[jboss-cvs] JBossAS SVN: r73061 - in projects/ejb3/trunk/core/src: test/java/org/jboss/ejb3/test/webservices and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon May 5 10:36:34 EDT 2008
Author: heiko.braun at jboss.com
Date: 2008-05-05 10:36:34 -0400 (Mon, 05 May 2008)
New Revision: 73061
Added:
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/BusinessInterface.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/SimpleEndpoint.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/WebServiceContextEndpoint.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/WebServiceRefBean.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/unit/WebServiceTestCase.java
Removed:
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/Ejb3WSEndpointImpl.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/unit/Ejb3WSTestCase.java
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
Log:
Extended WS coverage, EJBTHREE-1285 and EJBTHREE-1286
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2008-05-05 12:49:19 UTC (rev 73060)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2008-05-05 14:36:34 UTC (rev 73061)
@@ -48,19 +48,21 @@
import org.jboss.ejb3.timerservice.TimedObjectInvoker;
import org.jboss.ejb3.timerservice.TimerServiceFactory;
import org.jboss.injection.WebServiceContextProxy;
+import org.jboss.injection.lang.reflect.BeanProperty;
import org.jboss.logging.Logger;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
import org.jboss.proxy.ejb.handle.HomeHandleImpl;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.invocation.ExtensibleWebServiceContext;
+import org.jboss.wsf.spi.invocation.InvocationType;
+import org.jboss.wsf.spi.invocation.WebServiceContextFactory;
import org.jboss.wsf.spi.invocation.integration.InvocationContextCallback;
import org.jboss.wsf.spi.invocation.integration.ServiceEndpointContainer;
-import javax.ejb.EJBException;
-import javax.ejb.Handle;
-import javax.ejb.Timer;
-import javax.ejb.TimerService;
+import javax.ejb.*;
import javax.naming.NamingException;
-import javax.xml.ws.WebServiceContext;
import java.lang.reflect.Method;
import java.util.Hashtable;
import java.util.Map;
@@ -548,18 +550,31 @@
* WS Integration
* @param method
* @param args
- * @param invocationContextCallback
+ * @param invCtxCallback
* @return
* @throws Throwable
*/
- public Object invokeEndpoint(Method method, Object[] args, InvocationContextCallback invocationContextCallback) throws Throwable
+ public Object invokeEndpoint(Method method, Object[] args, InvocationContextCallback invCtxCallback) throws Throwable
{
- // WebServiceContext association
- WebServiceContextProxy.associateMessageContext(
- invocationContextCallback.get( WebServiceContext.class )
+ // JAX-RPC message context
+ javax.xml.rpc.handler.MessageContext jaxrpcContext = invCtxCallback.get(javax.xml.rpc.handler.MessageContext.class);
+
+ // JAX-WS webservice context
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ WebServiceContextFactory contextFactory = spiProvider.getSPI(WebServiceContextFactory.class);
+ ExtensibleWebServiceContext jaxwsContext = contextFactory.newWebServiceContext(
+ InvocationType.JAXWS_EJB3,
+ invCtxCallback.get(javax.xml.ws.handler.MessageContext.class)
);
-
- return this.localInvoke(method, args, null, null);
+
+ // ThreadLocal association
+ WebServiceContextProxy.associateMessageContext(jaxwsContext);
+
+ // EJB3 Injection Callbacks
+ WSCallbackImpl ejb3Callback = new WSCallbackImpl( jaxrpcContext, jaxwsContext );
+
+ // Actual invocation
+ return this.localInvoke(method, args, null, ejb3Callback);
}
public String getContainerName()
@@ -567,4 +582,42 @@
String name = this.getObjectName() != null ? this.getObjectName().getCanonicalName() : null;
return name;
}
+
+ static class WSCallbackImpl implements BeanContextLifecycleCallback
+ {
+ private ExtensibleWebServiceContext jaxwsContext;
+ private javax.xml.rpc.handler.MessageContext jaxrpcMessageContext;
+
+ public WSCallbackImpl(javax.xml.rpc.handler.MessageContext jaxrpc, ExtensibleWebServiceContext jaxws)
+ {
+ jaxrpcMessageContext = jaxrpc;
+ jaxwsContext = jaxws;
+ }
+
+ public void attached(BeanContext beanCtx)
+ {
+ // JAX-RPC MessageContext
+ StatelessBeanContext sbc = (StatelessBeanContext)beanCtx;
+ sbc.setMessageContextJAXRPC(jaxrpcMessageContext);
+
+ // JAX-WS MessageContext
+ BeanProperty beanProp = sbc.getWebServiceContextProperty();
+ if (beanProp != null)
+ {
+ EJBContext ejbCtx = beanCtx.getEJBContext();
+ jaxwsContext.addAttachment(EJBContext.class, ejbCtx);
+ beanProp.set(beanCtx.getInstance(), jaxwsContext);
+ }
+ }
+
+ public void released(BeanContext beanCtx)
+ {
+ StatelessBeanContext sbc = (StatelessBeanContext)beanCtx;
+ sbc.setMessageContextJAXRPC(null);
+
+ BeanProperty beanProp = sbc.getWebServiceContextProperty();
+ if (beanProp != null)
+ beanProp.set(beanCtx.getInstance(), null);
+ }
+ }
}
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/BusinessInterface.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/BusinessInterface.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/BusinessInterface.java 2008-05-05 14:36:34 UTC (rev 73061)
@@ -0,0 +1,34 @@
+/*
+ * 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.jws.WebService;
+import javax.ejb.Remote;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at Remote
+public interface BusinessInterface
+{
+ String echo(String msg);
+}
Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/BusinessInterface.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/Ejb3WSEndpointImpl.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/Ejb3WSEndpointImpl.java 2008-05-05 12:49:19 UTC (rev 73060)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/Ejb3WSEndpointImpl.java 2008-05-05 14:36:34 UTC (rev 73061)
@@ -1,42 +0,0 @@
-/*
- * 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 org.jboss.ejb3.annotation.RemoteBinding;
-
-import javax.ejb.Stateless;
-import javax.jws.WebService;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
- at Stateless
- at RemoteBinding(jndiBinding = "Ejb3WSEndpoint")
- at WebService(endpointInterface = "org.jboss.ejb3.test.webservices.Ejb3WSEndpoint")
-public class Ejb3WSEndpointImpl implements Ejb3WSEndpoint
-{
-
- public String echo(String msg)
- {
- return msg;
- }
-}
Copied: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/SimpleEndpoint.java (from rev 73055, projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/Ejb3WSEndpointImpl.java)
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/SimpleEndpoint.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/SimpleEndpoint.java 2008-05-05 14:36:34 UTC (rev 73061)
@@ -0,0 +1,41 @@
+/*
+ * 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 org.jboss.ejb3.annotation.RemoteBinding;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at Stateless
+ at WebService(endpointInterface = "org.jboss.ejb3.test.webservices.Ejb3WSEndpoint")
+public class SimpleEndpoint implements Ejb3WSEndpoint
+{
+
+ public String echo(String msg)
+ {
+ return msg;
+ }
+}
Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/SimpleEndpoint.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/WebServiceContextEndpoint.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/WebServiceContextEndpoint.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/WebServiceContextEndpoint.java 2008-05-05 14:36:34 UTC (rev 73061)
@@ -0,0 +1,56 @@
+/*
+ * 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 org.jboss.ejb3.annotation.RemoteBinding;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+import javax.annotation.Resource;
+import javax.annotation.PostConstruct;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.WebServiceException;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at Stateless
+ at RemoteBinding(jndiBinding = "WebServiceContextEndpoint")
+ at WebService(endpointInterface = "org.jboss.ejb3.test.webservices.Ejb3WSEndpoint")
+public class WebServiceContextEndpoint implements Ejb3WSEndpoint
+{
+
+ @Resource(mappedName = "webservice-context")
+ WebServiceContext wsCtx;
+
+ @PostConstruct
+ public void init()
+ {
+ if(null == wsCtx)
+ throw new WebServiceException("WebService context is null @PostConstruct");
+ }
+
+ public String echo(String msg)
+ {
+ return msg +": " +wsCtx.getMessageContext();
+ }
+}
Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/WebServiceContextEndpoint.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/WebServiceRefBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/WebServiceRefBean.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/WebServiceRefBean.java 2008-05-05 14:36:34 UTC (rev 73061)
@@ -0,0 +1,42 @@
+/*
+ * 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.xml.ws.WebServiceRef;
+
+/**
+ * Simple EJB3 bean that delegates to a webservice injected through @WebServiceRef
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at Stateless
+public class WebServiceRefBean implements BusinessInterface
+{
+ @WebServiceRef(wsdlLocation = "http://localhost:8080/webservices-ejb3/SimpleEndpoint?wsdl")
+ Ejb3WSEndpoint serviceRef;
+
+ public String echo(String msg)
+ {
+ return serviceRef.echo(msg);
+ }
+}
Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/WebServiceRefBean.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/unit/Ejb3WSTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/unit/Ejb3WSTestCase.java 2008-05-05 12:49:19 UTC (rev 73060)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/unit/Ejb3WSTestCase.java 2008-05-05 14:36:34 UTC (rev 73061)
@@ -1,100 +0,0 @@
-/*
- * 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.unit;
-
-import junit.framework.Test;
-import org.jboss.test.JBossTestCase;
-import org.jboss.ejb3.test.webservices.Ejb3WSEndpoint;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.xml.ws.Service;
-import javax.xml.namespace.QName;
-import java.util.Hashtable;
-import java.net.URL;
-
-/**
- * @author Heiko.Braun at jboss.com
- * @version $Revision$
- */
-public class Ejb3WSTestCase extends JBossTestCase
-{
- public Ejb3WSTestCase(String name)
- {
- super(name);
- }
-
- public void testRemoteAccess() throws Exception
- {
- InitialContext iniCtx = getInitialContext();
- Ejb3WSEndpoint ejb3Remote = (Ejb3WSEndpoint)iniCtx.lookup("/Ejb3WSEndpoint");
-
- String helloWorld = "Hello world!";
- Object retObj = ejb3Remote.echo(helloWorld);
- assertEquals(helloWorld, retObj);
- }
-
- public void testWebService() throws Exception
- {
- Service service = Service.create(
- new URL("http://"+getServerHost()+":8080/webservices-ejb3/Ejb3WSEndpointImpl?wsdl"),
- new QName("http://webservices.test.ejb3.jboss.org/","Ejb3WSEndpointImplService")
- );
-
- Ejb3WSEndpoint port = service.getPort(Ejb3WSEndpoint.class);
- String response = port.echo("Hello");
- assertEquals("Hello", response);
- }
-
- public void testWebServiceRef() throws Exception
- {
-
- }
-
- public static Test suite() throws Exception
- {
- return getDeploySetup(Ejb3WSTestCase.class, "webservices-ejb3.jar, webservices-ejb3-client.jar");
- }
-
- protected InitialContext getInitialContext(String clientName) throws NamingException
- {
- InitialContext iniCtx = new InitialContext();
- Hashtable env = iniCtx.getEnvironment();
- env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
- env.put("j2ee.clientName", clientName);
- return new InitialContext(env);
- }
-
- /** Get the client's env context
- */
- protected InitialContext getInitialContext() throws NamingException
- {
- return getInitialContext("jbossws-client");
- }
-
- public String getServerHost()
- {
- String hostName = System.getProperty("jbosstest.server.host", "localhost");
- return hostName;
- }
-}
Copied: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/unit/WebServiceTestCase.java (from rev 73055, projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/unit/Ejb3WSTestCase.java)
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/unit/WebServiceTestCase.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/unit/WebServiceTestCase.java 2008-05-05 14:36:34 UTC (rev 73061)
@@ -0,0 +1,128 @@
+/*
+ * 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.unit;
+
+import junit.framework.Test;
+import org.jboss.test.JBossTestCase;
+import org.jboss.ejb3.test.webservices.Ejb3WSEndpoint;
+import org.jboss.ejb3.test.webservices.BusinessInterface;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.xml.ws.Service;
+import javax.xml.namespace.QName;
+import java.util.Hashtable;
+import java.net.URL;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class WebServiceTestCase extends JBossTestCase
+{
+ public WebServiceTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testRemoteAccess() throws Exception
+ {
+ InitialContext iniCtx = getInitialContext();
+ Ejb3WSEndpoint ejb3Remote = (Ejb3WSEndpoint)iniCtx.lookup("/webservices-ejb3/SimpleEndpoint/remote");
+
+ String helloWorld = "Hello world!";
+ Object retObj = ejb3Remote.echo(helloWorld);
+ assertEquals(helloWorld, retObj);
+ }
+
+ /**
+ * Simple web service test coverage
+ * @throws Exception
+ */
+ public void testWebService() throws Exception
+ {
+ Service service = Service.create(
+ new URL("http://"+getServerHost()+":8080/webservices-ejb3/SimpleEndpoint?wsdl"),
+ new QName("http://webservices.test.ejb3.jboss.org/","SimpleEndpointService")
+ );
+
+ String msg = "testWebService";
+ Ejb3WSEndpoint port = service.getPort(Ejb3WSEndpoint.class);
+ String response = port.echo(msg);
+ assertEquals(msg, response);
+ }
+
+ /**
+ * Test web service context injection
+ * @throws Exception
+ */
+ public void testWebServiceContext() throws Exception
+ {
+ Service service = Service.create(
+ new URL("http://"+getServerHost()+":8080/webservices-ejb3/WebServiceContextEndpoint?wsdl"),
+ new QName("http://webservices.test.ejb3.jboss.org/","WebServiceContextEndpointService")
+ );
+
+ String msg = "testWebServiceContext";
+ Ejb3WSEndpoint port = service.getPort(Ejb3WSEndpoint.class);
+ String response = port.echo(msg);
+ assertNotNull(response);
+ }
+
+ public void testWebServiceRef() throws Exception
+ {
+ InitialContext iniCtx = getInitialContext();
+ BusinessInterface ejb3Remote = (BusinessInterface)iniCtx.lookup("/webservices-ejb3/WebServiceRefBean/remote");
+
+ String msg = "testWebServiceRef";
+ Object retObj = ejb3Remote.echo(msg);
+ assertEquals(msg, retObj);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(WebServiceTestCase.class, "webservices-ejb3.jar, webservices-ejb3-client.jar");
+ }
+
+ protected InitialContext getInitialContext(String clientName) throws NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Hashtable env = iniCtx.getEnvironment();
+ env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
+ env.put("j2ee.clientName", clientName);
+ return new InitialContext(env);
+ }
+
+ /** Get the client's env context
+ */
+ protected InitialContext getInitialContext() throws NamingException
+ {
+ return getInitialContext("jbossws-client");
+ }
+
+ public String getServerHost()
+ {
+ String hostName = System.getProperty("jbosstest.server.host", "localhost");
+ return hostName;
+ }
+}
Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/webservices/unit/WebServiceTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list