Author: thomas.diesler(a)jboss.com
Date: 2008-05-01 15:57:30 -0400 (Thu, 01 May 2008)
New Revision: 6835
Added:
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/ClientTestCase.java
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/JMSClientTestCase.java
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/news/NewsTestCase.java
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/news/SecureNewsTestCase.java
Modified:
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/AddressingClient.java
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/AddressingClientTestCase.java
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/Client.java
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/samples/dar/WEB-INF/wsdl/reply.wsdl
Log:
Modified:
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/AddressingClient.java
===================================================================
---
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/AddressingClient.java 2008-05-01
19:48:31 UTC (rev 6834)
+++
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/AddressingClient.java 2008-05-01
19:57:30 UTC (rev 6835)
@@ -52,6 +52,7 @@
public class AddressingClient
{
protected DarEndpoint endpoint;
+ protected String replyToHost;
private static AddressingBuilder BUILDER;
private static final String WSA_TO =
"http://org.jboss.test.ws.jaxws.samples.dar/server";
@@ -63,17 +64,18 @@
BUILDER = AddressingBuilder.getAddressingBuilder();
}
- public AddressingClient(URL url)
+ public AddressingClient(URL url, String replyToHost)
{
DarService service = new DarService(url, new
QName("http://org.jboss.ws/samples/dar", "DarService"));
endpoint = service.getDarEndpointPort();
((StubExt)endpoint).setConfigName("Standard WSAddressing Client");
ClientHelper.setUsernamePassword((BindingProvider)endpoint, "kermit",
"thefrog");
+ this.replyToHost = replyToHost;
}
public void run(boolean asynch) throws Exception
{
- configureAddressingProperties((BindingProvider)endpoint, WSA_ACTION, WSA_TO,
"http://localhost:8080/dar-client/replyTo");
+ configureAddressingProperties((BindingProvider)endpoint, WSA_ACTION, WSA_TO,
"http://" + replyToHost + ":8080/dar-client/replyTo");
DarRequest request = ClientHelper.getRequest();
System.out.println(new Date() + " Sending request...");
if (asynch)
@@ -92,7 +94,7 @@
public void runOneway() throws Exception
{
- configureAddressingProperties((BindingProvider)endpoint, WSA_ACTION_ONEWAY, WSA_TO,
"http://localhost:8080/dar-client/replyService");
+ configureAddressingProperties((BindingProvider)endpoint, WSA_ACTION_ONEWAY, WSA_TO,
"http://" + replyToHost + ":8080/dar-client/replyService");
DarRequest request = ClientHelper.getRequest();
System.out.println(new Date() + " Sending request...");
endpoint.onewayProcess(request);
@@ -115,7 +117,7 @@
{
if (args.length == 1)
{
- AddressingClient client = new AddressingClient(new URL(args[0]));
+ AddressingClient client = new AddressingClient(new URL(args[0]),
"localhost");
System.out.println("* Synchronous invocation: ");
client.run(false);
System.out.println("\n* Asynchronous invocation: ");
Modified:
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/AddressingClientTestCase.java
===================================================================
---
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/AddressingClientTestCase.java 2008-05-01
19:48:31 UTC (rev 6834)
+++
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/AddressingClientTestCase.java 2008-05-01
19:57:30 UTC (rev 6835)
@@ -24,6 +24,7 @@
//$Id$
import java.net.URL;
+import java.util.Date;
import junit.framework.Test;
@@ -32,6 +33,8 @@
/**
* DAR addressing client; invokes the DAR addressing endpoint (sync, asynch and oneway)
+ * (this is actually a weak test since we can't check if the
+ * reply-to-service actually receives the response)
*
* @author Thomas.Diesler(a)jboss.org
* @since 24-Nov-2005
@@ -40,27 +43,36 @@
{
public static Test suite()
{
- return new JBossWSTestSetup(AddressingClientTestCase.class,
"jaxws-samples-dar.jar,jaxws-samples-dar-addressing-client.war");
+ return new JBossWSTestSetup(AddressingClientTestCase.class,
"jaxws-samples-dar-addressing-client.war,jaxws-samples-dar-addressing.jar");
}
public void testSync() throws Exception
{
URL wsdlURL = new URL("http://" + getServerHost() +
":8080/dar?wsdl");
- AddressingClient client = new AddressingClient(wsdlURL);
- //client.run(false);
+ AddressingClient client = new AddressingClient(wsdlURL, getServerHost());
+ Date start = new Date();
+ client.run(false);
+ Date stop = new Date();
+ assertTrue(stop.getTime() - start.getTime() > 3000);
}
public void testAsync() throws Exception
{
URL wsdlURL = new URL("http://" + getServerHost() +
":8080/dar?wsdl");
- AddressingClient client = new AddressingClient(wsdlURL);
- //client.run(true);
+ AddressingClient client = new AddressingClient(wsdlURL, getServerHost());
+ Date start = new Date();
+ client.run(true);
+ Date stop = new Date();
+ assertTrue(stop.getTime() - start.getTime() > 3000);
}
public void testOneWay() throws Exception
{
URL wsdlURL = new URL("http://" + getServerHost() +
":8080/dar?wsdl");
- AddressingClient client = new AddressingClient(wsdlURL);
- //client.runOneway();
+ AddressingClient client = new AddressingClient(wsdlURL, getServerHost());
+ Date start = new Date();
+ client.runOneway();
+ Date stop = new Date();
+ assertTrue(stop.getTime() - start.getTime() < 3000);
}
}
Modified:
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/Client.java
===================================================================
---
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/Client.java 2008-05-01
19:48:31 UTC (rev 6834)
+++
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/Client.java 2008-05-01
19:57:30 UTC (rev 6835)
@@ -52,7 +52,7 @@
ClientHelper.setUsernamePassword((BindingProvider)endpoint, "kermit",
"thefrog");
}
- public void run(boolean asynch) throws Exception
+ public DarResponse run(boolean asynch) throws Exception
{
DarRequest request = ClientHelper.getRequest();
System.out.println(new Date() + " Sending request...");
@@ -69,6 +69,7 @@
}
System.out.println(new Date() + " Response received: "+darResponse);
ClientHelper.printResponse(darResponse);
+ return darResponse;
}
public static void main(String[] args)
Copied:
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/ClientTestCase.java
(from rev 6834,
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/ClientTestCase.java)
===================================================================
---
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/ClientTestCase.java
(rev 0)
+++
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/ClientTestCase.java 2008-05-01
19:57:30 UTC (rev 6835)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.dar;
+
+//$Id$
+
+import java.net.URL;
+import java.util.Date;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+import org.jboss.test.ws.jaxws.samples.dar.generated.DarResponse;
+
+/**
+ * DAR client; invokes the DAR endpoint (sync, asynch)
+ *
+ * @author alessio.soldano(a)jboss.org
+ * @since 30-Apr-2008
+ */
+public class ClientTestCase extends JBossWSTest
+{
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(ClientTestCase.class,
"jaxws-samples-dar.jar");
+ }
+
+ public void testSync() throws Exception
+ {
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/dar?wsdl");
+ Client client = new Client(wsdlURL);
+ Date start = new Date();
+ DarResponse response = client.run(false);
+ Date stop = new Date();
+ assertTrue(stop.getTime() - start.getTime() > 3000);
+ assertNotNull(response);
+ }
+
+ public void testAsync() throws Exception
+ {
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/dar?wsdl");
+ Client client = new Client(wsdlURL);
+ Date start = new Date();
+ DarResponse response = client.run(true);
+ Date stop = new Date();
+ assertTrue(stop.getTime() - start.getTime() > 3000);
+ assertNotNull(response);
+ }
+}
Copied:
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/JMSClientTestCase.java
(from rev 6834,
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/dar/JMSClientTestCase.java)
===================================================================
---
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/JMSClientTestCase.java
(rev 0)
+++
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/dar/JMSClientTestCase.java 2008-05-01
19:57:30 UTC (rev 6835)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.dar;
+
+//$Id$
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Date;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * Invokes the DAR JMS client
+ * (this is actually a weak test since we don't check if the
+ * response queue actually receives the response)
+ *
+ * @author alessio.soldano(a)jboss.org
+ * @since 01-May-2008
+ */
+public class JMSClientTestCase extends JBossWSTest
+{
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(JMSClientTestCase.class,
"jaxws-samples-dar-jms-client.sar,jaxws-samples-dar-jms.jar");
+ }
+
+ public void test() throws Exception
+ {
+ String url = "http://" + getServerHost() +
":8080/dar-jms-client/JMSClient";
+ Date start = new Date();
+ HttpURLConnection connection = (HttpURLConnection)new URL(url).openConnection();
+ int responseCode = connection.getResponseCode();
+ if (responseCode != HttpURLConnection.HTTP_OK)
+ {
+ fail("Cannot access JMSClient servlet, responseCode == " +
responseCode);
+ }
+ BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
+ StringBuffer buffer = new StringBuffer();
+ String line;
+ while ((line = in.readLine()) != null) {
+ buffer.append(line + "\n");
+ }
+ assertTrue(buffer.toString().contains("Request message sent, doing something
interesting in the mean time... ;-) "));
+ Date stop = new Date();
+ assertTrue(stop.getTime() - start.getTime() < 3000);
+ }
+}
Copied:
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/news/NewsTestCase.java
(from rev 6834,
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/news/NewsTestCase.java)
===================================================================
---
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/news/NewsTestCase.java
(rev 0)
+++
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/news/NewsTestCase.java 2008-05-01
19:57:30 UTC (rev 6835)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.news;
+
+//$Id$
+
+import java.net.URL;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * Tests press agency and printer
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 01-May-2008
+ */
+public class NewsTestCase extends JBossWSTest
+{
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(NewsTestCase.class,
"jaxws-samples-news-step1-newspaper.jar");
+ }
+
+ public void testAgency() throws Exception
+ {
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/news/pressRelease?wsdl");
+ Agency agency = new Agency(wsdlURL);
+ agency.run("Press release title", "Press release body");
+ }
+
+ public void testPrinterSwa() throws Exception
+ {
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/news/newspaper/swa?wsdl");
+ Printer printer = new Printer(wsdlURL, false);
+ printer.run();
+ }
+
+ public void testPrinterMTOM() throws Exception
+ {
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/news/newspaper/mtom?wsdl");
+ Printer printer = new Printer(wsdlURL, true);
+ printer.run();
+ }
+}
Copied:
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/news/SecureNewsTestCase.java
(from rev 6834,
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/news/SecureNewsTestCase.java)
===================================================================
---
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/news/SecureNewsTestCase.java
(rev 0)
+++
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/news/SecureNewsTestCase.java 2008-05-01
19:57:30 UTC (rev 6835)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.news;
+
+//$Id$
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestHelper;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * Tests secure press agency
+ * (secure printer cannot be tested since it requires
+ * keystore & trustore in jboss-web tomcat configuration)
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 01-May-2008
+ */
+public class SecureNewsTestCase extends JBossWSTest
+{
+ public static Test suite()
+ {
+ addClientConfToClasspath("jaxws-samples-news-step2-agency.jar"); //this
way the ws-security conf is available
+ return new JBossWSTestSetup(SecureNewsTestCase.class,
"jaxws-samples-news-step2-newspaper.jar");
+ }
+
+ public void testAgency() throws Exception
+ {
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/news/pressRelease?wsdl");
+ SecureAgency agency = new SecureAgency(wsdlURL);
+ agency.run("Press release title", "Press release body");
+ }
+
+
+ protected static void addClientConfToClasspath(String s)
+ {
+ try
+ {
+ // wrap the classloader upfront to allow inclusion of the client.jar
+ JBossWSTestHelper helper = new JBossWSTestHelper();
+ ClassLoader parent = Thread.currentThread().getContextClassLoader();
+ URLClassLoader replacement = new URLClassLoader(new URL[] {
helper.getArchiveFile(s).toURL() }, parent);
+ Thread.currentThread().setContextClassLoader(replacement);
+
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalStateException(e);
+ }
+ }
+}
Modified:
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/samples/dar/WEB-INF/wsdl/reply.wsdl
===================================================================
---
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/samples/dar/WEB-INF/wsdl/reply.wsdl 2008-05-01
19:48:31 UTC (rev 6834)
+++
stack/native/branches/tdiesler/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/samples/dar/WEB-INF/wsdl/reply.wsdl 2008-05-01
19:57:30 UTC (rev 6835)
@@ -48,7 +48,8 @@
</binding>
<service name="DarReplyService">
<port binding="tns:DarReplyEndpointBinding"
name="DarReplyEndpointPort">
- <soap:address
location="http://localhost.localdomain:8080/dar-client/replyService"/>
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ <!-- <soap:address
location="http://localhost.localdomain:8080/dar-client/replyService"/>
-->
</port>
</service>
</definitions>