Author: ropalka
Date: 2012-02-28 09:20:18 -0500 (Tue, 28 Feb 2012)
New Revision: 15771
Added:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ApplicationClient.java
Modified:
shared-testsuite/trunk/testsuite/src/test/ant-import/build-samples-jaxws.xml
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ServiceRefClientTestCase.java
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/samples/serviceref/META-INF/application-client.xml
Log:
[JBWS-3444] rewrite test case
Modified: shared-testsuite/trunk/testsuite/src/test/ant-import/build-samples-jaxws.xml
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/ant-import/build-samples-jaxws.xml 2012-02-28
11:08:55 UTC (rev 15770)
+++
shared-testsuite/trunk/testsuite/src/test/ant-import/build-samples-jaxws.xml 2012-02-28
14:20:18 UTC (rev 15771)
@@ -286,10 +286,10 @@
<include
name="org/jboss/test/ws/jaxws/samples/serviceref/ApplicationClient.class"/>
<include
name="org/jboss/test/ws/jaxws/samples/serviceref/EndpointService.class"/>
<include
name="org/jboss/test/ws/jaxws/samples/serviceref/Endpoint.class"/>
- <include
name="org/jboss/test/ws/appclient/AppclientKiller.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/servicref/ApplicationClient.class"/>
</fileset>
<manifest>
- <attribute name="main-class"
value="org.jboss.test.ws.appclient.AppclientKiller"/>
+ <attribute name="main-class"
value="org.jboss.test.ws.jaxws.samples.serviceref.ApplicationClient"/>
</manifest>
<metainf
dir="${tests.output.dir}/test-resources/jaxws/samples/serviceref/META-INF">
<include name="application-client.xml"/>
Added:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ApplicationClient.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ApplicationClient.java
(rev 0)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ApplicationClient.java 2012-02-28
14:20:18 UTC (rev 15771)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.serviceref;
+
+import java.util.ArrayList;
+
+import javax.naming.InitialContext;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.SOAPBinding;
+
+public class ApplicationClient
+{
+ public static void main(final String[] args) throws Exception
+ {
+ ArrayList<Endpoint> ports = new ArrayList<Endpoint>(2);
+ try
+ {
+ InitialContext iniCtx = new InitialContext();
+
ports.add((Endpoint)((Service)iniCtx.lookup("java:comp/env/service1")).getPort(Endpoint.class));
+
ports.add(((EndpointService)iniCtx.lookup("java:comp/env/service2")).getEndpointPort());
+ }
+ catch (Exception ex)
+ {
+ throw new WebServiceException(ex);
+ }
+ System.out.println("TEST START");
+ for (int i = 0; i < ports.size(); i++)
+ {
+ Endpoint port = (Endpoint)ports.get(i);
+
+ BindingProvider bp = (BindingProvider)port;
+ boolean mtomEnabled = ((SOAPBinding)bp.getBinding()).isMTOMEnabled();
+ boolean expectedSetting = (i==0) ? false : true;
+
+ if (mtomEnabled != expectedSetting)
+ throw new WebServiceException("MTOM settings
(enabled="+expectedSetting+") not overridden through service-ref");
+
+ String inStr = args[0];
+ String outStr = port.echo(inStr);
+ if (inStr.equals(outStr) == false)
+ throw new WebServiceException("Invalid echo return: " + inStr);
+ }
+ System.out.println("TEST END");
+ }
+}
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ServiceRefClientTestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ServiceRefClientTestCase.java 2012-02-28
11:08:55 UTC (rev 15770)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ServiceRefClientTestCase.java 2012-02-28
14:20:18 UTC (rev 15771)
@@ -21,7 +21,9 @@
*/
package org.jboss.test.ws.jaxws.samples.serviceref;
+import java.io.ByteArrayOutputStream;
import java.io.InputStream;
+import java.io.OutputStream;
import java.net.URL;
import javax.naming.InitialContext;
@@ -33,6 +35,7 @@
import junit.framework.Test;
import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestHelper;
import org.jboss.wsf.test.JBossWSTestSetup;
/**
@@ -47,7 +50,7 @@
public static Test suite()
{
- String archives =
"jaxws-samples-serviceref.war,jaxws-samples-serviceref-appclient.ear#jaxws-samples-serviceref-appclient.jar";
+ String archives = "jaxws-samples-serviceref.war";
return new JBossWSTestSetup(ServiceRefClientTestCase.class, archives);
}
@@ -73,36 +76,18 @@
public void testApplicationClient() throws Exception
{
- InitialContext iniCtx = null;
- try
- {
- iniCtx = getAppclientInitialContext();
- Service service = (Service) iniCtx.lookup("java:service2");
- Endpoint port = service.getPort(Endpoint.class);
- assertNotNull(port);
-
- if(isIntegrationNative())
- {
- BindingProvider bp = (BindingProvider)port;
- boolean mtomEnabled = ((SOAPBinding)bp.getBinding()).isMTOMEnabled();
- assertTrue("MTOM should be enabled on port", mtomEnabled);
- }
- else
- {
- // MTOM property at service-ref level not possible with sun-ri
- }
-
- String request = "ApplicationClient";
- String response = port.echo(request);
- assertEquals(response, request);
+ final OutputStream appclientOS = new ByteArrayOutputStream();
+
JBossWSTestHelper.deployAppclient("jaxws-samples-serviceref-appclient.ear#jaxws-samples-serviceref-appclient.jar",
appclientOS, "Hello World!");
+ // wait till appclient stops
+ String appclientLog = appclientOS.toString();
+ while (!appclientLog.contains("stopped in")) {
+ Thread.sleep(100);
+ appclientLog = appclientOS.toString();
}
- finally
- {
- if (iniCtx != null)
- {
- iniCtx.close();
- }
- }
+ // assert appclient logs
+ assertTrue(appclientLog.contains("TEST START"));
+ assertTrue(appclientLog.contains("TEST END"));
+ assertFalse(appclientLog.contains("not overridden through
service-ref"));
+ assertFalse(appclientLog.contains("Invalid echo return"));
}
-
}
Modified:
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/samples/serviceref/META-INF/application-client.xml
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/samples/serviceref/META-INF/application-client.xml 2012-02-28
11:08:55 UTC (rev 15770)
+++
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/samples/serviceref/META-INF/application-client.xml 2012-02-28
14:20:18 UTC (rev 15771)
@@ -7,14 +7,14 @@
<display-name>jaxws simple tests</display-name>
<service-ref>
- <service-ref-name>java:jboss/exported/service1</service-ref-name>
+ <service-ref-name>service1</service-ref-name>
<service-interface>javax.xml.ws.Service</service-interface>
<wsdl-file>META-INF/wsdl/Endpoint.wsdl</wsdl-file>
<service-qname
xmlns:ns1="http://serviceref.samples.jaxws.ws.test.jboss.org/"&...
</service-ref>
<service-ref>
- <service-ref-name>java:jboss/exported/service2</service-ref-name>
+ <service-ref-name>service2</service-ref-name>
<service-interface>org.jboss.test.ws.jaxws.samples.serviceref.EndpointService</service-interface>
<wsdl-file>META-INF/wsdl/Endpoint.wsdl</wsdl-file>
<service-qname
xmlns:ns1="http://serviceref.samples.jaxws.ws.test.jboss.org/"&...