diff --git a/monitoring/pom.xml b/monitoring/pom.xml index 0e77711d9b5..0c23082dca1 100644 --- a/monitoring/pom.xml +++ b/monitoring/pom.xml @@ -49,6 +49,12 @@ com.jcabi jcabi-matchers + + com.google.truth + truth + 0.28 + test + diff --git a/monitoring/src/test/java/CloudMonitoringAuthSampleTest.java b/monitoring/src/test/java/CloudMonitoringAuthSampleTest.java index ad5cd9e5f50..878d959e16e 100644 --- a/monitoring/src/test/java/CloudMonitoringAuthSampleTest.java +++ b/monitoring/src/test/java/CloudMonitoringAuthSampleTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2015 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,8 +14,7 @@ * limitations under the License. */ -import static com.jcabi.matchers.RegexMatchers.*; -import static org.junit.Assert.*; +import static com.google.common.truth.Truth.assertThat; import org.junit.After; import org.junit.Before; @@ -23,7 +22,6 @@ import java.io.ByteArrayOutputStream; import java.io.PrintStream; -import java.util.regex.Pattern; /** * Tests the Cloud Monitoring auth sample. @@ -51,15 +49,19 @@ public void tearDown() { @Test public void testUsage() throws Exception { CloudMonitoringAuthSample.main(new String[] { }); - assertEquals("Usage: CloudMonitoringAuthSample \n", stderr.toString()); + assertThat(stderr.toString()) + .named("stderr") + .isEqualTo("Usage: CloudMonitoringAuthSample \n"); } @Test public void testListTimeSeries() throws Exception { CloudMonitoringAuthSample.main(new String[] { "cloud-samples-tests" }); String out = stdout.toString(); - assertThat(out, containsPattern("Timeseries.list raw response:")); - assertThat(out, containsPattern("\\{\\s*\"kind\" *: *\"cloudmonitoring#listTimeseriesResponse\",")); - assertThat(out, containsPattern(".*oldest.*")); + assertThat(out).named("stdout").contains("Timeseries.list raw response:"); + assertThat(out) + .named("stdout") + .containsMatch("\\{\\s*\"kind\" *: *\"cloudmonitoring#listTimeseriesResponse\","); + assertThat(out).named("stdout").containsMatch(".*oldest.*"); } }