@Test public void testBadPayload() throws Exception { AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("ABCDE"); ProduceDestination d = createDestination(); String s = d.getDestination(msg); assertEquals(DEFAULT_DESTINATION, s); }
@Override public String getDestination(AdaptrisMessage msg) { String destination = null; Object msgObject = null; try { msgObject = marshallerToUse().unmarshal(msg.getContent()); String className = msgObject.getClass().getName(); logR.trace("Unmarshalled [" + className + "]"); if (mappings.contains(new KeyValuePair(className, ""))) { destination = mappings.getValue(className); } else { logR.trace("[" + className + "] not found, using default"); destination = defaultDestination; } } catch (Exception e) { logR.trace("Payload could not be unmarshalled using default destination"); destination = defaultDestination; } logR.trace("Destination for message [" + destination +"]"); if (StringUtils.isEmpty(destination)) { throw new RuntimeException("Could not resolve destination"); } return destination; }
MarshalledClassDestination implements MessageDrivenDestination { @Override public String getDestination(AdaptrisMessage msg) { String destination = null; Object msgObject = null; try { msgObject = marshallerToUse().unmarshal(msg.getContent()); String className = msgObject.getClass().getName(); logR.trace("Unmarshalled [" + className + "]"); if (mappings.contains(new KeyValuePair(className, ""))) { destination = mappings.getValue(className); } else { logR.trace("[" + className + "] not found, using default"); destination = defaultDestination; } } catch (Exception e) { logR.trace("Payload could not be unmarshalled using default destination"); destination = defaultDestination; } logR.trace("Destination for message [" + destination +"]"); if (StringUtils.isEmpty(destination)) { throw new RuntimeException("Could not resolve destination"); } return destination; } }
MarshalledClassDestination implements MessageDrivenDestination { @Override public String getDestination(AdaptrisMessage msg) { String destination = null; Object msgObject = null; try { msgObject = marshallerToUse().unmarshal(msg.getContent()); String className = msgObject.getClass().getName(); logR.trace("Unmarshalled [" + className + "]"); if (mappings.contains(new KeyValuePair(className, ""))) { destination = mappings.getValue(className); } else { logR.trace("[" + className + "] not found, using default"); destination = defaultDestination; } } catch (Exception e) { logR.trace("Payload could not be unmarshalled using default destination"); destination = defaultDestination; } logR.trace("Destination for message [" + destination +"]"); if (StringUtils.isEmpty(destination)) { throw new RuntimeException("Could not resolve destination"); } return destination; } MarshalledClassDestination(); }
MarshalledClassDestination implements MessageDrivenDestination { @Override public String getDestination(AdaptrisMessage msg) { String destination = null; Object msgObject = null; try { msgObject = marshallerToUse().unmarshal(msg.getContent()); String className = msgObject.getClass().getName(); logR.trace("Unmarshalled [" + className + "]"); if (mappings.contains(new KeyValuePair(className, ""))) { destination = mappings.getValue(className); } else { logR.trace("[" + className + "] not found, using default"); destination = defaultDestination; } } catch (Exception e) { logR.trace("Payload could not be unmarshalled using default destination"); destination = defaultDestination; } logR.trace("Destination for message [" + destination +"]"); if (StringUtils.isEmpty(destination)) { throw new RuntimeException("Could not resolve destination"); } return destination; } MarshalledClassDestination(); @Override String getDestination(AdaptrisMessage msg); void setClassMappings(KeyValuePairSet set); KeyValuePairSet getClassMappings(); AdaptrisMarshaller getMarshaller(); void setMarshaller(AdaptrisMarshaller m); void setDefaultDestination(String d); String getDefaultDestination(); }
MarshalledClassDestination implements MessageDrivenDestination { @Override public String getDestination(AdaptrisMessage msg) { String destination = null; Object msgObject = null; try { msgObject = marshallerToUse().unmarshal(msg.getContent()); String className = msgObject.getClass().getName(); logR.trace("Unmarshalled [" + className + "]"); if (mappings.contains(new KeyValuePair(className, ""))) { destination = mappings.getValue(className); } else { logR.trace("[" + className + "] not found, using default"); destination = defaultDestination; } } catch (Exception e) { logR.trace("Payload could not be unmarshalled using default destination"); destination = defaultDestination; } logR.trace("Destination for message [" + destination +"]"); if (StringUtils.isEmpty(destination)) { throw new RuntimeException("Could not resolve destination"); } return destination; } MarshalledClassDestination(); @Override String getDestination(AdaptrisMessage msg); void setClassMappings(KeyValuePairSet set); KeyValuePairSet getClassMappings(); AdaptrisMarshaller getMarshaller(); void setMarshaller(AdaptrisMarshaller m); void setDefaultDestination(String d); String getDefaultDestination();  }