Author: andygumbrecht Date: Wed Sep 24 10:55:32 2014 New Revision: 1627275 URL: http://svn.apache.org/r1627275 Log: TOMEE-1359 - Test to highlight that multiple deployments can currently 'look' the same.
Modified: tomee/tomee/branches/tomee-1.7.x/arquillian/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/embedded/MultipleDeploymentsTest.java Modified: tomee/tomee/branches/tomee-1.7.x/arquillian/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/embedded/MultipleDeploymentsTest.java URL: http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/arquillian/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/embedded/MultipleDeploymentsTest.java?rev=1627275&r1=1627274&r2=1627275&view=diff ============================================================================== --- tomee/tomee/branches/tomee-1.7.x/arquillian/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/embedded/MultipleDeploymentsTest.java (original) +++ tomee/tomee/branches/tomee-1.7.x/arquillian/arquillian-tomee-embedded/src/test/java/org/apache/openejb/arquillian/embedded/MultipleDeploymentsTest.java Wed Sep 24 10:55:32 2014 @@ -16,6 +16,10 @@ */ package org.apache.openejb.arquillian.embedded; +import org.apache.openejb.AppContext; +import org.apache.openejb.BeanContext; +import org.apache.openejb.loader.SystemInstance; +import org.apache.openejb.spi.ContainerSystem; import org.apache.tomee.catalina.environment.Hosts; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.OperateOnDeployment; @@ -28,6 +32,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import javax.inject.Inject; +import java.util.List; @RunWith(Arquillian.class) public class MultipleDeploymentsTest extends Assert { @@ -64,18 +69,49 @@ public class MultipleDeploymentsTest ext @Test @OperateOnDeployment("orange") public void testOrange() throws Exception { + + final String className = TestMe.class.getName(); + final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); + final List<AppContext> appContexts = containerSystem.getAppContexts(); + final ClassLoader loader = this.getClass().getClassLoader(); + + int size = appContexts.size(); + assertEquals("Unexpected app count", 4, size); + + for (final AppContext app : appContexts) { + final BeanContext context = containerSystem.getBeanContext(app.getId() + "_" + className); + if (context != null) { + if (context.getBeanClass().getClassLoader() == loader) { + System.out.println("Found '" + className + "' in app: " + app.getId()); + size--; + } + } + } + + assertEquals("Found " + (4 - size) + " matching contexts", 3, size); + assertNotNull(testMe); assertEquals("Unexpected message", MSG, testMe.getMessage()); + + } @Test @OperateOnDeployment("green") - public void testMap() throws Exception { + public void testGreen() throws Exception { + assertNull("Value should be null", testMe); + } - //TODO - Should this actually work as TestMe.class has not been added to 'green'? + @Test + @OperateOnDeployment("blue") + public void testBlue() throws Exception { + assertNull("Value should be null", testMe); + } - assertNotNull(testMe); - assertEquals("Unexpected message", MSG, testMe.getMessage()); + @Test + @OperateOnDeployment("yellow") + public void testYellow() throws Exception { + assertNull("Value should be null", testMe); } public static class TestMe {