geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r702930 - in /geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests: wsa-ear/src/test/java/org/apache/geronimo/jaxws/wsa/ wsa-ejb/src/main/java/org/apache/geronimo/jaxws/test/ wsa-test-war/src/main/java/org/apache/geronimo/j...
Date Wed, 08 Oct 2008 17:21:48 GMT
Author: gawor
Date: Wed Oct  8 10:21:47 2008
New Revision: 702930

URL: http://svn.apache.org/viewvc?rev=702930&view=rev
Log:
add a test to check for wsa:Action attribute and wsa:UseAddressing element in WSDL

Modified:
    geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-ear/src/test/java/org/apache/geronimo/jaxws/wsa/WSATest.java
    geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-ejb/src/main/java/org/apache/geronimo/jaxws/test/CalculatorBean.java
    geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-test-war/src/main/java/org/apache/geronimo/jaxws/wsa/TestServlet.java
    geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-test-war/src/main/java/org/apache/geronimo/jaxws/wsa/TestUtils.java
    geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-war/src/main/java/org/apache/geronimo/jaxws/test/CalculatorImpl.java

Modified: geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-ear/src/test/java/org/apache/geronimo/jaxws/wsa/WSATest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-ear/src/test/java/org/apache/geronimo/jaxws/wsa/WSATest.java?rev=702930&r1=702929&r2=702930&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-ear/src/test/java/org/apache/geronimo/jaxws/wsa/WSATest.java
(original)
+++ geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-ear/src/test/java/org/apache/geronimo/jaxws/wsa/WSATest.java
Wed Oct  8 10:21:47 2008
@@ -85,6 +85,11 @@
     public void testReferencePropertiesDispatch() throws Exception {
         runTest("testReferencePropertiesDispatch");
     }
+    
+    @Test
+    public void testWSDL() throws Exception {
+        runTest("testWSDL");
+    }
 
     protected void runTest(String testName) throws Exception {
         String warName = System.getProperty("webAppName");

Modified: geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-ejb/src/main/java/org/apache/geronimo/jaxws/test/CalculatorBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-ejb/src/main/java/org/apache/geronimo/jaxws/test/CalculatorBean.java?rev=702930&r1=702929&r2=702930&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-ejb/src/main/java/org/apache/geronimo/jaxws/test/CalculatorBean.java
(original)
+++ geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-ejb/src/main/java/org/apache/geronimo/jaxws/test/CalculatorBean.java
Wed Oct  8 10:21:47 2008
@@ -24,6 +24,7 @@
 import javax.ejb.Stateless;
 import javax.jws.HandlerChain;
 import javax.jws.WebService;
+import javax.xml.ws.Action;
 import javax.xml.ws.WebServiceContext;
 import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.soap.Addressing;
@@ -41,6 +42,7 @@
     @Resource
     private WebServiceContext context;
 
+    @Action(input="http://geronimo.apache.org/calculator/CalculatorPortType/getmyepr")
     public W3CEndpointReference getEPR() {
         return (W3CEndpointReference)context.getEndpointReference();
     }

Modified: geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-test-war/src/main/java/org/apache/geronimo/jaxws/wsa/TestServlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-test-war/src/main/java/org/apache/geronimo/jaxws/wsa/TestServlet.java?rev=702930&r1=702929&r2=702930&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-test-war/src/main/java/org/apache/geronimo/jaxws/wsa/TestServlet.java
(original)
+++ geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-test-war/src/main/java/org/apache/geronimo/jaxws/wsa/TestServlet.java
Wed Oct  8 10:21:47 2008
@@ -21,6 +21,8 @@
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.HttpURLConnection;
+import java.net.URL;
 import java.text.MessageFormat;
 import java.util.UUID;
 
@@ -28,6 +30,14 @@
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.Input;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
 import javax.xml.namespace.QName;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.ws.BindingProvider;
@@ -43,23 +53,27 @@
 
 import org.apache.geronimo.calculator.Calculator;
 import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
            
 public abstract class TestServlet extends HttpServlet {
               
+    private static final String NAMESPACE = 
+        "http://geronimo.apache.org/calculator";
+    
     private static final QName PORT = 
-        new QName("http://geronimo.apache.org/calculator", "CalculatorPort");
+        new QName(NAMESPACE, "CalculatorPort");
     
     private static final QName SERVICE = 
-        new QName("http://geronimo.apache.org/calculator", "CalculatorService");
+        new QName(NAMESPACE, "CalculatorService");
         
     private static final String BASE_ACTION = 
         "http://geronimo.apache.org/calculator/Calculator";
     
     private static final String MULTIPLY_REQUEST_ACTION =
-        "http://geronimo.apache.org/calculator/Calculator/multiply";
+        "http://geronimo.apache.org/calculator/Calculator/multiplyRequest";
     
     private static final String ADD_REQUEST_ACTION =
-        "http://geronimo.apache.org/calculator/Calculator/add";
+        "http://geronimo.apache.org/calculator/Calculator/addRequest";
         
     public static final String MSG1 = 
         "<?xml version=\"1.0\"?><S:Envelope " +
@@ -278,6 +292,43 @@
         Assert.assertEquals(12, calc.add(6, 6));
     }
     
+    public void testWSDL() throws Exception {
+        URL url = new URL(this.address + "?wsdl");
+        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+        conn.setConnectTimeout(30 * 1000);
+        conn.setReadTimeout(30 * 1000);
+        conn.setUseCaches(false);
+
+        QName useAddressing = new QName("http://www.w3.org/2006/05/addressing/wsdl", "UsingAddressing");
+        QName actionAttr = new QName("http://www.w3.org/2006/05/addressing/wsdl", "Action");
+        
+        WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+        try {
+            Definition def = 
+                wsdlReader.readWSDL(null, new InputSource(conn.getInputStream()));
+            
+            // check for right wsa:Action element
+            Assert.assertEquals(1, def.getPortTypes().size());
+            PortType portType = (PortType)def.getPortTypes().values().iterator().next();
+            Assert.assertEquals(3, portType.getOperations().size());
+            Operation operation1 = portType.getOperation("getEPR", null, null);
+            Assert.assertNotNull("operation", operation1);
+            Input input1 = operation1.getInput();
+            Assert.assertNotNull("input", input1);
+            Object action = input1.getExtensionAttribute(actionAttr);
+            Assert.assertNotNull("action", action);
+            Assert.assertEquals("http://geronimo.apache.org/calculator/CalculatorPortType/getmyepr",
action.toString());
+            
+            // check for presence wsaw:UsingAddressing element
+            Assert.assertEquals(1, def.getBindings().size());
+            Binding binding = (Binding)def.getBindings().values().iterator().next();
+            Assert.assertEquals(3, binding.getBindingOperations().size());
+            ExtensibilityElement wsa = TestUtils.getExtensibilityElement(binding.getExtensibilityElements(),
useAddressing);
+            Assert.assertNotNull("UsingAddressing", wsa);
+        } finally {
+            conn.disconnect();
+        }
+    }    
     
     private void testAddResponse(SOAPMessage message, int sum, boolean mtom) throws Exception
{
         TestUtils.testResponse(message, BASE_ACTION + "/addResponse", "addResponse", sum,
mtom);

Modified: geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-test-war/src/main/java/org/apache/geronimo/jaxws/wsa/TestUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-test-war/src/main/java/org/apache/geronimo/jaxws/wsa/TestUtils.java?rev=702930&r1=702929&r2=702930&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-test-war/src/main/java/org/apache/geronimo/jaxws/wsa/TestUtils.java
(original)
+++ geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-test-war/src/main/java/org/apache/geronimo/jaxws/wsa/TestUtils.java
Wed Oct  8 10:21:47 2008
@@ -21,7 +21,9 @@
 import java.io.IOException;
 import java.io.StringReader;
 import java.util.Iterator;
+import java.util.List;
 
+import javax.wsdl.extensions.ExtensibilityElement;
 import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -108,5 +110,15 @@
         Assert.assertTrue(attrValue, 
                           "true".equalsIgnoreCase(attrValue) || "1".equalsIgnoreCase(attrValue));
     }
-
+    
+    public static ExtensibilityElement getExtensibilityElement(List elements, QName queryElement)
{
+        for (int i = 0; i < elements.size(); i++) {
+            ExtensibilityElement element = (ExtensibilityElement)elements.get(i);
+            if (queryElement.equals(element.getElementType())) {
+                return element;
+            }
+        }
+        return null;
+    }
+    
 }
\ No newline at end of file

Modified: geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-war/src/main/java/org/apache/geronimo/jaxws/test/CalculatorImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-war/src/main/java/org/apache/geronimo/jaxws/test/CalculatorImpl.java?rev=702930&r1=702929&r2=702930&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-war/src/main/java/org/apache/geronimo/jaxws/test/CalculatorImpl.java
(original)
+++ geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-wsa-tests/wsa-war/src/main/java/org/apache/geronimo/jaxws/test/CalculatorImpl.java
Wed Oct  8 10:21:47 2008
@@ -23,6 +23,7 @@
 import javax.annotation.Resource;
 import javax.jws.HandlerChain;
 import javax.jws.WebService;
+import javax.xml.ws.Action;
 import javax.xml.ws.WebServiceContext;
 import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.soap.Addressing;
@@ -39,6 +40,7 @@
     @Resource
     private WebServiceContext context;
 
+    @Action(input="http://geronimo.apache.org/calculator/CalculatorPortType/getmyepr") 
     public W3CEndpointReference getEPR() {
         return (W3CEndpointReference)context.getEndpointReference();
     }



Mime
View raw message