Browse Source

Added testing only fixes Windows newlines. (#714)

pull/730/merge
Karl Nicholas 7 years ago committed by Marvin Froeder
parent
commit
a25423c023
  1. 38
      jackson/src/test/java/feign/jackson/JacksonCodecTest.java
  2. 11
      jaxb/src/test/java/feign/jaxb/JAXBCodecTest.java
  3. 18
      slf4j/src/test/java/feign/slf4j/Slf4jLoggerTest.java

38
jackson/src/test/java/feign/jackson/JacksonCodecTest.java

@ -46,15 +46,15 @@ import static org.junit.Assert.assertTrue;
public class JacksonCodecTest { public class JacksonCodecTest {
private String zonesJson = ""// private String zonesJson = ""//
+ "[\n"// + "[" + System.lineSeparator() //
+ " {\n"// + " {" + System.lineSeparator() //
+ " \"name\": \"denominator.io.\"\n"// + " \"name\": \"denominator.io.\"" + System.lineSeparator()//
+ " },\n"// + " }," + System.lineSeparator()//
+ " {\n"// + " {" + System.lineSeparator()//
+ " \"name\": \"denominator.io.\",\n"// + " \"name\": \"denominator.io.\"," + System.lineSeparator()//
+ " \"id\": \"ABCD\"\n"// + " \"id\": \"ABCD\"" + System.lineSeparator()//
+ " }\n"// + " }" + System.lineSeparator()//
+ "]\n"; + "]" + System.lineSeparator();
@Test @Test
public void encodesMapObjectNumericalValuesAsInteger() throws Exception { public void encodesMapObjectNumericalValuesAsInteger() throws Exception {
@ -65,8 +65,8 @@ public class JacksonCodecTest {
new JacksonEncoder().encode(map, map.getClass(), template); new JacksonEncoder().encode(map, map.getClass(), template);
assertThat(template).hasBody(""// assertThat(template).hasBody(""//
+ "{\n" // + "{" + System.lineSeparator() //
+ " \"foo\" : 1\n" // + " \"foo\" : 1" + System.lineSeparator() //
+ "}"); + "}");
} }
@ -80,9 +80,9 @@ public class JacksonCodecTest {
new JacksonEncoder().encode(form, new TypeReference<Map<String, ?>>() {}.getType(), template); new JacksonEncoder().encode(form, new TypeReference<Map<String, ?>>() {}.getType(), template);
assertThat(template).hasBody(""// assertThat(template).hasBody(""//
+ "{\n" // + "{" + System.lineSeparator() //
+ " \"foo\" : 1,\n" // + " \"foo\" : 1," + System.lineSeparator() //
+ " \"bar\" : [ 2, 3 ]\n" // + " \"bar\" : [ 2, 3 ]" + System.lineSeparator() //
+ "}"); + "}");
} }
@ -155,11 +155,11 @@ public class JacksonCodecTest {
encoder.encode(zones, new TypeReference<List<Zone>>() {}.getType(), template); encoder.encode(zones, new TypeReference<List<Zone>>() {}.getType(), template);
assertThat(template).hasBody("" // assertThat(template).hasBody("" //
+ "[ {\n" + "[ {" + System.lineSeparator()
+ " \"name\" : \"DENOMINATOR.IO.\"\n" + " \"name\" : \"DENOMINATOR.IO.\"" + System.lineSeparator()
+ "}, {\n" + "}, {" + System.lineSeparator()
+ " \"name\" : \"DENOMINATOR.IO.\",\n" + " \"name\" : \"DENOMINATOR.IO.\"," + System.lineSeparator()
+ " \"id\" : \"ABCD\"\n" + " \"id\" : \"ABCD\"" + System.lineSeparator()
+ "} ]"); + "} ]");
} }

11
jaxb/src/test/java/feign/jaxb/JAXBCodecTest.java

@ -140,17 +140,16 @@ public class JAXBCodecTest {
RequestTemplate template = new RequestTemplate(); RequestTemplate template = new RequestTemplate();
encoder.encode(mock, MockObject.class, template); encoder.encode(mock, MockObject.class, template);
String NEWLINE = System.getProperty("line.separator"); // RequestTemplate always expects a UNIX style newline.
assertThat(template).hasBody( assertThat(template).hasBody(
new StringBuilder().append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>") new StringBuilder().append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>")
.append(NEWLINE) .append("\n")
.append("<mockObject>") .append("<mockObject>")
.append(NEWLINE) .append("\n")
.append(" <value>Test</value>") .append(" <value>Test</value>")
.append(NEWLINE) .append("\n")
.append("</mockObject>") .append("</mockObject>")
.append(NEWLINE) .append("\n")
.toString()); .toString());
} }

18
slf4j/src/test/java/feign/slf4j/Slf4jLoggerTest.java

@ -43,7 +43,7 @@ public class Slf4jLoggerTest {
@Test @Test
public void useFeignLoggerByDefault() throws Exception { public void useFeignLoggerByDefault() throws Exception {
slf4j.logLevel("debug"); slf4j.logLevel("debug");
slf4j.expectMessages("DEBUG feign.Logger - [someMethod] This is my message\n"); slf4j.expectMessages("DEBUG feign.Logger - [someMethod] This is my message" + System.lineSeparator());
logger = new Slf4jLogger(); logger = new Slf4jLogger();
logger.log(CONFIG_KEY, "This is my message"); logger.log(CONFIG_KEY, "This is my message");
@ -52,7 +52,7 @@ public class Slf4jLoggerTest {
@Test @Test
public void useLoggerByNameIfRequested() throws Exception { public void useLoggerByNameIfRequested() throws Exception {
slf4j.logLevel("debug"); slf4j.logLevel("debug");
slf4j.expectMessages("DEBUG named.logger - [someMethod] This is my message\n"); slf4j.expectMessages("DEBUG named.logger - [someMethod] This is my message" + System.lineSeparator());
logger = new Slf4jLogger("named.logger"); logger = new Slf4jLogger("named.logger");
logger.log(CONFIG_KEY, "This is my message"); logger.log(CONFIG_KEY, "This is my message");
@ -61,7 +61,7 @@ public class Slf4jLoggerTest {
@Test @Test
public void useLoggerByClassIfRequested() throws Exception { public void useLoggerByClassIfRequested() throws Exception {
slf4j.logLevel("debug"); slf4j.logLevel("debug");
slf4j.expectMessages("DEBUG feign.Feign - [someMethod] This is my message\n"); slf4j.expectMessages("DEBUG feign.Feign - [someMethod] This is my message" + System.lineSeparator());
logger = new Slf4jLogger(Feign.class); logger = new Slf4jLogger(Feign.class);
logger.log(CONFIG_KEY, "This is my message"); logger.log(CONFIG_KEY, "This is my message");
@ -70,7 +70,7 @@ public class Slf4jLoggerTest {
@Test @Test
public void useSpecifiedLoggerIfRequested() throws Exception { public void useSpecifiedLoggerIfRequested() throws Exception {
slf4j.logLevel("debug"); slf4j.logLevel("debug");
slf4j.expectMessages("DEBUG specified.logger - [someMethod] This is my message\n"); slf4j.expectMessages("DEBUG specified.logger - [someMethod] This is my message" + System.lineSeparator());
logger = new Slf4jLogger(LoggerFactory.getLogger("specified.logger")); logger = new Slf4jLogger(LoggerFactory.getLogger("specified.logger"));
logger.log(CONFIG_KEY, "This is my message"); logger.log(CONFIG_KEY, "This is my message");
@ -89,10 +89,12 @@ public class Slf4jLoggerTest {
@Test @Test
public void logRequestsAndResponses() throws Exception { public void logRequestsAndResponses() throws Exception {
slf4j.logLevel("debug"); slf4j.logLevel("debug");
slf4j.expectMessages("DEBUG feign.Logger - [someMethod] A message with 2 formatting tokens.\n" + slf4j.expectMessages("DEBUG feign.Logger - [someMethod] A message with 2 formatting tokens."
"DEBUG feign.Logger - [someMethod] ---> GET http://api.example.com HTTP/1.1\n" + System.lineSeparator() +
+ "DEBUG feign.Logger - [someMethod] ---> GET http://api.example.com HTTP/1.1"
"DEBUG feign.Logger - [someMethod] <--- HTTP/1.1 200 OK (273ms)\n"); + System.lineSeparator() +
"DEBUG feign.Logger - [someMethod] <--- HTTP/1.1 200 OK (273ms)"
+ System.lineSeparator());
logger = new Slf4jLogger(); logger = new Slf4jLogger();
logger.log(CONFIG_KEY, "A message with %d formatting %s.", 2, "tokens"); logger.log(CONFIG_KEY, "A message with %d formatting %s.", 2, "tokens");

Loading…
Cancel
Save