VersionInfoXmlManager { static Dependency parseDependency(final File f) throws JAXBException, SAXException, IOException { final String schemaVersion = getSchemaVersion(f); if (schemaVersion == null) { return parseOldDependency(f); } else if (schemaVersion.equals("1.2.0")) { return parseOldVersionsWithoutSchema(f); } else if ((schemaVersion.equals("1.2.1")) || (schemaVersion.equals("1.2.2"))) { return parseDependency_1_2_2(f); } throw new IllegalStateException("Unknown schemaVersion: '" + schemaVersion + "'."); }    }
@Test public void testStraightForward() throws Exception { Dependency dependency = VersionInfoXmlManager.parseDependency(new File("src/test/resources/validXML.xml")); Assert.assertEquals("com.sap.ondevice.production.ios.tests", dependency.getCoordinates().getGroupId()); Assert.assertEquals("MyApp", dependency.getCoordinates().getArtifactId()); Assert.assertEquals("1.0.0", dependency.getCoordinates().getVersion()); Assert.assertEquals("scm:perforce:PERFORCEHOST:9999: Assert.assertEquals("4711", dependency.getScm().getRevision()); }
@Test(expected=javax.xml.bind.UnmarshalException.class) public void testInvalidVersionInfoContentHtml() throws JAXBException, SAXException, IOException { VersionInfoXmlManager.parseDependency(new File("src/test/resources/versions-invalidHtml.xml")); }
@Test(expected=org.xml.sax.SAXParseException.class) public void testInvalidVersionInfoContentEmpty() throws JAXBException, SAXException, IOException { VersionInfoXmlManager.parseDependency(new File("src/test/resources/versions-invalidEmpty.xml")); }
@Test(expected=java.io.FileNotFoundException.class) public void testInvalidVersionInfoFileDoesNotExist() throws JAXBException, SAXException, IOException { VersionInfoXmlManager.parseDependency(new File("src/test/resources/versions-invalidDoesNotExist.xml")); }