View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.management.config;
8   
9   import org.mule.api.agent.Agent;
10  import org.mule.module.management.agent.ConfigurableJMXAuthenticator;
11  import org.mule.module.management.agent.JmxAgent;
12  import org.mule.tck.junit4.FunctionalTestCase;
13  
14  import java.util.Map;
15  
16  import javax.security.auth.Subject;
17  
18  import org.junit.Test;
19  
20  import static org.junit.Assert.assertEquals;
21  import static org.junit.Assert.assertNotNull;
22  
23  public class ManagementCustomJMXAuthenticatorTestCase extends FunctionalTestCase
24  {
25  
26      @Override
27      protected String getConfigResources()
28      {
29          return "management-custom-jmx-authenticator-config.xml";
30      }
31  
32      @Test
33      public void testCustomJMXAuthenticatorConfig() throws Exception
34      {
35          Agent agent = muleContext.getRegistry().lookupAgent("jmx-agent");
36          assertNotNull(agent);
37          assertEquals(JmxAgent.class, agent.getClass());
38          JmxAgent jmxAgent = (JmxAgent) agent;
39          assertEquals(CustomJMXAuthenticator.class, jmxAgent.getJmxAuthenticator().getClass());
40      }
41  
42      public static class CustomJMXAuthenticator implements ConfigurableJMXAuthenticator
43      {
44  
45          public void configure(Map credentials)
46          {
47          }
48  
49          public Subject authenticate(Object credentials)
50          {
51              return null;
52          }
53      }
54  
55  }