[jboss-cvs] JBossAS SVN: r73348 - in projects/ejb3/trunk/proxy/src/test: java/org/jboss/ejb3/test/proxy/common and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 13 09:58:40 EDT 2008
Author: wolfc
Date: 2008-05-13 09:58:40 -0400 (Tue, 13 May 2008)
New Revision: 73348
Added:
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/StatelessContainer.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Local.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Remote.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessBean.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocal.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocalHome.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemote.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemoteHome.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase.java
projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/
projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/
projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase-beans.xml
Modified:
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/EmbeddedTestMcBootstrap.java
Log:
EJBTHREE-1345: SLSB test case (wip)
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/EmbeddedTestMcBootstrap.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/EmbeddedTestMcBootstrap.java 2008-05-13 13:38:34 UTC (rev 73347)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/EmbeddedTestMcBootstrap.java 2008-05-13 13:58:40 UTC (rev 73348)
@@ -23,6 +23,8 @@
import java.net.URL;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.ControllerState;
import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
@@ -320,6 +322,15 @@
return url;
}
+ public void installInstance(String name, Object instance) throws Throwable
+ {
+ AbstractBeanMetaData bmd = new AbstractBeanMetaData(name, instance.getClass().getName());
+ AbstractConstructorMetaData cmd = new AbstractConstructorMetaData();
+ cmd.setValueObject(instance);
+ bmd.setConstructor(cmd);
+ getKernel().getController().install(bmd);
+ }
+
/**
* Perform a clean shutdown.
*/
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/StatelessContainer.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/StatelessContainer.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/StatelessContainer.java 2008-05-13 13:58:40 UTC (rev 73348)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.common;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.test.proxy.session.MyStatelessLocal;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.naming.Util;
+import org.jboss.util.naming.NonSerializableFactory;
+
+/**
+ * A simple stateless container that binds proxies and can be invoked.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class StatelessContainer
+{
+ private static final Logger log = Logger.getLogger(StatelessContainer.class);
+
+ private JBossSessionBeanMetaData metaData;
+ private Class<?> beanClass;
+
+ private class StatelessInvocationHandler implements InvocationHandler
+ {
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ return localInvoke(method, args);
+ }
+ }
+
+ public StatelessContainer(JBossSessionBeanMetaData metaData) throws ClassNotFoundException
+ {
+ this.metaData = metaData;
+ this.beanClass = Class.forName(metaData.getEjbClass());
+ }
+
+ private Object createInstance() throws InstantiationException, IllegalAccessException
+ {
+ return beanClass.newInstance();
+ }
+
+ public Object localInvoke(Method method, Object args[]) throws Throwable
+ {
+ Object obj = createInstance();
+ return method.invoke(obj, args);
+ }
+
+ public void start() throws Throwable
+ {
+ log.info("Starting " + this);
+
+ // TODO: a lot
+ log.fatal("StatelessContainer.start doesn't really do what's really supposed to happen");
+
+ InitialContext ctx = new InitialContext();
+ //String jndiName = metaData.determineLocalJndiName();
+ String jndiName = "MyStatelessBean/local";
+ ClassLoader classLoader = beanClass.getClassLoader();
+ Class<?> interfaces[] = { MyStatelessLocal.class };
+ InvocationHandler handler = new StatelessInvocationHandler();
+ Object proxy = Proxy.newProxyInstance(classLoader, interfaces, handler);
+ Util.createSubcontext(ctx, "MyStatelessBean");
+ // TODO: should no be non-serializable (how to get Kernel instance?)
+ NonSerializableFactory.rebind(ctx, jndiName, proxy);
+ }
+
+ public void stop()
+ {
+ log.info("Stopping " + this);
+ }
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless.java 2008-05-13 13:58:40 UTC (rev 73348)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.session;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MyStateless
+{
+ String sayHi(String name);
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Local.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Local.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Local.java 2008-05-13 13:58:40 UTC (rev 73348)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.session;
+
+import javax.ejb.EJBLocalObject;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MyStateless21Local extends EJBLocalObject, MyStateless
+{
+
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Remote.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Remote.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Remote.java 2008-05-13 13:58:40 UTC (rev 73348)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.session;
+
+import javax.ejb.EJBObject;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MyStateless21Remote extends EJBObject, MyStateless
+{
+
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessBean.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessBean.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessBean.java 2008-05-13 13:58:40 UTC (rev 73348)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.session;
+
+import javax.ejb.LocalHome;
+import javax.ejb.RemoteHome;
+import javax.ejb.Stateless;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at LocalHome(MyStatelessLocalHome.class)
+ at RemoteHome(MyStatelessRemoteHome.class)
+public class MyStatelessBean implements MyStatelessLocal, MyStatelessRemote
+{
+ public String sayHi(String name)
+ {
+ return "Hi " + name;
+ }
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocal.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocal.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocal.java 2008-05-13 13:58:40 UTC (rev 73348)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.session;
+
+import javax.ejb.Local;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Local
+public interface MyStatelessLocal extends MyStateless
+{
+
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocalHome.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocalHome.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocalHome.java 2008-05-13 13:58:40 UTC (rev 73348)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.session;
+
+import javax.ejb.EJBLocalHome;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MyStatelessLocalHome extends EJBLocalHome
+{
+ MyStateless21Local create();
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemote.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemote.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemote.java 2008-05-13 13:58:40 UTC (rev 73348)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.session;
+
+import javax.ejb.Remote;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Remote
+public interface MyStatelessRemote extends MyStateless
+{
+
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemoteHome.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemoteHome.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemoteHome.java 2008-05-13 13:58:40 UTC (rev 73348)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.session;
+
+import javax.ejb.EJBHome;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MyStatelessRemoteHome extends EJBHome
+{
+ MyStateless21Remote create();
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase.java 2008-05-13 13:58:40 UTC (rev 73348)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.session.unit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.test.proxy.common.EmbeddedTestMcBootstrap;
+import org.jboss.ejb3.test.proxy.common.StatelessContainer;
+import org.jboss.ejb3.test.proxy.session.MyStatelessBean;
+import org.jboss.ejb3.test.proxy.session.MyStatelessLocal;
+import org.jboss.ejb3.test.proxy.session.MyStatelessLocalHome;
+import org.jboss.ejb3.test.proxy.session.MyStatelessRemote;
+import org.jboss.ejb3.test.proxy.session.MyStatelessRemoteHome;
+import org.jboss.metadata.annotation.creator.ejb.EjbJar30Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ProxySessionTestCase
+{
+ private static EmbeddedTestMcBootstrap bootstrap;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Throwable
+ {
+ bootstrap = new EmbeddedTestMcBootstrap();
+ bootstrap.run();
+ bootstrap.deploy(ProxySessionTestCase.class);
+
+ // emulate annotation deployer
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ Collection<Class<?>> classes = new HashSet<Class<?>>();
+ classes.add(MyStatelessBean.class);
+ EjbJar30MetaData metaData = new EjbJar30Creator(finder).create(classes);
+
+ // emulate merge deployer
+ JBossMetaData mergedMetaData = new JBossMetaData();
+ mergedMetaData.merge(null, metaData);
+
+ JBossSessionBeanMetaData beanMetaData = (JBossSessionBeanMetaData) mergedMetaData.getEnterpriseBean("MyStatelessBean");
+
+ System.out.println(beanMetaData.determineJndiName()); // MyStatelessBean/remote
+ System.out.println(beanMetaData.determineLocalJndiName()); // MyStatelessBean/local
+
+ StatelessContainer container = new StatelessContainer(beanMetaData);
+
+ bootstrap.installInstance("jboss.j2ee:service=EJB3,name=" + beanMetaData.getEjbName(), container);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception
+ {
+ if(bootstrap != null)
+ bootstrap.shutdown();
+ bootstrap = null;
+ }
+
+ @Test
+ public void testLocal() throws Exception
+ {
+ InitialContext ctx = new InitialContext();
+
+ Object bean = ctx.lookup("MyStatelessBean/local");
+ assertTrue(bean instanceof MyStatelessLocal);
+
+ String result = ((MyStatelessLocal) bean).sayHi("testLocal");
+ assertEquals("Hi testLocal", result);
+ }
+
+ @Test
+ public void testLocalHome() throws Exception
+ {
+ InitialContext ctx = new InitialContext();
+
+ Object bean = ctx.lookup("MyStatelessBean/localHome");
+ assertTrue(bean instanceof MyStatelessLocalHome);
+ }
+
+ @Test
+ public void testRemote() throws Exception
+ {
+ InitialContext ctx = new InitialContext();
+
+ Object bean = ctx.lookup("MyStatelessBean/remote");
+ assertTrue(bean instanceof MyStatelessRemote);
+ }
+
+ @Test
+ public void testRemoteHome() throws Exception
+ {
+ InitialContext ctx = new InitialContext();
+
+ Object bean = ctx.lookup("MyStatelessBean/home");
+ assertTrue(bean instanceof MyStatelessRemoteHome);
+ }
+}
Added: projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase-beans.xml
===================================================================
--- projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase-beans.xml (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase-beans.xml 2008-05-13 13:58:40 UTC (rev 73348)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <!-- JNDI -->
+ <bean name="NameServer" class="org.jnp.server.SingletonNamingServer"/>
+
+</deployment>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list