@Test public void testExceptionNotFound() throws Exception { AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(); Exception e = new Exception(new NullPointerException()); msg.addObjectHeader(OBJ_METADATA_EXCEPTION, e); ExceptionDestination ed = new ExceptionDestination(DEFAULT_DEST, createExceptionMappings()); String dest = ed.getDestination(msg); assertEquals(ed.toString(), DEFAULT_DEST, dest); }
@Override public String getDestination(AdaptrisMessage msg) throws CoreException { String destinationName = defaultDestination; if (msg.getObjectHeaders().containsKey(OBJ_METADATA_EXCEPTION)) { Exception e = (Exception) msg.getObjectHeaders().get(OBJ_METADATA_EXCEPTION); Throwable exc = e; do { if (exceptionMapping.contains(new KeyValuePair(exc.getClass().getName(), ""))) { destinationName = exceptionMapping.getValue(exc.getClass().getName()); break; } } while ((exc = exc.getCause()) != null); } else { log.debug("No Exception in object metadata, using default destination"); } log.trace("Destination found to be " + destinationName); return destinationName; }
ExceptionDestination implements MessageDrivenDestination { @Override public String getDestination(AdaptrisMessage msg) throws CoreException { String destinationName = defaultDestination; if (msg.getObjectHeaders().containsKey(OBJ_METADATA_EXCEPTION)) { Exception e = (Exception) msg.getObjectHeaders().get(OBJ_METADATA_EXCEPTION); Throwable exc = e; do { if (exceptionMapping.contains(new KeyValuePair(exc.getClass().getName(), ""))) { destinationName = exceptionMapping.getValue(exc.getClass().getName()); break; } } while ((exc = exc.getCause()) != null); } else { log.debug("No Exception in object metadata, using default destination"); } log.trace("Destination found to be " + destinationName); return destinationName; } }
ExceptionDestination implements MessageDrivenDestination { @Override public String getDestination(AdaptrisMessage msg) throws CoreException { String destinationName = defaultDestination; if (msg.getObjectHeaders().containsKey(OBJ_METADATA_EXCEPTION)) { Exception e = (Exception) msg.getObjectHeaders().get(OBJ_METADATA_EXCEPTION); Throwable exc = e; do { if (exceptionMapping.contains(new KeyValuePair(exc.getClass().getName(), ""))) { destinationName = exceptionMapping.getValue(exc.getClass().getName()); break; } } while ((exc = exc.getCause()) != null); } else { log.debug("No Exception in object metadata, using default destination"); } log.trace("Destination found to be " + destinationName); return destinationName; } ExceptionDestination();  ExceptionDestination(String defaultDestination, KeyValuePairCollection mappings); }
ExceptionDestination implements MessageDrivenDestination { @Override public String getDestination(AdaptrisMessage msg) throws CoreException { String destinationName = defaultDestination; if (msg.getObjectHeaders().containsKey(OBJ_METADATA_EXCEPTION)) { Exception e = (Exception) msg.getObjectHeaders().get(OBJ_METADATA_EXCEPTION); Throwable exc = e; do { if (exceptionMapping.contains(new KeyValuePair(exc.getClass().getName(), ""))) { destinationName = exceptionMapping.getValue(exc.getClass().getName()); break; } } while ((exc = exc.getCause()) != null); } else { log.debug("No Exception in object metadata, using default destination"); } log.trace("Destination found to be " + destinationName); return destinationName; } ExceptionDestination();  ExceptionDestination(String defaultDestination, KeyValuePairCollection mappings); @Override String getDestination(AdaptrisMessage msg); KeyValuePairCollection getExceptionMapping(); void setExceptionMapping(KeyValuePairCollection mapping); String getDefaultDestination(); void setDefaultDestination(String s); }
ExceptionDestination implements MessageDrivenDestination { @Override public String getDestination(AdaptrisMessage msg) throws CoreException { String destinationName = defaultDestination; if (msg.getObjectHeaders().containsKey(OBJ_METADATA_EXCEPTION)) { Exception e = (Exception) msg.getObjectHeaders().get(OBJ_METADATA_EXCEPTION); Throwable exc = e; do { if (exceptionMapping.contains(new KeyValuePair(exc.getClass().getName(), ""))) { destinationName = exceptionMapping.getValue(exc.getClass().getName()); break; } } while ((exc = exc.getCause()) != null); } else { log.debug("No Exception in object metadata, using default destination"); } log.trace("Destination found to be " + destinationName); return destinationName; } ExceptionDestination();  ExceptionDestination(String defaultDestination, KeyValuePairCollection mappings); @Override String getDestination(AdaptrisMessage msg); KeyValuePairCollection getExceptionMapping(); void setExceptionMapping(KeyValuePairCollection mapping); String getDefaultDestination(); void setDefaultDestination(String s);  }