archive = new SrampArchive(tempFile);
/** * 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); } }
archive = new SrampArchive(tempFile); Collection<SrampArchiveEntry> entries = archive.getEntries(); Assert.assertEquals(1, entries.size());
/** * Creates an S-RAMP archive from this JAR. * @return an S-RAMP archive * @throws ZipToSrampArchiveException */ public SrampArchive createSrampArchive() throws ZipToSrampArchiveException { this.artifactFilter.setContext(this.context); this.metaDataFactory.setContext(this.context); DiscoveredArtifacts discoveredArtifacts = discoverArtifacts(); discoveredArtifacts.index(jarWorkDir); generateMetaData(discoveredArtifacts); try { SrampArchive archive = new SrampArchive(); for (DiscoveredArtifact artifact : discoveredArtifacts) { String path = artifact.getArchivePath(); archive.addEntry(path, artifact.getMetaData(), artifact.getContent()); } return archive; } catch (Exception e) { throw new ZipToSrampArchiveException(e); } }
/** * 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); } }
InputStream is2 = null; try { archive = new SrampArchive();
InputStream is2 = null; try { archive = new SrampArchive();
setMetaData(artifact4MetaData, "xlink.xsd", "1.6.1", "X-LINK schema."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ archive = new SrampArchive(); archive.addEntry(path1, artifact1MetaData, artifact1ContentStream); archive.addEntry(path2, artifact2MetaData, artifact2ContentStream); archive = new SrampArchive(archiveFile); Collection<SrampArchiveEntry> entries = archive.getEntries(); Assert.assertEquals(4, entries.size());
archive = new SrampArchive(); ExtendedArtifactType nonDocArtifact = new ExtendedArtifactType(); nonDocArtifact.setArtifactType(BaseArtifactEnum.EXTENDED_ARTIFACT_TYPE);