org.springframework.messaging.MessageHandlingException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中org.springframework.messaging.MessageHandlingException.getMessage()方法的一些代码示例,展示了MessageHandlingException.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MessageHandlingException.getMessage()方法的具体详情如下:
包路径:org.springframework.messaging.MessageHandlingException
类名称:MessageHandlingException
方法名:getMessage

MessageHandlingException.getMessage介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-integration

@Test
public void exceptionExpected() {
  try {
    shouldFail.send(new GenericMessage<String>("foo"));
    fail("Exception expected");
  }
  catch (MessageHandlingException e) {
    assertThat(e.getMessage(), startsWith("Unable to find outbound socket"));
  }
}

代码示例来源:origin: spring-projects/spring-integration

/**
 * Test uses the Fail mode of the File Outbound Gateway. When persisting
 * a payload using the File Outbound Gateway and the mode is set to Fail,
 * then the destination {@link File} will be created and written if it does
 * not yet exist. BUT if the destination {@link File} already exists, a
 * {@link MessageHandlingException} will be thrown.
 *
 */
@Test
public void gatewayWithFailMode() throws Exception {
  final MessagingTemplate messagingTemplate = new MessagingTemplate();
  messagingTemplate.setDefaultDestination(this.gatewayWithFailModeChannel);
  String expectedFileContent = "Initial File Content:";
  File testFile = new File("test/fileToAppend.txt");
  if (testFile.exists()) {
    testFile.delete();
  }
  messagingTemplate.sendAndReceive(new GenericMessage<>("Initial File Content:"));
  final String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
  assertEquals(expectedFileContent, actualFileContent);
  try {
    messagingTemplate.sendAndReceive(new GenericMessage<>("String content:"));
  }
  catch (MessageHandlingException e) {
    assertThat(e.getMessage(), startsWith("The destination file already exists at '"));
    return;
  }
  fail("Was expecting a MessageHandlingException to be thrown.");
}

代码示例来源:origin: spring-projects/spring-integration

/**
 * Test is exactly the same as {@link #gatewayWithFailMode()}. However, the
 * mode is provided in lower-case ensuring that the mode can be provided
 * in an case-insensitive fashion.
 *
 * Instead a {@link MessageHandlingException} will be thrown.
 *
 */
@Test
public void gatewayWithFailModeLowercase() throws Exception {
  final MessagingTemplate messagingTemplate = new MessagingTemplate();
  messagingTemplate.setDefaultDestination(this.gatewayWithFailModeLowercaseChannel);
  String expectedFileContent = "Initial File Content:";
  File testFile = new File("test/fileToAppend.txt");
  if (testFile.exists()) {
    testFile.delete();
  }
  messagingTemplate.sendAndReceive(new GenericMessage<>("Initial File Content:"));
  final String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
  assertEquals(expectedFileContent, actualFileContent);
  try {
    messagingTemplate.sendAndReceive(new GenericMessage<>("String content:"));
  }
  catch (MessageHandlingException e) {
    assertThat(e.getMessage(), startsWith("The destination file already exists at '"));
    return;
  }
  fail("Was expecting a MessageHandlingException to be thrown.");
}

代码示例来源:origin: spring-projects/spring-integration

assertThat(e.getMessage(), containsString("already exists"));
assertThat(e.getMessage(), containsString("already exists"));

代码示例来源:origin: spring-projects/spring-integration

assertThat(e.getMessage(), Matchers.containsString("Unable to find outbound socket"));

代码示例来源:origin: spring-projects/spring-integration

assertThat(e.getMessage(), containsString("Failed to clone payload object"));
return;

相关文章