AddExtendedLoggingContext extends ServiceImp { AddExtendedLoggingContext withUseDefaultKeys(Boolean useDefaultKeys){ setUseDefaultKeys(useDefaultKeys); return this; } AddExtendedLoggingContext(); @Override void doService(AdaptrisMessage msg); @Override void prepare(); KeyValuePairList getValuesToSet(); void setValuesToSet(KeyValuePairList values); void setUseDefaultKeys(Boolean useDefaultKeys); Boolean getUseDefaultKeys();  }
@Test public void testUseDefaultKeysChannel() throws Exception { AddExtendedLoggingContext srv = new AddExtendedLoggingContext() .withUseDefaultKeys(true); AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(); msg.addObjectHeader(CoreConstants.CHANNEL_ID_KEY, "channel"); execute(srv, msg); assertEquals("channel", MDC.get(CoreConstants.CHANNEL_ID_KEY)); }
@Test public void testUseDefaultKeysWorkflow() throws Exception { AddExtendedLoggingContext srv = new AddExtendedLoggingContext() .withUseDefaultKeys(true); AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(); msg.addObjectHeader(CoreConstants.WORKFLOW_ID_KEY, "workflow"); execute(srv, msg); assertEquals("workflow", MDC.get(CoreConstants.WORKFLOW_ID_KEY)); }
@Test public void testUseDefaultKeysUniqueId() throws Exception { AddExtendedLoggingContext srv = new AddExtendedLoggingContext() .withUseDefaultKeys(true); AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(); msg.addObjectHeader(CoreConstants.MESSAGE_UNIQUE_ID_KEY, "unique"); execute(srv, msg); assertEquals("unique", MDC.get(CoreConstants.MESSAGE_UNIQUE_ID_KEY)); }