[jboss-cvs] JBossAS SVN: r99812 - projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/org/jboss/reloaded/api.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jan 22 11:24:23 EST 2010
Author: ALRubinger
Date: 2010-01-22 11:24:22 -0500 (Fri, 22 Jan 2010)
New Revision: 99812
Removed:
projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/org/jboss/reloaded/api/MainDeployerTestBase.java
Modified:
projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/org/jboss/reloaded/api/MainDeployerViaBootstrapUnitTest.java
Log:
[RELOADED-10] Centralize the test into one class; easier to read/manage and the abstraction is no longer necessary
Deleted: projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/org/jboss/reloaded/api/MainDeployerTestBase.java
===================================================================
--- projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/org/jboss/reloaded/api/MainDeployerTestBase.java 2010-01-22 16:14:22 UTC (rev 99811)
+++ projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/org/jboss/reloaded/api/MainDeployerTestBase.java 2010-01-22 16:24:22 UTC (rev 99812)
@@ -1,160 +0,0 @@
-package org.jboss.reloaded.api;
-
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.File;
-
-import junit.framework.TestCase;
-
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.Deployer;
-import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
-import org.jboss.kernel.Kernel;
-import org.jboss.logging.Logger;
-import org.jboss.shrinkwrap.api.Archives;
-import org.jboss.shrinkwrap.api.exporter.ZipExporter;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-import org.junit.Test;
-
-/**
- * Base support for tests of MainDeployer and VDF
- * in a minimal setup which ensures that we can bring up MC and the
- * Virtual Deployers Framework
- * in an isolated context, supporting installation of new {@link Deployer}
- * instances into the chain which will be used to process incoming {@link Deployment}s
- * made into the {@link MainDeployer}.
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public abstract class MainDeployerTestBase
-{
-
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(MainDeployerTestBase.class);
-
- /**
- * Name of the archive we'll deploy
- */
- private static final String NAME_ARCHIVE = "testDeployment.jar";
-
- /**
- * Extension to give to TMP files
- */
- private static final String EXTENSION_TMP = ".tmp";
-
- /**
- * MC bean name of the {@link MainDeployer}
- */
- protected static final String NAME_MC_MAIN_DEPLOYER = "MainDeployer";
-
- //-------------------------------------------------------------------------------------||
- // Tests ------------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Ensures that VDF is brought up by:
- * 1) Installing a new Deployer
- * 2) Processing a deployment via MainDeployer
- * 3) Ensuring the new Deployer processes the incoming DeploymentUnit
- */
- @Test
- public void testVdfBoot() throws Throwable
- {
-
- // Get the MainDeployer
- MainDeployer mainDeployer = (MainDeployer) getKernel().getController().getInstalledContext(NAME_MC_MAIN_DEPLOYER)
- .getTarget();
- TestCase.assertNotNull(MainDeployer.class.getName() + " instance was not installed into MC", mainDeployer);
-
- // Install a caching deployer which will remember the last deployment
- final CachingDeployer deployer = new CachingDeployer();
- final String deployerName = deployer.getClass().getSimpleName();
- final BeanMetaDataBuilder bmdb = BeanMetaDataBuilder.createBuilder(deployerName, deployer.getClass().getName());
- getKernel().getController().install(bmdb.getBeanMetaData(), deployer);
-
- // Construct a test JAR
- final JavaArchive cachingDeployerJar = Archives.create(NAME_ARCHIVE, JavaArchive.class).addClass(this.getClass());
-
- // Flush out to a real File
- final File tmpFile = File.createTempFile(cachingDeployerJar.getName(), EXTENSION_TMP);
- cachingDeployerJar.as(ZipExporter.class).exportZip(tmpFile, true);
- tmpFile.deleteOnExit();
-
- // Deploy the test JAR
- final VirtualFile vFile = VFS.createNewRoot(tmpFile.toURI());
- final VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(vFile);
- mainDeployer.addDeployment(deployment);
- mainDeployer.process();
- mainDeployer.checkComplete();
-
- // Obtain the last deployed
- DeploymentUnit lastDeployed = deployer.lastDeployed;
- TestCase.assertEquals(vFile.toURI().toURL().toExternalForm(), lastDeployed.getName());
-
- // Undeploy
- mainDeployer.undeploy(deployment);
- mainDeployer.process();
- mainDeployer.checkComplete();
- }
-
- //-------------------------------------------------------------------------------------||
- // Contracts --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Obtains the {@link Kernel} in the currently-running server
- */
- abstract Kernel getKernel();
-
- //-------------------------------------------------------------------------------------||
- // Inner Classes ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Simple {@link Deployer} to cache and make accessible the last-deployed
- * {@link DeploymentUnit}. Used to ensure that we can install deployers
- * into the chain and that they'll process new {@link Deployment}s.
- */
- protected static class CachingDeployer extends AbstractDeployer
- {
-
- /**
- * The last unit deployed
- */
- DeploymentUnit lastDeployed;
-
- public void deploy(final DeploymentUnit unit) throws DeploymentException
- {
- log.info("Deploying: " + unit);
- lastDeployed = unit;
- }
-
- }
-}
Modified: projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/org/jboss/reloaded/api/MainDeployerViaBootstrapUnitTest.java
===================================================================
--- projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/org/jboss/reloaded/api/MainDeployerViaBootstrapUnitTest.java 2010-01-22 16:14:22 UTC (rev 99811)
+++ projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/org/jboss/reloaded/api/MainDeployerViaBootstrapUnitTest.java 2010-01-22 16:24:22 UTC (rev 99812)
@@ -1,18 +1,36 @@
package org.jboss.reloaded.api;
+
+import java.io.File;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.List;
+import junit.framework.TestCase;
+
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
import org.jboss.bootstrap.api.descriptor.BootstrapDescriptor;
import org.jboss.bootstrap.api.lifecycle.LifecycleState;
import org.jboss.bootstrap.api.mc.server.MCServer;
import org.jboss.bootstrap.api.mc.server.MCServerFactory;
-import org.jboss.kernel.Kernel;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.Deployer;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.logging.Logger;
-import org.jboss.reloaded.api.ReloadedDescriptors;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Test of MainDeployer/VDF which installs necessary components
@@ -23,7 +41,7 @@
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
-public class MainDeployerViaBootstrapUnitTest extends MainDeployerTestBase
+public class MainDeployerViaBootstrapUnitTest
{
//-------------------------------------------------------------------------------------||
@@ -50,6 +68,21 @@
*/
private static final String VALUE_SYSPROP_JBOSSXB_IGNORE_ORDER = "true";
+ /**
+ * Name of the archive we'll deploy
+ */
+ private static final String NAME_ARCHIVE = "testDeployment.jar";
+
+ /**
+ * Extension to give to TMP files
+ */
+ private static final String EXTENSION_TMP = ".tmp";
+
+ /**
+ * MC bean name of the {@link MainDeployer}
+ */
+ protected static final String NAME_MC_MAIN_DEPLOYER = "MainDeployer";
+
//-------------------------------------------------------------------------------------||
// Lifecycle --------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
@@ -121,16 +154,79 @@
}
//-------------------------------------------------------------------------------------||
- // Required Implementations -----------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
/**
- * {@inheritDoc}
- * @see MainDeployerTestBase#getKernel()
+ * Ensures that VDF is brought up by:
+ * 1) Installing a new Deployer
+ * 2) Processing a deployment via MainDeployer
+ * 3) Ensuring the new Deployer processes the incoming DeploymentUnit
*/
- @Override
- Kernel getKernel()
+ @Test
+ public void testVdfBoot() throws Throwable
{
- return server.getKernel();
+ // Get the KernelController
+ final KernelController controller = server.getKernel().getController();
+
+ // Get the MainDeployer (should have been installed via the lifecycle)
+ final MainDeployer mainDeployer = (MainDeployer) controller.getInstalledContext(NAME_MC_MAIN_DEPLOYER)
+ .getTarget();
+ TestCase.assertNotNull(MainDeployer.class.getName() + " instance was not installed into MC", mainDeployer);
+
+ // Install a caching deployer which will remember the last deployment
+ final CachingDeployer deployer = new CachingDeployer();
+ final String deployerName = deployer.getClass().getSimpleName();
+ final BeanMetaDataBuilder bmdb = BeanMetaDataBuilder.createBuilder(deployerName, deployer.getClass().getName());
+ controller.install(bmdb.getBeanMetaData(), deployer);
+
+ // Construct a test JAR
+ final JavaArchive cachingDeployerJar = Archives.create(NAME_ARCHIVE, JavaArchive.class).addClass(this.getClass());
+
+ // Flush out to a real File
+ final File tmpFile = File.createTempFile(cachingDeployerJar.getName(), EXTENSION_TMP);
+ cachingDeployerJar.as(ZipExporter.class).exportZip(tmpFile, true);
+ tmpFile.deleteOnExit();
+
+ // Deploy the test JAR
+ final VirtualFile vFile = VFS.createNewRoot(tmpFile.toURI());
+ final VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(vFile);
+ mainDeployer.addDeployment(deployment);
+ mainDeployer.process();
+ mainDeployer.checkComplete();
+
+ // Obtain the last deployed
+ DeploymentUnit lastDeployed = deployer.lastDeployed;
+ TestCase.assertEquals(vFile.toURI().toURL().toExternalForm(), lastDeployed.getName());
+
+ // Undeploy
+ mainDeployer.undeploy(deployment);
+ mainDeployer.process();
+ mainDeployer.checkComplete();
}
+
+ //-------------------------------------------------------------------------------------||
+ // Inner Classes ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Simple {@link Deployer} to cache and make accessible the last-deployed
+ * {@link DeploymentUnit}. Used to ensure that we can install deployers
+ * into the chain and that they'll process new {@link Deployment}s.
+ */
+ protected static class CachingDeployer extends AbstractDeployer
+ {
+
+ /**
+ * The last unit deployed
+ */
+ DeploymentUnit lastDeployed;
+
+ public void deploy(final DeploymentUnit unit) throws DeploymentException
+ {
+ log.info("Deploying: " + unit);
+ lastDeployed = unit;
+ }
+
+ }
}
More information about the jboss-cvs-commits
mailing list