Backported refinements and polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -42,13 +42,13 @@ import static org.junit.Assert.assertTrue;
|
||||
*/
|
||||
public class AtomFeedHttpMessageConverterTests {
|
||||
|
||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
private AtomFeedHttpMessageConverter converter;
|
||||
|
||||
private Charset utf8;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
utf8 = Charset.forName("UTF-8");
|
||||
converter = new AtomFeedHttpMessageConverter();
|
||||
XMLUnit.setIgnoreWhitespace(true);
|
||||
}
|
||||
@@ -56,20 +56,20 @@ public class AtomFeedHttpMessageConverterTests {
|
||||
@Test
|
||||
public void canRead() {
|
||||
assertTrue(converter.canRead(Feed.class, new MediaType("application", "atom+xml")));
|
||||
assertTrue(converter.canRead(Feed.class, new MediaType("application", "atom+xml", utf8)));
|
||||
assertTrue(converter.canRead(Feed.class, new MediaType("application", "atom+xml", UTF_8)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
assertTrue(converter.canWrite(Feed.class, new MediaType("application", "atom+xml")));
|
||||
assertTrue(converter.canWrite(Feed.class, new MediaType("application", "atom+xml", Charset.forName("UTF-8"))));
|
||||
assertTrue(converter.canWrite(Feed.class, new MediaType("application", "atom+xml", UTF_8)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void read() throws IOException {
|
||||
InputStream is = getClass().getResourceAsStream("atom.xml");
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(is);
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "atom+xml", utf8));
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "atom+xml", UTF_8));
|
||||
Feed result = converter.read(Feed.class, inputMessage);
|
||||
assertEquals("title", result.getTitle());
|
||||
assertEquals("subtitle", result.getSubtitle().getValue());
|
||||
@@ -106,12 +106,12 @@ public class AtomFeedHttpMessageConverterTests {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
converter.write(feed, null, outputMessage);
|
||||
|
||||
assertEquals("Invalid content-type", new MediaType("application", "atom+xml", utf8),
|
||||
assertEquals("Invalid content-type", new MediaType("application", "atom+xml", UTF_8),
|
||||
outputMessage.getHeaders().getContentType());
|
||||
String expected = "<feed xmlns=\"http://www.w3.org/2005/Atom\">" + "<title>title</title>" +
|
||||
"<entry><id>id1</id><title>title1</title></entry>" +
|
||||
"<entry><id>id2</id><title>title2</title></entry></feed>";
|
||||
assertXMLEqual(expected, outputMessage.getBodyAsString(utf8));
|
||||
assertXMLEqual(expected, outputMessage.getBodyAsString(UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -42,34 +42,35 @@ import static org.junit.Assert.assertTrue;
|
||||
*/
|
||||
public class RssChannelHttpMessageConverterTests {
|
||||
|
||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
private RssChannelHttpMessageConverter converter;
|
||||
|
||||
private Charset utf8;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
utf8 = Charset.forName("UTF-8");
|
||||
converter = new RssChannelHttpMessageConverter();
|
||||
XMLUnit.setIgnoreWhitespace(true);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
assertTrue(converter.canRead(Channel.class, new MediaType("application", "rss+xml")));
|
||||
assertTrue(converter.canRead(Channel.class, new MediaType("application", "rss+xml", utf8)));
|
||||
assertTrue(converter.canRead(Channel.class, new MediaType("application", "rss+xml", UTF_8)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
assertTrue(converter.canWrite(Channel.class, new MediaType("application", "rss+xml")));
|
||||
assertTrue(converter.canWrite(Channel.class, new MediaType("application", "rss+xml", Charset.forName("UTF-8"))));
|
||||
assertTrue(converter.canWrite(Channel.class, new MediaType("application", "rss+xml", UTF_8)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void read() throws IOException {
|
||||
InputStream is = getClass().getResourceAsStream("rss.xml");
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(is);
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "rss+xml", utf8));
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "rss+xml", UTF_8));
|
||||
Channel result = converter.read(Channel.class, inputMessage);
|
||||
assertEquals("title", result.getTitle());
|
||||
assertEquals("http://example.com", result.getLink());
|
||||
@@ -106,14 +107,14 @@ public class RssChannelHttpMessageConverterTests {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
converter.write(channel, null, outputMessage);
|
||||
|
||||
assertEquals("Invalid content-type", new MediaType("application", "rss+xml", utf8),
|
||||
assertEquals("Invalid content-type", new MediaType("application", "rss+xml", UTF_8),
|
||||
outputMessage.getHeaders().getContentType());
|
||||
String expected = "<rss version=\"2.0\">" +
|
||||
"<channel><title>title</title><link>http://example.com</link><description>description</description>" +
|
||||
"<item><title>title1</title></item>" +
|
||||
"<item><title>title2</title></item>" +
|
||||
"</channel></rss>";
|
||||
assertXMLEqual(expected, outputMessage.getBodyAsString(utf8));
|
||||
assertXMLEqual(expected, outputMessage.getBodyAsString(UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -127,7 +127,7 @@ public class JaxWsSupportTests {
|
||||
}
|
||||
catch (BeanCreationException ex) {
|
||||
if ("exporter".equals(ex.getBeanName()) && ex.getRootCause() instanceof ClassNotFoundException) {
|
||||
// ignore - probably running on JDK < 1.6 without the JAX-WS impl present
|
||||
// ignore - probably running on JDK without the JAX-WS impl present
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
@@ -146,7 +146,7 @@ public class JaxWsSupportTests {
|
||||
|
||||
public OrderService myService;
|
||||
|
||||
@WebServiceRef(value=OrderServiceService.class, wsdlLocation = "http://localhost:9999/OrderService?wsdl")
|
||||
@WebServiceRef(value = OrderServiceService.class, wsdlLocation = "http://localhost:9999/OrderService?wsdl")
|
||||
public void setMyService(OrderService myService) {
|
||||
this.myService = myService;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user