1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.jboss.as.quickstarts.wshelloworld;
18
19 import static org.junit.Assert.*;
20
21 import java.net.MalformedURLException;
22 import java.net.URL;
23 import java.util.ArrayList;
24 import java.util.List;
25
26 import org.jboss.arquillian.container.test.api.Deployment;
27 import org.jboss.arquillian.junit.Arquillian;
28 import org.jboss.arquillian.test.api.ArquillianResource;
29 import org.jboss.as.quickstarts.wshelloworld.HelloWorldService;
30 import org.jboss.shrinkwrap.api.ShrinkWrap;
31 import org.jboss.shrinkwrap.api.spec.WebArchive;
32 import org.junit.Before;
33 import org.junit.Test;
34 import org.junit.runner.RunWith;
35
36
37
38
39
40
41 @RunWith(Arquillian.class)
42 public class ClientArqTest {
43
44
45
46 private static final String APP_NAME = "jboss-helloworld-ws";
47
48
49
50 private static final String WSDL_PATH = "HelloWorldService?wsdl";
51
52 @ArquillianResource
53 private URL deploymentUrl;
54
55 private HelloWorldService client;
56
57 @Deployment(testable = false)
58 public static WebArchive createDeployment() {
59 return ShrinkWrap.create(WebArchive.class, APP_NAME + ".war").addPackage(HelloWorldService.class.getPackage());
60 }
61
62 @Before
63 public void setup() {
64 try {
65 client = new Client(new URL(deploymentUrl, WSDL_PATH));
66 } catch (MalformedURLException e) {
67 e.printStackTrace();
68 }
69 }
70
71 @Test
72 public void testHello() {
73 System.out.println("[Client] Requesting the WebService to say Hello.");
74
75
76 final String response = client.sayHello();
77 assertEquals(response, "Hello World!");
78
79 System.out.println("[WebService] " + response);
80
81 }
82
83 @Test
84 public void testHelloName() {
85 System.out.println("[Client] Requesting the WebService to say Hello to John.");
86
87
88 final String response = client.sayHelloToName("John");
89 assertEquals(response, "Hello John!");
90
91 System.out.println("[WebService] " + response);
92 }
93
94 @Test
95 public void testHelloNames() {
96 System.out.println("[Client] Requesting the WebService to say Hello to John, Mary and Mark.");
97
98
99 final List<String> names = new ArrayList<String>();
100 names.add("John");
101 names.add("Mary");
102 names.add("Mark");
103
104
105 final String response = client.sayHelloToNames(names);
106 assertEquals(response, "Hello John, Mary & Mark!");
107
108 System.out.println("[WebService] " + response);
109 }
110 }