@Test
public void testJMXRegistrationWithNetty() throws Exception {

    String originalServerCnxnFactory = System
            .getProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY);
    System.setProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY,
            NettyServerCnxnFactory.class.getName());
    try {
        ClientBase.setupTestEnv();
        File tmpDir_1 = ClientBase.createTmpDir();
        ServerCnxnFactory server_1 = startServer(tmpDir_1);
        File tmpDir_2 = ClientBase.createTmpDir();
        ServerCnxnFactory server_2 = startServer(tmpDir_2);
        server_1.shutdown();
        server_2.shutdown();
        deleteFile(tmpDir_1);
        deleteFile(tmpDir_2);
    } finally {
        // setting back
        if (originalServerCnxnFactory == null
                || originalServerCnxnFactory.isEmpty()) {
            System.clearProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY);
        } else {
            System.setProperty(
                    ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY,
                    originalServerCnxnFactory);
        }
    }
}