Author: rfeng
Date: Mon May  4 23:06:50 2009
New Revision: 771488

URL: http://svn.apache.org/viewvc?rev=771488&view=rev
Log:
Change the test case to use an external SCA bundle to control the RFC119

Added:
    
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/
    
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/
    
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF
    
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml
    
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/
    
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/
    
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite
Modified:
    
tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java
    
tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
    
tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java

Modified: 
tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java?rev=771488&r1=771487&r2=771488&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java
 (original)
+++ 
tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java
 Mon May  4 23:06:50 2009
@@ -71,6 +71,7 @@
             return true;
         }
 
+        /*
         // OSGi Declarative Services
         if (headers.get("Service-Component") != null) {
             return true;
@@ -85,6 +86,7 @@
         if (entries != null && entries.hasMoreElements()) {
             return true;
         }
+        */
         return false;
     }
 

Modified: 
tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java?rev=771488&r1=771487&r2=771488&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
 (original)
+++ 
tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
 Mon May  4 23:06:50 2009
@@ -21,6 +21,7 @@
 
 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.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 @@
     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 @@
                 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 @@
                     System.out.println(bundleStatus(b, false));
                 }
             }
+            
+            if (scaBundle != null) {
+                scaBundle.start();
+            }
 
             if (calculatorBundle != null) {
                 calculatorBundle.start();

Modified: 
tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java?rev=771488&r1=771487&r2=771488&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java
 (original)
+++ 
tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java
 Mon May  4 23:06:50 2009
@@ -227,11 +227,14 @@
                                              
"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 @@
                             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 @@
                                              
"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,

Added: 
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF?rev=771488&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF
 (added)
+++ 
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF
 Mon May  4 23:06:50 2009
@@ -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

Added: 
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml?rev=771488&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml
 (added)
+++ 
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml
 Mon May  4 23:06:50 2009
@@ -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>

Added: 
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite?rev=771488&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite
 (added)
+++ 
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite
 Mon May  4 23:06:50 2009
@@ -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>


Reply via email to