View Javadoc

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