@Test
public void testRewrite() {

  try {
    // Create a JarWriter and do some settings
    final JarWriter jw = new JarWriter(Paths.get("./src/test/resources/examples.jar"));
    jw.addManifestEntry("Test", "JUnit test entry");
    jw.setClassifier(StringUtil.getRandonString(6));
    jw.addFile("", Paths.get("./src/test/resources/Callgraph.class"), true);
    jw.addFile("WEB-INF/lib", Paths.get("./src/test/resources/examples.jar"), true);
    assertEquals("F22A5E25F37455867B5C2CF476BAC25189AC2B28", jw.getSHA1());
    // Callback for .class files and rewrite
    jw.register(".*.class$", this);
    final Path rewritten = jw.rewrite(Paths.get("./target"));
    // Callbacks for 6 class files
    assertEquals(6, this.countCallbacks);
    // Create a new JarWriter and check whether is recognized as rewritten (the original SHA1 is
    // taken from the manifest)
    final JarWriter jw2 = new JarWriter(rewritten);
    assertTrue(jw2.isRewrittenByVulas());
    assertEquals("F22A5E25F37455867B5C2CF476BAC25189AC2B28", jw2.getSHA1());
  } catch (Exception e) {
    e.printStackTrace();
    assertTrue(false);
  }
}