MultiPayloadByteArrayInputParameter implements DataInputParameter<byte[]> { @Override public byte[] extract(InterlokMessage m) throws InterlokException { if (m instanceof MultiPayloadAdaptrisMessage) { return extract(m.resolve(getPayloadId()), (MultiPayloadAdaptrisMessage)m); } throw new InterlokException("Cannot extract payload from message type " + m.getClass().getName() + " as it does not support multiple payloads."); }  String getPayloadId(); void setPayloadId(String payloadId); @Override byte[] extract(InterlokMessage m); byte[] extract(String id, MultiPayloadAdaptrisMessage m);  }
@Test public void testExtract() throws Exception { MultiPayloadByteArrayInputParameter parameter = new MultiPayloadByteArrayInputParameter(); parameter.setPayloadId(ID); MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage)new MultiPayloadMessageFactory().newMessage(ID, PAYLOAD); assertArrayEquals(PAYLOAD, parameter.extract(message)); assertArrayEquals(PAYLOAD, parameter.extract(ID, message)); assertArrayEquals(PAYLOAD, parameter.extract(null, message)); }
@Test public void testWrongMessageType() { try { MultiPayloadByteArrayInputParameter parameter = new MultiPayloadByteArrayInputParameter(); AdaptrisMessage message = DefaultMessageFactory.getDefaultInstance().newMessage(PAYLOAD); parameter.extract(message); fail(); } catch (Exception e) { } }