You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2007/02/14 03:07:39 UTC

svn commit: r507356 - in /incubator/tuscany/java/sca/integration-test/specTest/src: main/java/org/apache/tuscany/sca/test/spec/ main/resources/META-INF/sca/ test/java/org/apache/tuscany/sca/test/spec/

Author: jboynes
Date: Tue Feb 13 18:07:38 2007
New Revision: 507356

URL: http://svn.apache.org/viewvc?view=rev&rev=507356
Log:
add integration test for ComponentContext#getService

Added:
    incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.java   (with props)
    incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.java   (with props)
Modified:
    incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTester.java
    incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTesterImpl.java
    incubator/tuscany/java/sca/integration-test/specTest/src/main/resources/META-INF/sca/default.scdl
    incubator/tuscany/java/sca/integration-test/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestComponent.java

Modified: incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTester.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTester.java?view=diff&rev=507356&r1=507355&r2=507356
==============================================================================
--- incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTester.java (original)
+++ incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTester.java Tue Feb 13 18:07:38 2007
@@ -21,8 +21,17 @@
 /**
  * @version $Rev$ $Date$
  */
-public interface ComponentContextTester {
+public interface ComponentContextTester extends IdentityService {
+    /**
+     * Returns true if the ComponentContext was injected
+     * @return true if the ComponentContext was injected
+     */
     boolean isContextInjected();
 
-    String getURI();
+    /**
+     * Looks up a reference with the supplied name and returns the identity of the referenced component.
+     * @param name the name of a reference
+     * @return the identity of the referenced component
+     */
+    String getServiceIdentity(String name);
 }

Modified: incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTesterImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTesterImpl.java?view=diff&rev=507356&r1=507355&r2=507356
==============================================================================
--- incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTesterImpl.java (original)
+++ incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTesterImpl.java Tue Feb 13 18:07:38 2007
@@ -20,6 +20,7 @@
 
 import org.osoa.sca.ComponentContext;
 import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Reference;
 
 /**
  * Component that tests ComponentContext functions.
@@ -30,11 +31,19 @@
     @Context
     public ComponentContext context;
 
+    @Reference
+    public IdentityService getServiceTest;
+
     public boolean isContextInjected() {
         return context != null;
     }
 
     public String getURI() {
         return context.getURI();
+    }
+
+    public String getServiceIdentity(String name) {
+        IdentityService service = context.getService(IdentityService.class, name);
+        return service.getURI();
     }
 }

Added: incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.java?view=auto&rev=507356
==============================================================================
--- incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.java (added)
+++ incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.java Tue Feb 13 18:07:38 2007
@@ -0,0 +1,34 @@
+/*
+ * 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.test.spec;
+
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.ComponentContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class IdentifiableComponent implements IdentityService {
+    @Context
+    public ComponentContext context;
+
+    public String getURI() {
+        return context.getURI();
+    }    
+}

Propchange: incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.java?view=auto&rev=507356
==============================================================================
--- incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.java (added)
+++ incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.java Tue Feb 13 18:07:38 2007
@@ -0,0 +1,26 @@
+/*
+ * 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.test.spec;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface IdentityService {
+    String getURI();
+}

Propchange: incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/integration-test/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/integration-test/specTest/src/main/resources/META-INF/sca/default.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/integration-test/specTest/src/main/resources/META-INF/sca/default.scdl?view=diff&rev=507356&r1=507355&r2=507356
==============================================================================
--- incubator/tuscany/java/sca/integration-test/specTest/src/main/resources/META-INF/sca/default.scdl (original)
+++ incubator/tuscany/java/sca/integration-test/specTest/src/main/resources/META-INF/sca/default.scdl Tue Feb 13 18:07:38 2007
@@ -22,6 +22,11 @@
 
     <component name="ComponentContextTester">
         <implementation.java class="org.apache.tuscany.sca.test.spec.ComponentContextTesterImpl"/>
+        <reference name="getServiceTest">ReferencedService</reference>
+    </component>
+
+    <component name="ReferencedService">
+        <implementation.java class="org.apache.tuscany.sca.test.spec.IdentifiableComponent"/>
     </component>
 
     <!--

Modified: incubator/tuscany/java/sca/integration-test/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/integration-test/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestComponent.java?view=diff&rev=507356&r1=507355&r2=507356
==============================================================================
--- incubator/tuscany/java/sca/integration-test/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestComponent.java (original)
+++ incubator/tuscany/java/sca/integration-test/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestComponent.java Tue Feb 13 18:07:38 2007
@@ -35,4 +35,8 @@
     public void testComponentURI() {
         assertEquals("itest://localhost/testDomain/ComponentContextTester", tester.getURI());
     }
+
+    public void testGetService() {
+        assertEquals("itest://localhost/testDomain/ReferencedService", tester.getServiceIdentity("getServiceTest"));
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org