summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-03-17 23:07:31 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-03-17 23:07:31 +0000
commitefec32910420ff0a3316914668ff44d069d4a744 (patch)
treeaf44e700042376564884bc28048423a6017abead /java
parentc7a8cd70aacea40d19aad4107d3417fa4d10e2d3 (diff)
Update the test case
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@755439 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r--java/sca/modules/node-impl-osgi/pom.xml59
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiServiceTracker.java40
-rw-r--r--java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/CalculatorServiceImpl.java14
-rw-r--r--java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java9
-rw-r--r--java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/calculator.composite8
5 files changed, 113 insertions, 17 deletions
diff --git a/java/sca/modules/node-impl-osgi/pom.xml b/java/sca/modules/node-impl-osgi/pom.xml
index b997b31972..ed7a922d6b 100644
--- a/java/sca/modules/node-impl-osgi/pom.xml
+++ b/java/sca/modules/node-impl-osgi/pom.xml
@@ -55,6 +55,20 @@
<version>2.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-contribution-osgi</artifactId>
@@ -90,6 +104,7 @@
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-assembly-xml</artifactId>
<version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
</dependency>
<dependency>
@@ -167,7 +182,49 @@
<version>2.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
-
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-rmi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-osgi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiServiceTracker.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiServiceTracker.java
new file mode 100644
index 0000000000..59ee133061
--- /dev/null
+++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiServiceTracker.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+package org.apache.tuscany.sca.node.osgi.impl;
+
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+/**
+ * A ServiceTracker
+ */
+public class OSGiServiceTracker implements ServiceTrackerCustomizer {
+
+ public Object addingService(ServiceReference serviceReference) {
+ return null;
+ }
+
+ public void modifiedService(ServiceReference serviceReference, Object service) {
+ }
+
+ public void removedService(ServiceReference serviceReference, Object service) {
+ }
+
+}
diff --git a/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/CalculatorServiceImpl.java b/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/CalculatorServiceImpl.java
index 9f31afbd1f..6dc2e4c621 100644
--- a/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/CalculatorServiceImpl.java
+++ b/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/CalculatorServiceImpl.java
@@ -18,8 +18,9 @@
*/
package calculator.dosgi;
+import static org.osgi.framework.Constants.OBJECTCLASS;
+
import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.util.tracker.ServiceTracker;
@@ -33,10 +34,10 @@ import calculator.dosgi.operations.SubtractService;
* An implementation of the Calculator service.
*/
public class CalculatorServiceImpl implements CalculatorService {
-// private AddService addService;
-// private SubtractService subtractService;
-// private MultiplyService multiplyService;
-// private DivideService divideService;
+ // private AddService addService;
+ // private SubtractService subtractService;
+ // private MultiplyService multiplyService;
+ // private DivideService divideService;
private ServiceTracker tracker;
@@ -48,7 +49,7 @@ public class CalculatorServiceImpl implements CalculatorService {
super();
Filter filter = null;
try {
- filter = context.createFilter("(" + Constants.OBJECTCLASS + "=calculator.dosgi.operations.*)");
+ filter = context.createFilter("(&(" + OBJECTCLASS + "=calculator.dosgi.operations.*) (sca.reference=*))");
} catch (InvalidSyntaxException e) {
e.printStackTrace();
}
@@ -80,6 +81,7 @@ public class CalculatorServiceImpl implements CalculatorService {
private <T> T getService(Class<T> cls) {
for (Object s : tracker.getServices()) {
if (cls.isInstance(s)) {
+ System.out.println(s);
return cls.cast(s);
}
}
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 fdfd07414f..508c332a2b 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
@@ -29,10 +29,7 @@ import java.security.PrivilegedAction;
import java.util.HashSet;
import java.util.Set;
-import org.apache.tuscany.sca.contribution.osgi.impl.OSGiBundleContributionScanner;
-import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
import org.apache.tuscany.sca.node.equinox.launcher.EquinoxHost;
-import org.apache.tuscany.sca.node.osgi.impl.NodeImpl;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -85,9 +82,9 @@ public class CalculatorOSGiNodeTestCase {
}
}
- bundles.add(getCodeLocation(OSGiImplementation.class));
- bundles.add(getCodeLocation(OSGiBundleContributionScanner.class));
- bundles.add(getCodeLocation(NodeImpl.class));
+// bundles.add(getCodeLocation(OSGiImplementation.class));
+// bundles.add(getCodeLocation(OSGiBundleContributionScanner.class));
+// bundles.add(getCodeLocation(NodeImpl.class));
bundles.add(OSGiTestBundles.createBundle("target/test-classes/calculator-bundle.jar",
"calculator/dosgi/META-INF/MANIFEST.MF",
diff --git a/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/calculator.composite b/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/calculator.composite
index bc054b7db8..3c77086c45 100644
--- a/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/calculator.composite
+++ b/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/calculator.composite
@@ -26,16 +26,16 @@
<component name="CalculatorComponent">
<tuscany:implementation.osgi bundleSymbolicName="calculator.dosgi" bundleVersion="1.0.0" />
<reference name="addService">
- <tuscany:binding.rmi uri="rmi://locahost:8085/AddService"/>
+ <tuscany:binding.rmi uri="rmi://localhost:8085/AddService"/>
</reference>
<reference name="subtractService">
- <tuscany:binding.rmi uri="rmi://locahost:8085/SubtractService"/>
+ <tuscany:binding.rmi uri="rmi://localhost:8085/SubtractService"/>
</reference>
<reference name="multiplyService">
- <tuscany:binding.rmi uri="rmi://locahost:8085/MultiplyService"/>
+ <tuscany:binding.rmi uri="rmi://localhost:8085/MultiplyService"/>
</reference>
<reference name="divideService">
- <tuscany:binding.rmi uri="rmi://locahost:8085/DivideService"/>
+ <tuscany:binding.rmi uri="rmi://localhost:8085/DivideService"/>
</reference>
<!--