Author: dallen6
Date: 2009-05-15 15:58:11 -0400 (Fri, 15 May 2009)
New Revision: 2687
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/AnimalStereotype.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Den.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Fox.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Litter.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/ConstructorHasDisposesParameterTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ConstructorHasObservesParameterTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/NewSimpleBeanTest.java
Log:
A few more new bean tests
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/ConstructorHasDisposesParameterTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/ConstructorHasDisposesParameterTest.java 2009-05-15
14:43:28 UTC (rev 2686)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/ConstructorHasDisposesParameterTest.java 2009-05-15
19:58:11 UTC (rev 2687)
@@ -13,7 +13,7 @@
public class ConstructorHasDisposesParameterTest extends AbstractJSR299Test
{
- @Test(groups = { "disposalMethod", "stub" })
+ @Test(groups = { "disposalMethod", "ri-broken" })
@SpecAssertion(section = "3.2.6.1", id = "d")
public void testConstructorHasDisposesParameter() throws Exception
{
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ConstructorHasObservesParameterTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ConstructorHasObservesParameterTest.java 2009-05-15
14:43:28 UTC (rev 2686)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ConstructorHasObservesParameterTest.java 2009-05-15
19:58:11 UTC (rev 2687)
@@ -13,7 +13,7 @@
public class ConstructorHasObservesParameterTest extends AbstractJSR299Test
{
- @Test(groups = { "stub", "observerMethod" })
+ @Test(groups = { "ri-broken", "observerMethod" })
@SpecAssertion(section = "3.2.6.1", id = "e")
public void testConstructorHasObservesParameter()
{
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/AnimalStereotype.java
(from rev 2685,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/AnimalStereotype.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/AnimalStereotype.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/AnimalStereotype.java 2009-05-15
19:58:11 UTC (rev 2687)
@@ -0,0 +1,25 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.newSimpleBean;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.annotation.Named;
+import javax.annotation.Stereotype;
+import javax.context.RequestScoped;
+
+@Stereotype
+@Target( { TYPE, METHOD, FIELD })
+@Retention(RUNTIME)
+@RequestScoped
+@Named
+@Inherited
+@interface AnimalStereotype
+{
+
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Den.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Den.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Den.java 2009-05-15
19:58:11 UTC (rev 2687)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.newSimpleBean;
+
+public class Den
+{
+ private String name;
+
+ public Den(String name)
+ {
+ this.name = name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Den.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Fox.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Fox.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Fox.java 2009-05-15
19:58:11 UTC (rev 2687)
@@ -0,0 +1,57 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.newSimpleBean;
+
+import javax.event.Observes;
+import javax.inject.Disposes;
+import javax.inject.Produces;
+
+@AnimalStereotype
+class Fox
+{
+ @Produces
+ private Den den = new Den("FoxDen");
+
+ private int nextLitterSize;
+
+ private boolean litterDisposed = false;
+
+ public void observeEvent(@Observes String event)
+ {
+
+ }
+
+ public Den getDen()
+ {
+ return den;
+ }
+
+ public void setDen(Den den)
+ {
+ this.den = den;
+ }
+
+ public int getNextLitterSize()
+ {
+ return nextLitterSize;
+ }
+
+ public void setNextLitterSize(int nextLitterSize)
+ {
+ this.nextLitterSize = nextLitterSize;
+ }
+
+ @Produces
+ public Litter produceLitter()
+ {
+ return new Litter(nextLitterSize);
+ }
+
+ public void disposeLitter(@Disposes Litter litter)
+ {
+ this.litterDisposed = true;
+ }
+
+ public boolean isLitterDisposed()
+ {
+ return litterDisposed;
+ }
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Fox.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Litter.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Litter.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Litter.java 2009-05-15
19:58:11 UTC (rev 2687)
@@ -0,0 +1,16 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.newSimpleBean;
+
+class Litter
+{
+ private int quantity;
+
+ public Litter(int quantity)
+ {
+ this.quantity = quantity;
+ }
+
+ public int getQuantity()
+ {
+ return quantity;
+ }
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/Litter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/NewSimpleBeanTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/NewSimpleBeanTest.java 2009-05-15
14:43:28 UTC (rev 2686)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/NewSimpleBeanTest.java 2009-05-15
19:58:11 UTC (rev 2687)
@@ -6,6 +6,7 @@
import java.util.Set;
import javax.context.Dependent;
+import javax.context.RequestScoped;
import javax.inject.AnnotationLiteral;
import javax.inject.Current;
import javax.inject.New;
@@ -72,39 +73,88 @@
assert newSimpleBean.getName() == null;
}
- @Test(groups = { "stub", "new" })
+ @Test(groups = { "new" })
@SpecAssertion(section = "3.2.5", id = "h")
public void testNewBeanHasNoStereotypes()
{
- assert false;
+ Bean<Fox> foxBean =
getCurrentManager().resolveByType(Fox.class).iterator().next();
+ assert foxBean.getScopeType().equals(RequestScoped.class);
+ assert foxBean.getName().equals("fox");
+ Bean<Fox> newFoxBean = getCurrentManager().resolveByType(Fox.class, new
NewLiteral()).iterator().next();
+ assert newFoxBean.getScopeType().equals(Dependent.class);
+ assert newFoxBean.getName() == null;
}
- @Test(groups = { "new", "stub" })
+ @Test(groups = { "new" })
@SpecAssertion(section = "3.2.5", id = "i")
public void testNewBeanHasNoObservers()
{
- assert false;
+ // As long as only one observer exists here, we know it is not from the @New bean
+ assert getCurrentManager().resolveObservers("event").size() == 1;
}
- @Test(groups = { "new", "stub" })
+ @Test(groups = { "new" })
@SpecAssertion(section = "3.2.5", id = "k")
- public void testNewBeanHasNoProducerFields()
+ public void testNewBeanHasNoProducerFields() throws Exception
{
- assert false;
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ Fox fox = getCurrentManager().getInstanceByType(Fox.class);
+ Fox newFox = getCurrentManager().getInstanceByType(Fox.class, new
NewLiteral());
+ newFox.setDen(new Den("NewFoxDen"));
+ Den theOnlyDen = getCurrentManager().getInstanceByType(Den.class);
+ assert theOnlyDen.getName().equals(fox.getDen().getName());
+ }
+
+ }.run();
+
}
- @Test(groups = { "new", "stub" })
+ @Test(groups = { "new" })
@SpecAssertion(section = "3.2.5", id = "j")
- public void testNewBeanHasNoProducerMethods()
+ public void testNewBeanHasNoProducerMethods() throws Exception
{
- assert false;
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ Fox fox = getCurrentManager().getInstanceByType(Fox.class);
+ Fox newFox = getCurrentManager().getInstanceByType(Fox.class, new
NewLiteral());
+ fox.setNextLitterSize(3);
+ newFox.setNextLitterSize(5);
+ Litter theOnlyLitter = getCurrentManager().getInstanceByType(Litter.class);
+ assert theOnlyLitter.getQuantity() == fox.getNextLitterSize();
+ }
+
+ }.run();
}
- @Test(groups = { "new", "stub" })
+ @Test(groups = { "new" })
@SpecAssertion(section = "3.2.5", id = "l")
- public void testNewBeanHasNoDisposalMethods()
+ public void testNewBeanHasNoDisposalMethods() throws Exception
{
- assert false;
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ Fox fox = getCurrentManager().getInstanceByType(Fox.class);
+ Fox newFox = getCurrentManager().getInstanceByType(Fox.class, new
NewLiteral());
+ Bean<Litter> litterBean =
getCurrentManager().resolveByType(Litter.class).iterator().next();
+ Litter litter = getCurrentManager().getInstanceByType(Litter.class);
+ litterBean.destroy(litter);
+ assert fox.isLitterDisposed();
+ assert !newFox.isLitterDisposed();
+ }
+
+ }.run();
}
@Test(groups = { "new" })
Show replies by date