Skip to content

Commit f11ff2d

Browse files
committed
Added actual test methods for JAX-RPC
1 parent a291e9f commit f11ff2d

4 files changed

Lines changed: 56 additions & 11 deletions

File tree

jaxrpc/jaxrpc-endpoint/build.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
keep = "true"
1212
base = "target"
1313
nonClassDir = "target"
14-
features = "rpcliteral"
1514
config = "./src/main/resources/HelloService.xml">
1615
</wscompile>
1716
</target>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl

jaxrpc/jaxrpc-endpoint/src/main/webapp/WEB-INF/web.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
2-
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
3+
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
4+
version="3.0">
35

46
<servlet>
57
<servlet-name>HelloServiceServlet</servlet-name>

jaxrpc/jaxrpc-endpoint/src/test/java/org/javaee7/jaxrpc/endpoint/HelloTest.java

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,43 @@
11
package org.javaee7.jaxrpc.endpoint;
22

3+
import static javax.xml.rpc.Call.SOAPACTION_URI_PROPERTY;
4+
import static javax.xml.rpc.Call.SOAPACTION_USE_PROPERTY;
5+
import static javax.xml.rpc.ParameterMode.IN;
36
import static org.jboss.shrinkwrap.api.ShrinkWrap.create;
7+
import static org.junit.Assert.assertEquals;
48

59
import java.io.File;
6-
7-
//import static org.junit.Assert.assertEquals;
8-
910
import java.net.MalformedURLException;
1011
import java.net.URL;
12+
import java.rmi.RemoteException;
13+
14+
import javax.xml.namespace.QName;
15+
import javax.xml.rpc.Call;
16+
import javax.xml.rpc.ServiceException;
17+
import javax.xml.rpc.ServiceFactory;
1118

1219
import org.jboss.arquillian.container.test.api.Deployment;
20+
import org.jboss.arquillian.container.test.api.RunAsClient;
1321
import org.jboss.arquillian.junit.Arquillian;
1422
import org.jboss.arquillian.test.api.ArquillianResource;
1523
import org.jboss.shrinkwrap.api.spec.WebArchive;
16-
import org.junit.Before;
1724
import org.junit.Test;
1825
import org.junit.runner.RunWith;
1926

2027
@RunWith(Arquillian.class)
2128
public class HelloTest {
2229

2330
private static final String WEBAPP_SRC = "src/main/webapp";
31+
private static final String ENCODING_STYLE_PROPERTY = "javax.xml.rpc.encodingstyle.namespace.uri";
32+
private static final String NS_XSD = "http://www.w3.org/2001/XMLSchema";
2433

2534
@ArquillianResource
2635
private URL url;
2736

37+
2838
@Deployment(testable = false)
2939
public static WebArchive createDeployment() {
30-
System.out.println("************************************************************");
40+
System.out.println("************** DEPLOYING ************************************");
3141

3242
WebArchive war =
3343
create(WebArchive.class)
@@ -44,13 +54,46 @@ public static WebArchive createDeployment() {
4454
return war;
4555
}
4656

47-
@Before
48-
public void setupClass() throws MalformedURLException {
57+
@Test
58+
@RunAsClient
59+
public void testHelloProxy() throws MalformedURLException, ServiceException, RemoteException {
60+
HelloService helloService = (HelloService)
61+
ServiceFactory.newInstance()
62+
.createService(
63+
new URL(url, "hello?wsdl"),
64+
new QName("urn:sample", "MyHelloService"))
65+
.getPort(
66+
new QName("urn:sample", "HelloServicePort"),
67+
HelloService.class);
68+
69+
String result = helloService.sayHello("Sailor");
70+
71+
assertEquals("Hello Sailor", result);
4972
}
5073

5174
@Test
52-
public void testHello() throws MalformedURLException {
75+
@RunAsClient
76+
public void testHelloDII() throws MalformedURLException, ServiceException, RemoteException {
77+
Call call = ServiceFactory.newInstance()
78+
.createService(new QName("MyHelloService"))
79+
.createCall(new QName("HelloServicePort"));
80+
81+
call.setTargetEndpointAddress(url + "hello");
82+
83+
call.setProperty(SOAPACTION_USE_PROPERTY, true);
84+
call.setProperty(SOAPACTION_URI_PROPERTY, "");
85+
call.setProperty(ENCODING_STYLE_PROPERTY, "http://schemas.xmlsoap.org/soap/encoding/");
86+
87+
call.setReturnType(new QName(NS_XSD, "string"));
88+
call.setOperationName(new QName("urn:sample", "sayHello"));
89+
call.addParameter("String_1", new QName(NS_XSD, "string"), IN);
90+
91+
String result = (String) call.invoke(new String[] { "Captain" });
92+
93+
assertEquals("Hello Captain", result);
5394
}
5495

5596

97+
98+
5699
}

0 commit comments

Comments
 (0)