Author: kwilliams
Date: Wed Feb 27 22:18:31 2008
New Revision: 631862

URL: http://svn.apache.org/viewvc?rev=631862&view=rev
Log:
Adding more tests for Conversation Liftime

Modified:
    
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java
    
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java
    
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java
    
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java
    
incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationLifetimeTestCase.java

Modified: 
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java?rev=631862&r1=631861&r2=631862&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java
 (original)
+++ 
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java
 Wed Feb 27 22:18:31 2008
@@ -26,39 +26,15 @@
 @Conversational
 public interface CService {
 
-    /**
-     * Returns the state for this service.
-     * 
-     * @return The state for this service
-     */
     String getState();
 
-    /**
-     * Returns the state for the other service that this service is using
-     * 
-     * @return The state for the other service that this service is using
-     */
-    String getStateOnD();
-
-    /**
-     * Sets the state for this service.
-     * 
-     * @param aState The state for this service
-     */
     void setState(String aState);
-
-    /**
-     * Sets the state for the other service that this service is using
-     * 
-     * @param aState The state for the other service that this service is using
-     */
-    void setStateOnD(String aState);
-    
-    Object getConversationIDWithD();
     
-    Object getUserConversationIDWithD();
+    Object getConversationID();
+        
+    void setConversationID(String theID);
     
-    void setUserConversationIDWithD(String theID);
+    void endConversation();
     
-    void endConversationWithD();
+    void endConversationViaAnnotatedMethod();
 }

Modified: 
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java?rev=631862&r1=631861&r2=631862&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java
 (original)
+++ 
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java
 Wed Feb 27 22:18:31 2008
@@ -39,4 +39,6 @@
      * @param aState The state for this service
      */
     void setState(String aState);
+    
+    void endConversationViaAnnotatedMethod();
 }

Modified: 
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java?rev=631862&r1=631861&r2=631862&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java
 Wed Feb 27 22:18:31 2008
@@ -19,10 +19,8 @@
 package org.apache.tuscany.sca.itest.conversational.impl;
 
 import org.apache.tuscany.sca.itest.conversational.CService;
-import org.apache.tuscany.sca.itest.conversational.Constants;
 import org.apache.tuscany.sca.itest.conversational.DService;
 import org.osoa.sca.ServiceReference;
-import org.osoa.sca.annotations.ConversationID;
 import org.osoa.sca.annotations.Reference;
 import org.osoa.sca.annotations.Scope;
 import org.osoa.sca.annotations.Service;
@@ -34,92 +32,39 @@
 @Scope("CONVERSATION")
 public class CServiceImpl implements CService {
 
-    /**
-     * The state 
-     */
-    private String state = Constants.A_INITIAL_VALUE;
-    
-    /**
-     * The reference to the other service
-     */
     private ServiceReference<DService> dServiceRef;
-    /**
-     * Constructor
-     *
-     */
-    public CServiceImpl() {
-        System.out.println("---> CServiceImpl constructor for " + this);
-    }
 
-    /**
-     * Inject the reference to the other service
-     * @param servRef Ref to the other service.
-     */
-    @Reference(name="d")
+    @Reference(name = "d")
     public void setD(ServiceReference<DService> servRef) {
-        System.out.println("---> Setting reference to D on " + this + " to " + 
servRef);
         this.dServiceRef = servRef;
     }
-    
-    /**
-     * Returns the state for this service.
-     * 
-     * @return The state for this service
-     */
-    public String getState() {
-        return state;
-    }
 
-    /**
-     * Returns the state for the other service that this service is using
-     * 
-     * @return The state for the other service that this service is using
-     */
-    public String getStateOnD() {
+    public String getState() {
         return dServiceRef.getService().getState();
     }
 
-    /**
-     * Sets the state for this service.
-     * 
-     * @param aState The state for this service
-     */
     public void setState(String aState) {
-        this.state = aState;
-    }
-
-    /**
-     * Sets the state for the other service that this service is using
-     * 
-     * @param aState The state for the other service that this service is using
-     */
-    public void setStateOnD(String aState) {
         dServiceRef.getService().setState(aState);
     }
-    
-    /**
-     * Sets the conversation ID for this service
-     * @param id The Conversation ID
+
+    /*
+     * Whether the conversation ID is chosen by the client or is generated by
+     * the system, the client may access the conversation ID by calling
+     * ServiceReference.getConversationID().
      */
-    @ConversationID
-    public void setConversationID(String id) {
-        System.out.println("Conversation ID for " + this + " is set to " + id);
-    }
-    
-    public Object getConversationIDWithD() {
-        return dServiceRef.getConversation().getConversationID();
+    public Object getConversationID() {
+        return dServiceRef.getConversationID();
     }
 
-    public void endConversationWithD() {
-      
+    public void endConversation() {
         dServiceRef.getConversation().end();
     }
 
-    public Object getUserConversationIDWithD() {
-        return dServiceRef.getConversationID();
+    public void endConversationViaAnnotatedMethod() {
+        dServiceRef.getService().endConversationViaAnnotatedMethod();
     }
-    
-    public void setUserConversationIDWithD(String theID) {
+
+    public void setConversationID(String theID) {
         dServiceRef.setConversationID(theID);
     }
 }

Modified: 
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java?rev=631862&r1=631861&r2=631862&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java
 Wed Feb 27 22:18:31 2008
@@ -22,6 +22,7 @@
 import org.apache.tuscany.sca.itest.conversational.Constants;
 import org.apache.tuscany.sca.itest.conversational.DService;
 import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.EndsConversation;
 import org.osoa.sca.annotations.Scope;
 import org.osoa.sca.annotations.Service;
 
@@ -35,16 +36,9 @@
     /**
      * The state for this service
      */
-    private String state = Constants.B_INITIAL_VALUE;
+    private String state = "Initial state value";
 
     /**
-     * Constructor
-     */
-    public DServiceImpl() {
-        System.out.println("---> DServiceImpl constructor for " + this);
-    }
-    
-    /**
      * Returns the state for this service.
      * 
      * @return The state for this service
@@ -68,6 +62,11 @@
      */
     @ConversationID
     public void setConversationID(String id) {
-        System.out.println("Conversation ID for " + this + " is set to " + id);
+        System.out.println ("Setting conversation ID");
+    }
+    
+    @EndsConversation
+    public void endConversationViaAnnotatedMethod() {
+        System.out.println ("Annotated Ends Conversation");
     }
 }

Modified: 
incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationLifetimeTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationLifetimeTestCase.java?rev=631862&r1=631861&r2=631862&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationLifetimeTestCase.java
 (original)
+++ 
incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationLifetimeTestCase.java
 Wed Feb 27 22:18:31 2008
@@ -23,6 +23,7 @@
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class ConversationLifetimeTestCase {
@@ -32,7 +33,6 @@
     @Before
     public void setUp() throws Exception {
         domain = SCADomain.newInstance("conversationLifetime.composite");
-
     }
 
     @After
@@ -42,32 +42,127 @@
         }
     }
 
+
+    /**
+     * Java Common Annotations and APIs 1.00 Specification line 522-523 
Verify: Whether the 
+     * conversation ID is chosen by the client or is generated by the system, 
+     * the client may access the conversation ID by calling 
ServiceReference.getConversationID().
+     */
+    @Ignore
+    @Test
+    public void getConversationID() {
+        CService service = domain.getService(CService.class, 
"ConversationalCComponent");
+        service.getState();
+        Assert.assertNotNull(service.getConversationID());
+    }
+
+    /**
+     * Java Common Annotations and APIs 1.00 Specification line 522-523 
Verify: Whether the 
+     * conversation ID is chosen by the client or is generated by the system, 
+     * the client may access the conversation ID by calling 
ServiceReference.getConversationID().
+     */
+    @Test
+    public void getConversationID2() {
+        String userProvidedID = "A conversation ID";
+        CService service = domain.getService(CService.class, 
"ConversationalCComponent");
+        service.setConversationID(userProvidedID);
+        Assert.assertEquals(service.getConversationID(), userProvidedID);
+    }
     
     /**
-     * Verify that user provided conversation ID is returned from 
Conversation.getConversationID()
+     * Java Common Annotations and APIs 1.00 Specification line 494-495 Verify:
+     * If a method is invoked on a service reference after an
+     * "@EndsConversation" method has been called then a new conversation will
+     * automatically be started.
+     */
+    @Ignore
+    @Test
+    public void implicitStartNewConversationAfterEnd() {
+        CService service = domain.getService(CService.class, 
"ConversationalCComponent");
+        service.getState();
+        Object firstID = service.getConversationID();
+        service.endConversationViaAnnotatedMethod();
+        service.getState();
+        Assert.assertNotSame(firstID, service.getConversationID());
+    }
+
+    /**
+     * Java Common Annotations and APIs 1.00 Spec line 495-495 Verify: If a
+     * method is invoked on a service reference after an "@EndsConversation"
+     * method has been called then a new conversation will automatically be
+     * started. Note: Uses Conversation.end() rather than "@EndsConversation"
      */
+    @Ignore
     @Test
-    public void testSetUserSuppliedConversationID() {
+    public void implicitStartNewConversationAfterEnd2() {
         CService service = domain.getService(CService.class, 
"ConversationalCComponent");
-        service.setUserConversationIDWithD("A user set conversation ID");
-        service.getStateOnD();
-        Assert.assertEquals(service.getUserConversationIDWithD(), 
service.getConversationIDWithD());
-        Assert.assertEquals(service.getConversationIDWithD(),"A user set 
conversation ID");
-   }
+        service.getState();
+        Object firstID = service.getConversationID();
+        service.endConversation();
+        service.getState();
+        Assert.assertNotSame(firstID, service.getConversationID());
+    }
+
+    /**
+     * Java Common Annotations and APIs 1.00 Specification line 495-497 Verify:
+     * If ServiceReference.getConversationID() is called after the
+     * "@EndsConversation" method is called, but before the next conversation
+     * has been started, it will return null.
+     */
+    @Test
+    public void nullConversationIDAfterEndConversation() {
+        CService service = domain.getService(CService.class, 
"ConversationalCComponent");
+        service.getState();
+        service.endConversationViaAnnotatedMethod();
+        Assert.assertNull(service.getConversationID());
+    }
     
+    /**
+     * Java Common Annotations and APIs 1.00 Specification line 495-497 Verify:
+     * If ServiceReference.getConversationID() is called after the
+     * "@EndsConversation" method is called, but before the next conversation
+     * has been started, it will return null.  Note: Uses explicit set of 
Conversation ID
+     */
+    @Ignore
+    @Test
+    public void nullConversationIDAfterEndConversation1a() {
+        CService service = domain.getService(CService.class, 
"ConversationalCComponent");
+        service.setConversationID("User provided ID");
+        service.getState();
+        service.endConversationViaAnnotatedMethod();
+        Assert.assertNull(service.getConversationID());
+    }
 
     /**
-     * Verify that a new conversation is started if conversational service 
method is called subsequent
-     * to a call to Conversation.end()
+     * Java Common Annotations and APIs 1.00 Spec line 495-497 Verify: If
+     * ServiceReference.getConversationID() is called after the
+     * "@EndsConversationmethod" is called, but before the next conversation 
has
+     * been started, it will return null. Note: Uses Conversation.end() rather
+     * than "@EndsConversation"
      */
     @Test
-    public void explicitEnd() {
+    public void nullConversationIDAfterEndConversation2() {
         CService service = domain.getService(CService.class, 
"ConversationalCComponent");
-        service.getStateOnD();
-        Object firstID = service.getConversationIDWithD();
-        service.endConversationWithD();
-        service.getStateOnD();
-        Assert.assertNotSame(firstID, service.getConversationIDWithD());
+        service.getState();
+        service.endConversation();
+        Assert.assertNull(service.getConversationID());
     }
     
+    /**
+     * Java Common Annotations and APIs 1.00 Spec line 495-497 Verify: If
+     * ServiceReference.getConversationID() is called after the
+     * "@EndsConversationmethod" is called, but before the next conversation 
has
+     * been started, it will return null. Note: Uses Conversation.end() rather
+     * than "@EndsConversation".  Note 2: Uses explicit set of Conversation ID
+     */
+    @Ignore
+    @Test
+    public void nullConversationIDAfterEndConversation2a() {
+        CService service = domain.getService(CService.class, 
"ConversationalCComponent");
+        service.setConversationID("User provided ID");
+        service.getState();
+        service.endConversation();
+        Assert.assertNull(service.getConversationID());
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to