try { zipOutputStream = new ZipOutputStream(outputStream); Collection<SrampArchiveEntry> entries = getEntries(); for (SrampArchiveEntry entry : entries) { packEntry(entry, zipOutputStream);
if (archive.getEntries().isEmpty()) { return new HashMap<String, Object>();
/** * Test method for {@link org.overlord.sramp.atom.archive.jar.ZipToSrampArchive.jar.JarToSrampArchive#createSrampArchive()}. */ @Test public void testCreateSrampArchive() throws Exception { InputStream resourceAsStream = ZipToSrampArchiveTest.class.getResourceAsStream("sample-webservice-0.0.1.jar"); //$NON-NLS-1$ ZipToSrampArchive j2sramp = null; SrampArchive archive = null; try { j2sramp = new ZipToSrampArchive(resourceAsStream){}; archive = j2sramp.createSrampArchive(); Assert.assertNotNull(archive); Collection<SrampArchiveEntry> entries = archive.getEntries(); Assert.assertEquals(2, entries.size()); Set<String> paths = new HashSet<String>(); for (SrampArchiveEntry entry : entries) { paths.add(entry.getPath()); } Assert.assertEquals(2, entries.size()); Assert.assertTrue(paths.contains("schema/teetime.xsd")); //$NON-NLS-1$ Assert.assertTrue(paths.contains("wsdl/teetime.wsdl")); //$NON-NLS-1$ } finally { ZipToSrampArchive.closeQuietly(j2sramp); SrampArchive.closeQuietly(archive); } }
archive = j2sramp.createSrampArchive(); Assert.assertNotNull(archive); Collection<SrampArchiveEntry> entries = archive.getEntries(); Assert.assertEquals(16, entries.size()); Set<String> paths = new HashSet<String>();
/** * Asserts that the s-ramp archive was properly created. * @param archive * @throws SrampArchiveException */ private void doAllAssertions(SrampArchive archive) throws SrampArchiveException { Collection<SrampArchiveEntry> entries = archive.getEntries(); // Make sure all the entries we expect to be there are there. TreeSet<String> entryNames = new TreeSet<String>(); for (SrampArchiveEntry srampArchiveEntry : entries) { entryNames.add(srampArchiveEntry.getPath()); } StringBuilder buff = new StringBuilder(); for (String entryName : entryNames) { buff.append(entryName).append("\n"); //$NON-NLS-1$ } Assert.assertEquals(EXPECTED_ENTRIES, buff.toString()); // Now spot-check some representative entries. // Check the kmodule.xml SrampArchiveEntry entry = archive.getEntry("META-INF/kmodule.xml"); //$NON-NLS-1$ Assert.assertNotNull(entry); Assert.assertEquals("kmodule.xml", entry.getMetaData().getName()); //$NON-NLS-1$ Assert.assertEquals(BaseArtifactEnum.EXTENDED_DOCUMENT, entry.getMetaData().getArtifactType()); ExtendedDocument kieXmlDoc = (ExtendedDocument) entry.getMetaData(); Assert.assertEquals(KieJarModel.KieXmlDocument, kieXmlDoc.getExtendedType()); }
@Test public void shouldExpandProductsVdb() throws Exception { final InputStream stream = getResourceAsStream("ProductsSS_VDB.vdb"); VdbToSrampArchive vdbArchive = null; SrampArchive srampArchive = null; try { vdbArchive = new VdbToSrampArchive(stream); srampArchive = vdbArchive.createSrampArchive(); assertThat(srampArchive, is(not(nullValue()))); assertThat(srampArchive.getEntries().size(), is(2)); // manifest + 1 xmi models // check the manifest assertManifest(srampArchive); // check the model assertModel(srampArchive, "TestProducts/ProductsSS.xmi"); } finally { IOUtils.closeQuietly(stream); SrampArchive.closeQuietly(srampArchive); ZipToSrampArchive.closeQuietly(vdbArchive); } }
Collection<SrampArchiveEntry> entries = archive.getEntries(); Assert.assertEquals(1, entries.size()); SrampArchiveEntry entry = entries.iterator().next();
@Test public void shouldExpandBooksVdb() throws Exception { final InputStream stream = getResourceAsStream("BooksVdb.vdb"); VdbToSrampArchive vdbArchive = null; SrampArchive srampArchive = null; try { vdbArchive = new VdbToSrampArchive(stream); srampArchive = vdbArchive.createSrampArchive(); assertThat(srampArchive, is(not(nullValue()))); assertThat(srampArchive.getEntries().size(), is(7)); // manifest + 6 xmi models // check the manifest assertManifest(srampArchive); // check the models assertModel(srampArchive, "BooksProject/Books_Oracle.xmi"); assertModel(srampArchive, "BooksProject/BooksView_Output_View.xmi"); assertModel(srampArchive, "BooksProject/BooksView_WS.xmi"); assertModel(srampArchive, "BooksProject/BooksView.xmi"); // check other files assertXsd(srampArchive, "BooksProject/BooksView_Input.xsd"); assertXsd(srampArchive, "BooksProject/BooksView_Output.xsd"); } finally { IOUtils.closeQuietly(stream); SrampArchive.closeQuietly(srampArchive); ZipToSrampArchive.closeQuietly(vdbArchive); } }
Collection<SrampArchiveEntry> entries = archive.getEntries();
Collection<SrampArchiveEntry> entries = archive.getEntries(); Assert.assertEquals(4, entries.size()); Map<String, SrampArchiveEntry> entryMap = new HashMap<String, SrampArchiveEntry>();