Skip to content

Commit

Permalink
Add jackson integration test - minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
stataru8 committed Sep 27, 2024
1 parent 1bd8206 commit 32729d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.apache.karaf.camel.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.RouteDefinition;
Expand All @@ -26,7 +27,7 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;

@Component(
name = "karaf-camel-jackson-test",
Expand Down Expand Up @@ -86,7 +87,7 @@ protected void configureProducer(RouteBuilder builder, RouteDefinition producerR
.process(ex -> {
MyData data = ex.getIn().getBody(MyData.class);
assertEquals(JSON_SAMPLE_NAME, data.getName());
assertEquals(null, data.getNikname());
assertNull(data.getNikname());
assertEquals(JSON_SAMPLE_AGE, data.getAge());
})
.log("Will marshal: ${body}")
Expand All @@ -95,10 +96,10 @@ protected void configureProducer(RouteBuilder builder, RouteDefinition producerR
.process(ex -> {
String data = ex.getIn().getBody(String.class);

ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(data);
JsonMapper jsonMapper = new JsonMapper();
JsonNode jsonNode = jsonMapper.readTree(data);
assertEquals(JSON_SAMPLE_NAME, jsonNode.get("name").asText());
assertEquals(null, jsonNode.get("nikname"));
assertNull(jsonNode.get("nikname"));
assertEquals(JSON_SAMPLE_AGE, jsonNode.get("age").asInt());
}).toF("mock:%s", getResultMockName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@Component(
name = "karaf-camel-${featureNameLower}-test",
immediate = true,
service = CamelRouteSupplier.class
service = Camel${featureName}RouteSupplier.class
)
public class Camel${featureName}RouteSupplier extends AbstractCamelSingleFeatureResultMockBasedRouteSupplier {

Expand Down

0 comments on commit 32729d0

Please sign in to comment.