[jboss-svn-commits] JBL Code SVN: r24198 - in labs/jbossesb/workspace/skeagh/container/microcontainer/src: test/java/org/jboss/esb/microcontainer/deployers and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Dec 2 03:38:47 EST 2008
Author: beve
Date: 2008-12-02 03:38:47 -0500 (Tue, 02 Dec 2008)
New Revision: 24198
Modified:
labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployers/EsbParserDeployer.java
labs/jbossesb/workspace/skeagh/container/microcontainer/src/test/java/org/jboss/esb/microcontainer/deployers/EsbParserDeployerTest.java
labs/jbossesb/workspace/skeagh/container/microcontainer/src/test/java/org/jboss/esb/microcontainer/deployers/EsbRuntimeDeployerTest.java
labs/jbossesb/workspace/skeagh/container/microcontainer/src/test/java/org/jboss/esb/microcontainer/deployers/TestUtil.java
Log:
Refactored tests.
Modified: labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployers/EsbParserDeployer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployers/EsbParserDeployer.java 2008-12-02 08:11:39 UTC (rev 24197)
+++ labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployers/EsbParserDeployer.java 2008-12-02 08:38:47 UTC (rev 24198)
@@ -44,8 +44,7 @@
* Sample configuration:
* <pre>{@code
* <bean name="EsbParserDeployer" class="org.jboss.esb.microcontainer.deployers.EsbParserDeployer"/>
- * }
- * </pre>
+ * }</pre>
*
* @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
* @since 5.0
Modified: labs/jbossesb/workspace/skeagh/container/microcontainer/src/test/java/org/jboss/esb/microcontainer/deployers/EsbParserDeployerTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/container/microcontainer/src/test/java/org/jboss/esb/microcontainer/deployers/EsbParserDeployerTest.java 2008-12-02 08:11:39 UTC (rev 24197)
+++ labs/jbossesb/workspace/skeagh/container/microcontainer/src/test/java/org/jboss/esb/microcontainer/deployers/EsbParserDeployerTest.java 2008-12-02 08:38:47 UTC (rev 24198)
@@ -20,21 +20,10 @@
*/
package org.jboss.esb.microcontainer.deployers;
-import java.net.URL;
-
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentUnit;
-import org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl;
-import org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder;
-import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
-import org.jboss.deployers.vfs.spi.structure.StructureDeployer;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.esb.api.exception.DeploymentException;
import org.jboss.esb.microcontainer.metadata.EsbMetaData;
import org.jboss.test.kernel.junit.MicrocontainerTest;
-import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
/**
@@ -75,8 +64,8 @@
private void assertDeployed(final String archiveName) throws Exception, DeploymentException
{
- VirtualFile virtualFile = getVirtualFile(testArchivesDir, archiveName);
- VFSDeploymentUnit deploymentUnit = getDeploymentUnit(virtualFile);
+ VirtualFile virtualFile = TestUtil.getVirtualFile(testArchivesDir, archiveName, this.getClass());
+ VFSDeploymentUnit deploymentUnit = TestUtil.getDeploymentUnit(virtualFile);
EsbMetaData esbMetaData = parserDeployer.parse(deploymentUnit, virtualFile, (EsbMetaData)null);
System.out.println(esbMetaData.getAchiveName());
@@ -90,37 +79,4 @@
parserDeployer = (EsbParserDeployer) getBean("EsbParserDeployer");
}
- private VFSDeploymentUnit getDeploymentUnit(final VirtualFile esbArchive) throws Exception
- {
- VFSDeploymentContext deploymentContext = getDeploymentContext(esbArchive);
- deploymentContext.setClassLoader(getClass().getClassLoader());
- return getDeploymentUnit(deploymentContext);
- }
-
- private VFSDeploymentUnit getDeploymentUnit(final VFSDeploymentContext deploymentContext)
- {
- return new AbstractVFSDeploymentUnit(deploymentContext);
- }
-
- private VFSDeploymentContext getDeploymentContext(final VirtualFile esbArchive) throws Exception
- {
- VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(esbArchive);
- VFSStructuralDeployersImpl structuralDeployers = new VFSStructuralDeployersImpl();
- VFSStructureBuilder builder = new VFSStructureBuilder();
- structuralDeployers.setStructureBuilder(builder);
- StructureDeployer[] deployers = new StructureDeployer[]{new JARStructure()};
- for (StructureDeployer deployer : deployers)
- {
- structuralDeployers.addDeployer(deployer);
- }
- return (VFSDeploymentContext) structuralDeployers.determineStructure(deployment);
- }
-
-
- private VirtualFile getVirtualFile(String directory, String fileName) throws Exception
- {
- URL url = getResource(directory);
- return VFS.getVirtualFile(url, fileName);
- }
-
}
Modified: labs/jbossesb/workspace/skeagh/container/microcontainer/src/test/java/org/jboss/esb/microcontainer/deployers/EsbRuntimeDeployerTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/container/microcontainer/src/test/java/org/jboss/esb/microcontainer/deployers/EsbRuntimeDeployerTest.java 2008-12-02 08:11:39 UTC (rev 24197)
+++ labs/jbossesb/workspace/skeagh/container/microcontainer/src/test/java/org/jboss/esb/microcontainer/deployers/EsbRuntimeDeployerTest.java 2008-12-02 08:38:47 UTC (rev 24198)
@@ -20,21 +20,10 @@
*/
package org.jboss.esb.microcontainer.deployers;
-import java.net.URL;
-
import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentUnit;
-import org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl;
-import org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder;
-import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
-import org.jboss.deployers.vfs.spi.structure.StructureDeployer;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.esb.microcontainer.metadata.EsbMetaData;
import org.jboss.test.kernel.junit.MicrocontainerTest;
-import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
/**
@@ -68,44 +57,11 @@
{
super.setUp();
final String archiveName = "exploded-esb-archive.jar";
- VirtualFile virtualFile = getVirtualFile(testArchivesDir, archiveName);
- deploymentUnit = getDeploymentUnit(virtualFile);
+ final VirtualFile virtualFile = TestUtil.getVirtualFile(testArchivesDir, archiveName, this.getClass());
+ deploymentUnit = TestUtil.getDeploymentUnit(virtualFile);
EsbParserDeployer parserDeployer = (EsbParserDeployer) getBean("EsbParserDeployer");
esbMetaData = parserDeployer.parse(deploymentUnit, virtualFile, (EsbMetaData)null);
runtimeDeployer = (EsbRuntimeDeployer) getBean("EsbRuntimeDeployer");
}
- private VFSDeploymentUnit getDeploymentUnit(final VirtualFile esbArchive) throws Exception
- {
- VFSDeploymentContext deploymentContext = getDeploymentContext(esbArchive);
- deploymentContext.setClassLoader(getClass().getClassLoader());
- return getDeploymentUnit(deploymentContext);
- }
-
- private VFSDeploymentUnit getDeploymentUnit(final VFSDeploymentContext deploymentContext)
- {
- return new AbstractVFSDeploymentUnit(deploymentContext);
- }
-
- private VFSDeploymentContext getDeploymentContext(final VirtualFile esbArchive) throws Exception
- {
- VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(esbArchive);
- VFSStructuralDeployersImpl structuralDeployers = new VFSStructuralDeployersImpl();
- VFSStructureBuilder builder = new VFSStructureBuilder();
- structuralDeployers.setStructureBuilder(builder);
- StructureDeployer[] deployers = new StructureDeployer[]{new JARStructure()};
- for (StructureDeployer deployer : deployers)
- {
- structuralDeployers.addDeployer(deployer);
- }
- return (VFSDeploymentContext) structuralDeployers.determineStructure(deployment);
- }
-
-
- private VirtualFile getVirtualFile(String directory, String fileName) throws Exception
- {
- URL url = getResource(directory);
- return VFS.getVirtualFile(url, fileName);
- }
-
}
Modified: labs/jbossesb/workspace/skeagh/container/microcontainer/src/test/java/org/jboss/esb/microcontainer/deployers/TestUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/container/microcontainer/src/test/java/org/jboss/esb/microcontainer/deployers/TestUtil.java 2008-12-02 08:11:39 UTC (rev 24197)
+++ labs/jbossesb/workspace/skeagh/container/microcontainer/src/test/java/org/jboss/esb/microcontainer/deployers/TestUtil.java 2008-12-02 08:38:47 UTC (rev 24198)
@@ -29,9 +29,16 @@
import java.net.URL;
import java.util.List;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentContext;
-import org.jboss.esb.microcontainer.metadata.EsbMetaData;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentUnit;
+import org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl;
+import org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder;
+import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.deployers.vfs.spi.structure.StructureDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.spi.VFSContext;
import org.jboss.virtual.spi.VirtualFileHandler;
@@ -48,20 +55,39 @@
{
}
- public static DeploymentUnit createDeploymentUnit(final VirtualFile esbConfigVF)
+ public static VFSDeploymentUnit getDeploymentUnit(final VirtualFile esbArchive) throws Exception
{
- AbstractVFSDeploymentContext context = new AbstractVFSDeploymentContext("esbTest", "esbTest", esbConfigVF, esbConfigVF.getPathName());
- context.setClassLoader(TestUtil.class.getClassLoader());
- DeploymentUnit unit = context.getDeploymentUnit();
- unit.addAttachment(EsbMetaData.class.getName() + ".altDD", esbConfigVF);
- return unit;
+ VFSDeploymentContext deploymentContext = getDeploymentContext(esbArchive);
+ deploymentContext.setClassLoader(TestUtil.class.getClassLoader());
+ return getDeploymentUnit(deploymentContext);
}
- public static File createEsbConfigFile(final String fileName)
+ public static VFSDeploymentUnit getDeploymentUnit(final VFSDeploymentContext deploymentContext)
{
- return new File(TestUtil.class.getResource(fileName).getFile());
+ return new AbstractVFSDeploymentUnit(deploymentContext);
}
+ public static VFSDeploymentContext getDeploymentContext(final VirtualFile esbArchive) throws Exception
+ {
+ VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(esbArchive);
+ VFSStructuralDeployersImpl structuralDeployers = new VFSStructuralDeployersImpl();
+ VFSStructureBuilder builder = new VFSStructureBuilder();
+ structuralDeployers.setStructureBuilder(builder);
+ StructureDeployer[] deployers = new StructureDeployer[]{new JARStructure()};
+ for (StructureDeployer deployer : deployers)
+ {
+ structuralDeployers.addDeployer(deployer);
+ }
+ return (VFSDeploymentContext) structuralDeployers.determineStructure(deployment);
+ }
+
+ public static VirtualFile getVirtualFile(final String directory, final String fileName, final Class<?> clazz) throws Exception
+ {
+ URL url = clazz.getResource(directory);
+ return VFS.getVirtualFile(url, fileName);
+ }
+
+
public static VirtualFile getMockVF(final File esbFile)
{
VirtualFile file = new VirtualFile(new VirtualFileHandler()
More information about the jboss-svn-commits
mailing list