From ba4247f963e479d02f1806d2898444643ceeb685 Mon Sep 17 00:00:00 2001 From: rfeng Date: Mon, 4 May 2009 23:06:50 +0000 Subject: Change the test case to use an external SCA bundle to control the RFC119 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@771488 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/node/osgi/impl/NodeManager.java | 2 + .../dosgi/test/CalculatorOSGiNodeTestCase.java | 13 +++- .../calculator/dosgi/test/OSGiTestBundles.java | 35 ++++++++++- .../calculator/dosgi/sca/META-INF/MANIFEST.MF | 10 ++++ .../dosgi/sca/META-INF/sca-contribution.xml | 24 ++++++++ .../dosgi/sca/OSGI-INF/sca/calculator.composite | 70 ++++++++++++++++++++++ 6 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF create mode 100644 java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml create mode 100644 java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite (limited to 'java/sca/modules') diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java index 47368a9f18..b69208d351 100644 --- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java +++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java @@ -71,6 +71,7 @@ public class NodeManager implements SynchronousBundleListener, ServiceListener { return true; } + /* // OSGi Declarative Services if (headers.get("Service-Component") != null) { return true; @@ -85,6 +86,7 @@ public class NodeManager implements SynchronousBundleListener, ServiceListener { if (entries != null && entries.hasMoreElements()) { return true; } + */ return false; } diff --git a/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java b/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java index 945f0fca37..a141cbeb21 100644 --- a/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java +++ b/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java @@ -21,6 +21,7 @@ package calculator.dosgi.test; import static calculator.dosgi.test.OSGiTestBundles.bundleStatus; import static calculator.dosgi.test.OSGiTestBundles.generateCalculatorBundle; +import static calculator.dosgi.test.OSGiTestBundles.generateCalculatorSCABundle; import static calculator.dosgi.test.OSGiTestBundles.generateOperationsBundle; import java.net.URL; @@ -34,6 +35,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; import org.osgi.framework.ServiceReference; import calculator.dosgi.CalculatorService; @@ -46,6 +48,7 @@ public class CalculatorOSGiNodeTestCase { private static BundleContext context; private static Bundle calculatorBundle; private static Bundle operationsBundle; + private static Bundle scaBundle; private static Boolean client; public static URL getCodeLocation(final Class anchorClass) { @@ -78,12 +81,16 @@ public class CalculatorOSGiNodeTestCase { System.out.println("Generating calculator.dosgi.operations bundle..."); operationsBundle = context.installBundle("reference:" + generateOperationsBundle().toString()); } + + scaBundle = context.installBundle("reference:" + generateCalculatorSCABundle().toString()); for (Bundle b : context.getBundles()) { if (b.getSymbolicName().equals("org.eclipse.equinox.ds") || b.getSymbolicName() .startsWith("org.apache.tuscany.sca.")) { try { - b.start(); + if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null) { + b.start(); + } } catch (Exception e) { System.out.println(bundleStatus(b, false)); e.printStackTrace(); @@ -91,6 +98,10 @@ public class CalculatorOSGiNodeTestCase { System.out.println(bundleStatus(b, false)); } } + + if (scaBundle != null) { + scaBundle.start(); + } if (calculatorBundle != null) { calculatorBundle.start(); diff --git a/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java b/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java index 0e299938a1..619dcaa07d 100644 --- a/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java +++ b/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java @@ -227,11 +227,14 @@ public class OSGiTestBundles { "OSGI-INF/remote-service/calculator-service-descriptions.xml"}, {"calculator/dosgi/OSGI-INF/calculator-component.xml", "OSGI-INF/calculator-component.xml"}, + /* {"calculator/dosgi/bundle.componentType", "OSGI-INF/sca/bundle.componentType"}, {"calculator/dosgi/calculator.composite", "OSGI-INF/sca/bundle.composite"}, {"calculator/dosgi/META-INF/sca-contribution.xml", - "META-INF/sca-contribution.xml"}}, + "META-INF/sca-contribution.xml"} + */ + }, CalculatorService.class, // Package the interfaces so that the operations bundle can be remote AddService.class, @@ -243,6 +246,31 @@ public class OSGiTestBundles { CalculatorActivator.class); } + /** + * Create the OSGi bundle for calculator SCA + * @return + * @throws IOException + */ + static URL generateCalculatorSCABundle() throws IOException { + return createBundle("target/test-classes/calculator-sca-bundle.jar", + "calculator/dosgi/sca/META-INF/MANIFEST.MF", + new String[][] { + {"calculator/dosgi/sca/OSGI-INF/sca/calculator.composite", + "OSGI-INF/sca/bundle.composite"}, + {"calculator/dosgi/sca/META-INF/sca-contribution.xml", + "META-INF/sca-contribution.xml"}, + {"calculator/dosgi/bundle.componentType", + "OSGI-INF/sca/calculator.dosgi/bundle.componentType"}, + {"calculator/dosgi/operations/bundle.componentType", + "OSGI-INF/sca/calculator.dosgi.operations/bundle.componentType"}, + }); + } + + /** + * Create the OSGi bundle for calculator operations + * @return + * @throws IOException + */ static URL generateOperationsBundle() throws IOException { return createBundle("target/test-classes/operations-bundle.jar", "calculator/dosgi/operations/META-INF/MANIFEST.MF", @@ -255,12 +283,15 @@ public class OSGiTestBundles { "OSGI-INF/multiply-component.xml"}, {"calculator/dosgi/operations/OSGI-INF/divide-component.xml", "OSGI-INF/divide-component.xml"}, + /* {"calculator/dosgi/operations/bundle.componentType", "OSGI-INF/sca/bundle.componentType"}, {"calculator/dosgi/operations/operations.composite", "OSGI-INF/sca/bundle.composite"}, {"calculator/dosgi/operations/META-INF/sca-contribution.xml", - "META-INF/sca-contribution.xml"}}, + "META-INF/sca-contribution.xml"} + */ + }, OperationsActivator.class, AddService.class, AddServiceImpl.class, diff --git a/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF b/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..0153fc6997 --- /dev/null +++ b/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-Version: 1.0.0 +Bundle-Name: calculator.dosgi.sca +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: calculator.dosgi.sca +Bundle-Vendor: The Apache Software Foundation +Eclipse-LazyStart: false +Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt +Bundle-DocURL: http://www.apache.org/ +Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6 diff --git a/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml b/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..8ba4b85247 --- /dev/null +++ b/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + + diff --git a/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite b/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite new file mode 100644 index 0000000000..ac7f0f470c --- /dev/null +++ b/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3