KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > samples > loanbroker > esb > LoanBrokerESBTestCase


1 /*
2  * $Id: LoanBrokerESBTestCase.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.samples.loanbroker.esb;
12
13 import org.mule.extras.client.MuleClient;
14 import org.mule.providers.NullPayload;
15 import org.mule.samples.loanbroker.esb.message.Customer;
16 import org.mule.samples.loanbroker.esb.message.CustomerQuoteRequest;
17 import org.mule.samples.loanbroker.esb.message.LoanQuote;
18 import org.mule.tck.FunctionalTestCase;
19 import org.mule.umo.UMOMessage;
20
21 /**
22  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
23  * @version $Revision: 3798 $
24  */

25 public class LoanBrokerESBTestCase extends FunctionalTestCase
26 {
27
28     public static final int REQUESTS = 100;
29
30     protected String JavaDoc getConfigResources()
31     {
32         return "loan-broker-esb-mule-config-test-case.xml";
33     }
34
35     public void testSingleLoanRequest() throws Exception JavaDoc
36     {
37         MuleClient client = new MuleClient();
38         Customer c = new Customer("Ross Mason", 1234);
39         CustomerQuoteRequest request = new CustomerQuoteRequest(c, 100000, 48);
40         UMOMessage result = client.send("vm://loan.broker.requests", request, null);
41         assertNotNull(result);
42         assertFalse(result.getPayload() instanceof NullPayload);
43         assertTrue(result.getPayload() instanceof LoanQuote);
44         LoanQuote quote = (LoanQuote)result.getPayload();
45         assertTrue(quote.getInterestRate() > 0);
46     }
47
48     // public void testLotsOfLoanRequests() throws Exception {
49
// MuleClient client = new MuleClient();
50
// Customer c = new Customer("Ross Mason", 1234);
51
// LoanQuoteRequest[] requests = new LoanQuoteRequest[2];
52
// requests[0] = new LoanQuoteRequest();
53
// requests[1] = new LoanQuoteRequest();
54
// requests[0].setCustomerRequest(new CustomerQuoteRequest(c, 100000, 48));
55
// requests[1].setCustomerRequest(new CustomerQuoteRequest(c, 1000, 12));
56
// UMOMessage result;
57
// int i = 0;
58
// long start = System.currentTimeMillis();
59
// try {
60
// for (; i < REQUESTS; i++) {
61
// result = client.send("vm://loan.broker.requests", requests[i % 2], null);
62
// assertNotNull(result);
63
// assertFalse(result.getPayload() instanceof NullPayload);
64
// assertTrue(result.getPayload() instanceof LoanQuote);
65
// LoanQuote quote = (LoanQuote)result.getPayload();
66
// assertTrue(quote.getInterestRate() > 0);
67
// }
68
// } finally {
69
// System.out.println("Requests processed was: " + i);
70
// long el = System.currentTimeMillis() - start;
71
// System.out.println("Total running time was: " + el);
72
// float mps = 1000 / (el / REQUESTS);
73
// System.out.println("MPS: " + mps + " (no warm up)");
74
// }
75
// }
76
}
77
Popular Tags