OverrideProcessor implements PreProcessor { public Document process(Document input) throws TransformerException { log.log(Level.FINE, "Preprocessing overrides with " + environment + "." + region); Document ret = Xml.copyDocument(input); Element root = ret.getDocumentElement(); applyOverrides(root, Context.empty()); return ret; } OverrideProcessor(InstanceName instance, Environment environment, RegionName region); Document process(Document input);  }
@Test(expected = IllegalArgumentException.class) public void testParsingDifferentEnvInParentAndChild() throws TransformerException { String in = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<services xmlns:deploy=\"vespa\" xmlns:preprocess=\"?\" version=\"1.0\">" + " <admin deploy:environment=\"prod\" version=\"2.0\">" + " <adminserver deploy:environment=\"test\" hostalias=\"node1\"/>" + " </admin>" + "</services>"; Document inputDoc = Xml.getDocument(new StringReader(in)); new OverrideProcessor(InstanceName.from("default"), Environment.from("prod"), RegionName.from("us-west")).process(inputDoc); }
@Test(expected = IllegalArgumentException.class) public void testParsingDifferentRegionInParentAndChild() throws TransformerException { String in = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<services xmlns:deploy=\"vespa\" xmlns:preprocess=\"?\" version=\"1.0\">" + " <admin deploy:region=\"us-west\" version=\"2.0\">" + " <adminserver deploy:region=\"us-east\" hostalias=\"node1\"/>" + " </admin>" + "</services>"; Document inputDoc = Xml.getDocument(new StringReader(in)); new OverrideProcessor(InstanceName.from("default"), Environment.defaultEnvironment(), RegionName.from("us-west")).process(inputDoc); }