Search in sources :

Example 1 with DefaultControllerMessageHandler

use of org.apache.helix.manager.zk.DefaultControllerMessageHandlerFactory.DefaultControllerMessageHandler 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()));
}
Also used : NotificationContext(org.apache.helix.NotificationContext) HelixException(org.apache.helix.HelixException) Message(org.apache.helix.model.Message) DefaultControllerMessageHandler(org.apache.helix.manager.zk.DefaultControllerMessageHandlerFactory.DefaultControllerMessageHandler) MessageHandler(org.apache.helix.messaging.handling.MessageHandler) HashMap(java.util.HashMap) DefaultControllerMessageHandlerFactory(org.apache.helix.manager.zk.DefaultControllerMessageHandlerFactory) DefaultControllerMessageHandler(org.apache.helix.manager.zk.DefaultControllerMessageHandlerFactory.DefaultControllerMessageHandler) Date(java.util.Date) Test(org.testng.annotations.Test)

Aggregations

Date (java.util.Date)1 HashMap (java.util.HashMap)1 HelixException (org.apache.helix.HelixException)1 NotificationContext (org.apache.helix.NotificationContext)1 DefaultControllerMessageHandlerFactory (org.apache.helix.manager.zk.DefaultControllerMessageHandlerFactory)1 DefaultControllerMessageHandler (org.apache.helix.manager.zk.DefaultControllerMessageHandlerFactory.DefaultControllerMessageHandler)1 MessageHandler (org.apache.helix.messaging.handling.MessageHandler)1 Message (org.apache.helix.model.Message)1 Test (org.testng.annotations.Test)1