Polish JsonSymmetricalMessageMappingTests
This commit is contained in:
@@ -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<Message<?>> sameExceptImmutableHeaders(Message<?> operand) {
|
||||
return new MessageMatcher(operand);
|
||||
}
|
||||
|
||||
public static Matcher<Message<?>> sameExceptImmutableHeaders(Message<?> operand) {
|
||||
return new MessageMatcher(operand);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSymmetricalMappingWithHistory() throws Exception {
|
||||
Message<String> 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<String> result = (Message<String>) 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;
|
||||
|
||||
Reference in New Issue
Block a user