From 60180348cde540f51af49c6a262e950a38feda48 Mon Sep 17 00:00:00 2001 From: mcilwain Date: Fri, 15 Jul 2016 11:38:50 -0700 Subject: [PATCH] Add better assertions on registry_tool stdout ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=127561648 --- javatests/google/registry/tools/CommandTestCase.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/javatests/google/registry/tools/CommandTestCase.java b/javatests/google/registry/tools/CommandTestCase.java index 80ec46f14..5c26f82b2 100644 --- a/javatests/google/registry/tools/CommandTestCase.java +++ b/javatests/google/registry/tools/CommandTestCase.java @@ -145,17 +145,22 @@ public abstract class CommandTestCase { return ofy().load().type(PollMessage.class).count(); } + protected void assertStdoutIs(String expected) throws Exception { + assertThat(getStdoutAsString()).isEqualTo(expected); + } + protected void assertInStdout(String... expected) throws Exception { + String stdout = getStdoutAsString(); for (String line : expected) { - assertThat(stdout.toString(UTF_8.toString())).contains(line); + assertThat(stdout).contains(line); } } void assertNotInStdout(String expected) throws Exception { - assertThat(stdout.toString(UTF_8.toString())).doesNotContain(expected); + assertThat(getStdoutAsString()).doesNotContain(expected); } - String getStdoutAsString() { + protected String getStdoutAsString() { return new String(stdout.toByteArray(), UTF_8); }