@Test public void testApplyCharset_PassthruDisabled_Invalid() { AdaptrisMessage msg = new DefaultMessageFactory().newMessage(); MessageHelper.checkCharsetAndApply(msg, "UTF-9", false); assertEquals(UnsupportedCharsetException.class, msg.getObjectHeaders().get(CoreConstants.OBJ_METADATA_EXCEPTION).getClass()); }
public static AdaptrisMessage checkCharsetAndApply(final AdaptrisMessage msg, String charEnc, final boolean passthru) { Optional.ofNullable(charEnc).ifPresent((charsetName) -> { if (!passthru) { if (Charset.isSupported(charsetName)) { msg.setContentEncoding(charsetName); } else { log.trace("'{}' is not supported, using default, and marking", charsetName); msg.addObjectHeader(OBJ_METADATA_EXCEPTION, new UnsupportedCharsetException(charsetName)); } } else { msg.setContentEncoding(charsetName); } }); return msg; }
MessageHelper { public static AdaptrisMessage checkCharsetAndApply(final AdaptrisMessage msg, String charEnc, final boolean passthru) { Optional.ofNullable(charEnc).ifPresent((charsetName) -> { if (!passthru) { if (Charset.isSupported(charsetName)) { msg.setContentEncoding(charsetName); } else { log.trace("'{}' is not supported, using default, and marking", charsetName); msg.addObjectHeader(OBJ_METADATA_EXCEPTION, new UnsupportedCharsetException(charsetName)); } } else { msg.setContentEncoding(charsetName); } }); return msg; } }
MessageHelper { public static AdaptrisMessage checkCharsetAndApply(final AdaptrisMessage msg, String charEnc, final boolean passthru) { Optional.ofNullable(charEnc).ifPresent((charsetName) -> { if (!passthru) { if (Charset.isSupported(charsetName)) { msg.setContentEncoding(charsetName); } else { log.trace("'{}' is not supported, using default, and marking", charsetName); msg.addObjectHeader(OBJ_METADATA_EXCEPTION, new UnsupportedCharsetException(charsetName)); } } else { msg.setContentEncoding(charsetName); } }); return msg; }  }
MessageHelper { public static AdaptrisMessage checkCharsetAndApply(final AdaptrisMessage msg, String charEnc, final boolean passthru) { Optional.ofNullable(charEnc).ifPresent((charsetName) -> { if (!passthru) { if (Charset.isSupported(charsetName)) { msg.setContentEncoding(charsetName); } else { log.trace("'{}' is not supported, using default, and marking", charsetName); msg.addObjectHeader(OBJ_METADATA_EXCEPTION, new UnsupportedCharsetException(charsetName)); } } else { msg.setContentEncoding(charsetName); } }); return msg; }  static void copyPayload(AdaptrisMessage src, AdaptrisMessage dest); static void copyPayloadStream(AdaptrisMessage src, AdaptrisMessage dest); static AdaptrisMessage checkCharsetAndApply(final AdaptrisMessage msg, String charEnc,
      final boolean passthru); }
MessageHelper { public static AdaptrisMessage checkCharsetAndApply(final AdaptrisMessage msg, String charEnc, final boolean passthru) { Optional.ofNullable(charEnc).ifPresent((charsetName) -> { if (!passthru) { if (Charset.isSupported(charsetName)) { msg.setContentEncoding(charsetName); } else { log.trace("'{}' is not supported, using default, and marking", charsetName); msg.addObjectHeader(OBJ_METADATA_EXCEPTION, new UnsupportedCharsetException(charsetName)); } } else { msg.setContentEncoding(charsetName); } }); return msg; }  static void copyPayload(AdaptrisMessage src, AdaptrisMessage dest); static void copyPayloadStream(AdaptrisMessage src, AdaptrisMessage dest); static AdaptrisMessage checkCharsetAndApply(final AdaptrisMessage msg, String charEnc,
      final boolean passthru);  }