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 153f25160e0a6a31e2c107ea4c42a245cc1188cf Author: Guillaume Nodet <[email protected]> AuthorDate: Mon Jul 27 11:35:49 2020 +0200 [CAMEL-11807] Upgrade camel-zipfile to junit5 --- components/camel-zipfile/pom.xml | 4 +-- .../zipfile/SpringZipSplitterRouteTest.java | 4 +-- .../dataformat/zipfile/ZipFileDataFormatTest.java | 33 ++++++++++++---------- .../zipfile/ZipFileIteratorDataFormatTest.java | 4 +-- .../zipfile/ZipFileMultipleFilesSplitterTest.java | 2 +- .../zipfile/ZipFileSplitAndDeleteTest.java | 15 ++++++---- .../zipfile/ZipFileSplitOneFileTest.java | 10 ++++--- .../zipfile/ZipSplitterRouteIssueTest.java | 10 ++++--- .../dataformat/zipfile/ZipSplitterRouteTest.java | 4 +-- .../AggregationStrategyWithFilenameHeaderTest.java | 17 ++++++----- .../AggregationStrategyWithPreservationTest.java | 22 +++++++++------ .../ZipAggregationStrategyEmptyFileTest.java | 16 +++++++---- .../zipfile/ZipAggregationStrategyTest.java | 16 +++++++---- 13 files changed, 91 insertions(+), 66 deletions(-) diff --git a/components/camel-zipfile/pom.xml b/components/camel-zipfile/pom.xml index 2e59308..977a91e 100644 --- a/components/camel-zipfile/pom.xml +++ b/components/camel-zipfile/pom.xml @@ -47,7 +47,7 @@ <!-- test dependencies --> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> + <artifactId>camel-test-junit5</artifactId> <scope>test</scope> </dependency> <dependency> @@ -57,7 +57,7 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test-spring</artifactId> + <artifactId>camel-test-spring-junit5</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/SpringZipSplitterRouteTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/SpringZipSplitterRouteTest.java index ddb746a..f5d3974 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/SpringZipSplitterRouteTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/SpringZipSplitterRouteTest.java @@ -17,8 +17,8 @@ package org.apache.camel.dataformat.zipfile; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.spring.CamelSpringTestSupport; -import org.junit.Test; +import org.apache.camel.test.spring.junit5.CamelSpringTestSupport; +import org.junit.jupiter.api.*; import static org.junit.jupiter.api.Assertions.*; import org.springframework.context.support.ClassPathXmlApplicationContext; public class SpringZipSplitterRouteTest extends CamelSpringTestSupport { diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java index 31115a0..f2817fa 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java @@ -39,10 +39,14 @@ import org.apache.camel.builder.NotifyBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.converter.stream.InputStreamCache; -import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.camel.util.IOHelper; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.*; + +import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf; +import static org.apache.camel.test.junit5.TestSupport.deleteDirectory; +import static org.junit.jupiter.api.Assertions.*; import static org.apache.camel.Exchange.FILE_NAME; @@ -157,13 +161,12 @@ public class ZipFileDataFormatTest extends CamelTestSupport { deleteDirectory(new File("hello_out")); } - @Test(expected = CamelExecutionException.class) + @Test public void testUnzipWithCorruptedZipFile() throws Exception { deleteDirectory(new File("hello_out")); - template.sendBody("direct:corruptUnzip", new File("src/test/resources/corrupt.zip")); - - deleteDirectory(new File("hello_out")); + assertThrows(CamelExecutionException.class, + () -> template.sendBody("direct:corruptUnzip", new File("src/test/resources/corrupt.zip"))); } @Test @@ -195,12 +198,12 @@ public class ZipFileDataFormatTest extends CamelTestSupport { assertMockEndpointsSatisfied(); // use builder to ensure the exchange is fully done before we check for file exists - assertTrue("The exchange is not done in time.", notify.matches(5, TimeUnit.SECONDS)); + assertTrue(notify.matches(5, TimeUnit.SECONDS), "The exchange is not done in time."); Exchange exchange = mock.getReceivedExchanges().get(0); File file = new File(TEST_DIR, exchange.getIn().getMessageId() + ".zip"); - assertTrue("The file should exist.", file.exists()); - assertArrayEquals("Get a wrong message content.", getZippedText(exchange.getIn().getMessageId()), getBytes(file)); + assertTrue(file.exists(), "The file should exist."); + assertArrayEquals(getZippedText(exchange.getIn().getMessageId()), getBytes(file), "Get a wrong message content."); } @Test @@ -211,7 +214,7 @@ public class ZipFileDataFormatTest extends CamelTestSupport { mock.expectedMessageCount(1); File file = new File(TEST_DIR, "poem.txt.zip"); - assertFalse("The zip should not exit.", file.exists()); + assertFalse(file.exists(), "The zip should not exit."); template.sendBodyAndHeader("direct:zipToFile", TEXT, FILE_NAME, "poem.txt"); @@ -219,10 +222,10 @@ public class ZipFileDataFormatTest extends CamelTestSupport { mock.assertIsSatisfied(); // use builder to ensure the exchange is fully done before we check for file exists - assertTrue("The exchange is not done in time.", notify.matches(5, TimeUnit.SECONDS)); + assertTrue(notify.matches(5, TimeUnit.SECONDS), "The exchange is not done in time."); - assertTrue("The file should exist.", file.exists()); - assertArrayEquals("Get a wrong message content.", getZippedText("poem.txt"), getBytes(file)); + assertTrue(file.exists(), "The file should exist."); + assertArrayEquals(getZippedText("poem.txt"), getBytes(file), "Get a wrong message content."); } @Test @@ -246,7 +249,7 @@ public class ZipFileDataFormatTest extends CamelTestSupport { } @Override - @Before + @BeforeEach public void setUp() throws Exception { deleteDirectory(TEST_DIR); super.setUp(); diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileIteratorDataFormatTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileIteratorDataFormatTest.java index f576429..8f75453 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileIteratorDataFormatTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileIteratorDataFormatTest.java @@ -22,8 +22,8 @@ import java.util.stream.Stream; import org.apache.camel.Exchange; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Test; +import org.apache.camel.test.junit5.CamelTestSupport; +import org.junit.jupiter.api.*; import static org.junit.jupiter.api.Assertions.*; public class ZipFileIteratorDataFormatTest extends CamelTestSupport { diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileMultipleFilesSplitterTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileMultipleFilesSplitterTest.java index fe3cf94..2120667 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileMultipleFilesSplitterTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileMultipleFilesSplitterTest.java @@ -22,7 +22,7 @@ import org.apache.camel.AggregationStrategy; import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; +import org.junit.jupiter.api.*; import static org.junit.jupiter.api.Assertions.*; public class ZipFileMultipleFilesSplitterTest extends ZipSplitterRouteTest { static final String PROCESSED_FILES_HEADER_NAME = "processedFiles"; diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileSplitAndDeleteTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileSplitAndDeleteTest.java index 27691de..62e601e 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileSplitAndDeleteTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileSplitAndDeleteTest.java @@ -27,15 +27,18 @@ import java.util.Iterator; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.NotifyBuilder; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Before; -import org.junit.Test; +import org.apache.camel.test.junit5.CamelTestSupport; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.*; + +import static org.apache.camel.test.junit5.TestSupport.deleteDirectory; +import static org.junit.jupiter.api.Assertions.assertFalse; public class ZipFileSplitAndDeleteTest extends CamelTestSupport { @Override - @Before + @BeforeEach public void setUp() throws Exception { deleteDirectory("target/testDeleteZipFileWhenUnmarshalWithDataFormat"); deleteDirectory("target/testDeleteZipFileWhenUnmarshalWithSplitter"); @@ -53,7 +56,7 @@ public class ZipFileSplitAndDeleteTest extends CamelTestSupport { notify.matchesMockWaitTime(); // the original file should have been deleted - assertFalse("File should been deleted", new File(zipFile).exists()); + assertFalse(new File(zipFile).exists(), "File should been deleted"); } @Test @@ -67,7 +70,7 @@ public class ZipFileSplitAndDeleteTest extends CamelTestSupport { notify.matchesMockWaitTime(); // the original file should have been deleted, - assertFalse("File should been deleted", new File(zipFile).exists()); + assertFalse(new File(zipFile).exists(), "File should been deleted"); } diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileSplitOneFileTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileSplitOneFileTest.java index a0d77d8..6aabea2 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileSplitOneFileTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileSplitOneFileTest.java @@ -28,14 +28,16 @@ import java.util.zip.ZipOutputStream; import org.apache.camel.Exchange; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Before; -import org.junit.Test; +import org.apache.camel.test.junit5.CamelTestSupport; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.*; + +import static org.apache.camel.test.junit5.TestSupport.deleteDirectory; public class ZipFileSplitOneFileTest extends CamelTestSupport { @Override - @Before + @BeforeEach public void setUp() throws Exception { deleteDirectory("target/zip-unmarshal"); super.setUp(); diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteIssueTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteIssueTest.java index d00ab5d..5de29ae 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteIssueTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteIssueTest.java @@ -19,14 +19,16 @@ package org.apache.camel.dataformat.zipfile; import java.io.File; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Before; -import org.junit.Test; +import org.apache.camel.test.junit5.CamelTestSupport; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.*; + +import static org.apache.camel.test.junit5.TestSupport.deleteDirectory; public class ZipSplitterRouteIssueTest extends CamelTestSupport { @Override - @Before + @BeforeEach public void setUp() throws Exception { deleteDirectory("target/zip"); super.setUp(); diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteTest.java index 571eda4..2f30f4b2 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteTest.java @@ -18,8 +18,8 @@ package org.apache.camel.dataformat.zipfile; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Test; +import org.apache.camel.test.junit5.CamelTestSupport; +import org.junit.jupiter.api.*; import static org.junit.jupiter.api.Assertions.*; public class ZipSplitterRouteTest extends CamelTestSupport { diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/AggregationStrategyWithFilenameHeaderTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/AggregationStrategyWithFilenameHeaderTest.java index ea1c703..f52dacc 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/AggregationStrategyWithFilenameHeaderTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/AggregationStrategyWithFilenameHeaderTest.java @@ -26,10 +26,13 @@ import java.util.zip.ZipFile; import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.camel.util.IOHelper; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.*; + +import static org.apache.camel.test.junit5.TestSupport.deleteDirectory; +import static org.junit.jupiter.api.Assertions.*; public class AggregationStrategyWithFilenameHeaderTest extends CamelTestSupport { @@ -37,7 +40,7 @@ public class AggregationStrategyWithFilenameHeaderTest extends CamelTestSupport private static final String TEST_DIR = "target/out_AggregationStrategyWithFilenameHeaderTest"; @Override - @Before + @BeforeEach public void setUp() throws Exception { deleteDirectory(TEST_DIR); super.setUp(); @@ -55,7 +58,7 @@ public class AggregationStrategyWithFilenameHeaderTest extends CamelTestSupport File[] files = new File(TEST_DIR).listFiles(); assertNotNull(files); - assertTrue("Should be a file in " + TEST_DIR + " directory", files.length > 0); + assertTrue(files.length > 0, "Should be a file in " + TEST_DIR + " directory"); File resultFile = files[0]; @@ -66,9 +69,9 @@ public class AggregationStrategyWithFilenameHeaderTest extends CamelTestSupport while (entries.hasMoreElements()) { fileCount++; final ZipEntry entry = entries.nextElement(); - assertTrue("Zip entry file name should be on of: " + FILE_NAMES, FILE_NAMES.contains(entry.getName())); + assertTrue(FILE_NAMES.contains(entry.getName()), "Zip entry file name should be on of: " + FILE_NAMES); } - assertEquals("Zip file should contain " + FILE_NAMES.size() + " files", FILE_NAMES.size(), fileCount); + assertEquals(FILE_NAMES.size(), fileCount, "Zip file should contain " + FILE_NAMES.size() + " files"); } finally { IOHelper.close(file); } diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/AggregationStrategyWithPreservationTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/AggregationStrategyWithPreservationTest.java index 66ebc8a..b8e1b54 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/AggregationStrategyWithPreservationTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/AggregationStrategyWithPreservationTest.java @@ -26,10 +26,13 @@ import java.util.zip.ZipInputStream; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.camel.util.IOHelper; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.*; + +import static org.apache.camel.test.junit5.TestSupport.deleteDirectory; +import static org.junit.jupiter.api.Assertions.*; public class AggregationStrategyWithPreservationTest extends CamelTestSupport { @@ -37,7 +40,7 @@ public class AggregationStrategyWithPreservationTest extends CamelTestSupport { private static final String TEST_DIR = "target/out_AggregationStrategyWithPreservationTest"; @Override - @Before + @BeforeEach public void setUp() throws Exception { deleteDirectory(TEST_DIR); super.setUp(); @@ -51,7 +54,7 @@ public class AggregationStrategyWithPreservationTest extends CamelTestSupport { File[] files = new File(TEST_DIR).listFiles(); assertNotNull(files); - assertTrue("Should be a file in " + TEST_DIR + " directory", files.length > 0); + assertTrue(files.length > 0, "Should be a file in " + TEST_DIR + " directory"); File resultFile = files[0]; Set<String> expectedZipFiles = new HashSet<>(Arrays.asList("another/hello.txt", @@ -62,14 +65,15 @@ public class AggregationStrategyWithPreservationTest extends CamelTestSupport { int fileCount = 0; for (ZipEntry ze = zin.getNextEntry(); ze != null; ze = zin.getNextEntry()) { if (!ze.isDirectory()) { - assertTrue("Found unexpected entry " + ze + " in zipfile", expectedZipFiles.remove(ze.toString())); + assertTrue(expectedZipFiles.remove(ze.toString()), "Found unexpected entry " + ze + " in zipfile"); fileCount++; } } - assertTrue(String.format("Zip file should contains %d files, got %d files", AggregationStrategyWithPreservationTest.EXPECTED_NO_FILES, fileCount), - fileCount == AggregationStrategyWithPreservationTest.EXPECTED_NO_FILES); - assertEquals("Should have found all of the zip files in the file. Remaining: " + expectedZipFiles, 0, expectedZipFiles.size()); + assertEquals(fileCount, AggregationStrategyWithPreservationTest.EXPECTED_NO_FILES, + String.format("Zip file should contains %d files, got %d files", AggregationStrategyWithPreservationTest.EXPECTED_NO_FILES, fileCount)); + assertEquals(0, expectedZipFiles.size(), + "Should have found all of the zip files in the file. Remaining: " + expectedZipFiles); } finally { IOHelper.close(zin); } diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/ZipAggregationStrategyEmptyFileTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/ZipAggregationStrategyEmptyFileTest.java index 5bb7b2d..47b5e18 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/ZipAggregationStrategyEmptyFileTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/ZipAggregationStrategyEmptyFileTest.java @@ -23,10 +23,13 @@ import java.util.zip.ZipInputStream; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.camel.util.IOHelper; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.*; + +import static org.apache.camel.test.junit5.TestSupport.deleteDirectory; +import static org.junit.jupiter.api.Assertions.*; public class ZipAggregationStrategyEmptyFileTest extends CamelTestSupport { @@ -35,7 +38,7 @@ public class ZipAggregationStrategyEmptyFileTest extends CamelTestSupport { @Override - @Before + @BeforeEach public void setUp() throws Exception { deleteDirectory("target/foo"); deleteDirectory(TEST_DIR); @@ -57,7 +60,7 @@ public class ZipAggregationStrategyEmptyFileTest extends CamelTestSupport { File[] files = new File(TEST_DIR).listFiles(); assertNotNull(files); - assertTrue("Should be a file in " + TEST_DIR + " directory", files.length > 0); + assertTrue(files.length > 0, "Should be a file in " + TEST_DIR + " directory"); File resultFile = files[0]; @@ -67,7 +70,8 @@ public class ZipAggregationStrategyEmptyFileTest extends CamelTestSupport { for (ZipEntry ze = zin.getNextEntry(); ze != null; ze = zin.getNextEntry()) { fileCount++; } - assertEquals("Zip file should contains " + ZipAggregationStrategyEmptyFileTest.EXPECTED_NO_FILES + " files", ZipAggregationStrategyEmptyFileTest.EXPECTED_NO_FILES, fileCount); + assertEquals(ZipAggregationStrategyEmptyFileTest.EXPECTED_NO_FILES, fileCount, + "Zip file should contains " + ZipAggregationStrategyEmptyFileTest.EXPECTED_NO_FILES + " files"); } finally { IOHelper.close(zin); } diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/ZipAggregationStrategyTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/ZipAggregationStrategyTest.java index a06d989..60fdbcc 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/ZipAggregationStrategyTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/ZipAggregationStrategyTest.java @@ -23,10 +23,13 @@ import java.util.zip.ZipInputStream; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.camel.util.IOHelper; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.*; + +import static org.apache.camel.test.junit5.TestSupport.deleteDirectory; +import static org.junit.jupiter.api.Assertions.*; public class ZipAggregationStrategyTest extends CamelTestSupport { @@ -34,7 +37,7 @@ public class ZipAggregationStrategyTest extends CamelTestSupport { private static final String TEST_DIR = "target/out_ZipAggregationStrategyTest"; @Override - @Before + @BeforeEach public void setUp() throws Exception { deleteDirectory(TEST_DIR); super.setUp(); @@ -50,7 +53,7 @@ public class ZipAggregationStrategyTest extends CamelTestSupport { File[] files = new File(TEST_DIR).listFiles(); assertNotNull(files); - assertTrue("Should be a file in " + TEST_DIR + " directory", files.length > 0); + assertTrue(files.length > 0, "Should be a file in " + TEST_DIR + " directory"); File resultFile = files[0]; @@ -60,7 +63,8 @@ public class ZipAggregationStrategyTest extends CamelTestSupport { for (ZipEntry ze = zin.getNextEntry(); ze != null; ze = zin.getNextEntry()) { fileCount++; } - assertEquals("Zip file should contains " + ZipAggregationStrategyTest.EXPECTED_NO_FILES + " files", ZipAggregationStrategyTest.EXPECTED_NO_FILES, fileCount); + assertEquals(ZipAggregationStrategyTest.EXPECTED_NO_FILES, fileCount, + "Zip file should contains " + ZipAggregationStrategyTest.EXPECTED_NO_FILES + " files"); } finally { IOHelper.close(zin); }
