summaryrefslogtreecommitdiffstats
path: root/sandbox/ant/sca/branches/tb3/vtest/java-api/apis
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/ant/sca/branches/tb3/vtest/java-api/apis')
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/pom.xml45
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/AComponent.java38
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BCallback.java26
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BComponent.java38
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/AComponentImpl.java104
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/BComponentImpl.java70
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/resources/callablereference.composite34
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/CallableReferenceTestCase.java118
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/pom.xml45
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/AComponent.java42
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BComponent.java29
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java34
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/CService.java29
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java29
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java124
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AUnannotatedComponentImpl.java121
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/BComponentImpl.java52
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/DComponentImpl.java32
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite47
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java191
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/pom.xml45
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/AComponent.java34
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/BComponent.java39
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/AComponentImpl.java73
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/BComponentImpl.java78
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/resources/conversation.composite34
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/ConversationTestCase.java70
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/pom.xml45
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/AComponent.java40
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BCallback.java26
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BComponent.java35
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/CComponent.java34
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DComponent.java33
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DException.java30
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/AComponentImpl.java128
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/BComponentImpl.java64
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/CComponentImpl.java50
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/DComponentImpl.java37
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/resources/exception.composite44
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/ExceptionTestCase.java132
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/pom.xml64
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/pom.xml45
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/AComponent.java35
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BCallback.java27
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java35
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/AComponentImpl.java102
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/BComponentImpl.java61
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/resources/requestcontext.composite34
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/RequestContextTestCase.java109
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/pom.xml45
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/AComponent.java37
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BCallback.java26
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BComponent.java38
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/CComponent.java27
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/AComponentImpl.java119
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/BComponentImpl.java74
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/CComponentImpl.java38
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/TestObject.java37
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/resources/servicereference.composite39
-rw-r--r--sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/ServiceReferenceTestCase.java106
60 files changed, 3417 insertions, 0 deletions
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/pom.xml b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/pom.xml
new file mode 100644
index 0000000000..fff1689569
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/pom.xml
@@ -0,0 +1,45 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>java-api-apis</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>vtest-java-api-apis-callablereference</artifactId>
+ <name>Apache Tuscany SCA Java APIs and Annotations Verification Tests - APIs - CallableReference</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/AComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/AComponent.java
new file mode 100644
index 0000000000..a7040f944e
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/AComponent.java
@@ -0,0 +1,38 @@
+/*
+ * 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.callablereference;
+
+import org.oasisopen.sca.annotation.Conversational;
+
+/**
+ * Simple Service A.
+ */
+@Conversational
+public interface AComponent {
+
+ public String getName();
+
+ public String getServiceName();
+ public String getBusinessInterfaceName();
+ public boolean isConversational();
+ public void testConversationID();
+ public String getCallbackResult();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BCallback.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BCallback.java
new file mode 100644
index 0000000000..707568e507
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BCallback.java
@@ -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.vtest.javaapi.apis.callablereference;
+
+public interface BCallback {
+
+ public void processResults(String result);
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BComponent.java
new file mode 100644
index 0000000000..18fcaee6ee
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BComponent.java
@@ -0,0 +1,38 @@
+/*
+ * 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.callablereference;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Conversational;
+
+/**
+ * Simple Service B.
+ */
+@Conversational
+@Callback(BCallback.class)
+public interface BComponent {
+
+ public String getName();
+
+ public void testCallback();
+ public void testConversationID();
+ public void testNonNullConversation();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/AComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/AComponentImpl.java
new file mode 100644
index 0000000000..70a257d19f
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/AComponentImpl.java
@@ -0,0 +1,104 @@
+/*
+ * 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.callablereference.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.callablereference.AComponent;
+import org.apache.tuscany.sca.vtest.javaapi.apis.callablereference.BCallback;
+import org.apache.tuscany.sca.vtest.javaapi.apis.callablereference.BComponent;
+import org.junit.Assert;
+import org.oasisopen.sca.CallableReference;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.ConversationID;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(AComponent.class)
+@Scope("CONVERSATION")
+public class AComponentImpl implements AComponent, BCallback {
+
+ private static Object monitor = new Object();
+ private static String returnMessage = null;
+
+ protected ComponentContext componentContext;
+
+ @Reference
+ protected CallableReference<BComponent> bReference;
+
+ @ConversationID
+ protected String cid;
+
+ public String getName() {
+ return "ComponentA";
+ }
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ public String getServiceName() {
+ return bReference.getService().getName();
+ }
+
+ public String getBusinessInterfaceName() {
+ return bReference.getBusinessInterface().getSimpleName();
+ }
+
+ public boolean isConversational() {
+ return bReference.isConversational();
+ }
+
+ public void testConversationID() {
+ ServiceReference<BComponent> bSR = componentContext.getServiceReference(BComponent.class, "bReference");
+ bSR.setConversationID("AConversationID");
+ bSR.getService().testConversationID();
+
+ Assert.assertEquals("AConversationID", bSR.getConversation().getConversationID());
+ }
+
+ public String getCallbackResult() {
+ ServiceReference<BComponent> bSR = componentContext.getServiceReference(BComponent.class, "bReference");
+ String cbID = "ComponentACallBack";
+ bSR.setCallbackID(cbID);
+ bSR.getService().testCallback();
+
+ // Wait for 30s max.
+ int count = 0;
+ synchronized(monitor) {
+ while (returnMessage == null && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return returnMessage;
+ }
+
+ public void processResults(String result) {
+ returnMessage = result;
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/BComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/BComponentImpl.java
new file mode 100644
index 0000000000..ea4c71d27a
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/BComponentImpl.java
@@ -0,0 +1,70 @@
+/*
+ * 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.callablereference.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.callablereference.BCallback;
+import org.apache.tuscany.sca.vtest.javaapi.apis.callablereference.BComponent;
+import org.junit.Assert;
+import org.oasisopen.sca.CallableReference;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.ConversationID;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(BComponent.class)
+@Scope("CONVERSATION")
+public class BComponentImpl implements BComponent {
+
+ protected ComponentContext componentContext;
+
+ @Callback
+ protected BCallback callback;
+
+ @ConversationID
+ protected String cid;
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ public String getName() {
+ return "ComponentB";
+ }
+
+ public void testCallback() {
+ callback = componentContext.getRequestContext().getCallback();
+ callback.processResults("CallBackFromB");
+
+ CallableReference<BCallback> bCR = componentContext.getRequestContext().getCallbackReference();
+ Assert.assertEquals("ComponentACallBack", bCR.getCallbackID());
+ }
+
+ public void testConversationID() {
+ Assert.assertEquals("AConversationID", cid);
+ }
+
+ public void testNonNullConversation() {
+ Assert.assertNotNull(componentContext.getRequestContext().getServiceReference().getConversation());
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/resources/callablereference.composite b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/resources/callablereference.composite
new file mode 100644
index 0000000000..f997d78bb5
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/resources/callablereference.composite
@@ -0,0 +1,34 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://java-api-tests"
+ name="CallableReference-Composite">
+
+ <component name="AComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.callablereference.impl.AComponentImpl"/>
+ <reference name="bReference" target="BComponent"/>
+ </component>
+
+ <component name="BComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.callablereference.impl.BComponentImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/CallableReferenceTestCase.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/CallableReferenceTestCase.java
new file mode 100644
index 0000000000..4d0d8338ba
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/CallableReferenceTestCase.java
@@ -0,0 +1,118 @@
+/*
+ * 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.callablereference;
+
+import org.apache.tuscany.sca.vtest.utilities.ServiceFinder;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * This test class tests the CallableReference interface described in 1.7.3 of
+ * the SCA Java Annotations & APIs Specification 1.0.
+ */
+public class CallableReferenceTestCase {
+
+ protected static String compositeName = "callablereference.composite";
+ protected static AComponent a;
+ protected static BComponent b;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ System.out.println("Setting up");
+ ServiceFinder.init(compositeName);
+ a = ServiceFinder.getService(AComponent.class, "AComponent");
+ b = ServiceFinder.getService(BComponent.class, "BComponent");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ System.out.println("Cleaning up");
+ ServiceFinder.cleanup();
+ }
+
+ /**
+ * Lines 884 <br>
+ * getService() - Returns a type-safe reference to the target of this
+ * reference. The instance returned is guaranteed to implement the business
+ * interface for this reference. The value returned is a proxy to the target
+ * that implements the business interface associated with this reference.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetService() throws Exception {
+ Assert.assertEquals("ComponentB", a.getServiceName());
+ }
+
+ /**
+ * Lines 885 <br>
+ * getBusinessInterface() – Returns the Java class for the business
+ * interface associated with this reference.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetBusinessInterface() throws Exception {
+ Assert.assertEquals("BComponent", a.getBusinessInterfaceName());
+ }
+
+ /**
+ * Lines 886 <br>
+ * isConversational() – Returns true if this reference is conversational.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testIsConversational() throws Exception {
+ Assert.assertEquals(true, a.isConversational());
+ }
+
+ /**
+ * Lines 887 <br>
+ * getConversation() – Returns the conversation associated with this
+ * reference. Returns null if no conversation is currently active.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetConversation() throws Exception {
+ a.testConversationID();
+ b.testNonNullConversation();
+ }
+
+ /**
+ * Lines 888 <br>
+ * getCallbackID() – Returns the callback ID.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetCallbackID() throws Exception {
+ // Actual test is in BComponentImpl. Below is an extra test.
+ Assert.assertEquals("CallBackFromB", a.getCallbackResult());
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/pom.xml b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/pom.xml
new file mode 100644
index 0000000000..0a2d12a41e
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/pom.xml
@@ -0,0 +1,45 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>java-api-apis</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>vtest-java-api-apis-componentcontext</artifactId>
+ <name>Apache Tuscany SCA Java APIs and Annotations Verification Tests - APIs - ComponentContext</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/AComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/AComponent.java
new file mode 100644
index 0000000000..b2c8c07866
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/AComponent.java
@@ -0,0 +1,42 @@
+/*
+ * 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;
+
+/**
+ * Simple Service A.
+ */
+public interface AComponent {
+
+ public String getName();
+
+ public String getContextURI();
+ public String getServiceBName();
+ public String getServiceReferenceBName();
+ public String getSelfReferenceName();
+ public String getProperty();
+ public String getRequestContextServiceName();
+ public String getCastCallableReferenceServiceName();
+ public String getCastServiceReferenceServiceName();
+ public void illegalCast();
+
+ public String testServiceLookup();
+ public String getRequestContextContent();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BComponent.java
new file mode 100644
index 0000000000..7e425c740f
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BComponent.java
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+/**
+ * Simple Service B.
+ */
+public interface BComponent {
+
+ String getName();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java
new file mode 100644
index 0000000000..d7799bb3aa
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java
@@ -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.vtest.javaapi.apis.componentcontext;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Simple Service B.
+ */
+@Remotable
+public interface BService {
+
+ String getBName();
+
+ String getSelfReferenceWithServiceName();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/CService.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/CService.java
new file mode 100644
index 0000000000..d0da012f6f
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/CService.java
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+/**
+ * Simple Service C.
+ */
+public interface CService {
+
+ String getCName();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java
new file mode 100644
index 0000000000..079d859f74
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface DComponent {
+
+ public String getName();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java
new file mode 100644
index 0000000000..06a71c29ac
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java
@@ -0,0 +1,124 @@
+/*
+ * 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.oasisopen.sca.CallableReference;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(AComponent.class)
+@Scope("COMPOSITE")
+@EagerInit
+public class AComponentImpl implements AComponent {
+
+ public static String rcContent = null;
+
+ protected ComponentContext componentContext;
+
+ @Reference
+ protected BService bReference;
+
+ @Reference
+ protected DComponent dReference;
+
+ @Property(name="aProperty", required=true)
+ 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/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AUnannotatedComponentImpl.java b/sandbox/ant/sca/branches/tb3/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..e508687965
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/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.oasisopen.sca.CallableReference;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.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/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/BComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/BComponentImpl.java
new file mode 100644
index 0000000000..157864fd27
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/BComponentImpl.java
@@ -0,0 +1,52 @@
+/*
+ * 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.BService;
+import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.CService;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(interfaces={BService.class, CService.class})
+public class BComponentImpl implements BService, CService {
+
+ protected ComponentContext componentContext;
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ public String getBName() {
+ return "ServiceB";
+ }
+
+ public String getCName() {
+ return "ServiceC";
+ }
+
+ public String getSelfReferenceWithServiceName() {
+ ServiceReference<CService> cSR = componentContext.createSelfReference(CService.class, "CService");
+ return cSR.getService().getCName();
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/DComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/DComponentImpl.java
new file mode 100644
index 0000000000..9432c70ff3
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/DComponentImpl.java
@@ -0,0 +1,32 @@
+/*
+ * 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.DComponent;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(DComponent.class)
+public class DComponentImpl implements DComponent {
+
+ public String getName() {
+ return "ComponentD";
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite
new file mode 100644
index 0000000000..19f110d5dc
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite
@@ -0,0 +1,47 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://java-api-tests"
+ name="AB-Composite">
+
+ <component name="AComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.impl.AComponentImpl"/>
+ <reference name="bReference" target="BComponent/BService"/>
+ <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"/>
+ </component>
+
+ <component name="DComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.impl.DComponentImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java
new file mode 100644
index 0000000000..e9352a5c06
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java
@@ -0,0 +1,191 @@
+/*
+ * 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;
+
+import org.apache.tuscany.sca.vtest.utilities.ServiceFinder;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * This test class tests the ComponentContext interface described in 1.7.1 of
+ * the SCA Java Annotations & APIs Specification 1.0. Relevant sections of 1.4
+ * will also be covered here.
+ */
+public class ComponentContextTestCase {
+
+ protected static String compositeName = "ab.composite";
+ protected static AComponent a;
+ protected static AComponent aUnannotated;
+ protected static BService b;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ 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();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ System.out.println("Cleaning up");
+ ServiceFinder.cleanup();
+ }
+
+ /**
+ * Lines 776 <br>
+ * getURI() - Returns the absolute URI of the component within the SCA
+ * domain.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetURI() throws Exception {
+ Assert.assertEquals("AComponent", a.getContextURI());
+ Assert.assertEquals("AUnannotatedComponent", aUnannotated.getContextURI());
+ }
+
+ /**
+ * Lines 778 <br>
+ * getService(Class&lt;B&gt; businessInterface, String referenceName) ?
+ * Returns a proxy for the reference defined by the current component.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetService() throws Exception {
+ Assert.assertEquals(a.getServiceBName(), "ServiceB");
+ }
+
+ /**
+ * Lines 780 <br>
+ * getServiceReference(Class&lt;B&gt; businessInterface, String
+ * referenceName) ? Returns a ServiceReference defined by the current
+ * component.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetServiceReference() throws Exception {
+ Assert.assertEquals(a.getServiceReferenceBName(), "ServiceB");
+ }
+
+ /**
+ * Lines 783 <br>
+ * createSelfReference(Class&lt;B&gt; businessInterface) ? Returns a
+ * ServiceReference that can be used to invoke this component over the
+ * designated service.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testCreateSelfReference() throws Exception {
+ Assert.assertEquals(a.getSelfReferenceName(), "ComponentA");
+ }
+
+ /**
+ * Lines 785 <br>
+ * getSelfReference(Class&lt;B&gt; businessInterface, String serviceName) -
+ * Returns a ServiceReference that can be used to invoke this component over
+ * the designated service. Service name explicitly declares the service name
+ * to invoke.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testCreateSelfReferenceWithServiceName() throws Exception {
+ Assert.assertEquals("ServiceC", b.getSelfReferenceWithServiceName());
+ }
+
+ /**
+ * Lines 788 <br>
+ * getProperty (Class&lt;B&gt; type, String propertyName) - Returns the
+ * value of an SCA property defined by this component.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetProperty() throws Exception {
+ Assert.assertEquals("PropertyA", a.getProperty());
+ }
+
+ /**
+ * Lines 793 <br>
+ * getRequestContext() - Returns the context for the current SCA service
+ * request, or null if there is no current request or if the context is
+ * unavailable.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetRequestContext() throws Exception {
+ Assert.assertEquals("AComponent", a.getRequestContextServiceName());
+ Assert.assertEquals("NotNull", a.getRequestContextContent());
+ }
+
+ /**
+ * Lines 790,794 <br>
+ * cast(B target) - Casts a type-safe reference to a CallableReference.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testCast() throws Exception {
+ Assert.assertEquals("ServiceB", a.getCastCallableReferenceServiceName());
+ Assert.assertEquals("ServiceB", a.getCastServiceReferenceServiceName());
+
+ String check = "";
+ try {
+ a.illegalCast();
+ } catch (IllegalArgumentException iae) {
+ check = "IllegalCast";
+ } catch (ServiceRuntimeException sre) {
+ if (sre.getCause() instanceof IllegalArgumentException) {
+ check = "IllegalCast";
+ }
+ }
+ Assert.assertEquals("IllegalCast", check);
+ }
+
+ /**
+ * Lines 342-344 <br>
+ * When a component implementation needs access to a service where the
+ * reference to the service is not known at compile time, the reference can
+ * be located using the component?s ComponentContext.
+ *
+ * @throws Exception
+ */
+ @Test
+ @Ignore("TUSCANY-2609")
+ public void testServiceLookup() throws Exception {
+ Assert.assertEquals("ComponentD", a.testServiceLookup());
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/pom.xml b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/pom.xml
new file mode 100644
index 0000000000..e026dcc800
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/pom.xml
@@ -0,0 +1,45 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>java-api-apis</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>vtest-java-api-apis-conversation</artifactId>
+ <name>Apache Tuscany SCA Java APIs and Annotations Verification Tests - APIs - Conversation</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/AComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/AComponent.java
new file mode 100644
index 0000000000..845c10303e
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/AComponent.java
@@ -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.vtest.javaapi.apis.conversation;
+
+import org.oasisopen.sca.annotation.Conversational;
+
+/**
+ * Simple Service A.
+ */
+@Conversational
+public interface AComponent {
+
+ public String getName();
+
+ public void testConversation();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/BComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/BComponent.java
new file mode 100644
index 0000000000..a3148aa0d7
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/BComponent.java
@@ -0,0 +1,39 @@
+/*
+ * 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.conversation;
+
+import org.oasisopen.sca.annotation.Conversational;
+import org.oasisopen.sca.annotation.EndsConversation;
+
+/**
+ * Simple Service B.
+ */
+@Conversational
+public interface BComponent {
+
+ public String getName();
+
+ public void testCustomConversationID();
+ public void testGeneratedConversationID(Object id);
+
+ @EndsConversation
+ public void endsConversation();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/AComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/AComponentImpl.java
new file mode 100644
index 0000000000..7160121388
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/AComponentImpl.java
@@ -0,0 +1,73 @@
+/*
+ * 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.conversation.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.conversation.AComponent;
+import org.apache.tuscany.sca.vtest.javaapi.apis.conversation.BComponent;
+import org.junit.Assert;
+import org.oasisopen.sca.CallableReference;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.Conversation;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.ConversationID;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(AComponent.class)
+@Scope("CONVERSATION")
+public class AComponentImpl implements AComponent {
+
+ protected ComponentContext componentContext;
+
+ @Reference
+ protected CallableReference<BComponent> bReference;
+
+ @ConversationID
+ protected String cid;
+
+ public String getName() {
+ return "ComponentA";
+ }
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ public void testConversation() {
+ ServiceReference<BComponent> bSR = componentContext.getServiceReference(BComponent.class, "bReference");
+ bSR.setConversationID("AConversationID");
+ bSR.getService().testCustomConversationID();
+
+ Conversation bc = bSR.getConversation();
+ Assert.assertEquals("AConversationID", bc.getConversationID());
+ bc.end();
+
+ Assert.assertEquals("ComponentB", bReference.getService().getName());
+ bReference.getService().testGeneratedConversationID(bReference.getConversation().getConversationID());
+ bReference.getConversation().end();
+
+ Assert.assertEquals(1, BComponentImpl.customInitCount);
+ Assert.assertEquals(1, BComponentImpl.customDestroyCount);
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/BComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/BComponentImpl.java
new file mode 100644
index 0000000000..c487559ca1
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/BComponentImpl.java
@@ -0,0 +1,78 @@
+/*
+ * 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.conversation.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.conversation.BComponent;
+import org.junit.Assert;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.ConversationID;
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(BComponent.class)
+@Scope("CONVERSATION")
+public class BComponentImpl implements BComponent {
+
+ public static int customInitCount = 0;
+ public static int customDestroyCount = 0;
+
+ protected ComponentContext componentContext;
+
+ @ConversationID
+ protected String cid;
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ public String getName() {
+ return "ComponentB";
+ }
+
+ public void testCustomConversationID() {
+ Assert.assertEquals("AConversationID", cid);
+ }
+
+ public void testGeneratedConversationID(Object id) {
+ Assert.assertEquals(id.toString(), cid);
+ }
+
+ public void endsConversation() {
+ }
+
+ @Init
+ public void initB() {
+ if (cid.equals("AConversationID")) {
+ customInitCount++;
+ }
+ }
+
+ @Destroy
+ public void destroyB() {
+ if (cid.equals("AConversationID")) {
+ customDestroyCount++;
+ }
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/resources/conversation.composite b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/resources/conversation.composite
new file mode 100644
index 0000000000..87cab2f479
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/resources/conversation.composite
@@ -0,0 +1,34 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://java-api-tests"
+ name="Conversation-Composite">
+
+ <component name="AComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.conversation.impl.AComponentImpl"/>
+ <reference name="bReference" target="BComponent"/>
+ </component>
+
+ <component name="BComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.conversation.impl.BComponentImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/ConversationTestCase.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/ConversationTestCase.java
new file mode 100644
index 0000000000..9b46ac5e08
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/ConversationTestCase.java
@@ -0,0 +1,70 @@
+/*
+ * 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.conversation;
+
+import org.apache.tuscany.sca.vtest.utilities.ServiceFinder;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * This test class tests the Conversation interface described in 1.7.5 of the
+ * SCA Java Annotations & APIs Specification 1.0.
+ */
+public class ConversationTestCase {
+
+ protected static String compositeName = "conversation.composite";
+ protected static AComponent a;
+ protected static BComponent b;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ System.out.println("Setting up");
+ ServiceFinder.init(compositeName);
+ a = ServiceFinder.getService(AComponent.class, "AComponent");
+ b = ServiceFinder.getService(BComponent.class, "BComponent");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ System.out.println("Cleaning up");
+ ServiceFinder.cleanup();
+ }
+
+ /**
+ * Lines 941, 942 <br>
+ * getConversationID() – Returns the identifier for this conversation. If a
+ * user-defined identity had been supplied for this reference then its value
+ * will be returned; otherwise the identity generated by the system when the
+ * conversation was initiated will be returned. <br>
+ * end() – Ends this conversation.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testConversation() throws Exception {
+ a.testConversation();
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/pom.xml b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/pom.xml
new file mode 100644
index 0000000000..ef6e5182ee
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/pom.xml
@@ -0,0 +1,45 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>java-api-apis</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>vtest-java-api-apis-exception</artifactId>
+ <name>Apache Tuscany SCA Java APIs and Annotations Verification Tests - APIs - Exception</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/AComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/AComponent.java
new file mode 100644
index 0000000000..90582e88a2
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/AComponent.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.vtest.javaapi.apis.exception;
+
+import org.oasisopen.sca.annotation.Conversational;
+
+/**
+ * Simple Service A.
+ */
+@Conversational
+public interface AComponent {
+
+ public String getName();
+
+ public void testConversation();
+ public void testCallBack();
+
+ public boolean testServiceRuntimeException();
+ public boolean testServiceUnavailableException();
+
+ public boolean testCheckedException();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BCallback.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BCallback.java
new file mode 100644
index 0000000000..c1c1c6544c
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BCallback.java
@@ -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.vtest.javaapi.apis.exception;
+
+public interface BCallback {
+
+ public void processResults(String result);
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BComponent.java
new file mode 100644
index 0000000000..11886277ad
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BComponent.java
@@ -0,0 +1,35 @@
+/*
+ * 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.exception;
+
+import org.oasisopen.sca.annotation.Callback;
+
+/**
+ * Simple Service B.
+ */
+@Callback(BCallback.class)
+public interface BComponent {
+
+ public String getName();
+
+ public void testCallback();
+ public void testRedirectedCallback();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/CComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/CComponent.java
new file mode 100644
index 0000000000..466a32731a
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/CComponent.java
@@ -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.vtest.javaapi.apis.exception;
+
+import org.oasisopen.sca.annotation.Conversational;
+
+/**
+ * Simple Service C.
+ */
+@Conversational
+public interface CComponent {
+
+ public String getName();
+
+ public void testConversation();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DComponent.java
new file mode 100644
index 0000000000..c0aed7a707
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DComponent.java
@@ -0,0 +1,33 @@
+/*
+ * 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.exception;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Simple Remote Service D.
+ */
+@Remotable
+public interface DComponent {
+
+ public String getName();
+ public void testException() throws DException;
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DException.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DException.java
new file mode 100644
index 0000000000..82873ed96d
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DException.java
@@ -0,0 +1,30 @@
+/*
+ * 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.exception;
+
+public class DException extends Exception {
+
+ private static final long serialVersionUID = -3819913841563109423L;
+
+ public DException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/AComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/AComponentImpl.java
new file mode 100644
index 0000000000..1190e6900f
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/AComponentImpl.java
@@ -0,0 +1,128 @@
+/*
+ * 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.exception.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.exception.AComponent;
+import org.apache.tuscany.sca.vtest.javaapi.apis.exception.BComponent;
+import org.apache.tuscany.sca.vtest.javaapi.apis.exception.CComponent;
+import org.apache.tuscany.sca.vtest.javaapi.apis.exception.DComponent;
+import org.apache.tuscany.sca.vtest.javaapi.apis.exception.DException;
+import org.junit.Assert;
+import org.oasisopen.sca.CallableReference;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.ConversationEndedException;
+import org.oasisopen.sca.NoRegisteredCallbackException;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.ConversationID;
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(AComponent.class)
+@Scope("CONVERSATION")
+public class AComponentImpl implements AComponent {
+
+ protected ComponentContext componentContext;
+
+ @Reference
+ protected CallableReference<BComponent> bReference;
+
+ @Reference
+ protected ServiceReference<CComponent> cReference;
+
+ @Reference
+ protected ServiceReference<DComponent> dReference;
+
+ @ConversationID
+ protected String cid;
+
+ public String getName() {
+ return "ComponentA";
+ }
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ public void testConversation() {
+ ServiceReference<CComponent> cSR = componentContext.getServiceReference(CComponent.class, "cReference");
+ cSR.setConversationID("AConversationID");
+ Assert.assertEquals("ComponentC", cSR.getService().getName());
+
+ try {
+ Thread.sleep(1100);
+ cSR.getService().testConversation();
+
+ Assert.fail();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ } catch (ConversationEndedException cee) {
+ // Expected
+ }
+ }
+
+ public void testCallBack() {
+ ServiceReference<BComponent> bSR = componentContext.getServiceReference(BComponent.class, "bReference");
+ bSR.setCallbackID("ComponentACallBack");
+
+ try {
+ bSR.getService().testCallback();
+ Assert.fail();
+ } catch (NoRegisteredCallbackException e) {
+ // Expected
+ }
+ }
+
+ public boolean testServiceRuntimeException() {
+ try {
+ componentContext.getServiceReference(BComponent.class, "dummyBReference").getService().getName();
+ } catch (ServiceRuntimeException sre) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean testServiceUnavailableException() {
+ return false;
+ }
+
+ public boolean testCheckedException() {
+ try {
+ dReference.getService().testException();
+ } catch (DException e) {
+ if (e.getMessage().equals("ADException")) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Destroy
+ public void destroy() {
+ System.out.println("This is a Destroy of AComponent ..");
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/BComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/BComponentImpl.java
new file mode 100644
index 0000000000..eca4b54109
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/BComponentImpl.java
@@ -0,0 +1,64 @@
+/*
+ * 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.exception.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.exception.BCallback;
+import org.apache.tuscany.sca.vtest.javaapi.apis.exception.BComponent;
+import org.junit.Assert;
+import org.oasisopen.sca.CallableReference;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(BComponent.class)
+public class BComponentImpl implements BComponent {
+
+ protected ComponentContext componentContext;
+
+ @Callback
+ protected BCallback callback;
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ public String getName() {
+ return "ComponentB";
+ }
+
+ public void testCallback() {
+ callback = componentContext.getRequestContext().getCallback();
+ callback.processResults("CallBackFromB");
+
+ CallableReference<BCallback> bCR = componentContext.getRequestContext().getCallbackReference();
+ Assert.assertEquals("ComponentACallBack", bCR.getCallbackID());
+ }
+
+ public void testRedirectedCallback() {
+ callback = componentContext.getRequestContext().getCallback();
+ callback.processResults("RedirectedCallBackFromB");
+
+ CallableReference<BCallback> bCR = componentContext.getRequestContext().getCallbackReference();
+ Assert.assertEquals("RedirectedCallBack", bCR.getCallbackID());
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/CComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/CComponentImpl.java
new file mode 100644
index 0000000000..57a34716e6
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/CComponentImpl.java
@@ -0,0 +1,50 @@
+/*
+ * 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.exception.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.exception.CComponent;
+import org.junit.Assert;
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.ConversationAttributes;
+import org.oasisopen.sca.annotation.ConversationID;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CComponent.class)
+@Scope("CONVERSATION")
+@ConversationAttributes(maxIdleTime="1 seconds")
+public class CComponentImpl implements CComponent {
+
+ @Context
+ protected RequestContext requestContext;
+
+ @ConversationID
+ protected String cid;
+
+ public String getName() {
+ return "ComponentC";
+ }
+
+ public void testConversation() {
+ Assert.assertEquals("AConversationID", cid);
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/DComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/DComponentImpl.java
new file mode 100644
index 0000000000..c1f5a56a9a
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/DComponentImpl.java
@@ -0,0 +1,37 @@
+/*
+ * 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.exception.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.exception.DComponent;
+import org.apache.tuscany.sca.vtest.javaapi.apis.exception.DException;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(DComponent.class)
+public class DComponentImpl implements DComponent {
+
+ public String getName() {
+ return "ComponentD";
+ }
+
+ public void testException() throws DException {
+ throw new DException("ADException");
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/resources/exception.composite b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/resources/exception.composite
new file mode 100644
index 0000000000..5bd933ce96
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/resources/exception.composite
@@ -0,0 +1,44 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://java-api-tests"
+ name="Exception-Composite">
+
+ <component name="AComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.exception.impl.AComponentImpl"/>
+ <reference name="bReference" target="BComponent"/>
+ <reference name="cReference" target="CComponent"/>
+ <reference name="dReference" target="DComponent"/>
+ </component>
+
+ <component name="BComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.exception.impl.BComponentImpl"/>
+ </component>
+
+ <component name="CComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.exception.impl.CComponentImpl"/>
+ </component>
+
+ <component name="DComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.exception.impl.DComponentImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/ExceptionTestCase.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/ExceptionTestCase.java
new file mode 100644
index 0000000000..da7b1da0fa
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/ExceptionTestCase.java
@@ -0,0 +1,132 @@
+/*
+ * 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.exception;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * This test class tests the Exceptions described in 1.7.6, 1.7.7, 1.7.8, and 1.7.9 of the SCA Java Annotations & APIs Specification 1.0.
+ * This also covers 1.5 of the specification.
+ */
+public class ExceptionTestCase {
+
+ protected static SCADomain domain;
+ protected static String compositeName = "exception.composite";
+ protected static AComponent a;
+ protected static BComponent b;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ System.out.println("Setting up");
+ domain = SCADomain.newInstance(compositeName);
+ a = domain.getService(AComponent.class, "AComponent");
+ b = domain.getService(BComponent.class, "BComponent");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ System.out.println("Cleaning up");
+ if (domain != null) {
+ domain.close();
+ }
+ }
+
+ /**
+ * Lines 951 <br>
+ * NoRegisteredCallbackException.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testNoRegisteredCallbackException() throws Exception {
+ a.testCallBack();
+ }
+
+ /**
+ * Lines 960 <br>
+ * ServiceRuntimeException - This exception signals problems in the management of SCA component execution.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testServiceRuntimeException() throws Exception {
+ Assert.assertTrue(a.testServiceRuntimeException());
+ }
+
+ /**
+ * Lines 970 <br>
+ * ServiceUnavailableException – This exception signals problems in the interaction with remote services.
+ *
+ * @throws Exception
+ */
+ @Test
+ //@Ignore
+ public void testServiceUnavailableException() throws Exception {
+ domain.getComponentManager().stopComponent("AComponent");
+
+ try {
+ a.getName();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ try {
+ AComponent ac = domain.getService(AComponent.class, "AComponent");
+ ac.getName();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ domain.getComponentManager().startComponent("AComponent");
+ }
+
+ /**
+ * Lines 983 <br>
+ * ConversationEndedException.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testConversationEndedException() throws Exception {
+ a.testConversation();
+ }
+
+ /**
+ * Lines 360-361 <br>
+ * Business exceptions are thrown by the implementation of the called service method,
+ * and are defined as checked exceptions on the interface that types the service.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testCheckedException() throws Exception {
+ Assert.assertTrue(a.testCheckedException());
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/pom.xml b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/pom.xml
new file mode 100644
index 0000000000..164c67ebbb
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/pom.xml
@@ -0,0 +1,64 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>vtest-java-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>java-api-apis</artifactId>
+ <packaging>pom</packaging>
+
+ <name>Apache Tuscany SCA Java APIs and Annotations Verification Tests - APIs</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>componentcontext</module>
+ <module>requestcontext</module>
+ <module>callablereference</module>
+ <module>servicereference</module>
+ <module>conversation</module>
+ <module>exception</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/pom.xml b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/pom.xml
new file mode 100644
index 0000000000..d849fad4fe
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/pom.xml
@@ -0,0 +1,45 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>java-api-apis</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>vtest-java-api-apis-requestcontext</artifactId>
+ <name>Apache Tuscany SCA Java APIs and Annotations Verification Tests - APIs - RequestContext</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/AComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/AComponent.java
new file mode 100644
index 0000000000..6fec5cada3
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/AComponent.java
@@ -0,0 +1,35 @@
+/*
+ * 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.requestcontext;
+
+/**
+ * Simple Service A.
+ */
+public interface AComponent {
+
+ public String getName();
+
+ public boolean isJAASSubject();
+ public String getServiceName();
+ public String getCallbackResult();
+ public String getServiceReferenceName();
+ public String getCallbackServiceReferenceName();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BCallback.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BCallback.java
new file mode 100644
index 0000000000..4dd2088f90
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BCallback.java
@@ -0,0 +1,27 @@
+/*
+ * 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.requestcontext;
+
+public interface BCallback {
+
+ public String getCallbackName();
+ public void processResults(String result);
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java
new file mode 100644
index 0000000000..d913e95a53
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java
@@ -0,0 +1,35 @@
+/*
+ * 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.requestcontext;
+
+import org.oasisopen.sca.annotation.Callback;
+
+/**
+ * Simple Service B.
+ */
+@Callback(BCallback.class)
+public interface BComponent {
+
+ public String getName();
+
+ public void testCallback();
+ public String getServiceReferenceName();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/AComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/AComponentImpl.java
new file mode 100644
index 0000000000..5d3cbf6e3d
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/AComponentImpl.java
@@ -0,0 +1,102 @@
+/*
+ * 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.requestcontext.impl;
+
+import javax.security.auth.Subject;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.AComponent;
+import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.BCallback;
+import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.BComponent;
+import org.oasisopen.sca.CallableReference;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(AComponent.class)
+public class AComponentImpl implements AComponent, BCallback {
+
+ private static Object monitor = new Object();
+ private static String returnMessage = null;
+ private static CallableReference<BCallback> cbCR;
+
+ protected ComponentContext componentContext;
+
+ @Reference
+ protected BComponent bReference;
+
+ public String getName() {
+ return "ComponentA";
+ }
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ public boolean isJAASSubject() {
+ return componentContext.getRequestContext().getSecuritySubject() instanceof Subject;
+ }
+
+ public String getServiceName() {
+ return componentContext.getRequestContext().getServiceName();
+ }
+
+ public String getCallbackResult() {
+ ServiceReference<BComponent> bSR = componentContext.getServiceReference(BComponent.class, "bReference");
+ String cbID = "ComponentACallBack";
+ bSR.setCallbackID(cbID);
+ bSR.getService().testCallback();
+
+ // Wait for 30s max.
+ int count = 0;
+ synchronized(monitor) {
+ while (returnMessage == null && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return returnMessage;
+ }
+
+ public void processResults(String result) {
+ returnMessage = result;
+ cbCR = componentContext.getRequestContext().getServiceReference();
+ }
+
+ public String getServiceReferenceName() {
+ CallableReference<AComponent> aCR = componentContext.getRequestContext().getServiceReference();
+ return aCR.getService().getName();
+ }
+
+ public String getCallbackServiceReferenceName() {
+ return cbCR.getService().getCallbackName();
+ }
+
+ public String getCallbackName() {
+ return "CallBackB";
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/BComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/BComponentImpl.java
new file mode 100644
index 0000000000..d358736daa
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/BComponentImpl.java
@@ -0,0 +1,61 @@
+/*
+ * 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.requestcontext.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.BCallback;
+import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.BComponent;
+import org.junit.Assert;
+import org.oasisopen.sca.CallableReference;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(BComponent.class)
+public class BComponentImpl implements BComponent {
+
+ protected ComponentContext componentContext;
+
+ @Callback
+ protected BCallback callback;
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ public String getName() {
+ return "ComponentB";
+ }
+
+ public void testCallback() {
+ callback = componentContext.getRequestContext().getCallback();
+ callback.processResults("CallBackFromB");
+
+ CallableReference<BCallback> bCR = componentContext.getRequestContext().getCallbackReference();
+ Assert.assertEquals("ComponentACallBack", bCR.getCallbackID());
+ }
+
+ public String getServiceReferenceName() {
+ CallableReference<BComponent> bCR = componentContext.getRequestContext().getServiceReference();
+ return bCR.getService().getName();
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/resources/requestcontext.composite b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/resources/requestcontext.composite
new file mode 100644
index 0000000000..4aa5eeb25a
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/resources/requestcontext.composite
@@ -0,0 +1,34 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://java-api-tests"
+ name="RequestContext-Composite">
+
+ <component name="AComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.impl.AComponentImpl"/>
+ <reference name="bReference" target="BComponent"/>
+ </component>
+
+ <component name="BComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.impl.BComponentImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/RequestContextTestCase.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/RequestContextTestCase.java
new file mode 100644
index 0000000000..e3b761bd37
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/RequestContextTestCase.java
@@ -0,0 +1,109 @@
+/*
+ * 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.requestcontext;
+
+import org.apache.tuscany.sca.vtest.utilities.ServiceFinder;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * This test class tests the RequestContext interface described in 1.7.2 of the
+ * SCA Java Annotations & APIs Specification 1.0.
+ */
+public class RequestContextTestCase {
+
+ protected static String compositeName = "requestcontext.composite";
+ protected static AComponent a;
+ protected static BComponent b;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ System.out.println("Setting up");
+ ServiceFinder.init(compositeName);
+ a = ServiceFinder.getService(AComponent.class, "AComponent");
+ b = ServiceFinder.getService(BComponent.class, "BComponent");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ System.out.println("Cleaning up");
+ ServiceFinder.cleanup();
+ }
+
+ /**
+ * Lines 858 <br>
+ * getSecuritySubject() – Returns the JAAS Subject of the current request.
+ *
+ * @throws Exception
+ */
+ @Ignore("TUSCANY-2608")
+ public void testGetSecuritySubject() throws Exception {
+ Assert.assertTrue(a.isJAASSubject());
+ }
+
+ /**
+ * Lines 860 <br>
+ * getServiceName() – Returns the name of the service on the Java
+ * implementation the request came in on.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetServiceName() throws Exception {
+ Assert.assertEquals("AComponent", a.getServiceName());
+ }
+
+ /**
+ * Lines 861, 862 <br>
+ * getCallbackReference() – Returns a callable reference to the callback as
+ * specified by the caller. getCallback() – Returns a proxy for the callback
+ * as specified by the caller.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetCallback() throws Exception {
+ Assert.assertEquals("CallBackFromB", a.getCallbackResult());
+ }
+
+ /**
+ * Lines 863 <br>
+ * getServiceReference() – When invoked during the execution of a service
+ * operation, this API MUST return a CallableReference that represents the
+ * service. When invoked during the execution of a callback operation, this
+ * API MUST return a CallableReference that represents the callback service.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetServiceReference() throws Exception {
+ Assert.assertEquals("ComponentA", a.getServiceReferenceName());
+ Assert.assertEquals("ComponentB", b.getServiceReferenceName());
+ Assert.assertEquals("CallBackB", a.getCallbackServiceReferenceName());
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/pom.xml b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/pom.xml
new file mode 100644
index 0000000000..1ad6a9c2ec
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/pom.xml
@@ -0,0 +1,45 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>java-api-apis</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>vtest-java-api-apis-servicereference</artifactId>
+ <name>Apache Tuscany SCA Java APIs and Annotations Verification Tests - APIs - ServiceReference</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/AComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/AComponent.java
new file mode 100644
index 0000000000..6de5d6810e
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/AComponent.java
@@ -0,0 +1,37 @@
+/*
+ * 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.servicereference;
+
+import org.oasisopen.sca.annotation.Conversational;
+
+/**
+ * Simple Service A.
+ */
+@Conversational
+public interface AComponent {
+
+ public String getName();
+
+ public void testConversationID();
+ public String getCallbackResult();
+ public void redirectCallback();
+ public void testGetCallback();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BCallback.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BCallback.java
new file mode 100644
index 0000000000..f8c5c1272f
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BCallback.java
@@ -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.vtest.javaapi.apis.servicereference;
+
+public interface BCallback {
+
+ public void processResults(String result);
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BComponent.java
new file mode 100644
index 0000000000..65a444d100
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BComponent.java
@@ -0,0 +1,38 @@
+/*
+ * 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.servicereference;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Conversational;
+
+/**
+ * Simple Service B.
+ */
+@Conversational
+@Callback(BCallback.class)
+public interface BComponent {
+
+ public String getName();
+
+ public void testCallback();
+ public void testConversationID();
+ public void testRedirectedCallback();
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/CComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/CComponent.java
new file mode 100644
index 0000000000..28c90e2071
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/CComponent.java
@@ -0,0 +1,27 @@
+/*
+ * 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.servicereference;
+
+/**
+ * Simple Service C.
+ */
+public interface CComponent extends BCallback {
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/AComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/AComponentImpl.java
new file mode 100644
index 0000000000..86dc80a4e1
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/AComponentImpl.java
@@ -0,0 +1,119 @@
+/*
+ * 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.servicereference.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.AComponent;
+import org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.BCallback;
+import org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.BComponent;
+import org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.CComponent;
+import org.junit.Assert;
+import org.oasisopen.sca.CallableReference;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.ConversationID;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(AComponent.class)
+@Scope("CONVERSATION")
+public class AComponentImpl implements AComponent, BCallback {
+
+ private static Object monitor = new Object();
+ private static String returnMessage = null;
+
+ protected ComponentContext componentContext;
+
+ @Reference
+ protected CallableReference<BComponent> bReference;
+
+ @Reference
+ protected ServiceReference<CComponent> cReference;
+
+ @ConversationID
+ protected String cid;
+
+ public String getName() {
+ return "ComponentA";
+ }
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ public void testConversationID() {
+ ServiceReference<BComponent> bSR = componentContext.getServiceReference(BComponent.class, "bReference");
+ bSR.setConversationID("AConversationID");
+ bSR.getService().testConversationID();
+
+ Assert.assertEquals("AConversationID", bSR.getConversation().getConversationID());
+ }
+
+ public String getCallbackResult() {
+ ServiceReference<BComponent> bSR = componentContext.getServiceReference(BComponent.class, "bReference");
+ String cbID = "ComponentACallBack";
+ bSR.setCallbackID(cbID);
+ bSR.getService().testCallback();
+
+ // Wait for 30s max.
+ int count = 0;
+ synchronized(monitor) {
+ while (returnMessage == null && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return returnMessage;
+ }
+
+ public void processResults(String result) {
+ returnMessage = result;
+ }
+
+ public void redirectCallback() {
+ ServiceReference<BComponent> bSR = componentContext.getServiceReference(BComponent.class, "bReference");
+ bSR.setCallbackID("RedirectedCallBack");
+ bSR.setCallback(cReference);
+ bSR.getService().testRedirectedCallback();
+ }
+
+ public void testGetCallback() {
+ ServiceReference<BComponent> bSR = componentContext.getServiceReference(BComponent.class, "bReference");
+ bSR.setCallback(cReference);
+ Assert.assertEquals(cReference, bSR.getCallback());
+
+ TestObject aCallback = new TestObject();
+ bSR.setCallback(aCallback);
+ Assert.assertEquals(aCallback, bSR.getCallback());
+ Assert.assertEquals(1, ((TestObject) bSR.getCallback()).getId());
+
+ TestObject bCallback = new TestObject();
+ bSR.setCallback(bCallback);
+ Assert.assertEquals(bCallback, bSR.getCallback());
+ Assert.assertEquals(2, ((TestObject) bSR.getCallback()).getId());
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/BComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/BComponentImpl.java
new file mode 100644
index 0000000000..c5af80291e
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/BComponentImpl.java
@@ -0,0 +1,74 @@
+/*
+ * 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.servicereference.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.BCallback;
+import org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.BComponent;
+import org.junit.Assert;
+import org.oasisopen.sca.CallableReference;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.ConversationID;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(BComponent.class)
+@Scope("CONVERSATION")
+public class BComponentImpl implements BComponent {
+
+ protected ComponentContext componentContext;
+
+ @Callback
+ protected BCallback callback;
+
+ @ConversationID
+ protected String cid;
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ public String getName() {
+ return "ComponentB";
+ }
+
+ public void testCallback() {
+ callback = componentContext.getRequestContext().getCallback();
+ callback.processResults("CallBackFromB");
+
+ CallableReference<BCallback> bCR = componentContext.getRequestContext().getCallbackReference();
+ Assert.assertEquals("ComponentACallBack", bCR.getCallbackID());
+ }
+
+ public void testConversationID() {
+ Assert.assertEquals("AConversationID", cid);
+ }
+
+ public void testRedirectedCallback() {
+ callback = componentContext.getRequestContext().getCallback();
+ callback.processResults("RedirectedCallBackFromB");
+
+ CallableReference<BCallback> bCR = componentContext.getRequestContext().getCallbackReference();
+ Assert.assertEquals("RedirectedCallBack", bCR.getCallbackID());
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/CComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/CComponentImpl.java
new file mode 100644
index 0000000000..563d3ceab6
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/CComponentImpl.java
@@ -0,0 +1,38 @@
+/*
+ * 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.servicereference.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.CComponent;
+import org.junit.Assert;
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CComponent.class)
+public class CComponentImpl implements CComponent {
+
+ @Context
+ protected RequestContext requestContext;
+
+ public void processResults(String result) {
+ Assert.assertEquals("RedirectedCallBackFromB", result);
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/TestObject.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/TestObject.java
new file mode 100644
index 0000000000..ba3edf13ae
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/TestObject.java
@@ -0,0 +1,37 @@
+/*
+ * 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.servicereference.impl;
+
+public class TestObject {
+
+ public static int count = 0;
+
+ private int id;
+
+ public TestObject() {
+ count++;
+ id = count;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/resources/servicereference.composite b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/resources/servicereference.composite
new file mode 100644
index 0000000000..9bded61947
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/resources/servicereference.composite
@@ -0,0 +1,39 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://java-api-tests"
+ name="ServiceReference-Composite">
+
+ <component name="AComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.impl.AComponentImpl"/>
+ <reference name="bReference" target="BComponent"/>
+ <reference name="cReference" target="CComponent"/>
+ </component>
+
+ <component name="BComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.impl.BComponentImpl"/>
+ </component>
+
+ <component name="CComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.impl.CComponentImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/ServiceReferenceTestCase.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/ServiceReferenceTestCase.java
new file mode 100644
index 0000000000..fda917d60a
--- /dev/null
+++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/ServiceReferenceTestCase.java
@@ -0,0 +1,106 @@
+/*
+ * 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.servicereference;
+
+import org.apache.tuscany.sca.vtest.utilities.ServiceFinder;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * This test class tests the ServiceReference interface described in 1.7.4 of
+ * the SCA Java Annotations & APIs Specification 1.0.
+ */
+public class ServiceReferenceTestCase {
+
+ protected static String compositeName = "servicereference.composite";
+ protected static AComponent a;
+ protected static BComponent b;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ System.out.println("Setting up");
+ ServiceFinder.init(compositeName);
+ a = ServiceFinder.getService(AComponent.class, "AComponent");
+ b = ServiceFinder.getService(BComponent.class, "BComponent");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ System.out.println("Cleaning up");
+ ServiceFinder.cleanup();
+ }
+
+ /**
+ * Lines 915-916 <br>
+ * getConversationID() - Returns the id supplied by the user that will be
+ * associated with conversations initiated through this reference. <br>
+ * setConversationID(Object conversationId) – Set the id to associate with
+ * any conversation started through this reference. If the value supplied is
+ * null then the id will be generated by the implementation. Throws an
+ * IllegalStateException if a conversation is currently associated with this
+ * reference.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testConversationID() throws Exception {
+ a.testConversationID();
+ }
+
+ /**
+ * Lines 917 <br>
+ * setCallbackID(Object callbackID) – Sets the callback ID.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testSetCallbackID() throws Exception {
+ Assert.assertEquals("CallBackFromB", a.getCallbackResult());
+ }
+
+ /**
+ * Lines 918 <br>
+ * getCallback() – Returns the callback object.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetCallback() throws Exception {
+ a.testGetCallback();
+ }
+
+ /**
+ * Lines 919 <br>
+ * setCallback(Object callback) – Sets the callback object.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testSetCallback() throws Exception {
+ a.redirectCallback();
+ }
+
+}