[jboss-cvs] JBossAS SVN: r63179 - in trunk/ejb3: src/test/org/jboss/ejb3/test and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 22 07:12:12 EDT 2007
Author: wolfc
Date: 2007-05-22 07:12:12 -0400 (Tue, 22 May 2007)
New Revision: 63179
Added:
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree971/
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree971/CheckEJBContext.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree971/CheckEJBContextBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree971/unit/
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree971/unit/CheckEJBContextTestCase.java
Modified:
trunk/ejb3/build-test.xml
Log:
EJBTHREE-971: unit test
Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml 2007-05-22 10:17:29 UTC (rev 63178)
+++ trunk/ejb3/build-test.xml 2007-05-22 11:12:12 UTC (rev 63179)
@@ -189,6 +189,7 @@
<path refid="jboss.transaction.classpath"/>
<path refid="jboss.security.classpath"/>
<path refid="jboss.security.spi.classpath"/>
+ <path refid="jboss.security.int.classpath"/>
<!-- this is for the NonSerializableFactory -->
<path refid="jboss.server.classpath"/>
<path refid="jboss.mq.classpath"/>
@@ -1993,6 +1994,13 @@
<build-simple-jar name="ejbthree967"/>
</target>
+ <target name="ejbthree971"
+ description="Builds a simple jar files."
+ depends="compile-classes">
+
+ <build-simple-jar name="ejbthree971"/>
+ </target>
+
<target name="jaxws"
description="Builds a simple jar."
depends="compile-classes">
@@ -3311,7 +3319,7 @@
<target name="jars" depends="appclient, tck5sec, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
circulardependency, jsp, timerdependency, servicedependency, servlet, stateless14, webservices, ear, ejbthree440,
ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree724, ejbthree751, ejbthree921, ejbthree936, ejbthree939,
- ejbthree953, ejbthree957, ejbthree959, ejbthree963, ejbthree967,
+ ejbthree953, ejbthree957, ejbthree959, ejbthree963, ejbthree967, ejbthree971,
aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency,
securitydomain, enventry,
jms/managed, naming, bmt, jca/inflowmdb, pool, jms, security, reference21_30, factory, dd/web, txexceptions,
@@ -4169,6 +4177,9 @@
<antcall target="test" inheritRefs="true">
<param name="test" value="ejbthree967"/>
</antcall>
+ <antcall target="test" inheritRefs="true">
+ <param name="test" value="ejbthree971"/>
+ </antcall>
</target>
<target name="entity-tests" depends="init" description="Execute all tests">
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree971/CheckEJBContext.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree971/CheckEJBContext.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree971/CheckEJBContext.java 2007-05-22 11:12:12 UTC (rev 63179)
@@ -0,0 +1,33 @@
+/*
+ * 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.ejbthree971;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version: $Revision: $
+ */
+public interface CheckEJBContext
+{
+ void checkForEjbContextInEnv();
+ void checkForInjectedEjbContext();
+ void checkForInjectedEjbCtxInEnv();
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree971/CheckEJBContextBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree971/CheckEJBContextBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree971/CheckEJBContextBean.java 2007-05-22 11:12:12 UTC (rev 63179)
@@ -0,0 +1,81 @@
+/*
+ * 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.ejbthree971;
+
+import javax.annotation.Resource;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version: $Revision: $
+ */
+ at Stateless
+ at Remote(CheckEJBContext.class)
+public class CheckEJBContextBean implements CheckEJBContext
+{
+ @Resource(name="ejbContext")
+ private SessionContext ctx;
+
+ public void checkForEjbContextInEnv()
+ {
+ checkSessionContext(lookup("java:comp/EJBContext"));
+ }
+
+ public void checkForInjectedEjbContext()
+ {
+ checkSessionContext(ctx);
+ }
+
+ public void checkForInjectedEjbCtxInEnv()
+ {
+ checkSessionContext(lookup("java:comp/env/ejbContext"));
+ }
+
+ private void checkSessionContext(SessionContext context)
+ {
+ if(context == null)
+ throw new IllegalStateException("context is null");
+ }
+
+ private InitialContext getInitialContext() throws NamingException
+ {
+ return new InitialContext();
+ }
+
+ private SessionContext lookup(String name)
+ {
+ try
+ {
+ return (SessionContext) getInitialContext().lookup(name);
+ }
+ catch (NamingException e)
+ {
+ throw new IllegalStateException("Can't lookup " + name, e);
+ }
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree971/unit/CheckEJBContextTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree971/unit/CheckEJBContextTestCase.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree971/unit/CheckEJBContextTestCase.java 2007-05-22 11:12:12 UTC (rev 63179)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejbthree971.unit;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree971.CheckEJBContext;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Test if an EJBContext can be properly located (EJB3 16.15).
+ * Note that we also bind the EJBContext into java:comp/env space
+ * if an annotation with a name is used (EJBTHREE-971).
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CheckEJBContextTestCase extends JBossTestCase
+{
+
+ public CheckEJBContextTestCase(String name)
+ {
+ super(name);
+ }
+
+ private CheckEJBContext lookupBean() throws Exception
+ {
+ return (CheckEJBContext) getInitialContext().lookup("CheckEJBContextBean/remote");
+ }
+
+ public void testEnvironment() throws Exception
+ {
+ CheckEJBContext bean = lookupBean();
+ bean.checkForEjbContextInEnv();
+ }
+
+ public void testInjection() throws Exception
+ {
+ CheckEJBContext bean = lookupBean();
+ bean.checkForInjectedEjbContext();
+ }
+
+ public void testInjectionEnv() throws Exception
+ {
+ CheckEJBContext bean = lookupBean();
+ bean.checkForInjectedEjbCtxInEnv();
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(CheckEJBContextTestCase.class, "ejbthree971.jar");
+ }
+}
More information about the jboss-cvs-commits
mailing list