mirror of
https://github.com/google/nomulus.git
synced 2025-05-16 17:37:13 +02:00
Log RDAP output formatting failures
Also, a couple tests are reworked to make their output more understandable in case of failure. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=176670087
This commit is contained in:
parent
a92cdbe8c3
commit
d75071f503
2 changed files with 11 additions and 5 deletions
|
@ -179,7 +179,8 @@ public abstract class RdapActionBase implements Runnable {
|
|||
response.setPayload(new JacksonFactory().toPrettyString(rdapJson));
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
// On exception, fall back to unformatted output
|
||||
logger.warning(
|
||||
e, "Unable to pretty-print RDAP JSON response; falling back to unformatted output.");
|
||||
}
|
||||
}
|
||||
response.setPayload(JSONValue.toJSONString(rdapJson));
|
||||
|
|
|
@ -233,14 +233,19 @@ public class RdapActionBaseTest {
|
|||
.build());
|
||||
}
|
||||
|
||||
private String loadFileWithoutTrailingNewline(String fileName) {
|
||||
String contents = loadFileWithSubstitutions(this.getClass(), fileName, null);
|
||||
return contents.endsWith("\n") ? contents.substring(0, contents.length() - 1) : contents;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnformatted() throws Exception {
|
||||
action.requestPath = RdapTestAction.PATH + "no.thing";
|
||||
action.fullServletPath = "http://myserver.example.com" + RdapTestAction.PATH;
|
||||
action.requestMethod = GET;
|
||||
action.run();
|
||||
assertThat(response.getPayload() + '\n').isEqualTo(
|
||||
loadFileWithSubstitutions(this.getClass(), "rdap_unformatted_output.json", null));
|
||||
assertThat(response.getPayload())
|
||||
.isEqualTo(loadFileWithoutTrailingNewline("rdap_unformatted_output.json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -250,7 +255,7 @@ public class RdapActionBaseTest {
|
|||
action.requestMethod = GET;
|
||||
action.formatOutputParam = Optional.of(true);
|
||||
action.run();
|
||||
assertThat(response.getPayload() + '\n').isEqualTo(
|
||||
loadFileWithSubstitutions(this.getClass(), "rdap_formatted_output.json", null));
|
||||
assertThat(response.getPayload())
|
||||
.isEqualTo(loadFileWithoutTrailingNewline("rdap_formatted_output.json"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue