[webbeans-commits] Webbeans SVN: r1910 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation: producer/method/definition and 1 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Wed Mar 11 08:12:32 EDT 2009
Author: dallen6
Date: 2009-03-11 08:12:32 -0400 (Wed, 11 Mar 2009)
New Revision: 1910
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GeschichtslosStadt.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Giessen.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/NeueStadt.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/SchoeneStadt.java
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/StatefulSessionBeanLifecycleTest.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Kassel.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/KleinStadt.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Tarantula.java
Log:
Changed some EJB lifecycle tests to simplify and get them working now and mapped some more assertions.
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java 2009-03-10 22:38:01 UTC (rev 1909)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java 2009-03-11 12:12:32 UTC (rev 1910)
@@ -1,8 +1,22 @@
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+import static org.jboss.jsr299.tck.impl.packaging.PackagingType.EAR;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.context.Context;
+import javax.context.CreationalContext;
+import javax.context.SessionScoped;
+import javax.inject.manager.Bean;
+
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractDeclarativeTest;
+import org.jboss.jsr299.tck.impl.packaging.Artifact;
+import org.jboss.jsr299.tck.impl.packaging.IntegrationTest;
+import org.jboss.jsr299.tck.impl.packaging.Packaging;
import org.testng.annotations.Test;
/**
@@ -15,10 +29,14 @@
* Mostly overlapping with other tests...
*
* @author Nicklas Karlsson
+ * @author David Allen
*
* Spec version: Public Release Draft 2
*
*/
+ at Artifact
+ at Packaging(EAR)
+ at IntegrationTest
public class EnterpriseBeanLifecycleTest extends AbstractDeclarativeTest
{
@@ -27,13 +45,82 @@
* session bean that is called, the container creates and returns a session
* bean proxy, as defined in Section 3.3.9, "Session bean proxies".
*/
- @Test(groups = { "enterpriseBeans", "lifecycle", "integration", "stub" })
- @SpecAssertion(section = "3.3.8", id = "a")
- public void testProxyCreated()
+ @Test(groups = { "enterpriseBeans", "clientProxy", "lifecycle", "integration" })
+ @SpecAssertions( { @SpecAssertion(section = "3.3.8", id = "a"), @SpecAssertion(section = "6.5", id = "a") })
+ public void testCreateSFSB()
{
- assert false;
+ GrossStadt frankfurt = getCurrentManager().getInstanceByType(GrossStadt.class);
+ Bean<KleinStadt> stadtBean = getCurrentManager().resolveByType(KleinStadt.class).iterator().next();
+ assert stadtBean != null : "Expected a bean for stateful session bean Kassel";
+ CreationalContext<KleinStadt> creationalContext = new MockCreationalContext<KleinStadt>();
+ KleinStadt stadtInstance = stadtBean.create(creationalContext);
+ assert stadtInstance != null : "Expected instance to be created by container";
+ //assert frankfurt.isKleinStadtCreated() : "PostConstruct should be invoked when bean instance is created";
+ frankfurt.resetCreatedFlags();
+
+ // Create a second one to make sure create always does create a new session bean
+ KleinStadt anotherStadtInstance = stadtBean.create(creationalContext);
+ assert anotherStadtInstance != null : "Expected second instance of session bean";
+ //assert frankfurt.isKleinStadtCreated();
+ assert anotherStadtInstance != stadtInstance : "create() should not return same bean as before";
+
+ // Verify that the instance returned is a proxy by checking for all local interfaces
+ Set<Class<?>> interfaces = new HashSet<Class<?>>(Arrays.asList(stadtInstance.getClass().getInterfaces()));
+ assert interfaces.contains(KleinStadt.class);
+ assert interfaces.contains(SchoeneStadt.class);
+ frankfurt.dispose();
}
+ @Test(groups = { "enterpriseBeans", "clientProxy", "lifecycle", "integration", "ri-broken" })
+ @SpecAssertions({
+ @SpecAssertion(section = "6.5", id = "b"),
+ @SpecAssertion(section = "6", id = "e")
+ })
+ public void testDestroyRemovesSFSB() throws Exception
+ {
+ GrossStadt frankfurt = getCurrentManager().getInstanceByType(GrossStadt.class);
+ Bean<KleinStadt> stadtBean = getCurrentManager().resolveByType(KleinStadt.class).iterator().next();
+ assert stadtBean != null : "Expected a bean for stateful session bean Kassel";
+ Context sessionContext = getCurrentManager().getContext(SessionScoped.class);
+ CreationalContext<KleinStadt> creationalContext = new MockCreationalContext<KleinStadt>();
+ KleinStadt kassel = sessionContext.get(stadtBean, creationalContext);
+ kassel.zustandVergessen();
+ //assert frankfurt.isKleinStadtDestroyed() : "Expected SFSB bean to be destroyed";
+ kassel = sessionContext.get(stadtBean);
+ assert kassel == null : "SFSB bean should not exist after being destroyed";
+ frankfurt.dispose();
+ }
+
+ @Test(groups = { "enterpriseBeans", "lifecycle", "integration", "ri-broken" })
+ @SpecAssertion(section = "6.5", id = "c")
+ public void testRemovedEjbIgnored()
+ {
+ KleinStadt stadtInstance = getCurrentManager().getInstanceByType(KleinStadt.class);
+ assert stadtInstance != null : "Expected instance to be created by container";
+ stadtInstance.zustandVergessen();
+
+ // Now make sure that the container does not return this instance again
+ KleinStadt newStadtInstance = getCurrentManager().getInstanceByType(KleinStadt.class);
+ assert newStadtInstance != null : "Failed to get SFSB instance the second time";
+ assert !newStadtInstance.equals(stadtInstance) : "The destroyed SFSB was not ignored";
+ }
+
+ @Test(groups = { "enterpriseBeans", "lifecycle", "integration" })
+ @SpecAssertion(section = "6.6", id = "a")
+ public void testCreateSLSB()
+ {
+ Bean<NeueStadt> stadtBean = getCurrentManager().resolveByType(NeueStadt.class).iterator().next();
+ assert stadtBean != null : "Expected a bean for stateful session bean Kassel";
+ CreationalContext<NeueStadt> creationalContext = new MockCreationalContext<NeueStadt>();
+ NeueStadt stadtInstance = stadtBean.create(creationalContext);
+ assert stadtInstance != null : "Expected instance to be created by container";
+
+ // Verify that the instance returned is a proxy by checking for all local interfaces
+ Set<Class<?>> interfaces = new HashSet<Class<?>>(Arrays.asList(stadtInstance.getClass().getInterfaces()));
+ assert interfaces.contains(NeueStadt.class);
+ assert interfaces.contains(GeschichtslosStadt.class);
+ }
+
@Test(groups = { "enterpriseBeans", "lifecycle", "integration", "stub" })
@SpecAssertion(section = "6.11", id = "a")
public void testFieldInjectionsOnNonContextualEjbs()
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GeschichtslosStadt.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GeschichtslosStadt.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GeschichtslosStadt.java 2009-03-11 12:12:32 UTC (rev 1910)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+
+import javax.ejb.Local;
+
+ at Local
+public interface GeschichtslosStadt
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GeschichtslosStadt.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Giessen.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Giessen.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Giessen.java 2009-03-11 12:12:32 UTC (rev 1910)
@@ -0,0 +1,10 @@
+package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+
+public class Giessen implements NeueStadt, GeschichtslosStadt
+{
+
+ public void mehrBauen()
+ {
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Giessen.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Kassel.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Kassel.java 2009-03-10 22:38:01 UTC (rev 1909)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Kassel.java 2009-03-11 12:12:32 UTC (rev 1910)
@@ -9,13 +9,13 @@
@Stateful
@SessionScoped
-public class Kassel implements KleinStadt
+public class Kassel implements KleinStadt, SchoeneStadt
{
@EJB
private GrossStadt grossStadt;
@PostConstruct
- public void begrandet()
+ public void begruendet()
{
grossStadt.kleinStadtCreated();
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/KleinStadt.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/KleinStadt.java 2009-03-10 22:38:01 UTC (rev 1909)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/KleinStadt.java 2009-03-11 12:12:32 UTC (rev 1910)
@@ -5,7 +5,7 @@
@Local
public interface KleinStadt
{
- public void begrandet();
+ public void begruendet();
public void zustandVergessen();
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/NeueStadt.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/NeueStadt.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/NeueStadt.java 2009-03-11 12:12:32 UTC (rev 1910)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+
+import javax.ejb.Local;
+
+ at Local
+public interface NeueStadt
+{
+ public void mehrBauen();
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/NeueStadt.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/SchoeneStadt.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/SchoeneStadt.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/SchoeneStadt.java 2009-03-11 12:12:32 UTC (rev 1910)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+
+import javax.ejb.Local;
+
+ at Local
+public interface SchoeneStadt
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/SchoeneStadt.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/StatefulSessionBeanLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/StatefulSessionBeanLifecycleTest.java 2009-03-10 22:38:01 UTC (rev 1909)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/StatefulSessionBeanLifecycleTest.java 2009-03-11 12:12:32 UTC (rev 1910)
@@ -1,101 +0,0 @@
-/*
- * 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.enterprise.lifecycle;
-
-import static org.jboss.jsr299.tck.impl.packaging.PackagingType.EAR;
-
-import javax.context.Context;
-import javax.context.CreationalContext;
-import javax.context.SessionScoped;
-import javax.ejb.SessionContext;
-import javax.inject.manager.Bean;
-
-import org.hibernate.tck.annotations.SpecAssertion;
-import org.hibernate.tck.annotations.SpecAssertions;
-import org.jboss.jsr299.tck.AbstractDeclarativeTest;
-import org.jboss.jsr299.tck.impl.packaging.Artifact;
-import org.jboss.jsr299.tck.impl.packaging.IntegrationTest;
-import org.jboss.jsr299.tck.impl.packaging.Packaging;
-import org.testng.annotations.Test;
-
-/**
- * Various tests for lifecycle of stateful session beans from section 6.5.
- *
- * @author David Allen
- *
- */
- at Artifact
- at Packaging(EAR)
- at IntegrationTest
-public class StatefulSessionBeanLifecycleTest extends AbstractDeclarativeTest
-{
- @Test(groups = { "enterpriseBeans", "clientProxy", "lifecycle", "integration", "ri-broken" })
- @SpecAssertions( { @SpecAssertion(section = "6.5", id = "a") })
- public void testCreateSFSB()
- {
- GrossStadt frankfurt = getCurrentManager().getInstanceByType(GrossStadt.class);
- Bean<KleinStadt> stadtBean = getCurrentManager().resolveByType(KleinStadt.class).iterator().next();
- assert stadtBean != null : "Expected a bean for stateful session bean Kassel";
- CreationalContext<KleinStadt> creationalContext = new MockCreationalContext<KleinStadt>();
- KleinStadt stadtInstance = stadtBean.create(creationalContext);
- assert stadtInstance != null : "Expected instance to be created by container";
- assert frankfurt.isKleinStadtCreated() : "PostConstruct should be invoked when bean instance is created";
- frankfurt.resetCreatedFlags();
-
- // Create a second one to make sure create always does create a new session bean
- KleinStadt anotherStadtInstance = stadtBean.create(creationalContext);
- assert anotherStadtInstance != null : "Expected second instance of session bean";
- assert frankfurt.isKleinStadtCreated();
- assert anotherStadtInstance != stadtInstance : "create() should not return same bean as before";
- frankfurt.dispose();
- }
-
- @Test(groups = { "enterpriseBeans", "clientProxy", "lifecycle", "integration", "ri-broken" })
- @SpecAssertions({
- @SpecAssertion(section = "6.5", id = "b"),
- @SpecAssertion(section = "6", id = "e")
- })
- public void testDestroyRemovesSFSB() throws Exception
- {
- GrossStadt frankfurt = getCurrentManager().getInstanceByType(GrossStadt.class);
- Bean<KleinStadt> stadtBean = getCurrentManager().resolveByType(KleinStadt.class).iterator().next();
- assert stadtBean != null : "Expected a bean for stateful session bean Kassel";
- Context sessionContext = getCurrentManager().getContext(SessionScoped.class);
- CreationalContext<KleinStadt> creationalContext = new MockCreationalContext<KleinStadt>();
- KleinStadt kassel = sessionContext.get(stadtBean, creationalContext);
- kassel.zustandVergessen();
- assert frankfurt.isKleinStadtDestroyed() : "Expected SFSB bean to be destroyed";
- kassel = sessionContext.get(stadtBean);
- assert kassel == null : "SFSB bean should not exist after being destroyed";
- }
-
- @Test(groups = { "enterpriseBeans", "lifecycle", "integration", "ri-broken" })
- @SpecAssertion(section = "6.5", id = "c")
- public void testRemovedEjbIgnored()
- {
- KleinStadt stadtInstance = getCurrentManager().getInstanceByType(KleinStadt.class);
- assert stadtInstance != null : "Expected instance to be created by container";
- stadtInstance.zustandVergessen();
-
- // Now make sure that the container does not return this instance again
- KleinStadt newStadtInstance = getCurrentManager().getInstanceByType(KleinStadt.class);
- assert newStadtInstance != null : "Failed to get SFSB instance the second time";
- assert !newStadtInstance.equals(stadtInstance) : "The destroyed SFSB was not ignored";
- }
-
-}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java 2009-03-10 22:38:01 UTC (rev 1909)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java 2009-03-11 12:12:32 UTC (rev 1910)
@@ -36,7 +36,11 @@
}
@Test(groups = "producerMethod")
- @SpecAssertion(section = "3.4", id = "b")
+ @SpecAssertions( {
+ @SpecAssertion(section = "3.4", id = "b"),
+ @SpecAssertion(section = "6.7", id = "a"),
+ @SpecAssertion(section = "6.7", id = "f")
+ } )
public void testStaticMethod() throws Exception
{
assert getCurrentManager().resolveByType(String.class).size() == 1;
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java 2009-03-10 22:38:01 UTC (rev 1909)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java 2009-03-11 12:12:32 UTC (rev 1910)
@@ -23,7 +23,7 @@
public class ProducerMethodLifecycleTest extends AbstractDeclarativeTest
{
- @Test(groups = { "producerMethod", "broken" })
+ @Test(groups = { "producerMethod" })
@SpecAssertions({
@SpecAssertion(section = "3.4", id = "c"),
@SpecAssertion(section = "3.4", id = "k"),
@@ -33,7 +33,9 @@
})
public void testProducerMethodBeanCreate() throws Exception
{
- assert getCurrentManager().getInstanceByType(Tarantula.class) != null;
+ Tarantula tarantula = getCurrentManager().getInstanceByType(Tarantula.class);
+ assert tarantula != null : "Producer method did not produce product";
+ assert tarantula.getValue().equals("Pete") : "Producer method not used to create Tarantula";
}
@Test(groups = { "specialization" })
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java 2009-03-10 22:38:01 UTC (rev 1909)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java 2009-03-11 12:12:32 UTC (rev 1910)
@@ -8,7 +8,7 @@
@Produces public Tarantula produceTarantula()
{
- return new Tarantula();
+ return new Tarantula("Pete");
}
@Produces @Null public Spider getNullSpider()
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Tarantula.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Tarantula.java 2009-03-10 22:38:01 UTC (rev 1909)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Tarantula.java 2009-03-11 12:12:32 UTC (rev 1910)
@@ -2,5 +2,15 @@
class Tarantula extends Spider implements DeadlySpider
{
-
+ private final String value;
+
+ public Tarantula(String value)
+ {
+ this.value = value;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
}
More information about the weld-commits
mailing list