[jbossws-commits] JBossWS SVN: r6266 - in framework/trunk/src/test/java/org/jboss/test/ws/jaxws: jbws1904 and 1 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Mon Apr 7 16:01:09 EDT 2008


Author: richard.opalka at jboss.com
Date: 2008-04-07 16:01:08 -0400 (Mon, 07 Apr 2008)
New Revision: 6266

Modified:
   framework/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1809/JBWS1809TestCase.java
   framework/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1904/JBWS1904TestCase.java
   framework/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/WebFaultTestCase.java
Log:
[JBWS-2105] remove dependency on both native wsdl and schema models

Modified: framework/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1809/JBWS1809TestCase.java
===================================================================
--- framework/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1809/JBWS1809TestCase.java	2008-04-07 17:52:35 UTC (rev 6265)
+++ framework/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1809/JBWS1809TestCase.java	2008-04-07 20:01:08 UTC (rev 6266)
@@ -22,19 +22,15 @@
 package org.jboss.test.ws.jaxws.jbws1809;
 
 import junit.framework.Test;
+
 import org.jboss.wsf.common.DOMUtils;
 import org.jboss.wsf.test.JBossWSTest;
 import org.jboss.wsf.test.JBossWSTestSetup;
-import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory;
-import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
-import org.jboss.ws.metadata.wsdl.WSDLTypes;
-import org.jboss.ws.metadata.wsdl.DOMTypes;
-import org.jboss.ws.metadata.wsdl.XSModelTypes;
+
+import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.Node;
 
 import java.net.URL;
-import java.net.MalformedURLException;
 import java.util.Iterator;
 
 /**
@@ -55,16 +51,11 @@
    public void testWSDLAccess() throws Exception
    {
       URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-jbws1809/EndpointImpl?wsdl");
-      WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
-      WSDLDefinitions wsdlDefinitions = factory.parse(wsdlURL);
-      assertNotNull("Unable to read WSDL definitions", wsdlDefinitions);
 
-      XSModelTypes wsdlTypes = (XSModelTypes)wsdlDefinitions.getWsdlTypes();
-
-      // convert XSModelTypes to dom representation
-      // it's easier to consume...
-
-      Element types = DOMUtils.parse(wsdlTypes.getSchemaModel().serialize());            
+      Document doc = DOMUtils.getDocumentBuilder().parse(wsdlURL.toString());
+      Element types = (Element)((Element)doc.getDocumentElement()
+         .getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/", "types").item(0))
+            .getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "schema").item(0);
       Iterator it = DOMUtils.getChildElements(types, "complexType");
 
       boolean foundAttributeDeclaration = false;
@@ -87,6 +78,5 @@
       }
 
       assertTrue("JAXBIntros should turn the 'docRequest.name' property into a XML attribute", foundAttributeDeclaration);
-
    }
 }

Modified: framework/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1904/JBWS1904TestCase.java
===================================================================
--- framework/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1904/JBWS1904TestCase.java	2008-04-07 17:52:35 UTC (rev 6265)
+++ framework/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1904/JBWS1904TestCase.java	2008-04-07 20:01:08 UTC (rev 6266)
@@ -22,16 +22,18 @@
 package org.jboss.test.ws.jaxws.jbws1904;
 
 import java.net.URL;
+import java.util.Iterator;
 
+import javax.xml.namespace.QName;
+
 import junit.framework.Test;
 
-import org.apache.xerces.xs.XSTypeDefinition;
-import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
-import org.jboss.ws.metadata.wsdl.WSDLUtils;
-import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSModel;
-import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory;
+import org.jboss.wsf.common.DOMUtils;
 import org.jboss.wsf.test.JBossWSTest;
 import org.jboss.wsf.test.JBossWSTestSetup;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
 
 /**
  * [JBWS-1904] Explicitly set the namespace of a WebFault
@@ -51,14 +53,45 @@
    public void testWSDLSchema() throws Exception
    {
       URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-jbws1904?wsdl");
-      WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
-      WSDLDefinitions wsdlDefinitions = factory.parse(wsdlURL);
-      JBossXSModel xsModel = WSDLUtils.getSchemaModel(wsdlDefinitions.getWsdlTypes());
-      XSTypeDefinition typeDefinition = xsModel.getTypeDefinition("TestException", "http://org.jboss.ws/jbws1904/exceptions");
-      assertNotNull(typeDefinition);
-      typeDefinition = xsModel.getTypeDefinition("TestException", "http://org.jboss.ws/jbws1904");
-      assertNull(typeDefinition);
-      typeDefinition = xsModel.getTypeDefinition("TestException", "http://org.jboss.ws/jbws1904/faults");
-      assertNull(typeDefinition);
+      
+      Document doc = DOMUtils.getDocumentBuilder().parse(wsdlURL.toString());
+      NodeList schemas = ((Element)doc.getDocumentElement()
+         .getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/", "types").item(0))
+            .getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "schema");
+      
+      boolean firstTypeFound = false;
+      boolean secondTypeFound = false;
+      for (int i = 0; i < schemas.getLength(); i++)
+      {
+         Element schema = (Element)schemas.item(i);
+         if (schema.getAttribute("targetNamespace").equals("http://org.jboss.ws/jbws1904/faults"))
+         {
+            Iterator elements = DOMUtils.getChildElements(schema, new QName("http://www.w3.org/2001/XMLSchema", "element"));
+            while (elements.hasNext())
+            {
+               Element e = (Element)elements.next();
+               boolean nameEquals = e.getAttribute("name").equals("TestExceptionFault");
+               boolean typeEquals = e.getAttribute("type").endsWith(":TestException");
+               if (nameEquals && typeEquals)
+               {
+                  firstTypeFound = true;
+               }
+            }
+         }
+         if (schema.getAttribute("targetNamespace").equals("http://org.jboss.ws/jbws1904/exceptions"))
+         {
+            Iterator elements = DOMUtils.getChildElements(schema, new QName("http://www.w3.org/2001/XMLSchema", "complexType"));
+            while (elements.hasNext())
+            {
+               Element e = (Element)elements.next();
+               boolean nameEquals = e.getAttribute("name").equals("TestException");
+               if (nameEquals)
+               {
+                  secondTypeFound = true;
+               }
+            }
+         }
+      }
+      assertTrue(firstTypeFound && secondTypeFound);
    }
 }

Modified: framework/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/WebFaultTestCase.java
===================================================================
--- framework/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/WebFaultTestCase.java	2008-04-07 17:52:35 UTC (rev 6265)
+++ framework/trunk/src/test/java/org/jboss/test/ws/jaxws/webfault/WebFaultTestCase.java	2008-04-07 20:01:08 UTC (rev 6266)
@@ -22,19 +22,19 @@
 package org.jboss.test.ws.jaxws.webfault;
 
 import java.net.URL;
+import java.util.Iterator;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.Service;
 
 import junit.framework.Test;
 
-import org.apache.xerces.xs.XSElementDeclaration;
-import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
-import org.jboss.ws.metadata.wsdl.WSDLUtils;
-import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSModel;
-import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory;
+import org.jboss.wsf.common.DOMUtils;
 import org.jboss.wsf.test.JBossWSTest;
 import org.jboss.wsf.test.JBossWSTestSetup;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
 
 /**
  * Test the JSR-181 annotation: javax.jws.WebFault
@@ -61,25 +61,66 @@
     */
    public void testWebFaultElement() throws Exception
    {
-      JBossXSModel xsModel = getSchemaModel();
-      XSElementDeclaration myCustomFaultElement = xsModel.getElementDeclaration("myCustomFault", CUSTOM_FAULT_NS);
-      assertNotNull(myCustomFaultElement);
-      myCustomFaultElement = xsModel.getElementDeclaration("myCustomFault", TARGET_NS);
-      assertNull(myCustomFaultElement);
-      myCustomFaultElement = xsModel.getElementDeclaration("CustomException", CUSTOM_FAULT_NS);
-      assertNull(myCustomFaultElement);
-      XSElementDeclaration simpleExceptiontElement = xsModel.getElementDeclaration("SimpleException", TARGET_NS); //default to exception simple class name
-      assertNotNull(simpleExceptiontElement);
+      Document doc = DOMUtils.getDocumentBuilder().parse(new URL(endpointURL + "?wsdl").toString());
+      NodeList schemas = ((Element)doc.getDocumentElement()
+         .getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/", "types").item(0))
+            .getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "schema");
+
+      boolean firstElementFound = false;
+      boolean secondElementFound = false;
+      boolean firstTypeFound = false;
+      boolean secondTypeFound = false;
+      for (int i = 0; i < schemas.getLength(); i++)
+      {
+         Element schema = (Element)schemas.item(i);
+         if (schema.getAttribute("targetNamespace").equals("org.jboss.test.ws.jaxws.webfault.exceptions"))
+         {
+            Iterator elements = DOMUtils.getChildElements(schema, new QName("http://www.w3.org/2001/XMLSchema", "element"));
+            while (elements.hasNext())
+            {
+               Element e = (Element)elements.next();
+               boolean nameEquals = e.getAttribute("name").equals("myCustomFault");
+               boolean typeEquals = e.getAttribute("type").endsWith(":CustomException");
+               if (nameEquals && typeEquals)
+               {
+                  firstElementFound = true;
+               }
+            }
+         }
+         if (schema.getAttribute("targetNamespace").equals("http://webfault.jaxws.ws.test.jboss.org/"))
+         {
+            Iterator elements = DOMUtils.getChildElements(schema, new QName("http://www.w3.org/2001/XMLSchema", "element"));
+            while (elements.hasNext())
+            {
+               Element e = (Element)elements.next();
+               boolean nameEquals = e.getAttribute("name").equals("SimpleException");
+               boolean typeEquals = e.getAttribute("type").endsWith(":SimpleException");
+               if (nameEquals && typeEquals)
+               {
+                  secondElementFound = true;
+               }
+            }
+            elements = DOMUtils.getChildElements(schema, new QName("http://www.w3.org/2001/XMLSchema", "complexType"));
+            while (elements.hasNext())
+            {
+               Element e = (Element)elements.next();
+               boolean nameEquals = e.getAttribute("name").equals("CustomException");
+               if (nameEquals)
+               {
+                  firstTypeFound = true;
+               }
+               nameEquals = e.getAttribute("name").equals("SimpleException");
+               if (nameEquals)
+               {
+                  secondTypeFound = true;
+               }
+            }
+         }
+      }
+      assertTrue(firstElementFound && secondElementFound);
+      assertTrue(firstTypeFound && secondTypeFound);
    }
    
-   private JBossXSModel getSchemaModel() throws Exception
-   {
-      URL wsdlURL = new URL(endpointURL + "?wsdl");
-      WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
-      WSDLDefinitions wsdlDefinitions = factory.parse(wsdlURL);
-      return WSDLUtils.getSchemaModel(wsdlDefinitions.getWsdlTypes());
-   }
-   
    public void testInvocation() throws Exception
    {
       URL wsdlURL = new URL(endpointURL + "?wsdl");




More information about the jbossws-commits mailing list