use of org.apache.helix.manager.zk.DefaultControllerMessageHandlerFactory in project helix by apache.
the class TestDefaultControllerMsgHandlerFactory method testDefaultControllerMsgHandlerFactory.
@Test()
public void testDefaultControllerMsgHandlerFactory() {
System.out.println("START TestDefaultControllerMsgHandlerFactory at " + new Date(System.currentTimeMillis()));
DefaultControllerMessageHandlerFactory facotry = new DefaultControllerMessageHandlerFactory();
Message message = new Message(MessageType.NO_OP, "0");
NotificationContext context = new NotificationContext(null);
boolean exceptionCaught = false;
try {
MessageHandler handler = facotry.createHandler(message, context);
} catch (HelixException e) {
exceptionCaught = true;
}
AssertJUnit.assertTrue(exceptionCaught);
message = new Message(MessageType.CONTROLLER_MSG, "1");
exceptionCaught = false;
try {
MessageHandler handler = facotry.createHandler(message, context);
} catch (HelixException e) {
exceptionCaught = true;
}
AssertJUnit.assertFalse(exceptionCaught);
Map<String, String> resultMap = new HashMap<String, String>();
message = new Message(MessageType.NO_OP, "3");
DefaultControllerMessageHandler defaultHandler = new DefaultControllerMessageHandler(message, context);
try {
defaultHandler.handleMessage();
} catch (HelixException e) {
exceptionCaught = true;
} catch (InterruptedException e) {
LOG.error("Interrupted handling message", e);
}
AssertJUnit.assertTrue(exceptionCaught);
message = new Message(MessageType.CONTROLLER_MSG, "4");
defaultHandler = new DefaultControllerMessageHandler(message, context);
exceptionCaught = false;
try {
defaultHandler.handleMessage();
} catch (HelixException e) {
exceptionCaught = true;
} catch (InterruptedException e) {
LOG.error("Interrupted handling message", e);
}
AssertJUnit.assertFalse(exceptionCaught);
System.out.println("END TestDefaultControllerMsgHandlerFactory at " + new Date(System.currentTimeMillis()));
}
Aggregations