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.ejb;
8   
9   import org.mule.tck.jndi.InMemoryContext;
10  import org.mule.tck.junit4.FunctionalTestCase;
11  import org.mule.transport.rmi.DummySecurityManager;
12  import org.mule.transport.rmi.RmiConnector;
13  
14  import org.junit.Test;
15  
16  import static org.junit.Assert.assertEquals;
17  import static org.junit.Assert.assertNotNull;
18  import static org.junit.Assert.assertTrue;
19  
20  public class EjbNamespaceHandlerTestCase extends FunctionalTestCase
21  {
22      
23      @Override
24      protected String getConfigResources()
25      {
26          return "ejb-namespace-config.xml";
27      }
28  
29      @Test
30      public void testConfig() throws Exception
31      {
32          EjbConnector c = (EjbConnector) muleContext.getRegistry().lookupConnector("ejbConnector");
33          assertNotNull(c);
34          assertEquals(1234, c.getPollingFrequency());
35          assertEquals(DummySecurityManager.class, c.getSecurityManager().getClass());
36          String url = c.getSecurityPolicy();
37          assertNotNull(url);
38          int index = url.lastIndexOf("/");
39          assertTrue(index > 0);
40          assertEquals("rmi.policy", url.substring(index+1));
41          assertEquals("bcd", c.getServerClassName());
42          assertEquals("cde", c.getServerCodebase());
43          assertEquals("org.mule.tck.jndi.InMemoryContextFactory", c.getJndiInitialFactory());
44          assertEquals("efg", c.getJndiProviderUrl());
45          assertEquals("fgh", c.getJndiUrlPkgPrefixes());
46          assertEquals("hij", c.getJndiProviderProperties().get("ghi"));
47      }
48  
49      @Test
50      public void testConfig2() throws Exception
51      {
52          RmiConnector c = (RmiConnector) muleContext.getRegistry().lookupConnector("ejbConnector2");
53          assertNotNull(c);
54          assertEquals(1234, c.getPollingFrequency());
55          assertEquals(DummySecurityManager.class, c.getSecurityManager().getClass());
56          String url = c.getSecurityPolicy();
57          assertNotNull(url);
58          int index = url.lastIndexOf("/");
59          assertTrue(index > 0);
60          assertEquals("rmi.policy", url.substring(index+1));
61          assertEquals("bcd", c.getServerClassName());
62          assertEquals("cde", c.getServerCodebase());
63          assertTrue(c.getJndiContext() instanceof InMemoryContext);
64      }
65  
66  }