@Test
public void testSetupMDC()
{

  // The test does not test MDC properties that are passed via environment variables
  String appenderName = "mdcTestAppender";
  String service = "test";
  String application = "my application";
  String args = "log4j.appender.mdcTestAppender=com.datatorrent.stram.util.LoggerUtilTest$TestAppender"
      + ",log4j.appender.mdcTestAppender.layout=org.apache.log4j.PatternLayout"
      + ",log4j.appender.mdcTestAppender.layout.ConversionPattern=%d %d{Z} [%t] %-5p (%F:%L) - %m%n";
  System.setProperty(APPLICATION_NAME.getLongName(), application);
  LoggerUtil.setupMDC(service);
  LoggerUtil.addAppenders(log4jLogger, new String[] {appenderName}, args, ",");
  TestAppender appender = (TestAppender)log4jLogger.getAppender(appenderName);
  LoggerUtilTest.logger.debug(args);
  assertEquals(service, appender.mdcProperties.get("apex.service"));
  String node = StramClientUtils.getHostName();
  assertEquals(node == null ? "unknown" : node, appender.mdcProperties.get("apex.node"));
  assertEquals(application, appender.mdcProperties.get("apex.application"));
  assertTrue(LoggerUtil.removeAppender(log4jLogger, appenderName));
}