From 6fadbc9cd1fcf03d0b3630f772d91df149b70428 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:07:19 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835123 13f79535-47bb-0310-9956-ffa450edef68 --- .../conversational/ConversationIdTestCase.java | 54 ++ .../conversational/ConversationalAgeTestCase.java | 103 ++++ .../conversational/ConversationalJ2SETestCase.java | 84 +++ .../conversational/ConversationalTestCase.java | 585 +++++++++++++++++++++ 4 files changed, 826 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationIdTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalJ2SETestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java (limited to 'sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org') diff --git a/sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationIdTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationIdTestCase.java new file mode 100644 index 0000000000..9cce341c60 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationIdTestCase.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.itest.conversational; + + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class ConversationIdTestCase { + + private SCADomain domain; + + @Before + public void setUp() throws Exception { + domain = SCADomain.newInstance("conversationId.composite"); + + } + + @After + public void tearDown() throws Exception { + if (domain != null) { + domain.close(); + } + } + + @Test + public void testConversationId() { + ConversationIdService service = + domain.getService(ConversationIdService.class, "ConversationIdComponent"); + Assert.assertNotNull(service.getCIDField()); + Assert.assertNotNull(service.getCIDSetter()); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTestCase.java new file mode 100644 index 0000000000..f3b4a92d6f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTestCase.java @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.itest.conversational; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.osoa.sca.ConversationEndedException; + +public class ConversationalAgeTestCase { + + private SCADomain domain; + + @Before + public void setUp() throws Exception { + System.setProperty("org.apache.tuscany.sca.core.scope.ConversationalScopeContainer.ReaperInterval", "2"); + domain = SCADomain.newInstance("ConversationAge.composite"); + + } + + @After + public void tearDown() throws Exception { + System.clearProperty("org.apache.tuscany.sca.core.scope.ConversationalScopeContainer.ReaperInterval"); + if (domain != null) { + domain.close(); + } + } + + @Test + public void testMaxAge() throws InterruptedException { + + ConversationalService conversationalService = + domain.getService(ConversationalService.class, "ConversationAgeComponent"); + + Assert.assertEquals(0, conversationalService.retrieveCount()); + conversationalService.initializeCount(42); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Thread.sleep(500); + try { + Assert.assertEquals(42, conversationalService.retrieveCount()); + } catch (ConversationEndedException e) { + Assert.fail(); + } + } + + @Test + public void testAgeExpired() throws InterruptedException { + + ConversationalService conversationalService = + domain.getService(ConversationalService.class, "ConversationAgeComponent"); + + Assert.assertEquals(0, conversationalService.retrieveCount()); + conversationalService.initializeCount(42); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Thread.sleep(1100); + try { + Assert.assertEquals(0, conversationalService.retrieveCount()); + Assert.fail(); + } catch (ConversationEndedException e) { + // expected + } + } + + @Test + public void testMaxIdle() throws InterruptedException { + + ConversationalService conversationalService = + domain.getService(ConversationalService.class, "ConversationIdleComponent"); + + Assert.assertEquals(0, conversationalService.retrieveCount()); + conversationalService.initializeCount(42); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Thread.sleep(1100); + try { + Assert.assertEquals(0, conversationalService.retrieveCount()); + } catch (ConversationEndedException e) { + // expected + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalJ2SETestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalJ2SETestCase.java new file mode 100644 index 0000000000..8480e04028 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalJ2SETestCase.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.itest.conversational; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class ConversationalJ2SETestCase { + + private SCADomain domain; + + @Before + public void setUp() throws Exception { + domain = SCADomain.newInstance("conversational.composite"); + + } + + @After + public void tearDown() throws Exception { + if (domain != null) { + domain.close(); + } + } + + @Test + public void testStatefulConversation() { + ConversationalService conversationalService = + domain.getService(ConversationalService.class, "ConversationalServiceStateful"); + + conversationalService.initializeCount(1); + Assert.assertEquals(1, conversationalService.retrieveCount()); + conversationalService.incrementCount(); + Assert.assertEquals(2, conversationalService.retrieveCount()); + conversationalService.endConversation(); + + Assert.assertEquals(0, conversationalService.retrieveCount()); + + conversationalService.initializeCount(4); + Assert.assertEquals(4, conversationalService.retrieveCount()); + conversationalService.incrementCount(); + Assert.assertEquals(5, conversationalService.retrieveCount()); + conversationalService.endConversation(); + + } + + @Test + public void testStatelessConversation() { + ConversationalService conversationalService = + domain.getService(ConversationalService.class, "ConversationalServiceStateless"); + + conversationalService.initializeCount(1); + Assert.assertEquals(1, conversationalService.retrieveCount()); + conversationalService.incrementCount(); + Assert.assertEquals(2, conversationalService.retrieveCount()); + conversationalService.endConversation(); + + conversationalService.initializeCount(4); + Assert.assertEquals(4, conversationalService.retrieveCount()); + conversationalService.incrementCount(); + Assert.assertEquals(5, conversationalService.retrieveCount()); + conversationalService.endConversation(); + + } +} diff --git a/sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java new file mode 100644 index 0000000000..ee623f32e9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java @@ -0,0 +1,585 @@ +/* + * 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.Before; +import org.junit.Test; + +public class ConversationalTestCase { + + private SCADomain domain; + private ConversationalClient conversationalStatelessClientStatelessService; + private ConversationalClient conversationalStatelessClientStatefulService; + private ConversationalClient conversationalStatefulClientStatelessService; + private ConversationalClient conversationalStatefulClientStatefulService; + private ConversationalClient conversationalStatelessClientRequestService; + private ConversationalClient conversationalStatefulClientNonConversationalCallbackStatelessService; + + @Before + public 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()); + } + + } + + @After + public void tearDown() throws Exception { + domain.close(); + } + + // 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() { + conversationalStatelessClientStatefulService.runConversationCheckingScope(); + Assert.assertEquals("init,initializeCount,incrementCount,retrieveCount,endConversation,destroy,", + ConversationalServiceStatefulImpl.calls.toString()); + } + + @Test + public void testStatelessStatefulConversationWithCallback() { + 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() { + conversationalStatelessClientStatelessService.runConversationCheckingScope(); + Assert.assertEquals("init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,", + ConversationalServiceStatelessImpl.calls.toString()); + } + + @Test + public void testStatelessStatelessConversationWithCallback() { + 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() { + conversationalStatefulClientStatefulService.runConversationCheckingScope(); + Assert.assertEquals("init,initializeCount,incrementCount,retrieveCount,endConversation,destroy,", + ConversationalServiceStatefulImpl.calls.toString()); + } + + @Test + public void testStatefulStatefulConversationWithCallback() { + 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() { + conversationalStatefulClientStatelessService.runConversationCheckingScope(); + Assert.assertEquals("init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,", + ConversationalServiceStatelessImpl.calls.toString()); + } + + @Test + public void testStatefulStatelessConversationWithCallback() { + 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() { + ConversationalServiceRequestImpl.calls = new StringBuffer(); + conversationalStatelessClientRequestService.runConversationCheckingScope(); + Assert.assertEquals("init,initializeCount,incrementCount,retrieveCount,endConversation,", + ConversationalServiceRequestImpl.calls.toString()); + } + + @Test + public void testStatelessRequestConversationWithCallback() { + 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() { + ConversationalServiceStatefulNonConversationalCallbackImpl.calls = new StringBuffer(); + conversationalStatefulClientNonConversationalCallbackStatelessService.runConversationCheckingScope(); + Assert.assertEquals("init,initializeCount,incrementCount,retrieveCount,endConversation,destroy,", + ConversationalServiceStatefulNonConversationalCallbackImpl.calls.toString()); + } + + @Test + public void testStatefulNonConversationalCallbackStatefulConversationWithCallback() { + 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); + } + +*/ + +} -- cgit v1.2.3