From 65be52c06030e90f0ba82d33db908adf18d9a81e Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 16 Nov 2010 23:44:02 -0700 Subject: [PATCH] Polish JsonSymmetricalMessageMappingTests --- .../JsonSymmetricalMessageMappingTests.java | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/spring-integration-core/src/test/java/org/springframework/integration/json/JsonSymmetricalMessageMappingTests.java b/spring-integration-core/src/test/java/org/springframework/integration/json/JsonSymmetricalMessageMappingTests.java index e0a19953fb..f6e346cf88 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/json/JsonSymmetricalMessageMappingTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/json/JsonSymmetricalMessageMappingTests.java @@ -1,10 +1,23 @@ +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.integration.json; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -import org.codehaus.jackson.JsonFactory; -import org.codehaus.jackson.map.ObjectMapper; import org.hamcrest.Factory; import org.hamcrest.Matcher; import org.junit.Test; @@ -15,17 +28,16 @@ import org.springframework.integration.message.MessageMatcher; import org.springframework.integration.support.MessageBuilder; +/** + * @author Jeremy Grelle + */ public class JsonSymmetricalMessageMappingTests { - private final JsonFactory jsonFactory = new JsonFactory(); - - private final ObjectMapper objectMapper = new ObjectMapper(); - @Factory - public static Matcher> sameExceptImmutableHeaders(Message operand) { - return new MessageMatcher(operand); - } - + public static Matcher> sameExceptImmutableHeaders(Message operand) { + return new MessageMatcher(operand); + } + @Test public void testSymmetricalMappingWithHistory() throws Exception { Message testMessage = MessageBuilder.withPayload("myPayloadStuff").build(); @@ -33,20 +45,17 @@ public class JsonSymmetricalMessageMappingTests { testMessage = MessageHistory.write(testMessage, new TestNamedComponent(2)); testMessage = MessageHistory.write(testMessage, new TestNamedComponent(3)); JsonOutboundMessageMapper outboundMapper = new JsonOutboundMessageMapper(); - + String outboundJson = outboundMapper.fromMessage(testMessage); - System.out.println(outboundJson); - + JsonInboundMessageMapper inboundMapper = new JsonInboundMessageMapper(String.class); - Message result = (Message) inboundMapper.toMessage(outboundJson); - + Message result = inboundMapper.toMessage(outboundJson); + assertThat(result, sameExceptImmutableHeaders(testMessage)); - //assertEquals(testMessage, result); - + outboundJson = outboundMapper.fromMessage(result); - System.out.println(outboundJson); } - + private static class TestNamedComponent implements NamedComponent { private final int id;