[Jboss-cvs] JBossAS SVN: r56644 - in projects/microcontainer/trunk/deployers/src: main/org/jboss/deployers/plugins/deployer main/org/jboss/deployers/plugins/deployment main/org/jboss/deployers/plugins/structure main/org/jboss/deployers/plugins/structure/vfs main/org/jboss/deployers/plugins/structure/vfs/war main/org/jboss/deployers/spi/deployer main/org/jboss/deployers/spi/structure main/org/jboss/deployers/spi/structure/vfs tests/org/jboss/test/deployers tests/org/jboss/test/deployers/structure tests/org/jboss/test/deployers/structure/jar/test tests/org/jboss/test/deployers/structure/main tests/org/jboss/test/deployers/structure/main/test tests/org/jboss/test/deployers/structure/war/test
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Sep 8 09:12:38 EDT 2006
Author: adrian at jboss.org
Date: 2006-09-08 09:12:17 -0400 (Fri, 08 Sep 2006)
New Revision: 56644
Added:
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DeployersAllTestSuite.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerJarStructureUnitTestCase.java
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/MainDeployerWarStructureUnitTestCase.java
Removed:
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DependencyAllTestSuite.java
Modified:
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitor.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/StructureDeployerWrapper.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WARStructure.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureDeployer.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/JARStructureUnitTestCase.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/WARStructureUnitTestCase.java
Log:
[JBMICROCONT-5] - Completed basic tests for the MainDeployer structure
phase.
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -116,6 +116,12 @@
@Override
public boolean equals(Object obj)
{
+ if (obj == this)
+ return true;
+ if (obj == null || obj instanceof Deployer == false)
+ return false;
+ if (obj instanceof DeployerWrapper)
+ obj = ((DeployerWrapper) obj).deployer;
return deployer.equals(obj);
}
@@ -124,4 +130,10 @@
{
return deployer.hashCode();
}
+
+ @Override
+ public String toString()
+ {
+ return deployer.toString();
+ }
}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -72,6 +72,9 @@
/** The deployments by name */
private Map<String, DeploymentContext> topLevelDeployments = new ConcurrentHashMap<String, DeploymentContext>();
+
+ /** All deployments by name */
+ private Map<String, DeploymentContext> allDeployments = new ConcurrentHashMap<String, DeploymentContext>();
/** The undeploy work */
private Set<DeploymentContext> undeploy = new CopyOnWriteArraySet<DeploymentContext>();
@@ -80,6 +83,40 @@
private Set<DeploymentContext> deploy = new CopyOnWriteArraySet<DeploymentContext>();
/**
+ * Get the structure deployers
+ *
+ * @return the structure deployers
+ */
+ public synchronized Set<StructureDeployer> getStructureDeployers()
+ {
+ return new HashSet<StructureDeployer>(structureDeployers);
+ }
+
+ /**
+ * Set the structure deployers
+ *
+ * @param deployers the deployers
+ * @throws IllegalArgumentException for null deployers
+ */
+ public synchronized void setStructureDeployers(Set<StructureDeployer> deployers)
+ {
+ if (deployers == null)
+ throw new IllegalArgumentException("Null deployers");
+
+ // Remove all the old deployers that are not in the new set
+ HashSet<StructureDeployer> oldDeployers = new HashSet<StructureDeployer>(structureDeployers);
+ oldDeployers.removeAll(deployers);
+ for (StructureDeployer deployer : oldDeployers)
+ removeStructureDeployer(deployer);
+
+ // Add all the new deployers that were not already present
+ HashSet<StructureDeployer> newDeployers = new HashSet<StructureDeployer>(deployers);
+ newDeployers.removeAll(structureDeployers);
+ for (StructureDeployer deployer : newDeployers)
+ addStructureDeployer(deployer);
+ }
+
+ /**
* Add a structure deployer
*
* @param deployer the deployer
@@ -91,6 +128,7 @@
StructureDeployerWrapper wrapper = new StructureDeployerWrapper(deployer);
structureDeployers.add(wrapper);
// TODO recheck failed deployments
+ log.debug("Added structure deployer: " + deployer);
}
/**
@@ -103,6 +141,7 @@
if (deployer == null)
throw new IllegalArgumentException("Null deployer");
structureDeployers.remove(deployer);
+ log.debug("Remove structure deployer: " + deployer);
}
/**
@@ -147,23 +186,32 @@
if (shutdown.get())
throw new DeploymentException("The main deployer is shutdown");
+ log.debug("Add deployment context: " + context.getName());
+
if (context.isTopLevel() == false)
throw new DeploymentException("Context is not a top level deployment: " + context.getName());
- context = context.clone();
-
- if (context.getStructureDetermined() == YES)
- context.setStructureDetermined(NO);
- context.setProblem(null);
-
String name = context.getName();
DeploymentContext previous = topLevelDeployments.get(name);
+ boolean topLevelFound = false;
if (previous != null)
{
log.debug("Removing previous deployment: " + previous.getName());
removeContext(previous);
+ topLevelFound = true;
}
+ if (topLevelFound == false)
+ {
+ previous = allDeployments.get(name);
+ if (previous != null)
+ throw new IllegalStateException("Deployment already exists as a subdeployment: " + context.getName());
+ }
+
+ if (context.getStructureDetermined() == YES)
+ context.setStructureDetermined(NO);
+ context.setProblem(null);
+
topLevelDeployments.put(name, context);
try
{
@@ -177,16 +225,6 @@
}
addContext(context);
-
- if (context.getProblem() == null)
- {
- Set<DeploymentContext> children = context.getChildren();
- if (children != null)
- {
- for (DeploymentContext child : children)
- addContext(child);
- }
- }
}
public synchronized boolean removeDeploymentContext(String name) throws DeploymentException
@@ -196,12 +234,15 @@
if (shutdown.get())
throw new IllegalStateException("The main deployer is shutdown");
+
+ log.debug("Remove deployment context: " + name);
DeploymentContext context = topLevelDeployments.remove(name);
if (context == null)
return false;
removeContext(context);
+
return true;
}
@@ -342,7 +383,7 @@
}
}
if (result == false && context.isCandidate() == false)
- throw new DeploymentException("No structural deployment recognised the deployment. " + context.getName());
+ throw new DeploymentException("No structural deployer recognised the deployment. " + context.getName());
Set<DeploymentContext> children = context.getChildren();
for (DeploymentContext child : children)
@@ -365,6 +406,7 @@
*/
private void addContext(DeploymentContext context)
{
+ allDeployments.put(context.getName(), context);
if (context.getState() == ERROR)
{
log.debug("Not scheduling addition of context already in error: " + context.getName());
@@ -374,6 +416,14 @@
context.setState(DEPLOYING);
log.debug("Scheduling deployment: " + context.getName());
deploy.add(context);
+
+ // Add all the children
+ Set<DeploymentContext> children = context.getChildren();
+ if (children != null)
+ {
+ for (DeploymentContext child : children)
+ addContext(child);
+ }
}
/**
@@ -383,6 +433,7 @@
*/
private void removeContext(DeploymentContext context)
{
+ allDeployments.remove(context.getName());
if (context.getState() == ERROR)
{
log.debug("Not scheduling removal of context already in error: " + context.getName());
@@ -391,5 +442,13 @@
context.setState(UNDEPLOYING);
log.debug("Scheduling undeployment: " + context.getName());
undeploy.add(context);
+
+ // Remove all the children
+ Set<DeploymentContext> children = context.getChildren();
+ if (children != null)
+ {
+ for (DeploymentContext child : children)
+ removeContext(child);
+ }
}
}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -35,7 +35,6 @@
import org.jboss.deployers.spi.structure.DeploymentState;
import org.jboss.deployers.spi.structure.StructureDetermined;
import org.jboss.logging.Logger;
-import org.jboss.util.UnreachableStatementException;
import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
@@ -282,7 +281,7 @@
{
this.metaDataLocation = location;
if (log.isTraceEnabled() && location != null)
- log.trace("MetaData locaton for " + root.getPathName() + " is " + location.getPathName());
+ log.trace("MetaData location for " + root.getPathName() + " is " + location.getPathName());
}
public ClassLoader getClassLoader()
@@ -389,18 +388,6 @@
}
}
- public AbstractDeploymentContext clone()
- {
- try
- {
- return (AbstractDeploymentContext) super.clone();
- }
- catch (CloneNotSupportedException e)
- {
- throw new UnreachableStatementException();
- }
- }
-
public String toString()
{
StringBuilder buffer = new StringBuilder();
@@ -410,9 +397,4 @@
buffer.append('{').append(name).append('}');
return buffer.toString();
}
-
- public void dump()
- {
- log.trace("TODO: dump");
- }
}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitor.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitor.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitor.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -37,6 +37,9 @@
{
/** The parent deployment context */
private final DeploymentContext parent;
+
+ /** The meta data location */
+ private final String metaDataPath;
/**
* Create a new CandidateStructureVisitor.
@@ -62,6 +65,11 @@
if (parent == null)
throw new IllegalArgumentException("Null parent");
this.parent = parent;
+ VirtualFile metaDataLocation = parent.getMetaDataLocation();
+ if (metaDataLocation != null)
+ metaDataPath = metaDataLocation.getPathName();
+ else
+ metaDataPath = null;
}
public void visit(VirtualFile virtualFile)
@@ -79,6 +87,10 @@
*/
protected DeploymentContext createCandidate(VirtualFile virtualFile)
{
+ // Exclude the meta data location
+ if (metaDataPath != null && virtualFile.getPathName().startsWith(metaDataPath))
+ return null;
+
return new AbstractDeploymentContext(virtualFile, true, parent);
}
}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/StructureDeployerWrapper.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/StructureDeployerWrapper.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/StructureDeployerWrapper.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -51,6 +51,7 @@
if (deployer == null)
throw new IllegalArgumentException("Null deployer");
this.deployer = deployer;
+ log = Logger.getLogger(deployer.getClass());
}
public boolean determineStructure(DeploymentContext context)
@@ -66,7 +67,7 @@
if (result == false)
log.trace("Not recognised: " + context.getName());
else
- context.dump();
+ log.trace("Recognised: " + context.getName());
}
return result;
}
@@ -85,6 +86,12 @@
@Override
public boolean equals(Object obj)
{
+ if (obj == this)
+ return true;
+ if (obj == null || obj instanceof StructureDeployer == false)
+ return false;
+ if (obj instanceof StructureDeployerWrapper)
+ obj = ((StructureDeployerWrapper) obj).deployer;
return deployer.equals(obj);
}
@@ -93,4 +100,10 @@
{
return deployer.hashCode();
}
+
+ @Override
+ public String toString()
+ {
+ return deployer.toString();
+ }
}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WARStructure.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WARStructure.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WARStructure.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -38,6 +38,12 @@
*/
public class WARStructure extends AbstractStructureDeployer
{
+ @Override
+ public int getRelativeOrder()
+ {
+ return 1000;
+ }
+
public boolean determineStructure(DeploymentContext context)
{
try
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -75,7 +75,10 @@
{
public int compare(Deployer o1, Deployer o2)
{
- return o1.getRelativeOrder() - o2.getRelativeOrder();
+ int relative = o1.getRelativeOrder() - o2.getRelativeOrder();
+ if (relative != 0)
+ return relative;
+ return o1.toString().compareTo(o2.toString());
}
}
}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -35,7 +35,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public interface DeploymentContext extends Cloneable
+public interface DeploymentContext
{
/**
* Get the deployment name
@@ -221,16 +221,4 @@
* @param problem the problem
*/
void setProblem(Throwable problem);
-
- /**
- * Clone the context
- *
- * @return the cloned context
- */
- DeploymentContext clone();
-
- /**
- * A debug method that dumps the context to the log
- */
- void dump();
}
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureDeployer.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureDeployer.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -58,7 +58,10 @@
{
public int compare(StructureDeployer o1, StructureDeployer o2)
{
- return o1.getRelativeOrder() - o2.getRelativeOrder();
+ int relative = o1.getRelativeOrder() - o2.getRelativeOrder();
+ if (relative != 0)
+ return relative;
+ return o1.toString().compareTo(o2.toString());
}
}
}
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -23,9 +23,12 @@
import java.net.URL;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
import org.jboss.test.BaseTestCase;
import org.jboss.util.NotImplementedException;
import org.jboss.virtual.VFS;
@@ -94,10 +97,42 @@
return url.toString();
}
- protected boolean determineStructure(DeploymentContext context) throws Exception
+ /**
+ * Get the structure deployer for this test
+ *
+ * @return the deployer
+ */
+ protected StructureDeployer getStrucutureDeployer()
{
throw new NotImplementedException("Implemented in subclasses");
}
+
+ /**
+ * Determine the structure
+ *
+ * @param context the context
+ * @return the result
+ */
+ protected boolean determineStructure(DeploymentContext context)
+ {
+ return determineStructure(getStrucutureDeployer(), context);
+ }
+
+ /**
+ * Determine the structure
+ *
+ * @param structure the structural deployer
+ * @param context the context
+ * @return the result
+ */
+ protected boolean determineStructure(StructureDeployer structure, DeploymentContext context)
+ {
+ assertNotNull(structure);
+ assertNotNull(context);
+
+ log.debug("Determining structure: " + context.getName());
+ return structure.determineStructure(context);
+ }
/**
* Assert non of the candidates are valid
@@ -107,10 +142,22 @@
*/
protected void assertCandidatesNotValid(DeploymentContext context) throws Exception
{
+ assertCandidatesNotValid(getStrucutureDeployer(), context);
+ }
+
+ /**
+ * Assert non of the candidates are valid
+ *
+ * @param structure the structure deployer
+ * @param context the context
+ * @throws Exception for any error
+ */
+ protected void assertCandidatesNotValid(StructureDeployer structure, DeploymentContext context) throws Exception
+ {
assertNotNull(context);
for (DeploymentContext child : context.getChildren())
- assertFalse("Should not be a valid candidate: " + child.getName(), determineStructure(child));
+ assertFalse("Should not be a valid candidate: " + child.getName(), determineStructure(structure, child));
}
/**
@@ -121,10 +168,23 @@
*/
protected void assertCandidatesValid(DeploymentContext context) throws Exception
{
+ assertCandidatesValid(getStrucutureDeployer(), context);
+ }
+
+ /**
+ * Assert the candidates are valid
+ *
+ * @param structure the structure deployer
+ * @param context the context
+ * @throws Exception for any error
+ */
+ protected void assertCandidatesValid(StructureDeployer structure, DeploymentContext context) throws Exception
+ {
+ assertNotNull(structure);
assertNotNull(context);
for (DeploymentContext child : context.getChildren())
- assertTrue("Should be a valid candidate: " + child.getName(), determineStructure(child));
+ assertTrue("Should be a valid candidate: " + child.getName(), determineStructure(structure, child));
}
/**
@@ -134,13 +194,50 @@
* @param actual the actual
* @throws Exception for any error
*/
- protected void assertContexts(Set<String> expected, Set<DeploymentContext> actual) throws Exception
+ protected void assertCandidateContexts(Map<String, Boolean> expected, Set<DeploymentContext> actual) throws Exception
{
assertNotNull(expected);
assertNotNull(actual);
- Set<String> contextNames = new HashSet<String>(actual.size());
+ Set<String> contexts = new HashSet<String>(actual.size());
for (DeploymentContext context : actual)
- contextNames.add(context.getName());
- assertEquals(expected, contextNames);
+ contexts.add(context.getName());
+ assertEquals(expected.keySet(), contexts);
}
+
+ /**
+ * Assert the contexts match the expected urls
+ *
+ * @param expected the expected
+ * @param actual the actual
+ * @throws Exception for any error
+ */
+ protected void assertActualContexts(Map<String, Boolean> expected, Set<DeploymentContext> actual) throws Exception
+ {
+ assertNotNull(expected);
+ assertNotNull(actual);
+ Set<String> contexts = new HashSet<String>(actual.size());
+ for (DeploymentContext context : actual)
+ contexts.add(context.getName());
+ Set<String> expectedActualContexts = new HashSet<String> (expected.size());
+ for (Map.Entry<String, Boolean> entry : expected.entrySet())
+ {
+ if (entry.getValue() == true)
+ expectedActualContexts.add(entry.getKey());
+ }
+ assertEquals(expectedActualContexts, contexts);
+ }
+
+ /**
+ * Create a deployment context
+ *
+ * @param root the root
+ * @param path the path
+ * @return the context
+ * @throws Exception for any error
+ */
+ protected DeploymentContext createDeploymentContext(String root, String path) throws Exception
+ {
+ VirtualFile file = getVirtualFile(root, path);
+ return new AbstractDeploymentContext(file);
+ }
}
Deleted: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DependencyAllTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DependencyAllTestSuite.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DependencyAllTestSuite.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -1,51 +0,0 @@
-/*
-* 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;
-
-import org.jboss.test.deployers.structure.StructureTestSuite;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-/**
- * Deployers All Test Suite.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 37459 $
- */
-public class DependencyAllTestSuite extends TestSuite
-{
- public static void main(String[] args)
- {
- TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite("Deployers All Tests");
-
- suite.addTest(StructureTestSuite.suite());
-
- return suite;
- }
-}
Copied: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DeployersAllTestSuite.java (from rev 56611, projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DependencyAllTestSuite.java)
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DependencyAllTestSuite.java 2006-09-07 12:24:00 UTC (rev 56611)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DeployersAllTestSuite.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -0,0 +1,51 @@
+/*
+* 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;
+
+import org.jboss.test.deployers.structure.StructureTestSuite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Deployers All Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37459 $
+ */
+public class DeployersAllTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Deployers All Tests");
+
+ suite.addTest(StructureTestSuite.suite());
+
+ return suite;
+ }
+}
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -26,6 +26,9 @@
import junit.textui.TestRunner;
import org.jboss.test.deployers.structure.jar.test.JARStructureUnitTestCase;
+import org.jboss.test.deployers.structure.main.test.MainDeployerJarStructureUnitTestCase;
+import org.jboss.test.deployers.structure.main.test.MainDeployerStructureUnitTestCase;
+import org.jboss.test.deployers.structure.main.test.MainDeployerWarStructureUnitTestCase;
import org.jboss.test.deployers.structure.war.test.WARStructureUnitTestCase;
/**
@@ -47,6 +50,9 @@
suite.addTest(JARStructureUnitTestCase.suite());
suite.addTest(WARStructureUnitTestCase.suite());
+ suite.addTest(MainDeployerStructureUnitTestCase.suite());
+ suite.addTest(MainDeployerJarStructureUnitTestCase.suite());
+ suite.addTest(MainDeployerWarStructureUnitTestCase.suite());
return suite;
}
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/JARStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/JARStructureUnitTestCase.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/JARStructureUnitTestCase.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -21,17 +21,17 @@
*/
package org.jboss.test.deployers.structure.jar.test;
-import java.util.HashSet;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
import org.jboss.test.deployers.BaseDeployersTest;
-import org.jboss.virtual.VirtualFile;
/**
* JARStructureUnitTestCase.
@@ -53,24 +53,24 @@
{
super(name);
}
-
+
+ @Override
protected void setUp() throws Exception
{
super.setUp();
enableTrace("org.jboss.deployers");
}
- protected boolean determineStructure(DeploymentContext context)
+ @Override
+ protected StructureDeployer getStrucutureDeployer()
{
- log.debug("Determining structure: " + context.getName());
- return structure.determineStructure(context);
+ return structure;
}
protected DeploymentContext getValidContext(String root, String path) throws Exception
{
- VirtualFile file = getVirtualFile(root, path);
- DeploymentContext context = new AbstractDeploymentContext(file);
- assertTrue("Structure should be valid: " + file, determineStructure(context));
+ DeploymentContext context = createDeploymentContext(root, path);
+ assertTrue("Structure should be valid: " + context.getName(), determineStructure(context));
return context;
}
@@ -81,9 +81,8 @@
protected DeploymentContext assertNotValidContext(String root, String path) throws Exception
{
- VirtualFile file = getVirtualFile(root, path);
- DeploymentContext context = new AbstractDeploymentContext(file);
- assertFalse("Structure should not be valid: " + file, determineStructure(context));
+ DeploymentContext context = createDeploymentContext(root, path);
+ assertFalse("Structure should not be valid: " + context.getName(), determineStructure(context));
assertEmpty(context.getChildren());
return context;
}
@@ -93,9 +92,9 @@
DeploymentContext context = getValidContext("/structure/", "jar/simple");
// Test it got all the candidates
- Set<String> expected = new HashSet<String>();
- expected.add(getURL("/structure/jar/simple/simple1.txt"));
- expected.add(getURL("/structure/jar/simple/simple2.txt"));
+ Map<String, Boolean> expected = new HashMap<String, Boolean>();
+ expected.put(getURL("/structure/jar/simple/simple1.txt"), false);
+ expected.put(getURL("/structure/jar/simple/simple2.txt"), false);
assertContexts(expected, context.getChildren());
assertCandidatesNotValid(context);
@@ -112,9 +111,9 @@
DeploymentContext context = getValidContext("/structure/", "jar/notanarchive");
// Test it got all the candidates
- Set<String> expected = new HashSet<String>();
- expected.add(getURL("/structure/jar/notanarchive/NotAnArchive.jar"));
- expected.add(getURL("/structure/jar/notanarchive/NotAnArchive.zip"));
+ Map<String, Boolean> expected = new HashMap<String, Boolean>();
+ expected.put(getURL("/structure/jar/notanarchive/NotAnArchive.jar"), false);
+ expected.put(getURL("/structure/jar/notanarchive/NotAnArchive.zip"), false);
assertContexts(expected, context.getChildren());
assertCandidatesNotValid(context);
@@ -131,9 +130,9 @@
DeploymentContext context = getValidContext("/structure/", "jar/indirectory");
// Test it got all the candidates
- Set<String> expected = new HashSet<String>();
- expected.add(getJarURL("/structure/jar/indirectory/archive.jar").toString());
- expected.add(getJarURL("/structure/jar/indirectory/archive.zip").toString());
+ Map<String, Boolean> expected = new HashMap<String, Boolean>();
+ expected.put(getJarURL("/structure/jar/indirectory/archive.jar"), true);
+ expected.put(getJarURL("/structure/jar/indirectory/archive.zip"), true);
assertContexts(expected, context.getChildren());
assertCandidatesValid(context);
@@ -144,8 +143,8 @@
DeploymentContext context = getValidContext("/structure/", "jar/subdirnotajar");
// Test it got all the candidates
- Set<String> expected = new HashSet<String>();
- expected.add(getURL("/structure/jar/subdirnotajar/sub").toString());
+ Map<String, Boolean> expected = new HashMap<String, Boolean>();
+ expected.put(getURL("/structure/jar/subdirnotajar/sub"), false);
assertContexts(expected, context.getChildren());
assertCandidatesNotValid(context);
@@ -156,8 +155,8 @@
DeploymentContext context = getValidContext("/structure/", "jar/subdirisajar");
// Test it got all the candidates
- Set<String> expected = new HashSet<String>();
- expected.add(getURL("/structure/jar/subdirisajar/sub.jar").toString());
+ Map<String, Boolean> expected = new HashMap<String, Boolean>();
+ expected.put(getURL("/structure/jar/subdirisajar/sub.jar"), true);
assertContexts(expected, context.getChildren());
assertCandidatesValid(context);
@@ -173,10 +172,15 @@
DeploymentContext context = getValidContext("/structure/", "jar/subdirhasmetainf");
// Test it got all the candidates
- Set<String> expected = new HashSet<String>();
- expected.add(getURL("/structure/jar/subdirhasmetainf/sub").toString());
+ Map<String, Boolean> expected = new HashMap<String, Boolean>();
+ expected.put(getURL("/structure/jar/subdirhasmetainf/sub"), true);
assertContexts(expected, context.getChildren());
assertCandidatesValid(context);
}
+
+ protected void assertContexts(Map<String, Boolean> expected, Set<DeploymentContext> actual) throws Exception
+ {
+ assertCandidateContexts(expected, actual);
+ }
}
Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerJarStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerJarStructureUnitTestCase.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerJarStructureUnitTestCase.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -0,0 +1,92 @@
+/*
+* 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.Map;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
+import org.jboss.deployers.plugins.structure.vfs.war.WARStructure;
+import org.jboss.deployers.spi.deployement.MainDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.DeploymentState;
+import org.jboss.test.deployers.structure.jar.test.JARStructureUnitTestCase;
+
+/**
+ * MainDeployerStructureUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MainDeployerJarStructureUnitTestCase extends JARStructureUnitTestCase
+{
+ public static Test suite()
+ {
+ return new TestSuite(MainDeployerJarStructureUnitTestCase.class);
+ }
+
+ public MainDeployerJarStructureUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected DeploymentContext getValidContext(String root, String path) throws Exception
+ {
+ DeploymentContext context = createDeploymentContext(root, path);
+ MainDeployer main = getMainDeployer();
+ main.addDeploymentContext(context);
+ assertFalse("Structure should be valid: " + context.getName(), context.getState() == DeploymentState.ERROR);
+ return context;
+ }
+
+ protected DeploymentContext assertValidContext(String root, String path) throws Exception
+ {
+ return getValidContext(root, path);
+ }
+
+ protected DeploymentContext assertNotValidContext(String root, String path) throws Exception
+ {
+ DeploymentContext context = createDeploymentContext(root, path);
+ MainDeployer main = getMainDeployer();
+ main.addDeploymentContext(context);
+ assertTrue("Structure should not be valid: " + context.getName(), context.getState() == DeploymentState.ERROR);
+ assertEmpty(context.getChildren());
+ return context;
+ }
+
+ protected void assertContexts(Map<String, Boolean> expected, Set<DeploymentContext> actual) throws Exception
+ {
+ assertActualContexts(expected, actual);
+ }
+
+ protected static MainDeployer getMainDeployer()
+ {
+ MainDeployerImpl main = new MainDeployerImpl();
+ main.addStructureDeployer(new JARStructure());
+ main.addStructureDeployer(new WARStructure());
+ return main;
+ }
+}
Added: 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 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -0,0 +1,205 @@
+/*
+* 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.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+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.vfs.StructureDeployer;
+import org.jboss.test.deployers.BaseDeployersTest;
+
+/**
+ * MainDeployerStructureUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MainDeployerStructureUnitTestCase extends BaseDeployersTest
+{
+ public static Test suite()
+ {
+ return new TestSuite(MainDeployerStructureUnitTestCase.class);
+ }
+
+ public MainDeployerStructureUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ enableTrace("org.jboss.deployers");
+ }
+
+ public void testAddNullStructuralDeployer() throws Exception
+ {
+ MainDeployerImpl main = new MainDeployerImpl();
+ try
+ {
+ main.addStructureDeployer(null);
+ fail("Should not be here!");
+ }
+ catch (AssertionFailedError e)
+ {
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ checkThrowable(IllegalArgumentException.class, t);
+ }
+ }
+
+ public void testAddStructuralDeployers() throws Exception
+ {
+ MainDeployerImpl main = new MainDeployerImpl();
+ assertEmpty(main.getStructureDeployers());
+
+ StructureDeployer deployer = new JARStructure();
+ HashSet<StructureDeployer> expected = new HashSet<StructureDeployer>();
+ expected.add(deployer);
+
+ main.addStructureDeployer(deployer);
+ assertEquals(expected, main.getStructureDeployers());
+
+ deployer = new WARStructure();
+ expected.add(deployer);
+
+ main.addStructureDeployer(deployer);
+ assertEquals(expected, main.getStructureDeployers());
+
+ // Duplicate
+ main.addStructureDeployer(deployer);
+ assertEquals(expected, main.getStructureDeployers());
+ }
+
+ public void testRemoveNullStructuralDeployer() throws Exception
+ {
+ MainDeployerImpl main = new MainDeployerImpl();
+ try
+ {
+ main.removeStructureDeployer(null);
+ fail("Should not be here!");
+ }
+ catch (AssertionFailedError e)
+ {
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ checkThrowable(IllegalArgumentException.class, t);
+ }
+ }
+
+ public void testRemoveStructuralDeployers() throws Exception
+ {
+ MainDeployerImpl main = new MainDeployerImpl();
+ assertEmpty(main.getStructureDeployers());
+
+ StructureDeployer jarDeployer = new JARStructure();
+ StructureDeployer warDeployer = new WARStructure();
+ HashSet<StructureDeployer> expected = new HashSet<StructureDeployer>();
+ expected.add(jarDeployer);
+ expected.add(warDeployer);
+ main.addStructureDeployer(jarDeployer);
+ main.addStructureDeployer(warDeployer);
+ assertEquals(expected, main.getStructureDeployers());
+
+ StructureDeployer notPresent = new JARStructure();
+ main.removeStructureDeployer(notPresent);
+ assertEquals(expected, main.getStructureDeployers());
+
+ main.removeStructureDeployer(jarDeployer);
+ expected.remove(jarDeployer);
+ assertEquals(expected, main.getStructureDeployers());
+
+ main.removeStructureDeployer(warDeployer);
+ expected.remove(warDeployer);
+ assertEquals(expected, main.getStructureDeployers());
+ }
+
+ public void testSetNullStructuralDeployers() throws Exception
+ {
+ MainDeployerImpl main = new MainDeployerImpl();
+ try
+ {
+ main.setStructureDeployers(null);
+ fail("Should not be here!");
+ }
+ catch (AssertionFailedError e)
+ {
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ checkThrowable(IllegalArgumentException.class, t);
+ }
+ }
+
+ public void testSetStructuralDeployers() throws Exception
+ {
+ MainDeployerImpl main = new MainDeployerImpl();
+ assertEmpty(main.getStructureDeployers());
+
+ StructureDeployer jarDeployer = new JARStructure();
+ StructureDeployer warDeployer = new WARStructure();
+ Set<StructureDeployer> expected = new HashSet<StructureDeployer>();
+ expected.add(jarDeployer);
+ expected.add(warDeployer);
+ main.setStructureDeployers(expected);
+ assertEquals(expected, main.getStructureDeployers());
+
+ expected = new HashSet<StructureDeployer>();
+ expected.add(jarDeployer);
+ main.setStructureDeployers(expected);
+ assertEquals(expected, main.getStructureDeployers());
+
+ expected = new HashSet<StructureDeployer>();
+ expected.add(warDeployer);
+ main.setStructureDeployers(expected);
+ assertEquals(expected, main.getStructureDeployers());
+
+ expected = Collections.emptySet();
+ main.setStructureDeployers(expected);
+ assertEquals(expected, main.getStructureDeployers());
+ }
+
+ public void testNoStructuralDeployers() throws Exception
+ {
+ MainDeployerImpl main = new MainDeployerImpl();
+ DeploymentContext context = createDeploymentContext("/structure/", "jar/simple");
+ main.addDeploymentContext(context);
+ assertEquals(DeploymentState.ERROR, context.getState());
+ checkThrowable(IllegalStateException.class, context.getProblem());
+ }
+}
Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerWarStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerWarStructureUnitTestCase.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerWarStructureUnitTestCase.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -0,0 +1,82 @@
+/*
+* 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 junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
+import org.jboss.deployers.plugins.structure.vfs.war.WARStructure;
+import org.jboss.deployers.spi.deployement.MainDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.DeploymentState;
+import org.jboss.test.deployers.structure.war.test.WARStructureUnitTestCase;
+
+/**
+ * MainDeployerStructureUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MainDeployerWarStructureUnitTestCase extends WARStructureUnitTestCase
+{
+ public static Test suite()
+ {
+ return new TestSuite(MainDeployerWarStructureUnitTestCase.class);
+ }
+
+ public MainDeployerWarStructureUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected DeploymentContext assertValidContext(String root, String path) throws Exception
+ {
+ DeploymentContext context = createDeploymentContext(root, path);
+ getMainDeployer().addDeploymentContext(context);
+ assertFalse("Structure should be valid: " + context.getName(), context.getState() == DeploymentState.ERROR);
+ assertEmpty(context.getChildren());
+ return context;
+ }
+
+ protected DeploymentContext assertNotValidContext(String root, String path, boolean isValidJar) throws Exception
+ {
+ // It might not be a valid war but it is a valid jar
+ if (isValidJar)
+ return assertValidContext(root, path);
+
+ DeploymentContext context = createDeploymentContext(root, path);
+ getMainDeployer().addDeploymentContext(context);
+ assertTrue("Structure should not be valid: " + context.getName(), context.getState() == DeploymentState.ERROR);
+ assertEmpty(context.getChildren());
+ return context;
+ }
+
+ protected static MainDeployer getMainDeployer()
+ {
+ MainDeployerImpl main = new MainDeployerImpl();
+ main.addStructureDeployer(new JARStructure());
+ main.addStructureDeployer(new WARStructure());
+ return main;
+ }
+}
Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/WARStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/WARStructureUnitTestCase.java 2006-09-08 10:15:45 UTC (rev 56643)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/war/test/WARStructureUnitTestCase.java 2006-09-08 13:12:17 UTC (rev 56644)
@@ -24,11 +24,10 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
import org.jboss.deployers.plugins.structure.vfs.war.WARStructure;
import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
import org.jboss.test.deployers.BaseDeployersTest;
-import org.jboss.virtual.VirtualFile;
/**
* WARStructureUnitTestCase.
@@ -50,33 +49,32 @@
{
super(name);
}
-
+
+ @Override
protected void setUp() throws Exception
{
super.setUp();
enableTrace("org.jboss.deployers");
}
- protected boolean determineStructure(DeploymentContext context)
+ @Override
+ protected StructureDeployer getStrucutureDeployer()
{
- log.debug("Determining structure: " + context.getName());
- return structure.determineStructure(context);
+ return structure;
}
protected DeploymentContext assertValidContext(String root, String path) throws Exception
{
- VirtualFile file = getVirtualFile(root, path);
- DeploymentContext context = new AbstractDeploymentContext(file);
- assertTrue("Structure should be valid: " + file, determineStructure(context));
+ DeploymentContext context = createDeploymentContext(root, path);
+ assertTrue("Structure should be valid: " + context.getName(), determineStructure(context));
assertEmpty(context.getChildren());
return context;
}
- protected DeploymentContext assertNotValidContext(String root, String path) throws Exception
+ protected DeploymentContext assertNotValidContext(String root, String path, boolean isValidJar) throws Exception
{
- VirtualFile file = getVirtualFile(root, path);
- DeploymentContext context = new AbstractDeploymentContext(file);
- assertFalse("Structure should not be valid: " + file, determineStructure(context));
+ DeploymentContext context = createDeploymentContext(root, path);
+ assertFalse("Structure should not be valid: " + context.getName(), determineStructure(context));
assertEmpty(context.getChildren());
return context;
}
@@ -88,7 +86,7 @@
public void testNotAnArchive() throws Exception
{
- assertNotValidContext("/structure/", "war/notanarchive/notanarchive.war");
+ assertNotValidContext("/structure/", "war/notanarchive/notanarchive.war", false);
}
public void testWarDirectory() throws Exception
@@ -98,7 +96,7 @@
public void testDirectoryNotAWar() throws Exception
{
- assertNotValidContext("/structure/", "war/directorynotawar");
+ assertNotValidContext("/structure/", "war/directorynotawar", true);
}
public void testDirectoryWithWebInf() throws Exception
More information about the jboss-cvs-commits
mailing list