View Javadoc

1   /*
2    * $Id: JBpmFunctionalTestCase.java 20321 2010-11-24 15:21:24Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.example.loanbroker.bpm;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.api.client.MuleClient;
15  import org.mule.example.loanbroker.messages.Customer;
16  import org.mule.example.loanbroker.messages.CustomerQuoteRequest;
17  import org.mule.example.loanbroker.messages.LoanQuote;
18  import org.mule.example.loanbroker.tests.AbstractAsynchronousLoanBrokerTestCase;
19  import org.mule.transport.NullPayload;
20  
21  
22  public class JBpmFunctionalTestCase extends AbstractAsynchronousLoanBrokerTestCase
23  {
24      public JBpmFunctionalTestCase()
25      {
26          super();
27          setDisposeManagerPerSuite(true);        
28      }
29      
30      @Override
31      protected String getConfigResources()
32      {
33          return "mule-config.xml";
34      }
35  
36      @Override
37      protected int getDelay()
38      {
39          return 20000;
40      }
41  
42      @Override
43      protected int getNumberOfRequests()
44      {
45          return 100;
46      }
47  
48      @Override
49      public void testLotsOfLoanRequests() throws Exception
50      {
51          final MuleClient client = muleContext.getClient();
52          Customer c = new Customer("Ross Mason", 1234);
53          CustomerQuoteRequest request = new CustomerQuoteRequest(c, 100000, 48);
54  
55          for (int i = 0; i < getNumberOfRequests(); i++)
56          {
57              client.dispatch("CustomerRequests", request, null);
58          }
59          
60          MuleMessage result;
61          for (int i = 0; i < getNumberOfRequests(); i++)
62          {
63              result = client.request("CustomerResponses", getDelay());
64              assertNotNull("Result is null", result);
65              assertFalse("Result is null", result.getPayload() instanceof NullPayload);
66              assertTrue("Result should be LoanQuote but is " + result.getPayload().getClass().getName(),
67                      result.getPayload() instanceof LoanQuote);
68              LoanQuote quote = (LoanQuote) result.getPayload();
69              assertTrue(quote.getInterestRate() > 0);
70          }
71      }
72  }