diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-20 09:41:17 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-20 09:41:17 +0000 |
commit | ecaed8ff741ea67c33c93cf571557db0837fa689 (patch) | |
tree | 35ded6f9b2ea3340fa8328f91539e9f648594d8f /sandbox/ant/sca/branches/tb7/itest/conversations/src | |
parent | e7b8cc1fba20b8e530c8ba89d67a6f094a2cb523 (diff) |
[maven-release-plugin] copy for branch tb7
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@756391 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
47 files changed, 4498 insertions, 0 deletions
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/Record.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/Record.java new file mode 100644 index 0000000000..a3b83dfc14 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/Record.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.itest; + +import java.io.Serializable; + +/** + * @version $Rev$ $Date$ + */ +public class Record implements Serializable { + public String id; + public String conversationId; +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/TestResult.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/TestResult.java new file mode 100644 index 0000000000..946ad93d7d --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/TestResult.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.itest; + +import java.util.Hashtable; + +/** + * @version $Rev$ $Date$ + */ +public class TestResult { + public static Hashtable<Object, Boolean> results = new Hashtable<Object, Boolean>(); + private static int completed = 0; + + public static synchronized void updateCompleted() { + ++completed; + } + + public static synchronized int getCompleted() { + return completed; + } +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/AService.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/AService.java new file mode 100644 index 0000000000..27939e3996 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/AService.java @@ -0,0 +1,56 @@ +/*
+ * 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.itest.conversational;
+
+import org.oasisopen.sca.annotation.Conversational;
+
+/**
+ * Simple conversational Service that uses another Conversational Service
+ */
+@Conversational
+public interface AService {
+
+ /**
+ * Returns the state for this service.
+ *
+ * @return The state for this service
+ */
+ String getState();
+
+ /**
+ * Returns the state for the other service that this service is using
+ *
+ * @return The state for the other service that this service is using
+ */
+ String getStateOnB();
+
+ /**
+ * Sets the state for this service.
+ *
+ * @param aState The state for this service
+ */
+ void setState(String aState);
+
+ /**
+ * Sets the state for the other service that this service is using
+ *
+ * @param aState The state for the other service that this service is using
+ */
+ void setStateOnB(String aState);
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Alpha.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Alpha.java new file mode 100644 index 0000000000..7887417e55 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Alpha.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.itest.conversational; + +import org.oasisopen.sca.annotation.OneWay; +import org.oasisopen.sca.annotation.Remotable; + +/** + * @version $Rev$ $Date$ + */ + +@Remotable +public interface Alpha { + @OneWay + void run(int param); +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/BService.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/BService.java new file mode 100644 index 0000000000..735bcee176 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/BService.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.itest.conversational;
+
+import org.oasisopen.sca.annotation.Conversational;
+
+/**
+ * Simple conversational Service
+ */
+@Conversational
+public interface BService {
+
+ /**
+ * Returns the state for this service.
+ *
+ * @return The state for this service
+ */
+ String getState();
+
+ /**
+ * Sets the state for this service.
+ *
+ * @param aState The state for this service
+ */
+ void setState(String aState);
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Beta.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Beta.java new file mode 100644 index 0000000000..1c5d2cdbb8 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Beta.java @@ -0,0 +1,31 @@ +/* + * 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.itest.conversational; + +import org.oasisopen.sca.CallableReference; +import org.oasisopen.sca.annotation.Remotable; + +/** + * @version $Rev$ $Date$ + */ + +@Remotable +public interface Beta { + CallableReference<Gamma> getRef(int param); +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java new file mode 100644 index 0000000000..cebbea0701 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.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.itest.conversational; + +import org.oasisopen.sca.annotation.Conversational; + +/** + * Simple conversational Service that uses another Conversational Service + */ +@Conversational +public interface CService { + + String getState(); + + void setState(String aState); + + Object getConversationID(); + + Object getConversationObjectConversationId(); + + void setConversationID(String theID); + + void endConversation(); + + void endConversationViaAnnotatedMethod(); +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Constants.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Constants.java new file mode 100644 index 0000000000..3f04e9f09e --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Constants.java @@ -0,0 +1,25 @@ +/*
+ * 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.itest.conversational;
+
+public interface Constants {
+
+ String A_INITIAL_VALUE = "Initial Value of A";
+ String B_INITIAL_VALUE = "Initial Value of B";
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationIdService.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationIdService.java new file mode 100644 index 0000000000..9ca4abb9d3 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationIdService.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.itest.conversational;
+
+import org.oasisopen.sca.annotation.Conversational;
+
+@Conversational
+public interface ConversationIdService {
+
+ String getCIDField();
+
+ String getCIDSetter();
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.java new file mode 100644 index 0000000000..734fb9fe7b --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.java @@ -0,0 +1,49 @@ +/*
+ * 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.itest.conversational;
+
+import org.oasisopen.sca.annotation.Conversational;
+import org.oasisopen.sca.annotation.EndsConversation;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The callback interface used when testing conversational callbacks
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
+ */
+@Remotable
+@Conversational
+public interface ConversationalCallback {
+
+ void init();
+
+ void destroy();
+
+ void initializeCount(int count);
+
+ void incrementCount();
+
+ int retrieveCount();
+
+ void businessException() throws Exception;
+
+ @EndsConversation
+ String endConversation();
+
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java new file mode 100644 index 0000000000..99f4c85d8f --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java @@ -0,0 +1,66 @@ +/*
+ * 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.itest.conversational;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The client for the conversational itest. Is implemented by clients
+ * offering both stateless and stateful callbacks
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
+ */
+
+@Remotable
+public interface ConversationalClient {
+
+ int runConversationFromInjectedReference();
+
+ int runConversationFromInjectedReference2();
+
+ int runConversationFromServiceReference();
+
+ int runConversationWithUserDefinedConversationId();
+
+ String runConversationCheckUserDefinedConversationId();
+
+ int runConversationCheckingScope();
+
+ int runConversationWithCallback();
+
+ int runConversationHavingPassedReference();
+
+ String runConversationBusinessException();
+
+ String runConversationBusinessExceptionCallback();
+
+ int runConversationCallingEndedConversation();
+
+ int runConversationCallingEndedConversationCallback();
+
+ String runConversationCallingEndedConversationCheckConversationId();
+
+ String runConversationCallingEndedConversationCallbackCheckConversationId();
+
+ int runConversationAgeTimeout();
+
+ int runConversationIdleTimeout();
+
+ int runConversationPrincipleError();
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalReferenceClient.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalReferenceClient.java new file mode 100644 index 0000000000..fb4ecb56e7 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalReferenceClient.java @@ -0,0 +1,36 @@ +/*
+ * 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.itest.conversational;
+
+import org.oasisopen.sca.CallableReference;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The client that calls into an existing conversation by accepting
+ * a reference to that conversation
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
+ */
+
+@Remotable
+public interface ConversationalReferenceClient {
+
+ void incrementCount(CallableReference<ConversationalService> conversationalService);
+
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.java new file mode 100644 index 0000000000..21a4db737e --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.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.itest.conversational;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Conversational;
+import org.oasisopen.sca.annotation.EndsConversation;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The service interface used when testing conversations
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
+ */
+@Remotable
+@Conversational
+@Callback(ConversationalCallback.class)
+public interface ConversationalService {
+
+ void init();
+
+ void destroy();
+
+ void initializeCount(int count);
+
+ void incrementCount();
+
+ int retrieveCount();
+
+ void businessException() throws Exception;
+
+ void initializeCountCallback(int count);
+
+ void incrementCountCallback();
+
+ int retrieveCountCallback();
+
+ void businessExceptionCallback() throws Exception;
+
+ @EndsConversation
+ String endConversation();
+
+ String endConversationCallback();
+
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java new file mode 100644 index 0000000000..48c1644b87 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.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.itest.conversational;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Conversational;
+import org.oasisopen.sca.annotation.EndsConversation;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The service interface used when testing conversations
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
+ */
+@Remotable
+@Conversational
+@Callback(NonConversationalCallback.class)
+public interface ConversationalServiceNonConversationalCallback {
+
+ void init();
+
+ void destroy();
+
+ void initializeCount(int count);
+
+ void incrementCount();
+
+ int retrieveCount();
+
+ void businessException() throws Exception;
+
+ void initializeCountCallback(int count);
+
+ void incrementCountCallback();
+
+ int retrieveCountCallback();
+
+ void businessExceptionCallback() throws Exception;
+
+ @EndsConversation
+ String endConversation();
+
+ String endConversationCallback();
+
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java new file mode 100644 index 0000000000..2c205c2cae --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java @@ -0,0 +1,46 @@ +/* + * 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.itest.conversational; + +import org.oasisopen.sca.annotation.Conversational; +import org.oasisopen.sca.annotation.EndsConversation; + +/** + * Simple conversational Service + */ +@Conversational +public interface DService { + + /** + * Returns the state for this service. + * + * @return The state for this service + */ + String getState(); + + /** + * Sets the state for this service. + * + * @param aState The state for this service + */ + void setState(String aState); + + @EndsConversation + void endConversationViaAnnotatedMethod(); +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Gamma.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Gamma.java new file mode 100644 index 0000000000..48c203ab35 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/Gamma.java @@ -0,0 +1,41 @@ +/* + * 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.itest.conversational; + +import org.apache.tuscany.sca.itest.Record; +import org.oasisopen.sca.annotation.Conversational; +import org.oasisopen.sca.annotation.EndsConversation; +import org.oasisopen.sca.annotation.Remotable; + +/** + * @version $Rev$ $Date$ + */ + +@Remotable +@Conversational +public interface Gamma { + void start(int param); + + boolean hasNext(); + + Record next(); + + @EndsConversation + void stop(); +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java new file mode 100644 index 0000000000..614c0a96b5 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java @@ -0,0 +1,45 @@ +/*
+ * 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.itest.conversational;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The callback interface used when testing conversational callbacks
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
+ */
+@Remotable
+public interface NonConversationalCallback {
+
+ void init();
+
+ void destroy();
+
+ void initializeCount(int count);
+
+ void incrementCount();
+
+ int retrieveCount();
+
+ void businessException() throws Exception;
+
+ String endConversation();
+
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/AServiceImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/AServiceImpl.java new file mode 100644 index 0000000000..86a96aaa75 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/AServiceImpl.java @@ -0,0 +1,108 @@ +/*
+ * 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.itest.conversational.impl;
+
+import org.apache.tuscany.sca.itest.conversational.AService;
+import org.apache.tuscany.sca.itest.conversational.BService;
+import org.apache.tuscany.sca.itest.conversational.Constants;
+import org.oasisopen.sca.annotation.ConversationID;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Simple conversational Service that uses another Conversational Service
+ */
+@Service(AService.class)
+@Scope("CONVERSATION")
+public class AServiceImpl implements AService {
+
+ /**
+ * The state
+ */
+ private String state = Constants.A_INITIAL_VALUE;
+
+ /**
+ * The reference to the other service
+ */
+ private BService b;
+
+ /**
+ * Constructor
+ *
+ */
+ public AServiceImpl() {
+ System.out.println("---> AServiceImpl constructor for " + this);
+ }
+
+ /**
+ * Inject the reference to the other service
+ * @param aB The other service.
+ */
+ @Reference(name = "b")
+ public void setB(BService aB) {
+ System.out.println("---> Setting reference to B on " + this + " to " + aB);
+ this.b = aB;
+ }
+
+ /**
+ * Returns the state for this service.
+ *
+ * @return The state for this service
+ */
+ public String getState() {
+ return state;
+ }
+
+ /**
+ * Returns the state for the other service that this service is using
+ *
+ * @return The state for the other service that this service is using
+ */
+ public String getStateOnB() {
+ return b.getState();
+ }
+
+ /**
+ * Sets the state for this service.
+ *
+ * @param aState The state for this service
+ */
+ public void setState(String aState) {
+ this.state = aState;
+ }
+
+ /**
+ * Sets the state for the other service that this service is using
+ *
+ * @param aState The state for the other service that this service is using
+ */
+ public void setStateOnB(String aState) {
+ b.setState(aState);
+ }
+
+ /**
+ * Sets the conversation ID for this service
+ * @param id The Conversation ID
+ */
+ @ConversationID
+ public void setConversationID(String id) {
+ System.out.println("Conversation ID for " + this + " is set to " + id);
+ }
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/AlphaImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/AlphaImpl.java new file mode 100644 index 0000000000..b56186ea88 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/AlphaImpl.java @@ -0,0 +1,69 @@ +/* + * 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.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.Record; +import org.apache.tuscany.sca.itest.TestResult; +import org.apache.tuscany.sca.itest.conversational.Alpha; +import org.apache.tuscany.sca.itest.conversational.Beta; +import org.apache.tuscany.sca.itest.conversational.Gamma; +import org.oasisopen.sca.CallableReference; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +/** + * @version $Rev$ $Date$ + */ + +@Service(Alpha.class) +@Scope("COMPOSITE") +public class AlphaImpl implements Alpha { + @Reference + public Beta beta; + + @Context + protected ComponentContext componentContext; + + public void run(int param) { + CallableReference<Gamma> gammaRef = null; + boolean testPassed = true; + try { + gammaRef = beta.getRef(param); + while (gammaRef.getService().hasNext()) { + Record record = gammaRef.getService().next(); + if (!record.conversationId.equals(gammaRef.getConversation().getConversationID())) { + // Record returned is not from this conversation. + testPassed = false; + } + } + } catch (Exception ex) { + testPassed = false; + ex.printStackTrace(); + } finally { + TestResult.updateCompleted(); + if (gammaRef != null) { + TestResult.results.put(gammaRef.getConversation().getConversationID(), testPassed); + gammaRef.getService().stop(); + } + } + } +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/BServiceImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/BServiceImpl.java new file mode 100644 index 0000000000..f394770ffc --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/BServiceImpl.java @@ -0,0 +1,72 @@ +/*
+ * 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.itest.conversational.impl;
+
+import org.apache.tuscany.sca.itest.conversational.BService;
+import org.apache.tuscany.sca.itest.conversational.Constants;
+import org.oasisopen.sca.annotation.ConversationID;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Simple conversational Service
+ */
+@Service(BService.class)
+@Scope("CONVERSATION")
+public class BServiceImpl implements BService {
+
+ /**
+ * The state for this service
+ */
+ private String state = Constants.B_INITIAL_VALUE;
+
+ /**
+ * Constructor
+ */
+ public BServiceImpl() {
+ System.out.println("---> BServiceImpl constructor for " + this);
+ }
+
+ /**
+ * Returns the state for this service.
+ *
+ * @return The state for this service
+ */
+ public String getState() {
+ return state;
+ }
+
+ /**
+ * Sets the state for this service.
+ *
+ * @param aState The state for this service
+ */
+ public void setState(String aState) {
+ this.state = aState;
+ }
+
+ /**
+ * Sets the conversation ID for this service
+ * @param id The Conversation ID
+ */
+ @ConversationID
+ public void setConversationID(String id) {
+ System.out.println("Conversation ID for " + this + " is set to " + id);
+ }
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/BetaImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/BetaImpl.java new file mode 100644 index 0000000000..b94e8a6452 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/BetaImpl.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.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.Beta; +import org.apache.tuscany.sca.itest.conversational.Gamma; +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.Scope; +import org.oasisopen.sca.annotation.Service; + +/** + * @version $Rev$ $Date$ + */ + +@Service(Beta.class) +@Scope("COMPOSITE") +public class BetaImpl implements Beta { + @Context + protected ComponentContext componentContext; + + @Reference + public Gamma gamma; + + public CallableReference<Gamma> getRef(int param) { + ServiceReference<Gamma> gammaRef = componentContext.getServiceReference(Gamma.class, "gamma"); + Gamma g = gammaRef.getService(); + g.start(param); + return gammaRef; + } +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java new file mode 100644 index 0000000000..737c2940dd --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java @@ -0,0 +1,84 @@ +/* + * 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.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.CService; +import org.apache.tuscany.sca.itest.conversational.DService; +import org.oasisopen.sca.ServiceReference; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +/** + * Simple conversational Service that uses another Conversational Service + */ +@Service(CService.class) +@Scope("CONVERSATION") +public class CServiceImpl implements CService { + + private ServiceReference<DService> dServiceRef; + + @Reference(name = "d") + public void setD(ServiceReference<DService> servRef) { + this.dServiceRef = servRef; + } + + public String getState() { + return dServiceRef.getService().getState(); + } + + public void setState(String aState) { + dServiceRef.getService().setState(aState); + } + + /* + * When the coversationId is set manually the client may access the + * conversation id that will be used by the reference using + * ServiceReference.getConversationId() + */ + public Object getConversationID() { + return dServiceRef.getConversationID(); + } + + /* + * Whether the conversation ID is chosen by the client or is generated by + * the system, the client may access the conversation ID by calling + * Conversation.getConversationID(). + */ + public Object getConversationObjectConversationId() { + // TODO Auto-generated method stub + if (dServiceRef.getConversation() != null) { + return dServiceRef.getConversation().getConversationID(); + } else { + return null; + } + } + + public void endConversation() { + dServiceRef.getConversation().end(); + } + + public void endConversationViaAnnotatedMethod() { + dServiceRef.getService().endConversationViaAnnotatedMethod(); + } + + public void setConversationID(String theID) { + dServiceRef.setConversationID(theID); + } +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java new file mode 100644 index 0000000000..8f2736ad2d --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java @@ -0,0 +1,75 @@ +/* + * 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.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.oasisopen.sca.annotation.ConversationAttributes; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(ConversationalService.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxAge = "1 seconds") +public class ConversationAgeComponentImpl implements ConversationalService { + + private int count; + + public void businessException() throws Exception { + } + + public void businessExceptionCallback() throws Exception { + } + + public void destroy() { + } + + public String endConversation() { + return null; + } + + public String endConversationCallback() { + return null; + } + + public void incrementCount() { + } + + public void incrementCountCallback() { + } + + public void init() { + } + + public void initializeCount(int count) { + this.count = count; + } + + public void initializeCountCallback(int count) { + } + + public int retrieveCount() { + return count; + } + + public int retrieveCountCallback() { + return 0; + } + +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdComponentImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdComponentImpl.java new file mode 100644 index 0000000000..8b3a8663d8 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdComponentImpl.java @@ -0,0 +1,48 @@ +/* + * 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.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationIdService; +import org.oasisopen.sca.annotation.ConversationID; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(ConversationIdService.class) +@Scope("CONVERSATION") +public class ConversationIdComponentImpl implements ConversationIdService { + + @ConversationID + public String cid; + + private String setterCid; + + public String getCIDField() { + return cid; + } + + public String getCIDSetter() { + return setterCid; + } + + @ConversationID + public void setCID(String cid) { + this.setterCid = cid; + } +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java new file mode 100644 index 0000000000..ae8bee8040 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java @@ -0,0 +1,75 @@ +/* + * 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.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.oasisopen.sca.annotation.ConversationAttributes; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(ConversationalService.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxIdleTime = "1 seconds") +public class ConversationMaxIdleComponentImpl implements ConversationalService { + + private int count; + + public void businessException() throws Exception { + } + + public void businessExceptionCallback() throws Exception { + } + + public void destroy() { + } + + public String endConversation() { + return null; + } + + public String endConversationCallback() { + return null; + } + + public void incrementCount() { + } + + public void incrementCountCallback() { + } + + public void init() { + } + + public void initializeCount(int count) { + this.count = count; + } + + public void initializeCountCallback(int count) { + } + + public int retrieveCount() { + return count; + } + + public int retrieveCountCallback() { + return 0; + } + +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.java new file mode 100644 index 0000000000..3784dfd53e --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.java @@ -0,0 +1,325 @@ +/*
+ * 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.itest.conversational.impl;
+
+import org.apache.tuscany.sca.itest.conversational.ConversationalCallback;
+import org.apache.tuscany.sca.itest.conversational.ConversationalClient;
+import org.apache.tuscany.sca.itest.conversational.ConversationalReferenceClient;
+import org.apache.tuscany.sca.itest.conversational.ConversationalService;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.ConversationAttributes;
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * The client for the conversational itest which presents a stateful
+ * callback interface
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
+ */
+
+@Service(interfaces = {ConversationalClient.class})
+@Scope("CONVERSATION")
+@ConversationAttributes(maxAge = "10 minutes", maxIdleTime = "5 minutes", singlePrincipal = false)
+public class ConversationalClientStatefulImpl implements ConversationalClient, ConversationalCallback {
+
+ @Context
+ protected ComponentContext componentContext;
+
+ @Reference
+ protected ConversationalService conversationalService;
+
+ @Reference
+ protected ConversationalService conversationalService2;
+
+ @Reference
+ protected ConversationalReferenceClient conversationalReferenceClient;
+
+ private int clientCount = 0;
+ private int callbackCount = 0;
+
+ // a static member variable that records the number of times this service is called
+ public static StringBuffer calls = new StringBuffer();
+
+ // From ConversationalClient
+ public int runConversationFromInjectedReference() {
+ calls.append("runConversationFromInjectedReference,");
+ conversationalService.initializeCount(1);
+ conversationalService.incrementCount();
+ clientCount = conversationalService.retrieveCount();
+ conversationalService.endConversation();
+
+ return clientCount;
+ }
+
+ public int runConversationFromInjectedReference2() {
+ calls.append("runConversationFromInjectedReference2,");
+
+ conversationalService2.initializeCount(1);
+ conversationalService2.incrementCount();
+
+ // stick in a call to the first reference to
+ // make sure the two references don't clash
+ conversationalService.initializeCount(1);
+
+ clientCount = conversationalService2.retrieveCount();
+ conversationalService2.endConversation();
+
+ // end the conversation through the first reference
+ conversationalService.endConversation();
+
+ return clientCount;
+ }
+
+ public int runConversationFromServiceReference() {
+ calls.append("runConversationFromServiceReference,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversation();
+
+ // serviceReference.getConversation().end();
+
+ return clientCount;
+ }
+
+ public int runConversationWithUserDefinedConversationId() {
+ calls.append("runConversationWithUserDefinedConversationId,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ serviceReference.setConversationID("MyConversation1");
+
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversation();
+
+ // serviceReference.getConversation().end();
+
+ return clientCount;
+ }
+
+ public String runConversationCheckUserDefinedConversationId() {
+ calls.append("runConversationCheckUserDefinedConversationId,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ serviceReference.setConversationID("MyConversation2");
+
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+
+ String clientConversationId = serviceReference.getConversationID().toString();
+ String serverConversationId = callableReference.endConversation();
+
+ if (clientConversationId.equals("MyConversation2") && serverConversationId.equals("MyConversation2")) {
+ return clientConversationId;
+ } else {
+ return "client = " + clientConversationId + "server = " + serverConversationId;
+ }
+
+ }
+
+ public int runConversationCheckingScope() {
+ calls.append("runConversationCheckingScope,");
+ // run a conversation
+ return runConversationFromInjectedReference();
+
+ // test will then use a static method to find out how many times
+ // init/destroy were called
+ }
+
+ public int runConversationWithCallback() {
+ calls.append("runConversationWithCallback,");
+ callbackCount = 2;
+ conversationalService.initializeCountCallback(1);
+ conversationalService.incrementCountCallback();
+ clientCount = conversationalService.retrieveCountCallback();
+ conversationalService.endConversationCallback();
+
+ return clientCount;
+ }
+
+ public int runConversationHavingPassedReference() {
+ calls.append("runConversationHavingPassedReference,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ conversationalReferenceClient.incrementCount(serviceReference);
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversation();
+
+ serviceReference.getConversation().end();
+
+ return clientCount;
+ }
+
+ public String runConversationBusinessException() {
+ calls.append("runConversationbusinessException,");
+ try {
+ conversationalService.initializeCount(1);
+ conversationalService.businessException();
+ clientCount = conversationalService.retrieveCount();
+ conversationalService.endConversation();
+ } catch (Exception ex) {
+ return ex.getMessage();
+ }
+
+ return "No Exception Returned";
+ }
+
+ public String runConversationBusinessExceptionCallback() {
+ calls.append("runConversationbusinessExceptionCallback,");
+ try {
+ conversationalService.initializeCountCallback(1);
+ conversationalService.businessExceptionCallback();
+ clientCount = conversationalService.retrieveCountCallback();
+ conversationalService.endConversationCallback();
+ } catch (Exception ex) {
+ return ex.getMessage();
+ }
+
+ return "No Exception Returned";
+ }
+
+ public int runConversationCallingEndedConversation() {
+ calls.append("runConversationCallingEndedConversation,");
+ conversationalService.initializeCount(1);
+ conversationalService.endConversation();
+ return conversationalService.retrieveCount();
+ }
+
+ public int runConversationCallingEndedConversationCallback() {
+ calls.append("runConversationCallingEndedConversationCallback,");
+ conversationalService.initializeCountCallback(1);
+ conversationalService.endConversationCallback();
+ return conversationalService.retrieveCountCallback();
+ }
+
+ public String runConversationCallingEndedConversationCheckConversationId() {
+ calls.append("runConversationCallingEndedConversationCheckConversationId,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ serviceReference.setConversationID("MyConversation3");
+
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversation();
+
+ if (serviceReference.getConversation() == null) {
+ return null;
+ } else {
+ return serviceReference.getConversation().getConversationID().toString();
+ }
+ }
+
+ public String runConversationCallingEndedConversationCallbackCheckConversationId() {
+ calls.append("runConversationCallingEndedConversationCallbackCheckConversationId,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ serviceReference.setConversationID("MyConversation3");
+
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversationCallback();
+
+ if (serviceReference.getConversation() == null) {
+ return null;
+ } else {
+ return serviceReference.getConversation().getConversationID().toString();
+ }
+ }
+
+ public int runConversationAgeTimeout() {
+ calls.append("runConversationAgeTimeout,");
+ // done in other testing
+ return clientCount;
+ }
+
+ public int runConversationIdleTimeout() {
+ calls.append("runConversationIdleTimeout,");
+ // done in other testing
+ return clientCount;
+ }
+
+ public int runConversationPrincipleError() {
+ calls.append("runConversationPrincipleError,");
+ // TODO - when policy framework is done
+ return clientCount;
+ }
+
+ // From ConversationalCallback
+ @Init
+ public void init() {
+ calls.append("init,");
+ }
+
+ @Destroy
+ public void destroy() {
+ calls.append("destroy,");
+ }
+
+ public void initializeCount(int count) {
+ calls.append("initializeCount,");
+ callbackCount += count;
+ }
+
+ public void incrementCount() {
+ calls.append("incrementCount,");
+ callbackCount++;
+ }
+
+ public int retrieveCount() {
+ calls.append("retrieveCount,");
+ return callbackCount;
+ }
+
+ public void businessException() throws Exception {
+ throw new Exception("Business Exception");
+ }
+
+ public String endConversation() {
+ calls.append("endConversation,");
+ callbackCount = 0;
+ return null;
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java new file mode 100644 index 0000000000..137dfc4108 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java @@ -0,0 +1,317 @@ +/*
+ * 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.itest.conversational.impl;
+
+import org.apache.tuscany.sca.itest.conversational.ConversationalClient;
+import org.apache.tuscany.sca.itest.conversational.ConversationalReferenceClient;
+import org.apache.tuscany.sca.itest.conversational.ConversationalService;
+import org.apache.tuscany.sca.itest.conversational.NonConversationalCallback;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.ConversationAttributes;
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * The client for the conversational itest which presents a stateful
+ * callback interface
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
+ */
+
+@Service(interfaces = {ConversationalClient.class})
+@Scope("CONVERSATION")
+@ConversationAttributes(maxAge = "10 minutes", maxIdleTime = "5 minutes", singlePrincipal = false)
+public class ConversationalClientStatefulNonConversationalCallbackImpl implements ConversationalClient,
+ NonConversationalCallback {
+
+ @Context
+ protected ComponentContext componentContext;
+
+ @Reference
+ protected ConversationalService conversationalService;
+
+ @Reference
+ protected ConversationalService conversationalService2;
+
+ @Reference
+ protected ConversationalReferenceClient conversationalReferenceClient;
+
+ private int clientCount = 0;
+ private int callbackCount = 0;
+
+ // a static member variable that records the number of times this service is called
+ public static StringBuffer calls = new StringBuffer();
+
+ // From ConversationalClient
+ public int runConversationFromInjectedReference() {
+ calls.append("runConversationFromInjectedReference,");
+ conversationalService.initializeCount(1);
+ conversationalService.incrementCount();
+ clientCount = conversationalService.retrieveCount();
+ conversationalService.endConversation();
+
+ return clientCount;
+ }
+
+ public int runConversationFromInjectedReference2() {
+ calls.append("runConversationFromInjectedReference2,");
+
+ conversationalService2.initializeCount(1);
+ conversationalService2.incrementCount();
+
+ // stick in a call to the first reference to
+ // make sure the two references don't clash
+ conversationalService.initializeCount(1);
+
+ clientCount = conversationalService2.retrieveCount();
+ conversationalService2.endConversation();
+
+ // end the conversation through the first reference
+ conversationalService.endConversation();
+
+ return clientCount;
+ }
+
+ public int runConversationFromServiceReference() {
+ calls.append("runConversationFromServiceReference,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversation();
+
+ // serviceReference.getConversation().end();
+
+ return clientCount;
+ }
+
+ public int runConversationWithUserDefinedConversationId() {
+ calls.append("runConversationWithUserDefinedConversationId,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ serviceReference.setConversationID("MyConversation1");
+
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversation();
+
+ // serviceReference.getConversation().end();
+
+ return clientCount;
+ }
+
+ public String runConversationCheckUserDefinedConversationId() {
+ calls.append("runConversationCheckUserDefinedConversationId,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ serviceReference.setConversationID("MyConversation2");
+
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+ return callableReference.endConversation();
+
+ }
+
+ public int runConversationCheckingScope() {
+ calls.append("runConversationCheckingScope,");
+ // run a conversation
+ return runConversationFromInjectedReference();
+
+ // test will then use a static method to find out how many times
+ // init/destroy were called
+ }
+
+ public int runConversationWithCallback() {
+ calls.append("runConversationWithCallback,");
+ callbackCount = 2;
+ conversationalService.initializeCountCallback(1);
+ conversationalService.incrementCountCallback();
+ clientCount = conversationalService.retrieveCountCallback();
+ conversationalService.endConversationCallback();
+
+ return clientCount;
+ }
+
+ public int runConversationHavingPassedReference() {
+ calls.append("runConversationHavingPassedReference,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ conversationalReferenceClient.incrementCount(serviceReference);
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversation();
+
+ // serviceReference.getConversation().end();
+
+ return clientCount;
+ }
+
+ public String runConversationBusinessException() {
+ calls.append("runConversationbusinessException,");
+ try {
+ conversationalService.initializeCount(1);
+ conversationalService.businessException();
+ clientCount = conversationalService.retrieveCount();
+ conversationalService.endConversation();
+ } catch (Exception ex) {
+ return ex.getMessage();
+ }
+
+ return "No Exception Returned";
+ }
+
+ public String runConversationBusinessExceptionCallback() {
+ calls.append("runConversationbusinessExceptionCallback,");
+ try {
+ conversationalService.initializeCountCallback(1);
+ conversationalService.businessExceptionCallback();
+ clientCount = conversationalService.retrieveCountCallback();
+ conversationalService.endConversationCallback();
+ } catch (Exception ex) {
+ return ex.getMessage();
+ }
+
+ return "No Exception Returned";
+ }
+
+ public String runConversationCallingEndedConversationCheckConversationId() {
+ calls.append("runConversationCallingEndedConversationCheckConversationId,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ serviceReference.setConversationID("MyConversation3");
+
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversation();
+
+ if (serviceReference.getConversation() == null) {
+ return null;
+ } else {
+ return serviceReference.getConversation().getConversationID().toString();
+ }
+ }
+
+ public String runConversationCallingEndedConversationCallbackCheckConversationId() {
+ calls.append("runConversationCallingEndedConversationCallbackCheckConversationId,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ serviceReference.setConversationID("MyConversation3");
+
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversationCallback();
+
+ if (serviceReference.getConversation() == null) {
+ return null;
+ } else {
+ return serviceReference.getConversation().getConversationID().toString();
+ }
+ }
+
+ public int runConversationCallingEndedConversation() {
+ calls.append("runConversationCallingEndedConversation,");
+ conversationalService.initializeCount(1);
+ conversationalService.endConversation();
+ return conversationalService.retrieveCount();
+ }
+
+ public int runConversationCallingEndedConversationCallback() {
+ calls.append("runConversationCallingEndedConversationCallback,");
+ conversationalService.initializeCountCallback(1);
+ conversationalService.endConversationCallback();
+ return conversationalService.retrieveCountCallback();
+ }
+
+ public int runConversationAgeTimeout() {
+ calls.append("runConversationAgeTimeout,");
+ // done in other testing
+ return clientCount;
+ }
+
+ public int runConversationIdleTimeout() {
+ calls.append("runConversationIdleTimeout,");
+ // done in other testing
+ return clientCount;
+ }
+
+ public int runConversationPrincipleError() {
+ calls.append("runConversationPrincipleError,");
+ // TODO - when policy framework is done
+ return clientCount;
+ }
+
+ // From ConversationalCallback
+ @Init
+ public void init() {
+ calls.append("init,");
+ }
+
+ @Destroy
+ public void destroy() {
+ calls.append("destroy,");
+ }
+
+ public void initializeCount(int count) {
+ calls.append("initializeCount,");
+ callbackCount += count;
+ }
+
+ public void incrementCount() {
+ calls.append("incrementCount,");
+ callbackCount++;
+ }
+
+ public int retrieveCount() {
+ calls.append("retrieveCount,");
+ return callbackCount;
+ }
+
+ public void businessException() throws Exception {
+ throw new Exception("Business Exception");
+ }
+
+ public String endConversation() {
+ calls.append("endConversation,");
+ return null;
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java new file mode 100644 index 0000000000..c9c5138515 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java @@ -0,0 +1,322 @@ +/*
+ * 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.itest.conversational.impl;
+
+import org.apache.tuscany.sca.itest.conversational.ConversationalCallback;
+import org.apache.tuscany.sca.itest.conversational.ConversationalClient;
+import org.apache.tuscany.sca.itest.conversational.ConversationalReferenceClient;
+import org.apache.tuscany.sca.itest.conversational.ConversationalService;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * The client for the conversational itest which presents a stateful
+ * callback interface
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
+ */
+
+@Service(interfaces = {ConversationalClient.class})
+public class ConversationalClientStatelessImpl implements ConversationalClient, ConversationalCallback {
+
+ @Context
+ protected ComponentContext componentContext;
+
+ @Reference
+ protected ConversationalService conversationalService;
+
+ @Reference
+ protected ConversationalService conversationalService2;
+
+ @Reference
+ protected ConversationalReferenceClient conversationalReferenceClient;
+
+ private int clientCount = 0;
+ private int callbackCount = 0;
+
+ // a static member variable that records the number of times this service is called
+ public static StringBuffer calls = new StringBuffer();
+
+ // From ConversationalClient
+ public int runConversationFromInjectedReference() {
+ calls.append("runConversationFromInjectedReference,");
+ conversationalService.initializeCount(1);
+ conversationalService.incrementCount();
+ clientCount = conversationalService.retrieveCount();
+ conversationalService.endConversation();
+
+ return clientCount;
+ }
+
+ public int runConversationFromInjectedReference2() {
+ calls.append("runConversationFromInjectedReference2,");
+
+ // now test the second reference
+ conversationalService2.initializeCount(1);
+ conversationalService2.incrementCount();
+
+ // stick in a call to the first reference to
+ // make sure the two references don't clash
+ conversationalService.initializeCount(1);
+
+ clientCount = conversationalService2.retrieveCount();
+ conversationalService2.endConversation();
+
+ // end the conversation through the first reference
+ conversationalService.endConversation();
+
+ return clientCount;
+ }
+
+ public int runConversationFromServiceReference() {
+ calls.append("runConversationFromServiceReference,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversation();
+
+ // serviceReference.getConversation().end();
+
+ return clientCount;
+ }
+
+ public int runConversationWithUserDefinedConversationId() {
+ calls.append("runConversationWithUserDefinedConversationId,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ serviceReference.setConversationID("MyConversation1");
+
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversation();
+
+ // serviceReference.getConversation().end();
+
+ return clientCount;
+ }
+
+ public String runConversationCheckUserDefinedConversationId() {
+ calls.append("runConversationCheckUserDefinedConversationId,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ serviceReference.setConversationID("MyConversation2");
+
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+
+ String clientConversationId = serviceReference.getConversationID().toString();
+ String serverConfersationId = callableReference.endConversation();
+
+ if (clientConversationId.equals("MyConversation2") && serverConfersationId.equals("MyConversation2")) {
+ return clientConversationId;
+ } else {
+ return "client = " + clientConversationId + "server = " + serverConfersationId;
+ }
+ }
+
+ public int runConversationCheckingScope() {
+ calls.append("runConversationCheckingScope,");
+ // run a conversation
+ return runConversationFromInjectedReference();
+
+ // test will then use a static method to find out how many times
+ // init/destroy were called
+ }
+
+ public int runConversationWithCallback() {
+ calls.append("runConversationWithCallback,");
+ conversationalService.initializeCountCallback(1);
+ conversationalService.incrementCountCallback();
+ clientCount = conversationalService.retrieveCountCallback();
+ conversationalService.endConversationCallback();
+
+ return clientCount;
+ }
+
+ public int runConversationHavingPassedReference() {
+ calls.append("runConversationHavingPassedReference,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ conversationalReferenceClient.incrementCount(serviceReference);
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversation();
+
+ serviceReference.getConversation().end();
+
+ return clientCount;
+ }
+
+ public String runConversationBusinessException() {
+ calls.append("runConversationbusinessException,");
+ try {
+ conversationalService.initializeCount(1);
+ conversationalService.businessException();
+ clientCount = conversationalService.retrieveCount();
+ conversationalService.endConversation();
+ } catch (Exception ex) {
+ return ex.getMessage();
+ }
+
+ return "No Exception Returned";
+ }
+
+ public String runConversationBusinessExceptionCallback() {
+ calls.append("runConversationbusinessExceptionCallback,");
+ try {
+ conversationalService.initializeCountCallback(1);
+ conversationalService.businessExceptionCallback();
+ clientCount = conversationalService.retrieveCountCallback();
+ conversationalService.endConversationCallback();
+ } catch (Exception ex) {
+ return ex.getMessage();
+ }
+
+ return "No Exception Returned";
+ }
+
+ public int runConversationCallingEndedConversation() {
+ calls.append("runConversationCallingEndedConversation,");
+ conversationalService.initializeCount(1);
+ conversationalService.endConversation();
+ return conversationalService.retrieveCount();
+ }
+
+ public int runConversationCallingEndedConversationCallback() {
+ calls.append("runConversationCallingEndedConversationCallback,");
+ conversationalService.initializeCountCallback(1);
+ conversationalService.endConversationCallback();
+ return conversationalService.retrieveCountCallback();
+ }
+
+ public String runConversationCallingEndedConversationCheckConversationId() {
+ calls.append("runConversationCallingEndedConversationCheckConversationId,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ serviceReference.setConversationID("MyConversation3");
+
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversation();
+
+ if (serviceReference.getConversation() == null) {
+ return null;
+ } else {
+ return serviceReference.getConversation().getConversationID().toString();
+ }
+ }
+
+ public String runConversationCallingEndedConversationCallbackCheckConversationId() {
+ calls.append("runConversationCallingEndedConversationCallbackCheckConversationId,");
+ ServiceReference<ConversationalService> serviceReference =
+ componentContext.getServiceReference(ConversationalService.class, "conversationalService");
+ serviceReference.setConversationID("MyConversation3");
+
+ ConversationalService callableReference = serviceReference.getService();
+
+ callableReference.initializeCount(1);
+ callableReference.incrementCount();
+ clientCount = callableReference.retrieveCount();
+ callableReference.endConversationCallback();
+
+ if (serviceReference.getConversation() == null) {
+ return null;
+ } else {
+ return serviceReference.getConversation().getConversationID().toString();
+ }
+ }
+
+ public int runConversationAgeTimeout() {
+ calls.append("runConversationAgeTimeout,");
+ // done in other testing
+ return clientCount;
+ }
+
+ public int runConversationIdleTimeout() {
+ calls.append("runConversationIdleTimeout,");
+ // done in other testing
+ return clientCount;
+ }
+
+ public int runConversationPrincipleError() {
+ calls.append("runConversationPrincipleError,");
+ // TODO - when policy framework is done
+ return clientCount;
+ }
+
+ // From ConversationalCallback
+ @Init
+ public void init() {
+ calls.append("init,");
+
+ }
+
+ @Destroy
+ public void destroy() {
+ calls.append("destroy,");
+
+ }
+
+ public void initializeCount(int count) {
+ calls.append("initializeCount,");
+ callbackCount = 0;
+ }
+
+ public void incrementCount() {
+ calls.append("incrementCount,");
+ callbackCount++;
+ }
+
+ public int retrieveCount() {
+ calls.append("retrieveCount,");
+ return callbackCount;
+ }
+
+ public void businessException() throws Exception {
+ throw new Exception("Business Exception");
+ }
+
+ public String endConversation() {
+ calls.append("endConversation,");
+ callbackCount = 0;
+ return null;
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.java new file mode 100644 index 0000000000..134ffda75d --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.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.itest.conversational.impl;
+
+import org.apache.tuscany.sca.itest.conversational.ConversationalReferenceClient;
+import org.apache.tuscany.sca.itest.conversational.ConversationalService;
+import org.oasisopen.sca.CallableReference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * A client component that accepts a reference to an ongoing conversation
+ * and takes part in that conversation
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
+ */
+
+@Service(interfaces = {ConversationalReferenceClient.class})
+public class ConversationalReferenceClientImpl implements ConversationalReferenceClient {
+
+ public void incrementCount(CallableReference<ConversationalService> conversationalService) {
+ ConversationalService callableReference = conversationalService.getService();
+
+ callableReference.incrementCount();
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java new file mode 100644 index 0000000000..73a6d7d27e --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java @@ -0,0 +1,122 @@ +/*
+ * 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.itest.conversational.impl;
+
+import java.util.HashMap;
+
+import org.apache.tuscany.sca.itest.conversational.ConversationalCallback;
+import org.apache.tuscany.sca.itest.conversational.ConversationalService;
+import org.oasisopen.sca.annotation.Callback;
+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;
+
+/**
+ * The service used when testing stateful conversations
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
+ */
+@Service(ConversationalService.class)
+@Scope("REQUEST")
+public class ConversationalServiceRequestImpl implements ConversationalService {
+
+ @ConversationID
+ protected String conversationId;
+
+ @Callback
+ protected ConversationalCallback conversationalCallback;
+
+ // static area in which to hold conversational data
+ private static HashMap<String, Integer> conversationalState = new HashMap<String, Integer>();
+
+ // a static member variable that records the number of times this service is called
+ public static StringBuffer calls = new StringBuffer();
+
+ @Init
+ public void init() {
+ calls.append("init,");
+ }
+
+ @Destroy
+ public void destroy() {
+ calls.append("destroy,");
+ }
+
+ public void initializeCount(int count) {
+ calls.append("initializeCount,");
+ Integer conversationalCount = Integer.valueOf(count);
+ conversationalState.put(conversationId, conversationalCount);
+ }
+
+ public void incrementCount() {
+ calls.append("incrementCount,");
+ Integer conversationalCount = conversationalState.get(conversationId);
+ conversationalCount++;
+ conversationalState.put(conversationId, conversationalCount);
+ }
+
+ public int retrieveCount() {
+ calls.append("retrieveCount,");
+ Integer count = conversationalState.get(conversationId);
+ if (count != null) {
+ return count.intValue();
+ } else {
+ return -999;
+ }
+ }
+
+ public void businessException() throws Exception {
+ throw new Exception("Business Exception");
+ }
+
+ public void initializeCountCallback(int count) {
+ calls.append("initializeCountCallback,");
+ initializeCount(count);
+ conversationalCallback.initializeCount(count);
+ }
+
+ public void incrementCountCallback() {
+ calls.append("incrementCountCallback,");
+ incrementCount();
+ conversationalCallback.incrementCount();
+ }
+
+ public int retrieveCountCallback() {
+ calls.append("retrieveCountCallback,");
+ return conversationalCallback.retrieveCount();
+ }
+
+ public void businessExceptionCallback() throws Exception {
+ calls.append("businessExceptionCallback,");
+ conversationalCallback.businessException();
+ }
+
+ public String endConversation() {
+ calls.append("endConversation,");
+ conversationalState.remove(conversationId);
+ return conversationId;
+ }
+
+ public String endConversationCallback() {
+ calls.append("endConversationCallback,");
+ return conversationalCallback.endConversation();
+ }
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java new file mode 100644 index 0000000000..5bafa5e075 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java @@ -0,0 +1,114 @@ +/*
+ * 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.itest.conversational.impl;
+
+import org.apache.tuscany.sca.itest.conversational.ConversationalCallback;
+import org.apache.tuscany.sca.itest.conversational.ConversationalService;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.ConversationAttributes;
+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;
+
+/**
+ * The service used when testing stateful conversations
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
+ */
+@Service(ConversationalService.class)
+@Scope("CONVERSATION")
+@ConversationAttributes(maxAge = "10 minutes", maxIdleTime = "5 minutes", singlePrincipal = false)
+public class ConversationalServiceStatefulImpl implements ConversationalService {
+
+ @ConversationID
+ protected String conversationId;
+
+ @Callback
+ protected ConversationalCallback conversationalCallback;
+
+ // local count - accumulates during the conversation
+ private int count = 0;
+
+ // a static member variable that records the number of times this service is called
+ public static StringBuffer calls = new StringBuffer();
+
+ @Init
+ public void init() {
+ calls.append("init,");
+ }
+
+ @Destroy
+ public void destroy() {
+ calls.append("destroy,");
+ }
+
+ public void initializeCount(int count) {
+ calls.append("initializeCount,");
+ this.count = count;
+ }
+
+ public void incrementCount() {
+ calls.append("incrementCount,");
+ count++;
+ }
+
+ public int retrieveCount() {
+ calls.append("retrieveCount,");
+ return count;
+ }
+
+ public void businessException() throws Exception {
+ throw new Exception("Business Exception");
+ }
+
+ public void initializeCountCallback(int count) {
+ calls.append("initializeCountCallback,");
+ this.count = count;
+ conversationalCallback.initializeCount(count);
+ }
+
+ public void incrementCountCallback() {
+ calls.append("incrementCountCallback,");
+ count++;
+ conversationalCallback.incrementCount();
+ }
+
+ public int retrieveCountCallback() {
+ calls.append("retrieveCountCallback,");
+ return conversationalCallback.retrieveCount();
+ }
+
+ public void businessExceptionCallback() throws Exception {
+ calls.append("businessExceptionCallback,");
+ conversationalCallback.businessException();
+ }
+
+ public String endConversation() {
+ calls.append("endConversation,");
+ count = 0;
+ return conversationId;
+ }
+
+ public String endConversationCallback() {
+ calls.append("endConversationCallback,");
+ return conversationalCallback.endConversation();
+ }
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java new file mode 100644 index 0000000000..8d63ebbbef --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java @@ -0,0 +1,115 @@ +/*
+ * 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.itest.conversational.impl;
+
+import org.apache.tuscany.sca.itest.conversational.ConversationalServiceNonConversationalCallback;
+import org.apache.tuscany.sca.itest.conversational.NonConversationalCallback;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.ConversationAttributes;
+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;
+
+/**
+ * The service used when testing stateful conversations
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
+ */
+@Service(ConversationalServiceNonConversationalCallback.class)
+@Scope("CONVERSATION")
+@ConversationAttributes(maxAge = "10 minutes", maxIdleTime = "5 minutes", singlePrincipal = false)
+public class ConversationalServiceStatefulNonConversationalCallbackImpl implements
+ ConversationalServiceNonConversationalCallback {
+
+ @ConversationID
+ protected String conversationId;
+
+ @Callback
+ protected NonConversationalCallback nonConversationalCallback;
+
+ // local count - accumulates during the conversation
+ private int count = 0;
+
+ // a static member variable that records the number of times this service is called
+ public static StringBuffer calls = new StringBuffer();
+
+ @Init
+ public void init() {
+ calls.append("init,");
+ }
+
+ @Destroy
+ public void destroy() {
+ calls.append("destroy,");
+ }
+
+ public void initializeCount(int count) {
+ calls.append("initializeCount,");
+ this.count = count;
+ }
+
+ public void incrementCount() {
+ calls.append("incrementCount,");
+ count++;
+ }
+
+ public int retrieveCount() {
+ calls.append("retrieveCount,");
+ return count;
+ }
+
+ public void businessException() throws Exception {
+ throw new Exception("Business Exception");
+ }
+
+ public void initializeCountCallback(int count) {
+ calls.append("initializeCountCallback,");
+ this.count = count;
+ nonConversationalCallback.initializeCount(count);
+ }
+
+ public void incrementCountCallback() {
+ calls.append("incrementCountCallback,");
+ count++;
+ nonConversationalCallback.incrementCount();
+ }
+
+ public int retrieveCountCallback() {
+ calls.append("retrieveCountCallback,");
+ return nonConversationalCallback.retrieveCount();
+ }
+
+ public void businessExceptionCallback() throws Exception {
+ calls.append("businessExceptionCallback,");
+ nonConversationalCallback.businessException();
+ }
+
+ public String endConversation() {
+ calls.append("endConversation,");
+ count = 0;
+ return conversationId;
+ }
+
+ public String endConversationCallback() {
+ calls.append("endConversationCallback,");
+ return nonConversationalCallback.endConversation();
+ }
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java new file mode 100644 index 0000000000..ecf108c656 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java @@ -0,0 +1,122 @@ +/*
+ * 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.itest.conversational.impl;
+
+import java.util.HashMap;
+
+import org.apache.tuscany.sca.itest.conversational.ConversationalCallback;
+import org.apache.tuscany.sca.itest.conversational.ConversationalService;
+import org.oasisopen.sca.annotation.Callback;
+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;
+
+/**
+ * The service used when testing stateful conversations
+ *
+ * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $
+ */
+@Service(ConversationalService.class)
+@Scope("STATELESS")
+public class ConversationalServiceStatelessImpl implements ConversationalService {
+
+ @ConversationID
+ protected String conversationId;
+
+ @Callback
+ protected ConversationalCallback conversationalCallback;
+
+ // static area in which to hold conversational data
+ private static HashMap<String, Integer> conversationalState = new HashMap<String, Integer>();
+
+ // a static member variable that records the number of times this service is called
+ public static StringBuffer calls = new StringBuffer();
+
+ @Init
+ public void init() {
+ calls.append("init,");
+ }
+
+ @Destroy
+ public void destroy() {
+ calls.append("destroy,");
+ }
+
+ public void initializeCount(int count) {
+ calls.append("initializeCount,");
+ Integer conversationalCount = Integer.valueOf(count);
+ conversationalState.put(conversationId, conversationalCount);
+ }
+
+ public void incrementCount() {
+ calls.append("incrementCount,");
+ Integer conversationalCount = conversationalState.get(conversationId);
+ conversationalCount++;
+ conversationalState.put(conversationId, conversationalCount);
+ }
+
+ public int retrieveCount() {
+ calls.append("retrieveCount,");
+ Integer count = conversationalState.get(conversationId);
+ if (count != null) {
+ return count.intValue();
+ } else {
+ return -999;
+ }
+ }
+
+ public void businessException() throws Exception {
+ throw new Exception("Business Exception");
+ }
+
+ public void initializeCountCallback(int count) {
+ calls.append("initializeCountCallback,");
+ initializeCount(count);
+ conversationalCallback.initializeCount(count);
+ }
+
+ public void incrementCountCallback() {
+ calls.append("incrementCountCallback,");
+ incrementCount();
+ conversationalCallback.incrementCount();
+ }
+
+ public int retrieveCountCallback() {
+ calls.append("retrieveCountCallback,");
+ return conversationalCallback.retrieveCount();
+ }
+
+ public void businessExceptionCallback() throws Exception {
+ calls.append("businessExceptionCallback,");
+ conversationalCallback.businessException();
+ }
+
+ public String endConversation() {
+ calls.append("endConversation,");
+ conversationalState.remove(conversationId);
+ return conversationId;
+ }
+
+ public String endConversationCallback() {
+ calls.append("endConversationCallback,");
+ return conversationalCallback.endConversation();
+ }
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScopeImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScopeImpl.java new file mode 100644 index 0000000000..ee09e99f1b --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScopeImpl.java @@ -0,0 +1,93 @@ +/*
+ * 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.itest.conversational.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.itest.conversational.ConversationalService;
+import org.oasisopen.sca.annotation.ConversationID;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(ConversationalService.class)
+public class ConversationalServiceStatelessScopeImpl implements ConversationalService {
+
+ @ConversationID
+ protected String cid;
+
+ static Map<String, Integer> state = new HashMap<String, Integer>();
+
+ public void destroy() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public String endConversation() {
+ state.remove(cid);
+ return cid;
+ }
+
+ public String endConversationCallback() {
+ // TODO Auto-generated method stub
+ return null;
+
+ }
+
+ public void incrementCount() {
+ state.put(cid, Integer.valueOf(state.get(cid) + 1));
+ }
+
+ public void businessException() throws Exception {
+ throw new Exception("Business Exception");
+ }
+
+ public void incrementCountCallback() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void init() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void initializeCount(int count) {
+ state.put(cid, Integer.valueOf(count));
+ }
+
+ public void initializeCountCallback(int count) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void businessExceptionCallback() throws Exception {
+ throw new Exception("Business Exception");
+ }
+
+ public int retrieveCount() {
+ return state.get(cid);
+ }
+
+ public int retrieveCountCallback() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+}
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java new file mode 100644 index 0000000000..ad0c1fb7da --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java @@ -0,0 +1,68 @@ +/* + * 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.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.DService; +import org.oasisopen.sca.annotation.ConversationID; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +/** + * Simple conversational Service + */ +@Service(DService.class) +@Scope("CONVERSATION") +public class DServiceImpl implements DService { + + /** + * The state for this service + */ + private String state = "Initial state value"; + + /** + * Returns the state for this service. + * + * @return The state for this service + */ + public String getState() { + return state; + } + + /** + * Sets the state for this service. + * + * @param aState The state for this service + */ + public void setState(String aState) { + this.state = aState; + } + + /** + * Sets the conversation ID for this service + * @param id The Conversation ID + */ + @ConversationID + public void setConversationID(String id) { + System.out.println("Setting conversation ID at service = " + id); + } + + public void endConversationViaAnnotatedMethod() { + System.out.println("Annotated Ends Conversation"); + } +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/GammaImpl.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/GammaImpl.java new file mode 100644 index 0000000000..55390189cf --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/GammaImpl.java @@ -0,0 +1,66 @@ +/* + * 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.itest.conversational.impl; + +import java.util.ArrayList; + +import org.apache.tuscany.sca.itest.Record; +import org.apache.tuscany.sca.itest.conversational.Gamma; +import org.oasisopen.sca.annotation.ConversationID; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +/** + * @version $Rev$ $Date$ + */ + +@Service(Gamma.class) +@Scope("CONVERSATION") +public class GammaImpl implements Gamma { + @ConversationID + public String conversationId; + + private ArrayList<Record> list; + + public void start(int param) { + list = new ArrayList<Record>(); + fillList(param, conversationId); + } + + public boolean hasNext() { + return !list.isEmpty(); + } + + public Record next() { + return list.remove(0); + } + + public void stop() { + list = null; + } + + private void fillList(int param, String cid) { + for (int i = 0; i < param; i++) { + Record record = new Record(); + record.id = "id_" + i; + record.conversationId = cid; + list.add(record); + } + } +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/ConversationAge.composite b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/ConversationAge.composite new file mode 100644 index 0000000000..6674c87d77 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/ConversationAge.composite @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ name="ConversationalIdTest">
+
+ <component name="ConversationAgeComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationAgeComponentImpl"/>
+ </component>
+
+ <component name="ConversationIdleComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationMaxIdleComponentImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/ConversationUniqueId.composite b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/ConversationUniqueId.composite new file mode 100644 index 0000000000..3fbffdc660 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/ConversationUniqueId.composite @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> + +<!-- $Rev$ $Date$ --> + +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" + targetNamespace="http://conversations" + name="ConversationUniqueIdTest"> + + <component name="Alpha"> + <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.AlphaImpl"/> + <service name="Alpha"> + <binding.sca /> + </service> + <reference name="beta" target="Beta"> + <binding.sca/> + </reference> + </component> + + <component name="Beta"> + <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.BetaImpl"/> + <service name="Beta"> + <binding.sca /> + </service> + <reference name="gamma" target="Gamma"> + <binding.sca /> + </reference> + </component> + + <component name="Gamma"> + <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.GammaImpl"/> + <service name="Gamma"> + <binding.sca/> + </service> + </component> +</composite> diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/conversationId.composite b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/conversationId.composite new file mode 100644 index 0000000000..50ffdea701 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/conversationId.composite @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ name="ConversationalIdTest">
+
+ <component name="ConversationIdComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationIdComponentImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/conversationLifetime.composite b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/conversationLifetime.composite new file mode 100644 index 0000000000..538e2f63fd --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/conversationLifetime.composite @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" + targetNamespace="http://conversations" + name="conversationLifetimeTest"> + + <component name="ConversationalCComponent"> + <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.CServiceImpl"/> + <reference name="d" target="ConversationalDComponent" /> + </component> + + <component name="ConversationalDComponent"> + <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.DServiceImpl"/> + </component> + +</composite> diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/conversational.composite b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/conversational.composite new file mode 100644 index 0000000000..dba9cec03f --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/main/resources/conversational.composite @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://conversations"
+ name="ConversationalITest">
+
+ <component name="ConversationalStatelessClientStatelessService">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatelessImpl"/>
+ <reference name="conversationalReferenceClient" target="ConversationalReferenceClient"/>
+ <reference name="conversationalService" target="ConversationalServiceStatelessSL"/>
+ <reference name="conversationalService2" target="ConversationalServiceStatelessSL"/>
+ </component>
+
+ <component name="ConversationalStatelessClientStatefulService">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatelessImpl"/>
+ <reference name="conversationalReferenceClient" target="ConversationalReferenceClient"/>
+ <reference name="conversationalService" target="ConversationalServiceStateful"/>
+ <reference name="conversationalService2" target="ConversationalServiceStateful"/>
+ </component>
+
+ <component name="ConversationalStatefulClientStatelessService">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatefulImpl"/>
+ <reference name="conversationalReferenceClient" target="ConversationalReferenceClient"/>
+ <reference name="conversationalService" target="ConversationalServiceStatelessSL"/>
+ <reference name="conversationalService2" target="ConversationalServiceStatelessSL"/>
+ </component>
+
+ <component name="ConversationalStatefulClientStatefulService">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatefulImpl"/>
+ <reference name="conversationalReferenceClient" target="ConversationalReferenceClient"/>
+ <reference name="conversationalService" target="ConversationalServiceStateful"/>
+ <reference name="conversationalService2" target="ConversationalServiceStateful"/>
+ </component>
+
+ <component name="ConversationalStatelessClientRequestService">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatelessImpl"/>
+ <reference name="conversationalReferenceClient" target="ConversationalReferenceClient"/>
+ <reference name="conversationalService" target="ConversationalServiceRequest"/>
+ <reference name="conversationalService2" target="ConversationalServiceRequest"/>
+ </component>
+
+ <component name="ConversationalStatefulClientNonConversationalCallbackStatefulService">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatefulNonConversationalCallbackImpl"/>
+ <reference name="conversationalReferenceClient" target="ConversationalReferenceClient"/>
+ <reference name="conversationalService" target="ConversationalServiceStatefulNonConversationalCallback"/>
+ <reference name="conversationalService2" target="ConversationalServiceStatefulNonConversationalCallback"/>
+ </component>
+
+ <component name="ConversationalReferenceClient">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalReferenceClientImpl"/>
+ </component>
+
+ <component name="ConversationalServiceStateful">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatefulImpl"/>
+ </component>
+
+ <component name="ConversationalServiceStateless">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatelessScopeImpl"/>
+ </component>
+
+ <component name="ConversationalServiceStatelessSL">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatelessImpl"/>
+ </component>
+
+ <component name="ConversationalServiceRequest">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceRequestImpl"/>
+ </component>
+
+ <component name="ConversationalServiceStatefulNonConversationalCallback">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatefulNonConversationalCallbackImpl"/>
+ </component>
+
+ <component name="ConversationalAComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.AServiceImpl"/>
+ <reference name="b" target="ConversationalBComponent" />
+ </component>
+
+ <component name="ConversationalBComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.BServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationIdTestCase.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationIdTestCase.java new file mode 100644 index 0000000000..e64a9acbe2 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationIdTestCase.java @@ -0,0 +1,56 @@ +/* + * 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.itest.conversational; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class ConversationIdTestCase { + + private Node node; + + @Before + public void setUp() throws Exception { + String location = ContributionLocationHelper.getContributionLocation("conversationId.composite"); + node = NodeFactory.newInstance().createNode("conversationId.composite", new Contribution("c1", location)); + node.start(); + } + + @After + public void tearDown() throws Exception { + if (node != null) { + node.stop(); + } + } + + @Test + public void testConversationId() { + ConversationIdService service = node.getService(ConversationIdService.class, "ConversationIdComponent"); + Assert.assertNotNull(service.getCIDField()); + Assert.assertNotNull(service.getCIDSetter()); + } + +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationLifetimeTestCase.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationLifetimeTestCase.java new file mode 100644 index 0000000000..2b1aea3ff3 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationLifetimeTestCase.java @@ -0,0 +1,208 @@ +/* + * 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.itest.conversational; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class ConversationLifetimeTestCase { + + private static Node node; + + @BeforeClass + public static void setUp() throws Exception { + String location = ContributionLocationHelper.getContributionLocation("conversationLifetime.composite"); + node = NodeFactory.newInstance().createNode("conversationLifetime.composite", new Contribution("c1", location)); + node.start(); + } + + @AfterClass + public static void tearDown() throws Exception { + if (node != null) { + node.stop(); + } + } + + /** + * Following a clarification re. the wording of the Java Common Annotations and APIs 1.00 Specification + * (see TUSCANY-2055) the following is accepted to be the intended operation + * + * Whether the conversation ID is chosen by the user or is generated by the system, the client + * may access the conversation ID by calling getConversationID() on the current conversation object. + * + * ServiceReference.getConversationID() - Returns the id supplied by the user that will be associated with + * future conversations initiated through this reference, or null if no ID has been set by the user. + * + * ServiceReference.setConversationID(Object conversationId) - Set an ID, supplied by the user, to associate with any future 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. + * + */ + + /** + * Verify that ServiceReference.getConversationID() returns null before a conversation + * ID has been set manually. + */ + @Test + public void getConversationID() { + CService service = node.getService(CService.class, "ConversationalCComponent"); + service.getState(); + Assert.assertNull(service.getConversationID()); + } + + /** + * Verify that ServiceReference.getConversationID() returns any value previous set through the + * setConversationID() API. + */ + @Test + public void getConversationID2() { + String userProvidedID = "A conversation ID"; + CService service = node.getService(CService.class, "ConversationalCComponent"); + service.setConversationID(userProvidedID); + service.getState(); + Assert.assertEquals(service.getConversationID(), userProvidedID); + } + + /** + * Whether the conversation ID is chosen by the user or is generated by the system, the client + * may access the conversation ID by calling getConversationID() on the current conversation object. + * Here test the manually set conversationID + */ + @Test + public void getConversationID3() { + String userProvidedID = "A conversation ID 3"; + CService service = node.getService(CService.class, "ConversationalCComponent"); + service.setConversationID(userProvidedID); + service.getState(); + Assert.assertEquals(service.getConversationObjectConversationId(), userProvidedID); + } + + /** + * Whether the conversation ID is chosen by the user or is generated by the system, the client + * may access the conversation ID by calling getConversationID() on the current conversation object. + * Here test the auto generated conversationId + */ + @Test + public void getConversationID4() { + CService service = node.getService(CService.class, "ConversationalCComponent"); + service.getState(); + Assert.assertNotNull(service.getConversationObjectConversationId()); + } + + /** + * Java Common Annotations and APIs 1.00 Specification line 494-495 Verify: + * If a method is invoked on a service reference after an + * "@EndsConversation" method has been called then a new conversation will + * automatically be started. + */ + @Test + public void implicitStartNewConversationAfterEnd() { + CService service = node.getService(CService.class, "ConversationalCComponent"); + service.getState(); + Object firstID = service.getConversationObjectConversationId(); + service.endConversationViaAnnotatedMethod(); + service.getState(); + Assert.assertNotSame(firstID, service.getConversationObjectConversationId()); + } + + /** + * Java Common Annotations and APIs 1.00 Specification line 495-495 Verify: If a + * method is invoked on a service reference after an "@EndsConversation" + * method has been called then a new conversation will automatically be + * started. Note: Uses Conversation.end() rather than "@EndsConversation" + */ + @Test + public void implicitStartNewConversationAfterEnd2() { + CService service = node.getService(CService.class, "ConversationalCComponent"); + service.getState(); + Object firstID = service.getConversationObjectConversationId(); + service.endConversation(); + service.getState(); + Assert.assertNotSame(firstID, service.getConversationObjectConversationId()); + } + + /** + * Java Common Annotations and APIs 1.00 Specification line 495-497 Verify: + * If ServiceReference.getConversationID() is called after the + * "@EndsConversation" method is called, but before the next conversation + * has been started, it will return null. + */ + @Test + public void nullConversationIDAfterEndConversation() { + CService service = node.getService(CService.class, "ConversationalCComponent"); + service.getState(); + service.endConversationViaAnnotatedMethod(); + Assert.assertNull(service.getConversationObjectConversationId()); + } + + /** + * Java Common Annotations and APIs 1.00 Specification line 495-497 Verify: + * If ServiceReference.getConversationID() is called after the + * "@EndsConversation" method is called, but before the next conversation + * has been started, it will return null. Note: Uses explicit set of Conversation ID + */ + @Test + public void nullConversationIDAfterEndConversation1a() { + CService service = node.getService(CService.class, "ConversationalCComponent"); + service.setConversationID("User provided ID"); + service.getState(); + service.endConversationViaAnnotatedMethod(); + Assert.assertNull(service.getConversationObjectConversationId()); + } + + /** + * Java Common Annotations and APIs 1.00 Specification line 495-497 Verify: If + * ServiceReference.getConversationID() is called after the + * "@EndsConversationmethod" is called, but before the next conversation has + * been started, it will return null. Note: Uses Conversation.end() rather + * than "@EndsConversation" + */ + @Test + public void nullConversationIDAfterEndConversation2() { + CService service = node.getService(CService.class, "ConversationalCComponent"); + service.getState(); + service.endConversation(); + Assert.assertNull(service.getConversationObjectConversationId()); + } + + /** + * Java Common Annotations and APIs 1.00 Specification line 495-497 Verify: If + * ServiceReference.getConversationID() is called after the + * "@EndsConversationmethod" is called, but before the next conversation has + * been started, it will return null. Note: Uses Conversation.end() rather + * than "@EndsConversation". Note 2: Uses explicit set of Conversation ID + */ + @Test + public void nullConversationIDAfterEndConversation2a() { + CService service = node.getService(CService.class, "ConversationalCComponent"); + service.setConversationID("User provided ID"); + service.getState(); + service.endConversation(); + Assert.assertNull(service.getConversationObjectConversationId()); + } + +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationUniqueIdTestCase.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationUniqueIdTestCase.java new file mode 100644 index 0000000000..f9bb69aa30 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationUniqueIdTestCase.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.itest.conversational; + +import org.apache.tuscany.sca.itest.TestResult; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +/** + * @version $Rev$ $Date$ + */ +public class ConversationUniqueIdTestCase { + + private Node node; + + @Before + public void setUp() throws Exception { + String location = ContributionLocationHelper.getContributionLocation("ConversationUniqueId.composite"); + node = NodeFactory.newInstance().createNode("ConversationUniqueId.composite", new Contribution("c1", location)); + node.start(); + } + + @After + public void tearDown() throws Exception { + if (node != null) { + node.stop(); + } + } + + @Ignore("I'm seeing NPE in GammaImpl.hasNext()") + @Test + public void testConversationUniqueId() { + Alpha alpha = node.getService(Alpha.class, "Alpha"); + int numConversations = 3; + + for (int i = 0; i < numConversations; ++i) { + alpha.run(5); + } + + // Wait for the conversations to complete + while (TestResult.getCompleted() < numConversations) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + } + + Assert.assertEquals(TestResult.results.size(), numConversations); + for (Boolean value : TestResult.results.values()) { + Assert.assertTrue(value); + } + } + +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTestCase.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTestCase.java new file mode 100644 index 0000000000..a686754d3a --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTestCase.java @@ -0,0 +1,107 @@ +/* + * 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.itest.conversational; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.oasisopen.sca.ConversationEndedException; + +public class ConversationalAgeTestCase { + + private static Node node; + + @BeforeClass + public static void setUp() throws Exception { + System.setProperty("org.apache.tuscany.sca.core.conversation.ConversationManager.ReaperInterval", "2"); + String location = ContributionLocationHelper.getContributionLocation("ConversationAge.composite"); + node = NodeFactory.newInstance().createNode("ConversationAge.composite", new Contribution("c1", location)); + node.start(); + } + + @AfterClass + public static void tearDown() throws Exception { + System.clearProperty("org.apache.tuscany.sca.core.conversation.ConversationManager.ReaperInterval"); + if (node != null) { + node.stop(); + } + } + + @Test + public void testMaxAge() throws InterruptedException { + + ConversationalService conversationalService = + node.getService(ConversationalService.class, "ConversationAgeComponent"); + + Assert.assertEquals(0, conversationalService.retrieveCount()); + conversationalService.initializeCount(42); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Thread.sleep(500); + try { + Assert.assertEquals(42, conversationalService.retrieveCount()); + } catch (ConversationEndedException e) { + Assert.fail(); + } + } + + @Test + public void testAgeExpired() throws InterruptedException { + + ConversationalService conversationalService = + node.getService(ConversationalService.class, "ConversationAgeComponent"); + + Assert.assertEquals(0, conversationalService.retrieveCount()); + conversationalService.initializeCount(42); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Thread.sleep(1100); + try { + Assert.assertEquals(0, conversationalService.retrieveCount()); + Assert.fail(); + } catch (ConversationEndedException e) { + // expected + } + } + + @Test + public void testMaxIdle() throws InterruptedException { + + ConversationalService conversationalService = + node.getService(ConversationalService.class, "ConversationIdleComponent"); + + Assert.assertEquals(0, conversationalService.retrieveCount()); + conversationalService.initializeCount(42); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Thread.sleep(1100); + try { + Assert.assertEquals(0, conversationalService.retrieveCount()); + } catch (ConversationEndedException e) { + // expected + } + } + +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalJ2SETestCase.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalJ2SETestCase.java new file mode 100644 index 0000000000..ee1bf84fc4 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalJ2SETestCase.java @@ -0,0 +1,88 @@ +/* + * 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.itest.conversational; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class ConversationalJ2SETestCase { + + private Node node; + + @Before + public void setUp() throws Exception { + String location = ContributionLocationHelper.getContributionLocation("conversational.composite"); + node = NodeFactory.newInstance().createNode("conversational.composite", new Contribution("c1", location)); + node.start(); + } + + @After + public void tearDown() throws Exception { + if (node != null) { + node.stop(); + } + } + + @Test + public void testStatefulConversation() { + ConversationalService conversationalService = + node.getService(ConversationalService.class, "ConversationalServiceStateful"); + + conversationalService.initializeCount(1); + Assert.assertEquals(1, conversationalService.retrieveCount()); + conversationalService.incrementCount(); + Assert.assertEquals(2, conversationalService.retrieveCount()); + conversationalService.endConversation(); + + Assert.assertEquals(0, conversationalService.retrieveCount()); + + conversationalService.initializeCount(4); + Assert.assertEquals(4, conversationalService.retrieveCount()); + conversationalService.incrementCount(); + Assert.assertEquals(5, conversationalService.retrieveCount()); + conversationalService.endConversation(); + + } + + @Test + public void testStatelessConversation() { + ConversationalService conversationalService = + node.getService(ConversationalService.class, "ConversationalServiceStateless"); + + conversationalService.initializeCount(1); + Assert.assertEquals(1, conversationalService.retrieveCount()); + conversationalService.incrementCount(); + Assert.assertEquals(2, conversationalService.retrieveCount()); + conversationalService.endConversation(); + + conversationalService.initializeCount(4); + Assert.assertEquals(4, conversationalService.retrieveCount()); + conversationalService.incrementCount(); + Assert.assertEquals(5, conversationalService.retrieveCount()); + conversationalService.endConversation(); + + } +} diff --git a/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java b/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java new file mode 100644 index 0000000000..56bca7ac78 --- /dev/null +++ b/sandbox/ant/sca/branches/tb7/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java @@ -0,0 +1,702 @@ +/*
+ * 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.itest.conversational;
+
+import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatefulImpl;
+import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatefulNonConversationalCallbackImpl;
+import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatelessImpl;
+import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceRequestImpl;
+import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatefulImpl;
+import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatefulNonConversationalCallbackImpl;
+import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatelessImpl;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class ConversationalTestCase {
+
+ private static Node node;
+ private static ConversationalClient conversationalStatelessClientStatelessService;
+ private static ConversationalClient conversationalStatelessClientStatefulService;
+ private static ConversationalClient conversationalStatefulClientStatelessService;
+ private static ConversationalClient conversationalStatefulClientStatefulService;
+ private static ConversationalClient conversationalStatelessClientRequestService;
+ private static ConversationalClient conversationalStatefulClientNonConversationalCallbackStatelessService;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ String location = ContributionLocationHelper.getContributionLocation("conversational.composite");
+ node = NodeFactory.newInstance().createNode("conversational.composite", new Contribution("c1", location));
+ node.start();
+
+ conversationalStatelessClientStatelessService =
+ node.getService(ConversationalClient.class, "ConversationalStatelessClientStatelessService");
+
+ conversationalStatelessClientStatefulService =
+ node.getService(ConversationalClient.class, "ConversationalStatelessClientStatefulService");
+
+ conversationalStatefulClientStatelessService =
+ node.getService(ConversationalClient.class, "ConversationalStatefulClientStatelessService");
+
+ conversationalStatefulClientStatefulService =
+ node.getService(ConversationalClient.class, "ConversationalStatefulClientStatefulService");
+ conversationalStatelessClientRequestService =
+ node.getService(ConversationalClient.class, "ConversationalStatelessClientRequestService");
+ conversationalStatefulClientNonConversationalCallbackStatelessService =
+ node.getService(ConversationalClient.class,
+ "ConversationalStatefulClientNonConversationalCallbackStatefulService");
+
+ } catch (Exception ex) {
+ System.err.println(ex.toString());
+ }
+
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ private void resetCallStack() {
+
+ // reset the place where we record the sequence of calls passing
+ // through each component instance
+ ConversationalServiceStatelessImpl.calls = new StringBuffer();
+ ConversationalServiceStatefulImpl.calls = new StringBuffer();
+ ConversationalClientStatelessImpl.calls = new StringBuffer();
+ ConversationalClientStatefulImpl.calls = new StringBuffer();
+ ConversationalClientStatefulNonConversationalCallbackImpl.calls = new StringBuffer();
+ ConversationalServiceStatefulNonConversationalCallbackImpl.calls = new StringBuffer();
+
+ }
+
+ // stateless client stateful service tests
+ // =======================================
+ @Test
+ public void testStatelessStatefulConversationFromInjectedReference() {
+ int count = conversationalStatelessClientStatefulService.runConversationFromInjectedReference();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatelessStatefulConversationFromInjectedReference2() {
+ int count = conversationalStatelessClientStatefulService.runConversationFromInjectedReference2();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatelessStatefulConversationFromServiceReference() {
+ int count = conversationalStatelessClientStatefulService.runConversationFromServiceReference();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatelessStatefulConversationWithUserDefinedConversationId() {
+ int count = conversationalStatelessClientStatefulService.runConversationWithUserDefinedConversationId();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatelessStatefulConversationCheckUserDefinedConversationId() {
+ String conversationId =
+ conversationalStatelessClientStatefulService.runConversationCheckUserDefinedConversationId();
+ Assert.assertEquals("MyConversation2", conversationId);
+ }
+
+ @Test
+ public void testStatelessStatefulConversationCheckingScope() {
+ resetCallStack();
+ conversationalStatelessClientStatefulService.runConversationCheckingScope();
+ Assert.assertEquals("init,initializeCount,incrementCount,retrieveCount,endConversation,destroy,",
+ ConversationalServiceStatefulImpl.calls.toString());
+ }
+
+ @Test
+ public void testStatelessStatefulConversationWithCallback() {
+ resetCallStack();
+ int count = conversationalStatelessClientStatefulService.runConversationWithCallback();
+ Assert.assertEquals(0, count);
+
+ Assert
+ .assertEquals("init,runConversationWithCallback,init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,destroy,",
+ ConversationalClientStatelessImpl.calls.toString());
+ }
+
+ //@Test
+ public void testStatelessStatefulConversationHavingPassedReference() {
+ int count = conversationalStatelessClientStatefulService.runConversationHavingPassedReference();
+ Assert.assertEquals(3, count);
+ }
+
+ @Test
+ public void testStatelessStatefulConversationBusinessException() {
+ String message = conversationalStatelessClientStatefulService.runConversationBusinessException();
+ Assert.assertEquals("Business Exception", message);
+ }
+
+ @Test
+ public void testStatelessStatefulConversationBusinessExceptionCallback() {
+ String message = conversationalStatelessClientStatefulService.runConversationBusinessExceptionCallback();
+ Assert.assertEquals("Business Exception", message);
+ }
+
+ @Test
+ public void testStatelessStatefulConversationCallingEndedConversation() {
+ int count = conversationalStatelessClientStatefulService.runConversationCallingEndedConversation();
+ Assert.assertEquals(0, count);
+ }
+
+ @Test
+ public void testStatelessStatefulConversationCallingEndedConversationCallback() {
+ int count = conversationalStatelessClientStatefulService.runConversationCallingEndedConversationCallback();
+ Assert.assertEquals(0, count);
+ }
+
+ @Test
+ public void testStatelessStatefulConversationCallingEndedConversationCheckConversationId() {
+ String id =
+ conversationalStatelessClientStatefulService.runConversationCallingEndedConversationCheckConversationId();
+ Assert.assertEquals(null, id);
+ }
+
+ //@Test
+ public void testStatelessStatefulConversationCallingEndedConversationCallbackCheckConversationId() {
+ String id =
+ conversationalStatelessClientStatefulService
+ .runConversationCallingEndedConversationCallbackCheckConversationId();
+ Assert.assertEquals(null, id);
+ }
+
+ // stateless client stateless service tests
+ // ========================================
+ @Test
+ public void testStatelessStatelessConversationFromInjectedReference() {
+ int count = conversationalStatelessClientStatelessService.runConversationFromInjectedReference();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatelessStatelessConversationFromInjectedReference2() {
+ int count = conversationalStatelessClientStatelessService.runConversationFromInjectedReference2();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatelessStatelessConversationFromServiceReference() {
+ int count = conversationalStatelessClientStatelessService.runConversationFromServiceReference();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatelessStatelessConversationWithUserDefinedConversationId() {
+ int count = conversationalStatelessClientStatelessService.runConversationWithUserDefinedConversationId();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatelessStatelessConversationCheckUserDefinedConversationId() {
+ String conversationId =
+ conversationalStatelessClientStatelessService.runConversationCheckUserDefinedConversationId();
+ Assert.assertEquals("MyConversation2", conversationId);
+ }
+
+ @Test
+ public void testStatelessStatelessConversationCheckingScope() {
+ resetCallStack();
+ conversationalStatelessClientStatelessService.runConversationCheckingScope();
+ Assert
+ .assertEquals("init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,",
+ ConversationalServiceStatelessImpl.calls.toString());
+ }
+
+ @Test
+ public void testStatelessStatelessConversationWithCallback() {
+ resetCallStack();
+ int count = conversationalStatelessClientStatelessService.runConversationWithCallback();
+ Assert.assertEquals(0, count);
+
+ Assert
+ .assertEquals("init,runConversationWithCallback,init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,destroy,",
+ ConversationalClientStatelessImpl.calls.toString());
+ }
+
+ //@Test
+ public void testStatelessStatelessConversationHavingPassedReference() {
+ int count = conversationalStatelessClientStatelessService.runConversationHavingPassedReference();
+ Assert.assertEquals(3, count);
+ }
+
+ @Test
+ public void testStatelessStatelessConversationCallingEndedConversation() {
+ int count = conversationalStatelessClientStatelessService.runConversationCallingEndedConversation();
+ Assert.assertEquals(-999, count);
+ }
+
+ @Test
+ public void testStatelessStatelessConversationCallingEndedConversationCallback() {
+ int count = conversationalStatelessClientStatelessService.runConversationCallingEndedConversationCallback();
+ Assert.assertEquals(0, count);
+ }
+
+ @Test
+ public void testStatelessStatelessConversationCallingEndedConversationCheckConversationId() {
+ String id =
+ conversationalStatelessClientStatelessService.runConversationCallingEndedConversationCheckConversationId();
+ Assert.assertEquals(null, id);
+ }
+
+ //@Test
+ public void testStatelessStatelessConversationCallingEndedConversationCallbackCheckConversationId() {
+ String id =
+ conversationalStatelessClientStatelessService
+ .runConversationCallingEndedConversationCallbackCheckConversationId();
+ Assert.assertEquals(null, id);
+ }
+
+ // stateful client stateful service tests
+ // ======================================
+ @Test
+ public void testStatefulStatefulConversationFromInjectedReference() {
+ int count = conversationalStatefulClientStatefulService.runConversationFromInjectedReference();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatefulStatefulConversationFromInjectedReference2() {
+ int count = conversationalStatefulClientStatefulService.runConversationFromInjectedReference2();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatefulStatefulConversationFromServiceReference() {
+ int count = conversationalStatefulClientStatefulService.runConversationFromServiceReference();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatefulStatefulConversationWithUserDefinedConversationId() {
+ int count = conversationalStatefulClientStatefulService.runConversationWithUserDefinedConversationId();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatefulStatefulConversationCheckUserDefinedConversationId() {
+ String conversationId =
+ conversationalStatefulClientStatefulService.runConversationCheckUserDefinedConversationId();
+ Assert.assertEquals("MyConversation2", conversationId);
+ }
+
+ @Test
+ public void testStatefulStatefulConversationCheckingScope() {
+ resetCallStack();
+ conversationalStatefulClientStatefulService.runConversationCheckingScope();
+ Assert.assertEquals("init,initializeCount,incrementCount,retrieveCount,endConversation,destroy,",
+ ConversationalServiceStatefulImpl.calls.toString());
+ }
+
+ @Test
+ public void testStatefulStatefulConversationWithCallback() {
+ resetCallStack();
+ int count = conversationalStatefulClientStatefulService.runConversationWithCallback();
+ Assert.assertEquals(4, count);
+
+ Assert
+ .assertEquals("init,runConversationWithCallback,initializeCount,incrementCount,retrieveCount,endConversation,destroy,",
+ ConversationalClientStatefulImpl.calls.toString());
+ }
+
+ //@Test
+ public void testStatefulStatefulConversationHavingPassedReference() {
+ int count = conversationalStatefulClientStatefulService.runConversationHavingPassedReference();
+ Assert.assertEquals(3, count);
+ }
+
+ @Test
+ public void testStatefulStatefulConversationCallingEndedConversation() {
+ int count = conversationalStatefulClientStatefulService.runConversationCallingEndedConversation();
+ Assert.assertEquals(0, count);
+ }
+
+ @Test
+ public void testStatefulStatefulConversationCallingEndedConversationCallback() {
+ int count = conversationalStatefulClientStatefulService.runConversationCallingEndedConversationCallback();
+ Assert.assertEquals(0, count);
+ }
+
+ @Test
+ public void testStatefulStatefulConversationCallingEndedConversationCheckConversationId() {
+ String id =
+ conversationalStatefulClientStatefulService.runConversationCallingEndedConversationCheckConversationId();
+ Assert.assertEquals(null, id);
+ }
+
+ @Test
+ public void testStatefulStatefulConversationCallingEndedConversationCallbackCheckConversationId() {
+ String id =
+ conversationalStatefulClientStatefulService
+ .runConversationCallingEndedConversationCallbackCheckConversationId();
+ Assert.assertEquals(null, id);
+ }
+
+ // stateful client stateless service tests
+ // =======================================
+ @Test
+ public void testStatefulStatelessConversationFromInjectedReference() {
+ int count = conversationalStatefulClientStatelessService.runConversationFromInjectedReference();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatefulStatelessConversationFromInjectedReference2() {
+ int count = conversationalStatefulClientStatelessService.runConversationFromInjectedReference2();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatefulStatelessConversationFromServiceReference() {
+ int count = conversationalStatefulClientStatelessService.runConversationFromServiceReference();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatefulStatelessConversationWithUserDefinedConversationId() {
+ int count = conversationalStatefulClientStatelessService.runConversationWithUserDefinedConversationId();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatefulStatelessConversationCheckUserDefinedConversationId() {
+ String conversationId =
+ conversationalStatefulClientStatelessService.runConversationCheckUserDefinedConversationId();
+ Assert.assertEquals("MyConversation2", conversationId);
+ }
+
+ @Test
+ public void testStatefulStatelessConversationCheckingScope() {
+ resetCallStack();
+ conversationalStatefulClientStatelessService.runConversationCheckingScope();
+ Assert
+ .assertEquals("init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,",
+ ConversationalServiceStatelessImpl.calls.toString());
+ }
+
+ @Test
+ public void testStatefulStatelessConversationWithCallback() {
+ resetCallStack();
+ int count = conversationalStatefulClientStatelessService.runConversationWithCallback();
+ Assert.assertEquals(4, count);
+
+ Assert
+ .assertEquals("init,runConversationWithCallback,initializeCount,incrementCount,retrieveCount,endConversation,destroy,",
+ ConversationalClientStatefulImpl.calls.toString());
+ }
+
+ //@Test
+ public void testStatefulStatelessConversationHavingPassedReference() {
+ int count = conversationalStatefulClientStatelessService.runConversationHavingPassedReference();
+ Assert.assertEquals(3, count);
+ }
+
+ @Test
+ public void testStatefulStatelessConversationCallingEndedConversation() {
+ int count = conversationalStatefulClientStatelessService.runConversationCallingEndedConversation();
+ Assert.assertEquals(-999, count);
+ }
+
+ @Test
+ public void testStatefulStatelessConversationCallingEndedConversationCallback() {
+ int count = conversationalStatefulClientStatelessService.runConversationCallingEndedConversationCallback();
+ Assert.assertEquals(0, count);
+ }
+
+ @Test
+ public void testStatefulStatelessConversationCallingEndedConversationCheckConversationId() {
+ String id =
+ conversationalStatefulClientStatelessService.runConversationCallingEndedConversationCheckConversationId();
+ Assert.assertEquals(null, id);
+ }
+
+ @Test
+ public void testStatefulStatelessConversationCallingEndedConversationCallbackCheckConversationId() {
+ String id =
+ conversationalStatefulClientStatelessService
+ .runConversationCallingEndedConversationCallbackCheckConversationId();
+ Assert.assertEquals(null, id);
+ }
+
+ // stateless client request scope service tests
+ // ============================================
+ @Test
+ public void testStatelessRequestConversationFromInjectedReference() {
+ int count = conversationalStatelessClientRequestService.runConversationFromInjectedReference();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatelessRequestConversationFromInjectedReference2() {
+ int count = conversationalStatelessClientRequestService.runConversationFromInjectedReference2();
+ Assert.assertEquals(1, count);
+ }
+
+ @Test
+ public void testStatelessRequestConversationFromServiceReference() {
+ int count = conversationalStatelessClientRequestService.runConversationFromServiceReference();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatelessRequestConversationWithUserDefinedConversationId() {
+ int count = conversationalStatelessClientRequestService.runConversationWithUserDefinedConversationId();
+ Assert.assertEquals(2, count);
+ }
+
+ //@Test
+ public void testStatelessRequestConversationCheckUserDefinedConversationId() {
+ String conversationId =
+ conversationalStatelessClientRequestService.runConversationCheckUserDefinedConversationId();
+ Assert.assertEquals("MyConversation2", conversationId);
+ }
+
+ @Test
+ public void testStatelessRequestConversationCheckingScope() {
+ resetCallStack();
+ ConversationalServiceRequestImpl.calls = new StringBuffer();
+ conversationalStatelessClientRequestService.runConversationCheckingScope();
+ Assert.assertEquals("initializeCount,incrementCount,retrieveCount,endConversation,",
+ ConversationalServiceRequestImpl.calls.toString());
+ }
+
+ @Test
+ public void testStatelessRequestConversationWithCallback() {
+ resetCallStack();
+ ConversationalClientStatelessImpl.calls = new StringBuffer();
+ int count = conversationalStatelessClientRequestService.runConversationWithCallback();
+ Assert.assertEquals(0, count);
+
+ Assert
+ .assertEquals("init,runConversationWithCallback,init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,destroy,",
+ ConversationalClientStatelessImpl.calls.toString());
+ }
+
+ //@Test
+ public void testStatelessRequestConversationHavingPassedReference() {
+ int count = conversationalStatelessClientRequestService.runConversationHavingPassedReference();
+ Assert.assertEquals(3, count);
+ }
+
+ @Test
+ public void testStatelessRequestConversationBusinessException() {
+ String message = conversationalStatelessClientRequestService.runConversationBusinessException();
+ Assert.assertEquals("Business Exception", message);
+ }
+
+ @Test
+ public void testStatelessRequestConversationBusinessExceptionCallback() {
+ String message = conversationalStatelessClientRequestService.runConversationBusinessExceptionCallback();
+ Assert.assertEquals("Business Exception", message);
+ }
+
+ @Test
+ public void testStatelessRequestConversationCallingEndedConversation() {
+ int count = conversationalStatelessClientRequestService.runConversationCallingEndedConversation();
+ Assert.assertEquals(-999, count);
+ }
+
+ @Test
+ public void testStatelessRequestConversationCallingEndedConversationCallback() {
+ int count = conversationalStatelessClientRequestService.runConversationCallingEndedConversationCallback();
+ Assert.assertEquals(0, count);
+ }
+
+ @Test
+ public void testStatelessRequestConversationCallingEndedConversationCheckConversationId() {
+ String id =
+ conversationalStatelessClientRequestService.runConversationCallingEndedConversationCheckConversationId();
+ Assert.assertEquals(null, id);
+ }
+
+ //@Test
+ public void testStatelessRequestConversationCallingEndedConversationCallbackCheckConversationId() {
+ String id =
+ conversationalStatelessClientRequestService
+ .runConversationCallingEndedConversationCallbackCheckConversationId();
+ Assert.assertEquals(null, id);
+ }
+
+ // stateful client non conversational callback stateful service tests
+ // ==================================================================
+
+ @Test
+ public void testStatefulNonConversationalCallbackStatefulConversationFromInjectedReference() {
+ int count =
+ conversationalStatefulClientNonConversationalCallbackStatelessService
+ .runConversationFromInjectedReference();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatefulNonConversationalCallbackStatefulConversationFromInjectedReference2() {
+ int count =
+ conversationalStatefulClientNonConversationalCallbackStatelessService
+ .runConversationFromInjectedReference2();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatefulNonConversationalCallbackStatefulConversationFromServiceReference() {
+ int count =
+ conversationalStatefulClientNonConversationalCallbackStatelessService.runConversationFromServiceReference();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatefulNonConversationalCallbackStatefulConversationWithUserDefinedConversationId() {
+ int count =
+ conversationalStatefulClientNonConversationalCallbackStatelessService
+ .runConversationWithUserDefinedConversationId();
+ Assert.assertEquals(2, count);
+ }
+
+ @Test
+ public void testStatefulNonConversationalCallbackStatefulConversationCheckUserDefinedConversationId() {
+ String conversationId =
+ conversationalStatefulClientNonConversationalCallbackStatelessService
+ .runConversationCheckUserDefinedConversationId();
+ Assert.assertEquals("MyConversation2", conversationId);
+ }
+
+ @Test
+ public void testStatefulNonConversationalCallbackStatefulConversationCheckingScope() {
+ resetCallStack();
+ conversationalStatefulClientNonConversationalCallbackStatelessService.runConversationCheckingScope();
+ Assert.assertEquals("init,initializeCount,incrementCount,retrieveCount,endConversation,destroy,",
+ ConversationalServiceStatefulNonConversationalCallbackImpl.calls.toString());
+ }
+
+ @Test
+ public void testStatefulNonConversationalCallbackStatefulConversationWithCallback() {
+ resetCallStack();
+ int count = conversationalStatefulClientNonConversationalCallbackStatelessService.runConversationWithCallback();
+ Assert.assertEquals(0, count);
+
+ Assert
+ .assertEquals("init,runConversationWithCallback,init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,",
+ ConversationalClientStatefulNonConversationalCallbackImpl.calls.toString());
+ }
+
+ //@Test
+ public void testStatefulNonConversationalCallbackStatefulConversationHavingPassedReference() {
+ int count =
+ conversationalStatefulClientNonConversationalCallbackStatelessService
+ .runConversationHavingPassedReference();
+ Assert.assertEquals(0, count);
+ }
+
+ @Test
+ public void testStatefulNonConversationalCallbackStatefulConversationCallingEndedConversation() {
+ int count =
+ conversationalStatefulClientNonConversationalCallbackStatelessService
+ .runConversationCallingEndedConversation();
+ Assert.assertEquals(0, count);
+ }
+
+ @Test
+ public void testStatefulNonConversationalCallbackStatefulConversationCallingEndedConversationCallback() {
+ int count =
+ conversationalStatefulClientNonConversationalCallbackStatelessService
+ .runConversationCallingEndedConversationCallback();
+ Assert.assertEquals(0, count);
+ }
+
+ @Test
+ public void testStatefulNonConversationalCallbackStatefulConversationCallingEndedConversationCheckConversationId() {
+ String id =
+ conversationalStatefulClientNonConversationalCallbackStatelessService
+ .runConversationCallingEndedConversationCheckConversationId();
+ Assert.assertEquals(null, id);
+ }
+
+ @Test
+ public void testStatefulNonConversationalCallbackStatefulConversationCallingEndedConversationCallbackCheckConversationId() {
+ String id =
+ conversationalStatefulClientNonConversationalCallbackStatelessService
+ .runConversationCallingEndedConversationCallbackCheckConversationId();
+ Assert.assertEquals("MyConversation3", id);
+ }
+
+ private static final String NEW_A_VALUE = "First Instance - TestCode Set state on A";
+ private static final String NEW_B_VALUE = "First Instance - TestCode Set state on B";
+ private static final String SECOND_NEW_A_VALUE = "Second Instance - TestCode Set state on A";
+ private static final String SECOND_NEW_B_VALUE = "Second Instance - TestCode Set state on B";
+
+ @Test
+ public void testMultipleConversations() {
+ //////////
+ // Tests on first instance
+ //////////
+ System.out.println("========= First instance tests =========");
+ AService aService = node.getService(AService.class, "ConversationalAComponent");
+
+ // Make sure initial values are correct
+ Assert.assertEquals(Constants.A_INITIAL_VALUE, aService.getState());
+ Assert.assertEquals(Constants.B_INITIAL_VALUE, aService.getStateOnB());
+
+ // Set some new values
+ aService.setState(NEW_A_VALUE);
+ aService.setStateOnB(NEW_B_VALUE);
+
+ // Verify the set worked
+ Assert.assertEquals(NEW_A_VALUE, aService.getState());
+ Assert.assertEquals(NEW_B_VALUE, aService.getStateOnB());
+
+ //////////
+ // Tests on second instance
+ //////////
+ System.out.println("========= Second instance tests =========");
+
+ // Do another look up
+ AService aService2 = node.getService(AService.class, "ConversationalAComponent");
+
+ // Make sure initial values are correct on the second instance
+ Assert.assertEquals(Constants.A_INITIAL_VALUE, aService2.getState());
+ Assert.assertEquals(Constants.B_INITIAL_VALUE, aService2.getStateOnB());
+
+ // Set some new values on the second instance
+ aService2.setState(SECOND_NEW_A_VALUE);
+ aService2.setStateOnB(SECOND_NEW_B_VALUE);
+
+ // Verify the set worked on the second instance
+ Assert.assertEquals(SECOND_NEW_A_VALUE, aService2.getState());
+ Assert.assertEquals(SECOND_NEW_B_VALUE, aService2.getStateOnB());
+
+ // Verify the values have not been changed on the first instance
+ Assert.assertEquals(NEW_A_VALUE, aService.getState());
+ Assert.assertEquals(NEW_B_VALUE, aService.getStateOnB());
+
+ System.out.println("========= Done instance tests =========");
+ }
+
+}
|