private DeploymentDescription createDeploymentDescription(String targetName) { return new DeploymentDescription(DEPLOYMENT_NAME, ShrinkWrap.create(JavaArchive.class)) .setTarget(new TargetDescription(targetName)); } }
private DeploymentDescription createDeploymentDescription(String targetName) { return new DeploymentDescription(DEPLOYMENT_NAME, ShrinkWrap.create(JavaArchive.class)) .setTarget(new TargetDescription(targetName)); } }
@Test(expected = IllegalArgumentException.class) public void shouldNotAllowMultipleArchiveDeploymentsWithSameName() { DeploymentScenario scenario = new DeploymentScenario(); scenario.addDeployment( new DeploymentDescription("X", ShrinkWrap.create(JavaArchive.class)) .setTarget(TargetDescription.DEFAULT)); scenario.addDeployment( new DeploymentDescription("X", ShrinkWrap.create(JavaArchive.class)) .setTarget(TargetDescription.DEFAULT)); }
@Test public void shouldNotDefaultWhenMultipleArchives() { DeploymentScenario scenario = new DeploymentScenario(); scenario.addDeployment( new DeploymentDescription("A", ShrinkWrap.create(JavaArchive.class)) .setTarget(TargetDescription.DEFAULT)); scenario.addDeployment( new DeploymentDescription("B", ShrinkWrap.create(JavaArchive.class)) .setTarget(TargetDescription.DEFAULT)); Deployment defaultDeployment = scenario.deployment(DeploymentTargetDescription.DEFAULT); Assert.assertNull(defaultDeployment); }
@Test public void shouldAllowMultipleArchiveDeploymentsWithSameArchiveNameWithDifferentTargets() { DeploymentScenario scenario = new DeploymentScenario(); scenario.addDeployment( new DeploymentDescription(DEFAULT_NAME, ShrinkWrap.create(JavaArchive.class, "test.jar")) .setTarget(TargetDescription.DEFAULT)); scenario.addDeployment( new DeploymentDescription("B", ShrinkWrap.create(JavaArchive.class, "test.jar")) .setTarget(new TargetDescription("B"))); Assert.assertEquals(2, scenario.deployments().size()); }
@Test(expected = IllegalArgumentException.class) public void shouldNotAllowMultipleDescriptorDeploymentsWithSameName() { DeploymentScenario scenario = new DeploymentScenario(); scenario.addDeployment( new DeploymentDescription(DEFAULT_NAME, Descriptors.create(BeansDescriptor.class)) .setTarget(TargetDescription.DEFAULT)); scenario.addDeployment( new DeploymentDescription(DEFAULT_NAME, Descriptors.create(BeansDescriptor.class)) .setTarget(TargetDescription.DEFAULT)); } }
@Test(expected = IllegalArgumentException.class) public void shouldNotAllowMultipleDescriptorDeploymentsWithSameName() { DeploymentScenario scenario = new DeploymentScenario(); scenario.addDeployment( new DeploymentDescription(DEFAULT_NAME, Descriptors.create(BeansDescriptor.class)) .setTarget(TargetDescription.DEFAULT)); scenario.addDeployment( new DeploymentDescription(DEFAULT_NAME, Descriptors.create(BeansDescriptor.class)) .setTarget(TargetDescription.DEFAULT)); } }
@Test public void shouldNotGetWithUnknownName() { DeploymentScenario scenario = new DeploymentScenario(); scenario.addDeployment( new DeploymentDescription("A", ShrinkWrap.create(JavaArchive.class)) .setTarget(TargetDescription.DEFAULT)); scenario.addDeployment( new DeploymentDescription("B", Descriptors.create(BeansDescriptor.class)) .setTarget(TargetDescription.DEFAULT)); Deployment deployment = scenario.deployment(new DeploymentTargetDescription("C")); Assert.assertNull(deployment); }
@Test public void shouldNotGetWithUnknownName() { DeploymentScenario scenario = new DeploymentScenario(); scenario.addDeployment( new DeploymentDescription("A", ShrinkWrap.create(JavaArchive.class)) .setTarget(TargetDescription.DEFAULT)); scenario.addDeployment( new DeploymentDescription("B", Descriptors.create(BeansDescriptor.class)) .setTarget(TargetDescription.DEFAULT)); Deployment deployment = scenario.deployment(new DeploymentTargetDescription("C")); Assert.assertNull(deployment); }
@Test public void shouldNotDefaultWhenMultipleDescriptors() { DeploymentScenario scenario = new DeploymentScenario(); scenario.addDeployment( new DeploymentDescription("A", Descriptors.create(BeansDescriptor.class)) .setTarget(TargetDescription.DEFAULT)); scenario.addDeployment( new DeploymentDescription("B", Descriptors.create(BeansDescriptor.class)) .setTarget(TargetDescription.DEFAULT)); Deployment defaultDeployment = scenario.deployment(DeploymentTargetDescription.DEFAULT); Assert.assertNull(defaultDeployment); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionOnUnDeployWhenContainerNotRunning() throws Exception { DeploymentDescription description = new DeploymentDescription(DEPLOYMENT_NAME, ShrinkWrap.create(JavaArchive.class)); description.setTarget(new TargetDescription("_CONTAINER_STOPPED_")); scenario.get().addDeployment(description); deployer.get().undeploy(DEPLOYMENT_NAME); } }
@Test public void shouldNotGetDefaultWithNonDefaultName() { DeploymentScenario scenario = new DeploymentScenario(); scenario.addDeployment( new DeploymentDescription("A", ShrinkWrap.create(JavaArchive.class)) .setTarget(TargetDescription.DEFAULT)); scenario.addDeployment( new DeploymentDescription("B", Descriptors.create(BeansDescriptor.class)) .setTarget(TargetDescription.DEFAULT)); DeploymentDescription deployment = scenario.deployment(new DeploymentTargetDescription("B")).getDescription(); Assert.assertEquals("B", deployment.getName()); }
@Test public void shouldNotGetDefaultWithNonDefaultName() { DeploymentScenario scenario = new DeploymentScenario(); scenario.addDeployment( new DeploymentDescription("A", ShrinkWrap.create(JavaArchive.class)) .setTarget(TargetDescription.DEFAULT)); scenario.addDeployment( new DeploymentDescription("B", Descriptors.create(BeansDescriptor.class)) .setTarget(TargetDescription.DEFAULT)); DeploymentDescription deployment = scenario.deployment(new DeploymentTargetDescription("B")).getDescription(); Assert.assertEquals("B", deployment.getName()); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionOnDeployWhenContainerNotStarted() throws Exception { DeploymentDescription description = new DeploymentDescription(DEPLOYMENT_NAME, ShrinkWrap.create(JavaArchive.class)); description.setTarget(new TargetDescription("_CONTAINER_STOPPED_")); scenario.get().addDeployment(description); deployer.get().deploy(DEPLOYMENT_NAME); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionOnUnDeployWhenContainerNotRunning() throws Exception { DeploymentDescription description = new DeploymentDescription(DEPLOYMENT_NAME, ShrinkWrap.create(JavaArchive.class)); description.setTarget(new TargetDescription("_CONTAINER_STOPPED_")); scenario.get().addDeployment(description); deployer.get().undeploy(DEPLOYMENT_NAME); } }
@Test public void shouldFireDeploymentEventOnDeploy() throws Exception { DeploymentDescription description = new DeploymentDescription(DEPLOYMENT_NAME, ShrinkWrap.create(JavaArchive.class)); description.shouldBeManaged(false); description.setTarget(new TargetDescription("_DEFAULT_")); scenario.get().addDeployment(description); deployer.get().deploy(DEPLOYMENT_NAME); assertEventFired(DeployDeployment.class, 1); }
@Test public void shouldFireUnDeploymentEventOnUnDeploy() throws Exception { DeploymentDescription description = new DeploymentDescription(DEPLOYMENT_NAME, ShrinkWrap.create(JavaArchive.class)); description.shouldBeManaged(false); description.setTarget(new TargetDescription("_DEFAULT_")); scenario.get().addDeployment(description); deployer.get().undeploy(DEPLOYMENT_NAME); assertEventFired(UnDeployDeployment.class, 1); }
@Test public void shouldDefaultToSingleDescriptor() { DeploymentDescription deployment = new DeploymentDescription(DEFAULT_NAME, Descriptors.create(BeansDescriptor.class)); deployment.setTarget(TargetDescription.DEFAULT); DeploymentScenario scenario = new DeploymentScenario(); scenario.addDeployment(deployment); DeploymentDescription defaultDeployment = scenario.deployment(DeploymentTargetDescription.DEFAULT).getDescription(); Assert.assertEquals(deployment, defaultDeployment); }
@Test public void shouldDefaultToSingleDescriptor() { DeploymentDescription deployment = new DeploymentDescription(DEFAULT_NAME, Descriptors.create(BeansDescriptor.class)); deployment.setTarget(TargetDescription.DEFAULT); DeploymentScenario scenario = new DeploymentScenario(); scenario.addDeployment(deployment); DeploymentDescription defaultDeployment = scenario.deployment(DeploymentTargetDescription.DEFAULT).getDescription(); Assert.assertEquals(deployment, defaultDeployment); }
@Test public void shouldNotExportedIfDeploymentIsNotArchive() throws Exception { bind(ApplicationScoped.class, ArquillianDescriptor.class, Descriptors.create(ArquillianDescriptor.class).engine() .deploymentExportPath(EXPORT_PATH)); deployment = new DeploymentDescription(DEPLOYMENT_NAME, Descriptors.create(WebAppDescriptor.class)); deployment.setTarget(new TargetDescription(TARGET_NAME)); fire(new BeforeDeploy(deployableContainer, deployment)); fileShouldExist(false); }