diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /jdisc_http_service/src/test/java/com/yahoo/jdisc/http/AssertFile.java |
Publish
Diffstat (limited to 'jdisc_http_service/src/test/java/com/yahoo/jdisc/http/AssertFile.java')
-rw-r--r-- | jdisc_http_service/src/test/java/com/yahoo/jdisc/http/AssertFile.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/AssertFile.java b/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/AssertFile.java new file mode 100644 index 00000000000..9c85164dcb6 --- /dev/null +++ b/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/AssertFile.java @@ -0,0 +1,34 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.jdisc.http; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; + + +/** + * @author <a href="mailto:apurvak@yahoo-inc.com">Apurva Kumar</a> + */ + +public class AssertFile { + + public static void assertContains(File logFile, String expected) throws IOException { + String s = new String( + Files.readAllBytes(Paths.get(logFile.getAbsolutePath())), + StandardCharsets.UTF_8); + assertThat(s, containsString(expected)); + } + + public static void assertNotContains(File logFile, String expected) throws IOException { + String s = new String( + Files.readAllBytes(Paths.get(logFile.getAbsolutePath())), + StandardCharsets.UTF_8); + assertThat(s, not(containsString(expected))); + } +} |