コード例 #1
0
  @Test
  public void testSLAJobSelectorsNegative() throws Exception {
    JMSSLAEventListener slaListener = new JMSSLAEventListener();
    slaListener.init(conf);
    SLACalcStatus startMiss = new SLACalcStatus(new SLARegistrationBean());
    SLARegistrationBean startMissBean = startMiss.getSLARegistrationBean();

    startMiss.setId("0000000-000000000000001-oozie-wrkf-C@1");
    startMissBean.setAppName("Test-SLA-Start-Miss");
    startMissBean.setAppType(AppType.COORDINATOR_ACTION);
    startMissBean.setUser("dummyuser");
    startMiss.setEventStatus(EventStatus.START_MISS);
    startMiss.setSLAStatus(SLAStatus.NOT_STARTED);
    startMiss.setMsgType(MessageType.SLA);

    ConnectionContext jmsContext = getConnectionContext();

    Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
    // Pass a selector which does not match and assert for null message
    String selector = JMSHeaderConstants.EVENT_STATUS + "='SLA_END_MISS'";
    MessageConsumer consumer =
        jmsContext.createConsumer(session, slaListener.getTopic(startMiss), selector);
    slaListener.onStartMiss(startMiss);
    TextMessage message = (TextMessage) consumer.receive(5000);
    assertNull(message);
  }
コード例 #2
0
  @Test
  public void testSLAJobSelectors() throws Exception {
    JMSSLAEventListener slaListener = new JMSSLAEventListener();
    slaListener.init(conf);
    SLACalcStatus startMiss = new SLACalcStatus(new SLARegistrationBean());
    SLARegistrationBean startMissBean = startMiss.getSLARegistrationBean();
    startMiss.setId("0000000-000000000000001-oozie-wrkf-C@1");
    startMissBean.setAppName("Test-SLA-Start-Miss");
    startMissBean.setAppType(AppType.COORDINATOR_ACTION);
    startMissBean.setUser("dummyuser");
    startMiss.setEventStatus(EventStatus.START_MISS);
    startMiss.setSLAStatus(SLAStatus.NOT_STARTED);
    startMiss.setMsgType(MessageType.SLA);

    ConnectionContext jmsContext = getConnectionContext();
    Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
    String selector = JMSHeaderConstants.EVENT_STATUS + "='START_MISS'";
    MessageConsumer consumer =
        jmsContext.createConsumer(session, slaListener.getTopic(startMiss), selector);
    slaListener.onStartMiss(startMiss);
    TextMessage message = (TextMessage) consumer.receive(5000);
    System.out.println("\n Text " + message.getText());
    SLAMessage startMissMsg = (SLAMessage) JMSMessagingUtils.getEventMessage(message);
    assertEquals("dummyuser", startMissMsg.getUser());
    assertEquals(EventStatus.START_MISS, startMissMsg.getEventStatus());
    assertEquals(MessageType.SLA, startMissMsg.getMessageType());
  }