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

davsclaus 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 fa5900d8fe3 Fixed netty tests
fa5900d8fe3 is described below

commit fa5900d8fe318bba31a505f963adca1165a96015
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Fri Jan 3 20:20:20 2025 +0100

    Fixed netty tests
---
 .../camel/component/netty/MainNettyCustomCodecTest.java      | 12 ++++++++----
 .../camel/component/netty/ObjectSerializationTest.java       | 11 +++--------
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git 
a/components/camel-netty/src/test/java/org/apache/camel/component/netty/MainNettyCustomCodecTest.java
 
b/components/camel-netty/src/test/java/org/apache/camel/component/netty/MainNettyCustomCodecTest.java
index 3873dcf32e9..dedcfa42c43 100644
--- 
a/components/camel-netty/src/test/java/org/apache/camel/component/netty/MainNettyCustomCodecTest.java
+++ 
b/components/camel-netty/src/test/java/org/apache/camel/component/netty/MainNettyCustomCodecTest.java
@@ -18,13 +18,14 @@ package org.apache.camel.component.netty;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.main.Main;
-import org.junit.jupiter.api.Assertions;
+import org.apache.camel.util.ObjectHelper;
 import org.junit.jupiter.api.Test;
 
 public class MainNettyCustomCodecTest extends BaseNettyTest {
 
     // use reaadble bytes
-    private byte[] data = new byte[] { 65, 66, 67, 68, 69, 70, 71, 72, 73, 0, 
0 };
+    private byte[] data_eol = new byte[] { 65, 66, 67, 68, 69, 70, 71, 72, 73, 
0, 0 };
+    private byte[] data = new byte[] { 65, 66, 67, 68, 69, 70, 71, 72, 73 };
 
     @Test
     public void testMain() throws Exception {
@@ -42,11 +43,14 @@ public class MainNettyCustomCodecTest extends BaseNettyTest 
{
                 from(uri).to("log:input")
                         .process(e -> {
                             byte[] local = 
e.getMessage().getBody(byte[].class);
-                            Assertions.assertEquals(data, local);
+                            boolean eq = ObjectHelper.equalByteArray(data, 
local);
+                            if (!eq) {
+                                throw new IllegalArgumentException("Data 
received is not as expected");
+                            }
                         });
 
                 from("timer:once?repeatCount=1")
-                        .setBody().constant(data)
+                        .setBody().constant(data_eol) // include null 
terminator
                         .to(uri);
             }
         });
diff --git 
a/components/camel-netty/src/test/java/org/apache/camel/component/netty/ObjectSerializationTest.java
 
b/components/camel-netty/src/test/java/org/apache/camel/component/netty/ObjectSerializationTest.java
index ce79706a033..3abe03faa35 100644
--- 
a/components/camel-netty/src/test/java/org/apache/camel/component/netty/ObjectSerializationTest.java
+++ 
b/components/camel-netty/src/test/java/org/apache/camel/component/netty/ObjectSerializationTest.java
@@ -22,18 +22,17 @@ import java.util.Properties;
 import io.netty.channel.ChannelHandler;
 import io.netty.handler.codec.serialization.ClassResolvers;
 import org.apache.camel.BindToRegistry;
-import org.apache.camel.CamelExecutionException;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.netty.codec.ObjectDecoder;
 import org.apache.camel.component.netty.codec.ObjectEncoder;
 import org.apache.camel.test.AvailablePortFinder;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * Object Serialization is not allowed by default. However it can be enabled 
by adding specific encoders/decoders.
@@ -50,12 +49,8 @@ public class ObjectSerializationTest extends BaseNettyTest {
     @Test
     public void testObjectSerializationFailureByDefault() {
         Date date = new Date();
-        try {
-            
template.requestBody("netty:tcp://localhost:{{port}}?sync=true&encoders=#encoder",
 date, Date.class);
-            fail("Should have thrown exception");
-        } catch (CamelExecutionException e) {
-            // expected
-        }
+        Object o = 
template.requestBody("netty:tcp://localhost:{{port}}?sync=true&encoders=#encoder",
 date, Date.class);
+        Assertions.assertNull(o);
     }
 
     @Test

Reply via email to