From 875ac5d246878b199c393e9700c8a085c8939333 Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 19 Mar 2009 17:02:07 +0000 Subject: [maven-release-plugin] copy for branch tb3 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@756088 13f79535-47bb-0310-9956-ffa450edef68 --- .../vtest/java-api/apis/callablereference/pom.xml | 45 +++++ .../javaapi/apis/callablereference/AComponent.java | 38 ++++ .../javaapi/apis/callablereference/BCallback.java | 26 +++ .../javaapi/apis/callablereference/BComponent.java | 38 ++++ .../callablereference/impl/AComponentImpl.java | 104 +++++++++++ .../callablereference/impl/BComponentImpl.java | 70 ++++++++ .../src/main/resources/callablereference.composite | 34 ++++ .../CallableReferenceTestCase.java | 118 +++++++++++++ .../vtest/java-api/apis/componentcontext/pom.xml | 45 +++++ .../javaapi/apis/componentcontext/AComponent.java | 42 +++++ .../javaapi/apis/componentcontext/BComponent.java | 29 ++++ .../javaapi/apis/componentcontext/BService.java | 34 ++++ .../javaapi/apis/componentcontext/CService.java | 29 ++++ .../javaapi/apis/componentcontext/DComponent.java | 29 ++++ .../apis/componentcontext/impl/AComponentImpl.java | 124 +++++++++++++ .../impl/AUnannotatedComponentImpl.java | 121 +++++++++++++ .../apis/componentcontext/impl/BComponentImpl.java | 52 ++++++ .../apis/componentcontext/impl/DComponentImpl.java | 32 ++++ .../src/main/resources/ab.composite | 47 +++++ .../componentcontext/ComponentContextTestCase.java | 191 +++++++++++++++++++++ .../tb3/vtest/java-api/apis/conversation/pom.xml | 45 +++++ .../javaapi/apis/conversation/AComponent.java | 34 ++++ .../javaapi/apis/conversation/BComponent.java | 39 +++++ .../apis/conversation/impl/AComponentImpl.java | 73 ++++++++ .../apis/conversation/impl/BComponentImpl.java | 78 +++++++++ .../src/main/resources/conversation.composite | 34 ++++ .../apis/conversation/ConversationTestCase.java | 70 ++++++++ .../tb3/vtest/java-api/apis/exception/pom.xml | 45 +++++ .../vtest/javaapi/apis/exception/AComponent.java | 40 +++++ .../vtest/javaapi/apis/exception/BCallback.java | 26 +++ .../vtest/javaapi/apis/exception/BComponent.java | 35 ++++ .../vtest/javaapi/apis/exception/CComponent.java | 34 ++++ .../vtest/javaapi/apis/exception/DComponent.java | 33 ++++ .../vtest/javaapi/apis/exception/DException.java | 30 ++++ .../apis/exception/impl/AComponentImpl.java | 128 ++++++++++++++ .../apis/exception/impl/BComponentImpl.java | 64 +++++++ .../apis/exception/impl/CComponentImpl.java | 50 ++++++ .../apis/exception/impl/DComponentImpl.java | 37 ++++ .../src/main/resources/exception.composite | 44 +++++ .../javaapi/apis/exception/ExceptionTestCase.java | 132 ++++++++++++++ .../sca/branches/tb3/vtest/java-api/apis/pom.xml | 64 +++++++ .../tb3/vtest/java-api/apis/requestcontext/pom.xml | 45 +++++ .../javaapi/apis/requestcontext/AComponent.java | 35 ++++ .../javaapi/apis/requestcontext/BCallback.java | 27 +++ .../javaapi/apis/requestcontext/BComponent.java | 35 ++++ .../apis/requestcontext/impl/AComponentImpl.java | 102 +++++++++++ .../apis/requestcontext/impl/BComponentImpl.java | 61 +++++++ .../src/main/resources/requestcontext.composite | 34 ++++ .../requestcontext/RequestContextTestCase.java | 109 ++++++++++++ .../vtest/java-api/apis/servicereference/pom.xml | 45 +++++ .../javaapi/apis/servicereference/AComponent.java | 37 ++++ .../javaapi/apis/servicereference/BCallback.java | 26 +++ .../javaapi/apis/servicereference/BComponent.java | 38 ++++ .../javaapi/apis/servicereference/CComponent.java | 27 +++ .../apis/servicereference/impl/AComponentImpl.java | 119 +++++++++++++ .../apis/servicereference/impl/BComponentImpl.java | 74 ++++++++ .../apis/servicereference/impl/CComponentImpl.java | 38 ++++ .../apis/servicereference/impl/TestObject.java | 37 ++++ .../src/main/resources/servicereference.composite | 39 +++++ .../servicereference/ServiceReferenceTestCase.java | 106 ++++++++++++ 60 files changed, 3417 insertions(+) create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/pom.xml create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/AComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BCallback.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/AComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/BComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/resources/callablereference.composite create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/CallableReferenceTestCase.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/pom.xml create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/AComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/CService.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AUnannotatedComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/BComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/DComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/pom.xml create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/AComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/BComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/AComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/BComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/resources/conversation.composite create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/ConversationTestCase.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/pom.xml create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/AComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BCallback.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/CComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DException.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/AComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/BComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/CComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/DComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/resources/exception.composite create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/ExceptionTestCase.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/pom.xml create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/pom.xml create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/AComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BCallback.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/AComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/BComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/resources/requestcontext.composite create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/RequestContextTestCase.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/pom.xml create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/AComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BCallback.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/CComponent.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/AComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/BComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/CComponentImpl.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/TestObject.java create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/resources/servicereference.composite create mode 100644 sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/ServiceReferenceTestCase.java (limited to 'sandbox/ant/sca/branches/tb3/vtest/java-api/apis') diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/pom.xml b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/pom.xml new file mode 100644 index 0000000000..fff1689569 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-apis + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-apis-callablereference + Apache Tuscany SCA Java APIs and Annotations Verification Tests - APIs - CallableReference + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/AComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/AComponent.java new file mode 100644 index 0000000000..a7040f944e --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/AComponent.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.callablereference; + +import org.oasisopen.sca.annotation.Conversational; + +/** + * Simple Service A. + */ +@Conversational +public interface AComponent { + + public String getName(); + + public String getServiceName(); + public String getBusinessInterfaceName(); + public boolean isConversational(); + public void testConversationID(); + public String getCallbackResult(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BCallback.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BCallback.java new file mode 100644 index 0000000000..707568e507 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BCallback.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.callablereference; + +public interface BCallback { + + public void processResults(String result); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BComponent.java new file mode 100644 index 0000000000..18fcaee6ee --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/BComponent.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.callablereference; + +import org.oasisopen.sca.annotation.Callback; +import org.oasisopen.sca.annotation.Conversational; + +/** + * Simple Service B. + */ +@Conversational +@Callback(BCallback.class) +public interface BComponent { + + public String getName(); + + public void testCallback(); + public void testConversationID(); + public void testNonNullConversation(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/AComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/AComponentImpl.java new file mode 100644 index 0000000000..70a257d19f --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/AComponentImpl.java @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.callablereference.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.callablereference.AComponent; +import org.apache.tuscany.sca.vtest.javaapi.apis.callablereference.BCallback; +import org.apache.tuscany.sca.vtest.javaapi.apis.callablereference.BComponent; +import org.junit.Assert; +import org.oasisopen.sca.CallableReference; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.ServiceReference; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.ConversationID; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(AComponent.class) +@Scope("CONVERSATION") +public class AComponentImpl implements AComponent, BCallback { + + private static Object monitor = new Object(); + private static String returnMessage = null; + + protected ComponentContext componentContext; + + @Reference + protected CallableReference 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 bSR = componentContext.getServiceReference(BComponent.class, "bReference"); + bSR.setConversationID("AConversationID"); + bSR.getService().testConversationID(); + + Assert.assertEquals("AConversationID", bSR.getConversation().getConversationID()); + } + + public String getCallbackResult() { + ServiceReference bSR = componentContext.getServiceReference(BComponent.class, "bReference"); + String cbID = "ComponentACallBack"; + bSR.setCallbackID(cbID); + bSR.getService().testCallback(); + + // Wait for 30s max. + int count = 0; + synchronized(monitor) { + while (returnMessage == null && count++ < 30) { + try { + monitor.wait(1000L); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + return returnMessage; + } + + public void processResults(String result) { + returnMessage = result; + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/BComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/BComponentImpl.java new file mode 100644 index 0000000000..ea4c71d27a --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/impl/BComponentImpl.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.callablereference.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.callablereference.BCallback; +import org.apache.tuscany.sca.vtest.javaapi.apis.callablereference.BComponent; +import org.junit.Assert; +import org.oasisopen.sca.CallableReference; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.annotation.Callback; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.ConversationID; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(BComponent.class) +@Scope("CONVERSATION") +public class BComponentImpl implements BComponent { + + protected ComponentContext componentContext; + + @Callback + protected BCallback callback; + + @ConversationID + protected String cid; + + @Context + public void setComponentContext(ComponentContext context) { + this.componentContext = context; + } + + public String getName() { + return "ComponentB"; + } + + public void testCallback() { + callback = componentContext.getRequestContext().getCallback(); + callback.processResults("CallBackFromB"); + + CallableReference bCR = componentContext.getRequestContext().getCallbackReference(); + Assert.assertEquals("ComponentACallBack", bCR.getCallbackID()); + } + + public void testConversationID() { + Assert.assertEquals("AConversationID", cid); + } + + public void testNonNullConversation() { + Assert.assertNotNull(componentContext.getRequestContext().getServiceReference().getConversation()); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/resources/callablereference.composite b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/resources/callablereference.composite new file mode 100644 index 0000000000..f997d78bb5 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/main/resources/callablereference.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/CallableReferenceTestCase.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/CallableReferenceTestCase.java new file mode 100644 index 0000000000..4d0d8338ba --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/callablereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/callablereference/CallableReferenceTestCase.java @@ -0,0 +1,118 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.callablereference; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This test class tests the CallableReference interface described in 1.7.3 of + * the SCA Java Annotations & APIs Specification 1.0. + */ +public class CallableReferenceTestCase { + + protected static String compositeName = "callablereference.composite"; + protected static AComponent a; + protected static BComponent b; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + a = ServiceFinder.getService(AComponent.class, "AComponent"); + b = ServiceFinder.getService(BComponent.class, "BComponent"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + } + + /** + * Lines 884
+ * 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
+ * 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
+ * isConversational() – Returns true if this reference is conversational. + * + * @throws Exception + */ + @Test + public void testIsConversational() throws Exception { + Assert.assertEquals(true, a.isConversational()); + } + + /** + * Lines 887
+ * 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
+ * getCallbackID() – Returns the callback ID. + * + * @throws Exception + */ + @Test + public void testGetCallbackID() throws Exception { + // Actual test is in BComponentImpl. Below is an extra test. + Assert.assertEquals("CallBackFromB", a.getCallbackResult()); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/pom.xml b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/pom.xml new file mode 100644 index 0000000000..0a2d12a41e --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-apis + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-apis-componentcontext + Apache Tuscany SCA Java APIs and Annotations Verification Tests - APIs - ComponentContext + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/AComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/AComponent.java new file mode 100644 index 0000000000..b2c8c07866 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/AComponent.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext; + +/** + * Simple Service A. + */ +public interface AComponent { + + public String getName(); + + public String getContextURI(); + public String getServiceBName(); + public String getServiceReferenceBName(); + public String getSelfReferenceName(); + public String getProperty(); + public String getRequestContextServiceName(); + public String getCastCallableReferenceServiceName(); + public String getCastServiceReferenceServiceName(); + public void illegalCast(); + + public String testServiceLookup(); + public String getRequestContextContent(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BComponent.java new file mode 100644 index 0000000000..7e425c740f --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BComponent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext; + +/** + * Simple Service B. + */ +public interface BComponent { + + String getName(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java new file mode 100644 index 0000000000..d7799bb3aa --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/BService.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service B. + */ +@Remotable +public interface BService { + + String getBName(); + + String getSelfReferenceWithServiceName(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/CService.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/CService.java new file mode 100644 index 0000000000..d0da012f6f --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/CService.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext; + +/** + * Simple Service C. + */ +public interface CService { + + String getCName(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java new file mode 100644 index 0000000000..079d859f74 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/DComponent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface DComponent { + + public String getName(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java new file mode 100644 index 0000000000..06a71c29ac --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AComponentImpl.java @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.AComponent; +import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.BService; +import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.DComponent; +import org.oasisopen.sca.CallableReference; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.RequestContext; +import org.oasisopen.sca.ServiceReference; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.EagerInit; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(AComponent.class) +@Scope("COMPOSITE") +@EagerInit +public class AComponentImpl implements AComponent { + + public static String rcContent = null; + + protected ComponentContext componentContext; + + @Reference + protected BService bReference; + + @Reference + protected DComponent dReference; + + @Property(name="aProperty", required=true) + protected String aProperty; + + public String getName() { + return "ComponentA"; + } + + @Context + public void setComponentContext(ComponentContext context) { + this.componentContext = context; + } + + @Init + public void init() { + RequestContext rc = componentContext.getRequestContext(); + if (rc != null) { + rcContent = "NotNull"; + } else { + rcContent = "Null"; + } + } + + public String getContextURI() { + return componentContext.getURI(); + } + + public String getServiceBName() { + return componentContext.getService(BService.class, "bReference").getBName(); + } + + public String getServiceReferenceBName() { + ServiceReference bSR = componentContext.getServiceReference(BService.class, "bReference"); + return bSR.getService().getBName(); + } + + public String getSelfReferenceName() { + ServiceReference 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 bCR = componentContext.cast(b); + return bCR.getService().getBName(); + } + + public String getCastServiceReferenceServiceName() { + BService b = componentContext.getService(BService.class, "bReference"); + ServiceReference bSR = componentContext.cast(b); + return bSR.getService().getBName(); + } + + public void illegalCast() { + componentContext.cast(""); + } + + public String testServiceLookup() { + return componentContext.getService(DComponent.class, "dReference").getName(); + } + + public String getRequestContextContent() { + return rcContent; + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AUnannotatedComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AUnannotatedComponentImpl.java new file mode 100644 index 0000000000..e508687965 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/AUnannotatedComponentImpl.java @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.AComponent; +import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.BService; +import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.DComponent; +import org.oasisopen.sca.CallableReference; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.RequestContext; +import org.oasisopen.sca.ServiceReference; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.EagerInit; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(AComponent.class) +@Scope("COMPOSITE") +@EagerInit +public class AUnannotatedComponentImpl implements AComponent { + + public static String rcContent = null; + + protected ComponentContext componentContext; + + protected BService bReference; + + protected DComponent dReference; + + protected String aProperty; + + public String getName() { + return "ComponentA"; + } + + @Context + public void setComponentContext(ComponentContext context) { + this.componentContext = context; + } + + @Init + public void init() { + RequestContext rc = componentContext.getRequestContext(); + if (rc != null) { + rcContent = "NotNull"; + } else { + rcContent = "Null"; + } + } + + public String getContextURI() { + return componentContext.getURI(); + } + + public String getServiceBName() { + return componentContext.getService(BService.class, "bReference").getBName(); + } + + public String getServiceReferenceBName() { + ServiceReference bSR = componentContext.getServiceReference(BService.class, "bReference"); + return bSR.getService().getBName(); + } + + public String getSelfReferenceName() { + ServiceReference 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 bCR = componentContext.cast(b); + return bCR.getService().getBName(); + } + + public String getCastServiceReferenceServiceName() { + BService b = componentContext.getService(BService.class, "bReference"); + ServiceReference bSR = componentContext.cast(b); + return bSR.getService().getBName(); + } + + public void illegalCast() { + componentContext.cast(""); + } + + public String testServiceLookup() { + return componentContext.getService(DComponent.class, "dReference").getName(); + } + + public String getRequestContextContent() { + return rcContent; + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/BComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/BComponentImpl.java new file mode 100644 index 0000000000..157864fd27 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/BComponentImpl.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.BService; +import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.CService; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.ServiceReference; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.Service; + +@Service(interfaces={BService.class, CService.class}) +public class BComponentImpl implements BService, CService { + + protected ComponentContext componentContext; + + @Context + public void setComponentContext(ComponentContext context) { + this.componentContext = context; + } + + public String getBName() { + return "ServiceB"; + } + + public String getCName() { + return "ServiceC"; + } + + public String getSelfReferenceWithServiceName() { + ServiceReference cSR = componentContext.createSelfReference(CService.class, "CService"); + return cSR.getService().getCName(); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/DComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/DComponentImpl.java new file mode 100644 index 0000000000..9432c70ff3 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/impl/DComponentImpl.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext.DComponent; +import org.oasisopen.sca.annotation.Service; + +@Service(DComponent.class) +public class DComponentImpl implements DComponent { + + public String getName() { + return "ComponentD"; + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite new file mode 100644 index 0000000000..19f110d5dc --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/main/resources/ab.composite @@ -0,0 +1,47 @@ + + + + + + + + + PropertyA + + + + + + + PropertyA + + + + + + + + + + + diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java new file mode 100644 index 0000000000..e9352a5c06 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/componentcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/componentcontext/ComponentContextTestCase.java @@ -0,0 +1,191 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.componentcontext; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import org.oasisopen.sca.ServiceRuntimeException; + +/** + * This test class tests the ComponentContext interface described in 1.7.1 of + * the SCA Java Annotations & APIs Specification 1.0. Relevant sections of 1.4 + * will also be covered here. + */ +public class ComponentContextTestCase { + + protected static String compositeName = "ab.composite"; + protected static AComponent a; + protected static AComponent aUnannotated; + protected static BService b; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + a = ServiceFinder.getService(AComponent.class, "AComponent"); + aUnannotated = ServiceFinder.getService(AComponent.class, "AUnannotatedComponent"); + b = ServiceFinder.getService(BService.class, "BComponent/BService"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + } + + /** + * Lines 776
+ * 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
+ * getService(Class<B> 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
+ * getServiceReference(Class<B> 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
+ * createSelfReference(Class<B> 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
+ * getSelfReference(Class<B> 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
+ * getProperty (Class<B> 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
+ * 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
+ * cast(B target) - Casts a type-safe reference to a CallableReference. + * + * @throws Exception + */ + @Test + public void testCast() throws Exception { + Assert.assertEquals("ServiceB", a.getCastCallableReferenceServiceName()); + Assert.assertEquals("ServiceB", a.getCastServiceReferenceServiceName()); + + String check = ""; + try { + a.illegalCast(); + } catch (IllegalArgumentException iae) { + check = "IllegalCast"; + } catch (ServiceRuntimeException sre) { + if (sre.getCause() instanceof IllegalArgumentException) { + check = "IllegalCast"; + } + } + Assert.assertEquals("IllegalCast", check); + } + + /** + * Lines 342-344
+ * When a component implementation needs access to a service where the + * reference to the service is not known at compile time, the reference can + * be located using the component?s ComponentContext. + * + * @throws Exception + */ + @Test + @Ignore("TUSCANY-2609") + public void testServiceLookup() throws Exception { + Assert.assertEquals("ComponentD", a.testServiceLookup()); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/pom.xml b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/pom.xml new file mode 100644 index 0000000000..e026dcc800 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-apis + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-apis-conversation + Apache Tuscany SCA Java APIs and Annotations Verification Tests - APIs - Conversation + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/AComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/AComponent.java new file mode 100644 index 0000000000..845c10303e --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/AComponent.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.conversation; + +import org.oasisopen.sca.annotation.Conversational; + +/** + * Simple Service A. + */ +@Conversational +public interface AComponent { + + public String getName(); + + public void testConversation(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/BComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/BComponent.java new file mode 100644 index 0000000000..a3148aa0d7 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/BComponent.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.conversation; + +import org.oasisopen.sca.annotation.Conversational; +import org.oasisopen.sca.annotation.EndsConversation; + +/** + * Simple Service B. + */ +@Conversational +public interface BComponent { + + public String getName(); + + public void testCustomConversationID(); + public void testGeneratedConversationID(Object id); + + @EndsConversation + public void endsConversation(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/AComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/AComponentImpl.java new file mode 100644 index 0000000000..7160121388 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/AComponentImpl.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.conversation.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.conversation.AComponent; +import org.apache.tuscany.sca.vtest.javaapi.apis.conversation.BComponent; +import org.junit.Assert; +import org.oasisopen.sca.CallableReference; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.Conversation; +import org.oasisopen.sca.ServiceReference; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.ConversationID; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(AComponent.class) +@Scope("CONVERSATION") +public class AComponentImpl implements AComponent { + + protected ComponentContext componentContext; + + @Reference + protected CallableReference bReference; + + @ConversationID + protected String cid; + + public String getName() { + return "ComponentA"; + } + + @Context + public void setComponentContext(ComponentContext context) { + this.componentContext = context; + } + + public void testConversation() { + ServiceReference bSR = componentContext.getServiceReference(BComponent.class, "bReference"); + bSR.setConversationID("AConversationID"); + bSR.getService().testCustomConversationID(); + + Conversation bc = bSR.getConversation(); + Assert.assertEquals("AConversationID", bc.getConversationID()); + bc.end(); + + Assert.assertEquals("ComponentB", bReference.getService().getName()); + bReference.getService().testGeneratedConversationID(bReference.getConversation().getConversationID()); + bReference.getConversation().end(); + + Assert.assertEquals(1, BComponentImpl.customInitCount); + Assert.assertEquals(1, BComponentImpl.customDestroyCount); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/BComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/BComponentImpl.java new file mode 100644 index 0000000000..c487559ca1 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/impl/BComponentImpl.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.conversation.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.conversation.BComponent; +import org.junit.Assert; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.ConversationID; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(BComponent.class) +@Scope("CONVERSATION") +public class BComponentImpl implements BComponent { + + public static int customInitCount = 0; + public static int customDestroyCount = 0; + + protected ComponentContext componentContext; + + @ConversationID + protected String cid; + + @Context + public void setComponentContext(ComponentContext context) { + this.componentContext = context; + } + + public String getName() { + return "ComponentB"; + } + + public void testCustomConversationID() { + Assert.assertEquals("AConversationID", cid); + } + + public void testGeneratedConversationID(Object id) { + Assert.assertEquals(id.toString(), cid); + } + + public void endsConversation() { + } + + @Init + public void initB() { + if (cid.equals("AConversationID")) { + customInitCount++; + } + } + + @Destroy + public void destroyB() { + if (cid.equals("AConversationID")) { + customDestroyCount++; + } + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/resources/conversation.composite b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/resources/conversation.composite new file mode 100644 index 0000000000..87cab2f479 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/main/resources/conversation.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/ConversationTestCase.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/ConversationTestCase.java new file mode 100644 index 0000000000..9b46ac5e08 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/conversation/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/conversation/ConversationTestCase.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.conversation; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This test class tests the Conversation interface described in 1.7.5 of the + * SCA Java Annotations & APIs Specification 1.0. + */ +public class ConversationTestCase { + + protected static String compositeName = "conversation.composite"; + protected static AComponent a; + protected static BComponent b; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + a = ServiceFinder.getService(AComponent.class, "AComponent"); + b = ServiceFinder.getService(BComponent.class, "BComponent"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + } + + /** + * Lines 941, 942
+ * 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.
+ * end() – Ends this conversation. + * + * @throws Exception + */ + @Test + public void testConversation() throws Exception { + a.testConversation(); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/pom.xml b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/pom.xml new file mode 100644 index 0000000000..ef6e5182ee --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-apis + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-apis-exception + Apache Tuscany SCA Java APIs and Annotations Verification Tests - APIs - Exception + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/AComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/AComponent.java new file mode 100644 index 0000000000..90582e88a2 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/AComponent.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.exception; + +import org.oasisopen.sca.annotation.Conversational; + +/** + * Simple Service A. + */ +@Conversational +public interface AComponent { + + public String getName(); + + public void testConversation(); + public void testCallBack(); + + public boolean testServiceRuntimeException(); + public boolean testServiceUnavailableException(); + + public boolean testCheckedException(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BCallback.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BCallback.java new file mode 100644 index 0000000000..c1c1c6544c --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BCallback.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.exception; + +public interface BCallback { + + public void processResults(String result); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BComponent.java new file mode 100644 index 0000000000..11886277ad --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/BComponent.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.exception; + +import org.oasisopen.sca.annotation.Callback; + +/** + * Simple Service B. + */ +@Callback(BCallback.class) +public interface BComponent { + + public String getName(); + + public void testCallback(); + public void testRedirectedCallback(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/CComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/CComponent.java new file mode 100644 index 0000000000..466a32731a --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/CComponent.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.exception; + +import org.oasisopen.sca.annotation.Conversational; + +/** + * Simple Service C. + */ +@Conversational +public interface CComponent { + + public String getName(); + + public void testConversation(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DComponent.java new file mode 100644 index 0000000000..c0aed7a707 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DComponent.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.exception; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Remote Service D. + */ +@Remotable +public interface DComponent { + + public String getName(); + public void testException() throws DException; + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DException.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DException.java new file mode 100644 index 0000000000..82873ed96d --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/DException.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.exception; + +public class DException extends Exception { + + private static final long serialVersionUID = -3819913841563109423L; + + public DException(String message) { + super(message); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/AComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/AComponentImpl.java new file mode 100644 index 0000000000..1190e6900f --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/AComponentImpl.java @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.exception.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.exception.AComponent; +import org.apache.tuscany.sca.vtest.javaapi.apis.exception.BComponent; +import org.apache.tuscany.sca.vtest.javaapi.apis.exception.CComponent; +import org.apache.tuscany.sca.vtest.javaapi.apis.exception.DComponent; +import org.apache.tuscany.sca.vtest.javaapi.apis.exception.DException; +import org.junit.Assert; +import org.oasisopen.sca.CallableReference; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.ConversationEndedException; +import org.oasisopen.sca.NoRegisteredCallbackException; +import org.oasisopen.sca.ServiceReference; +import org.oasisopen.sca.ServiceRuntimeException; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.ConversationID; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(AComponent.class) +@Scope("CONVERSATION") +public class AComponentImpl implements AComponent { + + protected ComponentContext componentContext; + + @Reference + protected CallableReference bReference; + + @Reference + protected ServiceReference cReference; + + @Reference + protected ServiceReference dReference; + + @ConversationID + protected String cid; + + public String getName() { + return "ComponentA"; + } + + @Context + public void setComponentContext(ComponentContext context) { + this.componentContext = context; + } + + public void testConversation() { + ServiceReference 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 bSR = componentContext.getServiceReference(BComponent.class, "bReference"); + bSR.setCallbackID("ComponentACallBack"); + + try { + bSR.getService().testCallback(); + Assert.fail(); + } catch (NoRegisteredCallbackException e) { + // Expected + } + } + + public boolean testServiceRuntimeException() { + try { + componentContext.getServiceReference(BComponent.class, "dummyBReference").getService().getName(); + } catch (ServiceRuntimeException sre) { + return true; + } + + return false; + } + + public boolean testServiceUnavailableException() { + return false; + } + + public boolean testCheckedException() { + try { + dReference.getService().testException(); + } catch (DException e) { + if (e.getMessage().equals("ADException")) { + return true; + } + } + + return false; + } + + @Destroy + public void destroy() { + System.out.println("This is a Destroy of AComponent .."); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/BComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/BComponentImpl.java new file mode 100644 index 0000000000..eca4b54109 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/BComponentImpl.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.exception.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.exception.BCallback; +import org.apache.tuscany.sca.vtest.javaapi.apis.exception.BComponent; +import org.junit.Assert; +import org.oasisopen.sca.CallableReference; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.annotation.Callback; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.Service; + +@Service(BComponent.class) +public class BComponentImpl implements BComponent { + + protected ComponentContext componentContext; + + @Callback + protected BCallback callback; + + @Context + public void setComponentContext(ComponentContext context) { + this.componentContext = context; + } + + public String getName() { + return "ComponentB"; + } + + public void testCallback() { + callback = componentContext.getRequestContext().getCallback(); + callback.processResults("CallBackFromB"); + + CallableReference bCR = componentContext.getRequestContext().getCallbackReference(); + Assert.assertEquals("ComponentACallBack", bCR.getCallbackID()); + } + + public void testRedirectedCallback() { + callback = componentContext.getRequestContext().getCallback(); + callback.processResults("RedirectedCallBackFromB"); + + CallableReference bCR = componentContext.getRequestContext().getCallbackReference(); + Assert.assertEquals("RedirectedCallBack", bCR.getCallbackID()); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/CComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/CComponentImpl.java new file mode 100644 index 0000000000..57a34716e6 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/CComponentImpl.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.exception.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.exception.CComponent; +import org.junit.Assert; +import org.oasisopen.sca.RequestContext; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.ConversationAttributes; +import org.oasisopen.sca.annotation.ConversationID; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(CComponent.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxIdleTime="1 seconds") +public class CComponentImpl implements CComponent { + + @Context + protected RequestContext requestContext; + + @ConversationID + protected String cid; + + public String getName() { + return "ComponentC"; + } + + public void testConversation() { + Assert.assertEquals("AConversationID", cid); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/DComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/DComponentImpl.java new file mode 100644 index 0000000000..c1f5a56a9a --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/impl/DComponentImpl.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.exception.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.exception.DComponent; +import org.apache.tuscany.sca.vtest.javaapi.apis.exception.DException; +import org.oasisopen.sca.annotation.Service; + +@Service(DComponent.class) +public class DComponentImpl implements DComponent { + + public String getName() { + return "ComponentD"; + } + + public void testException() throws DException { + throw new DException("ADException"); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/resources/exception.composite b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/resources/exception.composite new file mode 100644 index 0000000000..5bd933ce96 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/main/resources/exception.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/ExceptionTestCase.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/ExceptionTestCase.java new file mode 100644 index 0000000000..da7b1da0fa --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/exception/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/exception/ExceptionTestCase.java @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.exception; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * This test class tests the Exceptions described in 1.7.6, 1.7.7, 1.7.8, and 1.7.9 of the SCA Java Annotations & APIs Specification 1.0. + * This also covers 1.5 of the specification. + */ +public class ExceptionTestCase { + + protected static SCADomain domain; + protected static String compositeName = "exception.composite"; + protected static AComponent a; + protected static BComponent b; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + domain = SCADomain.newInstance(compositeName); + a = domain.getService(AComponent.class, "AComponent"); + b = domain.getService(BComponent.class, "BComponent"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + System.out.println("Cleaning up"); + if (domain != null) { + domain.close(); + } + } + + /** + * Lines 951
+ * NoRegisteredCallbackException. + * + * @throws Exception + */ + @Test + public void testNoRegisteredCallbackException() throws Exception { + a.testCallBack(); + } + + /** + * Lines 960
+ * 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
+ * ServiceUnavailableException – This exception signals problems in the interaction with remote services. + * + * @throws Exception + */ + @Test + //@Ignore + public void testServiceUnavailableException() throws Exception { + domain.getComponentManager().stopComponent("AComponent"); + + try { + a.getName(); + } catch (Exception e) { + e.printStackTrace(); + } + + try { + AComponent ac = domain.getService(AComponent.class, "AComponent"); + ac.getName(); + } catch (Exception e) { + e.printStackTrace(); + } + + domain.getComponentManager().startComponent("AComponent"); + } + + /** + * Lines 983
+ * ConversationEndedException. + * + * @throws Exception + */ + @Test + public void testConversationEndedException() throws Exception { + a.testConversation(); + } + + /** + * Lines 360-361
+ * Business exceptions are thrown by the implementation of the called service method, + * and are defined as checked exceptions on the interface that types the service. + * + * @throws Exception + */ + @Test + public void testCheckedException() throws Exception { + Assert.assertTrue(a.testCheckedException()); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/pom.xml b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/pom.xml new file mode 100644 index 0000000000..164c67ebbb --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/pom.xml @@ -0,0 +1,64 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + vtest-java-api + 2.0-SNAPSHOT + ../pom.xml + + java-api-apis + pom + + Apache Tuscany SCA Java APIs and Annotations Verification Tests - APIs + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + + + + default + + true + + + componentcontext + requestcontext + callablereference + servicereference + conversation + exception + + + + diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/pom.xml b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/pom.xml new file mode 100644 index 0000000000..d849fad4fe --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-apis + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-apis-requestcontext + Apache Tuscany SCA Java APIs and Annotations Verification Tests - APIs - RequestContext + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/AComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/AComponent.java new file mode 100644 index 0000000000..6fec5cada3 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/AComponent.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext; + +/** + * Simple Service A. + */ +public interface AComponent { + + public String getName(); + + public boolean isJAASSubject(); + public String getServiceName(); + public String getCallbackResult(); + public String getServiceReferenceName(); + public String getCallbackServiceReferenceName(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BCallback.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BCallback.java new file mode 100644 index 0000000000..4dd2088f90 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BCallback.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext; + +public interface BCallback { + + public String getCallbackName(); + public void processResults(String result); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java new file mode 100644 index 0000000000..d913e95a53 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext; + +import org.oasisopen.sca.annotation.Callback; + +/** + * Simple Service B. + */ +@Callback(BCallback.class) +public interface BComponent { + + public String getName(); + + public void testCallback(); + public String getServiceReferenceName(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/AComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/AComponentImpl.java new file mode 100644 index 0000000000..5d3cbf6e3d --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/AComponentImpl.java @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.impl; + +import javax.security.auth.Subject; + +import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.AComponent; +import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.BCallback; +import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.BComponent; +import org.oasisopen.sca.CallableReference; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.ServiceReference; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +@Service(AComponent.class) +public class AComponentImpl implements AComponent, BCallback { + + private static Object monitor = new Object(); + private static String returnMessage = null; + private static CallableReference 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 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 aCR = componentContext.getRequestContext().getServiceReference(); + return aCR.getService().getName(); + } + + public String getCallbackServiceReferenceName() { + return cbCR.getService().getCallbackName(); + } + + public String getCallbackName() { + return "CallBackB"; + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/BComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/BComponentImpl.java new file mode 100644 index 0000000000..d358736daa --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/BComponentImpl.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.BCallback; +import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.BComponent; +import org.junit.Assert; +import org.oasisopen.sca.CallableReference; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.annotation.Callback; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.Service; + +@Service(BComponent.class) +public class BComponentImpl implements BComponent { + + protected ComponentContext componentContext; + + @Callback + protected BCallback callback; + + @Context + public void setComponentContext(ComponentContext context) { + this.componentContext = context; + } + + public String getName() { + return "ComponentB"; + } + + public void testCallback() { + callback = componentContext.getRequestContext().getCallback(); + callback.processResults("CallBackFromB"); + + CallableReference bCR = componentContext.getRequestContext().getCallbackReference(); + Assert.assertEquals("ComponentACallBack", bCR.getCallbackID()); + } + + public String getServiceReferenceName() { + CallableReference bCR = componentContext.getRequestContext().getServiceReference(); + return bCR.getService().getName(); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/resources/requestcontext.composite b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/resources/requestcontext.composite new file mode 100644 index 0000000000..4aa5eeb25a --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/main/resources/requestcontext.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/RequestContextTestCase.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/RequestContextTestCase.java new file mode 100644 index 0000000000..e3b761bd37 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/requestcontext/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/RequestContextTestCase.java @@ -0,0 +1,109 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * This test class tests the RequestContext interface described in 1.7.2 of the + * SCA Java Annotations & APIs Specification 1.0. + */ +public class RequestContextTestCase { + + protected static String compositeName = "requestcontext.composite"; + protected static AComponent a; + protected static BComponent b; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + a = ServiceFinder.getService(AComponent.class, "AComponent"); + b = ServiceFinder.getService(BComponent.class, "BComponent"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + } + + /** + * Lines 858
+ * getSecuritySubject() – Returns the JAAS Subject of the current request. + * + * @throws Exception + */ + @Ignore("TUSCANY-2608") + public void testGetSecuritySubject() throws Exception { + Assert.assertTrue(a.isJAASSubject()); + } + + /** + * Lines 860
+ * 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
+ * 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
+ * getServiceReference() – When invoked during the execution of a service + * operation, this API MUST return a CallableReference that represents the + * service. When invoked during the execution of a callback operation, this + * API MUST return a CallableReference that represents the callback service. + * + * @throws Exception + */ + @Test + public void testGetServiceReference() throws Exception { + Assert.assertEquals("ComponentA", a.getServiceReferenceName()); + Assert.assertEquals("ComponentB", b.getServiceReferenceName()); + Assert.assertEquals("CallBackB", a.getCallbackServiceReferenceName()); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/pom.xml b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/pom.xml new file mode 100644 index 0000000000..1ad6a9c2ec --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-apis + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-apis-servicereference + Apache Tuscany SCA Java APIs and Annotations Verification Tests - APIs - ServiceReference + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/AComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/AComponent.java new file mode 100644 index 0000000000..6de5d6810e --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/AComponent.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.servicereference; + +import org.oasisopen.sca.annotation.Conversational; + +/** + * Simple Service A. + */ +@Conversational +public interface AComponent { + + public String getName(); + + public void testConversationID(); + public String getCallbackResult(); + public void redirectCallback(); + public void testGetCallback(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BCallback.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BCallback.java new file mode 100644 index 0000000000..f8c5c1272f --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BCallback.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.servicereference; + +public interface BCallback { + + public void processResults(String result); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BComponent.java new file mode 100644 index 0000000000..65a444d100 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/BComponent.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.servicereference; + +import org.oasisopen.sca.annotation.Callback; +import org.oasisopen.sca.annotation.Conversational; + +/** + * Simple Service B. + */ +@Conversational +@Callback(BCallback.class) +public interface BComponent { + + public String getName(); + + public void testCallback(); + public void testConversationID(); + public void testRedirectedCallback(); + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/CComponent.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/CComponent.java new file mode 100644 index 0000000000..28c90e2071 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/CComponent.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.servicereference; + +/** + * Simple Service C. + */ +public interface CComponent extends BCallback { + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/AComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/AComponentImpl.java new file mode 100644 index 0000000000..86dc80a4e1 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/AComponentImpl.java @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.AComponent; +import org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.BCallback; +import org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.BComponent; +import org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.CComponent; +import org.junit.Assert; +import org.oasisopen.sca.CallableReference; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.ServiceReference; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.ConversationID; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(AComponent.class) +@Scope("CONVERSATION") +public class AComponentImpl implements AComponent, BCallback { + + private static Object monitor = new Object(); + private static String returnMessage = null; + + protected ComponentContext componentContext; + + @Reference + protected CallableReference bReference; + + @Reference + protected ServiceReference cReference; + + @ConversationID + protected String cid; + + public String getName() { + return "ComponentA"; + } + + @Context + public void setComponentContext(ComponentContext context) { + this.componentContext = context; + } + + public void testConversationID() { + ServiceReference bSR = componentContext.getServiceReference(BComponent.class, "bReference"); + bSR.setConversationID("AConversationID"); + bSR.getService().testConversationID(); + + Assert.assertEquals("AConversationID", bSR.getConversation().getConversationID()); + } + + public String getCallbackResult() { + ServiceReference 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 bSR = componentContext.getServiceReference(BComponent.class, "bReference"); + bSR.setCallbackID("RedirectedCallBack"); + bSR.setCallback(cReference); + bSR.getService().testRedirectedCallback(); + } + + public void testGetCallback() { + ServiceReference bSR = componentContext.getServiceReference(BComponent.class, "bReference"); + bSR.setCallback(cReference); + Assert.assertEquals(cReference, bSR.getCallback()); + + TestObject aCallback = new TestObject(); + bSR.setCallback(aCallback); + Assert.assertEquals(aCallback, bSR.getCallback()); + Assert.assertEquals(1, ((TestObject) bSR.getCallback()).getId()); + + TestObject bCallback = new TestObject(); + bSR.setCallback(bCallback); + Assert.assertEquals(bCallback, bSR.getCallback()); + Assert.assertEquals(2, ((TestObject) bSR.getCallback()).getId()); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/BComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/BComponentImpl.java new file mode 100644 index 0000000000..c5af80291e --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/BComponentImpl.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.BCallback; +import org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.BComponent; +import org.junit.Assert; +import org.oasisopen.sca.CallableReference; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.annotation.Callback; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.ConversationID; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(BComponent.class) +@Scope("CONVERSATION") +public class BComponentImpl implements BComponent { + + protected ComponentContext componentContext; + + @Callback + protected BCallback callback; + + @ConversationID + protected String cid; + + @Context + public void setComponentContext(ComponentContext context) { + this.componentContext = context; + } + + public String getName() { + return "ComponentB"; + } + + public void testCallback() { + callback = componentContext.getRequestContext().getCallback(); + callback.processResults("CallBackFromB"); + + CallableReference 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 bCR = componentContext.getRequestContext().getCallbackReference(); + Assert.assertEquals("RedirectedCallBack", bCR.getCallbackID()); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/CComponentImpl.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/CComponentImpl.java new file mode 100644 index 0000000000..563d3ceab6 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/CComponentImpl.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.impl; + +import org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.CComponent; +import org.junit.Assert; +import org.oasisopen.sca.RequestContext; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.Service; + +@Service(CComponent.class) +public class CComponentImpl implements CComponent { + + @Context + protected RequestContext requestContext; + + public void processResults(String result) { + Assert.assertEquals("RedirectedCallBackFromB", result); + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/TestObject.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/TestObject.java new file mode 100644 index 0000000000..ba3edf13ae --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/impl/TestObject.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.servicereference.impl; + +public class TestObject { + + public static int count = 0; + + private int id; + + public TestObject() { + count++; + id = count; + } + + public int getId() { + return id; + } + +} diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/resources/servicereference.composite b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/resources/servicereference.composite new file mode 100644 index 0000000000..9bded61947 --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/main/resources/servicereference.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/ServiceReferenceTestCase.java b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/ServiceReferenceTestCase.java new file mode 100644 index 0000000000..fda917d60a --- /dev/null +++ b/sandbox/ant/sca/branches/tb3/vtest/java-api/apis/servicereference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/apis/servicereference/ServiceReferenceTestCase.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.apis.servicereference; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This test class tests the ServiceReference interface described in 1.7.4 of + * the SCA Java Annotations & APIs Specification 1.0. + */ +public class ServiceReferenceTestCase { + + protected static String compositeName = "servicereference.composite"; + protected static AComponent a; + protected static BComponent b; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + a = ServiceFinder.getService(AComponent.class, "AComponent"); + b = ServiceFinder.getService(BComponent.class, "BComponent"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + } + + /** + * Lines 915-916
+ * getConversationID() - Returns the id supplied by the user that will be + * associated with conversations initiated through this reference.
+ * 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
+ * setCallbackID(Object callbackID) – Sets the callback ID. + * + * @throws Exception + */ + @Test + public void testSetCallbackID() throws Exception { + Assert.assertEquals("CallBackFromB", a.getCallbackResult()); + } + + /** + * Lines 918
+ * getCallback() – Returns the callback object. + * + * @throws Exception + */ + @Test + public void testGetCallback() throws Exception { + a.testGetCallback(); + } + + /** + * Lines 919
+ * setCallback(Object callback) – Sets the callback object. + * + * @throws Exception + */ + @Test + public void testSetCallback() throws Exception { + a.redirectCallback(); + } + +} -- cgit v1.2.3