View Javadoc

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