View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.stdio;
8   
9   import org.mule.api.endpoint.ImmutableEndpoint;
10  import org.mule.tck.junit4.FunctionalTestCase;
11  
12  import org.junit.Test;
13  
14  import static org.junit.Assert.assertEquals;
15  import static org.junit.Assert.assertNotNull;
16  import static org.junit.Assert.assertTrue;
17  
18  public class StdioNamespaceHandlerTestCase extends FunctionalTestCase
19  {
20  
21      @Override
22      protected String getConfigResources()
23      {
24          return "stdio-namespace-config.xml";
25      }
26  
27      @Test
28      public void testConfig() throws Exception
29      {
30          PromptStdioConnector c =
31                  (PromptStdioConnector) muleContext.getRegistry().lookupConnector("stdioConnector");
32          assertNotNull(c);
33  
34          assertEquals(1234, c.getMessageDelayTime());
35          assertEquals("abc", c.getOutputMessage());
36          assertEquals("edc", c.getPromptMessage());
37          assertEquals("456", c.getPromptMessageCode());
38          assertEquals("dummy-messages", c.getResourceBundle());
39  
40          assertTrue(c.isConnected());
41          assertTrue(c.isStarted());
42      }
43  
44      @Test
45      public void testNoBundle() throws Exception
46      {
47          PromptStdioConnector c =
48                  (PromptStdioConnector)muleContext.getRegistry().lookupConnector("noBundleConnector");
49          assertNotNull(c);
50  
51          assertEquals(1234, c.getMessageDelayTime());
52          assertEquals("abc", c.getOutputMessage());
53          assertEquals("bcd", c.getPromptMessage());
54  
55          assertTrue(c.isConnected());
56          assertTrue(c.isStarted());
57      }
58  
59      @Test
60      public void testSystemAttributeMap()
61      {
62          testEndpointAttribute("in", "system.in");
63          testEndpointAttribute("out", "system.out");
64          testEndpointAttribute("err", "system.err");
65      }
66  
67      protected void testEndpointAttribute(String name, String address)
68      {
69          ImmutableEndpoint endpoint = (ImmutableEndpoint) muleContext.getRegistry().lookupObject(name);
70          assertNotNull("Null " + name, endpoint);
71          assertEquals(address, endpoint.getEndpointURI().getAddress());
72      }
73  
74  }