changed startsWith() to contains() in test since order of payload and headers is not definite

This commit is contained in:
Mark Fisher
2010-03-09 21:10:12 +00:00
parent 3cb0b360ca
commit 1e502871fa

View File

@@ -1,3 +1,19 @@
/*
* 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.*;
@@ -13,7 +29,10 @@ import org.junit.Test;
import org.springframework.integration.core.Message;
import org.springframework.integration.message.MessageBuilder;
/**
* @author Jeremy Grelle
* @since 2.0
*/
public class OutboundJsonMessageMapperTests {
private JsonFactory jsonFactory = new JsonFactory();
@@ -24,7 +43,7 @@ public class OutboundJsonMessageMapperTests {
Message<String> testMessage = MessageBuilder.withPayload("myPayloadStuff").build();
OutboundJsonMessageMapper mapper = new OutboundJsonMessageMapper();
String result = mapper.fromMessage(testMessage);
assertTrue(result.startsWith("{\"headers\":{"));
assertTrue(result.contains("\"headers\":{"));
assertTrue(result.contains("\"$timestamp\":"+testMessage.getHeaders().getTimestamp()));
assertTrue(result.contains("\"$history\":[]"));
assertTrue(result.contains("\"$id\":\""+testMessage.getHeaders().getId()+"\""));
@@ -47,7 +66,7 @@ public class OutboundJsonMessageMapperTests {
Message<TestBean> testMessage = MessageBuilder.withPayload(payload).build();
OutboundJsonMessageMapper mapper = new OutboundJsonMessageMapper();
String result = mapper.fromMessage(testMessage);
assertTrue(result.startsWith("{\"headers\":{"));
assertTrue(result.contains("\"headers\":{"));
assertTrue(result.contains("\"$timestamp\":"+testMessage.getHeaders().getTimestamp()));
assertTrue(result.contains("\"$history\":[]"));
assertTrue(result.contains("\"$id\":\""+testMessage.getHeaders().getId()+"\""));