This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 5e4903b2184a chore: fix SonarCloud S2699 test assertions in camel-core
5e4903b2184a is described below
commit 5e4903b2184a02c18b8dd468369ab42e24a9857c
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue Jul 21 15:14:42 2026 +0200
chore: fix SonarCloud S2699 test assertions in camel-core
Replace shallow assertDoesNotThrow wrappers with meaningful assertions
across 21 test files in core/camel-core. Specific improvements:
- FileInvalidStartingPathTest: assert endpoint directory and fileName
- FileProduceTempPrefixTest: verify file creation and content via Path API
- CustomSchemaFactoryFeatureTest: assertSame on SchemaFactory instance
- RouteMustHaveOutputOnExceptionTest: send message and verify mock:result
- AdviceWithTryCatchFinallyTest: verify mock:replaced called,
mock:replace-me not
- UUID generator tests: assert generated IDs are non-null and non-empty
- XmlConverterTest: assert converted DOM nodes are non-null
- IOHelperTest: assert copied stream content matches original
- InetAddressUtilTest: assertNotNull on hostname lookup
- RouteHealthCheckTest: assert health check state transitions
- MDCErrorHandlerTest/TraceInterceptorTest: verify mock endpoint
satisfaction
- ThreadsInvalidConfigTest/OnExceptionMisconfiguredTest: use assertThrows
- VirtualThreadsLoadTest: verify exchange count on mock endpoint
- DefaultProducerTemplateNonBlockingAsyncTest: assert future result
Drop public modifier incrementally on test classes and methods that
received substantive changes (JUnit 5 does not require public).
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* (chores): fix SonarCloud S2699 test assertions in camel-core
Add explicit assertions to 27 test methods across 22 files in
core/camel-core that were flagged by SonarCloud rule S2699
(tests should include assertions).
All flagged methods are smoke tests that verify operations
complete without throwing exceptions. The fix wraps test bodies
in assertDoesNotThrow() or adds assertTrue/assertDoesNotThrow
as appropriate.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* Address review: replace assertDoesNotThrow with meaningful assertions
- FileInvalidStartingPathTest: assert endpoint resolves and is FileEndpoint
- FileProduceTempPrefixTest: assert file is actually created in test
directory
- CustomSchemaFactoryFeatureTest: assert endpoint has custom SchemaFactory
set
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* (chores): strengthen assertions per reviewer feedback
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* (chores): fix compilation error in FileProduceTempPrefixTest
Add missing 'throws Exception' to testTempPrefixUUIDFilename() method
which calls Files.readAllBytes() that throws IOException.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* (chores): replace empty assertDoesNotThrow with @Disabled
Use @Disabled annotation instead of meaningless empty
assertDoesNotThrow(() -> {}) for intentionally disabled test override.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* (chores): replace assertDoesNotThrow wrappers with meaningful assertions
Replace weak assertDoesNotThrow wrappers with real assertions that
verify actual test behavior: output content, generated values, mock
endpoint satisfaction, context state, etc.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* Address review comments: improve test assertions
- FileInvalidStartingPathTest: assert endpoint directory and fileName
expression content
- FileProduceTempPrefixTest: use Path API, assert exactly 1 file created,
check content
- CustomSchemaFactoryFeatureTest: verify same SchemaFactory instance via
assertSame
- CamelContextDeadlockTest: revert to main (test is inherently fragile,
needs rework)
- RouteMustHaveOutputOnExceptionTest: send message and verify mock:result
is called
- AdviceWithTryCatchFinallyTest: verify mock:replaced is called,
mock:replace-me is not
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* chore: improve test assertions and drop public modifier in camel-core
- Replace assertDoesNotThrow wrappers with direct calls and meaningful
assertions (e.g., assertEquals on route count)
- Replace instanceof + assertTrue patterns with assertInstanceOf
- Drop unnecessary public modifier from test classes and test methods
(JUnit 5 does not require public visibility)
- Preserve public on @Override methods where parent requires it
- Add content assertion to IOHelper.testCopyAndCloseInput
- Add assertNotNull to InetAddressUtilTest.testGetLocalHostNameSafe
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* chore: limit public modifier removal to touched methods only
Restore the public modifier on test methods where the only change was
removing public (no assertion improvements or body changes). Per the
project rule: "only change what you are already modifying."
Methods with substantive changes (new assertions, modified assertions,
body changes) keep public removed. Class declarations also keep public
removed since the file was touched.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
---------
Co-authored-by: Claude Opus 4.6 <[email protected]>
---
.../file/FileInvalidStartingPathTest.java | 18 ++++++++--
.../component/file/FileProduceTempPrefixTest.java | 21 ++++++++++--
.../validator/CustomSchemaFactoryFeatureTest.java | 22 ++++++++++--
.../camel/converter/jaxp/XmlConverterTest.java | 7 ++--
.../camel/impl/ClassicUuidGeneratorTest.java | 18 ++++++----
...efaultProducerTemplateNonBlockingAsyncTest.java | 5 +--
.../camel/impl/DefaultUuidGeneratorTest.java | 19 ++++++----
.../apache/camel/impl/RandomUuidGeneratorTest.java | 19 ++++++----
.../impl/RouteMustHaveOutputOnExceptionTest.java | 12 +++++--
.../apache/camel/impl/ShortUuidGeneratorTest.java | 19 ++++++----
.../apache/camel/impl/SimpleUuidGeneratorTest.java | 14 +++++---
.../camel/impl/health/RouteHealthCheckTest.java | 7 ++--
.../issues/AdviceWithTryCatchFinallyTest.java | 15 ++++++--
.../java/org/apache/camel/issues/Issue3Test.java | 16 ++++++---
.../camel/processor/MDCErrorHandlerTest.java | 13 +++++--
.../camel/processor/ThreadsInvalidConfigTest.java | 40 ++++++++++------------
.../camel/processor/TraceInterceptorTest.java | 13 +++++--
.../camel/processor/VirtualThreadsLoadTest.java | 7 ++--
.../onexception/OnExceptionMisconfiguredTest.java | 25 +++++++-------
.../java/org/apache/camel/util/IOHelperTest.java | 12 ++++---
.../org/apache/camel/util/InetAddressUtilTest.java | 6 ++--
21 files changed, 229 insertions(+), 99 deletions(-)
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileInvalidStartingPathTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileInvalidStartingPathTest.java
index 506ecf0c4ef6..e6f5ec17d18b 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileInvalidStartingPathTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileInvalidStartingPathTest.java
@@ -17,13 +17,17 @@
package org.apache.camel.component.file;
import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
import org.apache.camel.ResolveEndpointFailedException;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-public class FileInvalidStartingPathTest extends ContextTestSupport {
+class FileInvalidStartingPathTest extends ContextTestSupport {
@Test
public void testInvalidStartingPath() {
@@ -35,9 +39,17 @@ public class FileInvalidStartingPathTest extends
ContextTestSupport {
}
@Test
- public void testValidStartingPath() {
- context.getEndpoint(
+ void testValidStartingPath() {
+ Endpoint endpoint = context.getEndpoint(
fileUri("?fileName=${date:now:yyyyMMdd}/${in.header.messageType}-${date:now:hhmmss}.txt"));
+ assertNotNull(endpoint, "Endpoint should be resolved for a valid
starting path");
+ FileEndpoint fileEndpoint = assertInstanceOf(FileEndpoint.class,
endpoint);
+ assertNotNull(fileEndpoint.getFileName(), "FileEndpoint should have a
fileName expression set");
+ assertNotNull(fileEndpoint.getConfiguration().getDirectory(),
+ "FileEndpoint should have a directory configured");
+
assertEquals("${date:now:yyyyMMdd}/${in.header.messageType}-${date:now:hhmmss}.txt",
+ fileEndpoint.getFileName().toString(),
+ "FileEndpoint fileName expression should match the configured
value");
}
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProduceTempPrefixTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProduceTempPrefixTest.java
index 2ddf90bf7145..5345f4325fbb 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProduceTempPrefixTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProduceTempPrefixTest.java
@@ -16,7 +16,11 @@
*/
package org.apache.camel.component.file;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
import java.util.UUID;
+import java.util.stream.Stream;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Endpoint;
@@ -24,10 +28,13 @@ import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
/**
* Unit test for file producer option tempPrefix
*/
-public class FileProduceTempPrefixTest extends ContextTestSupport {
+class FileProduceTempPrefixTest extends ContextTestSupport {
private static final String TEST_FILE_NAME_1 = "hello" + UUID.randomUUID()
+ ".txt";
private static final String TEST_FILE_NAME_2 = "claus" + UUID.randomUUID()
+ ".txt";
@@ -74,8 +81,18 @@ public class FileProduceTempPrefixTest extends
ContextTestSupport {
}
@Test
- public void testTempPrefixUUIDFilename() {
+ void testTempPrefixUUIDFilename() throws Exception {
template.sendBody("direct:a", "Bye World");
+
+ // When no FILE_NAME header is set, the producer creates a file with
an auto-generated UUID name
+ List<Path> files;
+ try (Stream<Path> stream = Files.list(testDirectory())) {
+ files = stream.toList();
+ }
+ assertNotNull(files, "Test directory should contain files");
+ assertEquals(1, files.size(), "exactly one file should have been
created");
+ String content = Files.readString(files.get(0));
+ assertEquals("Bye World", content, "File content should match the body
that was sent");
}
@Override
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/validator/CustomSchemaFactoryFeatureTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/validator/CustomSchemaFactoryFeatureTest.java
index 47f6e2713ac3..54065f95b350 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/validator/CustomSchemaFactoryFeatureTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/validator/CustomSchemaFactoryFeatureTest.java
@@ -20,10 +20,16 @@ import javax.xml.XMLConstants;
import javax.xml.validation.SchemaFactory;
import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
import org.apache.camel.spi.Registry;
import org.junit.jupiter.api.Test;
-public class CustomSchemaFactoryFeatureTest extends ContextTestSupport {
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+
+class CustomSchemaFactoryFeatureTest extends ContextTestSupport {
// Need to bind the CustomerSchemaFactory
@Override
protected Registry createCamelRegistry() throws Exception {
@@ -36,11 +42,21 @@ public class CustomSchemaFactoryFeatureTest extends
ContextTestSupport {
// just inject the SchemaFactory as we want
@Test
- public void testCustomSchemaFactory() throws Exception {
+ void testCustomSchemaFactory() throws Exception {
+ SchemaFactory registeredFactory = (SchemaFactory)
context.getRegistry().lookupByName("MySchemaFactory");
+
ValidatorComponent v = new ValidatorComponent();
v.setCamelContext(context);
v.init();
-
v.createEndpoint("validator:org/apache/camel/component/validator/unsecuredSchema.xsd?schemaFactory=#MySchemaFactory");
+ Endpoint endpoint = v.createEndpoint(
+
"validator:org/apache/camel/component/validator/unsecuredSchema.xsd?schemaFactory=#MySchemaFactory");
+ assertNotNull(endpoint, "Endpoint should be created with a custom
SchemaFactory");
+ ValidatorEndpoint ve = assertInstanceOf(ValidatorEndpoint.class,
endpoint);
+ assertNotNull(ve.getSchemaFactory(), "Endpoint should have the custom
SchemaFactory configured");
+ assertSame(registeredFactory, ve.getSchemaFactory(),
+ "Endpoint should use the same SchemaFactory instance that was
registered");
+
assertFalse(ve.getSchemaFactory().getFeature(XMLConstants.FEATURE_SECURE_PROCESSING),
+ "Custom SchemaFactory should have FEATURE_SECURE_PROCESSING
set to false");
}
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/converter/jaxp/XmlConverterTest.java
b/core/camel-core/src/test/java/org/apache/camel/converter/jaxp/XmlConverterTest.java
index c58f51dcd402..16ccef50bd4b 100644
---
a/core/camel-core/src/test/java/org/apache/camel/converter/jaxp/XmlConverterTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/converter/jaxp/XmlConverterTest.java
@@ -51,12 +51,15 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
-public class XmlConverterTest extends ContextTestSupport {
+class XmlConverterTest extends ContextTestSupport {
@Test
- public void testToResultNoSource() throws Exception {
+ void testToResultNoSource() throws Exception {
XmlConverter conv = new XmlConverter();
+ // Should handle null source gracefully (returns immediately without
transforming)
conv.toResult(null, null);
+ // Verify the converter itself is still functional after handling null
+ assertNotNull(conv.createDocument());
}
@Test
diff --git
a/core/camel-core/src/test/java/org/apache/camel/impl/ClassicUuidGeneratorTest.java
b/core/camel-core/src/test/java/org/apache/camel/impl/ClassicUuidGeneratorTest.java
index 1ed84b3378e5..9a22ca949545 100644
---
a/core/camel-core/src/test/java/org/apache/camel/impl/ClassicUuidGeneratorTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/impl/ClassicUuidGeneratorTest.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.impl;
+import java.util.HashSet;
+import java.util.Set;
+
import org.apache.camel.support.ClassicUuidGenerator;
import org.apache.camel.util.StopWatch;
import org.apache.camel.util.TimeUtils;
@@ -26,7 +29,7 @@ import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
-public class ClassicUuidGeneratorTest {
+class ClassicUuidGeneratorTest {
private static final Logger LOG =
LoggerFactory.getLogger(ClassicUuidGeneratorTest.class);
@@ -41,17 +44,20 @@ public class ClassicUuidGeneratorTest {
}
@Test
- public void testPerformance() {
+ void testPerformance() {
ClassicUuidGenerator uuidGenerator = new ClassicUuidGenerator();
StopWatch watch = new StopWatch();
+ int count = 500000;
+ Set<String> ids = new HashSet<>(count + 2);
- LOG.info("First id: {}", uuidGenerator.generateUuid());
- for (int i = 0; i < 500000; i++) {
- uuidGenerator.generateUuid();
+ ids.add(uuidGenerator.generateUuid());
+ for (int i = 0; i < count; i++) {
+ ids.add(uuidGenerator.generateUuid());
}
- LOG.info("Last id: {}", uuidGenerator.generateUuid());
+ ids.add(uuidGenerator.generateUuid());
LOG.info("Took {}", TimeUtils.printDuration(watch.taken(), true));
+ assertEquals(count + 2, ids.size(), "All generated UUIDs should be
unique");
}
@Test
diff --git
a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateNonBlockingAsyncTest.java
b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateNonBlockingAsyncTest.java
index 787802898ccd..8e714d027bb2 100644
---
a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateNonBlockingAsyncTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateNonBlockingAsyncTest.java
@@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture;
import org.apache.camel.Exchange;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
@@ -27,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
@Timeout(20)
-public class DefaultProducerTemplateNonBlockingAsyncTest extends
DefaultProducerTemplateAsyncTest {
+class DefaultProducerTemplateNonBlockingAsyncTest extends
DefaultProducerTemplateAsyncTest {
@Override
@BeforeEach
public void setUp() throws Exception {
@@ -37,10 +38,10 @@ public class DefaultProducerTemplateNonBlockingAsyncTest
extends DefaultProducer
template.start();
}
+ @Disabled("Not applicable for non-blocking async mode")
@Test
@Override
public void testSendAsyncProcessor() {
- // noop
}
@Test
diff --git
a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultUuidGeneratorTest.java
b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultUuidGeneratorTest.java
index 78a314cd8dcf..30b5f38fa3a5 100644
---
a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultUuidGeneratorTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultUuidGeneratorTest.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.impl;
+import java.util.HashSet;
+import java.util.Set;
+
import org.apache.camel.spi.UuidGenerator;
import org.apache.camel.support.DefaultUuidGenerator;
import org.apache.camel.util.StopWatch;
@@ -24,9 +27,10 @@ import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
-public class DefaultUuidGeneratorTest {
+class DefaultUuidGeneratorTest {
private static final Logger LOG =
LoggerFactory.getLogger(DefaultUuidGeneratorTest.class);
@Test
@@ -40,17 +44,20 @@ public class DefaultUuidGeneratorTest {
}
@Test
- public void testPerformance() {
+ void testPerformance() {
UuidGenerator uuidGenerator = new DefaultUuidGenerator();
StopWatch watch = new StopWatch();
+ int count = 500000;
+ Set<String> ids = new HashSet<>(count + 2);
- LOG.info("First id: {}", uuidGenerator.generateUuid());
- for (int i = 0; i < 500000; i++) {
- uuidGenerator.generateUuid();
+ ids.add(uuidGenerator.generateUuid());
+ for (int i = 0; i < count; i++) {
+ ids.add(uuidGenerator.generateUuid());
}
- LOG.info("Last id: {}", uuidGenerator.generateUuid());
+ ids.add(uuidGenerator.generateUuid());
LOG.info("Took {}", TimeUtils.printDuration(watch.taken(), true));
+ assertEquals(count + 2, ids.size(), "All generated UUIDs should be
unique");
}
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/impl/RandomUuidGeneratorTest.java
b/core/camel-core/src/test/java/org/apache/camel/impl/RandomUuidGeneratorTest.java
index db959e37a9dc..bfa8e8ef3a3f 100644
---
a/core/camel-core/src/test/java/org/apache/camel/impl/RandomUuidGeneratorTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/impl/RandomUuidGeneratorTest.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.impl;
+import java.util.HashSet;
+import java.util.Set;
+
import org.apache.camel.spi.UuidGenerator;
import org.apache.camel.support.RandomUuidGenerator;
import org.apache.camel.util.StopWatch;
@@ -24,9 +27,10 @@ import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
-public class RandomUuidGeneratorTest {
+class RandomUuidGeneratorTest {
private static final Logger LOG =
LoggerFactory.getLogger(RandomUuidGeneratorTest.class);
@Test
@@ -40,17 +44,20 @@ public class RandomUuidGeneratorTest {
}
@Test
- public void testPerformance() {
+ void testPerformance() {
UuidGenerator uuidGenerator = new RandomUuidGenerator();
StopWatch watch = new StopWatch();
+ int count = 500000;
+ Set<String> ids = new HashSet<>(count + 2);
- LOG.info("First id: {}", uuidGenerator.generateUuid());
- for (int i = 0; i < 500000; i++) {
- uuidGenerator.generateUuid();
+ ids.add(uuidGenerator.generateUuid());
+ for (int i = 0; i < count; i++) {
+ ids.add(uuidGenerator.generateUuid());
}
- LOG.info("Last id: {}", uuidGenerator.generateUuid());
+ ids.add(uuidGenerator.generateUuid());
LOG.info("Took {}", TimeUtils.printDuration(watch.taken(), true));
+ assertEquals(count + 2, ids.size(), "All generated UUIDs should be
unique");
}
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/impl/RouteMustHaveOutputOnExceptionTest.java
b/core/camel-core/src/test/java/org/apache/camel/impl/RouteMustHaveOutputOnExceptionTest.java
index 83b743dd1b21..3277c4f2680d 100644
---
a/core/camel-core/src/test/java/org/apache/camel/impl/RouteMustHaveOutputOnExceptionTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/impl/RouteMustHaveOutputOnExceptionTest.java
@@ -18,11 +18,12 @@ package org.apache.camel.impl;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;
-public class RouteMustHaveOutputOnExceptionTest extends ContextTestSupport {
+class RouteMustHaveOutputOnExceptionTest extends ContextTestSupport {
@Override
public boolean isUseRouteBuilder() {
@@ -30,7 +31,7 @@ public class RouteMustHaveOutputOnExceptionTest extends
ContextTestSupport {
}
@Test
- public void testValid() throws Exception {
+ void testValid() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
@@ -40,6 +41,13 @@ public class RouteMustHaveOutputOnExceptionTest extends
ContextTestSupport {
}
});
context.start();
+
+ MockEndpoint mockResult = getMockEndpoint("mock:result");
+ mockResult.expectedMessageCount(1);
+
+ template.sendBody("direct:start", "Hello World");
+
+ mockResult.assertIsSatisfied();
}
@Test
diff --git
a/core/camel-core/src/test/java/org/apache/camel/impl/ShortUuidGeneratorTest.java
b/core/camel-core/src/test/java/org/apache/camel/impl/ShortUuidGeneratorTest.java
index e27dcd2fcda1..e5d567a0cbeb 100644
---
a/core/camel-core/src/test/java/org/apache/camel/impl/ShortUuidGeneratorTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/impl/ShortUuidGeneratorTest.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.impl;
+import java.util.HashSet;
+import java.util.Set;
+
import org.apache.camel.spi.UuidGenerator;
import org.apache.camel.support.ShortUuidGenerator;
import org.apache.camel.util.StopWatch;
@@ -24,9 +27,10 @@ import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
-public class ShortUuidGeneratorTest {
+class ShortUuidGeneratorTest {
private static final Logger LOG =
LoggerFactory.getLogger(ShortUuidGeneratorTest.class);
@Test
@@ -40,17 +44,20 @@ public class ShortUuidGeneratorTest {
}
@Test
- public void testPerformance() {
+ void testPerformance() {
UuidGenerator uuidGenerator = new ShortUuidGenerator();
StopWatch watch = new StopWatch();
+ int count = 500000;
+ Set<String> ids = new HashSet<>(count + 2);
- LOG.info("First id: {}", uuidGenerator.generateUuid());
- for (int i = 0; i < 500000; i++) {
- uuidGenerator.generateUuid();
+ ids.add(uuidGenerator.generateUuid());
+ for (int i = 0; i < count; i++) {
+ ids.add(uuidGenerator.generateUuid());
}
- LOG.info("Last id: {}", uuidGenerator.generateUuid());
+ ids.add(uuidGenerator.generateUuid());
LOG.info("Took {}", TimeUtils.printDuration(watch.taken(), true));
+ assertEquals(count + 2, ids.size(), "All generated UUIDs should be
unique");
}
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/impl/SimpleUuidGeneratorTest.java
b/core/camel-core/src/test/java/org/apache/camel/impl/SimpleUuidGeneratorTest.java
index 380204d0998b..cc49ad28a0e4 100644
---
a/core/camel-core/src/test/java/org/apache/camel/impl/SimpleUuidGeneratorTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/impl/SimpleUuidGeneratorTest.java
@@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertEquals;
-public class SimpleUuidGeneratorTest {
+class SimpleUuidGeneratorTest {
private static final Logger LOG =
LoggerFactory.getLogger(SimpleUuidGeneratorTest.class);
@@ -38,17 +38,21 @@ public class SimpleUuidGeneratorTest {
}
@Test
- public void testPerformance() {
+ void testPerformance() {
SimpleUuidGenerator uuidGenerator = new SimpleUuidGenerator();
StopWatch watch = new StopWatch();
+ int count = 500000;
- LOG.info("First id: {}", uuidGenerator.generateUuid());
- for (int i = 0; i < 500000; i++) {
+ String first = uuidGenerator.generateUuid();
+ for (int i = 0; i < count; i++) {
uuidGenerator.generateUuid();
}
- LOG.info("Last id: {}", uuidGenerator.generateUuid());
+ String last = uuidGenerator.generateUuid();
LOG.info("Took {}", TimeUtils.printDuration(watch.taken(), true));
+ // SimpleUuidGenerator is sequential, so the last id should be count +
2
+ assertEquals(String.valueOf(count + 2), last);
+ assertEquals("1", first);
}
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/impl/health/RouteHealthCheckTest.java
b/core/camel-core/src/test/java/org/apache/camel/impl/health/RouteHealthCheckTest.java
index f3fe4c2d2c05..0b3866af0ff5 100644
---
a/core/camel-core/src/test/java/org/apache/camel/impl/health/RouteHealthCheckTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/impl/health/RouteHealthCheckTest.java
@@ -27,12 +27,12 @@ import org.apache.camel.impl.DefaultCamelContext;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-public class RouteHealthCheckTest {
+class RouteHealthCheckTest {
private static final String TEST_ROUTE_ID = "Test-Route";
@Test
- public void testDoCallDoesNotHaveNPEWhenJmxDisabled() throws Exception {
+ void testDoCallDoesNotHaveNPEWhenJmxDisabled() throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
@Override
@@ -48,6 +48,9 @@ public class RouteHealthCheckTest {
final HealthCheckResultBuilder builder =
HealthCheckResultBuilder.on(healthCheck);
healthCheck.doCall(builder, Collections.emptyMap());
+ HealthCheck.Result result = builder.build();
+
+ Assertions.assertEquals(HealthCheck.State.UP, result.getState());
context.stop();
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/issues/AdviceWithTryCatchFinallyTest.java
b/core/camel-core/src/test/java/org/apache/camel/issues/AdviceWithTryCatchFinallyTest.java
index b76b560166bf..30d525a91fcd 100644
---
a/core/camel-core/src/test/java/org/apache/camel/issues/AdviceWithTryCatchFinallyTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/issues/AdviceWithTryCatchFinallyTest.java
@@ -18,11 +18,12 @@ package org.apache.camel.issues;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
import static org.apache.camel.builder.AdviceWith.adviceWith;
-public class AdviceWithTryCatchFinallyTest extends ContextTestSupport {
+class AdviceWithTryCatchFinallyTest extends ContextTestSupport {
@Override
public boolean isUseRouteBuilder() {
@@ -30,13 +31,23 @@ public class AdviceWithTryCatchFinallyTest extends
ContextTestSupport {
}
@Test
- public void testAdviceTryCatchFinally() throws Exception {
+ void testAdviceTryCatchFinally() throws Exception {
context.addRoutes(createRouteBuilder());
adviceWith(context, "my-route", a -> a.weaveById("replace-me")
.replace().to("mock:replaced"));
context.start();
+
+ MockEndpoint mockReplaced = getMockEndpoint("mock:replaced");
+ mockReplaced.expectedMessageCount(1);
+
+ MockEndpoint mockReplaceMe = getMockEndpoint("mock:replace-me");
+ mockReplaceMe.expectedMessageCount(0);
+
+ template.sendBody("direct:start", "Hello World");
+
+ MockEndpoint.assertIsSatisfied(context);
}
@Override
diff --git
a/core/camel-core/src/test/java/org/apache/camel/issues/Issue3Test.java
b/core/camel-core/src/test/java/org/apache/camel/issues/Issue3Test.java
index 25afd3cb3118..0df8efa9690c 100644
--- a/core/camel-core/src/test/java/org/apache/camel/issues/Issue3Test.java
+++ b/core/camel-core/src/test/java/org/apache/camel/issues/Issue3Test.java
@@ -21,16 +21,24 @@ import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
-public class Issue3Test extends ContextTestSupport {
+class Issue3Test extends ContextTestSupport {
protected final String fromQueue = "direct:A";
@Test
- public void testIssue() {
+ void testIssue() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedBodiesReceived("cluster!");
+
sendBody(fromQueue, "cluster!");
+
+ MockEndpoint.assertIsSatisfied(context);
}
@Override
@@ -51,7 +59,7 @@ public class Issue3Test extends ContextTestSupport {
boolean isDebug2 = in.getHeader("someproperty",
boolean.class);
assertFalse(isDebug2);
}
- });
+ }).to("mock:result");
}
};
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/MDCErrorHandlerTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/MDCErrorHandlerTest.java
index fea33212c1a6..8020dffbd93d 100644
---
a/core/camel-core/src/test/java/org/apache/camel/processor/MDCErrorHandlerTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/MDCErrorHandlerTest.java
@@ -22,16 +22,22 @@ import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.slf4j.MDC;
@Deprecated(since = "4.19.0")
-public class MDCErrorHandlerTest extends ContextTestSupport {
+class MDCErrorHandlerTest extends ContextTestSupport {
@Test
- public void testMDC() {
+ void testMDC() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:dead");
+ mock.expectedMessageCount(1);
+
template.sendBody("direct:start", "Hello World");
+
+ MockEndpoint.assertIsSatisfied(context);
}
@Override
@@ -68,7 +74,8 @@ public class MDCErrorHandlerTest extends ContextTestSupport {
Assertions.assertEquals("dead",
m.get("camel.routeId"));
}
})
- .to("log:dead");
+ .to("log:dead")
+ .to("mock:dead");
}
};
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsInvalidConfigTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsInvalidConfigTest.java
index b0b388e2815e..6ff5dd1350ff 100644
---
a/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsInvalidConfigTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsInvalidConfigTest.java
@@ -22,15 +22,17 @@ import org.apache.camel.spi.ThreadPoolProfile;
import org.junit.jupiter.api.Test;
import static org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy.Abort;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-public class ThreadsInvalidConfigTest extends ContextTestSupport {
+class ThreadsInvalidConfigTest extends ContextTestSupport {
final ThreadPoolProfile threadPoolProfile = new ThreadPoolProfile("poll");
@Test
- public void testCreateRouteIfNoInvalidOptions() throws Exception {
+ void testCreateRouteIfNoInvalidOptions() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
@@ -38,10 +40,11 @@ public class ThreadsInvalidConfigTest extends
ContextTestSupport {
from("direct:start").threads().executorService(threadPoolProfile.getId()).to("mock:test");
}
});
+ assertEquals(1, context.getRoutes().size(), "Route should be created
when no invalid options are set");
}
@Test
- public void testFailIfThreadNameAndExecutorServiceRef() {
+ void testFailIfThreadNameAndExecutorServiceRef() {
Exception exception = assertThrows(Exception.class, () ->
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
@@ -51,13 +54,12 @@ public class ThreadsInvalidConfigTest extends
ContextTestSupport {
}
}));
- boolean b = exception.getCause() instanceof IllegalArgumentException;
- assertTrue(b);
+ assertInstanceOf(IllegalArgumentException.class, exception.getCause());
assertTrue(exception.getCause().getMessage().startsWith("ThreadName"));
}
@Test
- public void testPassIfThreadNameWithoutExecutorServiceRef() throws
Exception {
+ void testPassIfThreadNameWithoutExecutorServiceRef() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
@@ -65,10 +67,11 @@ public class ThreadsInvalidConfigTest extends
ContextTestSupport {
from("direct:start").threads().threadName("foo").to("mock:test");
}
});
+ assertEquals(1, context.getRoutes().size(), "Route should be created
with threadName and no executorServiceRef");
}
@Test
- public void testFailIfPoolSizeAndExecutorServiceRef() {
+ void testFailIfPoolSizeAndExecutorServiceRef() {
Exception exception = assertThrows(Exception.class, () ->
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
@@ -77,13 +80,12 @@ public class ThreadsInvalidConfigTest extends
ContextTestSupport {
}
}));
- boolean b = exception.getCause() instanceof IllegalArgumentException;
- assertTrue(b);
+ assertInstanceOf(IllegalArgumentException.class, exception.getCause());
assertTrue(exception.getCause().getMessage().startsWith("PoolSize"));
}
@Test
- public void testFailIfMaxPoolSizeAndExecutorServiceRef() {
+ void testFailIfMaxPoolSizeAndExecutorServiceRef() {
Exception exception = assertThrows(Exception.class, () ->
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
@@ -92,13 +94,12 @@ public class ThreadsInvalidConfigTest extends
ContextTestSupport {
}
}));
- boolean b = exception.getCause() instanceof IllegalArgumentException;
- assertTrue(b);
+ assertInstanceOf(IllegalArgumentException.class, exception.getCause());
assertTrue(exception.getCause().getMessage().startsWith("MaxPoolSize"));
}
@Test
- public void testFailIfKeepAliveTimeAndExecutorServiceRef() {
+ void testFailIfKeepAliveTimeAndExecutorServiceRef() {
Exception exception = assertThrows(Exception.class, () ->
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
@@ -108,13 +109,12 @@ public class ThreadsInvalidConfigTest extends
ContextTestSupport {
}
}));
- boolean b = exception.getCause() instanceof IllegalArgumentException;
- assertTrue(b);
+ assertInstanceOf(IllegalArgumentException.class, exception.getCause());
assertTrue(exception.getCause().getMessage().startsWith("KeepAliveTime"));
}
@Test
- public void testFailIfMaxQueueSizeAndExecutorServiceRef() {
+ void testFailIfMaxQueueSizeAndExecutorServiceRef() {
Exception exception = assertThrows(Exception.class, () ->
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
@@ -124,13 +124,12 @@ public class ThreadsInvalidConfigTest extends
ContextTestSupport {
}
}));
- boolean b = exception.getCause() instanceof IllegalArgumentException;
- assertTrue(b);
+ assertInstanceOf(IllegalArgumentException.class, exception.getCause());
assertTrue(exception.getCause().getMessage().startsWith("MaxQueueSize"));
}
@Test
- public void testFailIfRejectedPolicyAndExecutorServiceRef() {
+ void testFailIfRejectedPolicyAndExecutorServiceRef() {
Exception exception = assertThrows(Exception.class, () ->
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
@@ -140,8 +139,7 @@ public class ThreadsInvalidConfigTest extends
ContextTestSupport {
}
}));
- boolean b = exception.getCause() instanceof IllegalArgumentException;
- assertTrue(b);
+ assertInstanceOf(IllegalArgumentException.class, exception.getCause());
assertTrue(exception.getCause().getMessage().startsWith("RejectedPolicy"));
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorTest.java
index aaf474d55626..b825359d260e 100644
---
a/core/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorTest.java
@@ -20,15 +20,24 @@ import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
-public class TraceInterceptorTest extends ContextTestSupport {
+class TraceInterceptorTest extends ContextTestSupport {
// START SNIPPET: e1
@Test
- public void testSendingSomeMessages() {
+ void testSendingSomeMessages() throws Exception {
+ MockEndpoint mockFoo = getMockEndpoint("mock:foo");
+ mockFoo.expectedMessageCount(2);
+
+ MockEndpoint mockBar = getMockEndpoint("mock:bar");
+ mockBar.expectedMessageCount(2);
+
template.sendBodyAndHeader("direct:start", "Hello London", "to",
"James");
template.sendBodyAndHeader("direct:start", "This is Copenhagen
calling", "from", "Claus");
+
+ MockEndpoint.assertIsSatisfied(context);
}
@Override
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/VirtualThreadsLoadTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/VirtualThreadsLoadTest.java
index 291b2b5a6e8a..2d52f1e0f58d 100644
---
a/core/camel-core/src/test/java/org/apache/camel/processor/VirtualThreadsLoadTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/VirtualThreadsLoadTest.java
@@ -28,6 +28,7 @@ import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.util.StopWatch;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
@@ -57,7 +58,7 @@ import org.slf4j.LoggerFactory;
* </pre>
*/
@Disabled("Manual load test - run explicitly for benchmarking")
-public class VirtualThreadsLoadTest extends ContextTestSupport {
+class VirtualThreadsLoadTest extends ContextTestSupport {
private static final Logger LOG =
LoggerFactory.getLogger(VirtualThreadsLoadTest.class);
@@ -85,7 +86,7 @@ public class VirtualThreadsLoadTest extends
ContextTestSupport {
}
@Test
- public void testHighConcurrencyWithSimulatedIO() throws Exception {
+ void testHighConcurrencyWithSimulatedIO() throws Exception {
completionLatch = new CountDownLatch(TOTAL_MESSAGES);
processedCount.reset();
@@ -140,6 +141,8 @@ public class VirtualThreadsLoadTest extends
ContextTestSupport {
System.out.println("Virtual threads: " +
System.getProperty("camel.threads.virtual.enabled", "false"));
System.out.println("Thread-per-task mode: " + VIRTUAL_THREAD_PER_TASK);
System.out.println();
+
+ Assertions.assertTrue(completed, "Not all messages processed within
timeout");
}
@Override
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
index 651665dbb064..c66f547d6235 100644
---
a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionMisconfiguredTest.java
@@ -29,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.*;
/**
*
*/
-public class OnExceptionMisconfiguredTest extends ContextTestSupport {
+class OnExceptionMisconfiguredTest extends ContextTestSupport {
@Override
public boolean isUseRouteBuilder() {
@@ -131,7 +131,7 @@ public class OnExceptionMisconfiguredTest extends
ContextTestSupport {
}
@Test
- public void testOnExceptionNotMisconfigured() throws Exception {
+ void testOnExceptionNotMisconfigured() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
@@ -141,11 +141,11 @@ public class OnExceptionMisconfiguredTest extends
ContextTestSupport {
}
});
context.start();
- // okay
+ assertEquals(1, context.getRoutes().size());
}
@Test
- public void testOnExceptionNotMisconfigured2() throws Exception {
+ void testOnExceptionNotMisconfigured2() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
@@ -155,11 +155,11 @@ public class OnExceptionMisconfiguredTest extends
ContextTestSupport {
}
});
context.start();
- // okay
+ assertEquals(1, context.getRoutes().size());
}
@Test
- public void testOnExceptionNotMisconfigured3() throws Exception {
+ void testOnExceptionNotMisconfigured3() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
@@ -169,11 +169,11 @@ public class OnExceptionMisconfiguredTest extends
ContextTestSupport {
}
});
context.start();
- // okay
+ assertEquals(1, context.getRoutes().size());
}
@Test
- public void testOnExceptionNotMisconfigured4() throws Exception {
+ void testOnExceptionNotMisconfigured4() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
@@ -183,20 +183,21 @@ public class OnExceptionMisconfiguredTest extends
ContextTestSupport {
}
});
context.start();
- // okay
+ assertEquals(1, context.getRoutes().size());
}
@Test
- public void testOnExceptionNotMisconfigured5() throws Exception {
+ void testOnExceptionNotMisconfigured5() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
-
from("direct:start").onException(SOAPException.class).onException(IOException.class).to("mock:error").end()
+
from("direct:start").onException(SOAPException.class).onException(IOException.class).to("mock:error")
+ .end()
.to("mock:result");
}
});
context.start();
- // okay
+ assertEquals(1, context.getRoutes().size());
}
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/util/IOHelperTest.java
b/core/camel-core/src/test/java/org/apache/camel/util/IOHelperTest.java
index d30f034b6e45..f55ae1f5173d 100644
--- a/core/camel-core/src/test/java/org/apache/camel/util/IOHelperTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/util/IOHelperTest.java
@@ -21,7 +21,6 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
import java.io.PrintWriter;
import java.nio.charset.Charset;
import java.nio.file.Files;
@@ -33,9 +32,11 @@ import org.apache.camel.support.DefaultExchange;
import org.apache.camel.support.ExchangeHelper;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNull;
-public class IOHelperTest {
+class IOHelperTest {
@Test
public void testIOException() {
@@ -52,10 +53,11 @@ public class IOHelperTest {
}
@Test
- public void testCopyAndCloseInput() throws Exception {
+ void testCopyAndCloseInput() throws Exception {
InputStream is = new ByteArrayInputStream("Hello".getBytes());
- OutputStream os = new ByteArrayOutputStream();
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
IOHelper.copyAndCloseInput(is, os, 256);
+ assertEquals("Hello", os.toString());
}
@Test
diff --git
a/core/camel-core/src/test/java/org/apache/camel/util/InetAddressUtilTest.java
b/core/camel-core/src/test/java/org/apache/camel/util/InetAddressUtilTest.java
index 86549097dcb5..c8dc03f2216a 100644
---
a/core/camel-core/src/test/java/org/apache/camel/util/InetAddressUtilTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/util/InetAddressUtilTest.java
@@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class InetAddressUtilTest {
+class InetAddressUtilTest {
@Test
public void testGetLocalHostName() {
@@ -35,7 +35,7 @@ public class InetAddressUtilTest {
}
@Test
- public void testGetLocalHostNameSafe() {
- InetAddressUtil.getLocalHostNameSafe();
+ void testGetLocalHostNameSafe() {
+ assertNotNull(InetAddressUtil.getLocalHostNameSafe());
}
}