Package org.apache.oozie.jms

Examples of org.apache.oozie.jms.JMSJobEventListener


    }

    @Test
    public void testOnCoordinatorActionWaitingEvent() throws ParseException {
        JMSJobEventListener wfEventListner = new JMSJobEventListener();
        wfEventListner.init(conf);
        Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
        Date nominalTime = DateUtils.parseDateUTC("2011-07-11T00:00Z");
        CoordinatorActionEvent cae = new CoordinatorActionEvent("caId1", "caJobId1", CoordinatorAction.Status.WAITING,
                "user1", "wf-app-name1", nominalTime, startDate, "missingDep1");
        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            MessageConsumer consumer = jmsContext.createConsumer(session, wfEventListner.getTopic(cae));
            wfEventListner.onCoordinatorActionEvent(cae);
            TextMessage message = (TextMessage) consumer.receive(5000);
            assertFalse(message.getText().contains("endTime"));
            assertFalse(message.getText().contains("errorCode"));
            assertFalse(message.getText().contains("errorMessage"));
            CoordinatorActionMessage coordActionWaitingMessage = JMSMessagingUtils
View Full Code Here


        }
    }

    @Test
    public void testOnCoordinatorActionStartEvent() throws ParseException {
        JMSJobEventListener coordEventListener = new JMSJobEventListener();
        coordEventListener.init(conf);
        Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
        Date nominalTime = DateUtils.parseDateUTC("2011-07-11T00:00Z");
        CoordinatorActionEvent cae = new CoordinatorActionEvent("caId1", "caJobId1", CoordinatorAction.Status.RUNNING,
                "user1", "wf-app-name1", nominalTime, startDate, null);
        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            MessageConsumer consumer = jmsContext.createConsumer(session, coordEventListener.getTopic(cae));
            coordEventListener.onCoordinatorActionEvent(cae);
            TextMessage message = (TextMessage) consumer.receive(5000);
            assertFalse(message.getText().contains("endTime"));
            assertFalse(message.getText().contains("errorCode"));
            assertFalse(message.getText().contains("errorMessage"));
            assertFalse(message.getText().contains("missingDependency"));
View Full Code Here

        }
    }

    @Test
    public void testOnCoordinatorJobSuccessEvent() throws ParseException {
        JMSJobEventListener coordEventListener = new JMSJobEventListener();
        coordEventListener.init(conf);
        Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
        Date nominalTime = DateUtils.parseDateUTC("2011-07-11T00:00Z");
        Date endDate = new Date();
        CoordinatorActionEvent cae = new CoordinatorActionEvent("caId1", "caJobId1",
                CoordinatorAction.Status.SUCCEEDED, "user1", "wf-app-name1", nominalTime, startDate, null);
        cae.setEndTime(endDate);
        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            MessageConsumer consumer = jmsContext.createConsumer(session, coordEventListener.getTopic(cae));
            coordEventListener.onCoordinatorActionEvent(cae);
            TextMessage message = (TextMessage) consumer.receive(5000);
            assertFalse(message.getText().contains("errorCode"));
            assertFalse(message.getText().contains("errorMessage"));
            assertFalse(message.getText().contains("missingDependency"));
            CoordinatorActionMessage coordActionSuccessMessage = JMSMessagingUtils
View Full Code Here

        }
    }

    @Test
    public void testOnCoordinatorJobFailureEvent() throws ParseException {
        JMSJobEventListener coordEventListener = new JMSJobEventListener();
        coordEventListener.init(conf);
        Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
        Date nominalTime = DateUtils.parseDateUTC("2011-07-11T00:00Z");
        Date endDate = new Date();
        CoordinatorActionEvent cae = new CoordinatorActionEvent("caId1", "caJobId1", CoordinatorAction.Status.FAILED,
                "user1", "wf-app-name1", nominalTime, startDate, null);
        cae.setEndTime(endDate);
        cae.setErrorCode("E0101");
        cae.setErrorMessage("dummyError");
        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            MessageConsumer consumer = jmsContext.createConsumer(session, coordEventListener.getTopic(cae));
            coordEventListener.onCoordinatorActionEvent(cae);
            TextMessage message = (TextMessage) consumer.receive(5000);
            assertFalse(message.getText().contains("missingDependency"));
            CoordinatorActionMessage coordActionFailMessage = JMSMessagingUtils
                    .getEventMessage(message);
            assertEquals(CoordinatorAction.Status.FAILED, coordActionFailMessage.getStatus());
View Full Code Here

        }
    }

    @Test
    public void testCoordinatorActionSelectors() throws ParseException {
        JMSJobEventListener coordEventListener = new JMSJobEventListener();
        coordEventListener.init(conf);
        Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
        Date nominalTime = DateUtils.parseDateUTC("2011-07-11T00:00Z");
        CoordinatorActionEvent cae = new CoordinatorActionEvent("caId1", "caJobId1", CoordinatorAction.Status.FAILED,
                "user1", "wf-app-name1", nominalTime, startDate, null);
        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            String selector = JMSHeaderConstants.USER + "='user1'";
            MessageConsumer consumer = jmsContext.createConsumer(session, coordEventListener.getTopic(cae), selector);
            coordEventListener.onCoordinatorActionEvent(cae);
            TextMessage message = (TextMessage) consumer.receive(5000);
            CoordinatorActionMessage coordActionFailMessage = JMSMessagingUtils
                    .getEventMessage(message);
            Assert.assertEquals(CoordinatorAction.Status.FAILED, coordActionFailMessage.getStatus());
            assertEquals("user1", coordActionFailMessage.getUser());
View Full Code Here

        }
    }

    @Test
    public void testCoordinatorActionSelectorsNegative() throws ParseException {
        JMSJobEventListener coordEventListener = new JMSJobEventListener();
        coordEventListener.init(conf);
        Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
        Date nominalTime = DateUtils.parseDateUTC("2011-07-11T00:00Z");
        CoordinatorActionEvent cae = new CoordinatorActionEvent("caId1", "caJobId1", CoordinatorAction.Status.FAILED,
                "user1", "wf-app-name1", nominalTime, startDate, null);
        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            // Pass a selector which wont match and assert for null message
            String selector = JMSHeaderConstants.USER + "='Non_matching_user'";
            MessageConsumer consumer = jmsContext.createConsumer(session, coordEventListener.getTopic(cae), selector);
            coordEventListener.onCoordinatorActionEvent(cae);
            TextMessage message = (TextMessage) consumer.receive(5000);
            assertNull(message);
        }
        catch (Exception e) {
            e.printStackTrace();
View Full Code Here

        super.tearDown();
    }

    @Test
    public void testOnWorkflowJobStartedEvent() throws ParseException {
        JMSJobEventListener wfEventListener = new JMSJobEventListener();
        wfEventListener.init(conf);
        Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
        WorkflowJobEvent wfe = new WorkflowJobEvent("wfId1", "caId1", WorkflowJob.Status.RUNNING, "user1",
                "wf-app-name1", startDate, null);

        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            MessageConsumer consumer = jmsContext.createConsumer(session, wfEventListener.getTopic(wfe));
            wfEventListener.onWorkflowJobEvent(wfe);
            TextMessage message = (TextMessage) consumer.receive(5000);
            assertFalse(message.getText().contains("endTime"));
            WorkflowJobMessage wfStartMessage = JMSMessagingUtils.getEventMessage(message);
            assertEquals(WorkflowJob.Status.RUNNING, wfStartMessage.getStatus());
            assertEquals(startDate, wfStartMessage.getStartTime());
            assertEquals("wfId1", wfStartMessage.getId());
            assertEquals("caId1", wfStartMessage.getParentId());
            assertEquals(MessageType.JOB, wfStartMessage.getMessageType());
            assertEquals(AppType.WORKFLOW_JOB, wfStartMessage.getAppType());
            assertEquals(EventStatus.STARTED, wfStartMessage.getEventStatus());
            assertEquals("user1", wfStartMessage.getUser());
            assertEquals("wf-app-name1", wfStartMessage.getAppName());
            wfEventListener.destroy();
        }
        catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
View Full Code Here

        }
    }

    @Test
    public void testOnWorkflowJobSuccessEvent() throws ParseException {
        JMSJobEventListener wfEventListener = new JMSJobEventListener();
        wfEventListener.init(conf);
        Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
        Date endDate = new Date();
        WorkflowJobEvent wfe = new WorkflowJobEvent("wfId1", "caId1", WorkflowJob.Status.SUCCEEDED, "user1",
                "wf-app-name1", startDate, endDate);

        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            MessageConsumer consumer = jmsContext.createConsumer(session, wfEventListener.getTopic(wfe));
            wfEventListener.onWorkflowJobEvent(wfe);
            TextMessage message = (TextMessage) consumer.receive(5000);
            WorkflowJobMessage wfSuccMessage = JMSMessagingUtils.getEventMessage(message);
            assertEquals(WorkflowJob.Status.SUCCEEDED, wfSuccMessage.getStatus());
            assertEquals(startDate, wfSuccMessage.getStartTime());
            assertEquals(endDate, wfSuccMessage.getEndTime());
            assertEquals("wfId1", wfSuccMessage.getId());
            assertEquals("caId1", wfSuccMessage.getParentId());
            assertEquals(MessageType.JOB, wfSuccMessage.getMessageType());
            assertEquals(AppType.WORKFLOW_JOB, wfSuccMessage.getAppType());
            assertEquals(EventStatus.SUCCESS, wfSuccMessage.getEventStatus());
            assertEquals("user1", wfSuccMessage.getUser());
            assertEquals("wf-app-name1", wfSuccMessage.getAppName());
            wfEventListener.destroy();

        }
        catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
View Full Code Here

        }
    }

    @Test
    public void testOnWorkflowJobFailureEvent() throws ParseException {
        JMSJobEventListener wfEventListener = new JMSJobEventListener();
        wfEventListener.init(conf);
        Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
        Date endDate = new Date();
        WorkflowJobEvent wfe = new WorkflowJobEvent("wfId1", "caId1", WorkflowJob.Status.FAILED, "user1",
                "wf-app-name1", startDate, endDate);
        wfe.setErrorCode("dummyErrorCode");
        wfe.setErrorMessage("dummyErrorMessage");
        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            MessageConsumer consumer = jmsContext.createConsumer(session, wfEventListener.getTopic(wfe));
            wfEventListener.onWorkflowJobEvent(wfe);
            TextMessage message = (TextMessage) consumer.receive(5000);
            WorkflowJobMessage wfFailMessage = JMSMessagingUtils.getEventMessage(message);
            assertEquals(WorkflowJob.Status.FAILED, wfFailMessage.getStatus());
            assertEquals(startDate, wfFailMessage.getStartTime());
            assertEquals(endDate, wfFailMessage.getEndTime());
            assertEquals("wfId1", wfFailMessage.getId());
            assertEquals("caId1", wfFailMessage.getParentId());
            assertEquals(MessageType.JOB, wfFailMessage.getMessageType());
            assertEquals(AppType.WORKFLOW_JOB, wfFailMessage.getAppType());
            assertEquals(EventStatus.FAILURE, wfFailMessage.getEventStatus());
            assertEquals("user1", wfFailMessage.getUser());
            assertEquals("wf-app-name1", wfFailMessage.getAppName());
            assertEquals("dummyErrorCode", wfFailMessage.getErrorCode());
            assertEquals("dummyErrorMessage", wfFailMessage.getErrorMessage());
            wfEventListener.destroy();
        }
        catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
View Full Code Here

        }
    }

    @Test
    public void testOnWorkflowJobSuspendEvent() throws ParseException {
        JMSJobEventListener wfEventListener = new JMSJobEventListener();
        wfEventListener.init(conf);
        Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
        WorkflowJobEvent wfe = new WorkflowJobEvent("wfId1", "caId1", WorkflowJob.Status.SUSPENDED, "user1",
                "wf-app-name1", startDate, null);
        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            MessageConsumer consumer = jmsContext.createConsumer(session, wfEventListener.getTopic(wfe));
            wfEventListener.onWorkflowJobEvent(wfe);
            TextMessage message = (TextMessage) consumer.receive(5000);
            assertFalse(message.getText().contains("endTime"));
            WorkflowJobMessage wfFailMessage = JMSMessagingUtils.getEventMessage(message);
            assertEquals(WorkflowJob.Status.SUSPENDED, wfFailMessage.getStatus());
            assertEquals(startDate, wfFailMessage.getStartTime());
            assertEquals("wfId1", wfFailMessage.getId());
            assertEquals("caId1", wfFailMessage.getParentId());
            assertEquals(MessageType.JOB, wfFailMessage.getMessageType());
            assertEquals(AppType.WORKFLOW_JOB, wfFailMessage.getAppType());
            assertEquals(EventStatus.SUSPEND, wfFailMessage.getEventStatus());
            assertEquals("user1", wfFailMessage.getUser());
            assertEquals("wf-app-name1", wfFailMessage.getAppName());
            assertNull(wfFailMessage.getErrorCode());
            assertNull(wfFailMessage.getErrorMessage());
            wfEventListener.destroy();
        }
        catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
View Full Code Here

TOP

Related Classes of org.apache.oozie.jms.JMSJobEventListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.