View Javadoc

1   /*
2    * $Id: StdioNamespaceHandlerTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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  package org.mule.transport.stdio;
11  
12  import org.mule.api.endpoint.ImmutableEndpoint;
13  import org.mule.tck.FunctionalTestCase;
14  
15  public class StdioNamespaceHandlerTestCase extends FunctionalTestCase
16  {
17      protected String getConfigResources()
18      {
19          return "stdio-namespace-config.xml";
20      }
21  
22      public void testConfig() throws Exception
23      {
24          PromptStdioConnector c =
25                  (PromptStdioConnector) muleContext.getRegistry().lookupConnector("stdioConnector");
26          assertNotNull(c);
27  
28          assertEquals(1234, c.getMessageDelayTime());
29          assertEquals("abc", c.getOutputMessage());
30          assertEquals("edc", c.getPromptMessage());
31          assertEquals("456", c.getPromptMessageCode());
32          assertEquals("dummy-messages", c.getResourceBundle());
33  
34          assertTrue(c.isConnected());
35          assertTrue(c.isStarted());
36      }
37  
38      public void testNoBundle() throws Exception
39      {
40          PromptStdioConnector c =
41                  (PromptStdioConnector)muleContext.getRegistry().lookupConnector("noBundleConnector");
42          assertNotNull(c);
43  
44          assertEquals(1234, c.getMessageDelayTime());
45          assertEquals("abc", c.getOutputMessage());
46          assertEquals("bcd", c.getPromptMessage());
47  
48          assertTrue(c.isConnected());
49          assertTrue(c.isStarted());
50      }
51  
52      public void testSystemAttributeMap()
53      {
54          testEndpointAttribute("in", "system.in");
55          testEndpointAttribute("out", "system.out");
56          testEndpointAttribute("err", "system.err");
57      }
58  
59      protected void testEndpointAttribute(String name, String address)
60      {
61          ImmutableEndpoint endpoint = (ImmutableEndpoint) muleContext.getRegistry().lookupObject(name);
62          assertNotNull("Null " + name, endpoint);
63          assertEquals(address, endpoint.getEndpointURI().getAddress());
64      }
65  
66  }