e3467e6430b8b1879a5ae14e147e5077eefddbb1
[hc2vpp.git] /
1 /*
2  * Copyright (c) 2016 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.common.test.write;
18
19 import io.fd.hc2vpp.common.test.util.FutureProducer;
20 import io.fd.hc2vpp.common.test.util.NamingContextHelper;
21 import io.fd.honeycomb.translate.MappingContext;
22 import io.fd.honeycomb.translate.ModificationCache;
23 import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
24 import io.fd.honeycomb.translate.write.WriteContext;
25 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
26 import org.junit.Before;
27 import org.mockito.Mock;
28 import org.mockito.Mockito;
29 import org.mockito.MockitoAnnotations;
30
31 /**
32  * Generic test for classes implementing {@link WriterCustomizer} interface.
33  */
34 public abstract class WriterCustomizerTest implements FutureProducer,
35     NamingContextHelper {
36
37     @Mock
38     protected FutureJVppCore api;
39     @Mock
40     protected WriteContext writeContext;
41     @Mock
42     protected MappingContext mappingContext;
43
44     protected ModificationCache cache;
45
46     protected WriterCustomizerTest() {
47     }
48
49     @Before
50     public final void setUpParent() throws Exception {
51         MockitoAnnotations.initMocks(this);
52         cache = new ModificationCache();
53         Mockito.doReturn(cache).when(writeContext).getModificationCache();
54         Mockito.doReturn(mappingContext).when(writeContext).getMappingContext();
55         setUpTest();
56     }
57
58     /**
59      * Optional setup for subclasses. Invoked after parent initialization.
60      */
61     protected void setUpTest() throws Exception {
62         // this method would normally trigger this warning while compiling:
63         //
64         // "if test is using @RunWith(HoneycombTestRunner and if named setUp() :
65         // [JUnit4SetUpNotRun] setUpTest() method will not be run; Please add a @Before annotation"
66         //
67         // more details http://errorprone.info/bugpattern/JUnit4SetUpNotRun
68     }
69 }