diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-04 23:06:50 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-04 23:06:50 +0000 |
commit | ba4247f963e479d02f1806d2898444643ceeb685 (patch) | |
tree | 0130b200c60b37ba1f5cf7e6707f1ca739578df8 | |
parent | 818cab64a0e869011acb140271664c10707ef803 (diff) |
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
6 files changed, 151 insertions, 3 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+-->
+
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:c="http://calculator.dosgi">
+ <deployable composite="c:CalculatorComposite" />
+</contribution>
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 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://calculator.dosgi"
+ name="CalculatorComposite">
+
+ <component name="CalculatorComponent">
+ <tuscany:implementation.osgi bundleSymbolicName="calculator.dosgi" bundleVersion="1.0.0" />
+ <reference name="addService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/AddService"/>
+ </reference>
+ <reference name="subtractService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/SubtractService"/>
+ </reference>
+ <reference name="multiplyService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/MultiplyService"/>
+ </reference>
+ <reference name="divideService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/DivideService"/>
+ </reference>
+
+ <!--
+ <reference name="addService" target="OperationsComponent/AddService">
+ </reference>
+ <reference name="subtractService" target="OperationsComponent/SubtractService">
+ </reference>
+ <reference name="multiplyService" target="OperationsComponent/MultiplyService">
+ </reference>
+ <reference name="divideService" target="OperationsComponent/DivideService">
+ </reference>
+ -->
+
+ <component name="OperationsComponent">
+ <tuscany:implementation.osgi bundleSymbolicName="calculator.dosgi.operations" bundleVersion="1.0.0" />
+ <service name="AddService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/AddService"/>
+ </service>
+ <service name="SubtractService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/SubtractService"/>
+ </service>
+ <service name="MultiplyService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/MultiplyService"/>
+ </service>
+ <service name="DivideService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/DivideService"/>
+ </service>
+
+ </component>
+ </component>
+
+</composite>
|