- * The {@link org.ops4j.pax.tinybundles.TinyBundles} class is the factory to get everything started.
+ * Provides a fluent Java API to create and modify OSGi bundles on the fly.
*
* @since 1.0
*/
diff --git a/src/test/java/org/ops4j/pax/tinybundles/it/DeclarativeServiceBndBundleBuildIT.java b/src/test/java/org/ops4j/pax/tinybundles/it/DeclarativeServiceBndBundleBuildIT.java
index b47bb22..f58a35c 100644
--- a/src/test/java/org/ops4j/pax/tinybundles/it/DeclarativeServiceBndBundleBuildIT.java
+++ b/src/test/java/org/ops4j/pax/tinybundles/it/DeclarativeServiceBndBundleBuildIT.java
@@ -54,7 +54,7 @@ public class DeclarativeServiceBndBundleBuildIT extends TinybundlesTestSupport {
private InputStream dsBundle() {
return bundle()
.symbolicName(BUNDLE_SYMBOLICNAME)
- .add(DsService.class)
+ .addClass(DsService.class)
.build(bndBuilder());
}
diff --git a/src/test/java/org/ops4j/pax/tinybundles/test/BndTest.java b/src/test/java/org/ops4j/pax/tinybundles/test/BndTest.java
index f2c0fcd..4263d33 100644
--- a/src/test/java/org/ops4j/pax/tinybundles/test/BndTest.java
+++ b/src/test/java/org/ops4j/pax/tinybundles/test/BndTest.java
@@ -20,6 +20,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.jar.Attributes;
+import java.util.jar.JarInputStream;
import org.junit.Test;
import org.ops4j.pax.tinybundles.demo.HelloWorld;
@@ -61,7 +62,7 @@ public void bndCustomHeaders() throws IOException {
@Test
public void bndDeclarativeServices() throws IOException {
final InputStream bundle = bundle()
- .add(DsService.class)
+ .addClass(DsService.class)
.build(bndBuilder());
final Attributes attributes = getManifest(bundle).getMainAttributes();
assertThat(attributes.getValue("Service-Component"), is("OSGI-INF/org.ops4j.pax.tinybundles.demo.ds.DsService.xml"));
@@ -70,11 +71,11 @@ public void bndDeclarativeServices() throws IOException {
@Test
public void createTestAllDefault() throws IOException {
final InputStream bundle = bundle()
- .add(HelloWorldActivator.class)
- .add(HelloWorld.class)
- .add(HelloWorldImpl.class)
- .set(Constants.BUNDLE_SYMBOLICNAME, "MyFirstTinyBundle")
- .set(Constants.BUNDLE_ACTIVATOR, HelloWorldActivator.class.getName())
+ .addClass(HelloWorldActivator.class)
+ .addClass(HelloWorld.class)
+ .addClass(HelloWorldImpl.class)
+ .setHeader(Constants.BUNDLE_SYMBOLICNAME, "MyFirstTinyBundle")
+ .setHeader(Constants.BUNDLE_ACTIVATOR, HelloWorldActivator.class.getName())
.build(bndBuilder());
final Attributes attributes = getManifest(bundle).getMainAttributes();
// calculated import
@@ -86,12 +87,12 @@ public void createTestAllDefault() throws IOException {
@Test
public void createTestExport() throws IOException {
final InputStream bundle = bundle()
- .add(HelloWorldActivator.class)
- .add(HelloWorld.class)
- .add(HelloWorldImpl.class)
- .set(Constants.BUNDLE_SYMBOLICNAME, "MyFirstTinyBundle")
- .set(Constants.EXPORT_PACKAGE, HelloWorld.class.getPackage().getName())
- .set(Constants.BUNDLE_ACTIVATOR, HelloWorldActivator.class.getName())
+ .addClass(HelloWorldActivator.class)
+ .addClass(HelloWorld.class)
+ .addClass(HelloWorldImpl.class)
+ .setHeader(Constants.BUNDLE_SYMBOLICNAME, "MyFirstTinyBundle")
+ .setHeader(Constants.EXPORT_PACKAGE, HelloWorld.class.getPackage().getName())
+ .setHeader(Constants.BUNDLE_ACTIVATOR, HelloWorldActivator.class.getName())
.build(bndBuilder());
final Attributes attributes = getManifest(bundle).getMainAttributes();
// calculated import and re-import
@@ -103,15 +104,14 @@ public void createTestExport() throws IOException {
@Test
public void embedDependency() throws IOException {
final InputStream bundle = bundle()
- .add(HelloWorldActivator.class)
- .add(HelloWorld.class)
- .add(HelloWorldImpl.class)
- .set(Constants.BUNDLE_SYMBOLICNAME, "MyFirstTinyBundle")
- .set(Constants.EXPORT_PACKAGE, HelloWorld.class.getPackage().getName())
- .set(Constants.BUNDLE_ACTIVATOR, HelloWorldActivator.class.getName())
- .set(Constants.BUNDLE_ACTIVATOR, HelloWorldActivator.class.getName())
- .set("Bundle-Classpath", ".,ant-1.8.1.jar")
- .set("Include-Resource", "@/Users/tonit/devel/gradle/lib/ant-1.8.1.jar")
+ .addClass(HelloWorldActivator.class)
+ .addClass(HelloWorld.class)
+ .addClass(HelloWorldImpl.class)
+ .setHeader(Constants.BUNDLE_SYMBOLICNAME, "MyFirstTinyBundle")
+ .setHeader(Constants.EXPORT_PACKAGE, HelloWorld.class.getPackage().getName())
+ .setHeader(Constants.BUNDLE_ACTIVATOR, HelloWorldActivator.class.getName())
+ .setHeader("Bundle-Classpath", ".,ant-1.8.1.jar")
+ .setHeader("Include-Resource", "@/Users/tonit/devel/gradle/lib/ant-1.8.1.jar")
.build(bndBuilder());
final Attributes attributes = getManifest(bundle).getMainAttributes();
// calculated import and re-import
@@ -123,18 +123,18 @@ public void embedDependency() throws IOException {
@Test
public void modifyTest() throws IOException {
final InputStream bundle1 = bundle()
- .add(HelloWorldActivator.class)
- .add(HelloWorld.class)
- .add(HelloWorldImpl.class)
- .set(Constants.BUNDLE_SYMBOLICNAME, "MyFirstTinyBundle")
- .set(Constants.BUNDLE_ACTIVATOR, HelloWorldActivator.class.getName())
+ .addClass(HelloWorldActivator.class)
+ .addClass(HelloWorld.class)
+ .addClass(HelloWorldImpl.class)
+ .setHeader(Constants.BUNDLE_SYMBOLICNAME, "MyFirstTinyBundle")
+ .setHeader(Constants.BUNDLE_ACTIVATOR, HelloWorldActivator.class.getName())
.build(bndBuilder());
// Add an export:
final InputStream bundle2 = bundle()
- .read(bundle1)
- .set(Constants.EXPORT_PACKAGE, HelloWorld.class.getPackage().getName())
- .set(Constants.IMPORT_PACKAGE, "*")
- .set("another", "property")
+ .readIn(new JarInputStream(bundle1))
+ .setHeader(Constants.EXPORT_PACKAGE, HelloWorld.class.getPackage().getName())
+ .setHeader(Constants.IMPORT_PACKAGE, "*")
+ .setHeader("another", "property")
.build(bndBuilder());
// test output
final Attributes attributes = getManifest(bundle2).getMainAttributes();
diff --git a/src/test/java/org/ops4j/pax/tinybundles/test/InnerClassesTest.java b/src/test/java/org/ops4j/pax/tinybundles/test/InnerClassesTest.java
index b858094..b22dae0 100644
--- a/src/test/java/org/ops4j/pax/tinybundles/test/InnerClassesTest.java
+++ b/src/test/java/org/ops4j/pax/tinybundles/test/InnerClassesTest.java
@@ -33,7 +33,7 @@ public class InnerClassesTest {
@Test
public void allInnerClassesTest() {
- bundle().add(DemoAnonymousInnerClass.class, InnerClassStrategy.ALL).build(
+ bundle().addClass(DemoAnonymousInnerClass.class, InnerClassStrategy.ALL).build(
(resources, headers) -> {
assertThat(resources.keySet(), hasItems(
"org/ops4j/pax/tinybundles/demo/DemoAnonymousInnerClass.class",
@@ -49,7 +49,7 @@ public void allInnerClassesTest() {
@Test
public void anonymousInnerClassesTest() {
- bundle().add(DemoAnonymousInnerClass.class, InnerClassStrategy.ANONYMOUS).build(
+ bundle().addClass(DemoAnonymousInnerClass.class, InnerClassStrategy.ANONYMOUS).build(
(resources, headers) -> {
final Set