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

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

本文整理了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

  1. @Test
  2. public void exceptionExpected() {
  3. try {
  4. shouldFail.send(new GenericMessage<String>("foo"));
  5. fail("Exception expected");
  6. }
  7. catch (MessageHandlingException e) {
  8. assertThat(e.getMessage(), startsWith("Unable to find outbound socket"));
  9. }
  10. }

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

  1. /**
  2. * Test uses the Fail mode of the File Outbound Gateway. When persisting
  3. * a payload using the File Outbound Gateway and the mode is set to Fail,
  4. * then the destination {@link File} will be created and written if it does
  5. * not yet exist. BUT if the destination {@link File} already exists, a
  6. * {@link MessageHandlingException} will be thrown.
  7. *
  8. */
  9. @Test
  10. public void gatewayWithFailMode() throws Exception {
  11. final MessagingTemplate messagingTemplate = new MessagingTemplate();
  12. messagingTemplate.setDefaultDestination(this.gatewayWithFailModeChannel);
  13. String expectedFileContent = "Initial File Content:";
  14. File testFile = new File("test/fileToAppend.txt");
  15. if (testFile.exists()) {
  16. testFile.delete();
  17. }
  18. messagingTemplate.sendAndReceive(new GenericMessage<>("Initial File Content:"));
  19. final String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
  20. assertEquals(expectedFileContent, actualFileContent);
  21. try {
  22. messagingTemplate.sendAndReceive(new GenericMessage<>("String content:"));
  23. }
  24. catch (MessageHandlingException e) {
  25. assertThat(e.getMessage(), startsWith("The destination file already exists at '"));
  26. return;
  27. }
  28. fail("Was expecting a MessageHandlingException to be thrown.");
  29. }

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

  1. /**
  2. * Test is exactly the same as {@link #gatewayWithFailMode()}. However, the
  3. * mode is provided in lower-case ensuring that the mode can be provided
  4. * in an case-insensitive fashion.
  5. *
  6. * Instead a {@link MessageHandlingException} will be thrown.
  7. *
  8. */
  9. @Test
  10. public void gatewayWithFailModeLowercase() throws Exception {
  11. final MessagingTemplate messagingTemplate = new MessagingTemplate();
  12. messagingTemplate.setDefaultDestination(this.gatewayWithFailModeLowercaseChannel);
  13. String expectedFileContent = "Initial File Content:";
  14. File testFile = new File("test/fileToAppend.txt");
  15. if (testFile.exists()) {
  16. testFile.delete();
  17. }
  18. messagingTemplate.sendAndReceive(new GenericMessage<>("Initial File Content:"));
  19. final String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
  20. assertEquals(expectedFileContent, actualFileContent);
  21. try {
  22. messagingTemplate.sendAndReceive(new GenericMessage<>("String content:"));
  23. }
  24. catch (MessageHandlingException e) {
  25. assertThat(e.getMessage(), startsWith("The destination file already exists at '"));
  26. return;
  27. }
  28. fail("Was expecting a MessageHandlingException to be thrown.");
  29. }

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

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

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

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

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

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

相关文章