NEU
authorKai Moritz <kai@juplo.de>
Thu, 20 Apr 2023 12:22:43 +0000 (14:22 +0200)
committerKai Moritz <kai@juplo.de>
Thu, 20 Apr 2023 12:22:43 +0000 (14:22 +0200)
src/test/java/de/juplo/kafka/chat/backend/KafkaConfigurationIT.java
src/test/java/de/juplo/kafka/chat/backend/persistence/kafka/KafkaServicesConfiguration.java

index 9692a5b..e300c0d 100644 (file)
@@ -34,7 +34,7 @@ class KafkaConfigurationIT extends AbstractConfigurationIT
   {
     UUID chatRoomId = UUID.fromString("5c73531c-6fc4-426c-adcb-afc5c140a0f7");
     int shard = shardingStrategy.selectShard(chatRoomId);
-    chatRoomTemplate.send(TOPIC, null,"{\"id\":\"5c73531c-6fc4-426c-adcb-afc5c140a0f7\",\"shard\":" + shard + ",\"name\":\"FOO\"");
+    chatRoomTemplate.send(TOPIC, null,"{ \"id\": \"5c73531c-6fc4-426c-adcb-afc5c140a0f7\", \"shard\": " + shard + ", \"name\": \"FOO\" }");
     messageTemplate.send(TOPIC,"5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"peter\", \"text\" : \"Hallo, ich heiße Peter!\" }");
     messageTemplate.send(TOPIC,"5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"ute\", \"text\" : \"Ich bin Ute...\" }");
     messageTemplate.send(TOPIC,"5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 2, \"user\" : \"peter\", \"text\" : \"Willst du mit mir gehen?\" }");
index 4576973..63f7dbf 100644 (file)
@@ -2,6 +2,7 @@ package de.juplo.kafka.chat.backend.persistence.kafka;
 
 import de.juplo.kafka.chat.backend.ChatBackendProperties;
 import de.juplo.kafka.chat.backend.domain.ChatHome;
+import de.juplo.kafka.chat.backend.domain.Message;
 import de.juplo.kafka.chat.backend.domain.ShardingStrategy;
 import de.juplo.kafka.chat.backend.persistence.KafkaLikeShardingStrategy;
 import org.apache.kafka.clients.consumer.Consumer;
@@ -89,6 +90,9 @@ public class KafkaServicesConfiguration
   JsonSerializer<ChatRoomTo> chatRoomSerializer()
   {
     JsonSerializer<ChatRoomTo> serializer = new JsonSerializer<>();
+    serializer.configure(
+        Map.of(JsonSerializer.ADD_TYPE_INFO_HEADERS, false),
+        false);
     return serializer;
   }
 
@@ -119,6 +123,12 @@ public class KafkaServicesConfiguration
   JsonDeserializer<ChatRoomTo> chatRoomDeserializer()
   {
     JsonDeserializer<ChatRoomTo> deserializer = new JsonDeserializer<>();
+    deserializer.configure(
+        Map.of(
+            JsonDeserializer.USE_TYPE_INFO_HEADERS, false,
+            JsonDeserializer.VALUE_DEFAULT_TYPE, ChatRoomTo.class,
+            JsonDeserializer.TRUSTED_PACKAGES, getClass().getPackageName()),
+        false );
     return deserializer;
   }
 
@@ -165,6 +175,9 @@ public class KafkaServicesConfiguration
   JsonSerializer<MessageTo> chatMessageSerializer()
   {
     JsonSerializer<MessageTo> serializer = new JsonSerializer<>();
+    serializer.configure(
+        Map.of(JsonSerializer.ADD_TYPE_INFO_HEADERS, false),
+        false);
     return serializer;
   }
 
@@ -195,6 +208,12 @@ public class KafkaServicesConfiguration
   JsonDeserializer<MessageTo> chatMessageDeserializer()
   {
     JsonDeserializer<MessageTo> deserializer = new JsonDeserializer<>();
+    deserializer.configure(
+        Map.of(
+            JsonDeserializer.USE_TYPE_INFO_HEADERS, false,
+            JsonDeserializer.VALUE_DEFAULT_TYPE, MessageTo.class,
+            JsonDeserializer.TRUSTED_PACKAGES, getClass().getPackageName()),
+        false );
     return deserializer;
   }