DecodingService extends TranscodingService { public void setOverrideMetadata(Boolean overrideMetadata) { this.overrideMetadata = overrideMetadata; } DecodingService();  DecodingService(AdaptrisMessageEncoder encoder); @Override void transcodeMessage(AdaptrisMessage msg); Boolean getOverrideMetadata(); void setOverrideMetadata(Boolean overrideMetadata);  }
@Test public void testSetOverrideMetadata() throws Exception { DecodingService s = new DecodingService(); assertNull(s.getOverrideMetadata()); assertFalse(s.isOverrideMetadata()); s.setOverrideMetadata(true); assertTrue(s.isOverrideMetadata()); s.setOverrideMetadata(false); assertFalse(s.isOverrideMetadata()); }
@Test public void testMimeEncoder_OverrideHeader() throws Exception { DecodingService service = new DecodingService(new MimeEncoder()); service.setOverrideMetadata(true); AdaptrisMessage msg = createMimeMessage(); msg.addMetadata(TEST_METADATA_KEY, OVERRIDE_HEADER_VALUE); assertTrue(msg.headersContainsKey(TEST_METADATA_KEY)); assertEquals(OVERRIDE_HEADER_VALUE, msg.getMetadataValue(TEST_METADATA_KEY)); execute(service, msg); assertTrue(msg.headersContainsKey(TEST_METADATA_KEY)); assertTrue(msg.headersContainsKey(TEST_METADATA_KEY_2)); assertEquals(TEST_METADATA_VALUE, msg.getMetadataValue(TEST_METADATA_KEY)); assertEquals(TEST_METADATA_VALUE_2, msg.getMetadataValue(TEST_METADATA_KEY_2)); assertEquals(TEST_PAYLOAD, new String(msg.getPayload())); }
@Test public void testMimeEncoder_DoNotOverrideHeader() throws Exception { DecodingService service = new DecodingService(new MimeEncoder()); service.setOverrideMetadata(false); AdaptrisMessage msg = createMimeMessage(); msg.addMetadata(TEST_METADATA_KEY, OVERRIDE_HEADER_VALUE); assertTrue(msg.headersContainsKey(TEST_METADATA_KEY)); assertEquals(OVERRIDE_HEADER_VALUE, msg.getMetadataValue(TEST_METADATA_KEY)); execute(service, msg); assertTrue(msg.headersContainsKey(TEST_METADATA_KEY)); assertTrue(msg.headersContainsKey(TEST_METADATA_KEY_2)); assertEquals(OVERRIDE_HEADER_VALUE, msg.getMetadataValue(TEST_METADATA_KEY)); assertEquals(TEST_METADATA_VALUE_2, msg.getMetadataValue(TEST_METADATA_KEY_2)); assertEquals(TEST_PAYLOAD, new String(msg.getPayload())); }