[Jboss-cvs] JBossAS SVN: r56647 -	projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test
    jboss-cvs-commits at lists.jboss.org 
    jboss-cvs-commits at lists.jboss.org
       
    Fri Sep  8 10:11:46 EDT 2006
    
    
  
Author: adrian at jboss.org
Date: 2006-09-08 10:11:44 -0400 (Fri, 08 Sep 2006)
New Revision: 56647
Added:
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/TestStructureDeployer.java
Modified:
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java
Log:
[JBMICROCONT-5] - Add simple structure pre-determined tests.
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java	2006-09-08 13:38:28 UTC (rev 56646)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java	2006-09-08 14:11:44 UTC (rev 56647)
@@ -30,10 +30,12 @@
 import junit.framework.TestSuite;
 
 import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
 import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
 import org.jboss.deployers.plugins.structure.vfs.war.WARStructure;
 import org.jboss.deployers.spi.structure.DeploymentContext;
 import org.jboss.deployers.spi.structure.DeploymentState;
+import org.jboss.deployers.spi.structure.StructureDetermined;
 import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
 import org.jboss.test.deployers.BaseDeployersTest;
 
@@ -202,4 +204,29 @@
       assertEquals(DeploymentState.ERROR, context.getState());
       checkThrowable(IllegalStateException.class, context.getProblem());
    }
+   
+   public void testPredeterminedStructure() throws Exception
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      TestStructureDeployer deployer = new TestStructureDeployer();
+      main.addStructureDeployer(deployer);
+      
+      DeploymentContext predetermined = new AbstractDeploymentContext("predetermined");
+      predetermined.setStructureDetermined(StructureDetermined.PREDETERMINED);
+      main.addDeploymentContext(predetermined);
+      assertEmpty(deployer.getInvoked());
+   }
+   
+   public void testNotPredeterminedStructure() throws Exception
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      TestStructureDeployer deployer = new TestStructureDeployer();
+      main.addStructureDeployer(deployer);
+      
+      DeploymentContext context = createDeploymentContext("/structure/", "jar/simple");
+      main.addDeploymentContext(context);
+      Set<DeploymentContext> expected = new HashSet<DeploymentContext>();
+      expected.add(context);
+      assertEquals(expected, deployer.getInvoked());
+   }
 }
Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/TestStructureDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/TestStructureDeployer.java	2006-09-08 13:38:28 UTC (rev 56646)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/TestStructureDeployer.java	2006-09-08 14:11:44 UTC (rev 56647)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.deployers.structure.main.test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+
+/**
+ * TestStructureDeployer.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestStructureDeployer extends AbstractStructureDeployer
+{
+   /** The contexts with which we have been invoked */
+   private Set<DeploymentContext> invoked = new HashSet<DeploymentContext>();
+
+   /**
+    * Get the contexts with which we were invoked and clear it
+    * 
+    * @return the set of contexts
+    */
+   public Set<DeploymentContext> getInvoked()
+   {
+      HashSet<DeploymentContext> result = new HashSet<DeploymentContext>(invoked);
+      invoked.clear();
+      return result;
+   }
+   
+   public boolean determineStructure(DeploymentContext context)
+   {
+      invoked.add(context);
+      return true;
+   }
+}
    
    
More information about the jboss-cvs-commits
mailing list