### Question:
ResourceMerger { public Archive mergeJars(final String jarname, final File... archives) throws IOException { AssertArgument.isNotNull(jarname, "jarname"); AssertArgument.isNotNull(archives, "archives"); final List<Archive> jars = new ArrayList<Archive>(); for (File jar : archives) { jars.add(new Archive(new JarInputStream(new FileInputStream(jar)))); } return mergeJars(jarname, jars); } ResourceMerger(final String resourcePath);  ResourceMerger(final List<String> resourcesPaths); Archive mergeJars(final String jarname, final File... archives); Archive mergeJars(final String jarname, final List<Archive> archives);  }### Answer:
@Test public void merge_resources_from_two_jars() throws Exception { final Archive firstJar = setupFirstJar(); final Archive secondJar = setupSecondJar(); final Archive mergedJar = resourceMerger.mergeJars("smooks-all.jar", Arrays.asList(firstJar, secondJar)); assertThat(mergedJar.getArchiveName(), is("smooks-all.jar")); final String contentHandlers = readContent(mergedJar, CONTENT_HANDLER_PATH); assertThat(contentHandlers, containsString("property1")); assertThat(contentHandlers, containsString("property2")); final String content = readContent(mergedJar, "firstJar/someFile"); assertThat(content, is("dummyContent")); }
@Test public void merge_with_pre_existing_jar() throws Exception { final File jarfile = setupPreExistingJar(); final Archive firstJar = setupFirstJar(); final Archive merged = resourceMerger.mergeJars(jarfile.getAbsolutePath(), Collections.singletonList(firstJar)); assertThat(readContent(merged, "firstJar/someFile"), is("dummyContent")); assertThat(readContent(merged, "preExistingJar/file"), is("contentInPreExistingJar")); }
@Test public void verify_that_metainf_is_the_first_entry_in_jar() throws Exception { final Archive firstJar = setupFirstJar(); final File jarfile = setupPreExistingJar(); final Archive merged = resourceMerger.mergeJars(jarfile.getAbsolutePath(), Collections.singletonList(firstJar)); final byte[] content = merged.getEntryBytes(JarFile.MANIFEST_NAME); assertThat(content, is(notNullValue())); final File newFile = exportJarToFile(merged, "output.jar"); final Manifest manifest = getManifest(newFile.getAbsolutePath()); assertNotNull("Manifest could not be found by JarInputStream", manifest); }