mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Pretty-print actual XML in tests
This means that, when writing new tests that are failing, you get much more useful logs that show the actual XML in a more comprehensible format that is suitable for pasting back into the golden file in the test (if the change was intended). This requires outputting the standalone parameter in the XML transformer, and some minor changes to some tests as a result that were relying on it being stripped out. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=204513690
This commit is contained in:
parent
df5d9957f7
commit
278ec2b289
5 changed files with 11 additions and 7 deletions
|
@ -303,6 +303,7 @@ public class XmlTransformer {
|
|||
try {
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.setOutputProperty(OutputKeys.STANDALONE, "yes");
|
||||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
|
||||
transformer.transform(
|
||||
new StreamSource(new StringReader(xmlString)),
|
||||
|
|
|
@ -132,7 +132,8 @@ public class FlowRunnerTest extends ShardableTestCase {
|
|||
"TheRegistrar",
|
||||
"StatelessRequestSessionMetadata"
|
||||
+ "{clientId=TheRegistrar, failedLoginAttempts=0, serviceExtensionUris=}",
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><xml/>",
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>",
|
||||
"<xml/>",
|
||||
"", // Extra newline at the end of the XML.
|
||||
"PasswordOnlyTransportCredentials{}",
|
||||
"UNIT_TEST",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.tools;
|
|||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.xml.XmlTestUtils.assertXmlEquals;
|
||||
import static google.registry.xml.XmlTransformer.prettyPrint;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
|
@ -191,9 +192,7 @@ public class EppToolVerifier {
|
|||
private EppToolVerifier verifySentContents(String expectedXmlContent) throws Exception {
|
||||
setArgumentsIfNeeded();
|
||||
assertThat(capturedParams.size()).isGreaterThan(paramIndex);
|
||||
assertXmlEquals(
|
||||
expectedXmlContent,
|
||||
bytesToXml(capturedParams.get(paramIndex)));
|
||||
assertXmlEquals(expectedXmlContent, prettyPrint(bytesToXml(capturedParams.get(paramIndex))));
|
||||
paramIndex++;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,8 @@ public class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntr
|
|||
+ "Time: 2000-01-01T00:00:00.000Z\n"
|
||||
+ "Client TRID: ABC-123\n"
|
||||
+ "Server TRID: server-trid\n"
|
||||
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xml/>\n"
|
||||
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
|
||||
+ "<xml/>\n"
|
||||
+ "\n");
|
||||
}
|
||||
|
||||
|
@ -77,7 +78,8 @@ public class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntr
|
|||
+ "Time: 2000-01-01T00:00:00.000Z\n"
|
||||
+ "Client TRID: null\n"
|
||||
+ "Server TRID: null\n"
|
||||
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xml/>\n"
|
||||
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
|
||||
+ "<xml/>\n"
|
||||
+ "\n");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue