Author: rmannibucau
Date: Wed Jun 25 18:12:22 2014
New Revision: 1605531

URL: http://svn.apache.org/r1605531
Log:
TOMEE-1257 correct undeployment of validator* from JNDI + fixing 
bval-evaluation-redeployment test

Modified:
    
tomee/tomee/trunk/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java
    
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
    tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/pom.xml
    
tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/src/test/java/RedeploymentTest.java
    
tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/src/test/resources/arquillian.xml

Modified: 
tomee/tomee/trunk/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/trunk/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java?rev=1605531&r1=1605530&r2=1605531&view=diff
==============================================================================
--- 
tomee/tomee/trunk/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java
 (original)
+++ 
tomee/tomee/trunk/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java
 Wed Jun 25 18:12:22 2014
@@ -419,7 +419,7 @@ public abstract class TomEEContainer<Con
 
     @Override
     public void undeploy(final Archive<?> archive) throws DeploymentException {
-        final DeployedApp deployed = moduleIds.get(archive.getName());
+        final DeployedApp deployed = moduleIds.remove(archive.getName());
         try {
             deployer().undeploy(deployed.path);
         } catch (final Exception e) {

Modified: 
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=1605531&r1=1605530&r2=1605531&view=diff
==============================================================================
--- 
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
 (original)
+++ 
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
 Wed Jun 25 18:12:22 2014
@@ -238,7 +238,6 @@ public class Assembler extends Assembler
     protected OpenEjbConfigurationFactory configFactory;
     private final Map<String, AppInfo> deployedApplications = new 
HashMap<String, AppInfo>();
     private final Map<ObjectName, CreationalContext> 
creationalContextForAppMbeans = new HashMap<ObjectName, CreationalContext>();
-    private final Set<String> moduleIds = new HashSet<String>();
     private final Set<ObjectName> containerObjectNames = new 
HashSet<ObjectName>();
     private final RemoteResourceMonitor remoteResourceMonitor = new 
RemoteResourceMonitor();
 
@@ -702,19 +701,7 @@ public class Assembler extends Assembler
                 // Bean Validation
                 // ValidatorFactory needs to be put in the map sent to the 
entity manager factory
                 // so it has to be constructed before
-                final List<CommonInfoObject> vfs = new 
ArrayList<CommonInfoObject>();
-                for (final ClientInfo clientInfo : appInfo.clients) {
-                    vfs.add(clientInfo);
-                }
-                for (final ConnectorInfo connectorInfo : appInfo.connectors) {
-                    vfs.add(connectorInfo);
-                }
-                for (final EjbJarInfo ejbJarInfo : appInfo.ejbJars) {
-                    vfs.add(ejbJarInfo);
-                }
-                for (final WebAppInfo webAppInfo : appInfo.webApps) {
-                    vfs.add(webAppInfo);
-                }
+                final List<CommonInfoObject> vfs = 
listCommonInfoObjectsForAppInfo(appInfo);
 
                 final Map<String, ValidatorFactory> validatorFactories = new 
HashMap<String, ValidatorFactory>();
                 for (final CommonInfoObject info : vfs) {
@@ -728,7 +715,6 @@ public class Assembler extends Assembler
                         validatorFactories.put(info.uniqueId, factory);
                     }
                 }
-                moduleIds.addAll(validatorFactories.keySet());
 
                 // validators bindings
                 for (final Entry<String, ValidatorFactory> validatorFactory : 
validatorFactories.entrySet()) {
@@ -908,6 +894,25 @@ public class Assembler extends Assembler
         }
     }
 
+    private static List<CommonInfoObject> 
listCommonInfoObjectsForAppInfo(final AppInfo appInfo) {
+        final List<CommonInfoObject> vfs = new ArrayList<CommonInfoObject>(
+                                appInfo.clients.size() + 
appInfo.connectors.size() +
+                                appInfo.ejbJars.size() + 
appInfo.webApps.size());
+        for (final ClientInfo clientInfo : appInfo.clients) {
+            vfs.add(clientInfo);
+        }
+        for (final ConnectorInfo connectorInfo : appInfo.connectors) {
+            vfs.add(connectorInfo);
+        }
+        for (final EjbJarInfo ejbJarInfo : appInfo.ejbJars) {
+            vfs.add(ejbJarInfo);
+        }
+        for (final WebAppInfo webAppInfo : appInfo.webApps) {
+            vfs.add(webAppInfo);
+        }
+        return vfs;
+    }
+
     public void bindGlobals(final Map<String, Object> bindings) throws 
NamingException {
         final Context containerSystemContext = 
containerSystem.getJNDIContext();
         for (final Entry<String, Object> value : bindings.entrySet()) {
@@ -1707,15 +1712,16 @@ public class Assembler extends Assembler
                 pool.stop();
             }
 
-            for (final String sId : moduleIds) {
+            for (final CommonInfoObject jar : 
listCommonInfoObjectsForAppInfo(appInfo)) {
                 try {
-                    globalContext.unbind(VALIDATOR_FACTORY_NAMING_CONTEXT + 
sId);
-                    globalContext.unbind(VALIDATOR_NAMING_CONTEXT + sId);
+                    globalContext.unbind(VALIDATOR_FACTORY_NAMING_CONTEXT + 
jar.uniqueId);
+                    globalContext.unbind(VALIDATOR_NAMING_CONTEXT + 
jar.uniqueId);
                 } catch (final NamingException e) {
-                    undeployException.getCauses().add(new 
Exception("validator: " + sId + ": " + e.getMessage(), e));
+                    if (EjbJarInfo.class.isInstance(jar)) {
+                        undeployException.getCauses().add(new 
Exception("validator: " + jar.uniqueId + ": " + e.getMessage(), e));
+                    } // else an error but not that important
                 }
             }
-            moduleIds.clear();
             try {
                 if (globalContext instanceof IvmContext) {
                     final IvmContext ivmContext = (IvmContext) globalContext;

Modified: tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/pom.xml
URL: 
http://svn.apache.org/viewvc/tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/pom.xml?rev=1605531&r1=1605530&r2=1605531&view=diff
==============================================================================
--- tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/pom.xml 
(original)
+++ tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/pom.xml Wed 
Jun 25 18:12:22 2014
@@ -30,6 +30,14 @@
       <groupId>org.apache.cxf</groupId>
       <artifactId>cxf-rt-frontend-jaxrs</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>apache-tomee</artifactId>
+      <version>1.7.0-SNAPSHOT</version>
+      <type>zip</type>
+      <classifier>jaxrs</classifier>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 </project>
\ No newline at end of file

Modified: 
tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/src/test/java/RedeploymentTest.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/src/test/java/RedeploymentTest.java?rev=1605531&r1=1605530&r2=1605531&view=diff
==============================================================================
--- 
tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/src/test/java/RedeploymentTest.java
 (original)
+++ 
tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/src/test/java/RedeploymentTest.java
 Wed Jun 25 18:12:22 2014
@@ -41,7 +41,7 @@ public class RedeploymentTest {
     @Test
     public void validateTest() throws Exception {
 
-        final String port = System.getProperty("server.http.port");
+        final String port = System.getProperty("server.http.port", "8080");
         System.out.println("");
         System.out.println("===========================================");
         System.out.println("Running test on port: " + port);
@@ -53,7 +53,7 @@ public class RedeploymentTest {
         Assert.assertEquals(406, result);
 
         //Not interested in webapp2 output
-        deployer.undeploy("webapp2");
+        // deployer.undeploy("webapp2");
         deployer.deploy("webapp2");
 
         result = WebClient.create("http://localhost:"; + port + 
"/WebApp1/test/")
@@ -61,6 +61,14 @@ public class RedeploymentTest {
         System.out.println(result);
         Assert.assertEquals(406, result);
         deployer.undeploy("webapp2");
+        result = WebClient.create("http://localhost:"; + port + 
"/WebApp1/test/")
+                
.type(MediaType.APPLICATION_JSON_TYPE).post("validd").getStatus();
+        System.out.println(result);
+        Assert.assertEquals(406, result);
+        result = WebClient.create("http://localhost:"; + port + 
"/WebApp1/test/")
+                
.type(MediaType.APPLICATION_JSON_TYPE).post("valid").getStatus();
+        System.out.println(result);
+        Assert.assertEquals(200, result);
         System.out.println("===========================================");
         System.out.println("");
     }

Modified: 
tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/src/test/resources/arquillian.xml
URL: 
http://svn.apache.org/viewvc/tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/src/test/resources/arquillian.xml?rev=1605531&r1=1605530&r2=1605531&view=diff
==============================================================================
--- 
tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/src/test/resources/arquillian.xml
 (original)
+++ 
tomee/tomee/trunk/examples/bval-evaluation-redeployment/runner/src/test/resources/arquillian.xml
 Wed Jun 25 18:12:22 2014
@@ -22,10 +22,10 @@
 
   <container qualifier="tomee" default="true">
     <configuration>
-      <property name="conf">src/test/conf/</property>
       <property name="httpPort">-1</property>
       <property name="stopPort">-1</property>
       <property name="ajpPort">-1</property>
+      <property name="classifier">jaxrs</property>
       <property name="simpleLog">true</property>
       <property name="dir">target/apache-tomee-remote</property>
       <property 
name="appWorkingDir">target/arquillian-test-working-dir</property>


Reply via email to