This is an automated email from the ASF dual-hosted git repository.
orpiske 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 d1569d2 (chores) test cleanups
d1569d2 is described below
commit d1569d288accf5a50f8ec933ab4267624ad38e31
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Thu Nov 25 07:28:25 2021 +0100
(chores) test cleanups
- camel-cxf: fixed incorrect assertion order
- camel-ignite: chained assertions
- camel-quartz: fixed incorrect assertion
- camel-core: cleaned up assertions
- camel-microprofile: cleaned up assertions
- camel-resilience4j: cleaned up assertions
- camel-core: cleaned up assertions
- camel-core: cleaned up assertions
- camel-jms: fixed comparison of dissimilar types
- camel-ignite: completed missing assertions
- camel-ignite: simplified assertions
---
.../component/cxf/jaxrs/CxfRsAsyncProducerTest.java | 2 +-
.../camel/component/ignite/IgniteComputeTest.java | 6 ++----
.../camel/component/ignite/IgniteIdGenTest.java | 6 +++---
.../camel/component/ignite/IgniteQueueTest.java | 8 ++++----
.../component/jms/JmsEndpointConfigurationTest.java | 7 ++++---
.../FaultToleranceRouteFallbackViaNetworkTest.java | 17 ++++++++---------
.../camel/component/quartz/QuartzStopRouteTest.java | 3 +--
.../ResilienceRouteFallbackViaNetworkTest.java | 17 ++++++++---------
.../apache/camel/builder/PredicateBuilderTest.java | 9 +--------
.../camel/component/xslt/InvalidXsltFileTest.java | 19 +++++++------------
.../component/xslt/XsltCustomErrorListenerTest.java | 17 ++++++-----------
.../camel/component/xslt/XsltFileNotFoundTest.java | 21 +++++++++------------
12 files changed, 54 insertions(+), 78 deletions(-)
diff --git
a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsAsyncProducerTest.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsAsyncProducerTest.java
index 33faf52..f1fbb77 100644
---
a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsAsyncProducerTest.java
+++
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsAsyncProducerTest.java
@@ -378,7 +378,7 @@ public class CxfRsAsyncProducerTest extends
CamelSpringTestSupport {
// get the response message
Customer response = (Customer) exchange.getMessage().getBody();
assertNotNull(response, "The response should not be null");
- assertNotEquals(response.getId(), 8888, "Get a wrong customer id");
+ assertNotEquals(8888, response.getId(), "Get a wrong customer id");
assertEquals("Willem", response.getName(), "Get a wrong customer
name");
assertEquals(201,
exchange.getMessage().getHeader(Exchange.HTTP_RESPONSE_CODE), "Get a wrong
response code");
}
diff --git
a/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteComputeTest.java
b/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteComputeTest.java
index 443efa5..6d659d6 100644
---
a/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteComputeTest.java
+++
b/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteComputeTest.java
@@ -139,15 +139,13 @@ public class IgniteComputeTest extends AbstractIgniteTest
{
Collection<String> colResult = template.requestBody("ignite-compute:"
+ resourceUid + "?executionType=BROADCAST",
TestIgniteComputeResources.TEST_CALLABLE,
Collection.class);
- Assertions.assertThat(colResult).isNotNull();
- Assertions.assertThat(colResult).containsExactly("hello", "hello",
"hello");
+ Assertions.assertThat(colResult).isNotNull().containsExactly("hello",
"hello", "hello");
// Single Closure.
colResult = template.requestBodyAndHeader("ignite-compute:" +
resourceUid + "?executionType=BROADCAST",
TestIgniteComputeResources.TEST_CLOSURE,
IgniteConstants.IGNITE_COMPUTE_PARAMS, "Camel",
Collection.class);
- Assertions.assertThat(colResult).isNotNull();
- Assertions.assertThat(colResult).containsExactly("hello Camel", "hello
Camel", "hello Camel");
+ Assertions.assertThat(colResult).isNotNull().containsExactly("hello
Camel", "hello Camel", "hello Camel");
}
@Test
diff --git
a/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteIdGenTest.java
b/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteIdGenTest.java
index abf851d..bb01a39 100644
---
a/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteIdGenTest.java
+++
b/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteIdGenTest.java
@@ -43,10 +43,10 @@ public class IgniteIdGenTest extends AbstractIgniteTest {
Assertions
.assertThat(
template.requestBody("ignite-idgen:" + resourceUid +
"?initialValue=0&operation=GET", null, Long.class))
- .isEqualTo(0);
+ .isZero();
Assertions.assertThat(template
.requestBody("ignite-idgen:" + resourceUid +
"?initialValue=0&operation=GET_AND_INCREMENT", null, Long.class))
- .isEqualTo(0);
+ .isZero();
Assertions.assertThat(template
.requestBody("ignite-idgen:" + resourceUid +
"?initialValue=0&operation=INCREMENT_AND_GET", null, Long.class))
.isEqualTo(2);
@@ -108,7 +108,7 @@ public class IgniteIdGenTest extends AbstractIgniteTest {
// Cannot test much here with a single Ignite instance, let's just test
// that the parameter could be set.
- Assertions.assertThat(endpoint.getBatchSize());
+ Assertions.assertThat(endpoint.getBatchSize()).isEqualTo(100);
}
@AfterEach
diff --git
a/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteQueueTest.java
b/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteQueueTest.java
index 2cb4385..2b3ef66 100644
---
a/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteQueueTest.java
+++
b/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteQueueTest.java
@@ -109,12 +109,12 @@ public class IgniteQueueTest extends AbstractIgniteTest {
// CLEAR
Object result = template.requestBody("ignite-queue:" + resourceUid +
"?operation=CLEAR", "hello", String.class);
Assertions.assertThat(result).isEqualTo("hello");
- Assertions.assertThat(ignite().queue(resourceUid, 0, new
CollectionConfiguration()).size()).isEqualTo(0);
+ Assertions.assertThat(ignite().queue(resourceUid, 0, new
CollectionConfiguration()).size()).isZero();
// SIZE
size = template.requestBody("ignite-queue:" + resourceUid +
"?operation=SIZE", "hello", int.class);
- Assertions.assertThat(size).isEqualTo(0);
- Assertions.assertThat(ignite().queue(resourceUid, 0, new
CollectionConfiguration()).size()).isEqualTo(0);
+ Assertions.assertThat(size).isZero();
+ Assertions.assertThat(ignite().queue(resourceUid, 0, new
CollectionConfiguration()).size()).isZero();
}
@Test
@@ -240,7 +240,7 @@ public class IgniteQueueTest extends AbstractIgniteTest {
Assertions
.assertThat(
template.requestBody("ignite-queue:" + resourceUid +
"?operation=SIZE&capacity=100", null, int.class))
- .isEqualTo(0);
+ .isZero();
Assertions.assertThat(
template.requestBody("ignite-queue:" + resourceUid +
"?operation=POLL&capacity=100", null, String.class))
.isNull();
diff --git
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
index a9cf4fe..3cd63b4 100644
---
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
+++
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
@@ -42,6 +42,7 @@ import
org.springframework.jms.support.converter.SimpleMessageConverter;
import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -336,9 +337,9 @@ public class JmsEndpointConfigurationTest extends
CamelTestSupport {
assertEquals(0, endpoint.getMaxConcurrentConsumers());
assertEquals(-1, endpoint.getMaxMessagesPerTask());
assertNull(endpoint.getMessageConverter());
- assertNotNull(endpoint.getPriority());
- assertNotNull(endpoint.getReceiveTimeout());
- assertNotNull(endpoint.getRecoveryInterval());
+ assertNotEquals(0, endpoint.getPriority());
+ assertNotEquals(0, endpoint.getReceiveTimeout());
+ assertNotEquals(0, endpoint.getRecoveryInterval());
assertNull(endpoint.getReplyTo());
assertNull(endpoint.getReplyToType());
assertNull(endpoint.getReplyToCacheLevelName());
diff --git
a/components/camel-microprofile/camel-microprofile-fault-tolerance/src/test/java/org/apache/camel/component/microprofile/faulttolerance/FaultToleranceRouteFallbackViaNetworkTest.java
b/components/camel-microprofile/camel-microprofile-fault-tolerance/src/test/java/org/apache/camel/component/microprofile/faulttolerance/FaultToleranceRouteFallbackViaNetworkTest.java
index c9c9c68..e2e0750 100644
---
a/components/camel-microprofile/camel-microprofile-fault-tolerance/src/test/java/org/apache/camel/component/microprofile/faulttolerance/FaultToleranceRouteFallbackViaNetworkTest.java
+++
b/components/camel-microprofile/camel-microprofile-fault-tolerance/src/test/java/org/apache/camel/component/microprofile/faulttolerance/FaultToleranceRouteFallbackViaNetworkTest.java
@@ -16,13 +16,14 @@
*/
package org.apache.camel.component.microprofile.faulttolerance;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class FaultToleranceRouteFallbackViaNetworkTest extends
CamelTestSupport {
@@ -33,14 +34,12 @@ public class FaultToleranceRouteFallbackViaNetworkTest
extends CamelTestSupport
@Test
public void testFaultTolerance() throws Exception {
- try {
- context.addRoutes(createRouteBuilder());
- context.start();
- fail("Should throw exception");
- } catch (Exception e) {
- assertIsInstanceOf(UnsupportedOperationException.class,
e.getCause());
- assertEquals("camel-microprofile-fault-tolerance does not support
onFallbackViaNetwork", e.getCause().getMessage());
- }
+ context.addRoutes(createRouteBuilder());
+
+ RuntimeCamelException exception =
assertThrows(RuntimeCamelException.class, () -> context.start());
+ assertIsInstanceOf(UnsupportedOperationException.class,
exception.getCause());
+ assertEquals("camel-microprofile-fault-tolerance does not support
onFallbackViaNetwork",
+ exception.getCause().getMessage());
}
@Override
diff --git
a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzStopRouteTest.java
b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzStopRouteTest.java
index f769c5c..2f44649 100644
---
a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzStopRouteTest.java
+++
b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzStopRouteTest.java
@@ -34,14 +34,13 @@ public class QuartzStopRouteTest extends BaseQuartzTest {
context.getRouteController().stopRoute("foo");
int size = mock.getReceivedCounter();
+ assertEquals(1, size, "Should not schedule when stopped");
resetMocks();
mock.expectedMessageCount(0);
mock.assertIsSatisfied(3000);
- assertEquals(size, size, "Should not schedule when stopped");
-
resetMocks();
mock.expectedMinimumMessageCount(1);
diff --git
a/components/camel-resilience4j/src/test/java/org/apache/camel/component/resilience4j/ResilienceRouteFallbackViaNetworkTest.java
b/components/camel-resilience4j/src/test/java/org/apache/camel/component/resilience4j/ResilienceRouteFallbackViaNetworkTest.java
index 3bbf404..e5260d7 100644
---
a/components/camel-resilience4j/src/test/java/org/apache/camel/component/resilience4j/ResilienceRouteFallbackViaNetworkTest.java
+++
b/components/camel-resilience4j/src/test/java/org/apache/camel/component/resilience4j/ResilienceRouteFallbackViaNetworkTest.java
@@ -16,13 +16,14 @@
*/
package org.apache.camel.component.resilience4j;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class ResilienceRouteFallbackViaNetworkTest extends CamelTestSupport {
@@ -33,14 +34,12 @@ public class ResilienceRouteFallbackViaNetworkTest extends
CamelTestSupport {
@Test
public void testResilience() throws Exception {
- try {
- context.addRoutes(createRouteBuilder());
- context.start();
- fail("Should throw exception");
- } catch (Exception e) {
- assertIsInstanceOf(UnsupportedOperationException.class,
e.getCause());
- assertEquals("camel-resilience4j does not support
onFallbackViaNetwork", e.getCause().getMessage());
- }
+ context.addRoutes(createRouteBuilder());
+
+ RuntimeCamelException exception =
assertThrows(RuntimeCamelException.class, () -> context.start());
+ assertIsInstanceOf(UnsupportedOperationException.class,
exception.getCause());
+ assertEquals("camel-resilience4j does not support
onFallbackViaNetwork",
+ exception.getCause().getMessage());
}
@Override
diff --git
a/core/camel-core/src/test/java/org/apache/camel/builder/PredicateBuilderTest.java
b/core/camel-core/src/test/java/org/apache/camel/builder/PredicateBuilderTest.java
index 08c6fb0..f8f1f78 100644
---
a/core/camel-core/src/test/java/org/apache/camel/builder/PredicateBuilderTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/builder/PredicateBuilderTest.java
@@ -30,7 +30,6 @@ import org.junit.jupiter.api.Test;
import static org.apache.camel.builder.Builder.constant;
import static org.apache.camel.builder.PredicateBuilder.in;
import static org.apache.camel.builder.PredicateBuilder.not;
-import static org.junit.jupiter.api.Assertions.fail;
public class PredicateBuilderTest extends TestSupport {
@@ -171,13 +170,7 @@ public class PredicateBuilderTest extends TestSupport {
assertMatches(body().not().isInstanceOf(Integer.class));
assertMatches(header("name").not().isEqualTo("Claus"));
assertMatches(header("size").not().isLessThan(7));
-
- try {
- assertMatches(header("name").not().isEqualTo("James"));
- fail("Should fail");
- } catch (AssertionError e) {
- // expected
- }
+ assertDoesNotMatch(header("name").not().isEqualTo("James"));
}
@Override
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java
index 3b8026a..f4cb210 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/xslt/InvalidXsltFileTest.java
@@ -19,12 +19,13 @@ package org.apache.camel.component.xslt;
import javax.xml.transform.TransformerConfigurationException;
import org.apache.camel.CamelContext;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.TestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
*
@@ -33,17 +34,11 @@ public class InvalidXsltFileTest extends TestSupport {
@Test
public void testInvalidStylesheet() throws Exception {
- try {
- RouteBuilder builder = createRouteBuilder();
- CamelContext context = new DefaultCamelContext();
- context.addRoutes(builder);
- context.start();
-
- fail("Should have thrown an exception due XSL compilation error");
- } catch (Exception e) {
- // expected
- assertIsInstanceOf(TransformerConfigurationException.class,
e.getCause().getCause().getCause());
- }
+ RouteBuilder builder = createRouteBuilder();
+ CamelContext context = new DefaultCamelContext();
+ context.addRoutes(builder);
+ RuntimeCamelException exception =
assertThrows(RuntimeCamelException.class, () -> context.start());
+ assertIsInstanceOf(TransformerConfigurationException.class,
exception.getCause().getCause().getCause());
}
protected RouteBuilder createRouteBuilder() throws Exception {
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltCustomErrorListenerTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltCustomErrorListenerTest.java
index 759388a..2faddcc 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltCustomErrorListenerTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltCustomErrorListenerTest.java
@@ -20,6 +20,7 @@ import javax.xml.transform.ErrorListener;
import javax.xml.transform.TransformerException;
import org.apache.camel.CamelContext;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.TestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
@@ -70,17 +71,11 @@ public class XsltCustomErrorListenerTest extends
TestSupport {
@Test
public void testErrorListener() throws Exception {
- try {
- RouteBuilder builder = createRouteBuilder();
- CamelContext context = new DefaultCamelContext();
- context.getRegistry().bind("myListener", listener);
- context.addRoutes(builder);
- context.start();
-
- fail("Should have thrown an exception due XSLT file not found");
- } catch (Exception e) {
- // expected
- }
+ RouteBuilder builder = createRouteBuilder();
+ CamelContext context = new DefaultCamelContext();
+ context.getRegistry().bind("myListener", listener);
+ context.addRoutes(builder);
+ assertThrows(RuntimeCamelException.class, () -> context.start());
assertFalse(listener.isWarning());
assertTrue(listener.isError(), "My error listener should been
invoked");
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java
index 6d01c51..863f14b 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFileNotFoundTest.java
@@ -21,12 +21,13 @@ import java.io.FileNotFoundException;
import javax.xml.transform.TransformerException;
import org.apache.camel.CamelContext;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.TestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
*
@@ -35,17 +36,13 @@ public class XsltFileNotFoundTest extends TestSupport {
@Test
public void testNoXsltFile() throws Exception {
- try {
- RouteBuilder builder = createRouteBuilder();
- CamelContext context = new DefaultCamelContext();
- context.addRoutes(builder);
- context.start();
-
- fail("Should have thrown an exception due XSLT file not found");
- } catch (Exception e) {
- assertIsInstanceOf(TransformerException.class,
e.getCause().getCause().getCause());
- assertIsInstanceOf(FileNotFoundException.class,
e.getCause().getCause().getCause().getCause());
- }
+ RouteBuilder builder = createRouteBuilder();
+ CamelContext context = new DefaultCamelContext();
+ context.addRoutes(builder);
+ RuntimeCamelException exception =
assertThrows(RuntimeCamelException.class, () -> context.start());
+
+ assertIsInstanceOf(TransformerException.class,
exception.getCause().getCause().getCause());
+ assertIsInstanceOf(FileNotFoundException.class,
exception.getCause().getCause().getCause().getCause());
}
protected RouteBuilder createRouteBuilder() throws Exception {