Package org.springframework.amqp.rabbit.log4j

Examples of org.springframework.amqp.rabbit.log4j.TestListener


    listenerContainer.shutdown();
  }

  @Test
  public void testAppender() throws InterruptedException {
    TestListener testListener = (TestListener) applicationContext.getBean("testListener", 4);
    listenerContainer.setMessageListener(testListener);
    listenerContainer.start();

    log.debug("This is a DEBUG message");
    log.info("This is an INFO message");
    log.warn("This is a WARN message");
    log.error("This is an ERROR message", new RuntimeException("Test exception"));

    assertTrue(testListener.getLatch().await(5, TimeUnit.SECONDS));
    assertNotNull(testListener.getId());
  }
View Full Code Here


    assertNotNull(testListener.getId());
  }

  @Test
  public void testAppenderWithProps() throws InterruptedException {
    TestListener testListener = (TestListener) applicationContext.getBean("testListener", 4);
    listenerContainer.setMessageListener(testListener);
    listenerContainer.start();

    String propertyName = "someproperty";
    String propertyValue = "property.value";
    MDC.put(propertyName, propertyValue);
    log.debug("This is a DEBUG message with properties");
    log.info("This is an INFO message with properties");
    log.warn("This is a WARN message with properties");
    log.error("This is an ERROR message with properties", new RuntimeException("Test exception"));
    MDC.remove(propertyName);

    assertTrue(testListener.getLatch().await(5, TimeUnit.SECONDS));
    MessageProperties messageProperties = testListener.getMessageProperties();
    assertNotNull(messageProperties);
    assertNotNull(messageProperties.getHeaders().get(propertyName));
    assertEquals(propertyValue, messageProperties.getHeaders().get(propertyName));
    Object location = messageProperties.getHeaders().get("location");
    assertNotNull(location);
View Full Code Here

        startsWith("org.springframework.amqp.rabbit.logback.AmqpAppenderIntegrationTests.testAppenderWithProps()"));
  }

  @Test
  public void testCharset() throws InterruptedException {
    TestListener testListener = (TestListener) applicationContext.getBean("testListener", 1);
    listenerContainer.setMessageListener(testListener);
    listenerContainer.start();

    String foo = "\u0fff"; // UTF-8 -> 0xe0bfbf
    log.info(foo);
    assertTrue(testListener.getLatch().await(5, TimeUnit.SECONDS));
    byte[] body = testListener.getMessage().getBody();
    int lineSeparatorExtraBytes = System.getProperty("line.separator").getBytes().length - 1;
    assertEquals(0xe0, body[body.length - 5 - lineSeparatorExtraBytes] & 0xff);
    assertEquals(0xbf, body[body.length - 4 - lineSeparatorExtraBytes] & 0xff);
    assertEquals(0xbf, body[body.length - 3 - lineSeparatorExtraBytes] & 0xff);
  }
View Full Code Here

TOP

Related Classes of org.springframework.amqp.rabbit.log4j.TestListener

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.