Author: dallen6
Date: 2009-03-27 10:19:05 -0400 (Fri, 27 Mar 2009)
New Revision: 2227
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanA.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanB.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanZ.java
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DummyContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DummyScoped.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyedInstanceReturnedByGetTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetOnInactiveContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetWithNoCreationalContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MySessionBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java
Log:
Added/enabled more context tests.
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyedInstanceReturnedByGetTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyedInstanceReturnedByGetTest.java 2009-03-27
13:06:18 UTC (rev 2226)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyedInstanceReturnedByGetTest.java 2009-03-27
14:19:05 UTC (rev 2227)
@@ -1,7 +1,6 @@
package org.jboss.jsr299.tck.tests.context;
import javax.context.ApplicationScoped;
-import javax.context.Context;
import javax.context.SessionScoped;
import javax.inject.manager.Bean;
@@ -13,22 +12,7 @@
@Artifact
public class DestroyedInstanceReturnedByGetTest extends AbstractJSR299Test
{
-
-
- Context context;
-
- @Override
- public void beforeMethod()
- {
- super.beforeMethod();
- if (context == null)
- {
- context = new DummyContext();
- getCurrentManager().addContext(context);
- }
- }
-
- @Test(groups = { "contexts", "ri-broken" })
+ @Test(groups = { "contexts" })
@SpecAssertion(section = "8.1", id = "g")
public void testDestroyedInstanceMustNotBeReturnedByGet()
{
@@ -36,19 +20,20 @@
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;
+ this.destroyContext(getCurrentManager().getContext(SessionScoped.class));
+ this.setContextActive(getCurrentManager().getContext(SessionScoped.class));
+ beanInstance =
getCurrentManager().getContext(SessionScoped.class).get(mySessionBean);
+ assert beanInstance == null;
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;
+ this.destroyContext(getCurrentManager().getContext(ApplicationScoped.class));
+ this.setContextActive(getCurrentManager().getContext(ApplicationScoped.class));
+
+ myApplicationBeanInstance =
getCurrentManager().getContext(ApplicationScoped.class).get(myApplicationBean);
+ assert myApplicationBeanInstance == null;
}
}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DummyContext.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DummyContext.java 2009-03-27
13:06:18 UTC (rev 2226)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DummyContext.java 2009-03-27
14:19:05 UTC (rev 2227)
@@ -1,30 +0,0 @@
-package org.jboss.jsr299.tck.tests.context;
-
-import java.lang.annotation.Annotation;
-
-import javax.context.Context;
-import javax.context.Contextual;
-import javax.context.CreationalContext;
-
-class DummyContext implements Context
-{
- public <T> T get(Contextual<T> bean, CreationalContext<T>
creationalContext)
- {
- throw new UnsupportedOperationException();
- }
-
- public <T> T get(Contextual<T> contextual)
- {
- return get(contextual, null);
- }
-
- public Class<? extends Annotation> getScopeType()
- {
- return DummyScoped.class;
- }
-
- public boolean isActive()
- {
- return true;
- }
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DummyScoped.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DummyScoped.java 2009-03-27
13:06:18 UTC (rev 2226)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DummyScoped.java 2009-03-27
14:19:05 UTC (rev 2227)
@@ -1,13 +0,0 @@
-package org.jboss.jsr299.tck.tests.context;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-import javax.context.ScopeType;
-
-@ScopeType
-(a)Retention(RetentionPolicy.RUNTIME)
-@interface DummyScoped
-{
-
-}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetOnInactiveContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetOnInactiveContextTest.java 2009-03-27
13:06:18 UTC (rev 2226)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetOnInactiveContextTest.java 2009-03-27
14:19:05 UTC (rev 2227)
@@ -13,21 +13,6 @@
@Artifact
public class GetOnInactiveContextTest extends AbstractJSR299Test
{
-
-
- Context context;
-
- public void initContext()
- {
- 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()
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetTest.java 2009-03-27
13:06:18 UTC (rev 2226)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetTest.java 2009-03-27
14:19:05 UTC (rev 2227)
@@ -1,7 +1,6 @@
package org.jboss.jsr299.tck.tests.context;
import javax.context.ApplicationScoped;
-import javax.context.Context;
import javax.context.Contextual;
import javax.context.CreationalContext;
import javax.context.SessionScoped;
@@ -14,24 +13,10 @@
@Artifact
public class GetTest extends AbstractJSR299Test
{
-
- Context context;
-
- public void initContext()
- {
- if (context == null)
- {
- context = new DummyContext();
- getCurrentManager().addContext(context);
- }
- }
-
-
@Test(groups = { "contexts" })
@SpecAssertion(section = "8.1", id = "e")
public void testGetMayNotCreateNewInstanceUnlessCreationalContextGiven()
{
- initContext();
Contextual<MySessionBean> mySessionBean =
getCurrentManager().resolveByType(MySessionBean.class).iterator().next();
assert getCurrentManager().getContext(SessionScoped.class).get(mySessionBean) ==
null;
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetWithNoCreationalContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetWithNoCreationalContextTest.java 2009-03-27
13:06:18 UTC (rev 2226)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetWithNoCreationalContextTest.java 2009-03-27
14:19:05 UTC (rev 2227)
@@ -1,6 +1,5 @@
package org.jboss.jsr299.tck.tests.context;
-import javax.context.Context;
import javax.context.Contextual;
import javax.context.SessionScoped;
@@ -12,24 +11,10 @@
@Artifact
public class GetWithNoCreationalContextTest extends AbstractJSR299Test
{
-
- Context context;
-
- public void initContext()
- {
- if (context == null)
- {
- context = new DummyContext();
- getCurrentManager().addContext(context);
- }
- }
-
-
@Test(groups = { "contexts" })
@SpecAssertion(section = "8.1", id = "b")
public void testGetWithoutCreationalContextReturnsNull()
{
- initContext();
Contextual<MySessionBean> mySessionBean =
getCurrentManager().resolveByType(MySessionBean.class).iterator().next();
assert getCurrentManager().getContext(SessionScoped.class).get(mySessionBean) ==
null;
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MySessionBean.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MySessionBean.java 2009-03-27
13:06:18 UTC (rev 2226)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MySessionBean.java 2009-03-27
14:19:05 UTC (rev 2227)
@@ -2,13 +2,11 @@
import java.io.Serializable;
-@DummyScoped
+import javax.context.SessionScoped;
+
+@SessionScoped
class MySessionBean implements Serializable
{
-
- /**
- *
- */
private static final long serialVersionUID = 1L;
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java 2009-03-27
13:06:18 UTC (rev 2226)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java 2009-03-27
14:19:05 UTC (rev 2227)
@@ -24,22 +24,13 @@
public class NormalContextTest extends AbstractJSR299Test
{
- Context context;
-
- public void initContext()
- {
- if (context == null)
- {
- context = new DummyContext();
- getCurrentManager().addContext(context);
- }
- }
-
@Test(groups = { "contexts" })
- @SpecAssertion(section = "8.1", id = "a")
+ @SpecAssertions( {
+ @SpecAssertion(section = "8.1", id = "a"),
+ @SpecAssertion(section = "8.2", id = "c")
+ } )
public void testGetReturnsExistingInstance()
{
- initContext();
Contextual<MySessionBean> mySessionBean =
getCurrentManager().resolveByType(MySessionBean.class).iterator().next();
MyCreationalContext<MySessionBean> myCreationalContext = new
MyCreationalContext<MySessionBean>();
MySessionBean beanInstance =
getCurrentManager().getContext(SessionScoped.class).get(mySessionBean,
myCreationalContext);
@@ -54,7 +45,6 @@
} )
public void testGetWithCreationalContextReturnsNewInstance()
{
- initContext();
MyContextual bean = new MyContextual(getCurrentManager());
bean.setShouldReturnNullInstances(false);
getCurrentManager().addBean(bean);
@@ -69,7 +59,6 @@
@SpecAssertion(section = "8.1", id = "d")
public void
testGetMayNotReturnNullUnlessNoCreationalContextOrContextualCreateReturnsNull()
{
- initContext();
// The case of no creational context is already tested where a null is
// returned. Here we just test that the contextual create can return null.
MyContextual bean = new MyContextual(getCurrentManager());
@@ -85,11 +74,11 @@
@SpecAssertions( {
@SpecAssertion(section = "6", id = "i"),
@SpecAssertion(section = "6", id = "j"),
- @SpecAssertion(section = "8.1", id = "f")
+ @SpecAssertion(section = "8.1", id = "f"),
+ @SpecAssertion(section = "8.2", id = "d")
})
public void testContextDestroysBeansWhenDestroyed()
{
- initContext();
MyContextual bean = new MyContextual(getCurrentManager());
bean.setShouldReturnNullInstances(false);
getCurrentManager().addBean(bean);
@@ -102,4 +91,15 @@
destroyContext(sessionContext);
assert bean.isDestroyCalled();
}
+
+ @Test(groups = { "contexts" })
+ @SpecAssertions( {
+ @SpecAssertion(section = "8.2", id = "e")
+ })
+ public void testSameNormalScopeBeanInjectedEverywhere()
+ {
+ SimpleBeanA instanceOfA =
getCurrentManager().getInstanceByType(SimpleBeanA.class);
+ SimpleBeanB instanceOfB =
getCurrentManager().getInstanceByType(SimpleBeanB.class);
+ assert instanceOfA.getZ() == instanceOfB.getZ();
+ }
}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanA.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanA.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanA.java 2009-03-27
14:19:05 UTC (rev 2227)
@@ -0,0 +1,20 @@
+package org.jboss.jsr299.tck.tests.context;
+
+import java.io.Serializable;
+
+import javax.context.SessionScoped;
+import javax.inject.Current;
+
+@SessionScoped
+public class SimpleBeanA implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ @Current @SessionScoped
+ private SimpleBeanZ z;
+
+ public SimpleBeanZ getZ()
+ {
+ return z;
+ }
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanA.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanB.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanB.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanB.java 2009-03-27
14:19:05 UTC (rev 2227)
@@ -0,0 +1,20 @@
+package org.jboss.jsr299.tck.tests.context;
+
+import java.io.Serializable;
+
+import javax.context.SessionScoped;
+import javax.inject.Current;
+
+@SessionScoped
+public class SimpleBeanB implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ @Current @SessionScoped
+ private SimpleBeanZ z;
+
+ public SimpleBeanZ getZ()
+ {
+ return z;
+ }
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanB.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanZ.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanZ.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanZ.java 2009-03-27
14:19:05 UTC (rev 2227)
@@ -0,0 +1,12 @@
+package org.jboss.jsr299.tck.tests.context;
+
+import java.io.Serializable;
+
+import javax.context.SessionScoped;
+
+@SessionScoped
+public class SimpleBeanZ implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/SimpleBeanZ.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain