use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class JarTest method testDeletePrefix.
public void testDeletePrefix() {
Resource r = new EmbeddedResource(new byte[1], 0);
Jar jar = new Jar("test");
jar.putResource("META-INF/maven/org/osgi/test/test.pom", r);
jar.putResource("META-INF/maven/org/osgi/test/test.properties", r);
jar.putResource("META-INF/MANIFEST.MF", r);
jar.putResource("com/example/foo.jar", r);
assertTrue(jar.getDirectories().containsKey("META-INF/maven/org/osgi/test"));
assertTrue(jar.getDirectories().containsKey("META-INF/maven"));
jar.removePrefix("META-INF/maven/");
assertNotNull(jar.getResource("META-INF/MANIFEST.MF"));
assertNotNull(jar.getResource("com/example/foo.jar"));
assertNull(jar.getResource("META-INF/maven/org/osgi/test/test.pom"));
assertNull(jar.getResource("META-INF/maven/org/osgi/test/test.properties"));
assertFalse(jar.getDirectories().containsKey("META-INF/maven"));
assertFalse(jar.getDirectories().containsKey("META-INF/maven/org/osgi/test"));
}
use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class JarTest method testNoManifest.
public static void testNoManifest() throws Exception {
Jar jar = new Jar("dot");
jar.setManifest(new Manifest());
jar.setDoNotTouchManifest();
jar.putResource("a/b", new FileResource(IO.getFile("testresources/bnd.jar")));
ByteArrayOutputStream bout = new ByteArrayOutputStream();
jar.write(bout);
Jar jin = new Jar("dotin", new ByteArrayInputStream(bout.toByteArray()));
Resource m = jin.getResource("META-INF/MANIFEST.MF");
assertNull(m);
Resource r = jin.getResource("a/b");
assertNotNull(r);
}
use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class LauncherTest method testShaPackager.
/**
* Test the sha packager
*
* @throws Exception
*/
public static void testShaPackager() throws Exception {
Project project = getProject();
project.clear();
project.setProperty("-package", "jpm");
ProjectLauncher l = project.getProjectLauncher();
l.setTrace(true);
Jar executable = l.executable();
assertNotNull(executable);
Manifest m = executable.getManifest();
m.write(System.out);
System.out.flush();
assertNotNull(m.getMainAttributes().getValue("JPM-Classpath"));
assertNotNull(m.getMainAttributes().getValue("JPM-Runbundles"));
Resource r = executable.getResource("launcher.properties");
assertNotNull(r);
Properties p = new Properties();
try (InputStream in = r.openInputStream()) {
p.load(in);
}
System.out.println(p);
String s = p.getProperty("launch.bundles");
assertTrue(s.contains("${JPMREPO}/"));
assertEquals("false", p.getProperty("launch.embedded"));
}
use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class DSAnnotationTest method testValidNamespaceVersion.
public void testValidNamespaceVersion() throws Exception {
Builder b = new Builder();
b.setProperty(Constants.DSANNOTATIONS, "test.component.*ValidNSVersion");
b.setProperty("Private-Package", "test.component");
b.addClasspath(new File("bin"));
// v1.0.0
b.addClasspath(new File("jar/osgi.jar"));
Jar jar = b.build();
if (!b.check())
fail();
Attributes a = getAttr(jar);
checkProvides(a);
checkRequires(a, null);
Resource r = jar.getResource("OSGI-INF/test.component.DSAnnotationTest$ValidNSVersion.xml");
System.err.println(Processor.join(jar.getResources().keySet(), "\n"));
assertNotNull(r);
r.write(System.err);
}
use of aQute.bnd.osgi.Resource in project bnd by bndtools.
the class DSAnnotationTest method testBinds13.
public void testBinds13() throws Exception {
Builder b = new Builder();
b.setProperty(Constants.DSANNOTATIONS, "test.component.DSAnnotationTest*CheckBinds13");
b.setProperty("Private-Package", "test.component");
b.addClasspath(new File("bin"));
Jar jar = b.build();
assertOk(b);
Attributes a = getAttr(jar);
checkProvides(a);
checkRequires(a, "1.3.0", LogService.class.getName());
Resource r = jar.getResource("OSGI-INF/" + CheckBinds13.class.getName() + ".xml");
assertNotNull(r);
r.write(System.err);
XmlTester xt = new XmlTester(r.openInputStream(), "scr", "http://www.osgi.org/xmlns/scr/v1.3.0");
for (int i = 1; i <= 8; i++) {
xt.assertAttribute(LogService.class.getName(), "scr:component/reference[" + i + "]/@interface");
}
}
Aggregations