From efec32910420ff0a3316914668ff44d069d4a744 Mon Sep 17 00:00:00 2001 From: rfeng Date: Tue, 17 Mar 2009 23:07:31 +0000 Subject: Update the test case git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@755439 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/modules/node-impl-osgi/pom.xml | 59 +++++++++++++++++++++- .../sca/node/osgi/impl/OSGiServiceTracker.java | 40 +++++++++++++++ .../calculator/dosgi/CalculatorServiceImpl.java | 14 ++--- .../dosgi/test/CalculatorOSGiNodeTestCase.java | 9 ++-- .../calculator/dosgi/calculator.composite | 8 +-- 5 files changed, 113 insertions(+), 17 deletions(-) create mode 100644 java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiServiceTracker.java (limited to 'java') 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 @@ 2.0-SNAPSHOT + + org.apache.tuscany.sca + tuscany-contribution-java + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-extensibility-equinox + 2.0-SNAPSHOT + runtime + + org.apache.tuscany.sca tuscany-contribution-osgi @@ -90,6 +104,7 @@ org.apache.tuscany.sca tuscany-assembly-xml 2.0-SNAPSHOT + runtime @@ -167,7 +182,49 @@ 2.0-SNAPSHOT test - + + + org.apache.tuscany.sca + tuscany-binding-rmi-runtime + 2.0-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-binding-rmi + 2.0-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-host-rmi + 2.0-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-osgi + 2.0-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-osgi-runtime + 2.0-SNAPSHOT + test + + + + cglib + cglib + 2.2 + test + + 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 getService(Class 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 @@ - + - + - + - +