davsclaus commented on code in PR #26937:
URL: https://github.com/apache/camel/pull/26937#discussion_r4137626924
##########
components/camel-jackson3/src/test/java/org/apache/camel/component/jackson3/JacksonFeaturesTest.java:
##########
@@ -23,14 +23,77 @@
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit6.CamelTestSupport;
import org.junit.jupiter.api.Test;
+import tools.jackson.core.StreamReadFeature;
import tools.jackson.core.StreamWriteFeature;
import tools.jackson.databind.DeserializationFeature;
import tools.jackson.databind.MapperFeature;
import tools.jackson.databind.SerializationFeature;
import tools.jackson.databind.cfg.DateTimeFeature;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
public class JacksonFeaturesTest extends CamelTestSupport {
+ @Test
+ public void testEnableWrongSyntaxOfFeature() throws Exception {
+ JacksonDataFormat format = new JacksonDataFormat();
+ format.setEnableFeatures("Package.Enum.FEATURE");
+ format.setCamelContext(context());
+ IllegalArgumentException ex =
assertThrows(IllegalArgumentException.class, () -> format.doStart());
+ assertEquals("Enable feature: Package.Enum.FEATURE cannot contain more
than one '.'", ex.getMessage());
+ }
+
+ @Test
+ public void testEnableWrongTypedFeatureWithClassName() throws Exception {
+ JacksonDataFormat format = new JacksonDataFormat();
+ format.setEnableFeatures("Enum.FEATURE");
+ format.setCamelContext(context());
+ IllegalArgumentException ex =
assertThrows(IllegalArgumentException.class, () -> format.doStart());
+ assertEquals(
+ "Enable feature: Enum.FEATURE cannot be converted to an
accepted enum of types
[SerializationFeature,DeserializationFeature,MapperFeature,DateTimeFeature,EnumFeature,JsonNodeFeature,StreamReadFeature,StreamWriteFeature]",
+ ex.getMessage());
+ }
+
+ @Test
+ public void testEnableWrongTypedFeatureWithoutClassName() throws Exception
{
+ JacksonDataFormat format = new JacksonDataFormat();
+ format.setEnableFeatures("FEATURE");
+ format.setCamelContext(context());
+ IllegalArgumentException ex =
assertThrows(IllegalArgumentException.class, () -> format.doStart());
+ assertEquals(
+ "Enable feature: FEATURE cannot be converted to an accepted
enum of types
[SerializationFeature,DeserializationFeature,MapperFeature,DateTimeFeature,EnumFeature,JsonNodeFeature,StreamReadFeature,StreamWriteFeature]",
+ ex.getMessage());
+ }
+
+ @Test
+ public void testEnableStrictDuplicateDetectionFromDifferentFeatures()
throws Exception {
+ // Initialization by implementation order (StreamReadFeature before
StreamWriteFeature)
+ JacksonDataFormat format1 = new JacksonDataFormat();
+ format1.setEnableFeatures("STRICT_DUPLICATE_DETECTION");
+ format1.setCamelContext(context());
+ format1.doStart();
+
assertTrue(format1.getObjectMapper().isEnabled(StreamReadFeature.STRICT_DUPLICATE_DETECTION));
+
assertFalse(format1.getObjectMapper().isEnabled(StreamWriteFeature.STRICT_DUPLICATE_DETECTION));
+
+ // Explizit declaration of implementing feature set
Review Comment:
Tiny nit, only if you touch the file again:
```suggestion
// Explicit declaration of implementing feature set
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]