You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/08/21 12:29:01 UTC

[camel] branch master updated: Fix incorrect and/or unusual test assertions (#4112)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new a6ef45b  Fix incorrect and/or unusual test assertions (#4112)
a6ef45b is described below

commit a6ef45b68175e9bbc45d9f598d1130caeba72744
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Fri Aug 21 14:24:57 2020 +0200

    Fix incorrect and/or unusual test assertions (#4112)
---
 .../apache/camel/component/activemq/ComplexRequestReplyTest.java    | 4 ++--
 .../java/org/apache/camel/component/cxf/DefaultCxfBindingTest.java  | 4 ++--
 .../apache/camel/component/thrift/ThriftConsumerConcurrentTest.java | 6 +++---
 .../org/apache/camel/component/twitter/UserProducerInOutTest.java   | 3 ++-
 .../camel/builder/ProxyBuilderSkipJavaLangObjectMethodsTest.java    | 2 +-
 5 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/ComplexRequestReplyTest.java b/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/ComplexRequestReplyTest.java
index bcab3c8..ac6f21e 100644
--- a/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/ComplexRequestReplyTest.java
+++ b/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/ComplexRequestReplyTest.java
@@ -83,7 +83,7 @@ public class ComplexRequestReplyTest {
         ProducerTemplate requester = senderContext.createProducerTemplate();
         LOG.info("*** Sending Request 1");
         String response = (String) requester.requestBody(fromEndpoint, "This is a request");
-        assertNotNull(response != null);
+        assertNotNull(response);
         LOG.info("Got response: " + response);
 
         /**
@@ -104,7 +104,7 @@ public class ComplexRequestReplyTest {
 
         LOG.info("*** Sending Request 2");
         response = (String) requester.requestBody(fromEndpoint, "This is a request");
-        assertNotNull(response != null);
+        assertNotNull(response);
         LOG.info("Got response: " + response);
     }
 
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/DefaultCxfBindingTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/DefaultCxfBindingTest.java
index 5477d99..3b41c74 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/DefaultCxfBindingTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/DefaultCxfBindingTest.java
@@ -189,7 +189,7 @@ public class DefaultCxfBindingTest {
         Set<Attachment> attachments
                 = CastUtils.cast((Set<?>) requestContext.get(CxfConstants.CAMEL_CXF_ATTACHMENTS));
         assertNotNull(attachments);
-        assertNotNull(attachments.size() == 1);
+        assertEquals(1, attachments.size());
         Attachment att = attachments.iterator().next();
         assertEquals("att-1", att.getId());
         assertEquals("value 1", att.getHeader("attachment-header"));
@@ -327,7 +327,7 @@ public class DefaultCxfBindingTest {
 
         Collection<Attachment> attachments = cxfMessage.getAttachments();
         assertNotNull(attachments);
-        assertNotNull(attachments.size() == 1);
+        assertEquals(1, attachments.size());
         Attachment att = attachments.iterator().next();
         assertEquals("att-1", att.getId());
         assertEquals("value 1", att.getHeader("attachment-header"));
diff --git a/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftConsumerConcurrentTest.java b/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftConsumerConcurrentTest.java
index e9aa61b..b0fe106 100644
--- a/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftConsumerConcurrentTest.java
+++ b/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftConsumerConcurrentTest.java
@@ -45,7 +45,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
 public class ThriftConsumerConcurrentTest extends CamelTestSupport {
     private static final Logger LOG = LoggerFactory.getLogger(ThriftConsumerConcurrentTest.class);
@@ -86,7 +86,7 @@ public class ThriftConsumerConcurrentTest extends CamelTestSupport {
                     LOG.info("Exception", e);
                 }
 
-                assertNotNull(calculateResponse, "instanceId = " + instanceId);
+                assertNotEquals(0, calculateResponse, "instanceId = " + instanceId);
                 assertEquals(instanceId * THRIFT_TEST_NUM1, calculateResponse);
 
                 transport.close();
@@ -120,7 +120,7 @@ public class ThriftConsumerConcurrentTest extends CamelTestSupport {
                 latch.await(5, TimeUnit.SECONDS);
 
                 int calculateResponse = calculateCallback.getCalculateResponse();
-                assertNotNull(calculateResponse, "instanceId = " + instanceId);
+                LOG.debug("instanceId = {}", instanceId);
                 assertEquals(instanceId * THRIFT_TEST_NUM1, calculateResponse);
 
                 transport.close();
diff --git a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/UserProducerInOutTest.java b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/UserProducerInOutTest.java
index 59089e2..98d3c40 100644
--- a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/UserProducerInOutTest.java
+++ b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/UserProducerInOutTest.java
@@ -31,6 +31,7 @@ import twitter4j.Status;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 /**
@@ -64,7 +65,7 @@ public class UserProducerInOutTest extends CamelTwitterTestSupport {
         Status receivedTweet = tweets.get(0).getIn().getBody(Status.class);
         assertNotNull(receivedTweet);
         // The identifier for the published tweet should be there
-        assertNotNull(receivedTweet.getId());
+        assertNotEquals(0, receivedTweet.getId());
     }
 
     @Override
diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/ProxyBuilderSkipJavaLangObjectMethodsTest.java b/core/camel-core/src/test/java/org/apache/camel/builder/ProxyBuilderSkipJavaLangObjectMethodsTest.java
index 560b950..3fbd5eb 100644
--- a/core/camel-core/src/test/java/org/apache/camel/builder/ProxyBuilderSkipJavaLangObjectMethodsTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/builder/ProxyBuilderSkipJavaLangObjectMethodsTest.java
@@ -36,7 +36,7 @@ public class ProxyBuilderSkipJavaLangObjectMethodsTest extends ContextTestSuppor
         assertEquals("Hello Camel", out);
 
         // these methods should not be proxied as they are from java.lang.Object
-        assertNotNull(foo.hashCode());
+        assertNotEquals(0, foo.hashCode());
         assertNotNull(foo.toString());
         assertFalse(foo.equals(null));