1   /*
2    * $Id: DefaultJmxSupportAgentTestCase.java 11234 2008-03-06 23:44:34Z tcarlson $
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  
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.setHost("127.0.0.1");
28          JmxAgent jmxAgent = agent.createJmxAgent();
29          Map props = jmxAgent.getConnectorServerProperties();
30          assertNotNull(props);
31          assertEquals("JMX ConnectorServer properties should've been merged",
32                       2, props.size());
33          assertTrue("Property shouldn't have been removed",
34                     props.containsKey(RMIConnectorServer.JNDI_REBIND_ATTRIBUTE));
35          assertTrue("Property should've been added",
36                     props.containsKey(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE));
37          Object ref = props.get(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE);
38          assertNotNull(ref);
39          assertTrue(ref instanceof FixedHostRmiClientSocketFactory);
40      }
41  }