| | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.net.InetSocketAddress; |
| | | import java.net.MalformedURLException; |
| | | import java.net.ServerSocket; |
| | | import java.security.KeyStore; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | * credentials are OK and refused when the credentials are invalid. |
| | | * |
| | | */ |
| | | @Test(enabled = false, dataProvider="simpleConnect") |
| | | @Test(enabled = true, dataProvider="simpleConnect") |
| | | public void simpleConnect(String user, String password, |
| | | boolean expectedResult) throws Exception |
| | | { |
| | |
| | | * Test simple JMX get. |
| | | * |
| | | */ |
| | | @Test(enabled = false, dataProvider="simpleGet") |
| | | @Test(enabled = true, dataProvider="simpleGet") |
| | | public void simpleGet(String dn, String attributeName, Object value) |
| | | throws Exception |
| | | { |
| | |
| | | /** |
| | | * Test setting some config attribute through jmx. |
| | | */ |
| | | @Test(enabled = false) |
| | | @Test(enabled = true) |
| | | public void simpleSet() throws Exception |
| | | { |
| | | OpendsJmxConnector connector = connect("cn=directory manager", "password", |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test(enabled = false) |
| | | @Test(enabled = true) |
| | | public void disable() throws Exception |
| | | { |
| | | OpendsJmxConnector connector = connect("cn=directory manager", "password", |
| | |
| | | * Test changing JMX port through LDAP |
| | | * @throws Exception |
| | | */ |
| | | @Test(enabled=false) |
| | | @Test(enabled=true) |
| | | public void changePort() throws Exception |
| | | { |
| | | // Connect to the JMX service and get the current port |
| | |
| | | assertNotNull(initJmxPort); |
| | | |
| | | // change the configuration of the connection handler to use |
| | | // the current port + 1 as the new port number |
| | | // a free port |
| | | ServerSocket serverJmxSocket = new ServerSocket(); |
| | | serverJmxSocket.setReuseAddress(true); |
| | | serverJmxSocket.bind(new InetSocketAddress("127.0.0.1", 0)); |
| | | int serverJmxPort = serverJmxSocket.getLocalPort(); |
| | | |
| | | ConfigEntry config = new ConfigEntry(TestCaseUtils.makeEntry( |
| | | "dn: cn=JMX Connection Handler,cn=Connection Handlers,cn=config", |
| | | "objectClass: top", |
| | |
| | | "ds-cfg-connection-handler-class: org.opends.server.protocols.jmx.JmxConnectionHandler", |
| | | "ds-cfg-connection-handler-enabled: true", |
| | | "ds-cfg-use-ssl: false", |
| | | "ds-cfg-listen-port: " + (initJmxPort+1), |
| | | "ds-cfg-listen-port: " + serverJmxPort, |
| | | "cn: JMX Connection Handler" |
| | | ), null); |
| | | serverJmxSocket.close(); |
| | | configureJmx(config); |
| | | |
| | | // connect the the JMX service using the new port |
| | | connector = connect("cn=directory manager", "password", initJmxPort+1) ; |
| | | connector = connect("cn=directory manager", "password",serverJmxPort) ; |
| | | jmxc = connector.getMBeanServerConnection(); |
| | | assertNotNull(jmxc); |
| | | Long val = (Long) jmxGet(dn, attribute, jmxc); |
| | | assertEquals((long) val, (long) initJmxPort+1); |
| | | assertEquals((long) val, (long) serverJmxPort); |
| | | connector.close(); |
| | | |
| | | // re-establish the initial configuration of the JMX service |
| | |
| | | * credentials are OK and refused when the credentials are invalid. |
| | | * |
| | | */ |
| | | @Test(enabled=false) |
| | | @Test(enabled=true) |
| | | public void sslConnect() throws Exception |
| | | { |
| | | // configure the JMX ssl key manager |
| | |
| | | "ds-cfg-connection-handler-class: org.opends.server.protocols.jmx.JmxConnectionHandler", |
| | | "ds-cfg-connection-handler-enabled: true", |
| | | "ds-cfg-use-ssl: true", |
| | | "ds-cfg-listen-port: " + (initJmxPort +1), |
| | | "ds-cfg-listen-port: " + initJmxPort , |
| | | "cn: JMX Connection Handler" |
| | | ), null); |
| | | |
| | |
| | | |
| | | |
| | | OpendsJmxConnector jmxc = sslConnect("cn=directory manager", "password", |
| | | initJmxPort +1); |
| | | initJmxPort); |
| | | MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); |
| | | jmxc.close(); |
| | | |
| | |
| | | "ds-cfg-listen-port: " + initJmxPort, |
| | | "cn: JMX Connection Handler" |
| | | ), null); |
| | | try |
| | | { |
| | | configureJmx(config); |
| | | } |
| | | catch (RuntimeException e) |
| | | { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | jmxc = connect("cn=directory manager", "password", initJmxPort); |
| | | jmxc.close(); |
| | | assertNotNull(jmxc); |
| | | } |
| | | |