Author: isilval
Date: Mon Dec  4 12:55:16 2006
New Revision: 482352

URL: http://svn.apache.org/viewvc?view=rev&rev=482352
Log:
Fix the sample at EndConversation

Modified:
    
incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClient.java
    
incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClientImpl.java
    
incubator/tuscany/java/samples/sca/loanappconversation/src/test/java/loanappconversation/LoanAppConversationTestCase.java

Modified: 
incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClient.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClient.java?view=diff&rev=482352&r1=482351&r2=482352
==============================================================================
--- 
incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClient.java
 (original)
+++ 
incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClient.java
 Mon Dec  4 12:55:16 2006
@@ -22,6 +22,7 @@
 
     void applyForLoan(String customerName, float amount);
     boolean isApproved();
+    boolean isCancelled();
     String displayLoan();
     void cancelLoan();
     void closeLoan();

Modified: 
incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClientImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClientImpl.java?view=diff&rev=482352&r1=482351&r2=482352
==============================================================================
--- 
incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClientImpl.java
 (original)
+++ 
incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClientImpl.java
 Mon Dec  4 12:55:16 2006
@@ -34,7 +34,17 @@
     }
     
     public boolean isApproved() {
+        if (loanService.getLoanStatus() == null) {
+            return false;
+        }
         return loanService.getLoanStatus().equals("approved");
+    }
+    
+    public boolean isCancelled() {
+        if (loanService.getLoanStatus() == null) {
+            return false;
+        }
+        return loanService.getLoanStatus().equals("cancelled");
     }
     
     public String displayLoan() {

Modified: 
incubator/tuscany/java/samples/sca/loanappconversation/src/test/java/loanappconversation/LoanAppConversationTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversation/src/test/java/loanappconversation/LoanAppConversationTestCase.java?view=diff&rev=482352&r1=482351&r2=482352
==============================================================================
--- 
incubator/tuscany/java/samples/sca/loanappconversation/src/test/java/loanappconversation/LoanAppConversationTestCase.java
 (original)
+++ 
incubator/tuscany/java/samples/sca/loanappconversation/src/test/java/loanappconversation/LoanAppConversationTestCase.java
 Mon Dec  4 12:55:16 2006
@@ -47,14 +47,28 @@
             loanClient.cancelLoan();
             System.out.println("Sleeping to let cancel complete ...");
             Thread.sleep(500);
+            if (!loanClient.isCancelled()) {
+                fail("Loan should be cancelled");
+            }
             System.out.println("Cancelled: " + loanClient.displayLoan());
             loanClient.closeLoan();
+            
+            /* This is a mistake, after @EndConversation, a new conversation is
+             * started automatically, so we should not get 
TargetNotFoundException.
+             * Keep this for the timeout case, where we should get the 
exception
             try {
                 System.out.println("Trying to use the closed loan in the ended 
conversation ...");            
                 System.out.println("Closed: " + loanClient.displayLoan());
                 fail("Target should not be found");
             } catch(TargetNotFoundException e) {
                 System.out.println("Target not found as expected");            
+            }
+            */
+
+            // Now check that a new conversation's loan is not cancelled
+            
+            if (loanClient.isCancelled()) {
+                fail("Loan should not be cancelled");
             }
         } catch(Throwable e) {
             e.printStackTrace();



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

Reply via email to