private String toString(String fileName) throws Exception { try (final InputStream is = getResource(fileName)){ assertNotNull(is); is.mark(0); String out = new Scanner(is).useDelimiter("\\A").next(); is.reset(); return out; } catch (Exception e) { return ""; } } }
@Test public void testParseDuplicateElementPatchId() throws Exception { final InputStream is = getResource("patch-02-ONE-OFF.xml"); final StringBuilder buf = new StringBuilder(); BufferedReader reader = null;
private void doMarshall(String fileName) throws Exception { final String original = toString(fileName); try (final InputStream is = getResource(fileName)) { final Patch patch = PatchXml.parse(is).resolvePatch(null, null); final StringWriter writer = new StringWriter(); PatchXml.marshal(writer, patch); final String marshalled = writer.toString(); XMLUtils.compareXml(original, marshalled, false); } }
@Test public void testParseOneOff() throws Exception { final InputStream is = getResource("patch-02-ONE-OFF.xml"); final Patch patch = PatchXml.parse(is).resolvePatch(null, null); // One-off Patch assertNotNull(patch); assertNotNull(patch.getPatchId()); assertNotNull(patch.getDescription()); final Identity identity = patch.getIdentity(); assertNotNull(identity); assertNotNull(patch.getIdentity().getVersion()); }
@Test public void testParseCP() throws Exception { final InputStream is = getResource("patch-01-CP.xml"); final Patch patch = PatchXml.parse(is).resolvePatch(null, null); // Cumulative Patch assertNotNull(patch); assertNotNull(patch.getPatchId()); assertNotNull(patch.getDescription()); final Identity identity = patch.getIdentity(); assertNotNull(identity); assertEquals(Patch.PatchType.CUMULATIVE, identity.getPatchType()); assertNotNull(identity.forType(Patch.PatchType.CUMULATIVE, Identity.IdentityUpgrade.class).getResultingVersion()); assertNotNull(identity.getVersion()); }