View Javadoc

1   /*
2    * $Id: DefaultJmxSupportAgentTestCase.java 20321 2010-11-24 15:21:24Z dfeist $
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  
11  package org.mule.management.agents;
12  
13  import org.mule.module.management.agent.DefaultJmxSupportAgent;
14  import org.mule.module.management.agent.FixedHostRmiClientSocketFactory;
15  import org.mule.module.management.agent.JmxAgent;
16  import org.mule.tck.AbstractMuleTestCase;
17  
18  import java.util.Map;
19  
20  import javax.management.remote.rmi.RMIConnectorServer;
21  
22  public class DefaultJmxSupportAgentTestCase extends AbstractMuleTestCase
23  {
24      public void testHostPropertyEnablesClientSocketFactory () throws Exception
25      {
26          DefaultJmxSupportAgent agent = new DefaultJmxSupportAgent();
27          agent.setMuleContext(muleContext);
28          agent.setHost("127.0.0.1");
29          JmxAgent jmxAgent = agent.createJmxAgent();
30          Map props = jmxAgent.getConnectorServerProperties();
31          assertNotNull(props);
32          assertEquals("JMX ConnectorServer properties should've been merged",
33                       2, props.size());
34          assertTrue("Property shouldn't have been removed",
35                     props.containsKey(RMIConnectorServer.JNDI_REBIND_ATTRIBUTE));
36          assertTrue("Property should've been added",
37                     props.containsKey(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE));
38          Object ref = props.get(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE);
39          assertNotNull(ref);
40          assertTrue(ref instanceof FixedHostRmiClientSocketFactory);
41      }
42  }