summaryrefslogtreecommitdiffstats
path: root/java/sca/vtest/java-api/apis/componentcontext
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-08-26 14:54:18 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-08-26 14:54:18 +0000
commit1558a09905b8dcc0a5ca917364293704fe076c07 (patch)
tree3829da9d17111109c22bafb29a68021a07fb1132 /java/sca/vtest/java-api/apis/componentcontext
parent130f96c02971b259b328283c50b702bb9b5c22fb (diff)
TUSCANY-2501 reference should either be all annotated or all not annotated. Here change the vtests to test these cases separately. Currently mixing annotated and unannotated fields as references causes any unannotated reference to be overlooked. Change the reference not found warning to an error to catch cases where they are mixed by accident. Changes to other tests to take account of this. Also change implementation.widget to pick up the string name of the reference in javascript rather than the name of the variable to which the reference is assigned.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@689102 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/vtest/java-api/apis/componentcontext')
-rw-r--r--java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java3
-rw-r--r--java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java3
-rw-r--r--java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java3
-rw-r--r--java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AUnannotatedComponentImpl.java121
-rw-r--r--java/sca/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite7
-rw-r--r--java/sca/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java3
6 files changed, 140 insertions, 0 deletions
diff --git a/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java b/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java
index 255d91e168..eff7cc5a88 100644
--- a/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java
+++ b/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java
@@ -19,9 +19,12 @@
package org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext;
+import org.osoa.sca.annotations.Remotable;
+
/**
* Simple Service B.
*/
+@Remotable
public interface BService {
String getBName();
diff --git a/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java b/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java
index 597dca0ea5..a221ba11fc 100644
--- a/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java
+++ b/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java
@@ -19,6 +19,9 @@
package org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext;
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
public interface DComponent {
public String getName();
diff --git a/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java b/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java
index 318b6ae0dd..606443a480 100644
--- a/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java
+++ b/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java
@@ -45,6 +45,9 @@ public class AComponentImpl implements AComponent {
@Reference
protected BService bReference;
+
+ @Reference
+ protected DComponent dReference;
@Property(name="aProperty", required=true)
protected String aProperty;
diff --git a/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AUnannotatedComponentImpl.java b/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AUnannotatedComponentImpl.java
new file mode 100644
index 0000000000..34a71e1318
--- /dev/null
+++ b/java/sca/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AUnannotatedComponentImpl.java
@@ -0,0 +1,121 @@
+/*
+ * 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.vtest.javaapi.apis.componentcontext.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.AComponent;
+import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.BService;
+import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.DComponent;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.RequestContext;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(AComponent.class)
+@Scope("COMPOSITE")
+@EagerInit
+public class AUnannotatedComponentImpl implements AComponent {
+
+ public static String rcContent = null;
+
+ protected ComponentContext componentContext;
+
+ protected BService bReference;
+
+ protected DComponent dReference;
+
+ protected String aProperty;
+
+ public String getName() {
+ return "ComponentA";
+ }
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ @Init
+ public void init() {
+ RequestContext rc = componentContext.getRequestContext();
+ if (rc != null) {
+ rcContent = "NotNull";
+ } else {
+ rcContent = "Null";
+ }
+ }
+
+ public String getContextURI() {
+ return componentContext.getURI();
+ }
+
+ public String getServiceBName() {
+ return componentContext.getService(BService.class, "bReference").getBName();
+ }
+
+ public String getServiceReferenceBName() {
+ ServiceReference<BService> bSR = componentContext.getServiceReference(BService.class, "bReference");
+ return bSR.getService().getBName();
+ }
+
+ public String getSelfReferenceName() {
+ ServiceReference<AComponent> aSR = componentContext.createSelfReference(AComponent.class);
+ return aSR.getService().getName();
+ }
+
+ public String getProperty() {
+ return componentContext.getProperty(String.class, "aProperty");
+ }
+
+ public String getRequestContextServiceName() {
+ return componentContext.getRequestContext().getServiceName();
+ }
+
+ public String getCastCallableReferenceServiceName() {
+ BService b = componentContext.getService(BService.class, "bReference");
+ CallableReference<BService> bCR = componentContext.cast(b);
+ return bCR.getService().getBName();
+ }
+
+ public String getCastServiceReferenceServiceName() {
+ BService b = componentContext.getService(BService.class, "bReference");
+ ServiceReference<BService> bSR = componentContext.cast(b);
+ return bSR.getService().getBName();
+ }
+
+ public void illegalCast() {
+ componentContext.cast("");
+ }
+
+ public String testServiceLookup() {
+ return componentContext.getService(DComponent.class, "dReference").getName();
+ }
+
+ public String getRequestContextContent() {
+ return rcContent;
+ }
+
+}
diff --git a/java/sca/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite b/java/sca/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite
index 695922e9ec..19f110d5dc 100644
--- a/java/sca/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite
+++ b/java/sca/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite
@@ -28,6 +28,13 @@
<reference name="dReference" target="DComponent"/>
<property name="aProperty" type="xsd:string">PropertyA</property>
</component>
+
+ <component name="AUnannotatedComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.impl.AUnannotatedComponentImpl"/>
+ <reference name="bReference" target="BComponent/BService"/>
+ <reference name="dReference" target="DComponent"/>
+ <property name="aProperty" type="xsd:string">PropertyA</property>
+ </component>
<component name="BComponent">
<implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.impl.BComponentImpl"/>
diff --git a/java/sca/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java b/java/sca/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java
index 5f39638e5c..9bfe0c06e7 100644
--- a/java/sca/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java
+++ b/java/sca/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java
@@ -35,6 +35,7 @@ public class ComponentContextTestCase {
protected static String compositeName = "ab.composite";
protected static AComponent a;
+ protected static AComponent aUnannotated;
protected static BService b;
@BeforeClass
@@ -43,6 +44,7 @@ public class ComponentContextTestCase {
System.out.println("Setting up");
ServiceFinder.init(compositeName);
a = ServiceFinder.getService(AComponent.class, "AComponent");
+ aUnannotated = ServiceFinder.getService(AComponent.class, "AUnannotatedComponent");
b = ServiceFinder.getService(BService.class, "BComponent/BService");
} catch (Exception e) {
e.printStackTrace();
@@ -65,6 +67,7 @@ public class ComponentContextTestCase {
@Test
public void testGetURI() throws Exception {
Assert.assertEquals("AComponent", a.getContextURI());
+ Assert.assertEquals("AUnannotatedComponent", aUnannotated.getContextURI());
}
/**