f3f06195db1c66c3537dd8df97fc9c3653c240ea
[hc2vpp.git] /
1 /*
2  * Copyright (c) 2017 Cisco and/or its affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package io.fd.hc2vpp.docs.core.mock.binding;
18
19 import static io.fd.hc2vpp.docs.core.mock.binding.MockBindingModule.noOpProxy;
20
21 import com.google.inject.Provider;
22 import io.fd.hc2vpp.vppioam.impl.VppIoamModule;
23 import io.fd.vpp.jvpp.JVpp;
24 import io.fd.vpp.jvpp.JVppRegistry;
25 import io.fd.vpp.jvpp.ioamexport.future.FutureJVppIoamexportFacade;
26 import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampotFacade;
27 import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade;
28 import java.io.IOException;
29
30 /**
31  * Use to bypass jvpp registration
32  */
33 public class MockIoamModule extends VppIoamModule {
34
35     public MockIoamModule() {
36         super(MockTraceProvider.class, MockPotProvider.class, MockExportProvider.class);
37     }
38
39     private static class MockTraceProvider implements Provider<FutureJVppIoamtraceFacade> {
40         @Override
41         public FutureJVppIoamtraceFacade get() {
42             try {
43                 return new FutureJVppIoamtraceFacade(noOpProxy(JVppRegistry.class), noOpProxy(JVpp.class));
44             } catch (IOException e) {
45                 throw new IllegalStateException(e);
46             }
47         }
48     }
49
50     private static class MockPotProvider implements Provider<FutureJVppIoampotFacade> {
51
52         @Override
53         public FutureJVppIoampotFacade get() {
54             try {
55                 return new FutureJVppIoampotFacade(noOpProxy(JVppRegistry.class), noOpProxy(JVpp.class));
56             } catch (IOException e) {
57                 throw new IllegalStateException(e);
58             }
59         }
60     }
61
62     private static class MockExportProvider implements Provider<FutureJVppIoamexportFacade> {
63
64         @Override
65         public FutureJVppIoamexportFacade get() {
66             try {
67                 return new FutureJVppIoamexportFacade(noOpProxy(JVppRegistry.class), noOpProxy(JVpp.class));
68             } catch (IOException e) {
69                 throw new IllegalStateException(e);
70             }
71         }
72     }
73 }