[jboss-cvs] JBossAS SVN: r65795 - in branches/Branch_4_2/ejb3/src: test/org/jboss/ejb3/test/jaxws and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Oct 3 06:16:25 EDT 2007


Author: wolfc
Date: 2007-10-03 06:16:25 -0400 (Wed, 03 Oct 2007)
New Revision: 65795

Added:
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jaxws/PostConstructEJB.java
Modified:
   branches/Branch_4_2/ejb3/src/resources/test/jaxws/TestService.wsdl
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jaxws/EndpointEJB.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jaxws/unit/ContextEJBTestCase.java
Log:
EJBTHREE-1055: unit test

Modified: branches/Branch_4_2/ejb3/src/resources/test/jaxws/TestService.wsdl
===================================================================
--- branches/Branch_4_2/ejb3/src/resources/test/jaxws/TestService.wsdl	2007-10-03 10:15:03 UTC (rev 65794)
+++ branches/Branch_4_2/ejb3/src/resources/test/jaxws/TestService.wsdl	2007-10-03 10:16:25 UTC (rev 65795)
@@ -30,9 +30,17 @@
   <service name="TestService">
     <port name="EndpointInterfacePort" binding="tns:EndpointInterfaceBinding">
     <!--
-      <soap:address location="http://@jbosstest.host.name@:8080/jaxws-context"/>
+      <soap:address location="http://@jbosstest.host.name@:8080/jaxws-context/testService"/>
     -->
-      <soap:address location="http://localhost:8080/jaxws-context"/>
+      <soap:address location="http://localhost:8080/jaxws-context/testService"/>
     </port>
   </service>
+  <service name="TestService2">
+    <port name="EndpointInterfacePort" binding="tns:EndpointInterfaceBinding">
+    <!--
+      <soap:address location="http://@jbosstest.host.name@:8080/jaxws-context/testService2"/>
+    -->
+      <soap:address location="http://localhost:8080/jaxws-context/testService2"/>
+    </port>
+  </service>
 </definitions>

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jaxws/EndpointEJB.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jaxws/EndpointEJB.java	2007-10-03 10:15:03 UTC (rev 65794)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jaxws/EndpointEJB.java	2007-10-03 10:16:25 UTC (rev 65795)
@@ -36,7 +36,7 @@
 import org.jboss.wsf.spi.annotation.WebContext;
 
 @WebService(endpointInterface = "org.jboss.ejb3.test.jaxws.EndpointInterface", serviceName = "TestService", targetNamespace = "http://org.jboss.ws/jaxws/context")
- at WebContext(contextRoot="jaxws-context", urlPattern="/*")
+ at WebContext(contextRoot="jaxws-context", urlPattern="/testService")
 @Stateless
 public class EndpointEJB
 {

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jaxws/PostConstructEJB.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jaxws/PostConstructEJB.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jaxws/PostConstructEJB.java	2007-10-03 10:16:25 UTC (rev 65795)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.jaxws;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.WebServiceException;
+
+import org.jboss.wsf.spi.annotation.WebContext;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at WebService(endpointInterface = "org.jboss.ejb3.test.jaxws.EndpointInterface", serviceName = "TestService2", targetNamespace = "http://org.jboss.ws/jaxws/context")
+ at WebContext(contextRoot="jaxws-context", urlPattern="/testService2")
+ at Stateless
+public class PostConstructEJB
+{
+   @Resource
+   WebServiceContext wsCtx;
+
+   @Resource
+   SessionContext ejbCtx;
+
+   public String echoWS(String input)
+   {
+      try
+      {
+         String retValue = getValueJAXWS();
+         return retValue + "2";
+      }
+      catch (SOAPException ex)
+      {
+         throw new WebServiceException(ex);
+      }
+   }
+
+   public String echoRPC(String input)
+   {
+      try
+      {
+         String retValue = getValueJAXRPC();
+         return retValue + "2";
+      }
+      catch (SOAPException ex)
+      {
+         throw new WebServiceException(ex);
+      }
+   }
+
+   private String getValueJAXWS() throws SOAPException
+   {
+      if(wsCtx == null)
+         throw new IllegalStateException("wsCtx was not injected");
+      javax.xml.ws.handler.soap.SOAPMessageContext jaxwsContext = (javax.xml.ws.handler.soap.SOAPMessageContext)wsCtx.getMessageContext();
+      SOAPMessage soapMessage = jaxwsContext.getMessage();
+      SOAPElement soapElement = (SOAPElement)soapMessage.getSOAPBody().getChildElements().next();
+      soapElement = (SOAPElement)soapElement.getChildElements().next();
+      return soapElement.getValue();
+   }
+
+   private String getValueJAXRPC() throws SOAPException
+   {
+      if(ejbCtx == null)
+         throw new IllegalStateException("ejbCtx was not injected");
+      javax.xml.rpc.handler.soap.SOAPMessageContext jaxrpcContext = (javax.xml.rpc.handler.soap.SOAPMessageContext)ejbCtx.getMessageContext();
+      SOAPMessage soapMessage = jaxrpcContext.getMessage();
+      SOAPElement soapElement = (SOAPElement)soapMessage.getSOAPBody().getChildElements().next();
+      soapElement = (SOAPElement)soapElement.getChildElements().next();
+      return soapElement.getValue();
+   }
+   
+   @SuppressWarnings("unused")
+   @PostConstruct
+   private void postConstruct()
+   {
+      // injection must be finished here
+      
+      if(ejbCtx == null)
+         throw new IllegalStateException("ejbCtx was not injected in post construct");
+      
+      if(wsCtx == null)
+         throw new IllegalStateException("wsCtx was not injected in post construct");
+      
+      System.err.println("post construct done");
+   }
+}


Property changes on: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jaxws/PostConstructEJB.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jaxws/unit/ContextEJBTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jaxws/unit/ContextEJBTestCase.java	2007-10-03 10:15:03 UTC (rev 65794)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jaxws/unit/ContextEJBTestCase.java	2007-10-03 10:16:25 UTC (rev 65795)
@@ -94,4 +94,26 @@
          showKnownIssue("EJBTHREE-757");
       }
    }
+   
+   public void testService2() throws Exception
+   {
+      log.info("In case of connection exception, there is a host name defined in the wsdl, which used to be '@jbosstest.host.name@'");
+      URL wsdlURL = new File("../src/resources/test/jaxws/TestService.wsdl").toURL();
+      QName qname = new QName("http://org.jboss.ws/jaxws/context", "TestService2");
+      Service service = Service.create(wsdlURL, qname);
+      EndpointInterface port = (EndpointInterface)service.getPort(EndpointInterface.class);
+      
+      String helloWorld = "Hello world!";
+      try
+      {
+         Object retObj = port.echoWS(helloWorld);
+         assertEquals(helloWorld + "2", retObj);
+      }
+      catch(SOAPFaultException e)
+      {
+         assertEquals("java.lang.IllegalStateException: wsCtx was not injected in post construct", e.getMessage());
+         showKnownIssue("EJBTHREE-1055");
+      }
+   }
+
 }




More information about the jboss-cvs-commits mailing list