You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2007/09/05 01:33:08 UTC

svn commit: r572838 - in /incubator/tuscany/java/sca/itest/conversations/src: main/java/org/apache/tuscany/sca/itest/conversational/ main/java/org/apache/tuscany/sca/itest/conversational/impl/ main/resources/ test/java/org/apache/tuscany/sca/itest/conv...

Author: slaws
Date: Tue Sep  4 16:33:07 2007
New Revision: 572838

URL: http://svn.apache.org/viewvc?rev=572838&view=rev
Log:
TUSCANY-1660
Add new test for request scope
Also add test for non-conversation callback. Not directly related to this but added it in at the same time

Added:
    incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java
    incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java
    incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java
    incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java
    incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java
Modified:
    incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java
    incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java
    incubator/tuscany/java/sca/itest/conversations/src/main/resources/conversational.composite
    incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java

Added: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java?rev=572838&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalServiceNonConversationalCallback.java Tue Sep  4 16:33:07 2007
@@ -0,0 +1,62 @@
+/*
+ * 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 init();
+    
+    public void destroy();
+    
+    public void initializeCount(int count);
+    
+    public void incrementCount();
+    
+    public int retrieveCount();
+    
+    public void businessException() throws Exception;        
+    
+    public void initializeCountCallback(int count);
+    
+    public void incrementCountCallback();
+    
+    public int retrieveCountCallback();
+    
+    public void businessExceptionCallback() throws Exception;    
+    
+    @EndsConversation
+    public String endConversation();
+    
+    public String endConversationCallback();
+
+}

Added: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java?rev=572838&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallback.java Tue Sep  4 16:33:07 2007
@@ -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;
+
+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 init();
+    
+    public void destroy();
+    
+    public void initializeCount(int count);
+    
+    public void incrementCount();
+    
+    public int retrieveCount();
+    
+    public void businessException() throws Exception;        
+    
+    public String endConversation();
+
+}

Added: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java?rev=572838&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulNonConversationalCallbackImpl.java Tue Sep  4 16:33:07 2007
@@ -0,0 +1,271 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.itest.conversational.impl;
+
+import org.apache.tuscany.sca.itest.conversational.ConversationalCallback;
+import org.apache.tuscany.sca.itest.conversational.ConversationalClient;
+import org.apache.tuscany.sca.itest.conversational.ConversationalReferenceClient;
+import org.apache.tuscany.sca.itest.conversational.ConversationalService;
+import org.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<ConversationalService> serviceReference = componentContext.getServiceReference(ConversationalService.class, 
+                                                                                                        "conversationalService");
+        ConversationalService callableReference = serviceReference.getService();
+        
+        callableReference.initializeCount(1);
+        callableReference.incrementCount();
+        clientCount = callableReference.retrieveCount();
+        callableReference.endConversation();
+        
+        serviceReference.getConversation().end();
+        
+        return clientCount;
+    }	
+    public int runConversationWithUserDefinedConversationId(){
+        calls.append("runConversationWithUserDefinedConversationId,");
+        ServiceReference<ConversationalService> serviceReference = componentContext.getServiceReference(ConversationalService.class, 
+                                                                                                        "conversationalService");
+        serviceReference.setConversationID("MyConversation1");
+        
+        ConversationalService callableReference = serviceReference.getService();
+        
+        callableReference.initializeCount(1);
+        callableReference.incrementCount();
+        clientCount = callableReference.retrieveCount();
+        callableReference.endConversation();
+        
+        serviceReference.getConversation().end();
+        
+        return clientCount;
+    }    
+    public String runConversationCheckUserDefinedConversationId(){
+        calls.append("runConversationCheckUserDefinedConversationId,");
+        ServiceReference<ConversationalService> serviceReference = componentContext.getServiceReference(ConversationalService.class, 
+                                                                                                        "conversationalService");
+        serviceReference.setConversationID("MyConversation2");
+        
+        ConversationalService callableReference = serviceReference.getService();
+        
+        callableReference.initializeCount(1);
+        callableReference.incrementCount();
+        clientCount = callableReference.retrieveCount();
+        return callableReference.endConversation();
+              
+    }      
+    public int runConversationCheckingScope(){
+        calls.append("runConversationCheckingScope,");
+        // run a conversation
+        return runConversationFromInjectedReference();
+        
+        // test will then use a static method to find out how many times 
+        // init/destroy were called
+    }    
+	public int runConversationWithCallback(){
+	    calls.append("runConversationWithCallback,");
+	    callbackCount = 2;
+        conversationalService.initializeCountCallback(1);
+        conversationalService.incrementCountCallback();
+        clientCount = conversationalService.retrieveCountCallback();
+        conversationalService.endConversationCallback();
+        
+        return clientCount;
+    } 
+    public int runConversationHavingPassedReference(){
+        calls.append("runConversationHavingPassedReference,");
+        ServiceReference<ConversationalService> serviceReference = componentContext.getServiceReference(ConversationalService.class, 
+                                                                                                        "conversationalService");       
+        ConversationalService callableReference = serviceReference.getService();
+        
+        callableReference.initializeCount(1);
+        callableReference.incrementCount();
+        conversationalReferenceClient.incrementCount(serviceReference);
+        clientCount = callableReference.retrieveCount();
+        callableReference.endConversation();
+        
+        serviceReference.getConversation().end();
+        
+        return clientCount;
+    }
+    public String runConversationBusinessException(){
+        calls.append("runConversationbusinessException,");      
+        try {
+            conversationalService.initializeCount(1);
+            conversationalService.businessException();
+            clientCount = conversationalService.retrieveCount();
+            conversationalService.endConversation();
+        } catch(Exception ex) {
+            return ex.getMessage();
+        }
+         
+        return "No Exception Returned";
+    }
+    
+    public String runConversationBusinessExceptionCallback(){
+        calls.append("runConversationbusinessExceptionCallback,");
+        try {
+            conversationalService.initializeCountCallback(1);
+            conversationalService.businessExceptionCallback();
+            clientCount = conversationalService.retrieveCountCallback();
+            conversationalService.endConversationCallback();
+        } catch(Exception ex) {
+            return ex.getMessage();
+        }
+         
+        return "No Exception Returned";
+    }   
+    
+    public int runConversationCallingEndedConversation(){
+        calls.append("runConversationCallingEndedConversation,");
+        conversationalService.initializeCount(1);
+        conversationalService.endConversation();
+        return conversationalService.retrieveCount();
+    }   
+    
+    public int runConversationCallingEndedConversationCallback(){
+        calls.append("runConversationCallingEndedConversationCallback,");
+        conversationalService.initializeCountCallback(1);
+        conversationalService.endConversationCallback();
+        return conversationalService.retrieveCountCallback();
+    }  
+    
+    public int runConversationAgeTimeout(){
+        calls.append("runConversationAgeTimeout,");
+        // done in other testing
+        return clientCount;
+    }
+    public int runConversationIdleTimeout(){
+        calls.append("runConversationIdleTimeout,");
+        // done in other testing
+        return clientCount;
+    }
+    public int runConversationPrincipleError(){
+        calls.append("runConversationPrincipleError,");
+        // TODO - when policy framework is done
+        return clientCount;
+    }
+    
+    
+    // From ConversationalCallback
+    @Init
+    public void init(){
+        calls.append("init,");
+    }
+    
+    @Destroy
+    public void destroy(){
+        calls.append("destroy,"); 
+    }
+    
+    public void initializeCount(int count){
+        calls.append("initializeCount,");
+        callbackCount += count;
+    }
+    
+    public void incrementCount(){
+        calls.append("incrementCount,");
+        callbackCount++;
+    }
+    
+    public int retrieveCount(){
+        calls.append("retrieveCount,");
+        return  callbackCount;
+    }
+    
+    public void businessException() throws Exception {
+        throw new Exception("Business Exception");
+    }     
+    
+    public String endConversation(){
+        calls.append("endConversation,");
+        return null;
+    }
+
+}

Modified: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java?rev=572838&r1=572837&r2=572838&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java (original)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java Tue Sep  4 16:33:07 2007
@@ -71,7 +71,7 @@
     public int runConversationFromInjectedReference2(){
         calls.append("runConversationFromInjectedReference2,");   
 
-        // no test the second reference        
+        // now test the second reference        
         conversationalService2.initializeCount(1);
         conversationalService2.incrementCount();
         

Added: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java?rev=572838&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceRequestImpl.java Tue Sep  4 16:33:07 2007
@@ -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.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<String, Integer> conversationalState = new HashMap<String, Integer>();
+   
+    // a static member variable that records the number of times this service is called
+    public static StringBuffer calls = new StringBuffer();
+   
+    @Init
+    public void init(){
+        calls.append("init,");
+    }
+    
+    @Destroy
+    public void destroy(){
+        calls.append("destroy,");
+    }
+    
+    public void initializeCount(int count){
+        calls.append("initializeCount,");
+        Integer conversationalCount = 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 Exception {
+        throw new Exception("Business Exception");
+    }    
+    
+    public void initializeCountCallback(int count){
+        calls.append("initializeCountCallback,");
+        initializeCount(count);
+        conversationalCallback.initializeCount(count);
+    }
+    
+    public void incrementCountCallback(){
+        calls.append("incrementCountCallback,");
+        incrementCount();
+        conversationalCallback.incrementCount();
+    }
+    
+    public int retrieveCountCallback(){
+        calls.append("retrieveCountCallback,");
+        return conversationalCallback.retrieveCount();
+    }
+    
+    public void businessExceptionCallback() throws Exception {
+        calls.append("businessExceptionCallback,");        
+        conversationalCallback.businessException();
+    }
+    
+    public String endConversation(){
+        calls.append("endConversation,");
+        conversationalState.remove(conversationId);
+        return conversationId;
+    }
+    
+    public String endConversationCallback(){
+        calls.append("endConversationCallback,");       
+        return conversationalCallback.endConversation();
+    }   
+}

Added: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java?rev=572838&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulNonConversationalCallbackImpl.java Tue Sep  4 16:33:07 2007
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.itest.conversational.impl;
+
+import org.apache.tuscany.sca.itest.conversational.ConversationalServiceNonConversationalCallback;
+import org.apache.tuscany.sca.itest.conversational.NonConversationalCallback;
+import org.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 Exception {
+        throw new Exception("Business Exception");
+    }     
+    
+    public void initializeCountCallback(int count){
+        calls.append("initializeCountCallback,"); 
+        this.count = count;
+        nonConversationalCallback.initializeCount(count);
+    }
+    
+    public void incrementCountCallback(){
+        calls.append("incrementCountCallback,"); 
+        count++;
+        nonConversationalCallback.incrementCount();
+    }
+    
+    public int retrieveCountCallback(){
+        calls.append("retrieveCountCallback,"); 
+        return nonConversationalCallback.retrieveCount();
+    }
+    
+    public void businessExceptionCallback() throws Exception {
+        calls.append("businessExceptionCallback,");        
+        nonConversationalCallback.businessException();
+    }    
+    
+    public String endConversation(){
+        calls.append("endConversation,"); 
+        count = 0;
+        return conversationId;
+    }
+    
+    public String endConversationCallback(){
+        calls.append("endConversationCallback,"); 
+        return nonConversationalCallback.endConversation();
+    }
+}

Modified: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java?rev=572838&r1=572837&r2=572838&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java (original)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java Tue Sep  4 16:33:07 2007
@@ -26,6 +26,7 @@
 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;
 
 

Modified: incubator/tuscany/java/sca/itest/conversations/src/main/resources/conversational.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/resources/conversational.composite?rev=572838&r1=572837&r2=572838&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/resources/conversational.composite (original)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/resources/conversational.composite Tue Sep  4 16:33:07 2007
@@ -22,7 +22,7 @@
 	name="ConversationalITest">
  	      
     <component name="ConversationalStatelessClientStatelessService">
-		<implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatelessImpl"/>
+	    <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatelessImpl"/>
         <reference name="conversationalReferenceClient" target="ConversationalReferenceClient"/>		
 		<reference name="conversationalService" target="ConversationalServiceStatelessSL"/>
 		<reference name="conversationalService2" target="ConversationalServiceStatelessSL"/>
@@ -47,7 +47,21 @@
         <reference name="conversationalReferenceClient" target="ConversationalReferenceClient"/>       
         <reference name="conversationalService" target="ConversationalServiceStateful"/>
         <reference name="conversationalService2" target="ConversationalServiceStateful"/>        
-    </component>   
+    </component>  
+    
+    <component name="ConversationalStatelessClientRequestService">
+	    <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatelessImpl"/>
+        <reference name="conversationalReferenceClient" target="ConversationalReferenceClient"/>		
+		<reference name="conversationalService" target="ConversationalServiceRequest"/>
+		<reference name="conversationalService2" target="ConversationalServiceRequest"/>
+    </component> 
+    
+    <component name="ConversationalStatefulClientNonConversationalCallbackStatefulService">
+        <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatefulNonConversationalCallbackImpl"/>
+        <reference name="conversationalReferenceClient" target="ConversationalReferenceClient"/>       
+        <reference name="conversationalService" target="ConversationalServiceStatefulNonConversationalCallback"/>
+        <reference name="conversationalService2" target="ConversationalServiceStatefulNonConversationalCallback"/>        
+    </component>     
     
     <component name="ConversationalReferenceClient">
         <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalReferenceClientImpl"/>
@@ -61,8 +75,16 @@
 		<implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatelessScope"/>
 	</component>  
 	
-	<component name="ConversationalServiceStatelessSL">
+    <component name="ConversationalServiceStatelessSL">
         <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatelessImpl"/>
     </component> 
+
+    <component name="ConversationalServiceRequest">
+        <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceRequestImpl"/>
+    </component> 
+    
+    <component name="ConversationalServiceStatefulNonConversationalCallback">
+		<implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatefulNonConversationalCallbackImpl"/>
+	</component>   
 
 </composite>

Modified: incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java?rev=572838&r1=572837&r2=572838&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java (original)
+++ incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java Tue Sep  4 16:33:07 2007
@@ -23,8 +23,11 @@
 
 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;
@@ -36,31 +39,41 @@
     private ConversationalClient conversationalStatelessClientStatelessService;
     private ConversationalClient conversationalStatelessClientStatefulService;
     private ConversationalClient conversationalStatefulClientStatelessService;
-    private ConversationalClient conversationalStatefulClientStatefulService;    
+    private ConversationalClient conversationalStatefulClientStatefulService; 
+    private ConversationalClient conversationalStatelessClientRequestService;
+    private ConversationalClient conversationalStatefulClientNonConversationalCallbackStatelessService;    
 
     @Before
     public void setUp() throws Exception {
-        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");
-
-
-        // 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();
+    	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());
+    	}
                
     }
 
@@ -68,10 +81,9 @@
     public void tearDown() throws Exception {
         domain.close();
     }
-  
+ 
     // stateless client stateful service tests
     // =======================================
-/* 
     @Test
     public void testStatelessStatefulConversationFromInjectedReference() {
         int count = conversationalStatelessClientStatefulService.runConversationFromInjectedReference();
@@ -89,7 +101,7 @@
         int count = conversationalStatelessClientStatefulService.runConversationFromServiceReference();
         Assert.assertEquals(2, count);
     }          
-*/   
+   
     @Test
     public void testStatelessStatefulConversationWithUserDefinedConversationId() {
         int count = conversationalStatelessClientStatefulService.runConversationWithUserDefinedConversationId();
@@ -147,7 +159,7 @@
         int count = conversationalStatelessClientStatefulService.runConversationCallingEndedConversationCallback();
         Assert.assertEquals(0, count);
     }     
-    
+
     // stateless client stateless service tests
     // ========================================
     @Test
@@ -342,6 +354,155 @@
     public void testStatefulStatelessConversationCallingEndedConversationCallback() {
         int count = conversationalStatefulClientStatelessService.runConversationCallingEndedConversationCallback();
         Assert.assertEquals(0, count);
-    }        
+    }     
+    
+    // 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);
+    }  
+    
+    // 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);
+    }         
         
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org