1
2
3
4
5
6
7
8
9
10
11 package org.mule.example.stockquote;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.module.client.MuleClient;
15 import org.mule.tck.FunctionalTestCase;
16 import org.mule.util.StringUtils;
17
18 import java.util.Locale;
19
20 public abstract class AbstractStockQuoteFunctionalTestCase extends FunctionalTestCase
21 {
22
23 public void testStockQuoteExample() throws Exception
24 {
25 MuleClient client = new MuleClient();
26 MuleMessage response = client.send("vm://stockquote", "HRB", null);
27
28 if (null == response)
29 {
30 fail("No response message.");
31 }
32 else
33 {
34 if (null == response.getExceptionPayload())
35 {
36 String text = response.getPayloadAsString();
37 assertNotNull("Null response", text);
38 assertTrue("Stock quote should contain \"BLOCK\": " + text, StringUtils.contains(text, "BLOCK"));
39 if (Locale.getDefault().getISO3Language().equalsIgnoreCase("eng"))
40 {
41
42 assertTrue("Stock quote should start with \"StockQuote[\":" + text, text.startsWith("StockQuote["));
43 }
44 logger.debug("**********");
45 logger.debug(response.getPayload());
46 logger.debug(response.getPayloadAsString());
47 logger.debug("**********");
48 }
49 else
50 {
51 fail("Exception occurred: " + response.getExceptionPayload());
52 }
53 }
54 }
55
56 }