View Javadoc

1   /*
2    * $Id: ManagementCustomJMXAuthenticatorTestCase.java 22401 2011-07-13 09:10:18Z dirk.olmes $
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.config;
12  
13  import org.mule.api.agent.Agent;
14  import org.mule.module.management.agent.ConfigurableJMXAuthenticator;
15  import org.mule.module.management.agent.JmxAgent;
16  import org.mule.tck.junit4.FunctionalTestCase;
17  
18  import java.util.Map;
19  
20  import javax.security.auth.Subject;
21  
22  import org.junit.Test;
23  
24  import static org.junit.Assert.assertEquals;
25  import static org.junit.Assert.assertNotNull;
26  
27  public class ManagementCustomJMXAuthenticatorTestCase extends FunctionalTestCase
28  {
29  
30      @Override
31      protected String getConfigResources()
32      {
33          return "management-custom-jmx-authenticator-config.xml";
34      }
35  
36      @Test
37      public void testCustomJMXAuthenticatorConfig() throws Exception
38      {
39          Agent agent = muleContext.getRegistry().lookupAgent("jmx-agent");
40          assertNotNull(agent);
41          assertEquals(JmxAgent.class, agent.getClass());
42          JmxAgent jmxAgent = (JmxAgent) agent;
43          assertEquals(CustomJMXAuthenticator.class, jmxAgent.getJmxAuthenticator().getClass());
44      }
45  
46      public static class CustomJMXAuthenticator implements ConfigurableJMXAuthenticator
47      {
48  
49          public void configure(Map credentials)
50          {
51          }
52  
53          public Subject authenticate(Object credentials)
54          {
55              return null;
56          }
57      }
58  
59  }