diff --git a/advanced/advanced-testing-examples/pom.xml b/advanced/advanced-testing-examples/pom.xml index b147d547..af4ab842 100644 --- a/advanced/advanced-testing-examples/pom.xml +++ b/advanced/advanced-testing-examples/pom.xml @@ -137,14 +137,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/advanced/dynamic-ftp/pom.xml b/advanced/dynamic-ftp/pom.xml index e2c72394..e91bfd12 100644 --- a/advanced/dynamic-ftp/pom.xml +++ b/advanced/dynamic-ftp/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/advanced/dynamic-tcp-client/pom.xml b/advanced/dynamic-tcp-client/pom.xml index 683c7d0c..920d1935 100644 --- a/advanced/dynamic-tcp-client/pom.xml +++ b/advanced/dynamic-tcp-client/pom.xml @@ -138,14 +138,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/applications/cafe-scripted/pom.xml b/applications/cafe-scripted/pom.xml index e33277bf..fb4bc5cd 100644 --- a/applications/cafe-scripted/pom.xml +++ b/applications/cafe-scripted/pom.xml @@ -159,14 +159,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/applications/cafe/cafe-amqp/pom.xml b/applications/cafe/cafe-amqp/pom.xml index 7bf360ea..bea8a960 100644 --- a/applications/cafe/cafe-amqp/pom.xml +++ b/applications/cafe/cafe-amqp/pom.xml @@ -132,14 +132,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/applications/cafe/cafe-jms/pom.xml b/applications/cafe/cafe-jms/pom.xml index a205e81f..612691f9 100644 --- a/applications/cafe/cafe-jms/pom.xml +++ b/applications/cafe/cafe-jms/pom.xml @@ -156,14 +156,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/applications/cafe/cafe-si/pom.xml b/applications/cafe/cafe-si/pom.xml index 59789955..01888811 100644 --- a/applications/cafe/cafe-si/pom.xml +++ b/applications/cafe/cafe-si/pom.xml @@ -131,14 +131,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/applications/file-split-ftp/pom.xml b/applications/file-split-ftp/pom.xml index ff2dbf77..0c5a6813 100644 --- a/applications/file-split-ftp/pom.xml +++ b/applications/file-split-ftp/pom.xml @@ -117,6 +117,12 @@ spring-boot-starter-test test + + com.icegreen + greenmail + 2.0.0-alpha-2 + test + org.junit.jupiter junit-jupiter-engine @@ -159,14 +165,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/applications/file-split-ftp/src/main/java/org/springframework/integration/samples/filesplit/Application.java b/applications/file-split-ftp/src/main/java/org/springframework/integration/samples/filesplit/Application.java index cb812119..7555f4cb 100644 --- a/applications/file-split-ftp/src/main/java/org/springframework/integration/samples/filesplit/Application.java +++ b/applications/file-split-ftp/src/main/java/org/springframework/integration/samples/filesplit/Application.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ import org.apache.commons.net.ftp.FTPFile; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.mail.MailProperties; import org.springframework.context.annotation.Bean; import org.springframework.integration.dsl.IntegrationFlow; @@ -34,6 +33,7 @@ import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.Pollers; import org.springframework.integration.file.FileHeaders; import org.springframework.integration.file.FileWritingMessageHandler; +import org.springframework.integration.file.dsl.FileWritingMessageHandlerSpec; import org.springframework.integration.file.dsl.Files; import org.springframework.integration.file.remote.session.SessionFactory; import org.springframework.integration.file.splitter.FileSplitter; @@ -67,11 +67,11 @@ public class Application { @Bean public IntegrationFlow fromFile() { return IntegrationFlows.from( - Files.inboundAdapter(new File("/tmp/in")) - .preventDuplicates(false) - .patternFilter("*.txt"), e -> e.poller(Pollers.fixedDelay(5000) - .errorChannel("tfrErrors.input")) - .id("fileInboundChannelAdapter")) + Files.inboundAdapter(new File("/tmp/in")) + .preventDuplicates(false) + .patternFilter("*.txt"), e -> e.poller(Pollers.fixedDelay(5000) + .errorChannel("tfrErrors.input")) + .id("fileInboundChannelAdapter")) .handle(Files.splitter(true, true)) .>route(Object::getClass, m -> m .channelMapping(FileSplitter.FileMarker.class, "markers.input") @@ -90,11 +90,10 @@ public class Application { } @Bean - public FileWritingMessageHandler fileOut() { + public FileWritingMessageHandlerSpec fileOut() { return Files.outboundAdapter("'/tmp/out'") .appendNewLine(true) - .fileNameExpression("payload.substring(1, 4) + '.txt'") - .get(); + .fileNameExpression("payload.substring(1, 4) + '.txt'"); } /** @@ -106,7 +105,7 @@ public class Application { @Bean public IntegrationFlow markers() { return f -> f.filter(m -> m.getMark().equals(FileSplitter.FileMarker.Mark.END), - e -> e.id("markerFilter")) + e -> e.id("markerFilter")) .publishSubscribeChannel(s -> s // first trigger file flushes @@ -133,7 +132,7 @@ public class Application { .enrichHeaders(Mail.headers() .subject("File successfully split and transferred") .from("foo@bar") - .toFunction(m -> new String[] { "bar@baz" })) + .toFunction(m -> new String[]{ "bar@baz" })) .enrichHeaders(h -> h.header(EMAIL_SUCCESS_SUFFIX, ".success")) .channel("toMail.input"))); } @@ -176,12 +175,12 @@ public class Application { .enrichHeaders(Mail.headers() .subject("File split and transfer failed") .from("foo@bar") - .toFunction(m -> new String[] { "bar@baz" })) + .toFunction(m -> new String[]{ "bar@baz" })) .enrichHeaders(h -> h.header(EMAIL_SUCCESS_SUFFIX, ".failed") .headerExpression(FileHeaders.ORIGINAL_FILE, "payload.failedMessage.headers['" + FileHeaders.ORIGINAL_FILE + "']")) .transform(p -> - p.getFailedMessage().getPayload().toString() + "\n" + getStackTraceAsString(p)) + p.getFailedMessage().getPayload() + "\n" + getStackTraceAsString(p)) .channel("toMail.input"); } @@ -189,7 +188,7 @@ public class Application { public IntegrationFlow toMail() { return f -> f .handle(Mail.outboundAdapter(this.mailProperties.getHost()) -// .javaMailProperties(b -> b.put("mail.debug", "true")) + // .javaMailProperties(b -> b.put("mail.debug", "true")) .port(this.mailProperties.getPort()) .credentials(this.mailProperties.getUsername(), this.mailProperties.getPassword()), e -> e.id("mailOut").advice(afterMailAdvice())); diff --git a/applications/file-split-ftp/src/test/java/org/springframework/integration/samples/filesplit/ApplicationTests.java b/applications/file-split-ftp/src/test/java/org/springframework/integration/samples/filesplit/ApplicationTests.java index 788687aa..6f73b7fa 100644 --- a/applications/file-split-ftp/src/test/java/org/springframework/integration/samples/filesplit/ApplicationTests.java +++ b/applications/file-split-ftp/src/test/java/org/springframework/integration/samples/filesplit/ApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,15 +30,14 @@ import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; -import java.util.List; import org.apache.commons.io.FileUtils; import org.apache.commons.net.ftp.FTPFile; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -49,19 +48,22 @@ import org.springframework.integration.endpoint.SourcePollingChannelAdapter; import org.springframework.integration.file.remote.session.Session; import org.springframework.integration.file.remote.session.SessionFactory; import org.springframework.integration.test.context.SpringIntegrationTest; -import org.springframework.integration.test.mail.TestMailServer; -import org.springframework.integration.test.mail.TestMailServer.SmtpServer; import org.springframework.integration.test.util.TestUtils; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) +import com.icegreen.greenmail.store.FolderException; +import com.icegreen.greenmail.util.GreenMail; +import com.icegreen.greenmail.util.ServerSetup; +import com.icegreen.greenmail.util.ServerSetupTest; +import jakarta.mail.internet.InternetAddress; +import jakarta.mail.internet.MimeMessage; + @SpringBootTest(properties = "spring.main.allow-bean-definition-overriding=true") @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) @SpringIntegrationTest(noAutoStartup = "fileInboundChannelAdapter") public class ApplicationTests { - private static final SmtpServer smtpServer = TestMailServer.smtp(0); + private static GreenMail mailServer; @Autowired private Session session; @@ -69,23 +71,31 @@ public class ApplicationTests { @Autowired private SourcePollingChannelAdapter fileInboundChannelAdapter; - @BeforeClass + @BeforeAll public static void setup() { + ServerSetup smtp = ServerSetupTest.SMTP.dynamicPort(); + smtp.setServerStartupTimeout(10000); + mailServer = new GreenMail(smtp); + mailServer.setUser("bar@bar@baz", "user", "pw"); + mailServer.start(); // Configure the boot property to send email to the test email server. - System.setProperty("spring.mail.port", Integer.toString(smtpServer.getPort())); + System.setProperty("spring.mail.port", Integer.toString(mailServer.getSmtp().getPort())); } - @Before - public void beforeTest() throws IOException { - smtpServer.getMessages().clear(); - - tearDown(); + @AfterAll + static void tearDown() { + mailServer.stop(); + } + @BeforeEach + public void beforeTest() throws FolderException, IOException { + mailServer.purgeEmailFromAllMailboxes(); + cleanup(); this.fileInboundChannelAdapter.start(); } - @After - public void tearDown() throws IOException { + @AfterEach + public void cleanup() throws IOException { File inDir = new File("/tmp/in"); if (inDir.exists()) { FileUtils.cleanDirectory(inDir); @@ -97,22 +107,21 @@ public class ApplicationTests { } } - @SuppressWarnings("unchecked") @Test public void testSuccess() throws Exception { - String message = runTest(false); - assertThat(message).contains("File successfully split and transferred"); - assertThat(message).contains(TestUtils.applySystemFileSeparator("/tmp/in/foo.txt")); + MimeMessage message = runTest(false); + assertThat(message.getSubject()).isEqualTo("File successfully split and transferred"); + assertThat(message.getContent()).asString().contains(TestUtils.applySystemFileSeparator("/tmp/in/foo.txt")); } @Test public void testFailure() throws Exception { willThrow(new RuntimeException("fail test exception")) .given(this.session).write(any(InputStream.class), eq("foo/002.txt.writing")); - String message = runTest(true); - assertThat(message).contains("File split and transfer failed"); - assertThat(message).contains("fail test exception"); - assertThat(message).contains(TestUtils.applySystemFileSeparator("/tmp/out/002.txt")); + MimeMessage message = runTest(true); + assertThat(message.getSubject()).isEqualTo("File split and transfer failed"); + assertThat(message.getContent()).asString().contains("fail test exception"); + assertThat(message.getContent()).asString().contains(TestUtils.applySystemFileSeparator("/tmp/out/002.txt")); } /* @@ -121,7 +130,7 @@ public class ApplicationTests { * Verify the input file was renamed based on success/failure. * Verify the email was sent. */ - private String runTest(boolean fail) throws Exception { + private MimeMessage runTest(boolean fail) throws Exception { File in = new File("/tmp/in/", "foo"); FileOutputStream fos = new FileOutputStream(in); fos.write("*002,foo,bar\n*006,baz,qux\n*009,fiz,buz\n".getBytes()); @@ -175,20 +184,18 @@ public class ApplicationTests { verify(this.session).rename("foo/009.txt.writing", "foo/009.txt"); } - String message = verifyMail(); - assertThat(message).contains("From: foo@bar"); - assertThat(message).contains("To: bar@baz"); + MimeMessage message = verifyMail(); + assertThat(message.getFrom()).containsOnly(new InternetAddress("foo@bar")); + assertThat(message.getRecipients(MimeMessage.RecipientType.TO)).containsOnly(new InternetAddress("bar@baz")); return message; } - public String verifyMail() throws Exception { - List messages = smtpServer.getMessages(); - int n = 0; - while (n++ < 100 && messages.size() < 1) { - Thread.sleep(100); - } - assertThat(messages).hasSize(1); - return messages.get(0); + public MimeMessage verifyMail() { + mailServer.waitForIncomingEmail(10000, 1); + MimeMessage[] mail = mailServer.getReceivedMessagesForDomain("baz"); + assertThat(mail).hasSize(1); + MimeMessage message = mail[0]; + return message; } /** diff --git a/applications/loan-broker/pom.xml b/applications/loan-broker/pom.xml index 5810a631..84437537 100644 --- a/applications/loan-broker/pom.xml +++ b/applications/loan-broker/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/applications/loanshark/pom.xml b/applications/loanshark/pom.xml index 9c3249c2..0f491092 100644 --- a/applications/loanshark/pom.xml +++ b/applications/loanshark/pom.xml @@ -325,14 +325,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/applications/stomp-chat/pom.xml b/applications/stomp-chat/pom.xml index b2074a94..e35837a3 100644 --- a/applications/stomp-chat/pom.xml +++ b/applications/stomp-chat/pom.xml @@ -148,14 +148,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/amqp/pom.xml b/basic/amqp/pom.xml index e73bdf29..380eeb28 100644 --- a/basic/amqp/pom.xml +++ b/basic/amqp/pom.xml @@ -137,14 +137,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/barrier/pom.xml b/basic/barrier/pom.xml index e73417c5..30f06150 100644 --- a/basic/barrier/pom.xml +++ b/basic/barrier/pom.xml @@ -153,14 +153,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/control-bus/pom.xml b/basic/control-bus/pom.xml index d94213cc..027db46b 100644 --- a/basic/control-bus/pom.xml +++ b/basic/control-bus/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/enricher/pom.xml b/basic/enricher/pom.xml index 79251d21..e27e1c99 100644 --- a/basic/enricher/pom.xml +++ b/basic/enricher/pom.xml @@ -132,14 +132,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/feed/pom.xml b/basic/feed/pom.xml index 92f8fd64..6f4e7e11 100644 --- a/basic/feed/pom.xml +++ b/basic/feed/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/file/pom.xml b/basic/file/pom.xml index 0d8beefd..0ad9aae0 100644 --- a/basic/file/pom.xml +++ b/basic/file/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/ftp/pom.xml b/basic/ftp/pom.xml index 739762d5..f9b3403d 100644 --- a/basic/ftp/pom.xml +++ b/basic/ftp/pom.xml @@ -150,14 +150,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/helloworld/pom.xml b/basic/helloworld/pom.xml index 2f439831..f94cd3f9 100644 --- a/basic/helloworld/pom.xml +++ b/basic/helloworld/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/http/pom.xml b/basic/http/pom.xml index e54cce16..0b70047e 100644 --- a/basic/http/pom.xml +++ b/basic/http/pom.xml @@ -186,14 +186,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/jdbc/pom.xml b/basic/jdbc/pom.xml index 3a677ee9..011b4d68 100644 --- a/basic/jdbc/pom.xml +++ b/basic/jdbc/pom.xml @@ -132,14 +132,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/jms/pom.xml b/basic/jms/pom.xml index 0655f283..52ac0c73 100644 --- a/basic/jms/pom.xml +++ b/basic/jms/pom.xml @@ -155,14 +155,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/jmx/pom.xml b/basic/jmx/pom.xml index db28f9a6..51d3ae27 100644 --- a/basic/jmx/pom.xml +++ b/basic/jmx/pom.xml @@ -131,14 +131,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/jpa/pom.xml b/basic/jpa/pom.xml index e0731b20..a93bfead 100644 --- a/basic/jpa/pom.xml +++ b/basic/jpa/pom.xml @@ -155,14 +155,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/kafka/pom.xml b/basic/kafka/pom.xml index 25c439d4..6aa9802a 100644 --- a/basic/kafka/pom.xml +++ b/basic/kafka/pom.xml @@ -155,14 +155,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/mail/pom.xml b/basic/mail/pom.xml index c04e114a..0d47e3ec 100644 --- a/basic/mail/pom.xml +++ b/basic/mail/pom.xml @@ -137,14 +137,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/mongodb/pom.xml b/basic/mongodb/pom.xml index 62cf2e2d..fcf9e415 100644 --- a/basic/mongodb/pom.xml +++ b/basic/mongodb/pom.xml @@ -132,14 +132,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/mqtt/pom.xml b/basic/mqtt/pom.xml index 1be66c49..0148da52 100644 --- a/basic/mqtt/pom.xml +++ b/basic/mqtt/pom.xml @@ -143,14 +143,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/oddeven/pom.xml b/basic/oddeven/pom.xml index a3280015..5f59b2de 100644 --- a/basic/oddeven/pom.xml +++ b/basic/oddeven/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/quote/pom.xml b/basic/quote/pom.xml index 12ef7f1a..13b4e687 100644 --- a/basic/quote/pom.xml +++ b/basic/quote/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/sftp/pom.xml b/basic/sftp/pom.xml index 8c07039d..9ea159be 100644 --- a/basic/sftp/pom.xml +++ b/basic/sftp/pom.xml @@ -132,14 +132,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/tcp-amqp/pom.xml b/basic/tcp-amqp/pom.xml index b6e112e7..d6f05e69 100644 --- a/basic/tcp-amqp/pom.xml +++ b/basic/tcp-amqp/pom.xml @@ -143,14 +143,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/tcp-broadcast/pom.xml b/basic/tcp-broadcast/pom.xml index 3bedf993..e3acd54c 100644 --- a/basic/tcp-broadcast/pom.xml +++ b/basic/tcp-broadcast/pom.xml @@ -143,14 +143,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/tcp-broadcast/src/main/java/org/springframework/integration/samples/tcpbroadcast/TcpBroadcastApplication.java b/basic/tcp-broadcast/src/main/java/org/springframework/integration/samples/tcpbroadcast/TcpBroadcastApplication.java index 054e5218..8dd551a7 100644 --- a/basic/tcp-broadcast/src/main/java/org/springframework/integration/samples/tcpbroadcast/TcpBroadcastApplication.java +++ b/basic/tcp-broadcast/src/main/java/org/springframework/integration/samples/tcpbroadcast/TcpBroadcastApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,7 +98,7 @@ public class TcpBroadcastApplication { } /* - * Excutor for clients. + * Executor for clients. */ @Bean public ThreadPoolTaskExecutor exec() { diff --git a/basic/tcp-client-server/pom.xml b/basic/tcp-client-server/pom.xml index 98ac6a76..e16dd2a1 100644 --- a/basic/tcp-client-server/pom.xml +++ b/basic/tcp-client-server/pom.xml @@ -137,14 +137,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/tcp-client-server/src/main/java/org/springframework/integration/samples/tcpclientserver/Main.java b/basic/tcp-client-server/src/main/java/org/springframework/integration/samples/tcpclientserver/Main.java index ca5874e2..49e3a912 100644 --- a/basic/tcp-client-server/src/main/java/org/springframework/integration/samples/tcpclientserver/Main.java +++ b/basic/tcp-client-server/src/main/java/org/springframework/integration/samples/tcpclientserver/Main.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,15 +16,14 @@ package org.springframework.integration.samples.tcpclientserver; -import java.util.HashMap; -import java.util.Map; import java.util.Scanner; -import org.springframework.context.support.GenericXmlApplicationContext; -import org.springframework.core.env.MapPropertySource; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.integration.endpoint.AbstractEndpoint; +import org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory; import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory; import org.springframework.integration.ip.util.TestingUtilities; -import org.springframework.util.SocketUtils; /** * Demonstrates the use of a gateway as an entry point into the integration flow. @@ -50,12 +49,11 @@ import org.springframework.util.SocketUtils; */ public final class Main { - private static final String AVAILABLE_SERVER_SOCKET = "availableServerSocket"; - /** * Prevent instantiation. */ - private Main() {} + private Main() { + } /** * Load the Spring Integration Application Context @@ -66,22 +64,28 @@ public final class Main { final Scanner scanner = new Scanner(System.in); - System.out.println("\n=========================================================" - + "\n " - + "\n Welcome to the Spring Integration " - + "\n TCP-Client-Server Sample! " - + "\n " - + "\n For more information please visit: " - + "\n https://www.springsource.org/spring-integration/ " - + "\n " - + "\n========================================================="); + System.out.println(""" - final GenericXmlApplicationContext context = Main.setupContext(); + ========================================================= + \s + Welcome to the Spring Integration \s + TCP-Client-Server Sample! \s + \s + For more information please visit: \s + https://www.springsource.org/spring-integration/ \s + \s + ========================================================="""); + + final ConfigurableApplicationContext context = Main.setupContext(); final SimpleGateway gateway = context.getBean(SimpleGateway.class); final AbstractServerConnectionFactory crLfServer = context.getBean(AbstractServerConnectionFactory.class); + final AbstractClientConnectionFactory client = context.getBean(AbstractClientConnectionFactory.class); + final AbstractEndpoint outGateway = context.getBean("outGateway", AbstractEndpoint.class); System.out.print("Waiting for server to accept connections..."); TestingUtilities.waitListening(crLfServer, 10000L); + client.setPort(crLfServer.getPort()); + outGateway.start(); System.out.println("running.\n\n"); System.out.println("Please enter some text and press : "); @@ -107,32 +111,13 @@ public final class Main { } System.out.println("Exiting application...bye."); + context.close(); System.exit(0); } - public static GenericXmlApplicationContext setupContext() { - final GenericXmlApplicationContext context = new GenericXmlApplicationContext(); - - if (System.getProperty(AVAILABLE_SERVER_SOCKET) == null) { - System.out.print("Detect open server socket..."); - int availableServerSocket = SocketUtils.findAvailableTcpPort(5678); - - final Map sockets = new HashMap<>(); - sockets.put(AVAILABLE_SERVER_SOCKET, availableServerSocket); - - final MapPropertySource propertySource = new MapPropertySource("sockets", sockets); - - context.getEnvironment().getPropertySources().addLast(propertySource); - } - - System.out.println("using port " + context.getEnvironment().getProperty(AVAILABLE_SERVER_SOCKET)); - - context.load("classpath:META-INF/spring/integration/tcpClientServerDemo-context.xml"); - context.registerShutdownHook(); - context.refresh(); - - return context; + public static ConfigurableApplicationContext setupContext() { + return new ClassPathXmlApplicationContext("META-INF/spring/integration/tcpClientServerDemo-context.xml"); } } diff --git a/basic/tcp-client-server/src/main/resources/META-INF/spring/integration/tcpClientServerDemo-context.xml b/basic/tcp-client-server/src/main/resources/META-INF/spring/integration/tcpClientServerDemo-context.xml index 30cceb93..4fea2734 100644 --- a/basic/tcp-client-server/src/main/resources/META-INF/spring/integration/tcpClientServerDemo-context.xml +++ b/basic/tcp-client-server/src/main/resources/META-INF/spring/integration/tcpClientServerDemo-context.xml @@ -27,6 +27,7 @@ + port="0"/> + port="0"/> diff --git a/basic/tcp-client-server/src/main/resources/META-INF/spring/integration/tcpServerCustomSerialize-context.xml b/basic/tcp-client-server/src/main/resources/META-INF/spring/integration/tcpServerCustomSerialize-context.xml index 02c568c2..47c185d1 100644 --- a/basic/tcp-client-server/src/main/resources/META-INF/spring/integration/tcpServerCustomSerialize-context.xml +++ b/basic/tcp-client-server/src/main/resources/META-INF/spring/integration/tcpServerCustomSerialize-context.xml @@ -17,7 +17,7 @@ formatted with the Stx-Etx bytes. --> org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/testing-examples/pom.xml b/basic/testing-examples/pom.xml index 4d602ad3..46a69c39 100644 --- a/basic/testing-examples/pom.xml +++ b/basic/testing-examples/pom.xml @@ -141,14 +141,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/twitter/pom.xml b/basic/twitter/pom.xml index 55db0db7..232ea079 100644 --- a/basic/twitter/pom.xml +++ b/basic/twitter/pom.xml @@ -127,14 +127,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/web-sockets/pom.xml b/basic/web-sockets/pom.xml index fa514d1d..86b2dfa1 100644 --- a/basic/web-sockets/pom.xml +++ b/basic/web-sockets/pom.xml @@ -138,14 +138,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/ws-inbound-gateway/pom.xml b/basic/ws-inbound-gateway/pom.xml index d1ccfc58..2eae2d5b 100644 --- a/basic/ws-inbound-gateway/pom.xml +++ b/basic/ws-inbound-gateway/pom.xml @@ -168,14 +168,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/ws-outbound-gateway/pom.xml b/basic/ws-outbound-gateway/pom.xml index d64f27e1..2995f49d 100644 --- a/basic/ws-outbound-gateway/pom.xml +++ b/basic/ws-outbound-gateway/pom.xml @@ -131,14 +131,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/xml/pom.xml b/basic/xml/pom.xml index d95c16e9..b92e57a6 100644 --- a/basic/xml/pom.xml +++ b/basic/xml/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/basic/xmpp/pom.xml b/basic/xmpp/pom.xml index fa0aa152..99c6c3a1 100644 --- a/basic/xmpp/pom.xml +++ b/basic/xmpp/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/build.gradle b/build.gradle index 75de3ee5..7623b65a 100644 --- a/build.gradle +++ b/build.gradle @@ -38,7 +38,7 @@ allprojects { maven { url 'https://repo.spring.io/release' } maven { url 'https://repo.spring.io/milestone' } maven { url 'https://repo.spring.io/snapshot' } -// maven { url 'https://repo.spring.io/libs-staging-local' } + maven { url 'https://repo.spring.io/libs-staging-local' } } } @@ -260,11 +260,11 @@ subprojects { subproject -> postgresVersion = '42.2.14' slf4jVersion = '1.7.30' springCloudVersion = '2022.0.0-SNAPSHOT' - springIntegrationVersion = '6.0.0-M1' + springIntegrationVersion = '6.0.0-M2' springIntegrationSocialTwiterVersion = '1.0.1.BUILD-SNAPSHOT' springIntegrationSplunkVersion = '1.2.0.BUILD-SNAPSHOT' - springVersion = '6.0.0-M2' - springSecurityVersion = '6.0.0-M1' + springVersion = '6.0.0-M3' + springSecurityVersion = '6.0.0-M2' springWebFlowVersion = '2.3.3.RELEASE' testcontainersVersion = '1.16.2' tilesJspVersion = '2.2.1' @@ -1494,6 +1494,7 @@ project('file-split-ftp') { testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.integration:spring-integration-test' + testImplementation "com.icegreen:greenmail:2.0.0-alpha-2" } springBoot { diff --git a/dsl/cafe-dsl/pom.xml b/dsl/cafe-dsl/pom.xml index 971ee97c..01e88e71 100644 --- a/dsl/cafe-dsl/pom.xml +++ b/dsl/cafe-dsl/pom.xml @@ -149,14 +149,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/dsl/kafka-dsl/pom.xml b/dsl/kafka-dsl/pom.xml index 070b96c9..37b9824a 100644 --- a/dsl/kafka-dsl/pom.xml +++ b/dsl/kafka-dsl/pom.xml @@ -149,14 +149,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/dsl/si4demo/pom.xml b/dsl/si4demo/pom.xml index fd414ac3..3307393e 100644 --- a/dsl/si4demo/pom.xml +++ b/dsl/si4demo/pom.xml @@ -171,14 +171,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/async-gateway/pom.xml b/intermediate/async-gateway/pom.xml index d8efd2de..61811aa5 100644 --- a/intermediate/async-gateway/pom.xml +++ b/intermediate/async-gateway/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/dynamic-poller/pom.xml b/intermediate/dynamic-poller/pom.xml index 4dbdf899..fbc9dd26 100644 --- a/intermediate/dynamic-poller/pom.xml +++ b/intermediate/dynamic-poller/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/errorhandling/pom.xml b/intermediate/errorhandling/pom.xml index 04ab8258..9f8bd4f3 100644 --- a/intermediate/errorhandling/pom.xml +++ b/intermediate/errorhandling/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/file-processing/pom.xml b/intermediate/file-processing/pom.xml index 07ac1735..00c9bdf2 100644 --- a/intermediate/file-processing/pom.xml +++ b/intermediate/file-processing/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/mail-attachments/pom.xml b/intermediate/mail-attachments/pom.xml index 48b934b4..35b6b247 100644 --- a/intermediate/mail-attachments/pom.xml +++ b/intermediate/mail-attachments/pom.xml @@ -143,14 +143,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/mail-attachments/src/test/java/org/springframework/integration/samples/mailattachments/MimeMessageParsingTest.java b/intermediate/mail-attachments/src/test/java/org/springframework/integration/samples/mailattachments/MimeMessageParsingTest.java deleted file mode 100644 index c4af31bd..00000000 --- a/intermediate/mail-attachments/src/test/java/org/springframework/integration/samples/mailattachments/MimeMessageParsingTest.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright 2002-2017 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.samples.mailattachments; - -import org.springframework.integration.samples.mailattachments.support.EmailFragment; - -/** - * Test to verify the correct parsing of Email Messages. - * - * @author Gunnar Hillert - * @author Gary Russell - * @author Artem Bilan - * - * @since 2.2 - */ -public class MimeMessageParsingTest { - -/* - private static final Log LOGGER = LogFactory.getLog(MimeMessageParsingTest.class); - - private Wiser wiser; - - private int wiserPort; - - @Before - public void startWiser() { - - this.wiserPort = SocketUtils.findAvailableTcpPort(2500); - - wiser = new Wiser(); - wiser.setPort(this.wiserPort); - wiser.start(); - LOGGER.info("Wiser was started."); - - } - - */ - /** - * This test will create a Mime Message that contains an Attachment, send it - * to an SMTP Server (Using Wiser) and retrieve and process the Mime Message. - * - * This test verifies that the parsing of the retrieved Mime Message is - * successful and that the correct number of {@link EmailFragment}s is created. - *//* - - @Test - public void testProcessingOfEmailAttachments() { - - final JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); - mailSender.setPort(this.wiserPort); - - final MimeMessage message = mailSender.createMimeMessage(); - final String pictureName = "picture.png"; - - final ByteArrayResource byteArrayResource = getFileData(pictureName); - - try { - - final MimeMessageHelper helper = new MimeMessageHelper(message, true); - - helper.setFrom("testfrom@springintegration.org"); - helper.setTo("testto@springintegration.org"); - helper.setSubject("Parsing of Attachments"); - helper.setText("Spring Integration Rocks!"); - - helper.addAttachment(pictureName, byteArrayResource, "image/png"); - - } - catch (MessagingException e) { - throw new MailParseException(e); - } - - mailSender.send(message); - - final List wiserMessages = wiser.getMessages(); - - Assert.assertTrue(wiserMessages.size() == 1); - - boolean foundTextMessage = false; - boolean foundPicture = false; - - for (WiserMessage wiserMessage : wiserMessages) { - - final List emailFragments = new ArrayList<>(); - - try { - final MimeMessage mailMessage = wiserMessage.getMimeMessage(); - EmailParserUtils.handleMessage(null, mailMessage, emailFragments); - } - catch (MessagingException e) { - throw new IllegalStateException("Error while retrieving Mime Message."); - } - - Assert.assertTrue(emailFragments.size() == 2); - - for (EmailFragment emailFragment : emailFragments) { - if ("picture.png".equals(emailFragment.getFilename())) { - foundPicture = true; - } - - if ("message.txt".equals(emailFragment.getFilename())) { - foundTextMessage = true; - } - } - - Assert.assertTrue(foundPicture); - Assert.assertTrue(foundTextMessage); - - } - } - - */ - /** - * This test will create a Mime Message that in return contains another - * mime message. The nested mime message contains an attachment. - * - * The root message consist of both HTML and Text message. - * - *//* - - @Test - public void testProcessingOfNestedEmailAttachments() { - - final JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); - mailSender.setPort(this.wiserPort); - - final MimeMessage rootMessage = mailSender.createMimeMessage(); - - try { - - final MimeMessageHelper messageHelper = new MimeMessageHelper(rootMessage, true); - - messageHelper.setFrom("testfrom@springintegration.org"); - messageHelper.setTo("testto@springintegration.org"); - messageHelper.setSubject("Parsing of Attachments"); - messageHelper.setText("Spring Integration Rocks!", "Spring Integration Rocks!"); - - final String pictureName = "picture.png"; - - final ByteArrayResource byteArrayResource = getFileData(pictureName); - - messageHelper.addInline("picture12345", byteArrayResource, "image/png"); - - } - catch (MessagingException e) { - throw new MailParseException(e); - } - - mailSender.send(rootMessage); - - final List wiserMessages = wiser.getMessages(); - - Assert.assertTrue(wiserMessages.size() == 1); - - boolean foundTextMessage = false; - boolean foundPicture = false; - boolean foundHtmlMessage = false; - - for (WiserMessage wiserMessage : wiserMessages) { - - List emailFragments = new ArrayList<>(); - - try { - - final MimeMessage mailMessage = wiserMessage.getMimeMessage(); - EmailParserUtils.handleMessage(null, mailMessage, emailFragments); - - } catch (MessagingException e) { - throw new IllegalStateException("Error while retrieving Mime Message."); - } - - Assert.assertTrue(emailFragments.size() == 3); - - for (EmailFragment emailFragment : emailFragments) { - if ("".equals(emailFragment.getFilename())) { - foundPicture = true; - } - - if ("message.txt".equals(emailFragment.getFilename())) { - foundTextMessage = true; - } - - if ("message.html".equals(emailFragment.getFilename())) { - foundHtmlMessage = true; - } - } - - Assert.assertTrue(foundPicture); - Assert.assertTrue(foundTextMessage); - Assert.assertTrue(foundHtmlMessage); - - } - } - - private ByteArrayResource getFileData(String filename) { - - final InputStream attachmentInputStream = MimeMessageParsingTest.class.getResourceAsStream(filename); - - Assert.assertNotNull("Resource not found: " + filename, attachmentInputStream); - - ByteArrayResource byteArrayResource = null; - - try { - byteArrayResource = new ByteArrayResource(IOUtils.toByteArray(attachmentInputStream)); - attachmentInputStream.close(); - } - catch (IOException e1) { - Assert.fail(); - } - - return byteArrayResource; - - } - - @After - public void stopWiser() { - wiser.stop(); - LOGGER.info("Wiser stopped."); - } -*/ - -} diff --git a/intermediate/monitoring/pom.xml b/intermediate/monitoring/pom.xml index 78e24ab7..a66d0a2d 100644 --- a/intermediate/monitoring/pom.xml +++ b/intermediate/monitoring/pom.xml @@ -180,14 +180,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/multipart-http/pom.xml b/intermediate/multipart-http/pom.xml index af38e3ff..ee19baad 100644 --- a/intermediate/multipart-http/pom.xml +++ b/intermediate/multipart-http/pom.xml @@ -180,14 +180,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/rest-http/pom.xml b/intermediate/rest-http/pom.xml index ad3c73ce..5914fa71 100644 --- a/intermediate/rest-http/pom.xml +++ b/intermediate/rest-http/pom.xml @@ -95,13 +95,13 @@ org.springframework.security spring-security-web - 6.0.0-M1 + 6.0.0-M2 compile org.springframework.security spring-security-config - 6.0.0-M1 + 6.0.0-M2 compile @@ -211,14 +211,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/retry-and-more/pom.xml b/intermediate/retry-and-more/pom.xml index cb8c5de5..bd7832ad 100644 --- a/intermediate/retry-and-more/pom.xml +++ b/intermediate/retry-and-more/pom.xml @@ -159,14 +159,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/splitter-aggregator-reaper/pom.xml b/intermediate/splitter-aggregator-reaper/pom.xml index fc5a7696..60eb6a39 100644 --- a/intermediate/splitter-aggregator-reaper/pom.xml +++ b/intermediate/splitter-aggregator-reaper/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/stored-procedures-derby/pom.xml b/intermediate/stored-procedures-derby/pom.xml index b902e2d3..32f6f76b 100644 --- a/intermediate/stored-procedures-derby/pom.xml +++ b/intermediate/stored-procedures-derby/pom.xml @@ -132,14 +132,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/stored-procedures-ms/pom.xml b/intermediate/stored-procedures-ms/pom.xml index 555c100e..8e199c59 100644 --- a/intermediate/stored-procedures-ms/pom.xml +++ b/intermediate/stored-procedures-ms/pom.xml @@ -138,14 +138,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/stored-procedures-oracle/pom.xml b/intermediate/stored-procedures-oracle/pom.xml index 5c828dcd..7cc66717 100644 --- a/intermediate/stored-procedures-oracle/pom.xml +++ b/intermediate/stored-procedures-oracle/pom.xml @@ -132,14 +132,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/stored-procedures-postgresql/pom.xml b/intermediate/stored-procedures-postgresql/pom.xml index 9fe8c1bb..c683150f 100644 --- a/intermediate/stored-procedures-postgresql/pom.xml +++ b/intermediate/stored-procedures-postgresql/pom.xml @@ -144,14 +144,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/tcp-async-bi-directional/pom.xml b/intermediate/tcp-async-bi-directional/pom.xml index 0fa7add7..53007fc9 100644 --- a/intermediate/tcp-async-bi-directional/pom.xml +++ b/intermediate/tcp-async-bi-directional/pom.xml @@ -138,14 +138,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/tcp-async-bi-directional/src/test/java/org/springframework/integration/samples/tcpasyncbi/TcpAsyncBiDirectionalApplicationTests.java b/intermediate/tcp-async-bi-directional/src/test/java/org/springframework/integration/samples/tcpasyncbi/TcpAsyncBiDirectionalApplicationTests.java index 7dea9340..d6a50af1 100644 --- a/intermediate/tcp-async-bi-directional/src/test/java/org/springframework/integration/samples/tcpasyncbi/TcpAsyncBiDirectionalApplicationTests.java +++ b/intermediate/tcp-async-bi-directional/src/test/java/org/springframework/integration/samples/tcpasyncbi/TcpAsyncBiDirectionalApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 the original author or authors. + * Copyright 2020-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,9 +33,11 @@ import org.springframework.lang.Nullable; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.support.ChannelInterceptor; +import org.springframework.test.annotation.DirtiesContext; @SpringBootTest @SpringIntegrationTest(noAutoStartup = { "client1Adapter", "client2Adapter" }) +@DirtiesContext class TcpAsyncBiDirectionalApplicationTests { @Autowired diff --git a/intermediate/tcp-client-server-multiplex/pom.xml b/intermediate/tcp-client-server-multiplex/pom.xml index 083bb552..057807b0 100644 --- a/intermediate/tcp-client-server-multiplex/pom.xml +++ b/intermediate/tcp-client-server-multiplex/pom.xml @@ -126,14 +126,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/tcp-client-server-multiplex/src/main/resources/META-INF/spring/integration/tcpClientServerDemo-conversion-context.xml b/intermediate/tcp-client-server-multiplex/src/main/resources/META-INF/spring/integration/tcpClientServerDemo-conversion-context.xml index 13af8dc7..251c5920 100644 --- a/intermediate/tcp-client-server-multiplex/src/main/resources/META-INF/spring/integration/tcpClientServerDemo-conversion-context.xml +++ b/intermediate/tcp-client-server-multiplex/src/main/resources/META-INF/spring/integration/tcpClientServerDemo-conversion-context.xml @@ -36,7 +36,7 @@ + @@ -84,7 +86,7 @@ diff --git a/intermediate/tcp-client-server-multiplex/src/test/java/org/springframework/integration/samples/tcpclientserver/TcpClientServerDemoTest.java b/intermediate/tcp-client-server-multiplex/src/test/java/org/springframework/integration/samples/tcpclientserver/TcpClientServerDemoTest.java index 503fab31..8559d0d1 100644 --- a/intermediate/tcp-client-server-multiplex/src/test/java/org/springframework/integration/samples/tcpclientserver/TcpClientServerDemoTest.java +++ b/intermediate/tcp-client-server-multiplex/src/test/java/org/springframework/integration/samples/tcpclientserver/TcpClientServerDemoTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,31 +16,28 @@ package org.springframework.integration.samples.tcpclientserver; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import java.util.concurrent.BlockingQueue; import java.util.concurrent.CountDownLatch; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.core.task.TaskExecutor; +import org.springframework.integration.endpoint.AbstractEndpoint; +import org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory; import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory; import org.springframework.integration.ip.util.TestingUtilities; -import org.springframework.integration.samples.tcpclientserver.support.CustomTestContextLoader; import org.springframework.messaging.MessagingException; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** @@ -56,9 +53,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @since 2.1 * */ -@ContextConfiguration(loader = CustomTestContextLoader.class, - locations = { "/META-INF/spring/integration/tcpClientServerDemo-conversion-context.xml" }) -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig(locations = "/META-INF/spring/integration/tcpClientServerDemo-conversion-context.xml") @DirtiesContext public class TcpClientServerDemoTest { @@ -68,15 +63,31 @@ public class TcpClientServerDemoTest { @Autowired AbstractServerConnectionFactory crLfServer; - @Before + @Autowired + AbstractClientConnectionFactory client; + + @Autowired + @Qualifier("outAdapter.client") + AbstractEndpoint outAdapterClient; + + @Autowired + @Qualifier("inAdapter.client") + AbstractEndpoint inAdapterClient; + + @BeforeEach public void setup() { - TestingUtilities.waitListening(this.crLfServer, 10000L); + if (!this.outAdapterClient.isRunning()) { + TestingUtilities.waitListening(this.crLfServer, 10000L); + this.client.setPort(this.crLfServer.getPort()); + this.outAdapterClient.start(); + this.inAdapterClient.start(); + } } @Test public void testHappyDay() { String result = gw.send("999Hello world!"); // first 3 bytes is correlationid - assertEquals("999Hello world!:echo", result); + assertThat(result).isEqualTo("999Hello world!:echo"); } @Test @@ -88,36 +99,28 @@ public class TcpClientServerDemoTest { results.add(i); final int j = i; executor.execute(() -> { - String result = gw.send(j + "Hello world!"); // first 3 bytes is correlationid - assertEquals(j + "Hello world!:echo", result); + String result = gw.send(j + "Hello world!"); // first 3 bytes is correlationId + assertThat(result).isEqualTo(j + "Hello world!:echo"); results.remove(j); latch.countDown(); }); } - assertTrue(latch.await(60, TimeUnit.SECONDS)); - assertEquals(0, results.size()); + assertThat(latch.await(60, TimeUnit.SECONDS)).isTrue(); + assertThat(results).hasSize(0); } @Test public void testTimeoutThrow() { - try { - gw.send("TIMEOUT_TEST_THROW"); - fail("expected exception"); - } - catch (MessagingException e) { - assertThat(e.getMessage(), containsString("No response received for TIMEOUT_TEST")); - } + assertThatExceptionOfType(MessagingException.class) + .isThrownBy(() -> gw.send("TIMEOUT_TEST_THROW")) + .withMessageContaining("No response received for TIMEOUT_TEST"); } @Test public void testTimeoutReturn() { - try { - gw.send("TIMEOUT_TEST_RETURN"); - fail("expected exception"); - } - catch (MessagingException e) { - assertThat(e.getMessage(), containsString("No response received for TIMEOUT_TEST")); - } + assertThatExceptionOfType(MessagingException.class) + .isThrownBy(() -> gw.send("TIMEOUT_TEST_RETURN")) + .withMessageContaining("No response received for TIMEOUT_TEST"); } } diff --git a/intermediate/tcp-client-server-multiplex/src/test/java/org/springframework/integration/samples/tcpclientserver/support/CustomTestContextLoader.java b/intermediate/tcp-client-server-multiplex/src/test/java/org/springframework/integration/samples/tcpclientserver/support/CustomTestContextLoader.java deleted file mode 100644 index f952646b..00000000 --- a/intermediate/tcp-client-server-multiplex/src/test/java/org/springframework/integration/samples/tcpclientserver/support/CustomTestContextLoader.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2002-2017 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.integration.samples.tcpclientserver.support; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.context.support.GenericApplicationContext; -import org.springframework.core.env.MapPropertySource; -import org.springframework.util.SocketUtils; -import org.springframework.test.context.MergedContextConfiguration; -import org.springframework.test.context.support.GenericXmlContextLoader; - -/** - * - * @author Gunnar Hillert - * @author Gary Russell - * @author Artem Bilan - * - */ -public class CustomTestContextLoader extends GenericXmlContextLoader { - - private static final Log LOGGER = LogFactory.getLog(CustomTestContextLoader.class); - - @Override - protected void loadBeanDefinitions(GenericApplicationContext context, - MergedContextConfiguration mergedConfig) { - - int availableServerSocket = SocketUtils.findAvailableTcpPort(5678); - - final Map sockets = new HashMap(); - sockets.put("availableServerSocket", availableServerSocket); - - if (LOGGER.isInfoEnabled()) { - LOGGER.info("Available Server Socket: " + availableServerSocket); - } - - final MapPropertySource propertySource = new MapPropertySource("sockets", sockets); - - context.getEnvironment().getPropertySources().addLast(propertySource); - super.loadBeanDefinitions(context, mergedConfig); - } - -} diff --git a/intermediate/testcontainers-rabbitmq/pom.xml b/intermediate/testcontainers-rabbitmq/pom.xml index 6710c65a..c9e3a51b 100644 --- a/intermediate/testcontainers-rabbitmq/pom.xml +++ b/intermediate/testcontainers-rabbitmq/pom.xml @@ -172,14 +172,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/travel/pom.xml b/intermediate/travel/pom.xml index 0d7e20f6..01ec885e 100644 --- a/intermediate/travel/pom.xml +++ b/intermediate/travel/pom.xml @@ -136,14 +136,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom diff --git a/intermediate/tx-synch/pom.xml b/intermediate/tx-synch/pom.xml index 750d8ff6..c26510b9 100644 --- a/intermediate/tx-synch/pom.xml +++ b/intermediate/tx-synch/pom.xml @@ -137,14 +137,14 @@ org.springframework spring-framework-bom - 6.0.0-M2 + 6.0.0-M3 import pom org.springframework.integration spring-integration-bom - 6.0.0-M1 + 6.0.0-M2 import pom