From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- tags/java/sca/1.2.1/itest/conversations-ws/pom.xml | 64 +++ .../itest/conversational/BusinessException.java | 41 ++ .../conversational/ConversationIdService.java | 29 + .../conversational/ConversationalCallback.java | 50 ++ .../itest/conversational/ConversationalClient.java | 51 ++ .../ConversationalReferenceClient.java | 36 ++ .../conversational/ConversationalService.java | 58 ++ ...ersationalServiceNonConversationalCallback.java | 59 ++ .../conversational/NonConversationalCallback.java | 44 ++ .../impl/ConversationAgeComponentImpl.java | 76 +++ .../impl/ConversationIdComponentImpl.java | 48 ++ .../impl/ConversationMaxIdleComponentImpl.java | 76 +++ .../impl/ConversationalClientStatefulImpl.java | 322 +++++++++++ ...lientStatefulNonConversationalCallbackImpl.java | 311 +++++++++++ .../impl/ConversationalClientStatelessImpl.java | 318 +++++++++++ .../impl/ConversationalReferenceClientImpl.java | 43 ++ .../impl/ConversationalServiceRequestImpl.java | 124 +++++ .../impl/ConversationalServiceStatefulImpl.java | 119 ++++ ...rviceStatefulNonConversationalCallbackImpl.java | 118 ++++ .../impl/ConversationalServiceStatelessImpl.java | 123 +++++ .../ConversationalServiceStatelessScopeImpl.java | 94 ++++ .../Conversational/META-INF/sca-contribution.xml | 22 + .../Conversational/conversational.composite | 169 ++++++ .../ConversationalServiceStateful.wsdl | 383 +++++++++++++ .../META-INF/sca-contribution.xml | 22 + .../conversationalWSDL.composite | 48 ++ .../conversational/ConversationWSDLTestCase.java | 75 +++ .../conversational/ConversationalTestCaseOff.java | 610 +++++++++++++++++++++ .../NonConversationalCallbackTestCase.java | 202 +++++++ .../itest/conversational/RequestScopeTestCase.java | 211 +++++++ .../conversational/StatefulStatefulTestCase.java | 197 +++++++ .../conversational/StatefulStatelessTestCase.java | 196 +++++++ .../conversational/StatelessStatefulTestCase.java | 209 +++++++ .../conversational/StatelessStatelessTestCase.java | 196 +++++++ 34 files changed, 4744 insertions(+) create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/pom.xml create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/BusinessException.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationIdService.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalReferenceClient.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdComponentImpl.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScopeImpl.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/Conversational/META-INF/sca-contribution.xml create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/Conversational/conversational.composite create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/ConversationalWSDL/ConversationalServiceStateful.wsdl create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/ConversationalWSDL/META-INF/sca-contribution.xml create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/ConversationalWSDL/conversationalWSDL.composite create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationWSDLTestCase.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCaseOff.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallbackTestCase.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/RequestScopeTestCase.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatefulTestCase.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatelessTestCase.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatefulTestCase.java create mode 100644 tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatelessTestCase.java (limited to 'tags/java/sca/1.2.1/itest/conversations-ws') diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/pom.xml b/tags/java/sca/1.2.1/itest/conversations-ws/pom.xml new file mode 100644 index 0000000000..d5d2193833 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/pom.xml @@ -0,0 +1,64 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.2.1-incubating + ../pom.xml + + itest-conversations-ws + Apache Tuscany SCA Conversations Over binding.ws Integration Tests + + + + org.apache.tuscany.sca + tuscany-node-api + 1.2.1-incubating + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.2.1-incubating + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.2.1-incubating + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.2.1-incubating + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.2.1-incubating + runtime + + + diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/BusinessException.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/BusinessException.java new file mode 100644 index 0000000000..4f3a4573fc --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/BusinessException.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; + +public class BusinessException extends Exception { + + private String message; + + public BusinessException() { + super(); + } + + public BusinessException(String message) { + super(message); + setMessage(message); + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationIdService.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationIdService.java new file mode 100644 index 0000000000..15c397b902 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationIdService.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.conversational; + +import org.osoa.sca.annotations.Conversational; + +@Conversational +public interface ConversationIdService { + + String getCIDField(); + String getCIDSetter(); +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.java new file mode 100644 index 0000000000..b1dc926318 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.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; + +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.Remotable; + + +/** + * The callback interface used when testing caonversational callbacks + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ +@Remotable +@Conversational +public interface ConversationalCallback { + + // public void init(); + + // public void destroy(); + + public void initializeCount(int count); + + public void incrementCount(); + + public int retrieveCount(); + + public void businessException() throws BusinessException; + + @EndsConversation + public String endConversation(); + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java new file mode 100644 index 0000000000..a5b7fd9e1a --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java @@ -0,0 +1,51 @@ +/* + * 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.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.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 { + + public int runConversationFromInjectedReference(); + public int runConversationFromInjectedReference2(); + public int runConversationFromServiceReference(); + public int runConversationWithUserDefinedConversationId(); + public String runConversationCheckUserDefinedConversationId(); + public int runConversationCheckingScope(); + public int runConversationWithCallback(); + public int runConversationHavingPassedReference(); + public String runConversationBusinessException(); + public String runConversationBusinessExceptionCallback(); + public int runConversationCallingEndedConversation(); + public int runConversationCallingEndedConversationCallback(); + public String runConversationCallingEndedConversationCheckConversationId(); + public String runConversationCallingEndedConversationCallbackCheckConversationId(); + public int runConversationAgeTimeout(); + public int runConversationIdleTimeout(); + public int runConversationPrincipleError(); +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalReferenceClient.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalReferenceClient.java new file mode 100644 index 0000000000..6f8d2d0b6f --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/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.osoa.sca.CallableReference; +import org.osoa.sca.annotations.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 { + + public void incrementCount(CallableReference conversationalService); + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.java new file mode 100644 index 0000000000..3a6f8fb97f --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.java @@ -0,0 +1,58 @@ +/* + * 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.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.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 { + + public void initializeCount(int count); + + public void incrementCount(); + + public int retrieveCount(); + + //public void businessException() throws BusinessException; + + public void initializeCountCallback(int count); + + public void incrementCountCallback(); + + public int retrieveCountCallback(); + + //public void businessExceptionCallback() throws BusinessException; + + @EndsConversation + public String endConversation(); + + public String endConversationCallback(); + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java new file mode 100644 index 0000000000..580c404448 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java @@ -0,0 +1,59 @@ +/* + * 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.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.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 { + + + public void initializeCount(int count); + + public void incrementCount(); + + public int retrieveCount(); + + public void businessException() throws BusinessException; + + public void initializeCountCallback(int count); + + public void incrementCountCallback(); + + public int retrieveCountCallback(); + + public void businessExceptionCallback() throws BusinessException; + + @EndsConversation + public String endConversation(); + + public String endConversationCallback(); + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java new file mode 100644 index 0000000000..0db328b3d8 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java @@ -0,0 +1,44 @@ +/* + * 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.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.Remotable; + + +/** + * The callback interface used when testing caonversational callbacks + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ +@Remotable +public interface NonConversationalCallback { + + public void initializeCount(int count); + + public void incrementCount(); + + public int retrieveCount(); + + public void businessException() throws BusinessException; + + public String endConversation(); + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java new file mode 100644 index 0000000000..a3b76352bd --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java @@ -0,0 +1,76 @@ +/* + * 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.BusinessException; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(ConversationalService.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxAge="1 seconds") +public class ConversationAgeComponentImpl implements ConversationalService { + + private int count; + + public void businessException() throws BusinessException { + } + + public void businessExceptionCallback() throws BusinessException { + } + + 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/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdComponentImpl.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdComponentImpl.java new file mode 100644 index 0000000000..cffa76186a --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/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.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.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/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java new file mode 100644 index 0000000000..a9d247ed40 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java @@ -0,0 +1,76 @@ +/* + * 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.BusinessException; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(ConversationalService.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxIdleTime="1 seconds") +public class ConversationMaxIdleComponentImpl implements ConversationalService { + + private int count; + + public void businessException() throws BusinessException { + } + + public void businessExceptionCallback() throws BusinessException { + } + + 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/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.java new file mode 100644 index 0000000000..0b50bae846 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.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.BusinessException; +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.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.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 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 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 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 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 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 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 BusinessException { + throw new BusinessException("Business Exception"); + } + + public String endConversation(){ + calls.append("endConversation,"); + callbackCount = 0; + return null; + } + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java new file mode 100644 index 0000000000..31b2cc7849 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java @@ -0,0 +1,311 @@ +/* + * 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.BusinessException; +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.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.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 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 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 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 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 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 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 BusinessException { + throw new BusinessException("Business Exception"); + } + + public String endConversation(){ + calls.append("endConversation,"); + return null; + } + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java new file mode 100644 index 0000000000..d5fe3bbb6c --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java @@ -0,0 +1,318 @@ +/* + * 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.BusinessException; +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.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.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 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 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 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 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 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 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 BusinessException { + throw new BusinessException("Business Exception"); + } + + public String endConversation(){ + calls.append("endConversation,"); + callbackCount = 0; + return null; + } + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.java new file mode 100644 index 0000000000..9895032f53 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.java @@ -0,0 +1,43 @@ +/* + * 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.osoa.sca.CallableReference; +import org.osoa.sca.annotations.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 callableReference = conversationalService.getService(); + + callableReference.incrementCount(); + } + + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java new file mode 100644 index 0000000000..d83cb65046 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest.conversational.impl; + +import java.util.HashMap; + +import org.apache.tuscany.sca.itest.conversational.BusinessException; +import org.apache.tuscany.sca.itest.conversational.ConversationalCallback; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + + +/** + * 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 conversationalState = new HashMap(); + + // 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 = new Integer(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 BusinessException { + throw new BusinessException("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 BusinessException { + 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/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java new file mode 100644 index 0000000000..be1d4bc4d9 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.BusinessException; +import org.apache.tuscany.sca.itest.conversational.ConversationalCallback; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + + +/** + * 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 BusinessException { + calls.append("businessException,"); + throw new BusinessException("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 BusinessException { + 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/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java new file mode 100644 index 0000000000..514880c37c --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java @@ -0,0 +1,118 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.BusinessException; +import org.apache.tuscany.sca.itest.conversational.ConversationalServiceNonConversationalCallback; +import org.apache.tuscany.sca.itest.conversational.NonConversationalCallback; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + + +/** + * 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 BusinessException { + throw new BusinessException("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 BusinessException { + 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/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java new file mode 100644 index 0000000000..19724149a3 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java @@ -0,0 +1,123 @@ +/* + * 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.BusinessException; +import org.apache.tuscany.sca.itest.conversational.ConversationalCallback; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + + +/** + * 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) +public class ConversationalServiceStatelessImpl implements ConversationalService { + + @ConversationID + protected String conversationId; + + @Callback + protected ConversationalCallback conversationalCallback; + + // static area in which to hold conversational data + private static HashMap conversationalState = new HashMap(); + + // 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 = new Integer(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 BusinessException { + throw new BusinessException("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 BusinessException { + 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/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScopeImpl.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScopeImpl.java new file mode 100644 index 0000000000..6ab5e554e4 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScopeImpl.java @@ -0,0 +1,94 @@ +/* + * 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.BusinessException; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Service; + +@Service(ConversationalService.class) +public class ConversationalServiceStatelessScopeImpl implements ConversationalService { + + @ConversationID + protected String cid; + + static Map state = new HashMap(); + + 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 BusinessException { + throw new BusinessException("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 BusinessException { + throw new BusinessException("Business Exception"); + } + + public int retrieveCount() { + return state.get(cid); + } + + public int retrieveCountCallback() { + // TODO Auto-generated method stub + return 0; + } + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/Conversational/META-INF/sca-contribution.xml b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/Conversational/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..090e115fa6 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/Conversational/META-INF/sca-contribution.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/Conversational/conversational.composite b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/Conversational/conversational.composite new file mode 100644 index 0000000000..b1885bd772 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/Conversational/conversational.composite @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/ConversationalWSDL/ConversationalServiceStateful.wsdl b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/ConversationalWSDL/ConversationalServiceStateful.wsdl new file mode 100644 index 0000000000..20a92c9dc7 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/ConversationalWSDL/ConversationalServiceStateful.wsdl @@ -0,0 +1,383 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/ConversationalWSDL/META-INF/sca-contribution.xml b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/ConversationalWSDL/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..f4f0c1be7d --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/ConversationalWSDL/META-INF/sca-contribution.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/ConversationalWSDL/conversationalWSDL.composite b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/ConversationalWSDL/conversationalWSDL.composite new file mode 100644 index 0000000000..93bf866712 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/main/resources/ConversationalWSDL/conversationalWSDL.composite @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationWSDLTestCase.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationWSDLTestCase.java new file mode 100644 index 0000000000..61b5892dc2 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationWSDLTestCase.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; + + +import java.net.URL; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatelessImpl; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.impl.SCANodeFactoryImpl; +import org.apache.tuscany.sca.node.util.SCAContributionUtil; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class ConversationWSDLTestCase { + + private SCANode node; + private ConversationalClient conversationalStatelessClientStatefulService; + + @Before + public void setUp() throws Exception { + node = SCANodeFactory.newInstance().createSCANode(null, null); + node.addContribution("mycontribution", + ConversationWSDLTestCase.class.getResource("/ConversationalWSDL/.")); + node.addToDomainLevelComposite(new QName("http://conversations", "ConversationalWSDLITest")); + node.start(); + + conversationalStatelessClientStatefulService = node.getDomain().getService(ConversationalClient.class, + "ConversationalStatelessClientStatefulService"); + + ConversationalClientStatelessImpl.calls = new StringBuffer(); + } + + @After + public void tearDown() throws Exception { + node.destroy(); + conversationalStatelessClientStatefulService = null; + } + + @Test + public void testStatelessStatefulConversationFromInjectedReference() { + int count = conversationalStatelessClientStatefulService.runConversationFromInjectedReference(); + Assert.assertEquals(2, count); + } + + //@Test + public void testKeepServerRunning() throws Exception { + System.out.println("press enter to continue"); + System.in.read(); + } + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCaseOff.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCaseOff.java new file mode 100644 index 0000000000..f97a8689be --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCaseOff.java @@ -0,0 +1,610 @@ +/* + * 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 junit.framework.Assert; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +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.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +public class ConversationalTestCaseOff { + + private static SCADomain domain; + 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 { + domain = SCADomain.newInstance("conversational.composite"); + + conversationalStatelessClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatelessService"); + + conversationalStatelessClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatefulService"); + + conversationalStatefulClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatelessService"); + + conversationalStatefulClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatefulService"); + conversationalStatelessClientRequestService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientRequestService"); + conversationalStatefulClientNonConversationalCallbackStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientNonConversationalCallbackStatefulService"); + + // 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(); + + } catch(Exception ex) { + System.err.println(ex.toString()); + } + + } + + @AfterClass + public static void tearDown() throws Exception { + domain.close(); + } + + private static 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(); + + } + + // 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("init,initializeCount,incrementCount,retrieveCount,endConversation,", + ConversationalServiceRequestImpl.calls.toString()); + //init,initializeCount,init,incrementCount,init,retrieveCount,init,endConversation, + } + + @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(); + ConversationalServiceStatefulNonConversationalCallbackImpl.calls = new StringBuffer(); + conversationalStatefulClientNonConversationalCallbackStatelessService.runConversationCheckingScope(); + Assert.assertEquals("init,initializeCount,incrementCount,retrieveCount,endConversation,destroy,", + ConversationalServiceStatefulNonConversationalCallbackImpl.calls.toString()); + } + + //@Test + public void testStatefulNonConversationalCallbackStatefulConversationWithCallback() { + resetCallStack(); + ConversationalClientStatefulNonConversationalCallbackImpl.calls = new StringBuffer(); + 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); + } + + + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallbackTestCase.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallbackTestCase.java new file mode 100644 index 0000000000..2d7af475a7 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallbackTestCase.java @@ -0,0 +1,202 @@ +/* + * 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 javax.xml.namespace.QName; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.domain.SCADomain; +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.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +public class NonConversationalCallbackTestCase { + + private static SCADomain domain; + private static SCANode 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 { + node = SCANodeFactory.newInstance().createSCANode(null, null); + node.addContribution("mycontribution", + StatefulStatefulTestCase.class.getResource("/Conversational/.")); + node.addToDomainLevelComposite(new QName("http://conversations", "ConversationalITest")); + node.start(); + domain = node.getDomain(); + + conversationalStatelessClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatelessService"); + + conversationalStatelessClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatefulService"); + + conversationalStatefulClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatelessService"); + + conversationalStatefulClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatefulService"); + conversationalStatelessClientRequestService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientRequestService"); + conversationalStatefulClientNonConversationalCallbackStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientNonConversationalCallbackStatefulService"); + + // 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(); + + } catch(Exception ex) { + System.err.println(ex.toString()); + } + + } + + @AfterClass + public static void tearDown() throws Exception { + node.destroy(); + domain = null; + conversationalStatelessClientStatelessService = null; + conversationalStatelessClientStatefulService = null; + conversationalStatefulClientStatelessService = null; + conversationalStatefulClientStatefulService = null; + conversationalStatelessClientRequestService = null; + conversationalStatefulClientNonConversationalCallbackStatelessService = null; + + } + + private static 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(); + + } + + // 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(); + ConversationalServiceStatefulNonConversationalCallbackImpl.calls = new StringBuffer(); + conversationalStatefulClientNonConversationalCallbackStatelessService.runConversationCheckingScope(); + Assert.assertEquals("init,initializeCount,incrementCount,retrieveCount,endConversation,destroy,", + ConversationalServiceStatefulNonConversationalCallbackImpl.calls.toString()); + } + + //@Test + public void testStatefulNonConversationalCallbackStatefulConversationWithCallback() { + resetCallStack(); + ConversationalClientStatefulNonConversationalCallbackImpl.calls = new StringBuffer(); + 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); + } + + + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/RequestScopeTestCase.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/RequestScopeTestCase.java new file mode 100644 index 0000000000..d3868ddaf4 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/RequestScopeTestCase.java @@ -0,0 +1,211 @@ +/* + * 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 javax.xml.namespace.QName; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.domain.SCADomain; +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.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +public class RequestScopeTestCase { + + private static SCADomain domain; + private static SCANode 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 { + node = SCANodeFactory.newInstance().createSCANode(null, null); + node.addContribution("mycontribution", + StatefulStatefulTestCase.class.getResource("/Conversational/.")); + node.addToDomainLevelComposite(new QName("http://conversations", "ConversationalITest")); + node.start(); + domain = node.getDomain(); + + conversationalStatelessClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatelessService"); + + conversationalStatelessClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatefulService"); + + conversationalStatefulClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatelessService"); + + conversationalStatefulClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatefulService"); + conversationalStatelessClientRequestService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientRequestService"); + conversationalStatefulClientNonConversationalCallbackStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientNonConversationalCallbackStatefulService"); + + // 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(); + + } catch(Exception ex) { + System.err.println(ex.toString()); + } + + } + + @AfterClass + public static void tearDown() throws Exception { + node.destroy(); + domain = null; + conversationalStatelessClientStatelessService = null; + conversationalStatelessClientStatefulService = null; + conversationalStatefulClientStatelessService = null; + conversationalStatefulClientStatefulService = null; + conversationalStatelessClientRequestService = null; + conversationalStatefulClientNonConversationalCallbackStatelessService = null; + } + + private static 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(); + + } + + // 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("init,initializeCount,incrementCount,retrieveCount,endConversation,", + ConversationalServiceRequestImpl.calls.toString()); + //init,initializeCount,init,incrementCount,init,retrieveCount,init,endConversation, + } + + @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); + } + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatefulTestCase.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatefulTestCase.java new file mode 100644 index 0000000000..6fc0391b34 --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatefulTestCase.java @@ -0,0 +1,197 @@ +/* + * 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 javax.xml.namespace.QName; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.domain.SCADomain; +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.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.util.SCAContributionUtil; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +public class StatefulStatefulTestCase { + + private static SCADomain domain; + private static SCANode 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 { + node = SCANodeFactory.newInstance().createSCANode(null, null); + node.addContribution("mycontribution", + StatefulStatefulTestCase.class.getResource("/Conversational/.")); + node.addToDomainLevelComposite(new QName("http://conversations", "ConversationalITest")); + node.start(); + domain = node.getDomain(); + + conversationalStatelessClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatelessService"); + + conversationalStatelessClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatefulService"); + + conversationalStatefulClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatelessService"); + + conversationalStatefulClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatefulService"); + conversationalStatelessClientRequestService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientRequestService"); + conversationalStatefulClientNonConversationalCallbackStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientNonConversationalCallbackStatefulService"); + + // 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(); + + } catch(Exception ex) { + System.err.println(ex.toString()); + } + + } + + @AfterClass + public static void tearDown() throws Exception { + node.destroy(); + domain = null; + conversationalStatelessClientStatelessService = null; + conversationalStatelessClientStatefulService = null; + conversationalStatefulClientStatelessService = null; + conversationalStatefulClientStatefulService = null; + conversationalStatelessClientRequestService = null; + conversationalStatefulClientNonConversationalCallbackStatelessService = null; + } + + private static 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(); + + } + + // 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); + } + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatelessTestCase.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatelessTestCase.java new file mode 100644 index 0000000000..432039d15d --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatelessTestCase.java @@ -0,0 +1,196 @@ +/* + * 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 javax.xml.namespace.QName; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.domain.SCADomain; +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.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +public class StatefulStatelessTestCase { + + private static SCADomain domain; + private static SCANode 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 { + node = SCANodeFactory.newInstance().createSCANode(null, null); + node.addContribution("mycontribution", + StatefulStatefulTestCase.class.getResource("/Conversational/.")); + node.addToDomainLevelComposite(new QName("http://conversations", "ConversationalITest")); + node.start(); + domain = node.getDomain(); + + conversationalStatelessClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatelessService"); + + conversationalStatelessClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatefulService"); + + conversationalStatefulClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatelessService"); + + conversationalStatefulClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatefulService"); + conversationalStatelessClientRequestService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientRequestService"); + conversationalStatefulClientNonConversationalCallbackStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientNonConversationalCallbackStatefulService"); + + // 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(); + + } catch(Exception ex) { + System.err.println(ex.toString()); + } + + } + + @AfterClass + public static void tearDown() throws Exception { + node.destroy(); + domain = null; + conversationalStatelessClientStatelessService = null; + conversationalStatelessClientStatefulService = null; + conversationalStatefulClientStatelessService = null; + conversationalStatefulClientStatefulService = null; + conversationalStatelessClientRequestService = null; + conversationalStatefulClientNonConversationalCallbackStatelessService = null; + } + + private static 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(); + + } + + // 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); + } + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatefulTestCase.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatefulTestCase.java new file mode 100644 index 0000000000..4db651a88a --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatefulTestCase.java @@ -0,0 +1,209 @@ +/* + * 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 javax.xml.namespace.QName; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.domain.SCADomain; +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.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +public class StatelessStatefulTestCase { + + private static SCADomain domain; + private static SCANode 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 { + node = SCANodeFactory.newInstance().createSCANode(null, null); + node.addContribution("mycontribution", + StatefulStatefulTestCase.class.getResource("/Conversational/.")); + node.addToDomainLevelComposite(new QName("http://conversations", "ConversationalITest")); + node.start(); + domain = node.getDomain(); + + conversationalStatelessClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatelessService"); + + conversationalStatelessClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatefulService"); + + conversationalStatefulClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatelessService"); + + conversationalStatefulClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatefulService"); + conversationalStatelessClientRequestService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientRequestService"); + conversationalStatefulClientNonConversationalCallbackStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientNonConversationalCallbackStatefulService"); + + // 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(); + + } catch(Exception ex) { + System.err.println(ex.toString()); + } + + } + + @AfterClass + public static void tearDown() throws Exception { + node.destroy(); + domain = null; + conversationalStatelessClientStatelessService = null; + conversationalStatelessClientStatefulService = null; + conversationalStatefulClientStatelessService = null; + conversationalStatefulClientStatefulService = null; + conversationalStatelessClientRequestService = null; + conversationalStatefulClientNonConversationalCallbackStatelessService = null; + } + + private static 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(); + + } + + // 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); + } + + +} diff --git a/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatelessTestCase.java b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatelessTestCase.java new file mode 100644 index 0000000000..3846a8a38a --- /dev/null +++ b/tags/java/sca/1.2.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatelessTestCase.java @@ -0,0 +1,196 @@ +/* + * 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 javax.xml.namespace.QName; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.domain.SCADomain; +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.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +public class StatelessStatelessTestCase { + + private static SCADomain domain; + private static SCANode 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 { + node = SCANodeFactory.newInstance().createSCANode(null, null); + node.addContribution("mycontribution", + StatefulStatefulTestCase.class.getResource("/Conversational/.")); + node.addToDomainLevelComposite(new QName("http://conversations", "ConversationalITest")); + node.start(); + domain = node.getDomain(); + + conversationalStatelessClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatelessService"); + + conversationalStatelessClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatefulService"); + + conversationalStatefulClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatelessService"); + + conversationalStatefulClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatefulService"); + conversationalStatelessClientRequestService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientRequestService"); + conversationalStatefulClientNonConversationalCallbackStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientNonConversationalCallbackStatefulService"); + + // 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(); + + } catch(Exception ex) { + System.err.println(ex.toString()); + } + + } + + @AfterClass + public static void tearDown() throws Exception { + node.destroy(); + domain = null; + conversationalStatelessClientStatelessService = null; + conversationalStatelessClientStatefulService = null; + conversationalStatefulClientStatelessService = null; + conversationalStatefulClientStatefulService = null; + conversationalStatelessClientRequestService = null; + conversationalStatefulClientNonConversationalCallbackStatelessService = null; + } + + private static 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(); + + } + + + // 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); + } + +} -- cgit v1.2.3