Reduce log noise/warnings format to conventions
[so.git] / packages / arquillian-unit-tests / src / test / java / org / openecomp / mso / global_tests / soapui / SoapUiITCase.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 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.openecomp.mso.global_tests.soapui;
22
23 import static org.junit.Assert.*;
24
25 import java.io.File;
26 import java.io.IOException;
27 import java.lang.reflect.Method;
28 import java.nio.file.Files;
29 import java.nio.file.Paths;
30 import java.nio.file.StandardCopyOption;
31 import java.util.Map;
32
33 import org.jboss.arquillian.container.test.api.Deployment;
34 import org.jboss.arquillian.container.test.api.RunAsClient;
35 import org.jboss.arquillian.junit.Arquillian;
36 import org.jboss.shrinkwrap.api.Archive;
37 import org.jboss.shrinkwrap.api.ShrinkWrap;
38 import org.jboss.shrinkwrap.api.spec.WebArchive;
39 import org.junit.After;
40 import org.junit.AfterClass;
41 import org.junit.BeforeClass;
42 import org.junit.FixMethodOrder;
43 import org.junit.runners.MethodSorters;
44 import org.junit.Test;
45 import org.junit.runner.RunWith;
46
47 import org.openecomp.mso.global_tests.ArquillianPackagerForITCases;
48 import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStepResult;
49 import com.eviware.soapui.model.testsuite.TestAssertion;
50 import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus;
51 import com.eviware.soapui.tools.SoapUITestCaseRunner;
52
53 @RunWith(Arquillian.class)
54 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
55 public class SoapUiITCase {
56
57     private static String jbossHost = System.getProperty("docker.hostname");
58     private static String jbossPort = "18080";
59
60     @Deployment(name = "mso-api-handler-infra", testable = false)
61     public static Archive<?> createMsoApiHandlerInfraWarDeployment() {
62         System.out.println("Deploying ApiHandler Infra WAR on default server");
63         return ArquillianPackagerForITCases.createPackageFromExistingOne("../../mso-api-handlers/mso-api-handler-infra/target/", "mso-api-handler-infra*.war", "mso-api-handler-infra.war");
64     }
65
66     @Deployment(name = "mso-vnf-adapter", testable = false)
67     public static Archive<?> createMsoVnfAdapterWarDeployment() {
68         System.out.println("Deploying VNF Adapter WAR on default server");
69         return ArquillianPackagerForITCases.createPackageFromExistingOne("../../adapters/mso-vnf-adapter/target/", "mso-vnf-adapter*.war", "mso-vnf-adapter.war");
70     }
71
72     @Deployment(name = "mso-tenant-adapter", testable = false)
73     public static Archive<?> createMsoTenantAdapterWarDeployment() {
74         System.out.println("Deploying Tenant Adapter WAR on default server");
75         return ArquillianPackagerForITCases.createPackageFromExistingOne("../../adapters/mso-tenant-adapter/target/", "mso-tenant-adapter*.war", "mso-tenant-adapter.war");
76     }
77
78     @Deployment(name = "mso-sdnc-adapter", testable = false)
79     public static Archive<?> createMsoSdncAdapterWarDeployment() {
80         System.out.println("Deploying SDNC Adapter WAR on default server");
81         return ArquillianPackagerForITCases.createPackageFromExistingOne("../../adapters/mso-sdnc-adapter/target/", "mso-sdnc-adapter*.war", "mso-sdnc-adapter.war");
82     }
83
84     @Deployment(name = "mso-network-adapter", testable = false)
85     public static Archive<?> createMsoNetworkAdapterWarDeployment() {
86         System.out.println("Deploying Network Adapter WAR on default server");
87         return ArquillianPackagerForITCases.createPackageFromExistingOne("../../adapters/mso-network-adapter/target/", "mso-network-adapter*.war", "mso-network-adapter.war");
88     }
89
90     @Deployment(name = "mso-requests-db-adapter", testable = false)
91     public static Archive<?> createMsoRequestsDbAdapterWarDeployment() {
92         System.out.println("Deploying Requests DB Adapter WAR on default server");
93         return ArquillianPackagerForITCases.createPackageFromExistingOne("../../adapters/mso-requests-db-adapter/target/", "mso-requests-db-adapter*.war", "mso-requests-db-adapter.war");
94     }
95
96     @Deployment(name = "asdc-controller", testable = true)
97     public static Archive<?> createAsdcControllerWarDeployment() {
98         System.out.println("Deploying ASDC Controller WAR with additional resources on default server");
99
100         WebArchive warArchive = (WebArchive) ArquillianPackagerForITCases.createPackageFromExistingOne("../../asdc-controller/target/", "asdc-controller*.war", "asdc-controller.war");
101
102         // Take one war randomly to make arquilian happy
103
104
105         return warArchive;
106     }
107
108     @Deployment(name = "infrastructure-bpmn", testable = false)
109     public static Archive<?> createInfraBPMNDeployment() {
110         System.out.println("Deploying Infrastructure BPMN WAR on default server");
111         return ArquillianPackagerForITCases.createPackageFromExistingOne("../../bpmn/MSOInfrastructureBPMN/target/",
112                 "MSOInfrastructureBPMN*.war", "MSOInfrastructureBPMN.war");
113     }
114 /*
115     @Deployment(name = "SoapUIMocks", testable = false)
116     public static Archive <?> createSoapUIMocksWarDeployment () {
117
118         File file = new File ("src/test/resources/SoapUIMocks.war");
119
120         WebArchive archive = ShrinkWrap.create (WebArchive.class, "SoapUIMocks.war");
121
122         archive.merge ((ShrinkWrap.createFromZipFile (WebArchive.class, file)));
123
124         return archive;
125     }*/
126
127     @BeforeClass
128     public static void waitBeforeStart() throws InterruptedException {
129         Thread.currentThread().sleep(10000);
130         System.out.println("Executing " + SoapUiITCase.class.getName());
131
132     }
133
134     @Test
135     @RunAsClient
136     public void test01Healthcheck() {
137         SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
138         runner.setSettingsFile("./src/test/resources/SoapUI/soapui-settings.xml");
139         runner.setJUnitReport(true);
140         runner.setProjectFile("./src/test/resources/SoapUI/Healthcheck-soapui-project.xml");
141         runner.setOutputFolder("./target/surefire-reports");
142         String[] properties = new String[7];
143         properties[0] = "apihhost=" + jbossHost + ":" + jbossPort;
144         properties[1] = "jrahost=" + jbossHost + ":" + jbossPort;
145         properties[2] = "userlogin=sitecontrol";
146         properties[3] = "userpassword=Domain2.0!";
147         properties[4] = "bpmnhost=" + jbossHost + ":" + jbossPort;
148         properties[5] = "sitename=mso-docker";
149         properties[6] = "enableBpmn=false";
150         runner.setProjectProperties(properties);
151
152         try {
153             runner.setTestSuite("Healthcheck TestSuite");
154             runner.run();
155             Map<TestAssertion, WsdlTestStepResult> mapResult = runner.getAssertionResults();
156             for (Map.Entry<TestAssertion, WsdlTestStepResult> entry : mapResult.entrySet()) {
157                 assertTrue(entry.getValue().getStatus().equals(TestStepStatus.OK));
158             }
159             assertTrue(runner.getFailedTests().size() == 0);
160
161         } catch (Exception e) {
162             e.printStackTrace();
163             fail("Failure in SOAPUI Healthcheck");
164         }
165     }
166
167     @Test
168     @RunAsClient
169     public void test02ApiHandlerInfra() {
170         SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
171         runner.setSettingsFile("./src/test/resources/SoapUI/soapui-settings.xml");
172         runner.setJUnitReport(true);
173         runner.setProjectFile("./src/test/resources/SoapUI/Local-API-Handler-soapui-project.xml");
174         runner.setOutputFolder("./target/surefire-reports");
175         String[] properties = new String[3];
176         properties[0] = "host=" + jbossHost + ":" + jbossPort;
177         properties[1] = "user-infraportal=InfraPortalClient";
178         properties[2] = "password-infraportal=password1$";
179
180         runner.setProjectProperties(properties);
181
182         try {
183             runner.setTestSuite("simple_tests_endpoints");
184             runner.run();
185             Map<TestAssertion, WsdlTestStepResult> mapResult = runner.getAssertionResults();
186             for (Map.Entry<TestAssertion, WsdlTestStepResult> entry : mapResult.entrySet()) {
187                 assertTrue(entry.getValue().getStatus().equals(TestStepStatus.OK));
188             }
189             assertTrue(runner.getFailedTests().size() == 0);
190
191         } catch (Exception e) {
192             e.printStackTrace();
193             fail("Failure in SOAPUI ApiHandler Infra");
194         }
195     }
196
197     @Test
198     @RunAsClient
199     public void test03StartNetworkAdapter() {
200         SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
201         runner.setSettingsFile("./src/test/resources/SoapUI/soapui-settings.xml");
202         runner.setJUnitReport(true);
203         runner.setProjectFile("./src/test/resources/SoapUI/MSONetworkAdapter-soapui-project.xml");
204         runner.setOutputFolder("./target/surefire-reports");
205         String[] properties = new String[1];
206         properties[0] = "host=" + jbossHost + ":" + jbossPort;
207         runner.setProjectProperties(properties);
208
209
210         try {
211             runner.setTestSuite("MsoNetworkAdapter TestSuite");
212             runner.run();
213
214             Map<TestAssertion, WsdlTestStepResult> mapResult = runner.getAssertionResults();
215             for (Map.Entry<TestAssertion, WsdlTestStepResult> entry : mapResult.entrySet()) {
216                 assertTrue(entry.getValue().getStatus().equals(TestStepStatus.OK));
217             }
218             assertTrue(runner.getFailedTests().size() == 0);
219
220         } catch (Exception e) {
221             e.printStackTrace();
222             fail("Failure in SOAPUI NetworkAdapter");
223         }
224     }
225
226
227     @Test
228     @RunAsClient
229     public void test04StartVnfAdapter() {
230         SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
231         runner.setSettingsFile("./src/test/resources/SoapUI/soapui-settings.xml");
232         runner.setJUnitReport(true);
233         runner.setProjectFile("./src/test/resources/SoapUI/MSOVnfAdapter-soapui-project.xml");
234         runner.setOutputFolder("./target/surefire-reports");
235         String[] properties = new String[1];
236         properties[0] = "host=" + jbossHost + ":" + jbossPort;
237         runner.setProjectProperties(properties);
238
239         try {
240             runner.setTestSuite("MsoVnfAdapter TestSuite");
241             runner.run();
242
243             Map<TestAssertion, WsdlTestStepResult> mapResult = runner.getAssertionResults();
244             for (Map.Entry<TestAssertion, WsdlTestStepResult> entry : mapResult.entrySet()) {
245                 assertTrue(entry.getValue().getStatus().equals(TestStepStatus.OK));
246             }
247             assertTrue(runner.getFailedTests().size() == 0);
248
249         } catch (Exception e) {
250             e.printStackTrace();
251             fail("Failure in SOAPUI VnfAdapter");
252         }
253     }
254
255
256     @Test
257     @RunAsClient
258     public void test05StartTenantAdapter() {
259         SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
260         runner.setSettingsFile("./src/test/resources/SoapUI/soapui-settings.xml");
261         runner.setJUnitReport(true);
262         runner.setProjectFile("./src/test/resources/SoapUI/MSOTenantAdapter-soapui-project.xml");
263         runner.setOutputFolder("./target/surefire-reports");
264         String[] properties = new String[3];
265         properties[0] = "host=" + jbossHost + ":" + jbossPort;
266         properties[1] = "user-bpel=BPELClient";
267         properties[2] = "password-bpel=password1$";
268         runner.setProjectProperties(properties);
269
270         try {
271             runner.setTestSuite("MsoTenantAdapter TestSuite");
272             runner.run();
273
274             Map<TestAssertion, WsdlTestStepResult> mapResult = runner.getAssertionResults();
275             for (Map.Entry<TestAssertion, WsdlTestStepResult> entry : mapResult.entrySet()) {
276                 assertTrue(entry.getValue().getStatus().equals(TestStepStatus.OK));
277             }
278             assertTrue(runner.getFailedTests().size() == 0);
279
280         } catch (Exception e) {
281             e.printStackTrace();
282             fail("Failure in SOAPUI TenantAdapter");
283         }
284     }
285
286
287     @Test
288     @RunAsClient
289     public void test06StartRequestDBAdapter() {
290         SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
291         runner.setSettingsFile("./src/test/resources/SoapUI/soapui-settings.xml");
292         runner.setJUnitReport(true);
293         runner.setProjectFile("./src/test/resources/SoapUI/MsoRequestDB-soapui-project.xml");
294         runner.setOutputFolder("./target/surefire-reports");
295         String[] properties = new String[3];
296         properties[0] = "host=" + jbossHost + ":" + jbossPort;
297         properties[1] = "user-infraportal=InfraPortalClient";
298         properties[2] = "password-infraportal=password1$";
299         runner.setProjectProperties(properties);
300
301
302         try {
303             runner.setTestSuite("MsoRequestsDbAdapterImplPortBinding TestSuite");
304             runner.run();
305
306             Map<TestAssertion, WsdlTestStepResult> mapResult = runner.getAssertionResults();
307             for (Map.Entry<TestAssertion, WsdlTestStepResult> entry : mapResult.entrySet()) {
308                 assertTrue(entry.getValue().getStatus().equals(TestStepStatus.OK));
309             }
310             assertTrue(runner.getFailedTests().size() == 0);
311
312         } catch (Exception e) {
313             e.printStackTrace();
314             fail("Failure in SOAPUI RequestDB adapter");
315         }
316     }
317
318     @Test
319     @RunAsClient
320     public void test07MsoConfigEndpoints() {
321         SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
322         runner.setSettingsFile("./src/test/resources/SoapUI/soapui-settings.xml");
323         runner.setJUnitReport(true);
324         runner.setProjectFile("./src/test/resources/SoapUI/MSOConfig-soapui-project.xml");
325         runner.setOutputFolder("./target/surefire-reports");
326         String[] properties = new String[3];
327         properties[0] = "host=" + jbossHost + ":" + jbossPort;
328         properties[1] = "user-infraportal=InfraPortalClient";
329         properties[2] = "password-infraportal=password1$";
330         runner.setProjectProperties(properties);
331
332
333         try {
334             runner.setTestSuite("test_config_endpoints TestSuite");
335             runner.run();
336
337             Map<TestAssertion, WsdlTestStepResult> mapResult = runner.getAssertionResults();
338             for (Map.Entry<TestAssertion, WsdlTestStepResult> entry : mapResult.entrySet()) {
339                 assertTrue(entry.getValue().getStatus().equals(TestStepStatus.OK));
340             }
341             assertTrue(runner.getFailedTests().size() == 0);
342
343         } catch (Exception e) {
344             e.printStackTrace();
345             fail("Failure in SOAPUI MSOConfig Endpoints");
346         }
347     }
348 }