Author: dallen6
Date: 2009-03-10 14:41:10 -0400 (Tue, 10 Mar 2009)
New Revision: 1908
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/FrankfurtAmMain.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GrossStadt.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/enterprise/lifecycle/MockCreationalContext.java
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
Log:
Added some implementations for SFSB lifecycle tests; currently marked ri-broken till
problem with SFSB instances is resolved.
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
14:58:59 UTC (rev 1907)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java 2009-03-10
18:41:10 UTC (rev 1908)
@@ -34,42 +34,7 @@
assert false;
}
- @Test(groups = { "enterpriseBeans", "clientProxy",
"lifecycle", "integration", "stub" })
- @SpecAssertions({
- @SpecAssertion(section = "6.5", id = "b"),
- @SpecAssertion(section = "6", id = "e")
- })
- public void testDestroyMethodCalled() throws Exception
- {
- // GoodDoggie.destructorCalled = false;
- // deployBeans(GoodDoggie.class);
- // new RunInDependentContext()
- // {
- //
- // @Override
- // protected void execute() throws Exception
- // {
- // Set<Bean<LocalGoodDoggie>> goodDoggieBeans =
- // manager.resolveByType(LocalGoodDoggie.class);
- // assert goodDoggieBeans.size() == 1;
- // Bean<LocalGoodDoggie> bean = goodDoggieBeans.iterator().next();
- // LocalGoodDoggie doggie = manager.getInstance(bean);
- // bean.destroy(doggie);
- // // TODO Need to verify that the remove method has been called
- // }
- //
- // }.run();
- assert false;
- }
-
@Test(groups = { "enterpriseBeans", "lifecycle",
"integration", "stub" })
- @SpecAssertion(section = "6.5", id = "c")
- public void testRemovedEjbIgnored()
- {
- assert false;
- }
-
- @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/FrankfurtAmMain.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/FrankfurtAmMain.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/FrankfurtAmMain.java 2009-03-10
18:41:10 UTC (rev 1908)
@@ -0,0 +1,50 @@
+package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+
+import javax.context.SessionScoped;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+@Stateful
+@SessionScoped
+public class FrankfurtAmMain implements GrossStadt
+{
+
+ private boolean kleinStadtCreated = false;
+ private boolean kleinStadtDestroyed = false;
+
+ public boolean isKleinStadtCreated()
+ {
+ return kleinStadtCreated;
+ }
+
+ public boolean isKleinStadtDestroyed()
+ {
+ return kleinStadtDestroyed;
+ }
+
+ public void kleinStadtCreated()
+ {
+ kleinStadtCreated = true;
+ }
+
+ public void kleinStadtDestroyed()
+ {
+ kleinStadtDestroyed = true;
+ }
+
+ public void resetCreatedFlags()
+ {
+ kleinStadtCreated = false;
+ }
+
+ public void resetDestroyedFlags()
+ {
+ kleinStadtDestroyed = false;
+ }
+
+ @Remove
+ public void dispose()
+ {
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/FrankfurtAmMain.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GrossStadt.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GrossStadt.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GrossStadt.java 2009-03-10
18:41:10 UTC (rev 1908)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+
+import javax.ejb.Local;
+
+@Local
+public interface GrossStadt
+{
+ public void kleinStadtCreated();
+
+ public void kleinStadtDestroyed();
+
+ public boolean isKleinStadtCreated();
+
+ public boolean isKleinStadtDestroyed();
+
+ public void resetCreatedFlags();
+
+ public void resetDestroyedFlags();
+
+ public void dispose();
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GrossStadt.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Kassel.java 2009-03-10
18:41:10 UTC (rev 1908)
@@ -0,0 +1,34 @@
+package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.context.SessionScoped;
+import javax.ejb.EJB;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+@Stateful
+@SessionScoped
+public class Kassel implements KleinStadt
+{
+ @EJB
+ private GrossStadt grossStadt;
+
+ @PostConstruct
+ public void begründet()
+ {
+ grossStadt.kleinStadtCreated();
+ }
+
+ @Remove
+ public void zustandVergessen()
+ {
+ }
+
+ @PreDestroy
+ public void zustandVerloren()
+ {
+ grossStadt.kleinStadtDestroyed();
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Kassel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/KleinStadt.java 2009-03-10
18:41:10 UTC (rev 1908)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+
+import javax.ejb.Local;
+
+@Local
+public interface KleinStadt
+{
+ public void begründet();
+
+ public void zustandVergessen();
+
+ public void zustandVerloren();
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/KleinStadt.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/MockCreationalContext.java
(from rev 1905,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MockCreationalContext.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/MockCreationalContext.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/MockCreationalContext.java 2009-03-10
18:41:10 UTC (rev 1908)
@@ -0,0 +1,13 @@
+package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+
+import javax.context.CreationalContext;
+
+public class MockCreationalContext<T> implements CreationalContext<T>
+{
+
+ public void push(T incompleteInstance)
+ {
+
+ }
+
+}
Added:
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
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/StatefulSessionBeanLifecycleTest.java 2009-03-10
18:41:10 UTC (rev 1908)
@@ -0,0 +1,101 @@
+/*
+ * 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
+ *
+ */
+@Artifact
+@Packaging(EAR)
+@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";
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/StatefulSessionBeanLifecycleTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain