[webbeans-commits] Webbeans SVN: r1686 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck: unit/context and 1 other directory.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Tue Feb 24 14:30:55 EST 2009
Author: pete.muir at jboss.org
Date: 2009-02-24 14:30:54 -0500 (Tue, 24 Feb 2009)
New Revision: 1686
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/DestroyedInstanceReturnedByGetTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetOnInactiveContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetWithNoCreationalContextTest.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractDeclarativeTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/NormalContextTest.java
Log:
Fix normalcontext tests for standalone
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractDeclarativeTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractDeclarativeTest.java 2009-02-24 17:49:48 UTC (rev 1685)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractDeclarativeTest.java 2009-02-24 19:30:54 UTC (rev 1686)
@@ -192,7 +192,7 @@
}
@BeforeClass(alwaysRun=true)
- public final void beforeClass() throws Throwable
+ public void beforeClass() throws Throwable
{
generateArtifact();
deployArtifact();
@@ -209,7 +209,7 @@
}
@BeforeMethod(alwaysRun=true)
- public final void beforeMethod(Method method)
+ public void beforeMethod(Method method)
{
if (!isInContainer() && artifact == null)
{
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/DestroyedInstanceReturnedByGetTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/DestroyedInstanceReturnedByGetTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/DestroyedInstanceReturnedByGetTest.java 2009-02-24 19:30:54 UTC (rev 1686)
@@ -0,0 +1,54 @@
+package org.jboss.jsr299.tck.unit.context;
+
+import javax.context.ApplicationScoped;
+import javax.context.Context;
+import javax.context.SessionScoped;
+import javax.inject.manager.Bean;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractDeclarativeTest;
+import org.jboss.jsr299.tck.impl.packaging.Artifact;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+ at Artifact
+public class DestroyedInstanceReturnedByGetTest extends AbstractDeclarativeTest
+{
+
+
+ Context context;
+
+ @BeforeMethod(dependsOnMethods = "beforeMethod")
+ public void initContext()
+ {
+ if (context == null)
+ {
+ context = new DummyContext();
+ getCurrentManager().addContext(context);
+ }
+ }
+
+ @Test(groups = { "contexts", "ri-broken" })
+ @SpecAssertion(section = "8.1", id = "g")
+ public void testDestroyedInstanceMustNotBeReturnedByGet()
+ {
+ Bean<MySessionBean> mySessionBean = getCurrentManager().resolveByType(MySessionBean.class).iterator().next();
+ MyCreationalContext<MySessionBean> myCreationalContext = new MyCreationalContext<MySessionBean>();
+ MySessionBean beanInstance = getCurrentManager().getContext(SessionScoped.class).get(mySessionBean, myCreationalContext);
+ assert beanInstance != null;
+ mySessionBean.destroy(beanInstance);
+ MySessionBean beanInstanceFromGet = getCurrentManager().getContext(SessionScoped.class).get(mySessionBean);
+ assert beanInstanceFromGet != beanInstance;
+
+ Bean<MyApplicationBean> myApplicationBean = getCurrentManager().resolveByType(MyApplicationBean.class).iterator().next();
+ MyCreationalContext<MyApplicationBean> myCreationalContextForApplication = new MyCreationalContext<MyApplicationBean>();
+ MyApplicationBean myApplicationBeanInstance = getCurrentManager().getContext(ApplicationScoped.class).get(myApplicationBean, myCreationalContextForApplication);
+ assert myApplicationBeanInstance != null;
+ myApplicationBean.destroy(myApplicationBeanInstance);
+
+ MyApplicationBean mySecondApplicationBeanInstance = getCurrentManager().getContext(ApplicationScoped.class).get(myApplicationBean);
+ assert mySecondApplicationBeanInstance != null;
+ assert myApplicationBeanInstance != mySecondApplicationBeanInstance;
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/DestroyedInstanceReturnedByGetTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetOnInactiveContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetOnInactiveContextTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetOnInactiveContextTest.java 2009-02-24 19:30:54 UTC (rev 1686)
@@ -0,0 +1,44 @@
+package org.jboss.jsr299.tck.unit.context;
+
+import javax.context.Context;
+import javax.context.ContextNotActiveException;
+import javax.context.Contextual;
+import javax.context.SessionScoped;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractDeclarativeTest;
+import org.jboss.jsr299.tck.impl.packaging.Artifact;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+ at Artifact
+public class GetOnInactiveContextTest extends AbstractDeclarativeTest
+{
+
+
+ Context context;
+
+ @BeforeMethod(dependsOnMethods = "beforeMethod")
+ public void initContext()
+ {
+ if (context == null)
+ {
+ context = new DummyContext();
+ getCurrentManager().addContext(context);
+ }
+ }
+
+
+ @Test(groups = { "contexts" }, expectedExceptions = { ContextNotActiveException.class })
+ @SpecAssertion(section = "8.1", id = "h")
+ public void testInvokingGetOnInactiveContextFails()
+ {
+ Context sessionContext = getCurrentManager().getContext(SessionScoped.class);
+ assert sessionContext.isActive();
+ setContextInactive(sessionContext);
+
+ Contextual<MySessionBean> mySessionBean = getCurrentManager().resolveByType(MySessionBean.class).iterator().next();
+ sessionContext.get(mySessionBean);
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetOnInactiveContextTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetTest.java 2009-02-24 19:30:54 UTC (rev 1686)
@@ -0,0 +1,50 @@
+package org.jboss.jsr299.tck.unit.context;
+
+import javax.context.ApplicationScoped;
+import javax.context.Context;
+import javax.context.Contextual;
+import javax.context.CreationalContext;
+import javax.context.SessionScoped;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractDeclarativeTest;
+import org.jboss.jsr299.tck.impl.packaging.Artifact;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+ at Artifact
+public class GetTest extends AbstractDeclarativeTest
+{
+
+ Context context;
+
+ @BeforeMethod(dependsOnMethods = "beforeMethod")
+ public void initContext()
+ {
+ if (context == null)
+ {
+ context = new DummyContext();
+ getCurrentManager().addContext(context);
+ }
+ }
+
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "8.1", id = "e")
+ public void testGetMayNotCreateNewInstanceUnlessCreationalContextGiven()
+ {
+ Contextual<MySessionBean> mySessionBean = getCurrentManager().resolveByType(MySessionBean.class).iterator().next();
+ assert getCurrentManager().getContext(SessionScoped.class).get(mySessionBean) == null;
+
+ Contextual<MyApplicationBean> myApplicationBean = getCurrentManager().resolveByType(MyApplicationBean.class).iterator().next();
+ assert getCurrentManager().getContext(ApplicationScoped.class).get(myApplicationBean) == null;
+
+ // Now try same operation with a CreationalContext
+ CreationalContext<MySessionBean> myCreationalContext = new MyCreationalContext<MySessionBean>();
+ assert getCurrentManager().getContext(SessionScoped.class).get(mySessionBean, myCreationalContext) != null;
+
+ CreationalContext<MyApplicationBean> myOtherCreationalContext = new MyCreationalContext<MyApplicationBean>();
+ assert getCurrentManager().getContext(ApplicationScoped.class).get(myApplicationBean, myOtherCreationalContext) != null;
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetWithNoCreationalContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetWithNoCreationalContextTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetWithNoCreationalContextTest.java 2009-02-24 19:30:54 UTC (rev 1686)
@@ -0,0 +1,38 @@
+package org.jboss.jsr299.tck.unit.context;
+
+import javax.context.Context;
+import javax.context.Contextual;
+import javax.context.SessionScoped;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractDeclarativeTest;
+import org.jboss.jsr299.tck.impl.packaging.Artifact;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+ at Artifact
+public class GetWithNoCreationalContextTest extends AbstractDeclarativeTest
+{
+
+ Context context;
+
+ @BeforeMethod(dependsOnMethods = "beforeMethod")
+ public void initContext()
+ {
+ if (context == null)
+ {
+ context = new DummyContext();
+ getCurrentManager().addContext(context);
+ }
+ }
+
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "8.1", id = "b")
+ public void testGetWithoutCreationalContextReturnsNull()
+ {
+ Contextual<MySessionBean> mySessionBean = getCurrentManager().resolveByType(MySessionBean.class).iterator().next();
+ assert getCurrentManager().getContext(SessionScoped.class).get(mySessionBean) == null;
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/GetWithNoCreationalContextTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/NormalContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/NormalContextTest.java 2009-02-24 17:49:48 UTC (rev 1685)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/context/NormalContextTest.java 2009-02-24 19:30:54 UTC (rev 1686)
@@ -1,12 +1,9 @@
package org.jboss.jsr299.tck.unit.context;
-import javax.context.ApplicationScoped;
import javax.context.Context;
-import javax.context.ContextNotActiveException;
import javax.context.Contextual;
import javax.context.CreationalContext;
import javax.context.SessionScoped;
-import javax.inject.manager.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
import org.jboss.jsr299.tck.AbstractDeclarativeTest;
@@ -34,8 +31,11 @@
@BeforeMethod(dependsOnMethods = "beforeMethod")
public void initContext()
{
- context = new DummyContext();
- getCurrentManager().addContext(context);
+ if (context == null)
+ {
+ context = new DummyContext();
+ getCurrentManager().addContext(context);
+ }
}
@Test(groups = { "contexts" })
@@ -51,14 +51,6 @@
}
@Test(groups = { "contexts" })
- @SpecAssertion(section = "8.1", id = "b")
- public void testGetWithoutCreationalContextReturnsNull()
- {
- Contextual<MySessionBean> mySessionBean = getCurrentManager().resolveByType(MySessionBean.class).iterator().next();
- assert getCurrentManager().getContext(SessionScoped.class).get(mySessionBean) == null;
- }
-
- @Test(groups = { "contexts" })
@SpecAssertion(section = "8.1", id = "c")
public void testGetWithCreationalContextReturnsNewInstance()
{
@@ -87,24 +79,6 @@
}
@Test(groups = { "contexts" })
- @SpecAssertion(section = "8.1", id = "e")
- public void testGetMayNotCreateNewInstanceUnlessCreationalContextGiven()
- {
- Contextual<MySessionBean> mySessionBean = getCurrentManager().resolveByType(MySessionBean.class).iterator().next();
- assert getCurrentManager().getContext(SessionScoped.class).get(mySessionBean) == null;
-
- Contextual<MyApplicationBean> myApplicationBean = getCurrentManager().resolveByType(MyApplicationBean.class).iterator().next();
- assert getCurrentManager().getContext(ApplicationScoped.class).get(myApplicationBean) == null;
-
- // Now try same operation with a CreationalContext
- CreationalContext<MySessionBean> myCreationalContext = new MyCreationalContext<MySessionBean>();
- assert getCurrentManager().getContext(SessionScoped.class).get(mySessionBean, myCreationalContext) != null;
-
- CreationalContext<MyApplicationBean> myOtherCreationalContext = new MyCreationalContext<MyApplicationBean>();
- assert getCurrentManager().getContext(ApplicationScoped.class).get(myApplicationBean, myOtherCreationalContext) != null;
- }
-
- @Test(groups = { "contexts" })
@SpecAssertion(section = "8.1", id = "f")
public void testContextDestroysBeansWhenDestroyed()
{
@@ -121,40 +95,8 @@
assert bean.isDestroyCalled();
}
- @Test(groups = { "contexts", "broken" })
- @SpecAssertion(section = "8.1", id = "g")
- public void testDestroyedInstanceMustNotBeReturnedByGet()
- {
- Bean<MySessionBean> mySessionBean = getCurrentManager().resolveByType(MySessionBean.class).iterator().next();
- MyCreationalContext<MySessionBean> myCreationalContext = new MyCreationalContext<MySessionBean>();
- MySessionBean beanInstance = getCurrentManager().getContext(SessionScoped.class).get(mySessionBean, myCreationalContext);
- assert beanInstance != null;
- mySessionBean.destroy(beanInstance);
- MySessionBean beanInstanceFromGet = getCurrentManager().getContext(SessionScoped.class).get(mySessionBean);
- assert beanInstanceFromGet != beanInstance;
-
- Bean<MyApplicationBean> myApplicationBean = getCurrentManager().resolveByType(MyApplicationBean.class).iterator().next();
- MyCreationalContext<MyApplicationBean> myCreationalContextForApplication = new MyCreationalContext<MyApplicationBean>();
- MyApplicationBean myApplicationBeanInstance = getCurrentManager().getContext(ApplicationScoped.class).get(myApplicationBean, myCreationalContextForApplication);
- assert myApplicationBeanInstance != null;
- myApplicationBean.destroy(myApplicationBeanInstance);
-
- MyApplicationBean mySecondApplicationBeanInstance = getCurrentManager().getContext(ApplicationScoped.class).get(myApplicationBean);
- assert mySecondApplicationBeanInstance != null;
- assert myApplicationBeanInstance != mySecondApplicationBeanInstance;
- }
- @Test(groups = { "contexts" }, expectedExceptions = { ContextNotActiveException.class })
- @SpecAssertion(section = "8.1", id = "h")
- public void testInvokingGetOnInactiveContextFails()
- {
- Context sessionContext = getCurrentManager().getContext(SessionScoped.class);
- assert sessionContext.isActive();
- setContextInactive(sessionContext);
- Contextual<MySessionBean> mySessionBean = getCurrentManager().resolveByType(MySessionBean.class).iterator().next();
- sessionContext.get(mySessionBean);
- }
/**
* There may be no more than one mapped instance per contextual type per
More information about the weld-commits
mailing list