@Override protected void handle(Matcher matcher, String value, ArquillianDescriptor descriptor) { String containerName = matcher.group(1); String propertyName = matcher.group(2); final ContainerDef containerDef = descriptor.container(containerName); final String originalValue = containerDef.getContainerProperty(propertyName); if (value.contains(ORIGINAL_VALUE)) { containerDef.property(propertyName, value.replace(ORIGINAL_VALUE, originalValue != null ? originalValue : "")); } else { containerDef.property(propertyName, value); } } }
@Override protected void handle(Matcher matcher, String value, ArquillianDescriptor descriptor) { String containerName = matcher.group(1); String propertyName = matcher.group(2); final ContainerDef containerDef = descriptor.container(containerName); final String originalValue = containerDef.getContainerProperty(propertyName); if (value.contains(ORIGINAL_VALUE)) { containerDef.property(propertyName, value.replace(ORIGINAL_VALUE, originalValue != null ? originalValue : "")); } else { containerDef.property(propertyName, value); } } }
@Override protected void handle(Matcher matcher, String value, ArquillianDescriptor descriptor) { String groupName = matcher.group(1); String containerName = matcher.group(2); String propertyName = matcher.group(3); final ContainerDef containerDef = descriptor.group(groupName).container(containerName); final String originalValue = containerDef.getContainerProperty(propertyName); if (value.contains(ORIGINAL_VALUE)) { containerDef.property(propertyName, value.replace(ORIGINAL_VALUE, originalValue != null ? originalValue : "")); } else { containerDef.property(propertyName, value); } } }
@Override protected void handle(Matcher matcher, String value, ArquillianDescriptor descriptor) { String groupName = matcher.group(1); String containerName = matcher.group(2); String propertyName = matcher.group(3); final ContainerDef containerDef = descriptor.group(groupName).container(containerName); final String originalValue = containerDef.getContainerProperty(propertyName); if (value.contains(ORIGINAL_VALUE)) { containerDef.property(propertyName, value.replace(ORIGINAL_VALUE, originalValue != null ? originalValue : "")); } else { containerDef.property(propertyName, value); } } }
@Test public void shouldBeAbleToAddContainerWithConfigurationAndOverwriteProperty() throws Exception { desc = create() .container(CONTAINER_NAME_1) .property(PROPERTY_NAME_1, PROPERTY_VALUE_1) .property(PROPERTY_NAME_1, PROPERTY_VALUE_2) .exportAsString(); assertXPath(desc, "/arquillian/container[1]/@qualifier", CONTAINER_NAME_1); assertXPath(desc, "/arquillian/container[1]/configuration/property/@name", PROPERTY_NAME_1); assertXPath(desc, "/arquillian/container[1]/configuration/property/text()", PROPERTY_VALUE_2); ArquillianDescriptor descriptor = create(desc); Assert.assertEquals(1, descriptor.getContainers().size()); Assert.assertEquals(CONTAINER_NAME_1, descriptor.getContainers().get(0).getContainerName()); Assert.assertEquals(1, descriptor.getContainers().get(0).getContainerProperties().size()); Assert.assertEquals(PROPERTY_VALUE_2, descriptor.getContainers().get(0).getContainerProperties().get(PROPERTY_NAME_1)); Assert.assertEquals(PROPERTY_VALUE_2, descriptor.getContainers().get(0).getContainerProperty(PROPERTY_NAME_1)); }
@Test public void shouldBeAbleToAddContainerWithConfiguration() throws Exception { desc = create() .container(CONTAINER_NAME_1) .property(PROPERTY_NAME_1, PROPERTY_VALUE_1) .container(CONTAINER_NAME_2) .property(PROPERTY_NAME_2, PROPERTY_VALUE_2) .exportAsString(); assertXPath(desc, "/arquillian/container[1]/@qualifier", CONTAINER_NAME_1); assertXPath(desc, "/arquillian/container[1]/configuration/property/@name", PROPERTY_NAME_1); assertXPath(desc, "/arquillian/container[1]/configuration/property/text()", PROPERTY_VALUE_1); assertXPath(desc, "/arquillian/container[2]/@qualifier", CONTAINER_NAME_2); assertXPath(desc, "/arquillian/container[2]/configuration/property/@name", PROPERTY_NAME_2); assertXPath(desc, "/arquillian/container[2]/configuration/property/text()", PROPERTY_VALUE_2); ArquillianDescriptor descriptor = create(desc); Assert.assertEquals(2, descriptor.getContainers().size()); Assert.assertEquals(CONTAINER_NAME_1, descriptor.getContainers().get(0).getContainerName()); Assert.assertEquals(PROPERTY_VALUE_1, descriptor.getContainers().get(0).getContainerProperties().get(PROPERTY_NAME_1)); Assert.assertEquals(PROPERTY_VALUE_1, descriptor.getContainers().get(0).getContainerProperty(PROPERTY_NAME_1)); Assert.assertEquals(CONTAINER_NAME_2, descriptor.getContainers().get(1).getContainerName()); Assert.assertEquals(PROPERTY_VALUE_2, descriptor.getContainers().get(1).getContainerProperties().get(PROPERTY_NAME_2)); Assert.assertEquals(PROPERTY_VALUE_2, descriptor.getContainers().get(1).getContainerProperty(PROPERTY_NAME_2)); }