use of org.apache.ivy.osgi.repo.BundleRepoDescriptor in project ant-ivy by apache.
the class BuildOBRTaskTest method testDir.
@Test
public void testDir() throws Exception {
buildObr.setBaseDir(new File("test/test-repo/bundlerepo"));
File obrFile = new File("build/cache/obr.xml");
buildObr.setOut(obrFile);
buildObr.execute();
BundleRepoDescriptor obr = readObr(obrFile);
assertEquals(14, CollectionUtils.toList(obr.getModules()).size());
}
use of org.apache.ivy.osgi.repo.BundleRepoDescriptor in project ant-ivy by apache.
the class BuildOBRTaskTest method testEmptyDir.
@Test
public void testEmptyDir() throws Exception {
buildObr.setBaseDir(new File("test/test-p2/composite"));
File obrFile = new File("build/cache/obr.xml");
buildObr.setOut(obrFile);
buildObr.execute();
BundleRepoDescriptor obr = readObr(obrFile);
assertEquals(0, CollectionUtils.toList(obr.getModules()).size());
}
use of org.apache.ivy.osgi.repo.BundleRepoDescriptor in project ant-ivy by apache.
the class OBRParserTest method testParseSource.
@Test
public void testParseSource() throws Exception {
BundleRepoDescriptor repo = OBRXMLParser.parse(testObr.toURI(), new FileInputStream(new File(testObr, "sources.xml")));
assertNotNull(repo);
assertEquals(2, CollectionUtils.toList(repo.getModules()).size());
Iterator<ModuleDescriptorWrapper> itModule = repo.getModules();
while (itModule.hasNext()) {
ModuleDescriptor md = itModule.next().getModuleDescriptor();
if (md.getModuleRevisionId().getName().equals("org.apache.felix.eventadmin")) {
assertEquals(1, md.getAllArtifacts().length);
} else {
assertEquals("org.apache.felix.bundlerepository", md.getModuleRevisionId().getName());
assertEquals(2, md.getAllArtifacts().length);
String type0 = md.getAllArtifacts()[0].getType();
String url0 = md.getAllArtifacts()[0].getUrl().toExternalForm();
String type1 = md.getAllArtifacts()[1].getType();
String url1 = md.getAllArtifacts()[1].getUrl().toExternalForm();
assertTrue("Default Maven URL must end with '/'", DEFAULT_M2_ROOT.endsWith("/"));
String jarUrl = DEFAULT_M2_ROOT + "org/apache/felix/org.apache.felix." + "bundlerepository/1.0.3/org.apache.felix.bundlerepository-1.0.3.jar";
String srcUrl = "http://oscar-osgi.sf.net/obr2/org.apache.felix." + "bundlerepository/org.apache.felix.bundlerepository-1.0.3-src.jar";
if (type0.equals("jar")) {
assertEquals(jarUrl, url0);
assertEquals("source", type1);
assertEquals(srcUrl, url1);
} else {
assertEquals("jar", type1);
assertEquals(jarUrl, url1);
assertEquals("source", type0);
assertEquals(srcUrl, url0);
}
}
}
assertEquals("Felix-Releases", repo.getName());
assertEquals("20120203022437.168", repo.getLastModified());
}
use of org.apache.ivy.osgi.repo.BundleRepoDescriptor in project ant-ivy by apache.
the class OBRParserTest method testParse.
@Test
public void testParse() throws Exception {
BundleRepoDescriptor repo = OBRXMLParser.parse(testObr.toURI(), new FileInputStream(new File(testObr, "obr.xml")));
assertNotNull(repo);
assertEquals("OBR/Releases", repo.getName());
assertEquals("1253581430652", repo.getLastModified());
}
use of org.apache.ivy.osgi.repo.BundleRepoDescriptor in project ant-ivy by apache.
the class OBRXMLWriterTest method testWriteWithSource.
@Test
public void testWriteWithSource() throws Exception {
List<BundleInfo> bundles = new ArrayList<>();
BundleInfo bundle = new BundleInfo(BUNDLE_1, BUNDLE_VERSION);
bundle.addArtifact(new BundleArtifact(false, new URI("file:///test.jar"), null));
bundle.addArtifact(new BundleArtifact(true, new URI("file:///test-sources.jar"), null));
bundles.add(bundle);
bundle = new BundleInfo(BUNDLE_2, BUNDLE_VERSION);
bundle.addArtifact(new BundleArtifact(false, new URI("file:///test2.jar"), null));
bundles.add(bundle);
new File("build/test-files").mkdirs();
File obrFile = new File("build/test-files/obr-sources.xml");
try (FileOutputStream out = new FileOutputStream(obrFile)) {
ContentHandler handler = OBRXMLWriter.newHandler(out, "UTF-8", true);
OBRXMLWriter.writeBundles(bundles, handler);
}
BundleRepoDescriptor repo;
try (FileInputStream in = new FileInputStream(obrFile)) {
repo = OBRXMLParser.parse(new URI("file:///test"), in);
}
assertEquals(2, CollectionUtils.toList(repo.getModules()).size());
ModuleDescriptorWrapper bundle1 = repo.findModule(BUNDLE_1, BUNDLE_VERSION);
assertNotNull(bundle1);
Artifact[] artifacts = bundle1.getModuleDescriptor().getAllArtifacts();
assertEquals(2, artifacts.length);
if (artifacts[0].getType().equals("jar")) {
assertEquals("source", artifacts[1].getType());
} else {
assertEquals("jar", artifacts[1].getType());
assertEquals("source", artifacts[0].getType());
}
ModuleDescriptorWrapper bundle2 = repo.findModule(BUNDLE_2, BUNDLE_VERSION);
assertNotNull(bundle2);
assertEquals(1, bundle2.getModuleDescriptor().getAllArtifacts().length);
}
Aggregations