コード例 #1
0
  public String getDetailedMessage() {
    MuleException e = ExceptionHelper.getRootMuleException(this);
    if (!e.equals(this)) {
      return getMessage();
    }
    StringBuffer buf = new StringBuffer(1024);
    buf.append(SystemUtils.LINE_SEPARATOR)
        .append(StringUtils.repeat('*', 80))
        .append(SystemUtils.LINE_SEPARATOR);
    buf.append("Message               : ").append(message).append(SystemUtils.LINE_SEPARATOR);
    buf.append("Type                  : ")
        .append(getClass().getName())
        .append(SystemUtils.LINE_SEPARATOR);
    buf.append("Code                  : ")
        .append("MULE_ERROR-")
        .append(getExceptionCode() + getMessageCode())
        .append(SystemUtils.LINE_SEPARATOR);
    // buf.append("Msg Code :
    // ").append(getMessageCode()).append(SystemUtils.LINE_SEPARATOR);

    Map info = ExceptionHelper.getExceptionInfo(this);
    for (Iterator iterator = info.keySet().iterator(); iterator.hasNext(); ) {
      String s = (String) iterator.next();
      int pad = 22 - s.length();
      buf.append(s);
      if (pad > 0) {
        buf.append(StringUtils.repeat(' ', pad));
      }
      buf.append(": ");
      buf.append(info.get(s)).append(SystemUtils.LINE_SEPARATOR);
    }

    // print exception stack
    buf.append(StringUtils.repeat('*', 80)).append(SystemUtils.LINE_SEPARATOR);
    buf.append(CoreMessages.exceptionStackIs()).append(SystemUtils.LINE_SEPARATOR);
    buf.append(ExceptionHelper.getExceptionStack(this));

    buf.append(StringUtils.repeat('*', 80)).append(SystemUtils.LINE_SEPARATOR);
    buf.append(CoreMessages.rootStackTrace()).append(SystemUtils.LINE_SEPARATOR);
    Throwable root = ExceptionHelper.getRootException(this);
    StringWriter w = new StringWriter();
    PrintWriter p = new PrintWriter(w);
    root.printStackTrace(p);
    buf.append(w.toString()).append(SystemUtils.LINE_SEPARATOR);
    buf.append(StringUtils.repeat('*', 80)).append(SystemUtils.LINE_SEPARATOR);

    return buf.toString();
  }
コード例 #2
0
public class HttpUtilEchoTestCase extends FunctionalTestCase {

  private static final String SMALL_PAYLOAD = "This is a test.";
  private static final String BIG_PAYLOAD = StringUtils.repeat(SMALL_PAYLOAD, 100);

  private final HttpUtil util = new HttpUtilImpl();

  @Rule public DynamicPort port = new DynamicPort("port1");

  @Override
  protected String getConfigFile() {
    return "http-util-config.xml";
  }

  @Test
  public void testSmallPayload() throws Exception {
    postAndAssert(SMALL_PAYLOAD);
  }

  @Test
  public void testBigPayload() throws Exception {
    postAndAssert(BIG_PAYLOAD);
  }

  private void postAndAssert(String payload) {
    assertEquals(
        payload, util.post(String.format("http://localhost:%d/echo", port.getNumber()), payload));
  }
}
コード例 #3
0
 private void addSeparatorLine(StringBuilder builder) {
   builder.append(StringUtils.repeat(SEPARATOR_CHAR, width));
   builder.append(NEW_LINE);
 }