Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TCK test for Andy to work with remove method stuff in core test - to …
…be removed once Andy is done git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@2506 1c488680-804c-0410-94cd-c6b725194a0e
- Loading branch information
Showing
25 changed files
with
482 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...c/test/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/AlteStadt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
import javax.ejb.Local; | ||
|
||
@Local | ||
public interface AlteStadt | ||
{ | ||
public String getPlaceOfInterest(); | ||
|
||
public void performPostConstructChecks(); | ||
|
||
public void initializeBean(GutenbergMuseum pointOfInterest); | ||
|
||
public GutenbergMuseum getAnotherPlaceOfInterest(); | ||
} |
9 changes: 9 additions & 0 deletions
9
.../org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/DirectOrderProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
import javax.ejb.Stateful; | ||
|
||
@Stateful | ||
public class DirectOrderProcessor extends OrderProcessor implements DirectOrderProcessorLocal | ||
{ | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/DirectOrderProcessorLocal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
import javax.ejb.Local; | ||
|
||
@Local | ||
public interface DirectOrderProcessorLocal | ||
{ | ||
void order(); | ||
} |
87 changes: 87 additions & 0 deletions
87
...oss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import javax.context.Context; | ||
import javax.context.CreationalContext; | ||
import javax.context.RequestScoped; | ||
import javax.inject.manager.Bean; | ||
|
||
import org.jboss.testharness.impl.packaging.Artifact; | ||
import org.jboss.testharness.impl.packaging.IntegrationTest; | ||
import org.jboss.testharness.impl.packaging.Packaging; | ||
import org.jboss.testharness.impl.packaging.PackagingType; | ||
import org.jboss.webbeans.test.AbstractWebBeansTest; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* Sections | ||
* | ||
* 6.5. Lifecycle of stateful session beans | ||
* 6.6. Lifecycle of stateless session and singleton beans | ||
* 6.11. Lifecycle of EJBs | ||
* | ||
* Mostly overlapping with other tests... | ||
* | ||
* @author Nicklas Karlsson | ||
* @author David Allen | ||
* | ||
* Spec version: Public Release Draft 2 | ||
* | ||
*/ | ||
@Artifact | ||
@Packaging(PackagingType.EAR) | ||
@IntegrationTest | ||
public class EnterpriseBeanLifecycleTest extends AbstractWebBeansTest | ||
{ | ||
|
||
/** | ||
* When the create() method of a Bean object that represents a stateful | ||
* 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", "clientProxy", "lifecycle", "integration" }) | ||
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"; | ||
|
||
// 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" }) | ||
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 requestContext = getCurrentManager().getContext(RequestScoped.class); | ||
CreationalContext<KleinStadt> creationalContext = new MockCreationalContext<KleinStadt>(); | ||
KleinStadt kassel = requestContext.get(stadtBean, creationalContext); | ||
stadtBean.destroy(kassel); | ||
|
||
assert frankfurt.isKleinStadtDestroyed() : "Expected SFSB bean to be destroyed"; | ||
kassel = requestContext.get(stadtBean); | ||
assert kassel == null : "SFSB bean should not exist after being destroyed"; | ||
//frankfurt.dispose(); | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
.../java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/FrankfurtAmMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
import javax.context.RequestScoped; | ||
import javax.ejb.Remove; | ||
import javax.ejb.Stateful; | ||
|
||
@Stateful | ||
@RequestScoped | ||
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() | ||
{ | ||
} | ||
|
||
private boolean schlossDestroyed = false; | ||
|
||
public boolean isSchlossDestroyed() | ||
{ | ||
return schlossDestroyed; | ||
} | ||
|
||
public void schlossDestroyed() | ||
{ | ||
schlossDestroyed = true; | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...va/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GeschichtslosStadt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
import javax.ejb.Local; | ||
|
||
@Local | ||
public interface GeschichtslosStadt | ||
{ | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...src/test/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Giessen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
public class Giessen implements NeueStadt, GeschichtslosStadt | ||
{ | ||
|
||
public void mehrBauen() | ||
{ | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
.../test/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GrossStadt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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(); | ||
|
||
public void schlossDestroyed(); | ||
|
||
public boolean isSchlossDestroyed(); | ||
} |
6 changes: 6 additions & 0 deletions
6
.../java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GutenbergMuseum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
public class GutenbergMuseum | ||
{ | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...rg/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/IndirectOrderProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
import javax.ejb.Stateful; | ||
|
||
@Stateful | ||
public class IndirectOrderProcessor extends IntermediateOrderProcessor implements OrderProcessorLocal | ||
{ | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
...boss/jsr299/tck/tests/implementation/enterprise/lifecycle/IntermediateOrderProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
class IntermediateOrderProcessor extends OrderProcessor | ||
{ | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
.../src/test/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Kassel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.annotation.PreDestroy; | ||
import javax.context.RequestScoped; | ||
import javax.ejb.EJB; | ||
import javax.ejb.Remove; | ||
import javax.ejb.Stateful; | ||
|
||
@Stateful | ||
@RequestScoped | ||
public class Kassel implements KleinStadt, SchoeneStadt | ||
{ | ||
@EJB | ||
private GrossStadt grossStadt; | ||
|
||
@PostConstruct | ||
public void begruendet() | ||
{ | ||
grossStadt.kleinStadtCreated(); | ||
} | ||
|
||
@Remove | ||
public void zustandVergessen() | ||
{ | ||
} | ||
|
||
@PreDestroy | ||
public void zustandVerloren() | ||
{ | ||
grossStadt.kleinStadtDestroyed(); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
.../test/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/KleinStadt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
import javax.ejb.Local; | ||
|
||
@Local | ||
public interface KleinStadt | ||
{ | ||
public void begruendet(); | ||
|
||
public void zustandVergessen(); | ||
|
||
public void zustandVerloren(); | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...va/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/LandgraffenSchloss.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
import javax.annotation.PreDestroy; | ||
import javax.context.Dependent; | ||
import javax.ejb.Remove; | ||
import javax.ejb.Stateful; | ||
import javax.inject.Current; | ||
|
||
@Stateful | ||
@Dependent | ||
public class LandgraffenSchloss implements Schloss | ||
{ | ||
@Current | ||
private GrossStadt biggerCity; | ||
|
||
@PreDestroy | ||
public void destructionCallback() | ||
{ | ||
biggerCity.schlossDestroyed(); | ||
} | ||
|
||
@Remove | ||
public void remove() | ||
{ | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...s/src/test/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Mainz.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.ejb.Stateless; | ||
import javax.inject.Current; | ||
import javax.inject.Initializer; | ||
|
||
@Stateless | ||
public class Mainz implements AlteStadt | ||
{ | ||
@Current | ||
private RoemerPassage placeOfInterest; | ||
|
||
private GutenbergMuseum anotherPlaceOfInterest; | ||
|
||
private String name; | ||
|
||
public String getPlaceOfInterest() | ||
{ | ||
return name; | ||
} | ||
|
||
@PostConstruct | ||
public void performPostConstructChecks() | ||
{ | ||
if ( placeOfInterest != null ) | ||
name = placeOfInterest.getName(); | ||
} | ||
|
||
@Initializer | ||
public void initializeBean(@Current GutenbergMuseum pointOfInterest) | ||
{ | ||
this.anotherPlaceOfInterest = pointOfInterest; | ||
} | ||
|
||
public GutenbergMuseum getAnotherPlaceOfInterest() | ||
{ | ||
return anotherPlaceOfInterest; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...src/test/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Marburg.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle; | ||
|
||
import javax.ejb.Remove; | ||
import javax.ejb.Stateful; | ||
import javax.inject.Current; | ||
|
||
@Stateful | ||
public class Marburg implements UniStadt | ||
{ | ||
@Current | ||
private Schloss theCastle; | ||
|
||
@Remove | ||
public void removeBean() | ||
{ | ||
} | ||
|
||
} |
Oops, something went wrong.