} finally { FileUtils.deleteQuietly(tempFile); SrampArchive.closeQuietly(archive);
@Test public void testSwitchYardIntegration() throws Exception { InputStream stream = getClass().getResourceAsStream("switchyard-quickstart-bean-service.jar"); //$NON-NLS-1$ SrampArchive archive = null; SwitchYardAppToSrampArchive sy2archive = null; try { sy2archive = new SwitchYardAppToSrampArchive(stream); archive = sy2archive.createSrampArchive(); Assert.assertNotNull(archive); doAllAssertions(archive); } finally { IOUtils.closeQuietly(stream); SrampArchive.closeQuietly(archive); ZipToSrampArchive.closeQuietly(sy2archive); } }
@Test public void testKieIntegration() throws Exception { InputStream stream = getClass().getResourceAsStream("kie.jar"); //$NON-NLS-1$ SrampArchive archive = null; KieJarToSrampArchive kie2archive = null; try { kie2archive = new KieJarToSrampArchive(stream); archive = kie2archive.createSrampArchive(); Assert.assertNotNull(archive); doAllAssertions(archive); } finally { IOUtils.closeQuietly(stream); SrampArchive.closeQuietly(archive); ZipToSrampArchive.closeQuietly(kie2archive); } }
/** * Test method for {@link SrampAtomApiClient#uploadBatch(SrampArchive)}. */ @Test public void testArchiveUpload_Empty() throws Exception { // First, create an s-ramp archive SrampArchive archive = null; try { archive = new SrampArchive(); } catch (Exception e) { SrampArchive.closeQuietly(archive); throw e; } finally { } try { // Now use the s-ramp atom api client to upload the s-ramp archive SrampAtomApiClient client = new SrampAtomApiClient(generateURL("/s-ramp")); //$NON-NLS-1$ Map<String, ?> results = client.uploadBatch(archive); Assert.assertTrue(results.isEmpty()); } finally { SrampArchive.closeQuietly(archive); } }
/** * Test method for {@link org.overlord.sramp.common.atom.archive.SrampArchive#addEntry(String, org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactType, InputStream)}. */ @Test public void testAddEntry() throws Exception { InputStream artifactContentStream = SrampArchiveTest.class.getResourceAsStream("sample.xsd"); //$NON-NLS-1$ XsdDocument artifactMetaData = new XsdDocument(); setMetaData(artifactMetaData, "sample.xsd", "1.0.3", "Just a sample XML Schema."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ SrampArchive archive = null; try { archive = new SrampArchive(); archive.addEntry("sample.xsd", artifactMetaData, artifactContentStream); //$NON-NLS-1$ File workDir = AtomTestUtils.getArchiveWorkDir(archive); Assert.assertNotNull(workDir); Assert.assertTrue(workDir.isDirectory()); Collection<File> files = FileUtils.listFiles(workDir, new String[] {"xsd", "atom"}, true); //$NON-NLS-1$ //$NON-NLS-2$ Assert.assertEquals(2, files.size()); Set<String> fnames = new HashSet<String>(); for (File f : files) { fnames.add(f.getName()); } Assert.assertTrue(fnames.contains("sample.xsd")); //$NON-NLS-1$ Assert.assertTrue(fnames.contains("sample.xsd.atom")); //$NON-NLS-1$ } finally { SrampArchive.closeQuietly(archive); } }
/** * 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); } }
} finally { ZipToSrampArchive.closeQuietly(j2sramp); SrampArchive.closeQuietly(archive);
IOUtils.closeQuietly(artifactsIS); ZipToSrampArchive.closeQuietly(sy2archive); SrampArchive.closeQuietly(archive); IOUtils.closeQuietly(artifactsIS); ZipToSrampArchive.closeQuietly(sy2archive); SrampArchive.closeQuietly(archive); IOUtils.closeQuietly(artifactsIS); ZipToSrampArchive.closeQuietly(sy2archive); SrampArchive.closeQuietly(archive);
} finally { FileUtils.deleteQuietly(tempFile); SrampArchive.closeQuietly(archive);
@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); } }
archive.addEntry("core/PO.xml", metaData, null); //$NON-NLS-1$ } catch (Exception e) { SrampArchive.closeQuietly(archive); throw e; } finally { Assert.assertNotNull(xmlError); } finally { SrampArchive.closeQuietly(archive);
archive.addEntry("core/PO.xml", metaData, is2); //$NON-NLS-1$ } catch (Exception e) { SrampArchive.closeQuietly(archive); throw e; } finally { Assert.assertEquals("1.2", xmlDoc.getVersion()); //$NON-NLS-1$ } finally { SrampArchive.closeQuietly(archive);
@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); } }
/** * Test method for {@link org.overlord.sramp.atom.archive.jar.ZipToSrampArchive.jar.JarToSrampArchive#createSrampArchive()}. */ @Test public void testMetaData() 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); SrampArchiveEntry entry = archive.getEntry("schema/teetime.xsd"); //$NON-NLS-1$ Assert.assertNotNull(entry); BaseArtifactType metaData = entry.getMetaData(); Assert.assertNotNull(metaData); Assert.assertTrue(metaData instanceof XsdDocument); XsdDocument md = (XsdDocument) metaData; Assert.assertEquals("teetime.xsd", md.getName()); //$NON-NLS-1$ Assert.assertNotNull(md.getUuid()); } finally { ZipToSrampArchive.closeQuietly(j2sramp); SrampArchive.closeQuietly(archive); } }
SrampArchive.closeQuietly(archive); Assert.assertEquals("X-LINK schema.", xlinkXsdMetaData.getDescription()); //$NON-NLS-1$ } finally { SrampArchive.closeQuietly(archive); FileUtils.deleteQuietly(archiveFile);
SrampArchive.closeQuietly(archive); throw e; } finally { Assert.assertEquals(1, resultSet.getTotalResults()); } finally { SrampArchive.closeQuietly(archive);
} finally { ZipToSrampArchive.closeQuietly(j2sramp); SrampArchive.closeQuietly(archive);