This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit c77da7ea69fd7b0de3c486c7d110b854a41f3c73 Author: Guillaume Nodet <[email protected]> AuthorDate: Tue Jun 30 12:09:01 2020 +0200 [CAMEL-11807] Upgrade camel-jsch to junit5 --- components/camel-jsch/pom.xml | 2 +- .../camel/component/scp/ScpServerTestSupport.java | 17 +++++++------ .../camel/component/scp/ScpSimpleProduceTest.java | 29 +++++++++++----------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/components/camel-jsch/pom.xml b/components/camel-jsch/pom.xml index 165da7d..62697f3 100644 --- a/components/camel-jsch/pom.xml +++ b/components/camel-jsch/pom.xml @@ -51,7 +51,7 @@ <!-- test dependencies --> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> + <artifactId>camel-test-junit5</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/components/camel-jsch/src/test/java/org/apache/camel/component/scp/ScpServerTestSupport.java b/components/camel-jsch/src/test/java/org/apache/camel/component/scp/ScpServerTestSupport.java index 12bda8b..37a5ef4 100644 --- a/components/camel-jsch/src/test/java/org/apache/camel/component/scp/ScpServerTestSupport.java +++ b/components/camel-jsch/src/test/java/org/apache/camel/component/scp/ScpServerTestSupport.java @@ -29,7 +29,7 @@ import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; import com.jcraft.jsch.UserInfo; import org.apache.camel.test.AvailablePortFinder; -import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.sshd.common.keyprovider.FileKeyPairProvider; import org.apache.sshd.server.SshServer; import org.apache.sshd.server.auth.password.PasswordAuthenticator; @@ -37,12 +37,15 @@ import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator; import org.apache.sshd.server.scp.ScpCommandFactory; import org.apache.sshd.server.session.ServerSession; import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.camel.test.junit5.TestSupport.createDirectory; +import static org.apache.camel.test.junit5.TestSupport.deleteDirectory; + public abstract class ScpServerTestSupport extends CamelTestSupport { protected static final Logger LOG = LoggerFactory.getLogger(ScpServerTestSupport.class); protected static final String SCP_ROOT_DIR = "target/test-classes/scp"; @@ -71,13 +74,13 @@ public abstract class ScpServerTestSupport extends CamelTestSupport { return sshd; } - @BeforeClass + @BeforeAll public static void initPort() throws Exception { port = AvailablePortFinder.getNextAvailable(); } @Override - @Before + @BeforeEach public void setUp() throws Exception { deleteDirectory(getScpPath()); createDirectory(getScpPath()); @@ -88,7 +91,7 @@ public abstract class ScpServerTestSupport extends CamelTestSupport { } @Override - @After + @AfterEach public void tearDown() throws Exception { super.tearDown(); diff --git a/components/camel-jsch/src/test/java/org/apache/camel/component/scp/ScpSimpleProduceTest.java b/components/camel-jsch/src/test/java/org/apache/camel/component/scp/ScpSimpleProduceTest.java index cbc8855..8da38c8 100644 --- a/components/camel-jsch/src/test/java/org/apache/camel/component/scp/ScpSimpleProduceTest.java +++ b/components/camel-jsch/src/test/java/org/apache/camel/component/scp/ScpSimpleProduceTest.java @@ -22,9 +22,10 @@ import java.nio.file.Files; import org.apache.camel.BindToRegistry; import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; -import org.junit.Assume; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class ScpSimpleProduceTest extends ScpServerTestSupport { @@ -42,7 +43,7 @@ public class ScpSimpleProduceTest extends ScpServerTestSupport { @Test public void testScpSimpleProduce() throws Exception { - Assume.assumeTrue(this.isSetupComplete()); + assumeTrue(this.isSetupComplete()); getMockEndpoint("mock:result").expectedBodiesReceived("Hello World"); @@ -54,7 +55,7 @@ public class ScpSimpleProduceTest extends ScpServerTestSupport { @Test public void testScpSimpleProduceTwoTimes() throws Exception { - Assume.assumeTrue(this.isSetupComplete()); + assumeTrue(this.isSetupComplete()); getMockEndpoint("mock:result").expectedBodiesReceivedInAnyOrder("Hello World", "Bye World"); @@ -67,7 +68,7 @@ public class ScpSimpleProduceTest extends ScpServerTestSupport { @Test public void testScpSimpleSubPathProduce() throws Exception { - Assume.assumeTrue(this.isSetupComplete()); + assumeTrue(this.isSetupComplete()); getMockEndpoint("mock:result").expectedBodiesReceived("Bye World"); @@ -79,7 +80,7 @@ public class ScpSimpleProduceTest extends ScpServerTestSupport { @Test public void testScpSimpleTwoSubPathProduce() throws Exception { - Assume.assumeTrue(this.isSetupComplete()); + assumeTrue(this.isSetupComplete()); getMockEndpoint("mock:result").expectedBodiesReceived("Farewell World"); @@ -91,7 +92,7 @@ public class ScpSimpleProduceTest extends ScpServerTestSupport { @Test public void testScpProduceChmod() throws Exception { - Assume.assumeTrue(this.isSetupComplete()); + assumeTrue(this.isSetupComplete()); getMockEndpoint("mock:result").expectedBodiesReceived("Bonjour Monde"); @@ -102,9 +103,9 @@ public class ScpSimpleProduceTest extends ScpServerTestSupport { } @Test - @Ignore("Fails on CI servers") + @Disabled("Fails on CI servers") public void testScpProducePrivateKey() throws Exception { - Assume.assumeTrue(this.isSetupComplete()); + assumeTrue(this.isSetupComplete()); getMockEndpoint("mock:result").expectedMessageCount(1); @@ -115,9 +116,9 @@ public class ScpSimpleProduceTest extends ScpServerTestSupport { } @Test - @Ignore("Fails on CI servers") + @Disabled("Fails on CI servers") public void testScpProducePrivateKeyFromClasspath() throws Exception { - Assume.assumeTrue(this.isSetupComplete()); + assumeTrue(this.isSetupComplete()); getMockEndpoint("mock:result").expectedMessageCount(1); @@ -128,9 +129,9 @@ public class ScpSimpleProduceTest extends ScpServerTestSupport { } @Test - @Ignore("Fails on CI servers") + @Disabled("Fails on CI servers") public void testScpProducePrivateKeyByte() throws Exception { - Assume.assumeTrue(this.isSetupComplete()); + assumeTrue(this.isSetupComplete()); getMockEndpoint("mock:result").expectedMessageCount(1);
