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 2022/12/08 05:32:43 UTC
[camel-spring-boot] branch main updated: Fixed Flaky Tests Caused by JSON permutations (#681)
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-spring-boot.git
The following commit(s) were added to refs/heads/main by this push:
new fcd90533408 Fixed Flaky Tests Caused by JSON permutations (#681)
fcd90533408 is described below
commit fcd905334084f4341a7f65ce89e5b4e9b831f245
Author: Bharati Kulkarni <31...@users.noreply.github.com>
AuthorDate: Wed Dec 7 23:32:38 2022 -0600
Fixed Flaky Tests Caused by JSON permutations (#681)
* Fix Flaky Test
* Updated Imports
---
.../camel/component/gson/springboot/GsonFieldNamePolicyTest.java | 6 ++++--
.../camel/component/gson/springboot/GsonMarshalExclusionTest.java | 6 +++++-
.../component/gson/springboot/SpringGsonFieldNamePolicyTest.java | 6 ++++--
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/GsonFieldNamePolicyTest.java b/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/GsonFieldNamePolicyTest.java
index 64a0cc5b148..4d031399f0b 100644
--- a/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/GsonFieldNamePolicyTest.java
+++ b/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/GsonFieldNamePolicyTest.java
@@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -72,9 +73,10 @@ public class GsonFieldNamePolicyTest {
pojo.setFirstName("Donald");
pojo.setLastName("Duck");
- String expected = "{\"id\":123,\"first_name\":\"Donald\",\"last_name\":\"Duck\"}";
String json = template.requestBody("direct:inPojo", pojo, String.class);
- assertEquals(expected, json);
+ assertTrue(json.contains("\"id\":123"));
+ assertTrue(json.contains("\"first_name\":\"Donald\""));
+ assertTrue(json.contains("\"last_name\":\"Duck\""));
}
// *************************************
diff --git a/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/GsonMarshalExclusionTest.java b/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/GsonMarshalExclusionTest.java
index 210c86786ac..9cffc3ec06f 100644
--- a/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/GsonMarshalExclusionTest.java
+++ b/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/GsonMarshalExclusionTest.java
@@ -32,6 +32,8 @@ import org.apache.camel.spring.boot.CamelAutoConfiguration;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -95,7 +97,9 @@ public class GsonMarshalExclusionTest {
Object marshalled = template.requestBody("direct:inPojoExcludeAge", in);
String marshalledAsString = context.getTypeConverter().convertTo(String.class, marshalled);
- assertEquals("{\"height\":190,\"weight\":70}", marshalledAsString);
+ assertTrue(marshalledAsString.contains("\"height\":190"));
+ assertTrue(marshalledAsString.contains("\"weight\":70"));
+ assertFalse(marshalledAsString.contains("\"age\":30"));
template.sendBody("direct:backPojoExcludeAge", marshalled);
diff --git a/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/SpringGsonFieldNamePolicyTest.java b/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/SpringGsonFieldNamePolicyTest.java
index 901175ac57e..e4e56d6eaed 100644
--- a/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/SpringGsonFieldNamePolicyTest.java
+++ b/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/SpringGsonFieldNamePolicyTest.java
@@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -82,8 +83,9 @@ public class SpringGsonFieldNamePolicyTest {
pojo.setFirstName("Donald");
pojo.setLastName("Duck");
- String expected = "{\"id\":123,\"first_name\":\"Donald\",\"last_name\":\"Duck\"}";
String json = template.requestBody("direct:inPojo", pojo, String.class);
- assertEquals(expected, json);
+ assertTrue(json.contains("\"id\":123"));
+ assertTrue(json.contains("\"first_name\":\"Donald\""));
+ assertTrue(json.contains("\"last_name\":\"Duck\""));
}
}