1   /*
2    * $Id: EjbNamespaceHandlerTestCase.java 10489 2008-01-23 17:53:38Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.FunctionalTestCase;
13  import org.mule.tck.jndi.InMemoryContext;
14  import org.mule.transport.ejb.EjbConnector;
15  import org.mule.transport.rmi.DummySecurityManager;
16  import org.mule.transport.rmi.RmiConnector;
17  
18  public class EjbNamespaceHandlerTestCase extends FunctionalTestCase
19  {
20      protected String getConfigResources()
21      {
22          return "ejb-namespace-config.xml";
23      }
24  
25      public void testConfig() throws Exception
26      {
27          EjbConnector c = (EjbConnector) muleContext.getRegistry().lookupConnector("ejbConnector");
28          assertNotNull(c);
29          assertEquals(1234, c.getPollingFrequency());
30          assertEquals(DummySecurityManager.class, c.getSecurityManager().getClass());
31          String url = c.getSecurityPolicy();
32          assertNotNull(url);
33          int index = url.lastIndexOf("/");
34          assertTrue(index > 0);
35          assertEquals("rmi.policy", url.substring(index+1));
36          assertEquals("bcd", c.getServerClassName());
37          assertEquals("cde", c.getServerCodebase());
38          assertEquals("org.mule.tck.jndi.InMemoryContextFactory", c.getJndiInitialFactory());
39          assertEquals("efg", c.getJndiProviderUrl());
40          assertEquals("fgh", c.getJndiUrlPkgPrefixes());
41          assertEquals("hij", c.getJndiProviderProperties().get("ghi"));
42      }
43  
44      public void testConfig2() throws Exception
45      {
46          RmiConnector c = (RmiConnector) muleContext.getRegistry().lookupConnector("ejbConnector2");
47          assertNotNull(c);
48          assertEquals(1234, c.getPollingFrequency());
49          assertEquals(DummySecurityManager.class, c.getSecurityManager().getClass());
50          String url = c.getSecurityPolicy();
51          assertNotNull(url);
52          int index = url.lastIndexOf("/");
53          assertTrue(index > 0);
54          assertEquals("rmi.policy", url.substring(index+1));
55          assertEquals("bcd", c.getServerClassName());
56          assertEquals("cde", c.getServerCodebase());
57          assertTrue(c.getJndiContext() instanceof InMemoryContext);
58      }
59  
60  }