@Override protected void handle(Matcher matcher, String value, ArquillianDescriptor descriptor) { String propertyName = matcher.group(1); if ("deploymentExportPath".equals(propertyName)) { descriptor.engine().deploymentExportPath(value); } else if ("maxTestClassesBeforeRestart".equals(propertyName)) { descriptor.engine().maxTestClassesBeforeRestart(Integer.parseInt(value)); } else { throw new RuntimeException( "Unknown arquillian engine property[" + propertyName + "] with value[" + value + "]"); } } }
@Override protected void handle(Matcher matcher, String value, ArquillianDescriptor descriptor) { String propertyName = matcher.group(1); if ("deploymentExportPath".equals(propertyName)) { descriptor.engine().deploymentExportPath(value); } else if ("maxTestClassesBeforeRestart".equals(propertyName)) { descriptor.engine().maxTestClassesBeforeRestart(Integer.parseInt(value)); } else { throw new RuntimeException( "Unknown arquillian engine property[" + propertyName + "] with value[" + value + "]"); } } }
@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 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 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 shouldBeAbleToSetEngineProperties() throws Exception { // add multiple times to see only one property added desc = create() .engine() .deploymentExportPath(PROPERTY_VALUE_1) .deploymentExportPath(PROPERTY_VALUE_1) .maxTestClassesBeforeRestart(PROPERTY_INT_VALUE_1) .maxTestClassesBeforeRestart(PROPERTY_INT_VALUE_1) .exportAsString(); assertXPath(desc, "/arquillian/engine/property[@name='deploymentExportPath']/text()", PROPERTY_VALUE_1); assertXPath(desc, "/arquillian/engine/property[@name='maxTestClassesBeforeRestart']/text()", PROPERTY_INT_VALUE_1); ArquillianDescriptor descriptor = create(desc); Assert.assertEquals(PROPERTY_VALUE_1, descriptor.engine().getDeploymentExportPath()); Assert.assertEquals(PROPERTY_INT_VALUE_1, descriptor.engine().getMaxTestClassesBeforeRestart()); }
@Test public void shouldBeAbleToSetEngineProperties() throws Exception { System.setProperty(KEY_PROPERTY_VALUE_1, PROPERTY_VALUE_1); // add multiple times to see only one property added desc = create() .engine() .deploymentExportPath(setPropKey(KEY_PROPERTY_VALUE_1)) .deploymentExportPath(setPropKey(KEY_PROPERTY_VALUE_1)) .maxTestClassesBeforeRestart(PROPERTY_INT_VALUE_1) .maxTestClassesBeforeRestart(PROPERTY_INT_VALUE_1); desc = new SystemPropertiesConfigurationPlaceholderResolver().resolve(desc); final String descString = desc.exportAsString(); assertXPath(descString, "/arquillian/engine/property[@name='deploymentExportPath']/text()", PROPERTY_VALUE_1); assertXPath(descString, "/arquillian/engine/property[@name='maxTestClassesBeforeRestart']/text()", PROPERTY_INT_VALUE_1); ArquillianDescriptor descriptor = create(descString); Assert.assertEquals(PROPERTY_VALUE_1, descriptor.engine().getDeploymentExportPath()); Assert.assertEquals(PROPERTY_INT_VALUE_1, descriptor.engine().getMaxTestClassesBeforeRestart()); }
@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); }