b7a3b04d96dce5114face3a6f2ec10f91ab34484
[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="common-bpmn",testable=false)
109         public static Archive<?> createCommonBPMNDeployment () {
110                 System.out.println("Deploying Common BPMN WAR on default server");
111                 return ArquillianPackagerForITCases.createPackageFromExistingOne("../../bpmn/MSOCommonBPMN/target/", "MSOCommonBPMN*.war", "MSOCommonBPMN.war");
112         }
113         
114         @Deployment(name = "infrastructure-bpmn", testable = false)
115         public static Archive<?> createInfraBPMNDeployment() {
116             System.out.println("Deploying Infrastructure BPMN WAR on default server");
117             return ArquillianPackagerForITCases.createPackageFromExistingOne("../../bpmn/MSOInfrastructureBPMN/target/",
118                     "MSOInfrastructureBPMN*.war", "MSOInfrastructureBPMN.war");
119         }
120 /*
121     @Deployment(name = "SoapUIMocks", testable = false)
122     public static Archive <?> createSoapUIMocksWarDeployment () {
123
124         File file = new File ("src/test/resources/SoapUIMocks.war");
125
126         WebArchive archive = ShrinkWrap.create (WebArchive.class, "SoapUIMocks.war");
127
128         archive.merge ((ShrinkWrap.createFromZipFile (WebArchive.class, file)));
129
130         return archive;
131     }*/
132
133     @BeforeClass
134     public static void waitBeforeStart () throws InterruptedException {
135         Thread.currentThread().sleep(10000);
136         System.out.println ("Executing " + SoapUiITCase.class.getName ());
137        
138     }
139
140     @Test
141     @RunAsClient
142     public void test01Healthcheck () {
143         SoapUITestCaseRunner runner = new SoapUITestCaseRunner ();
144         runner.setSettingsFile("./src/test/resources/SoapUI/soapui-settings.xml");
145         runner.setJUnitReport(true);
146         runner.setProjectFile ("./src/test/resources/SoapUI/Healthcheck-soapui-project.xml");
147         runner.setOutputFolder ("./target/surefire-reports");
148         String[] properties = new String[7];
149         properties[0] = "apihhost="+jbossHost+":"+jbossPort;
150         properties[1] = "jrahost="+jbossHost+":"+jbossPort;
151         properties[2] = "userlogin=sitecontrol";
152         properties[3] = "userpassword=Domain2.0!";
153         properties[4] = "bpmnhost="+jbossHost+":"+jbossPort;
154         properties[5] = "sitename=mso-docker";
155         properties[6] = "enableBpmn=false";
156         runner.setProjectProperties (properties);
157
158         try {
159             runner.setTestSuite ("Healthcheck TestSuite");
160             runner.run ();
161             Map<TestAssertion,WsdlTestStepResult> mapResult= runner.getAssertionResults();
162             for(Map.Entry<TestAssertion,WsdlTestStepResult> entry : mapResult.entrySet()) {
163                 assertTrue(entry.getValue().getStatus().equals(TestStepStatus.OK));
164             }
165             assertTrue (runner.getFailedTests ().size () == 0);
166
167         } catch (Exception e) {
168             e.printStackTrace ();
169             fail("Failure in SOAPUI Healthcheck");
170         }
171     }
172
173     @Test
174     @RunAsClient
175     public void test02ApiHandlerInfra () {
176         SoapUITestCaseRunner runner = new SoapUITestCaseRunner ();
177         runner.setSettingsFile("./src/test/resources/SoapUI/soapui-settings.xml");
178         runner.setJUnitReport(true);
179         runner.setProjectFile ("./src/test/resources/SoapUI/Local-API-Handler-soapui-project.xml");
180         runner.setOutputFolder ("./target/surefire-reports");
181         String[] properties = new String[3];
182         properties[0] = "host="+jbossHost+":"+jbossPort;
183         properties[1] = "user-infraportal=InfraPortalClient";
184         properties[2] = "password-infraportal=password1$";
185
186         runner.setProjectProperties (properties);
187
188         try {
189             runner.setTestSuite ("simple_tests_endpoints");
190             runner.run ();
191             Map<TestAssertion,WsdlTestStepResult> mapResult= runner.getAssertionResults();
192             for(Map.Entry<TestAssertion,WsdlTestStepResult> entry : mapResult.entrySet()) {
193                 assertTrue(entry.getValue().getStatus().equals(TestStepStatus.OK));
194             }
195             assertTrue (runner.getFailedTests ().size () == 0);
196
197         } catch (Exception e) {
198             e.printStackTrace ();
199             fail("Failure in SOAPUI ApiHandler Infra");
200         }
201     }
202
203     @Test
204     @RunAsClient
205     public void test03StartNetworkAdapter () {
206         SoapUITestCaseRunner runner = new SoapUITestCaseRunner ();
207         runner.setSettingsFile("./src/test/resources/SoapUI/soapui-settings.xml");
208         runner.setJUnitReport(true);
209         runner.setProjectFile ("./src/test/resources/SoapUI/MSONetworkAdapter-soapui-project.xml");
210         runner.setOutputFolder ("./target/surefire-reports");
211         String[] properties = new String[1];
212         properties[0] = "host="+jbossHost+":"+jbossPort;
213         runner.setProjectProperties (properties);
214
215
216         try {
217                 runner.setTestSuite ("MsoNetworkAdapter TestSuite");
218                 runner.run ();
219
220                 Map<TestAssertion,WsdlTestStepResult> mapResult= runner.getAssertionResults();
221                 for(Map.Entry<TestAssertion,WsdlTestStepResult> entry : mapResult.entrySet()) {
222                         assertTrue(entry.getValue().getStatus().equals(TestStepStatus.OK));
223                 }
224                 assertTrue (runner.getFailedTests ().size () == 0);
225
226         } catch (Exception e) {
227             e.printStackTrace ();
228                 fail("Failure in SOAPUI NetworkAdapter");
229         }
230     }
231
232
233     @Test
234     @RunAsClient
235     public void test04StartVnfAdapter () {
236         SoapUITestCaseRunner runner = new SoapUITestCaseRunner ();
237         runner.setSettingsFile("./src/test/resources/SoapUI/soapui-settings.xml");
238         runner.setJUnitReport(true);
239         runner.setProjectFile ("./src/test/resources/SoapUI/MSOVnfAdapter-soapui-project.xml");
240         runner.setOutputFolder ("./target/surefire-reports");
241         String[] properties = new String[1];
242         properties[0] = "host="+jbossHost+":"+jbossPort;
243         runner.setProjectProperties (properties);
244
245         try {
246             runner.setTestSuite ("MsoVnfAdapter TestSuite");
247             runner.run ();
248
249             Map<TestAssertion,WsdlTestStepResult> mapResult= runner.getAssertionResults();
250             for(Map.Entry<TestAssertion,WsdlTestStepResult> entry : mapResult.entrySet()) {
251                 assertTrue(entry.getValue().getStatus().equals(TestStepStatus.OK));
252             }
253             assertTrue (runner.getFailedTests ().size () == 0);
254
255         } catch (Exception e) {
256             e.printStackTrace ();
257             fail("Failure in SOAPUI VnfAdapter");
258         }
259     }
260
261
262     @Test
263     @RunAsClient
264     public void test05StartTenantAdapter () {
265         SoapUITestCaseRunner runner = new SoapUITestCaseRunner ();
266         runner.setSettingsFile("./src/test/resources/SoapUI/soapui-settings.xml");
267         runner.setJUnitReport(true);
268         runner.setProjectFile ("./src/test/resources/SoapUI/MSOTenantAdapter-soapui-project.xml");
269         runner.setOutputFolder ("./target/surefire-reports");
270         String[] properties = new String[3];
271         properties[0] = "host="+jbossHost+":"+jbossPort;
272         properties[1] = "user-bpel=BPELClient";
273         properties[2] = "password-bpel=password1$";
274         runner.setProjectProperties (properties);
275
276         try {
277             runner.setTestSuite ("MsoTenantAdapter TestSuite");
278             runner.run ();
279
280             Map<TestAssertion,WsdlTestStepResult> mapResult= runner.getAssertionResults();
281             for(Map.Entry<TestAssertion,WsdlTestStepResult> entry : mapResult.entrySet()) {
282                 assertTrue(entry.getValue().getStatus().equals(TestStepStatus.OK));
283             }
284             assertTrue (runner.getFailedTests ().size () == 0);
285
286         } catch (Exception e) {
287             e.printStackTrace ();
288             fail("Failure in SOAPUI TenantAdapter");
289         }
290     }
291
292
293     @Test
294     @RunAsClient
295     public void test06StartRequestDBAdapter () {
296         SoapUITestCaseRunner runner = new SoapUITestCaseRunner ();
297         runner.setSettingsFile("./src/test/resources/SoapUI/soapui-settings.xml");
298         runner.setJUnitReport(true);
299         runner.setProjectFile ("./src/test/resources/SoapUI/MsoRequestDB-soapui-project.xml");
300         runner.setOutputFolder ("./target/surefire-reports");
301         String[] properties = new String[3];
302         properties[0] = "host="+jbossHost+":"+jbossPort;
303         properties[1] = "user-infraportal=InfraPortalClient";
304         properties[2] = "password-infraportal=password1$";
305         runner.setProjectProperties (properties);
306
307
308         try {
309             runner.setTestSuite ("MsoRequestsDbAdapterImplPortBinding TestSuite");
310             runner.run ();
311
312             Map<TestAssertion,WsdlTestStepResult> mapResult= runner.getAssertionResults();
313             for(Map.Entry<TestAssertion,WsdlTestStepResult> entry : mapResult.entrySet()) {
314                 assertTrue(entry.getValue().getStatus().equals(TestStepStatus.OK));
315             }
316             assertTrue (runner.getFailedTests ().size () == 0);
317
318         } catch (Exception e) {
319             e.printStackTrace ();
320                 fail("Failure in SOAPUI RequestDB adapter");
321         }
322     }
323
324     @Test
325     @RunAsClient
326     public void test07MsoConfigEndpoints () {
327         SoapUITestCaseRunner runner = new SoapUITestCaseRunner ();
328                 runner.setSettingsFile("./src/test/resources/SoapUI/soapui-settings.xml");
329                 runner.setJUnitReport(true);
330         runner.setProjectFile ("./src/test/resources/SoapUI/MSOConfig-soapui-project.xml");
331         runner.setOutputFolder ("./target/surefire-reports");
332         String[] properties = new String[3];
333         properties[0] = "host="+jbossHost+":"+jbossPort;
334         properties[1] = "user-infraportal=InfraPortalClient";
335         properties[2] = "password-infraportal=password1$";
336         runner.setProjectProperties (properties);
337
338
339         try {
340             runner.setTestSuite ("test_config_endpoints TestSuite");
341             runner.run ();
342
343             Map<TestAssertion,WsdlTestStepResult> mapResult= runner.getAssertionResults();
344             for(Map.Entry<TestAssertion,WsdlTestStepResult> entry : mapResult.entrySet()) {
345                 assertTrue(entry.getValue().getStatus().equals(TestStepStatus.OK));
346             }
347             assertTrue (runner.getFailedTests ().size () == 0);
348
349         } catch (Exception e) {
350             e.printStackTrace ();
351                 fail("Failure in SOAPUI MSOConfig Endpoints");
352         }
353     }
354 }