replace all fixed wiremock ports
[so.git] / asdc-controller / src / test / java / org / onap / so / asdc / BaseTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.asdc;
22
23 import static org.mockito.Mockito.reset;
24
25 import org.junit.After;
26 import org.junit.runner.RunWith;
27 import org.onap.so.asdc.installer.ToscaResourceStructure;
28 import org.onap.so.asdc.installer.VfResourceStructure;
29 import org.onap.so.asdc.installer.heat.ToscaResourceInstaller;
30 import org.onap.so.asdc.tenantIsolation.WatchdogDistribution;
31 import org.onap.so.spring.SpringContextHelper;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.beans.factory.annotation.Value;
34 import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;
35 import org.springframework.boot.test.context.SpringBootTest;
36 import org.springframework.boot.test.mock.mockito.MockBean;
37 import org.springframework.boot.test.mock.mockito.SpyBean;
38 import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
39 import org.springframework.test.context.ActiveProfiles;
40 import org.springframework.test.context.ContextConfiguration;
41 import org.springframework.test.context.junit4.SpringRunner;
42
43 import com.github.tomakehurst.wiremock.WireMockServer;
44
45 @RunWith(SpringRunner.class)
46 @SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
47 @ActiveProfiles("test")
48 @ContextConfiguration(classes = SpringContextHelper.class, initializers = ConfigFileApplicationContextInitializer.class)
49 @AutoConfigureWireMock(port = 0)
50 public abstract class BaseTest {
51         @MockBean
52         protected VfResourceStructure vfResourceStructure;
53         @MockBean
54         protected ToscaResourceStructure toscaResourceStruct;
55         @SpyBean
56         protected WatchdogDistribution watchdogDistributionSpy;
57         @SpyBean
58         protected ToscaResourceInstaller toscaInstaller;
59         @Autowired
60         protected WireMockServer wireMockServer;
61         
62         @Value("${wiremock.server.port}")
63     protected String wireMockPort;
64
65         @After
66         public void after() {
67                 reset(vfResourceStructure);
68                 reset(toscaResourceStruct);
69         }
70 }