[jboss-svn-commits] JBoss Common SVN: r4356 - in arquillian/trunk: examples/domain/src/main/java/com/acme/ejb31 and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri May 7 07:32:31 EDT 2010
Author: aslak
Date: 2010-05-07 07:32:30 -0400 (Fri, 07 May 2010)
New Revision: 4356
Added:
arquillian/trunk/examples/domain/src/main/java/com/acme/ejb31/
arquillian/trunk/examples/domain/src/main/java/com/acme/ejb31/NoInterfaceEJB.java
arquillian/trunk/examples/junit/src/test/java/com/acme/ejb31/
arquillian/trunk/examples/junit/src/test/java/com/acme/ejb31/NoInterfaceEJBTestCase.java
Modified:
arquillian/trunk/examples/junit/pom.xml
arquillian/trunk/testenrichers/ejb/src/main/java/org/jboss/arquillian/testenricher/ejb/EJBInjectionEnricher.java
Log:
ARQ-93 Added support for EJB 3.1 NoInterface lookup
Added: arquillian/trunk/examples/domain/src/main/java/com/acme/ejb31/NoInterfaceEJB.java
===================================================================
--- arquillian/trunk/examples/domain/src/main/java/com/acme/ejb31/NoInterfaceEJB.java (rev 0)
+++ arquillian/trunk/examples/domain/src/main/java/com/acme/ejb31/NoInterfaceEJB.java 2010-05-07 11:32:30 UTC (rev 4356)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.acme.ejb31;
+
+import javax.ejb.Stateless;
+
+/**
+ * NoInterfaceEJB
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at Stateless
+public class NoInterfaceEJB
+{
+ public String hello()
+ {
+ return "Hey";
+ }
+}
Modified: arquillian/trunk/examples/junit/pom.xml
===================================================================
--- arquillian/trunk/examples/junit/pom.xml 2010-05-07 10:20:41 UTC (rev 4355)
+++ arquillian/trunk/examples/junit/pom.xml 2010-05-07 11:32:30 UTC (rev 4356)
@@ -204,6 +204,7 @@
<configuration>
<includes>
<include>com/acme/ejb/*</include>
+ <include>com/acme/ejb31/*</include>
</includes>
</configuration>
</plugin>
Added: arquillian/trunk/examples/junit/src/test/java/com/acme/ejb31/NoInterfaceEJBTestCase.java
===================================================================
--- arquillian/trunk/examples/junit/src/test/java/com/acme/ejb31/NoInterfaceEJBTestCase.java (rev 0)
+++ arquillian/trunk/examples/junit/src/test/java/com/acme/ejb31/NoInterfaceEJBTestCase.java 2010-05-07 11:32:30 UTC (rev 4356)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.acme.ejb31;
+
+import javax.ejb.EJB;
+
+import junit.framework.Assert;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * NoInterfaceEJBTestCase
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class NoInterfaceEJBTestCase
+{
+ @Deployment
+ public static JavaArchive createDeployment()
+ {
+ return ShrinkWrap.create("test.jar", JavaArchive.class)
+ .addClass(NoInterfaceEJB.class);
+ }
+
+ @EJB
+ private NoInterfaceEJB ejb;
+
+ @Test
+ public void shouldBeAbleToInjectNoInterfaceEJBs() throws Exception
+ {
+ Assert.assertNotNull(
+ "Verify that the ejb was injected",
+ ejb);
+
+ Assert.assertEquals(
+ "Verify that the ejb returns correct value",
+ "Hey",
+ ejb.hello());
+ }
+}
Modified: arquillian/trunk/testenrichers/ejb/src/main/java/org/jboss/arquillian/testenricher/ejb/EJBInjectionEnricher.java
===================================================================
--- arquillian/trunk/testenrichers/ejb/src/main/java/org/jboss/arquillian/testenricher/ejb/EJBInjectionEnricher.java 2010-05-07 10:20:41 UTC (rev 4355)
+++ arquillian/trunk/testenrichers/ejb/src/main/java/org/jboss/arquillian/testenricher/ejb/EJBInjectionEnricher.java 2010-05-07 11:32:30 UTC (rev 4356)
@@ -130,21 +130,31 @@
{
// TODO: figure out test context ?
InitialContext initcontext = createContext(context);
- try
+
+ String[] jndiNames = {
+ "java:global/test.ear/test/" + fieldType.getSimpleName() + "Bean",
+ "java:global/test.ear/test/" + fieldType.getSimpleName(),
+ "java:global/test/" + fieldType.getSimpleName() + "/no-interface",
+ "test/" + fieldType.getSimpleName() + "Bean/local",
+ "test/" + fieldType.getSimpleName() + "Bean/remote",
+ "test/" + fieldType.getSimpleName() + "/no-interface",
+ fieldType.getSimpleName() + "Bean/local",
+ fieldType.getSimpleName() + "Bean/remote",
+ fieldType.getSimpleName() + "/no-interface"
+ };
+
+ for(String jndiName : jndiNames)
{
- return initcontext.lookup("java:global/test.ear/test/" + fieldType.getSimpleName() + "Bean");
- }
- catch (NamingException e)
- {
- try
- {
- return initcontext.lookup("test/" + fieldType.getSimpleName() + "Bean/local");
- }
- catch (NamingException e2)
- {
- return initcontext.lookup("test/" + fieldType.getSimpleName() + "Bean/remote");
- }
+ try
+ {
+ return initcontext.lookup(jndiName);
+ }
+ catch (NamingException e)
+ {
+ // no-op, try next
+ }
}
+ throw new NamingException("No EJB found in JNDI, tried the following names: " + jndiNames);
}
protected InitialContext createContext(Context context) throws Exception
More information about the jboss-svn-commits
mailing list