4f0a0fc871ea373807fca27e388a49b39b36bcb6
[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.nat.NatModule;
23 import io.fd.vpp.jvpp.JVpp;
24 import io.fd.vpp.jvpp.JVppRegistry;
25 import io.fd.vpp.jvpp.nat.future.FutureJVppNatFacade;
26 import java.io.IOException;
27
28 /**
29  * Use to bypass jvpp registration
30  */
31 public class MockNatModule extends NatModule {
32
33     public MockNatModule() {
34         super(MockJVppNatProvider.class);
35     }
36
37     private static class MockJVppNatProvider implements Provider<FutureJVppNatFacade> {
38
39         @Override
40         public FutureJVppNatFacade get() {
41             try {
42                 return new FutureJVppNatFacade(noOpProxy(JVppRegistry.class), noOpProxy(JVpp.class));
43             } catch (IOException e) {
44                 throw new IllegalStateException(e);
45             }
46         }
47     }
48 }