geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r506625 - in /geronimo/server/trunk/modules/geronimo-axis2/src/test: ./ java/ java/org/ java/org/apache/ java/org/apache/geronimo/ java/org/apache/geronimo/axis2/ resources/
Date Mon, 12 Feb 2007 20:45:01 GMT
Author: dims
Date: Mon Feb 12 12:45:00 2007
New Revision: 506625

URL: http://svn.apache.org/viewvc?view=rev&rev=506625
Log:
Fix for GERONIMO-2824 - port the handler tests from CXF to Axis2

Added:
    geronimo/server/trunk/modules/geronimo-axis2/src/test/
    geronimo/server/trunk/modules/geronimo-axis2/src/test/java/
    geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/
    geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/
    geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/
    geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/
    geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2HandlerResolverTest.java
    geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/TestHandler.java
    geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/
    geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers.xml
    geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_bindings.xml
    geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_mixed.xml
    geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_port.xml
    geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_service.xml

Added: geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2HandlerResolverTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2HandlerResolverTest.java?view=auto&rev=506625
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2HandlerResolverTest.java
(added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2HandlerResolverTest.java
Mon Feb 12 12:45:00 2007
@@ -0,0 +1,205 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.axis2;
+
+import java.io.InputStream;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.PortInfo;
+import org.apache.axis2.jaxws.javaee.HandlerChainsType;
+
+import org.apache.geronimo.testsupport.TestSupport;
+
+public class Axis2HandlerResolverTest extends TestSupport {
+
+    public void testBasic() throws Exception {
+        InputStream in = getClass().getResourceAsStream("/handlers.xml");
+        assertTrue(in != null);
+        HandlerChainsType handlerChains = toHandlerChains(in); 
+        assertEquals(3, handlerChains.getHandlerChain().size());
+        
+        Axis2HandlerResolver resolver = 
+            new Axis2HandlerResolver(getClass().getClassLoader(), getClass(), handlerChains,
null);
+        
+        List<Handler> handlers = null;
+        
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));  
+        assertEquals(3, handlers.size());
+    }
+
+    public void testServiceMatching() throws Exception {
+        InputStream in = getClass().getResourceAsStream("/handlers_service.xml");
+        assertTrue(in != null);
+        HandlerChainsType handlerChains = toHandlerChains(in); 
+        assertEquals(3, handlerChains.getHandlerChain().size());
+        
+        Axis2HandlerResolver resolver = 
+            new Axis2HandlerResolver(getClass().getClassLoader(), getClass(), handlerChains,
null);
+        
+        List<Handler> handlers = null;
+        
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null)); 
+        assertEquals(0, handlers.size());
+        
+        QName serviceName1 = new QName("http://foo", "Bar");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName1));

+        assertEquals(1, handlers.size());
+        
+        QName serviceName2 = new QName("http://foo", "Foo");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName2));

+        assertEquals(2, handlers.size());
+        
+        QName serviceName3 = new QName("http://foo", "FooBar");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName3));

+        assertEquals(1, handlers.size());
+        
+        QName serviceName4 = new QName("http://foo", "BarFoo");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName4));

+        assertEquals(0, handlers.size());
+    }
+    
+    public void testBindingMatching() throws Exception {
+        InputStream in = getClass().getResourceAsStream("/handlers_bindings.xml");
+        assertTrue(in != null);
+        HandlerChainsType handlerChains = toHandlerChains(in); 
+        assertEquals(3, handlerChains.getHandlerChain().size());
+        
+        Axis2HandlerResolver resolver = 
+            new Axis2HandlerResolver(getClass().getClassLoader(), getClass(), handlerChains,
null);
+        
+        List<Handler> handlers = null;
+        
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null)); 
+        assertEquals(0, handlers.size());
+        
+        handlers = resolver.getHandlerChain(new TestPortInfo("##FOO_BAR", null, null)); 
+        assertEquals(0, handlers.size());
+        
+        handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP11_HTTP", null, null));

+        assertEquals(2, handlers.size());
+        
+        handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP11_HTTP_MTOM", null,
null)); 
+        assertEquals(1, handlers.size());
+    }
+    
+    public void testPortMatching() throws Exception {
+        InputStream in = getClass().getResourceAsStream("/handlers_port.xml");
+        assertTrue(in != null);
+        HandlerChainsType handlerChains = toHandlerChains(in); 
+        assertEquals(3, handlerChains.getHandlerChain().size());
+        
+        Axis2HandlerResolver resolver = 
+            new Axis2HandlerResolver(getClass().getClassLoader(), getClass(), handlerChains,
null);
+        
+        List<Handler> handlers = null;
+        
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null)); 
+        assertEquals(0, handlers.size());
+        
+        QName portName1 = new QName("http://foo", "Bar");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, portName1, null)); 
+        assertEquals(1, handlers.size());
+        
+        QName portName2 = new QName("http://foo", "Foo");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, portName2, null)); 
+        assertEquals(2, handlers.size());
+        
+        QName portName3 = new QName("http://foo", "FooBar");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, portName3, null));
+        assertEquals(1, handlers.size());
+        
+        QName portName4 = new QName("http://foo", "BarFoo");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, portName4, null)); 
+        assertEquals(0, handlers.size());
+    }
+    
+    public void testMixedMatching() throws Exception {
+        InputStream in = getClass().getResourceAsStream("/handlers_mixed.xml");
+        assertTrue(in != null);
+        HandlerChainsType handlerChains = toHandlerChains(in); 
+        assertEquals(3, handlerChains.getHandlerChain().size());
+        
+        Axis2HandlerResolver resolver = 
+            new Axis2HandlerResolver(getClass().getClassLoader(), getClass(), handlerChains,
null);
+        
+        List<Handler> handlers = null;
+        
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null)); 
+        assertEquals(0, handlers.size());
+        
+        QName serviceName1 = new QName("http:/foo", "Bar");
+        QName portName1 = new QName("http://foo", "FooBar");
+        String binding1 = "##XML_HTTP";
+        handlers = resolver.getHandlerChain(new TestPortInfo(binding1, portName1, serviceName1));

+        assertEquals(3, handlers.size());
+        
+        String binding2 = "##SOAP11_HTTP";
+        handlers = resolver.getHandlerChain(new TestPortInfo(binding2, portName1, serviceName1));

+        assertEquals(2, handlers.size());
+        
+        QName serviceName2 = new QName("http://foo", "Baaz");
+        QName portName2 = new QName("http://foo", "Baaz");
+        handlers = resolver.getHandlerChain(new TestPortInfo(binding1, portName2, serviceName2));

+        assertEquals(1, handlers.size());
+    }
+    
+    private static HandlerChainsType toHandlerChains(InputStream input)
+            throws JAXBException {
+        JAXBContext ctx = JAXBContext.newInstance(HandlerChainsType.class);
+        Unmarshaller unmarshaller = ctx.createUnmarshaller();
+        StreamSource in = new StreamSource(input);
+        JAXBElement handlerElement = unmarshaller.unmarshal(in,
+                HandlerChainsType.class);
+
+        return (HandlerChainsType) handlerElement.getValue();
+    }
+    
+    private static class TestPortInfo implements PortInfo {
+
+        private String bindingID;
+        private QName portName;
+        private QName serviceName;
+
+        public TestPortInfo(String bindingID, QName portName, QName serviceName) {
+            this.bindingID = bindingID;
+            this.portName = portName;
+            this.serviceName = serviceName;
+        }
+        
+        public String getBindingID() {
+            return this.bindingID;
+        }
+
+        public QName getPortName() {
+            return this.portName;
+        }
+
+        public QName getServiceName() {
+            return this.serviceName;
+        }
+        
+    }
+    
+}

Added: geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/TestHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/TestHandler.java?view=auto&rev=506625
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/TestHandler.java
(added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/TestHandler.java
Mon Feb 12 12:45:00 2007
@@ -0,0 +1,38 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.axis2;
+
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.MessageContext;
+
+public class TestHandler implements Handler {
+
+    public void close(MessageContext arg0) {
+        // TODO Auto-generated method stub        
+    }
+
+    public boolean handleFault(MessageContext arg0) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean handleMessage(MessageContext arg0) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+    
+}

Added: geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers.xml?view=auto&rev=506625
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers.xml (added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers.xml Mon Feb 12
12:45:00 2007
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+  <jws:handler-chain>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+  <jws:handler-chain>
+    <jws:service-name-pattern>*</jws:service-name-pattern>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+  <jws:handler-chain>
+    <jws:port-name-pattern>*</jws:port-name-pattern>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+</jws:handler-chains>

Added: geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_bindings.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_bindings.xml?view=auto&rev=506625
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_bindings.xml
(added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_bindings.xml
Mon Feb 12 12:45:00 2007
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+  <jws:handler-chain>
+    <jws:protocol-bindings>##XML_HTTP</jws:protocol-bindings>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+  <jws:handler-chain>
+    <jws:protocol-bindings>##SOAP11_HTTP</jws:protocol-bindings>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+  <jws:handler-chain>
+    <jws:protocol-bindings>##SOAP11_HTTP ##SOAP11_HTTP_MTOM</jws:protocol-bindings>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+</jws:handler-chains>

Added: geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_mixed.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_mixed.xml?view=auto&rev=506625
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_mixed.xml (added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_mixed.xml Mon
Feb 12 12:45:00 2007
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+  <jws:handler-chain>
+    <jws:protocol-bindings>##XML_HTTP</jws:protocol-bindings>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+  <jws:handler-chain>
+    <jws:port-name-pattern>jws:Foo*</jws:port-name-pattern>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+  <jws:handler-chain>
+    <jws:service-name-pattern>jws:Bar</jws:service-name-pattern>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+</jws:handler-chains>

Added: geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_port.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_port.xml?view=auto&rev=506625
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_port.xml (added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_port.xml Mon
Feb 12 12:45:00 2007
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+  <jws:handler-chain>
+    <jws:port-name-pattern>jws:Foo</jws:port-name-pattern>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+  <jws:handler-chain>
+    <jws:port-name-pattern>jws:Foo*</jws:port-name-pattern>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+  <jws:handler-chain>
+    <jws:port-name-pattern>jws:Bar</jws:port-name-pattern>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+</jws:handler-chains>

Added: geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_service.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_service.xml?view=auto&rev=506625
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_service.xml (added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/test/resources/handlers_service.xml Mon
Feb 12 12:45:00 2007
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+  <jws:handler-chain>
+    <jws:service-name-pattern>jws:Foo</jws:service-name-pattern>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+  <jws:handler-chain>
+    <jws:service-name-pattern>jws:Foo*</jws:service-name-pattern>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+  <jws:handler-chain>
+    <jws:service-name-pattern>jws:Bar</jws:service-name-pattern>
+    <jws:handler>
+      <jws:handler-name>GreeterHandler</jws:handler-name>
+      <jws:handler-class>org.apache.geronimo.axis2.TestHandler</jws:handler-class>
+    </jws:handler>
+  </jws:handler-chain>
+</jws:handler-chains>



Mime
View raw message