|  | /* | 
|  | Copyright 2017 Google Inc. | 
|  |  | 
|  | Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | you may not use this file except in compliance with the License. | 
|  | You may obtain a copy of the License at | 
|  |  | 
|  | http://www.apache.org/licenses/LICENSE-2.0 | 
|  |  | 
|  | Unless required by applicable law or agreed to in writing, software | 
|  | distributed under the License is distributed on an "AS IS" BASIS, | 
|  | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | See the License for the specific language governing permissions and | 
|  | limitations under the License. | 
|  | */ | 
|  |  | 
|  | package mock | 
|  |  | 
|  | import ( | 
|  | "fmt" | 
|  |  | 
|  | "istio.io/mixer/pkg/adapter" | 
|  | ) | 
|  |  | 
|  | type mockEnvironment struct { | 
|  | log *mockLogger | 
|  | } | 
|  |  | 
|  | /* | 
|  | NewMockEnvironment returns an implementation of the Mixer adapter's "Env" class so that | 
|  | we can test without launching the whole thing. | 
|  | */ | 
|  | func NewMockEnvironment() adapter.Env { | 
|  | return &mockEnvironment{ | 
|  | log: &mockLogger{}, | 
|  | } | 
|  | } | 
|  |  | 
|  | func (e *mockEnvironment) Logger() adapter.Logger { | 
|  | return e.log | 
|  | } | 
|  |  | 
|  | func (e *mockEnvironment) ScheduleWork(fn adapter.WorkFunc) { | 
|  | go func() { | 
|  | fn() | 
|  | }() | 
|  | } | 
|  |  | 
|  | func (e *mockEnvironment) ScheduleDaemon(fn adapter.DaemonFunc) { | 
|  | go func() { | 
|  | fn() | 
|  | }() | 
|  | } | 
|  |  | 
|  | type mockLogger struct { | 
|  | } | 
|  |  | 
|  | func (l *mockLogger) VerbosityLevel(level adapter.VerbosityLevel) bool { | 
|  | return true | 
|  | } | 
|  |  | 
|  | func (l *mockLogger) Infof(format string, args ...interface{}) { | 
|  | fmt.Printf("INFO: "+format+"\n", args...) | 
|  | } | 
|  |  | 
|  | func (l *mockLogger) Warningf(format string, args ...interface{}) { | 
|  | fmt.Printf("WARN: "+format+"\n", args...) | 
|  | } | 
|  |  | 
|  | func (l *mockLogger) Errorf(format string, args ...interface{}) error { | 
|  | fmt.Printf("ERR: "+format+"\n", args...) | 
|  | return nil | 
|  | } |