@Test public void shouldThrowIllegalStateExceptionOnMissingDeploymentGenerator() throws Exception { System.setProperty(ArchiveDeploymentToolingExporter.ARQUILLIAN_TOOLING_DEPLOYMENT_FOLDER, EXPORT_FOLDER); //context.add(Archive.class, ShrinkWrap.create(JavaArchive.class, "test.jar")); fire(new BeforeDeploy(deployableContainer, deployment)); File exportedFile = new File(EXPORT_FOLDER + getClass().getName() + ".xml"); Assert.assertTrue(exportedFile.exists()); exportedFile.delete(); } }
@Test public void shouldThrowIllegalStateExceptionOnMissingDeploymentGenerator() throws Exception { System.setProperty(ArchiveDeploymentToolingExporter.ARQUILLIAN_TOOLING_DEPLOYMENT_FOLDER, EXPORT_FOLDER); //context.add(Archive.class, ShrinkWrap.create(JavaArchive.class, "test.jar")); fire(new BeforeDeploy(deployableContainer, deployment)); File exportedFile = new File(EXPORT_FOLDER + getClass().getName() + ".xml"); Assert.assertTrue(exportedFile.exists()); exportedFile.delete(); } }
@Test public void shouldExportExplodedIfExportExplodedSystemPropertyIsSet() throws Exception { System.setProperty(ARQUILLIAN_DEPLOYMENT_EXPORT_PATH, EXPORT_PATH); System.setProperty(ARQUILLIAN_DEPLOYMENT_EXPORT_EXPLODED, "true"); try { bind(ApplicationScoped.class, ArquillianDescriptor.class, Descriptors.create(ArquillianDescriptor.class)); fire(new BeforeDeploy(deployableContainer, deployment)); fileShouldExist(true); } finally { System.setProperty(ARQUILLIAN_DEPLOYMENT_EXPORT_PATH, ""); System.setProperty(ARQUILLIAN_DEPLOYMENT_EXPORT_EXPLODED, ""); } }
@Test public void shouldHandleNoConfigurationInContext() throws Exception { fire(new BeforeDeploy(deployableContainer, deployment)); fileShouldExist(false); }
@Test public void shouldExportIfExportPathSystemPropertyIsSet() throws Exception { System.setProperty(ARQUILLIAN_DEPLOYMENT_EXPORT_PATH, EXPORT_PATH); try { bind(ApplicationScoped.class, ArquillianDescriptor.class, Descriptors.create(ArquillianDescriptor.class)); fire(new BeforeDeploy(deployableContainer, deployment)); fileShouldExist(true); } finally { System.setProperty(ARQUILLIAN_DEPLOYMENT_EXPORT_PATH, ""); } }
@Test public void shouldNotExportIfDeploymentExportPathNotSet() throws Exception { bind(ApplicationScoped.class, ArquillianDescriptor.class, Descriptors.create(ArquillianDescriptor.class)); fire(new BeforeDeploy(deployableContainer, deployment)); fileShouldExist(false); }
@Test public void shouldBeExportedWhenDeploymentExportPathIsSet() throws Exception { bind(ApplicationScoped.class, ArquillianDescriptor.class, Descriptors.create(ArquillianDescriptor.class).engine() .deploymentExportPath(EXPORT_PATH)); fire(new BeforeDeploy(deployableContainer, deployment)); fileShouldExist(true); }
@Test public void shouldBeDeleteAlreadyExplodedDeploymentAndExportDeploymentWhenDeploymentExportIsNotSet() throws Exception { // given - To export deployment archive bind(ApplicationScoped.class, ArquillianDescriptor.class, Descriptors.create(ArquillianDescriptor.class).engine() .deploymentExportPath(EXPORT_PATH) .deploymentExportExploded(true)); fire(new BeforeDeploy(deployableContainer, deployment)); // when bind(ApplicationScoped.class, ArquillianDescriptor.class, Descriptors.create(ArquillianDescriptor.class).engine() .deploymentExportPath(EXPORT_PATH) .deploymentExportExploded(false)); fire(new BeforeDeploy(deployableContainer, deployment)); // then fileShouldExist(true); }
@Test public void shouldBeDeleteAlreadyExportedDeploymentAndExportExplodedWhenDeploymentExportExplodedIsSet() throws Exception { // given - To create exploded deployment bind(ApplicationScoped.class, ArquillianDescriptor.class, Descriptors.create(ArquillianDescriptor.class).engine() .deploymentExportPath(EXPORT_PATH) .deploymentExportExploded(false)); fire(new BeforeDeploy(deployableContainer, deployment)); // when bind(ApplicationScoped.class, ArquillianDescriptor.class, Descriptors.create(ArquillianDescriptor.class).engine() .deploymentExportPath(EXPORT_PATH) .deploymentExportExploded(true)); fire(new BeforeDeploy(deployableContainer, deployment)); // then directoryShouldExist(); }
@Test public void shouldBeExportedExplodedWhenDeploymentExportExplodedIsSet() throws Exception { bind(ApplicationScoped.class, ArquillianDescriptor.class, Descriptors.create(ArquillianDescriptor.class).engine() .deploymentExportPath(EXPORT_PATH) .deploymentExportExploded(true)); fire(new BeforeDeploy(deployableContainer, deployment)); directoryShouldExist(); }
@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); }
@Override public Void call() throws Exception { DeployableContainer<?> deployableContainer = event.getDeployableContainer(); Deployment deployment = event.getDeployment(); DeploymentDescription deploymentDescription = deployment.getDescription(); /* * TODO: should the DeploymentDescription producer some how be automatically registered ? * Or should we just 'know' who is the first one to create the context */ deploymentDescriptionProducer.set(deploymentDescription); deploymentProducer.set(deployment); deployEvent.fire(new BeforeDeploy(deployableContainer, deploymentDescription)); try { if (deploymentDescription.isArchiveDeployment()) { protocolMetadata.set(deployableContainer.deploy( deploymentDescription.getTestableArchive() != null ? deploymentDescription.getTestableArchive() : deploymentDescription.getArchive())); } else { deployableContainer.deploy(deploymentDescription.getDescriptor()); } deployment.deployed(); } catch (Exception e) { deployment.deployedWithError(e); throw e; } deployEvent.fire(new AfterDeploy(deployableContainer, deploymentDescription)); return null; } });
@Override public Void call() throws Exception { DeployableContainer<?> deployableContainer = event.getDeployableContainer(); Deployment deployment = event.getDeployment(); DeploymentDescription deploymentDescription = deployment.getDescription(); /* * TODO: should the DeploymentDescription producer some how be automatically registered ? * Or should we just 'know' who is the first one to create the context */ deploymentDescriptionProducer.set(deploymentDescription); deploymentProducer.set(deployment); deployEvent.fire(new BeforeDeploy(deployableContainer, deploymentDescription)); try { if (deploymentDescription.isArchiveDeployment()) { protocolMetadata.set(deployableContainer.deploy( deploymentDescription.getTestableArchive() != null ? deploymentDescription.getTestableArchive() : deploymentDescription.getArchive())); } else { deployableContainer.deploy(deploymentDescription.getDescriptor()); } deployment.deployed(); } catch (Exception e) { deployment.deployedWithError(e); throw e; } deployEvent.fire(new AfterDeploy(deployableContainer, deploymentDescription)); return null; } });