BytePayloadCacheValueTranslator implements CacheValueTranslator<byte[]> { @Override public void addValueToMessage(AdaptrisMessage msg, byte[] value) throws CoreException { msg.setPayload(value); }  @Override byte[] getValueFromMessage(AdaptrisMessage msg); @Override void addValueToMessage(AdaptrisMessage msg, byte[] value);  }
@Test public void testAddValueToMessage() throws Exception { BytePayloadCacheValueTranslator translator = new BytePayloadCacheValueTranslator(); AdaptrisMessage message = createMessage(); translator.addValueToMessage(message, "Hello World".getBytes()); assertTrue(MessageDigest.isEqual("Hello World".getBytes(), message.getPayload())); }
@Test public void testAddInvalidValueToMessage() throws Exception { AdaptrisMessage message = createMessage(); CacheValueTranslator translator = new BytePayloadCacheValueTranslator(); try { translator.addValueToMessage(message, new Object()); fail("Successfully added an object that isn't a byte[]"); } catch (ClassCastException expected) { ; } }