[jboss-cvs] JBossAS SVN: r73073 - in projects/ejb3/trunk/core: src/test/java/org/jboss/ejb3/test/webservices and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue May 6 03:32:45 EDT 2008


Author: heiko.braun at jboss.com
Date: 2008-05-06 03:32:45 -0400 (Tue, 06 May 2008)
New Revision: 73073

Added:
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/ContextAccessingHandler.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/GenericHandler.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/GenericSOAPHandler.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/HandlerContextEndpoint.java
   projects/ejb3/trunk/core/src/test/resources/test/webservices/org/
   projects/ejb3/trunk/core/src/test/resources/test/webservices/org/jboss/
   projects/ejb3/trunk/core/src/test/resources/test/webservices/org/jboss/ejb3/
   projects/ejb3/trunk/core/src/test/resources/test/webservices/org/jboss/ejb3/test/
   projects/ejb3/trunk/core/src/test/resources/test/webservices/org/jboss/ejb3/test/webservices/
   projects/ejb3/trunk/core/src/test/resources/test/webservices/org/jboss/ejb3/test/webservices/handlerchain.xml
Modified:
   projects/ejb3/trunk/core/build-test.xml
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/unit/WebServiceTestCase.java
Log:
Added a simple JAX-WS handlers test case

Modified: projects/ejb3/trunk/core/build-test.xml
===================================================================
--- projects/ejb3/trunk/core/build-test.xml	2008-05-06 07:10:30 UTC (rev 73072)
+++ projects/ejb3/trunk/core/build-test.xml	2008-05-06 07:32:45 UTC (rev 73073)
@@ -1065,20 +1065,28 @@
 
       <mkdir dir="${build.lib}"/>
 
+      <copy todir="${build.classes}">
+         <fileset dir="${resources}/test/webservices">
+            <include name="org/jboss/ejb3/test/webservices/*.xml"/>
+         </fileset>
+      </copy>
+
       <jar jarfile="${build.lib}/webservices-ejb3.jar">
          <fileset dir="${build.classes}">
             <include name="org/jboss/ejb3/test/webservices/*.class"/>
+            <include name="org/jboss/ejb3/test/webservices/*.xml"/>
          </fileset>
       </jar>
 
       <jar jarfile="${build.lib}/webservices-ejb3-client.jar">
          <fileset dir="${build.classes}">
             <include name="org/jboss/ejb3/test/webservices/*.class"/>
+            <include name="org/jboss/ejb3/test/webservices/*.xml"/>
          </fileset>
          <fileset dir="${resources}/test/webservices">            
             <include name="META-INF/*.xml"/>
             <include name="META-INF/wsdl/*.wsdl"/>
-            <include name="META-INF/wsdl/*.xml"/>
+            <include name="META-INF/wsdl/*.xml"/>            
          </fileset>
       </jar>
    </target>

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/ContextAccessingHandler.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/ContextAccessingHandler.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/ContextAccessingHandler.java	2008-05-06 07:32:45 UTC (rev 73073)
@@ -0,0 +1,38 @@
+/*
+ * 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.ejb3.test.webservices;
+
+import javax.xml.ws.handler.MessageContext;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class ContextAccessingHandler extends GenericSOAPHandler
+{
+
+   protected boolean handleInbound(MessageContext msgContext)
+   {
+      msgContext.put("invoked", "ContextAccessingHandler:handleInbound()");
+      msgContext.setScope("invoked", MessageContext.Scope.APPLICATION);
+      return true;
+   }
+}


Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/ContextAccessingHandler.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/GenericHandler.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/GenericHandler.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/GenericHandler.java	2008-05-06 07:32:45 UTC (rev 73073)
@@ -0,0 +1,80 @@
+/*
+ * 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.ejb3.test.webservices;
+
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.MessageContext;
+
+/**
+ * A generic jaxws handler
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 13-Aug-2006
+ */
+public abstract class GenericHandler implements Handler
+{
+   private String handlerName;
+
+   public String getHandlerName()
+   {
+      return handlerName;
+   }
+
+   public void setHandlerName(String handlerName)
+   {
+      this.handlerName = handlerName;
+   }
+   
+   public boolean handleMessage(MessageContext msgContext)
+   {
+      Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+      if (outbound == null)
+         throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+
+      return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
+   }
+
+   protected boolean handleOutbound(MessageContext msgContext)
+   {
+      return true;
+   }
+
+   protected boolean handleInbound(MessageContext msgContext)
+   {
+      return true;
+   }
+
+   public boolean handleFault(MessageContext messagecontext)
+   {
+      return true;
+   }
+
+   public void close(MessageContext messageContext)
+   {
+   }
+
+   public String toString()
+   {
+      return (handlerName != null ? handlerName : super.toString());
+   }
+}
+


Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/GenericHandler.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/GenericSOAPHandler.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/GenericSOAPHandler.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/GenericSOAPHandler.java	2008-05-06 07:32:45 UTC (rev 73073)
@@ -0,0 +1,55 @@
+/*
+ * 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.ejb3.test.webservices;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.handler.LogicalMessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * A generic jaxws soap handler
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 13-Aug-2006
+ */
+public abstract class GenericSOAPHandler<C extends LogicalMessageContext> extends GenericHandler implements SOAPHandler
+{
+   // The header blocks that can be processed by this Handler instance
+   private Set<QName> headers = new HashSet<QName>();
+
+   /** Gets the header blocks that can be processed by this Handler instance.
+    */
+   public Set<QName> getHeaders()
+   {
+      return headers;
+   }
+
+   /** Sets the header blocks that can be processed by this Handler instance.
+    */
+   public void setHeaders(Set<QName> headers)
+   {
+      this.headers = headers;
+   }
+}
+


Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/GenericSOAPHandler.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/HandlerContextEndpoint.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/HandlerContextEndpoint.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/HandlerContextEndpoint.java	2008-05-06 07:32:45 UTC (rev 73073)
@@ -0,0 +1,50 @@
+/*
+ * 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.ejb3.test.webservices;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+import javax.jws.HandlerChain;
+import javax.annotation.Resource;
+import javax.xml.ws.WebServiceContext;
+
+/**
+ * Test resource injection with JAX-WS handlers
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+
+ at Stateless
+ at WebService(endpointInterface = "org.jboss.ejb3.test.webservices.Ejb3WSEndpoint")
+ at HandlerChain(file = "handlerchain.xml")
+public class HandlerContextEndpoint implements Ejb3WSEndpoint
+{
+   @Resource(mappedName = "webservice-context")
+   WebServiceContext wsCtx;
+
+   public String echo(String msg)
+   {
+      if(! "ContextAccessingHandler:handleInbound()".equals( wsCtx.getMessageContext().get("invoked") ) )
+         throw new IllegalArgumentException("Wrong webservice context instance or handler not invoked");
+
+      return msg;
+   }
+}


Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/HandlerContextEndpoint.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/unit/WebServiceTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/unit/WebServiceTestCase.java	2008-05-06 07:10:30 UTC (rev 73072)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/unit/WebServiceTestCase.java	2008-05-06 07:32:45 UTC (rev 73073)
@@ -99,6 +99,23 @@
       assertEquals(msg, retObj);
    }
 
+   /**
+    * Test web service context ibjection into JAX-WS handler
+    * @throws Exception
+    */
+   public void testHandlerContext() throws Exception
+   {
+      Service service = Service.create(
+        new URL("http://"+getServerHost()+":8080/webservices-ejb3/HandlerContextEndpoint?wsdl"),
+        new QName("http://webservices.test.ejb3.jboss.org/","HandlerContextEndpointService")
+      );
+
+      String msg = "testHandlerContext";
+      Ejb3WSEndpoint port = service.getPort(Ejb3WSEndpoint.class);
+      String response = port.echo(msg);
+      assertNotNull(response);
+   }
+
    public static Test suite() throws Exception
    {
       return getDeploySetup(WebServiceTestCase.class, "webservices-ejb3.jar, webservices-ejb3-client.jar");

Added: projects/ejb3/trunk/core/src/test/resources/test/webservices/org/jboss/ejb3/test/webservices/handlerchain.xml
===================================================================
--- projects/ejb3/trunk/core/src/test/resources/test/webservices/org/jboss/ejb3/test/webservices/handlerchain.xml	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/resources/test/webservices/org/jboss/ejb3/test/webservices/handlerchain.xml	2008-05-06 07:32:45 UTC (rev 73073)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<handler-chains xmlns="http://java.sun.com/xml/ns/javaee"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:ns1="http://org.jboss.ws/jaxws/handlerscope"
+  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee javaee_web_services_1_2.xsd">
+
+	<handler-chain>
+    <protocol-bindings>##SOAP11_HTTP</protocol-bindings>
+		<handler>
+			<handler-name>ContextAccessingHandler</handler-name>
+			<handler-class>org.jboss.ejb3.test.webservices.ContextAccessingHandler</handler-class>
+		</handler>
+	</handler-chain>
+
+</handler-chains>
\ No newline at end of file


Property changes on: projects/ejb3/trunk/core/src/test/resources/test/webservices/org/jboss/ejb3/test/webservices/handlerchain.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jboss-cvs-commits mailing list