ManifestVerifier { public void verify(String... filters) throws ManifestVerifyException { if (filters != null) { this.filters = Arrays.asList(filters); logFilters(); } verify(); } ManifestVerifier(File file0, File file1); void report(OutputStream out); Iterator<ResultEntry> resultEntries(); void verify(String... filters); void verify(); final static char DELIM; }
@Test public void testVerifyGood() { verifier = new ManifestVerifier(file0, file1); try { verifier.verify(); } catch (ManifestVerifyException e) { StringBuilder sb = new StringBuilder("No exception expected.\n\n"); sb.append(e.getFormattedMessage() + "\n\n"); sb.append(ExceptionUtil.getStackTraceAsString(e)); fail(sb.toString()); } }
@Test public void testVerifyUneven() { verifier = new ManifestVerifier(file0, file2); try { verifier.verify(); fail("Exception expected."); } catch (ManifestVerifyException e) { assertEquals(ManifestVerifyException.ErrorType.INVALID, e.getErrorType()); } }
@Test public void testVerifyUnevenAgain() { verifier = new ManifestVerifier(file2, file0); try { verifier.verify(); fail("Exception expected."); } catch (ManifestVerifyException e) { assertEquals(ManifestVerifyException.ErrorType.INVALID, e.getErrorType()); } }
@Test public void testVerifyMismatchCksum() { verifier = new ManifestVerifier(file0, file3); try { verifier.verify(); fail("Exception expected."); } catch (ManifestVerifyException e) { assertEquals(ManifestVerifyException.ErrorType.INVALID, e.getErrorType()); } }
@Test public void testVerifyMismatchName() { verifier = new ManifestVerifier(file0, file4); try { verifier.verify(); fail("Exception expected."); } catch (ManifestVerifyException e) { assertEquals(ManifestVerifyException.ErrorType.INVALID, e.getErrorType()); } }
@Test public void testVerifyUnevenBad() { verifier = new ManifestVerifier(file0, file5); try { verifier.verify(); fail("Exception expected."); } catch (ManifestVerifyException e) { assertEquals(ManifestVerifyException.ErrorType.INVALID, e.getErrorType()); } }
@Test public void testVerifyBad() { boolean runtimeThrown = false; verifier = new ManifestVerifier(file0, file6); try { verifier.verify(); fail("Exception expected."); } catch (ManifestVerifyException e) { fail("ManifestVerifyException not expected.\n" + e.getFormattedMessage()); } catch (RuntimeException re) { runtimeThrown = true; } assertTrue(runtimeThrown); }