summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis')
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/pom.xml45
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/AComponent.java38
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BCallback.java26
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BComponent.java38
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/AComponentImpl.java104
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/BComponentImpl.java70
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/resources/callablereference.composite34
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/CallableReferenceTestCase.java118
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/pom.xml45
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/AComponent.java42
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BComponent.java29
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java34
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/CService.java29
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java29
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java124
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AUnannotatedComponentImpl.java121
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/BComponentImpl.java52
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/DComponentImpl.java32
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite47
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java184
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/pom.xml45
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/AComponent.java34
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/BComponent.java39
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/AComponentImpl.java73
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/BComponentImpl.java78
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/main/resources/conversation.composite34
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/ConversationTestCase.java70
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/pom.xml45
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/AComponent.java40
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BCallback.java26
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BComponent.java35
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/CComponent.java34
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DComponent.java33
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DException.java30
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/AComponentImpl.java128
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/BComponentImpl.java64
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/CComponentImpl.java50
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/DComponentImpl.java37
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/resources/exception.composite44
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/ExceptionTestCase.java131
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/pom.xml64
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/pom.xml45
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/AComponent.java35
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BCallback.java27
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java35
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/AComponentImpl.java102
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/BComponentImpl.java61
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/main/resources/requestcontext.composite34
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/RequestContextTestCase.java109
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/pom.xml45
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/AComponent.java37
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BCallback.java26
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BComponent.java38
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/CComponent.java27
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/AComponentImpl.java119
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/BComponentImpl.java74
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/CComponentImpl.java38
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/TestObject.java37
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/resources/servicereference.composite39
-rw-r--r--sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/ServiceReferenceTestCase.java106
60 files changed, 3409 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/pom.xml b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/pom.xml
new file mode 100644
index 0000000000..d4af5b79db
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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>1.4-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>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/AComponent.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/AComponent.java
new file mode 100644
index 0000000000..a3f6d48685
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BCallback.java b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BComponent.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BComponent.java
new file mode 100644
index 0000000000..1a62b86c22
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/AComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..51ee68a393
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/BComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..f66db33a83
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/resources/callablereference.composite b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/main/resources/callablereference.composite
new file mode 100644
index 0000000000..f997d78bb5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/callablereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/CallableReferenceTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/pom.xml b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/pom.xml
new file mode 100644
index 0000000000..9af4b21f8a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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>1.4-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>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/AComponent.java b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BComponent.java b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java
new file mode 100644
index 0000000000..eff7cc5a88
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Service B.
+ */
+@Remotable
+public interface BService {
+
+ String getBName();
+
+ String getSelfReferenceWithServiceName();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/CService.java b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java
new file mode 100644
index 0000000000..a221ba11fc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface DComponent {
+
+ public String getName();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..606443a480
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.RequestContext;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(AComponent.class)
+@Scope("COMPOSITE")
+@EagerInit
+public class 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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AUnannotatedComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AUnannotatedComponentImpl.java
new file mode 100644
index 0000000000..34a71e1318
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AUnannotatedComponentImpl.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.AComponent;
+import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.BService;
+import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.DComponent;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.RequestContext;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(AComponent.class)
+@Scope("COMPOSITE")
+@EagerInit
+public class AUnannotatedComponentImpl implements AComponent {
+
+ public static String rcContent = null;
+
+ protected ComponentContext componentContext;
+
+ protected BService bReference;
+
+ protected DComponent dReference;
+
+ protected String aProperty;
+
+ public String getName() {
+ return "ComponentA";
+ }
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ @Init
+ public void init() {
+ RequestContext rc = componentContext.getRequestContext();
+ if (rc != null) {
+ rcContent = "NotNull";
+ } else {
+ rcContent = "Null";
+ }
+ }
+
+ public String getContextURI() {
+ return componentContext.getURI();
+ }
+
+ public String getServiceBName() {
+ return componentContext.getService(BService.class, "bReference").getBName();
+ }
+
+ public String getServiceReferenceBName() {
+ ServiceReference<BService> bSR = componentContext.getServiceReference(BService.class, "bReference");
+ return bSR.getService().getBName();
+ }
+
+ public String getSelfReferenceName() {
+ ServiceReference<AComponent> aSR = componentContext.createSelfReference(AComponent.class);
+ return aSR.getService().getName();
+ }
+
+ public String getProperty() {
+ return componentContext.getProperty(String.class, "aProperty");
+ }
+
+ public String getRequestContextServiceName() {
+ return componentContext.getRequestContext().getServiceName();
+ }
+
+ public String getCastCallableReferenceServiceName() {
+ BService b = componentContext.getService(BService.class, "bReference");
+ CallableReference<BService> bCR = componentContext.cast(b);
+ return bCR.getService().getBName();
+ }
+
+ public String getCastServiceReferenceServiceName() {
+ BService b = componentContext.getService(BService.class, "bReference");
+ ServiceReference<BService> bSR = componentContext.cast(b);
+ return bSR.getService().getBName();
+ }
+
+ public void illegalCast() {
+ componentContext.cast("");
+ }
+
+ public String testServiceLookup() {
+ return componentContext.getService(DComponent.class, "dReference").getName();
+ }
+
+ public String getRequestContextContent() {
+ return rcContent;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/BComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..71d2eade2b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/DComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..4b2c8c183b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.Service;
+
+@Service(DComponent.class)
+public class DComponentImpl implements DComponent {
+
+ public String getName() {
+ return "ComponentD";
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite
new file mode 100644
index 0000000000..19f110d5dc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java
new file mode 100644
index 0000000000..9bfe0c06e7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java
@@ -0,0 +1,184 @@
+/*
+ * 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;
+
+/**
+ * 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";
+ }
+ 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
+ */
+ @Ignore
+ public void testServiceLookup() throws Exception {
+ Assert.assertEquals("ComponentD", a.testServiceLookup());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/pom.xml b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/pom.xml
new file mode 100644
index 0000000000..143d6f1788
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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>1.4-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>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/AComponent.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/AComponent.java
new file mode 100644
index 0000000000..805c1f2750
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.Conversational;
+
+/**
+ * Simple Service A.
+ */
+@Conversational
+public interface AComponent {
+
+ public String getName();
+
+ public void testConversation();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/BComponent.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/BComponent.java
new file mode 100644
index 0000000000..abd8602705
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/AComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..616155ccdf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.Conversation;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/BComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..66a3d3c72c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.ComponentContext;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/main/resources/conversation.composite b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/main/resources/conversation.composite
new file mode 100644
index 0000000000..87cab2f479
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/conversation/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/ConversationTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/pom.xml b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/pom.xml
new file mode 100644
index 0000000000..e3325aaa07
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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>1.4-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>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/AComponent.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/AComponent.java
new file mode 100644
index 0000000000..5c3755b19f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BCallback.java b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BComponent.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BComponent.java
new file mode 100644
index 0000000000..6893a3b4b8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.Callback;
+
+/**
+ * Simple Service B.
+ */
+@Callback(BCallback.class)
+public interface BComponent {
+
+ public String getName();
+
+ public void testCallback();
+ public void testRedirectedCallback();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/CComponent.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/CComponent.java
new file mode 100644
index 0000000000..519e66f1ce
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.Conversational;
+
+/**
+ * Simple Service C.
+ */
+@Conversational
+public interface CComponent {
+
+ public String getName();
+
+ public void testConversation();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DComponent.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DComponent.java
new file mode 100644
index 0000000000..d0ef71a926
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Remote Service D.
+ */
+@Remotable
+public interface DComponent {
+
+ public String getName();
+ public void testException() throws DException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DException.java b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/AComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..b4d6e929c5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ConversationEndedException;
+import org.osoa.sca.NoRegisteredCallbackException;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.ServiceRuntimeException;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/BComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..245401e8aa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/CComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..2546548e1c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.RequestContext;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.ConversationAttributes;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/DComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..1cbda7e10b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/resources/exception.composite b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/main/resources/exception.composite
new file mode 100644
index 0000000000..5bd933ce96
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/ExceptionTestCase.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/ExceptionTestCase.java
new file mode 100644
index 0000000000..9ff7e8e28f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/exception/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/ExceptionTestCase.java
@@ -0,0 +1,131 @@
+/*
+ * 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
+ */
+ @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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/pom.xml b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/pom.xml
new file mode 100644
index 0000000000..b1b2fc3e6b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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>1.4-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>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.4-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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/pom.xml b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/pom.xml
new file mode 100644
index 0000000000..7f18df910c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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>1.4-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>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/AComponent.java b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BCallback.java b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java
new file mode 100644
index 0000000000..34f709d175
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.Callback;
+
+/**
+ * Simple Service B.
+ */
+@Callback(BCallback.class)
+public interface BComponent {
+
+ public String getName();
+
+ public void testCallback();
+ public String getServiceReferenceName();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/AComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..c6fa589ed4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/BComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..33ff829357
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/main/resources/requestcontext.composite b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/main/resources/requestcontext.composite
new file mode 100644
index 0000000000..4aa5eeb25a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/RequestContextTestCase.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/requestcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/RequestContextTestCase.java
new file mode 100644
index 0000000000..65a1dbf88b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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
+ 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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/pom.xml b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/pom.xml
new file mode 100644
index 0000000000..f792cff7e5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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>1.4-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>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/AComponent.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/AComponent.java
new file mode 100644
index 0000000000..a1745f400e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BCallback.java b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BComponent.java b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BComponent.java
new file mode 100644
index 0000000000..33a4d6edcc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/CComponent.java b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/AComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..545d037c53
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/BComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..f4307667b6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/CComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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..099655ea22
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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.osoa.sca.RequestContext;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/TestObject.java b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/resources/servicereference.composite b/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/main/resources/servicereference.composite
new file mode 100644
index 0000000000..9bded61947
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/vtest/java-api/apis/servicereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/ServiceReferenceTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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/sca-java-1.x/branches/sca-java-20080910/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();
+ }
+
+}