Author: alessio.soldano(a)jboss.com
Date: 2008-10-30 15:57:33 -0400 (Thu, 30 Oct 2008)
New Revision: 8608
Modified:
stack/metro/trunk/modules/testsuite/metro-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2206/JBWS2206TestCase.java
Log:
[JBWS-2206][JBWS-2374] Performing a real test in JBWS2206TestCase
Modified:
stack/metro/trunk/modules/testsuite/metro-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2206/JBWS2206TestCase.java
===================================================================
---
stack/metro/trunk/modules/testsuite/metro-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2206/JBWS2206TestCase.java 2008-10-30
19:56:13 UTC (rev 8607)
+++
stack/metro/trunk/modules/testsuite/metro-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2206/JBWS2206TestCase.java 2008-10-30
19:57:33 UTC (rev 8608)
@@ -24,12 +24,23 @@
import junit.framework.Test;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestSetup;
-import org.jboss.test.ws.jaxws.jbws1871.JBWS1871EndpointImplService;
-import org.jboss.test.ws.jaxws.jbws1871.JBWS1871Endpoint;
+import javax.wsdl.Definition;
+import javax.wsdl.Types;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.extensions.schema.SchemaImport;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
import javax.xml.ws.Service;
import javax.xml.namespace.QName;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
import java.net.URL;
+import java.util.List;
+import java.util.Map;
public class JBWS2206TestCase extends JBossWSTest
{
@@ -40,15 +51,47 @@
public void testClientProxy() throws Exception
{
- Service service = Service.create(
- new
URL("http://"+getServerHost()+":8080/jaxws-jbws2206/MetroTestServiceBean?wsdl"),
- new QName("http://com.acme.metroexceptiontest/",
"MetroTestService")
- );
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-jbws2206/MetroTestServiceBean?wsdl");
+ Service service = Service.create(wsdlURL, new
QName("http://com.acme.metroexceptiontest/", "MetroTestService"));
MetroTestPortType port = service.getPort(MetroTestPortType.class);
String res = port.helloWorld();
assertEquals("HelloWorld", res);
+ }
- System.out.println("FIXME JBWS2206: WSDL imports are not replaced with
absolute path");
+ public void testImportedDocument() throws Exception
+ {
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-jbws2206/MetroTestServiceBean?wsdl");
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ Definition wsdlDefinition = wsdlReader.readWSDL(wsdlURL.toString());
+ assertNotNull(wsdlDefinition);
+ Types types = wsdlDefinition.getTypes();
+ Map<String, List<SchemaImport>> map = null;
+ for (ExtensibilityElement el :
(List<ExtensibilityElement>)types.getExtensibilityElements())
+ {
+ if (el instanceof Schema)
+ {
+ map = (Map<String,
List<SchemaImport>>)((Schema)el).getImports();
+ }
+ }
+ assertNotNull(map);
+ SchemaImport schemaImport =
map.get("http://com.acme.metroexceptiontest/").iterator().next();
+ assertNotNull(schemaImport);
+ String schemaLocation = schemaImport.getSchemaLocationURI();
+ assertNotNull(schemaLocation);
+ assertTrue(schemaLocation.startsWith("http://" + getServerHost()));
//check absolute url
+
+
+ HttpURLConnection con = (HttpURLConnection)new
URL(schemaLocation).openConnection();
+ BufferedReader isr = new BufferedReader(new
InputStreamReader(con.getInputStream()));
+ String s = isr.readLine();
+ StringBuilder sb = new StringBuilder();
+ while (s != null)
+ {
+ sb.append(s);
+ sb.append("\n");
+ s = isr.readLine();
+ }
+ assertTrue(sb.toString().contains("MetroTestFaultInfo"));
}
}
Show replies by date