[webbeans-commits] Webbeans SVN: r3145 - in tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb and 7 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Wed Jul 22 16:12:04 EDT 2009
Author: dan.j.allen
Date: 2009-07-22 16:12:03 -0400 (Wed, 22 Jul 2009)
New Revision: 3145
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/AnotherInterface.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/ManagedBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/Monitor.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjb.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjbBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/ResourceProducer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/EnvInjectionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/Greeting.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/GreetingBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/ResourceProducer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/Default.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/ManagedBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/ResourceProducer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/ManagedBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/ResourceProducer.java
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/beans.xml
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/web.xml
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjb.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjbInterface.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/SimpleBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/SimpleBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/SimpleBean.java
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/web.xml
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/EjbInjectionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/Another.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/InjectionOfResourceTest.java
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/beans.xml
Log:
reimplement the EE resources test to use the producer field pattern
bring assertions up to 20090625 spec
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/AnotherInterface.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/AnotherInterface.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/AnotherInterface.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
+
+public interface AnotherInterface
+{
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/EjbInjectionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/EjbInjectionTest.java 2009-07-22 20:10:50 UTC (rev 3144)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/EjbInjectionTest.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -9,7 +9,7 @@
* 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,
+ * 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.
@@ -17,10 +17,15 @@
package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.IntegrationTest;
@@ -34,10 +39,9 @@
/**
* EJB injection tests for simple beans.
*
- * Spec version: 20090519
+ * Spec version: 20090625
*
* @author David Allen
- *
*/
@Artifact
@Packaging(PackagingType.EAR)
@@ -48,15 +52,54 @@
@BeansXml("beans.xml")
public class EjbInjectionTest extends AbstractJSR299Test
{
- @Test(groups = { "ri-broken", "beanLifecycle", "commonAnnotations", "integration" })
- @SpecAssertion(section = "3.6.1", id = "ee")
+ @Test(groups = { "beanLifecycle", "commonAnnotations", "integration" })
+ @SpecAssertions({
+ @SpecAssertion(section = "3.5.1", id = "ee")
+ })
public void testInjectionOfEjbs()
{
- Bean<SimpleBean> simpleBeanBean = getBeans(SimpleBean.class).iterator().next();
- CreationalContext<SimpleBean> creationalContext = getCurrentManager().createCreationalContext(simpleBeanBean);
- SimpleBean simpleBean = simpleBeanBean.create(creationalContext);
- assert !simpleBean.isMyEjbExists() : "Ejb was injected too early";
- assert simpleBean.getMyEjb() != null : "Ejb was not injected into bean";
- assert simpleBean.getMyEjb().hello().equals("hi!");
+ Bean<ManagedBean> managedBean = getBeans(ManagedBean.class).iterator().next();
+ CreationalContext<ManagedBean> creationalContext = getCurrentManager().createCreationalContext(managedBean);
+ ManagedBean instance = managedBean.create(creationalContext);
+ assert instance.getMyEjb() != null : "EJB reference was not produced and injected into bean";
+ assert instance.getMyEjb().knockKnock().equals("We're home");
}
+
+ // Marked as review because I think the EJB proxy should have the AnotherInterface interface
+ // also, need to verify that the instance is passivation capable
+ @Test(groups = { "beanLifecycle", "commonsAnnotations", "integration", "review" })
+ @SpecAssertions({
+ @SpecAssertion(section = "7.3.6", id = "l"),
+ @SpecAssertion(section = "7.3.6", id = "m"),
+ @SpecAssertion(section = "7.3.6", id = "o")
+ })
+ public void testProduceEjbProxyWithContainerInjections()
+ {
+ Bean<RemoteEjb> remoteEjbBean = getBeans(RemoteEjb.class).iterator().next();
+ CreationalContext<RemoteEjb> remoteEjbCc = getCurrentManager().createCreationalContext(remoteEjbBean);
+ RemoteEjb instance = remoteEjbBean.create(remoteEjbCc);
+ assert instance != null;
+
+ instance.knockKnock();
+ assert instance.getKnocks() == 1;
+
+ //assert getCurrentConfiguration().getBeans().isProxy(instance);
+ Set<Class> interfaces = new HashSet<Class>(Arrays.asList(instance.getClass().getInterfaces()));
+ assert interfaces.contains(RemoteEjb.class);
+ //assert interfaces.contains(AnotherInterface.class);
+ }
+
+ @Test(groups = { "beanLifecycle", "commonsAnnotations", "integration" })
+ @SpecAssertion(section = "7.3.6", id = "na")
+ public void testRemoveProducedEjbProxy()
+ {
+ Monitor monitor = getInstanceByType(Monitor.class);
+ Bean<RemoteEjb> remoteEjbBean = getBeans(RemoteEjb.class).iterator().next();
+ CreationalContext<RemoteEjb> remoteEjbCc = getCurrentManager().createCreationalContext(remoteEjbBean);
+ RemoteEjb instance = remoteEjbBean.create(remoteEjbCc);
+ instance.knockKnock();
+ remoteEjbBean.destroy(instance, remoteEjbCc);
+ // QUESTION is this the right assertion?
+ assert !monitor.isRemoteEjbDestroyed();
+ }
}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/ManagedBean.java (from rev 3118, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/SimpleBean.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/ManagedBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/ManagedBean.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
+
+import javax.enterprise.inject.Current;
+
+class ManagedBean
+{
+ private @Current RemoteEjb myEjb;
+
+ public RemoteEjb getMyEjb()
+ {
+ return myEjb;
+ }
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/Monitor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/Monitor.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/Monitor.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,20 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.RequestScoped;
+
+ at RequestScoped class Monitor implements Serializable
+{
+ private boolean remoteEjbDestroyed = false;
+
+ public void remoteEjbDestroyed()
+ {
+ remoteEjbDestroyed = true;
+ }
+
+ public boolean isRemoteEjbDestroyed()
+ {
+ return remoteEjbDestroyed;
+ }
+}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjb.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjb.java 2009-07-22 20:10:50 UTC (rev 3144)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjb.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -1,14 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
-
-import javax.ejb.Stateless;
-
- at Stateless(name="MyRemoteEjb", mappedName="ejb/MyRemoteEjb")
-public class RemoteEjb implements RemoteEjbInterface
-{
-
- public String hello()
- {
- return "hi!";
- }
-
-}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjb.java (from rev 3118, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjbInterface.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjb.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjb.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,16 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
+
+import javax.ejb.Remote;
+
+public @Remote interface RemoteEjb extends AnotherInterface
+{
+ public String knockKnock();
+
+ public int getKnocks();
+
+ public boolean isUserTransactionInjected();
+
+ public void cleanup();
+
+ public void dispose();
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjbBean.java (from rev 3118, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjb.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjbBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjbBean.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,59 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
+
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.enterprise.inject.Current;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+
+public
+ at Stateful(name="SampleRemoteEjb", mappedName="ejb/SampleRemoteEjb")
+ at TransactionManagement(TransactionManagementType.BEAN)
+class RemoteEjbBean implements RemoteEjb
+{
+ private int knocks = 0;
+
+ private @Current Monitor monitor;
+
+ private @Resource UserTransaction transaction;
+
+ public String knockKnock()
+ {
+ knocks++;
+ return "We're home";
+ }
+
+ public int getKnocks()
+ {
+ return knocks;
+ }
+
+ public boolean isUserTransactionInjected()
+ {
+ try
+ {
+ if (transaction != null)
+ {
+ transaction.getStatus();
+ return true;
+ }
+ }
+ catch (SystemException e)
+ {
+ }
+ return false;
+ }
+
+ public @PreDestroy void cleanup()
+ {
+ monitor.remoteEjbDestroyed();
+ }
+
+ public @Remove void dispose()
+ {
+ }
+}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjbInterface.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjbInterface.java 2009-07-22 20:10:50 UTC (rev 3144)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjbInterface.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -1,9 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
-
-import javax.ejb.Remote;
-
- at Remote
-public interface RemoteEjbInterface
-{
- public String hello();
-}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/ResourceProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/ResourceProducer.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/ResourceProducer.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
+
+import javax.ejb.EJB;
+import javax.enterprise.inject.Produces;
+
+class ResourceProducer
+{
+ private @Produces @EJB RemoteEjb remoteEjb;
+}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/SimpleBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/SimpleBean.java 2009-07-22 20:10:50 UTC (rev 3144)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/SimpleBean.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -1,25 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
-
-import javax.ejb.EJB;
-
-class SimpleBean
-{
- @EJB
- private RemoteEjb myEjb;
- private boolean myEjbExists;
-
- public SimpleBean()
- {
- myEjbExists = myEjb != null;
- }
-
- public RemoteEjb getMyEjb()
- {
- return myEjb;
- }
-
- public boolean isMyEjbExists()
- {
- return myEjbExists;
- }
-}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/EnvInjectionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/EnvInjectionTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/EnvInjectionTest.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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 org.jboss.jsr299.tck.tests.implementation.simple.resource.env;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.AnnotationLiteral;
+import javax.enterprise.inject.spi.Bean;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.testng.annotations.Test;
+
+/**
+ * Environment variable injection tests for simple beans.
+ *
+ * Spec version: 20090625
+ *
+ * @author Dan Allen
+ */
+ at Artifact
+ at Packaging(PackagingType.WAR)
+ at IntegrationTest
+ at Resource(source="web.xml", destination="/WEB-INF/web.xml")
+ at BeansXml("beans.xml")
+public class EnvInjectionTest extends AbstractJSR299Test
+{
+ @Test(groups = { "beanLifecycle", "commonAnnotations", "integration" })
+ @SpecAssertion(section = "3.5.1", id = "bb")
+ public void testInjectionOfEnv()
+ {
+ Bean<GreetingBean> greetingBean = getBeans(GreetingBean.class).iterator().next();
+ CreationalContext<GreetingBean> greetingBeanCc = getCurrentManager().createCreationalContext(greetingBean);
+ GreetingBean instance = greetingBean.create(greetingBeanCc);
+ assert instance.greet() != null;
+ assert instance.greet().equals("Hello there my friend");
+ }
+
+ @Test(groups = { "beanLifecycle", "commonsAnnotations", "integration" })
+ @SpecAssertions({
+ @SpecAssertion(section = "7.3.6", id = "l"),
+ @SpecAssertion(section = "7.3.6", id = "m"),
+ @SpecAssertion(section = "7.3.6", id = "o")
+ })
+ public void testProduceEnvProxy()
+ {
+ Bean<String> greetingEnvBean = getBeans(String.class, new AnnotationLiteral<Greeting>() {}).iterator().next();
+ CreationalContext<String> greetingEnvCc = getCurrentManager().createCreationalContext(greetingEnvBean);
+ String greeting = greetingEnvBean.create(greetingEnvCc);
+ assert greeting != null;
+ assert greeting.equals("Hello there my friend");
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/Greeting.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/Greeting.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/Greeting.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.env;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.BindingType;
+
+ at Target( { TYPE, METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at BindingType
+public @interface Greeting
+{
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/GreetingBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/GreetingBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/GreetingBean.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.env;
+
+class GreetingBean
+{
+ private @Greeting String phrase;
+
+ public String greet()
+ {
+ return phrase;
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/ResourceProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/ResourceProducer.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/ResourceProducer.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.env;
+
+import javax.annotation.Resource;
+import javax.enterprise.inject.Produces;
+
+class ResourceProducer
+{
+ private @Produces @Resource(name = "greeting") @Greeting String greeting;
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/Default.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/Default.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/Default.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.persistenceContext;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.BindingType;
+
+ at Target( { TYPE, METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at BindingType
+public @interface Default
+{
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/ManagedBean.java (from rev 3118, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/SimpleBean.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/ManagedBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/ManagedBean.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.persistenceContext;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+class ManagedBean
+{
+ private @Default EntityManager persistenceContext;
+
+ private @Default EntityManagerFactory persistenceUnit;
+
+ public EntityManager getPersistenceContext()
+ {
+ return persistenceContext;
+ }
+
+ public EntityManagerFactory getPersistenceUnit()
+ {
+ return persistenceUnit;
+ }
+
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java 2009-07-22 20:10:50 UTC (rev 3144)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -2,8 +2,6 @@
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
@@ -13,54 +11,47 @@
import org.jboss.testharness.impl.packaging.Packaging;
import org.jboss.testharness.impl.packaging.PackagingType;
import org.jboss.testharness.impl.packaging.Resource;
-import org.jboss.testharness.impl.packaging.Resources;
import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
import org.testng.annotations.Test;
/**
* Injection of persistence related objects.
*
- * Spec version: 20090519
+ * Spec version: 20090625
*
* @author David Allen
- *
*/
@Artifact
@Packaging(PackagingType.WAR)
@IntegrationTest
- at Resources({
- @Resource(source="persistence.xml", destination="WEB-INF/persistence.xml")
-})
+ at Resource(source = "persistence.xml", destination = "WEB-INF/classes/META-INF/persistence.xml")
+//@PersistenceXml("persistence.xml")
@BeansXml("beans.xml")
public class PersistenceContextInjectionTest extends AbstractJSR299Test
{
@Test(groups = { "beanLifecycle", "commonAnnotations", "integration" })
- @SpecAssertions( {
- @SpecAssertion(section = "3.6.1", id = "cc")
+ @SpecAssertions( {
+ @SpecAssertion(section = "3.5.1", id = "cc")
})
public void testInjectionOfPersistenceContext()
{
- Bean<SimpleBean> simpleBeanBean = getBeans(SimpleBean.class).iterator().next();
- CreationalContext<SimpleBean> creationalContext = getCurrentManager().createCreationalContext(simpleBeanBean);
- SimpleBean simpleBean = simpleBeanBean.create(creationalContext);
- EntityManager entityManager = simpleBean.getPersistenceContext();
- assert !simpleBean.isPersistenceContextExistsDuringConstruction() : "Persistence context injected too early";
- assert entityManager != null : "Persistence context was not injected into bean";
- assert entityManager.isOpen() : "persistence context not open injected into bean";
+ Bean<ManagedBean> managedBeanBean = getBeans(ManagedBean.class).iterator().next();
+ CreationalContext<ManagedBean> managedBeanCc = getCurrentManager().createCreationalContext(managedBeanBean);
+ ManagedBean managedBean = managedBeanBean.create(managedBeanCc);
+ assert managedBean.getPersistenceContext() != null : "Persistence context was not injected into bean";
+ assert managedBean.getPersistenceContext().isOpen() : "Persistence context not open injected into bean";
}
- @Test(groups = { "broken", "beanLifecycle", "commonAnnotations", "integration" })
- @SpecAssertions( {
- @SpecAssertion(section = "3.6.1", id = "dd")
+ @Test(groups = { "ri-broken", "beanLifecycle", "commonAnnotations", "integration" })
+ @SpecAssertions( {
+ @SpecAssertion(section = "3.5.1", id = "dd")
})
public void testInjectionOfPersistenceUnit()
{
- Bean<SimpleBean> simpleBeanBean = getBeans(SimpleBean.class).iterator().next();
- CreationalContext<SimpleBean> creationalContext = getCurrentManager().createCreationalContext(simpleBeanBean);
- SimpleBean simpleBean = simpleBeanBean.create(creationalContext);
- EntityManagerFactory entityManagerFactory = simpleBean.getPersistenceUnit();
- assert !simpleBean.isPersistenceUnitExistsDuringConstruction() : "Persistence unit injected too early";
- assert entityManagerFactory != null : "Persistence unit was not injected into bean";
- assert entityManagerFactory.isOpen() : "persistence unit not open injected into bean";
+ Bean<ManagedBean> managedBeanBean = getBeans(ManagedBean.class).iterator().next();
+ CreationalContext<ManagedBean> managedBeanCc = getCurrentManager().createCreationalContext(managedBeanBean);
+ ManagedBean managedBean = managedBeanBean.create(managedBeanCc);
+ assert managedBean.getPersistenceUnit() != null : "Persistence unit was not injected into bean";
+ assert managedBean.getPersistenceUnit().isOpen() : "Persistence unit not open injected into bean";
}
}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/ResourceProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/ResourceProducer.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/ResourceProducer.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.persistenceContext;
+
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
+
+class ResourceProducer
+{
+ private @Produces @Default @PersistenceUnit EntityManagerFactory persistenceUnit;
+
+ private @Produces @Default @PersistenceContext EntityManager persistenceContext;
+}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/SimpleBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/SimpleBean.java 2009-07-22 20:10:50 UTC (rev 3144)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/SimpleBean.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -1,43 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.simple.resource.persistenceContext;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.PersistenceContext;
-import javax.persistence.PersistenceUnit;
-
-class SimpleBean
-{
- @PersistenceContext
- private EntityManager persistenceContext;
- private boolean persistenceContextExistsDuringConstruction;
-
- @PersistenceUnit
- private EntityManagerFactory persistenceUnit;
- private boolean persistenceUnitExistsDuringConstruction;
-
- public SimpleBean()
- {
- persistenceContextExistsDuringConstruction = persistenceContext != null;
- persistenceUnitExistsDuringConstruction = persistenceUnit != null;
- }
-
- public EntityManager getPersistenceContext()
- {
- return persistenceContext;
- }
-
- public EntityManagerFactory getPersistenceUnit()
- {
- return persistenceUnit;
- }
-
- public boolean isPersistenceContextExistsDuringConstruction()
- {
- return persistenceContextExistsDuringConstruction;
- }
-
- public boolean isPersistenceUnitExistsDuringConstruction()
- {
- return persistenceUnitExistsDuringConstruction;
- }
-}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/Another.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/Another.java 2009-07-22 20:10:50 UTC (rev 3144)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/Another.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -18,5 +18,4 @@
@BindingType
@interface Another
{
-
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/InjectionOfResourceTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/InjectionOfResourceTest.java 2009-07-22 20:10:50 UTC (rev 3144)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/InjectionOfResourceTest.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -1,10 +1,12 @@
package org.jboss.jsr299.tck.tests.implementation.simple.resource.resource;
import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.AnnotationLiteral;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.IntegrationTest;
@@ -14,9 +16,7 @@
import org.testng.annotations.Test;
/**
- *
- * Spec version: 20090519
- *
+ * Spec version: 20090625
*/
@Artifact
@Packaging(PackagingType.WAR)
@@ -24,16 +24,29 @@
@BeansXml("beans.xml")
public class InjectionOfResourceTest extends AbstractJSR299Test
{
- @Test(groups = { "ri-broken", "beanLifecycle", "commonAnnotations", "integration" })
- @SpecAssertion(section = "3.6.1", id = "bb")
+ @Test(groups = { "beanLifecycle", "commonAnnotations", "integration" })
+ @SpecAssertion(section = "3.5.1", id = "bb")
public void testInjectionOfResource()
{
- Bean<SimpleBean> simpleBeanBean = getBeans(SimpleBean.class).iterator().next();
- CreationalContext<SimpleBean> creationalContext = getCurrentManager().createCreationalContext(simpleBeanBean);
- SimpleBean simpleBean = simpleBeanBean.create(creationalContext);
- BeanManager beanManager = simpleBean.getManager();
- assert !simpleBean.isManagerInjected() : "Manager injected too early";
- assert beanManager != null : "@Another Manager not found";
- assert beanManager.equals(getCurrentManager()): "Wrong manager found";
+ Bean<ManagedBean> managedBeanBean = getBeans(ManagedBean.class).iterator().next();
+ CreationalContext<ManagedBean> managedBeanCc = getCurrentManager().createCreationalContext(managedBeanBean);
+ ManagedBean managedBean = managedBeanBean.create(managedBeanCc);
+ assert managedBean.getBeanManager() != null : "@Another Manager not found";
+ assert managedBean.getBeanManager().equals(getCurrentManager()): "Wrong manager found";
}
+
+ @Test(groups = { "beanLifecycle", "commonsAnnotations", "integration" })
+ @SpecAssertions({
+ @SpecAssertion(section = "7.3.6", id = "l"),
+ @SpecAssertion(section = "7.3.6", id = "m"),
+ @SpecAssertion(section = "7.3.6", id = "o")
+ })
+ public void testProduceResourceProxy()
+ {
+ Bean<BeanManager> beanManagerBean = getBeans(BeanManager.class, new AnnotationLiteral<Another>() {}).iterator().next();
+ CreationalContext<BeanManager> beanManagerCc = getCurrentManager().createCreationalContext(beanManagerBean);
+ BeanManager beanManager = beanManagerBean.create(beanManagerCc);
+ assert beanManager != null;
+ assert beanManager.equals(getCurrentManager());
+ }
}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/ManagedBean.java (from rev 3118, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/SimpleBean.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/ManagedBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/ManagedBean.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,13 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.resource;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+class ManagedBean
+{
+ private @Another BeanManager beanManager;
+
+ public BeanManager getBeanManager()
+ {
+ return beanManager;
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/ResourceProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/ResourceProducer.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/ResourceProducer.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,10 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.resource;
+
+import javax.annotation.Resource;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.BeanManager;
+
+class ResourceProducer
+{
+ private @Produces @Another @Resource(mappedName = "java:app/BeanManager") BeanManager manager;
+}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/SimpleBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/SimpleBean.java 2009-07-22 20:10:50 UTC (rev 3144)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/SimpleBean.java 2009-07-22 20:12:03 UTC (rev 3145)
@@ -1,26 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.simple.resource.resource;
-
-import javax.annotation.Resource;
-import javax.enterprise.inject.spi.BeanManager;
-
-class SimpleBean
-{
- @Resource
- private BeanManager beanManager;
- private boolean managerInjected;
-
- public SimpleBean()
- {
- managerInjected = beanManager != null;
- }
-
- public BeanManager getManager()
- {
- return beanManager;
- }
-
- public boolean isManagerInjected()
- {
- return managerInjected;
- }
-}
Deleted: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/web.xml
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/web.xml 2009-07-22 20:10:50 UTC (rev 3144)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/web.xml 2009-07-22 20:12:03 UTC (rev 3145)
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
- <description>EJB references for Simple Beans.</description>
- <display-name>EJB Injection Tests</display-name>
-
- <ejb-ref>
- <ejb-ref-name>ejb/MyRemoteEjb</ejb-ref-name>
- <ejb-ref-type>Session</ejb-ref-type>
- <remote>org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb.RemoteEjbInterface</remote>
- </ejb-ref>
-
- <session-config>
- <session-timeout>10</session-timeout>
- </session-config>
- <login-config>
- <auth-method>BASIC</auth-method>
- </login-config>
-</web-app>
\ No newline at end of file
Added: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/beans.xml
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/beans.xml (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/beans.xml 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,3 @@
+<beans>
+
+</beans>
Added: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/web.xml
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/web.xml (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/env/web.xml 2009-07-22 20:12:03 UTC (rev 3145)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <description>Environment variables for managed beans</description>
+ <display-name>Env Injection Tests</display-name>
+
+ <env-entry>
+ <env-entry-name>greeting</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>Hello there my friend</env-entry-value>
+ </env-entry>
+
+ <listener>
+ <listener-class>org.jboss.testharness.impl.runner.servlet.HarnessServletListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>JBoss Test Harness Test Runner</servlet-name>
+ <servlet-class>org.jboss.testharness.impl.runner.servlet.ServletTestRunner</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JBoss Test Harness Test Runner</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+
+</web-app>
Modified: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/beans.xml
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/beans.xml 2009-07-22 20:10:50 UTC (rev 3144)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/beans.xml 2009-07-22 20:12:03 UTC (rev 3145)
@@ -1,11 +1,2 @@
-<Beans xmlns="urn:java:ee"
- xmlns:app="urn:java:org.jboss.jsr299.tck.tests.implementation.simple.resource.resource"
- xmlns:m="urn:java:javax.enterprise.inject.spi">
-
- <m:Manager>
- <Resource>
- <mappedName>java:app/Manager</mappedName>
- </Resource>
- <app:Another />
- </m:Manager>
-</Beans>
+<beans>
+</beans>
More information about the weld-commits
mailing list