diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-11-23 11:25:17 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-11-23 11:25:17 +0100 |
commit | b6b3f49adcd9868e6e8bc0f2eb633b8802370ca5 (patch) | |
tree | 0b9fa1c0a59ccf4adbab70a0864ff30e42a4bbad /config-application-package | |
parent | a3af55762932f6e7dc4100bcb2490f25a8e84555 (diff) |
Complete test
Diffstat (limited to 'config-application-package')
-rw-r--r-- | config-application-package/src/test/java/com/yahoo/config/application/MultiOverrideProcessorTest.java | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/config-application-package/src/test/java/com/yahoo/config/application/MultiOverrideProcessorTest.java b/config-application-package/src/test/java/com/yahoo/config/application/MultiOverrideProcessorTest.java index 67f49aae082..c450e478c85 100644 --- a/config-application-package/src/test/java/com/yahoo/config/application/MultiOverrideProcessorTest.java +++ b/config-application-package/src/test/java/com/yahoo/config/application/MultiOverrideProcessorTest.java @@ -11,6 +11,8 @@ import javax.xml.transform.TransformerException; import java.io.StringReader; /** + * Demonstrates that only the most specific match is retained and that this can be overridden by using ids. + * * @author bratseth */ public class MultiOverrideProcessorTest { @@ -41,7 +43,31 @@ public class MultiOverrideProcessorTest { " </resource>\n" + " </config>\n" + " </component>\n" + - " <nodes deploy:environment=\"dev\" count=\"1\"/>\n" + + " </container>\n" + + "</services>\n"; + + private static final String inputWithIds = + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + + "<services version=\"1.0\" xmlns:deploy=\"vespa\">\n" + + " <container id='qrserver' version='1.0'>\n" + + " <component id=\"comp-B\" class=\"com.yahoo.ls.MyComponent\" bundle=\"lsbe-hv\">\n" + + " <config name=\"ls.config.resource-pool\">\n" + + " <resource>\n" + + " <item id='1'>\n" + + " <id>comp-B-item-0</id>\n" + + " <type></type>\n" + + " </item>\n" + + " <item id='2' deploy:environment=\"dev perf test staging prod\" deploy:region=\"us-west-1 us-east-3\">\n" + + " <id>comp-B-item-1</id>\n" + + " <type></type>\n" + + " </item>\n" + + " <item id='3'>\n" + + " <id>comp-B-item-2</id>\n" + + " <type></type>\n" + + " </item>\n" + + " </resource>\n" + + " </config>\n" + + " </component>\n" + " </container>\n" + "</services>\n"; @@ -55,24 +81,44 @@ public class MultiOverrideProcessorTest { " <config name=\"ls.config.resource-pool\">\n" + " <resource>\n" + " <item>\n" + + " <id>comp-B-item-1</id>\n" + + " <type></type>\n" + + " </item>\n" + + " </resource>\n" + + " </config>\n" + + " </component>\n" + + " </container>\n" + + "</services>"; + assertOverride(Environment.dev, RegionName.defaultName(), expected); + } + + @Test + public void testParsingDevWithIds() throws TransformerException { + String expected = + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + + "<services version=\"1.0\" xmlns:deploy=\"vespa\">\n" + + " <container id='qrserver' version='1.0'>\n" + + " <component id=\"comp-B\" class=\"com.yahoo.ls.MyComponent\" bundle=\"lsbe-hv\">\n" + + " <config name=\"ls.config.resource-pool\">\n" + + " <resource>\n" + + " <item id='1'>\n" + " <id>comp-B-item-0</id>\n" + " <type></type>\n" + " </item>\n" + - " <item>\n" + + " <item id='2'>\n" + " <id>comp-B-item-1</id>\n" + " <type></type>\n" + " </item>\n" + - " <item>\n" + + " <item id='3'>\n" + " <id>comp-B-item-2</id>\n" + " <type></type>\n" + " </item>\n" + " </resource>\n" + " </config>\n" + " </component>\n" + - " <nodes count=\"1\"/>\n" + " </container>\n" + "</services>"; - assertOverride(Environment.dev, RegionName.defaultName(), expected); + assertOverrideWithIds(Environment.dev, RegionName.defaultName(), expected); } private void assertOverride(Environment environment, RegionName region, String expected) throws TransformerException { @@ -81,4 +127,10 @@ public class MultiOverrideProcessorTest { TestBase.assertDocument(expected, newDoc); } + private void assertOverrideWithIds(Environment environment, RegionName region, String expected) throws TransformerException { + Document inputDoc = Xml.getDocument(new StringReader(inputWithIds)); + Document newDoc = new OverrideProcessor(environment, region).process(inputDoc); + TestBase.assertDocument(expected, newDoc); + } + } |