@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 + "]"); } } }
private boolean shouldRestart() { ArquillianDescriptor descriptor = configuration.get(); Integer maxTestClasses = descriptor.engine().getMaxTestClassesBeforeRestart(); if (maxTestClasses == null) { return false; } if (maxTestClasses > 0) { if (maxTestClasses == testClassesCount) { testClassesCount = 1; return true; } } testClassesCount++; return false; } }
private boolean shouldRestart() { ArquillianDescriptor descriptor = configuration.get(); Integer maxTestClasses = descriptor.engine().getMaxTestClassesBeforeRestart(); if (maxTestClasses == null) { return false; } if (maxTestClasses > 0) { if (maxTestClasses == testClassesCount) { testClassesCount = 1; return true; } } testClassesCount++; return false; } }
@Override public String get() { return desc.engine().getDeploymentExportPath(); } });
@Override public String get() { return String.valueOf(desc.engine().getMaxTestClassesBeforeRestart()); } });
@Test public void shouldReturnNullOnEnginePropertiesIfNotSet() throws Exception { // add multiple times to see only one property added desc = create() .engine() .exportAsString(); ArquillianDescriptor descriptor = create(desc); Assert.assertNull(descriptor.engine().getDeploymentExportPath()); Assert.assertNull(descriptor.engine().getMaxTestClassesBeforeRestart()); }
@Test public void shouldReturnNullOnEnginePropertiesIfNotSet() throws Exception { // add multiple times to see only one property added desc = create() .engine(); desc = new SystemPropertiesConfigurationPlaceholderResolver().resolve(desc); final String descString = desc.exportAsString(); ArquillianDescriptor descriptor = create(descString); Assert.assertNull(descriptor.engine().getDeploymentExportPath()); Assert.assertNull(descriptor.engine().getMaxTestClassesBeforeRestart()); }
@Test public void shouldNotForceRestartIfMaxDeploymentsNotSet() throws Exception { ArquillianDescriptor desc = Descriptors.create(ArquillianDescriptor.class) .engine(); bind(ApplicationScoped.class, ArquillianDescriptor.class, desc); for (int i = 0; i < 10; i++) { fire(new BeforeClass(getClass())); } assertEventFired(StartSuiteContainers.class, 0); assertEventFired(StopSuiteContainers.class, 0); } }
@Test public void shouldNotForceRestartIfMaxDeploymentsNotSet() throws Exception { ArquillianDescriptor desc = Descriptors.create(ArquillianDescriptor.class) .engine(); bind(ApplicationScoped.class, ArquillianDescriptor.class, desc); for (int i = 0; i < 10; i++) { fire(new BeforeClass(getClass())); } assertEventFired(StartSuiteContainers.class, 0); assertEventFired(StopSuiteContainers.class, 0); } }
@Test public void shouldRestartContainerForEveryX() throws Exception { ArquillianDescriptor desc = Descriptors.create(ArquillianDescriptor.class) .engine().maxTestClassesBeforeRestart(5); bind(ApplicationScoped.class, ArquillianDescriptor.class, desc); for (int i = 0; i < 6; i++) { fire(new BeforeClass(getClass())); } assertEventFired(StartSuiteContainers.class, 1); assertEventFired(StopSuiteContainers.class, 1); }
@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 shouldNotRestartContainerOnStartOfSequence() throws Exception { ArquillianDescriptor desc = Descriptors.create(ArquillianDescriptor.class) .engine().maxTestClassesBeforeRestart(5); bind(ApplicationScoped.class, ArquillianDescriptor.class, desc); for (int i = 0; i < 5; i++) { fire(new BeforeClass(getClass())); } assertEventFired(StartSuiteContainers.class, 0); assertEventFired(StopSuiteContainers.class, 0); }
@Test public void shouldRestartContainerForEveryX() throws Exception { ArquillianDescriptor desc = Descriptors.create(ArquillianDescriptor.class) .engine().maxTestClassesBeforeRestart(5); bind(ApplicationScoped.class, ArquillianDescriptor.class, desc); for (int i = 0; i < 6; i++) { fire(new BeforeClass(getClass())); } assertEventFired(StartSuiteContainers.class, 1); assertEventFired(StopSuiteContainers.class, 1); }
@Test public void shouldNotRestartContainerOnStartOfSequence() throws Exception { ArquillianDescriptor desc = Descriptors.create(ArquillianDescriptor.class) .engine().maxTestClassesBeforeRestart(5); bind(ApplicationScoped.class, ArquillianDescriptor.class, desc); for (int i = 0; i < 5; i++) { fire(new BeforeClass(getClass())); } assertEventFired(StartSuiteContainers.class, 0); assertEventFired(StopSuiteContainers.class, 0); }
@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 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); }