diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-11 04:27:50 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-11 04:27:50 +0000 |
commit | 4490c4b376d6f334faadf3932d6517fea2b57db1 (patch) | |
tree | babad8c4f98fbc862b536bb173ec4db5d674b2b5 /java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany | |
parent | a8a286315d8994283b280d88b84aa790a4fedf74 (diff) |
Add import/export for the test bundles
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@752364 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany')
3 files changed, 21 insertions, 12 deletions
diff --git a/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTestCase.java b/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTestCase.java index 92d99a04ba..26bf78b395 100644 --- a/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTestCase.java +++ b/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTestCase.java @@ -53,6 +53,7 @@ public class OSGiTestCase { OSGiTestBundles.createBundle("target/test-classes/OSGiTestService.jar", OSGiTestInterface.class.getName(), null, + null, OSGiTestImpl.class, OSGiTestInterface.class); node = diff --git a/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java b/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java index 15cbd77c4e..c062aba40b 100644 --- a/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java +++ b/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java @@ -48,25 +48,32 @@ public class OSGiTestBundles { return index == -1 ? "" : name.substring(0, index); } - public static URL createBundle(String jarName, String bundleName, String imports, Class<?>... classes) - throws Exception { + public static URL createBundle(String jarName, + String bundleName, + String exports, + String imports, + Class<?>... classes) throws Exception { Class<?> activator = null; Set<String> packages = new HashSet<String>(); - StringBuffer exports = new StringBuffer(); + StringBuffer exportPackages = new StringBuffer(); + if (exports != null) { + exportPackages.append(exports); + } for (Class<?> cls : classes) { if (BundleActivator.class.isAssignableFrom(cls)) { activator = cls; } - if (cls.isInterface()) { + if (exports == null && cls.isInterface()) { String pkg = getPackageName(cls); if (packages.add(pkg)) { - exports.append(pkg).append(","); + exportPackages.append(pkg).append(","); } } } - if (exports.length() > 0) { - exports.deleteCharAt(exports.length() - 1); + int len = exportPackages.length(); + if (len > 0 && exportPackages.charAt(len - 1) == ',') { + exportPackages.deleteCharAt(len - 1); } Manifest manifest = new Manifest(); @@ -76,14 +83,14 @@ public class OSGiTestBundles { manifest.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, bundleName); manifest.getMainAttributes().putValue(Constants.BUNDLE_VERSION, "1.0.0"); manifest.getMainAttributes().putValue(Constants.BUNDLE_NAME, bundleName); - manifest.getMainAttributes().putValue(Constants.EXPORT_PACKAGE, exports.toString()); - String importPackages = null; + manifest.getMainAttributes().putValue(Constants.EXPORT_PACKAGE, exportPackages.toString()); + StringBuffer importPackages = new StringBuffer(); if (imports != null) { - importPackages = "org.osgi.framework," + imports; + importPackages.append(imports).append(",org.osgi.framework"); } else { - importPackages = "org.osgi.framework"; + importPackages.append("org.osgi.framework"); } - manifest.getMainAttributes().putValue(Constants.IMPORT_PACKAGE, importPackages); + manifest.getMainAttributes().putValue(Constants.IMPORT_PACKAGE, importPackages.toString()); if (activator != null) { manifest.getMainAttributes().putValue(Constants.BUNDLE_ACTIVATOR, activator.getName()); diff --git a/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java b/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java index ca458a2d4e..7be96b32c5 100644 --- a/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java +++ b/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java @@ -73,6 +73,7 @@ public class OSGiReadImplTestCase { OSGiTestBundles.createBundle("target/test-classes/OSGiTestService.jar", OSGiTestInterface.class.getName(), null, + null, OSGiTestImpl.class, OSGiTestInterface.class); } |