diff options
author | Jon Bratseth <bratseth@oath.com> | 2021-12-19 16:49:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-19 16:49:26 +0100 |
commit | 3662fb1b96d325fe7ff07a6eb031d7d58b5cc9e2 (patch) | |
tree | 683550356630610f6c639ab8486ea1a67115a326 | |
parent | 63da9a412b31fb1badc787e4ae8550a0c2b50fc0 (diff) | |
parent | 13a4da6277ac96d88b88d53075b91d9d0035f7cf (diff) |
Merge pull request #20580 from vespa-engine/balder/reduce-usage-of-hamcrest
Balder/reduce usage of hamcrest
21 files changed, 205 insertions, 248 deletions
diff --git a/config-application-package/src/test/java/com/yahoo/config/model/application/provider/FilesApplicationPackageTest.java b/config-application-package/src/test/java/com/yahoo/config/model/application/provider/FilesApplicationPackageTest.java index 2a70799ab3d..ec68ed73864 100644 --- a/config-application-package/src/test/java/com/yahoo/config/model/application/provider/FilesApplicationPackageTest.java +++ b/config-application-package/src/test/java/com/yahoo/config/model/application/provider/FilesApplicationPackageTest.java @@ -9,7 +9,6 @@ import com.yahoo.config.provision.Zone; import com.yahoo.io.IOUtils; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import java.io.File; @@ -17,10 +16,10 @@ import java.io.FileReader; import java.io.IOException; import java.nio.file.Files; -import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * @author Ulf Lilleengen @@ -30,9 +29,6 @@ public class FilesApplicationPackageTest { @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Test public void testPreprocessing() throws IOException { File appDir = temporaryFolder.newFolder(); @@ -112,9 +108,12 @@ public class FilesApplicationPackageTest { IOUtils.copyDirectory(new File("src/test/resources/multienvapp"), appDir); Files.delete(new File(appDir, "services.xml").toPath()); FilesApplicationPackage app = FilesApplicationPackage.fromFile(appDir); - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage(containsString("services.xml in application package is empty")); - app.preprocess(new Zone(Environment.dev, RegionName.defaultName()), new BaseDeployLogger()); + try { + app.preprocess(new Zone(Environment.dev, RegionName.defaultName()), new BaseDeployLogger()); + fail(); + } catch (IllegalArgumentException e) { + assertTrue(e.getMessage().contains("services.xml in application package is empty")); + } } } diff --git a/config-provisioning/pom.xml b/config-provisioning/pom.xml index 12b31bd6370..5f0c93ceec5 100644 --- a/config-provisioning/pom.xml +++ b/config-provisioning/pom.xml @@ -64,11 +64,6 @@ Provisioning APIs. <scope>test</scope> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-all</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> diff --git a/config-provisioning/src/test/java/com/yahoo/config/provision/ApplicationIdTest.java b/config-provisioning/src/test/java/com/yahoo/config/provision/ApplicationIdTest.java index 27b9a7213cb..c82230f7edf 100644 --- a/config-provisioning/src/test/java/com/yahoo/config/provision/ApplicationIdTest.java +++ b/config-provisioning/src/test/java/com/yahoo/config/provision/ApplicationIdTest.java @@ -7,8 +7,6 @@ import com.yahoo.cloud.config.ApplicationIdConfig; import com.yahoo.test.TotalOrderTester; import org.junit.Test; import com.google.common.testing.EqualsTester; -import static org.junit.Assert.assertThat; -import static org.hamcrest.Matchers.*; /** * @author Ulf Lilleengen @@ -53,9 +51,9 @@ public class ApplicationIdTest { ApplicationId id1 = applicationId("foo"); ApplicationId id2 = applicationId("bar"); ApplicationId id3 = idFrom("tenant", "baz", "bim"); - assertThat(id1.serializedForm(), is("default:foo:default")); - assertThat(id2.serializedForm(), is("default:bar:default")); - assertThat(id3.serializedForm(), is("tenant:baz:bim")); + assertEquals("default:foo:default", id1.serializedForm()); + assertEquals("default:bar:default", id2.serializedForm()); + assertEquals("tenant:baz:bim", id3.serializedForm()); } @Test @@ -63,20 +61,20 @@ public class ApplicationIdTest { ApplicationId id1 = applicationId("foo"); ApplicationId id2 = idFrom("bar", "baz", "default"); ApplicationId id3 = idFrom("tenant", "baz", "bim"); - assertThat(id1.toShortString(), is("default.foo")); - assertThat(id1.toFullString(), is("default.foo.default")); - assertThat(id2.toShortString(), is("bar.baz")); - assertThat(id2.toFullString(), is("bar.baz.default")); - assertThat(id3.toShortString(), is("tenant.baz.bim")); - assertThat(id3.toFullString(), is("tenant.baz.bim")); + assertEquals("default.foo", id1.toShortString()); + assertEquals("default.foo.default", id1.toFullString()); + assertEquals("bar.baz", id2.toShortString()); + assertEquals("bar.baz.default", id2.toFullString()); + assertEquals("tenant.baz.bim", id3.toShortString()); + assertEquals("tenant.baz.bim", id3.toFullString()); } @Test public void require_that_idstring_can_be_parsed() { ApplicationId id = ApplicationId.fromSerializedForm("ten:foo:bim"); - assertThat(id.tenant().value(), is("ten")); - assertThat(id.application().value(), is("foo")); - assertThat(id.instance().value(), is("bim")); + assertEquals("ten", id.tenant().value()); + assertEquals("foo", id.application().value()); + assertEquals("bim", id.instance().value()); } @Test(expected = IllegalArgumentException.class) @@ -87,8 +85,8 @@ public class ApplicationIdTest { @Test public void require_that_defaults_are_given() { ApplicationId id1 = applicationId("foo"); - assertThat(id1.tenant().value(), is("default")); - assertThat(id1.instance().value(), is("default")); + assertEquals("default", id1.tenant().value()); + assertEquals("default", id1.instance().value()); } @Test diff --git a/config-provisioning/src/test/java/com/yahoo/config/provision/IdentifierTestBase.java b/config-provisioning/src/test/java/com/yahoo/config/provision/IdentifierTestBase.java index 370bcd6cdf1..d4edb7a14eb 100644 --- a/config-provisioning/src/test/java/com/yahoo/config/provision/IdentifierTestBase.java +++ b/config-provisioning/src/test/java/com/yahoo/config/provision/IdentifierTestBase.java @@ -4,10 +4,9 @@ package com.yahoo.config.provision; import com.google.common.testing.EqualsTester; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; /** @@ -29,8 +28,8 @@ public abstract class IdentifierTestBase<ID_TYPE> { assertTrue(isDefault(def)); assertTrue(isDefault(def2)); assertFalse(isDefault(notdef)); - assertThat(def, is(def2)); - assertThat(def2, is(not(notdef))); + assertEquals(def, def2); + assertNotEquals(def2, notdef); } @Test diff --git a/config-provisioning/src/test/java/com/yahoo/config/provision/TenantTest.java b/config-provisioning/src/test/java/com/yahoo/config/provision/TenantTest.java index 8475c30c1f6..2bfcd183c85 100644 --- a/config-provisioning/src/test/java/com/yahoo/config/provision/TenantTest.java +++ b/config-provisioning/src/test/java/com/yahoo/config/provision/TenantTest.java @@ -4,8 +4,7 @@ package com.yahoo.config.provision; import com.yahoo.test.TotalOrderTester; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; /** * @author Ulf Lilleengen @@ -29,7 +28,7 @@ public class TenantTest extends IdentifierTestBase<TenantName> { @Test public void testComparator() { - assertThat(TenantName.defaultName().compareTo(TenantName.defaultName()), is(0)); + assertEquals(0, TenantName.defaultName().compareTo(TenantName.defaultName())); new TotalOrderTester<TenantName>() .theseObjects(TenantName.from("a"), TenantName.from("a")) diff --git a/container-disc/src/test/java/com/yahoo/container/jdisc/FilterBindingsProviderTest.java b/container-disc/src/test/java/com/yahoo/container/jdisc/FilterBindingsProviderTest.java index 40c66e115e4..b45fc037ca8 100644 --- a/container-disc/src/test/java/com/yahoo/container/jdisc/FilterBindingsProviderTest.java +++ b/container-disc/src/test/java/com/yahoo/container/jdisc/FilterBindingsProviderTest.java @@ -11,6 +11,8 @@ import com.yahoo.jdisc.http.filter.ResponseFilter; import com.yahoo.jdisc.http.server.jetty.FilterBindings; import org.junit.Test; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; @@ -39,9 +41,9 @@ public class FilterBindingsProviderTest { final FilterBindings filterBindings = provider.get(); - assertThat(filterBindings).isNotNull(); - assertThat(filterBindings.requestFilterIds()).isEmpty(); - assertThat(filterBindings.responseFilterIds()).isEmpty(); + assertNotNull(filterBindings); + assertTrue(filterBindings.requestFilterIds().isEmpty()); + assertTrue(filterBindings.responseFilterIds().isEmpty()); } @Test @@ -92,7 +94,7 @@ public class FilterBindingsProviderTest { final FilterBindings filterBindings = provider.get(); // Verify. - assertThat(filterBindings).isNotNull(); + assertNotNull(filterBindings); assertThat(filterBindings.requestFilters()) .containsExactlyInAnyOrder(requestFilter1Instance, requestFilter2Instance); assertThat(filterBindings.responseFilters()) @@ -127,7 +129,7 @@ public class FilterBindingsProviderTest { new ComponentRegistry<>()); fail("Dual-role filter should not be accepted"); } catch (RuntimeException e) { - assertThat(e.getMessage()).contains("Invalid config"); + assertTrue(e.getMessage().contains("Invalid config")); } } @@ -152,7 +154,7 @@ public class FilterBindingsProviderTest { new ComponentRegistry<>()); fail("Config with unknown filter reference should not be accepted"); } catch (RuntimeException e) { - assertThat(e.getMessage()).contains("Invalid config"); + assertTrue(e.getMessage().contains("Invalid config")); } } diff --git a/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/ClientThreadingTestCase.java b/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/ClientThreadingTestCase.java index 4336c491071..549a1e3b887 100644 --- a/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/ClientThreadingTestCase.java +++ b/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/ClientThreadingTestCase.java @@ -31,8 +31,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; /** * @author Simon Thoresen Hult @@ -56,11 +55,11 @@ public class ClientThreadingTestCase { } final ExecutorService executor = Executors.newFixedThreadPool(NUM_THREADS); for (final Future<Boolean> res : executor.invokeAll(lst, 60, TimeUnit.SECONDS)) { - assertThat(res.get(), is(true)); + assertTrue(res.get()); } - assertThat(client.close(), is(true)); - assertThat(server.close(), is(true)); + assertTrue(client.close()); + assertTrue(server.close()); } private static final class RequestTask implements Callable<Boolean> { diff --git a/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/MbusServerConformanceTest.java b/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/MbusServerConformanceTest.java index 13059f7c91f..397a3eb5242 100644 --- a/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/MbusServerConformanceTest.java +++ b/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/MbusServerConformanceTest.java @@ -18,7 +18,6 @@ import com.yahoo.messagebus.shared.ServerSession; import com.yahoo.messagebus.shared.SharedMessageBus; import com.yahoo.messagebus.test.SimpleMessage; import com.yahoo.messagebus.test.SimpleProtocol; -import org.hamcrest.Matcher; import org.junit.Ignore; import org.junit.Test; @@ -31,12 +30,12 @@ import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.TimeUnit; import static com.yahoo.messagebus.ErrorCode.APP_FATAL_ERROR; -import static com.yahoo.messagebus.ErrorCode.SEND_QUEUE_CLOSED; import static com.yahoo.messagebus.ErrorCode.SESSION_BUSY; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; /** * @author Simon Thoresen Hult @@ -51,28 +50,28 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { @Test public void testContainerNotReadyException() throws Throwable { new TestRunner().setRequestTimeout(100, TimeUnit.MILLISECONDS) - .expectError(is(SESSION_BUSY)) + .expectError(SESSION_BUSY) .executeAndClose(); } @Override @Test public void testBindingSetNotFoundException() throws Throwable { - new TestRunner().expectError(is(APP_FATAL_ERROR)) + new TestRunner().expectError(APP_FATAL_ERROR) .executeAndClose(); } @Override @Test public void testNoBindingSetSelectedException() throws Throwable { - new TestRunner().expectError(is(APP_FATAL_ERROR)) + new TestRunner().expectError(APP_FATAL_ERROR) .executeAndClose(); } @Override @Test public void testBindingNotFoundException() throws Throwable { - new TestRunner().expectError(is(APP_FATAL_ERROR)) + new TestRunner().expectError(APP_FATAL_ERROR) .executeAndClose(); } @@ -107,7 +106,7 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { @Override @Test public void testRequestException() throws Throwable { - new TestRunner().expectError(is(APP_FATAL_ERROR)) + new TestRunner().expectError(APP_FATAL_ERROR) .executeAndClose(); } @@ -142,7 +141,7 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestExceptionAfterResponseWriteWithSyncHandleResponse() throws Throwable { + public void testRequestExceptionAfterResponseWriteWithSyncHandleResponse() { } @Override @@ -154,7 +153,7 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { @Override @Test public void testRequestExceptionBeforeResponseWriteWithAsyncHandleResponse() throws Throwable { - new TestRunner().expectError(is(APP_FATAL_ERROR)) + new TestRunner().expectError(APP_FATAL_ERROR) .executeAndClose(); } @@ -168,181 +167,181 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestExceptionAfterResponseWriteWithAsyncHandleResponse() throws Throwable { + public void testRequestExceptionAfterResponseWriteWithAsyncHandleResponse() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteWithSyncCompletion() throws Throwable { + public void testRequestContentWriteWithSyncCompletion() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteWithAsyncCompletion() throws Throwable { + public void testRequestContentWriteWithAsyncCompletion() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteWithNondeterministicSyncFailure() throws Throwable { + public void testRequestContentWriteWithNondeterministicSyncFailure() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteWithSyncFailureBeforeResponseWrite() throws Throwable { + public void testRequestContentWriteWithSyncFailureBeforeResponseWrite() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteWithSyncFailureAfterResponseWrite() throws Throwable { + public void testRequestContentWriteWithSyncFailureAfterResponseWrite() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteWithNondeterministicAsyncFailure() throws Throwable { + public void testRequestContentWriteWithNondeterministicAsyncFailure() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteWithAsyncFailureBeforeResponseWrite() throws Throwable { + public void testRequestContentWriteWithAsyncFailureBeforeResponseWrite() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteWithAsyncFailureAfterResponseWrite() throws Throwable { + public void testRequestContentWriteWithAsyncFailureAfterResponseWrite() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteWithAsyncFailureAfterResponseCloseNoContent() throws Throwable { + public void testRequestContentWriteWithAsyncFailureAfterResponseCloseNoContent() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteNondeterministicException() throws Throwable { + public void testRequestContentWriteNondeterministicException() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionBeforeResponseWrite() throws Throwable { + public void testRequestContentWriteExceptionBeforeResponseWrite() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionAfterResponseWrite() throws Throwable { + public void testRequestContentWriteExceptionAfterResponseWrite() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionAfterResponseCloseNoContent() throws Throwable { + public void testRequestContentWriteExceptionAfterResponseCloseNoContent() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteNondeterministicExceptionWithSyncCompletion() throws Throwable { + public void testRequestContentWriteNondeterministicExceptionWithSyncCompletion() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionBeforeResponseWriteWithSyncCompletion() throws Throwable { + public void testRequestContentWriteExceptionBeforeResponseWriteWithSyncCompletion() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionAfterResponseWriteWithSyncCompletion() throws Throwable { + public void testRequestContentWriteExceptionAfterResponseWriteWithSyncCompletion() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionAfterResponseCloseNoContentWithSyncCompletion() throws Throwable { + public void testRequestContentWriteExceptionAfterResponseCloseNoContentWithSyncCompletion() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteNondeterministicExceptionWithAsyncCompletion() throws Throwable { + public void testRequestContentWriteNondeterministicExceptionWithAsyncCompletion() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionBeforeResponseWriteWithAsyncCompletion() throws Throwable { + public void testRequestContentWriteExceptionBeforeResponseWriteWithAsyncCompletion() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionAfterResponseWriteWithAsyncCompletion() throws Throwable { + public void testRequestContentWriteExceptionAfterResponseWriteWithAsyncCompletion() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionAfterResponseCloseNoContentWithAsyncCompletion() throws Throwable { + public void testRequestContentWriteExceptionAfterResponseCloseNoContentWithAsyncCompletion() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionWithNondeterministicSyncFailure() throws Throwable { + public void testRequestContentWriteExceptionWithNondeterministicSyncFailure() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionWithSyncFailureBeforeResponseWrite() throws Throwable { + public void testRequestContentWriteExceptionWithSyncFailureBeforeResponseWrite() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionWithSyncFailureAfterResponseWrite() throws Throwable { + public void testRequestContentWriteExceptionWithSyncFailureAfterResponseWrite() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionWithSyncFailureAfterResponseCloseNoContent() throws Throwable { + public void testRequestContentWriteExceptionWithSyncFailureAfterResponseCloseNoContent() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionWithNondeterministicAsyncFailure() throws Throwable { + public void testRequestContentWriteExceptionWithNondeterministicAsyncFailure() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionWithAsyncFailureBeforeResponseWrite() throws Throwable { + public void testRequestContentWriteExceptionWithAsyncFailureBeforeResponseWrite() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionWithAsyncFailureAfterResponseWrite() throws Throwable { + public void testRequestContentWriteExceptionWithAsyncFailureAfterResponseWrite() { } @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentWriteExceptionWithAsyncFailureAfterResponseCloseNoContent() throws Throwable { + public void testRequestContentWriteExceptionWithAsyncFailureAfterResponseCloseNoContent() { } @Override @@ -376,7 +375,7 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentCloseWithSyncFailureAfterResponseWrite() throws Throwable { + public void testRequestContentCloseWithSyncFailureAfterResponseWrite() { } @Override @@ -403,7 +402,7 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentCloseWithAsyncFailureAfterResponseWrite() throws Throwable { + public void testRequestContentCloseWithAsyncFailureAfterResponseWrite() { } @Override @@ -430,7 +429,7 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentCloseExceptionAfterResponseWrite() throws Throwable { + public void testRequestContentCloseExceptionAfterResponseWrite() { } @Override @@ -457,7 +456,7 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentCloseExceptionAfterResponseWriteWithSyncCompletion() throws Throwable { + public void testRequestContentCloseExceptionAfterResponseWriteWithSyncCompletion() { } @Override @@ -484,7 +483,7 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentCloseExceptionAfterResponseWriteWithAsyncCompletion() throws Throwable { + public void testRequestContentCloseExceptionAfterResponseWriteWithAsyncCompletion() { } @Override @@ -511,7 +510,7 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentCloseExceptionAfterResponseWriteWithSyncFailure() throws Throwable { + public void testRequestContentCloseExceptionAfterResponseWriteWithSyncFailure() { } @Override @@ -538,7 +537,7 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testRequestContentCloseExceptionAfterResponseWriteWithAsyncFailure() throws Throwable { + public void testRequestContentCloseExceptionAfterResponseWriteWithAsyncFailure() { } @Override @@ -551,7 +550,7 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { @Override @Test @Ignore // N/A: The messagebus protocol does not have content. - public void testResponseWriteCompletionException() throws Throwable { + public void testResponseWriteCompletionException() { } @Override @@ -573,7 +572,7 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { final LocalWire wire = new LocalWire(); final SharedMessageBus mbus; final ServerSession session; - Matcher<Integer> expectedError = null; + Integer expectedError = null; boolean successExpected = false; long timeoutMillis = TimeUnit.SECONDS.toMillis(60); @@ -592,14 +591,14 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { return this; } - TestRunner expectError(Matcher<Integer> matcher) { - assertThat(successExpected, is(false)); + TestRunner expectError(Integer matcher) { + assertFalse(successExpected); expectedError = matcher; return this; } TestRunner expectSuccess() { - assertThat(expectedError, is(nullValue())); + assertNull(expectedError); successExpected = true; return this; } @@ -621,24 +620,24 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { } @Override - public MyClient newClient(MbusServer server) throws Throwable { + public MyClient newClient(MbusServer server) { return new MyClient(wire, server.connectionSpec()); } @Override public Reply executeRequest(MyClient client, boolean withRequestContent) throws Throwable { // This protocol doesn't have the concept of "request content", so if we are asked to send any, it's a bug. - assertThat(withRequestContent, is(false)); + assertFalse(withRequestContent); final SimpleMessage msg = new SimpleMessage("foo"); msg.getTrace().setLevel(9); msg.setRoute(client.route); msg.setTimeRemaining(timeoutMillis); - assertThat("client.session.send(msg).isAccepted()", - client.session.send(msg).isAccepted(), is(true)); + assertTrue("client.session.send(msg).isAccepted()", + client.session.send(msg).isAccepted()); final Reply reply = client.replies.poll(60, TimeUnit.SECONDS); - assertThat("reply != null", reply, notNullValue()); + assertNotNull("reply != null", reply); return reply; } @@ -648,15 +647,15 @@ public class MbusServerConformanceTest extends ServerProviderConformanceTest { } @Override - public void validateResponse(Reply reply) throws Throwable { + public void validateResponse(Reply reply) { final String trace = String.valueOf(reply.getTrace()); if (expectedError != null) { - assertThat(reply.hasErrors(), is(true)); + assertTrue(reply.hasErrors()); final int error = reply.getError(0).getCode(); - assertThat(trace, error, expectedError); + assertEquals(trace, Integer.valueOf(error), expectedError); } if (successExpected) { - assertThat(trace, reply.hasErrors(), is(false)); + assertFalse(trace, reply.hasErrors()); } } diff --git a/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/ServerThreadingTestCase.java b/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/ServerThreadingTestCase.java index 0884762195b..0888a02c74c 100644 --- a/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/ServerThreadingTestCase.java +++ b/container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/ServerThreadingTestCase.java @@ -28,9 +28,8 @@ import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.TimeUnit; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; /** * @author Simon Thoresen Hult @@ -50,16 +49,16 @@ public class ServerThreadingTestCase { final Message msg = new SimpleMessage("foo"); msg.setRoute(Route.parse(server.delegate.connectionSpec())); msg.pushHandler(client); - assertThat(client.session.send(msg).isAccepted(), is(true)); + assertTrue(client.session.send(msg).isAccepted()); } for (int i = 0; i < NUM_REQUESTS; ++i) { final Reply reply = client.replies.poll(600, TimeUnit.SECONDS); - assertThat(reply, instanceOf(EmptyReply.class)); - assertThat(reply.hasErrors(), is(false)); + assertTrue(reply instanceof EmptyReply); + assertFalse(reply.hasErrors()); } - assertThat(client.close(), is(true)); - assertThat(server.close(), is(true)); + assertTrue(client.close()); + assertTrue(server.close()); } private static class Client implements ReplyHandler { @@ -106,14 +105,10 @@ public class ServerThreadingTestCase { @Override public void handleMessage(final Message msg) { - executor.execute(new Runnable() { - - @Override - public void run() { - final Reply reply = new EmptyReply(); - reply.swapState(msg); - reply.popHandler().handleReply(reply); - } + executor.execute(() -> { + final Reply reply = new EmptyReply(); + reply.swapState(msg); + reply.popHandler().handleReply(reply); }); } diff --git a/container-search-and-docproc/pom.xml b/container-search-and-docproc/pom.xml index 90c9c056131..e98b2a08662 100644 --- a/container-search-and-docproc/pom.xml +++ b/container-search-and-docproc/pom.xml @@ -217,11 +217,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <scope>test</scope> diff --git a/container-search-and-docproc/src/test/java/com/yahoo/container/handler/observability/ApplicationStatusHandlerTest.java b/container-search-and-docproc/src/test/java/com/yahoo/container/handler/observability/ApplicationStatusHandlerTest.java index 93668cf788d..317f5fc1329 100644 --- a/container-search-and-docproc/src/test/java/com/yahoo/container/handler/observability/ApplicationStatusHandlerTest.java +++ b/container-search-and-docproc/src/test/java/com/yahoo/container/handler/observability/ApplicationStatusHandlerTest.java @@ -5,7 +5,6 @@ import com.yahoo.component.ComponentId; import com.yahoo.component.chain.Chain; import com.yahoo.container.core.ApplicationMetadataConfig; import com.yahoo.container.jdisc.JdiscBindingsConfig; -import com.yahoo.jdisc.Metric; import com.yahoo.jdisc.handler.RequestHandler; import com.yahoo.jdisc.service.ClientProvider; import com.yahoo.processing.Processor; @@ -17,11 +16,9 @@ import org.junit.Test; import org.mockito.Mockito; import java.util.HashMap; -import java.util.concurrent.Executors; import static com.yahoo.container.jdisc.JdiscBindingsConfig.Handlers; -import static org.junit.Assert.assertThat; -import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertTrue; /** * @author gjoranv @@ -30,7 +27,7 @@ import static org.hamcrest.CoreMatchers.containsString; public class ApplicationStatusHandlerTest { @Test - public void application_configs_are_rendered() throws Exception { + public void application_configs_are_rendered() { ApplicationMetadataConfig metaConfig = new ApplicationMetadataConfig( new ApplicationMetadataConfig.Builder() .checksum("abc") @@ -44,28 +41,28 @@ public class ApplicationStatusHandlerTest { .version("v1")); String json = ApplicationStatusHandler.renderApplicationConfigs(metaConfig, userConfig).toString(); - assertThat(json, containsString("version")); - assertThat(json, containsString("meta")); - assertThat(json, containsString("abc")); - assertThat(json, containsString("app")); - assertThat(json, containsString("/a/b/c")); - assertThat(json, containsString("3000")); - assertThat(json, containsString("donald")); - - assertThat(json, containsString("v1")); + assertTrue(json.contains("version")); + assertTrue(json.contains("meta")); + assertTrue(json.contains("abc")); + assertTrue(json.contains("app")); + assertTrue(json.contains("/a/b/c")); + assertTrue(json.contains("3000")); + assertTrue(json.contains("donald")); + + assertTrue(json.contains("v1")); } @Test - public void object_components_are_rendered() throws Exception { + public void object_components_are_rendered() { HashMap<ComponentId, Object> id2object = new HashMap<>(); id2object.put(new ComponentId("myComponent"), new Object()); String json = ApplicationStatusHandler.renderObjectComponents(id2object).toString(); - assertThat(json, containsString("myComponent")); + assertTrue(json.contains("myComponent")); } @Test - public void request_handlers_are_rendered() throws Exception { + public void request_handlers_are_rendered() { final String id = "myHandler"; final String serverBinding1 = "http://*/serverBinding"; final String serverBinding2 = "http://*/anotherServerBinding"; @@ -81,14 +78,14 @@ public class ApplicationStatusHandlerTest { .clientBindings(clientBinding)) ); String json = ApplicationStatusHandler.renderRequestHandlers(bindingsConfig, handlersById).toString(); - assertThat(json, containsString("\"" + id + "\"")); - assertThat(json, containsString(serverBinding1)); - assertThat(json, containsString(serverBinding2)); - assertThat(json, containsString(clientBinding)); + assertTrue(json.contains("\"" + id + "\"")); + assertTrue(json.contains(serverBinding1)); + assertTrue(json.contains(serverBinding2)); + assertTrue(json.contains(clientBinding)); } @Test - public void client_providers_are_rendered() throws Exception { + public void client_providers_are_rendered() { final String id = "myClient"; final String clientBinding = "http://*/clientBinding"; final String clientBinding2 = "http://*/anotherClientBinding"; @@ -105,21 +102,21 @@ public class ApplicationStatusHandlerTest { ); String json = ApplicationStatusHandler.renderRequestHandlers(bindingsConfig, clientsById).toString(); System.out.println(json); - assertThat(json, containsString("\"" + id + "\"")); - assertThat(json, containsString(clientBinding)); - assertThat(json, containsString(clientBinding2)); - assertThat(json, containsString(serverBinding)); + assertTrue(json.contains("\"" + id + "\"")); + assertTrue(json.contains(clientBinding)); + assertTrue(json.contains(clientBinding2)); + assertTrue(json.contains(serverBinding)); } @Test - public void chains_are_rendered() throws Exception { + public void chains_are_rendered() { ChainRegistry<Processor> chains = new ChainRegistry<>(); - Chain<Processor> chain = new Chain<Processor>("myChain", new VoidProcessor(new ComponentId("voidProcessor"))); + Chain<Processor> chain = new Chain<>("myChain", new VoidProcessor(new ComponentId("voidProcessor"))); chains.register(new ComponentId("myChain"), chain); String json = ApplicationStatusHandler.StatusResponse.renderChains(chains).toString(); - assertThat(json, containsString("myChain")); - assertThat(json, containsString("voidProcessor")); + assertTrue(json.contains("myChain")); + assertTrue(json.contains("voidProcessor")); } private static class VoidProcessor extends Processor { diff --git a/node-admin/pom.xml b/node-admin/pom.xml index 8fe5b2aecd1..b5808ebc699 100644 --- a/node-admin/pom.xml +++ b/node-admin/pom.xml @@ -86,12 +86,6 @@ <!-- Test --> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-junit</artifactId> - <version>2.0.0.0</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <scope>test</scope> diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/ConfigServerApiImplTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/ConfigServerApiImplTest.java index 64406fcfafa..866b7d2877a 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/ConfigServerApiImplTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/ConfigServerApiImplTest.java @@ -21,9 +21,6 @@ import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.List; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.arrayContainingInAnyOrder; -import static org.hamcrest.junit.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -88,7 +85,7 @@ public class ConfigServerApiImplTest { @Test public void testBasicParsingSingleServer() { TestPojo answer = configServerApi.get("/path", TestPojo.class); - assertThat(answer.foo, is("bar")); + assertEquals(answer.foo, "bar"); assertLogStringContainsGETForAHost(); } @@ -139,8 +136,8 @@ public class ConfigServerApiImplTest { // ignore } - String[] log = mockLog.toString().split(" "); - assertThat(log, arrayContainingInAnyOrder("GET http://host1:666/path", "GET http://host2:666/path")); + List<String> log = List.of(mockLog.toString().split(" ")); + assertTrue(log.containsAll(List.of("GET http://host1:666/path", "GET http://host2:666/path"))); } @Test diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/flags/RealFlagRepositoryTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/flags/RealFlagRepositoryTest.java index 29581fe8b4d..8c914530122 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/flags/RealFlagRepositoryTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/flags/RealFlagRepositoryTest.java @@ -6,14 +6,13 @@ import com.yahoo.vespa.flags.json.FlagData; import com.yahoo.vespa.flags.json.wire.WireFlagData; import com.yahoo.vespa.flags.json.wire.WireFlagDataList; import com.yahoo.vespa.hosted.node.admin.configserver.ConfigServerApi; -import org.hamcrest.collection.IsMapContaining; -import org.hamcrest.collection.IsMapWithSize; import org.junit.Test; import java.util.ArrayList; import java.util.Map; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -35,7 +34,7 @@ public class RealFlagRepositoryTest { when(configServerApi.get(any(), eq(WireFlagDataList.class))).thenReturn(list); Map<FlagId, FlagData> allFlagData = repository.getAllFlagData(); - assertThat(allFlagData, IsMapWithSize.aMapWithSize(1)); - assertThat(allFlagData, IsMapContaining.hasKey(new FlagId("id1"))); + assertEquals(1, allFlagData.size()); + assertTrue(allFlagData.containsKey(new FlagId("id1"))); } }
\ No newline at end of file diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/RealNodeRepositoryTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/RealNodeRepositoryTest.java index 6a21814d5da..5d15d4353e2 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/RealNodeRepositoryTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/RealNodeRepositoryTest.java @@ -23,10 +23,8 @@ import java.util.List; import java.util.Optional; import java.util.Set; -import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -103,13 +101,13 @@ public class RealNodeRepositoryTest { String dockerHostHostname = "dockerhost1.yahoo.com"; List<NodeSpec> containersToRun = nodeRepositoryApi.getNodes(dockerHostHostname); - assertThat(containersToRun.size(), is(1)); + assertEquals(1, containersToRun.size()); NodeSpec node = containersToRun.get(0); - assertThat(node.hostname(), is("host4.yahoo.com")); - assertThat(node.wantedDockerImage().get(), is(DockerImage.fromString("docker-registry.domain.tld:8080/dist/vespa:6.42.0"))); - assertThat(node.state(), is(NodeState.active)); - assertThat(node.wantedRestartGeneration().get(), is(0L)); - assertThat(node.currentRestartGeneration().get(), is(0L)); + assertEquals("host4.yahoo.com", node.hostname()); + assertEquals(DockerImage.fromString("docker-registry.domain.tld:8080/dist/vespa:6.42.0"), node.wantedDockerImage().get()); + assertEquals(NodeState.active, node.state()); + assertEquals(Long.valueOf(0), node.wantedRestartGeneration().get()); + assertEquals(Long.valueOf(0), node.currentRestartGeneration().get()); assertEquals(1, node.vcpu(), delta); assertEquals(4, node.memoryGb(), delta); assertEquals(100, node.diskGb(), delta); diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/systemd/SystemCtlTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/systemd/SystemCtlTest.java index 163c3410c4a..eea6c744bab 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/systemd/SystemCtlTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/systemd/SystemCtlTest.java @@ -6,9 +6,7 @@ import com.yahoo.vespa.hosted.node.admin.task.util.process.ChildProcessFailureEx import com.yahoo.vespa.hosted.node.admin.task.util.process.TestTerminal; import org.junit.Test; -import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; @@ -139,7 +137,7 @@ public class SystemCtlTest { systemCtl.serviceExists(taskContext, "foo"); fail(); } catch (Exception e) { - assertThat(e.getMessage(), containsString("garbage")); + assertTrue(e.getMessage().contains("garbage")); } } diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageNameTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageNameTest.java index 45e1dc73521..0ff98e2b5fe 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageNameTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageNameTest.java @@ -5,10 +5,8 @@ import org.junit.Test; import java.util.Optional; -import static org.hamcrest.CoreMatchers.containsStringIgnoringCase; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -174,7 +172,7 @@ public class YumPackageNameTest { YumPackageName.fromString("epoch:docker-engine-selinux-1.12.6-1.el7.x86_64"); fail(); } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), containsStringIgnoringCase("epoch")); + assertTrue(e.getMessage().toLowerCase().contains("epoch")); } } diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerCompressionTest.java b/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerCompressionTest.java index 01784226c9e..6f1b5eebcc4 100644 --- a/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerCompressionTest.java +++ b/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerCompressionTest.java @@ -10,8 +10,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.zip.GZIPOutputStream; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -42,7 +41,7 @@ public class FeedHandlerCompressionTest { } processedInput.append((char)readValue); } - assertThat(processedInput.toString(), is(testData)); + assertEquals(processedInput.toString(), testData); } /** @@ -64,7 +63,7 @@ public class FeedHandlerCompressionTest { } processedInput.append((char)readValue); } - assertThat(processedInput.toString(), is(testData)); + assertEquals(processedInput.toString(), testData); } } diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerV3Test.java b/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerV3Test.java index 1fd6425f945..2f4afb0c2a5 100644 --- a/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerV3Test.java +++ b/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerV3Test.java @@ -30,9 +30,8 @@ import java.io.InputStream; import java.util.concurrent.Executor; import java.util.concurrent.Executors; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -47,8 +46,8 @@ public class FeedHandlerV3Test { HttpResponse httpResponse = feedHandlerV3.handle(createRequest(1)); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); httpResponse.render(outStream); - assertThat(httpResponse.getContentType(), is("text/plain")); - assertThat(Utf8.toString(outStream.toByteArray()), is("1230 OK message trace\n")); + assertEquals(httpResponse.getContentType(), "text/plain"); + assertEquals(Utf8.toString(outStream.toByteArray()), "1230 OK message trace\n"); } @Test @@ -57,9 +56,9 @@ public class FeedHandlerV3Test { HttpResponse httpResponse = feedHandlerV3.handle(createBrokenRequest()); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); httpResponse.render(outStream); - assertThat(httpResponse.getContentType(), is("text/plain")); - assertThat(Utf8.toString(outStream.toByteArray()), startsWith("1230 ERROR ")); - assertThat(metric.get(MetricNames.PARSE_ERROR), is(1L)); + assertEquals(httpResponse.getContentType(), "text/plain"); + assertTrue(Utf8.toString(outStream.toByteArray()).startsWith("1230 ERROR ")); + assertEquals(1L, metric.get(MetricNames.PARSE_ERROR)); } @Test @@ -68,9 +67,9 @@ public class FeedHandlerV3Test { HttpResponse httpResponse = feedHandlerV3.handle(createRequest(100)); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); httpResponse.render(outStream); - assertThat(httpResponse.getContentType(), is("text/plain")); + assertEquals(httpResponse.getContentType(), "text/plain"); String result = Utf8.toString(outStream.toByteArray()); - assertThat(Splitter.on("\n").splitToList(result).size(), is(101)); + assertEquals(101, Splitter.on("\n").splitToList(result).size()); } private static DocumentTypeManager createDoctypeManager() { diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/VersionsTestCase.java b/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/VersionsTestCase.java index a13f4f79ca9..6858c4bede3 100644 --- a/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/VersionsTestCase.java +++ b/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/VersionsTestCase.java @@ -10,10 +10,9 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; /** * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> @@ -34,86 +33,86 @@ public class VersionsTestCase { private static final List<String> GARBAGE = Collections.singletonList("garbage"); @Test - public void testEmpty() throws Exception { + public void testEmpty() { Tuple2<HttpResponse, Integer> v = FeedHandler.doCheckProtocolVersion(EMPTY); - assertThat(v.first, instanceOf(ErrorHttpResponse.class)); - assertThat(v.second, is(-1)); + assertTrue(v.first instanceof ErrorHttpResponse); + assertEquals(Integer.valueOf(-1), v.second); } @Test - public void testOneTwo() throws Exception { + public void testOneTwo() { Tuple2<HttpResponse, Integer> v = FeedHandler.doCheckProtocolVersion(ONE_TWO); - assertThat(v.first, instanceOf(ErrorHttpResponse.class)); - assertThat(v.second, is(-1)); + assertTrue(v.first instanceof ErrorHttpResponse); + assertEquals(Integer.valueOf(-1), v.second); } @Test - public void testOneThree() throws Exception { + public void testOneThree() { Tuple2<HttpResponse, Integer> v = FeedHandler.doCheckProtocolVersion(ONE_THREE); - assertThat(v.first, nullValue()); - assertThat(v.second, is(3)); + assertNull(v.first); + assertEquals(Integer.valueOf(3), v.second); } @Test - public void testTwoThree() throws Exception { + public void testTwoThree() { Tuple2<HttpResponse, Integer> v = FeedHandler.doCheckProtocolVersion(TWO_THREE); - assertThat(v.first, nullValue()); - assertThat(v.second, is(3)); + assertNull(v.first); + assertEquals(Integer.valueOf(3), v.second); } @Test - public void testOneNullThree() throws Exception { + public void testOneNullThree() { Tuple2<HttpResponse, Integer> v = FeedHandler.doCheckProtocolVersion(ONE_NULL_THREE); - assertThat(v.first, nullValue()); - assertThat(v.second, is(3)); + assertNull(v.first); + assertEquals(Integer.valueOf(3), v.second); } @Test - public void testOneCommaThree() throws Exception { + public void testOneCommaThree() { Tuple2<HttpResponse, Integer> v = FeedHandler.doCheckProtocolVersion(ONE_COMMA_THREE); - assertThat(v.first, nullValue()); - assertThat(v.second, is(3)); + assertNull(v.first); + assertEquals(Integer.valueOf(3), v.second); } @Test - public void testOneEmptyThree() throws Exception { + public void testOneEmptyThree() { Tuple2<HttpResponse, Integer> v = FeedHandler.doCheckProtocolVersion(ONE_EMPTY_THREE); - assertThat(v.first, nullValue()); - assertThat(v.second, is(3)); + assertNull(v.first); + assertEquals(Integer.valueOf(3), v.second); } @Test public void testTooLarge() throws Exception { Tuple2<HttpResponse, Integer> v = FeedHandler.doCheckProtocolVersion(TOO_LARGE_NUMBER); - assertThat(v.first, instanceOf(ErrorHttpResponse.class)); + assertTrue(v.first instanceof ErrorHttpResponse); ByteArrayOutputStream errorMsg = new ByteArrayOutputStream(); ErrorHttpResponse errorResponse = (ErrorHttpResponse) v.first; errorResponse.render(errorMsg); - assertThat(errorMsg.toString(), - is("Could not parse X-Yahoo-Feed-Protocol-Versionheader of request (values: [1000000000]). " + - "Server supports protocol versions [3]")); - assertThat(v.second, is(-1)); + assertEquals(errorMsg.toString(), + "Could not parse X-Yahoo-Feed-Protocol-Versionheader of request (values: [1000000000]). " + + "Server supports protocol versions [3]"); + assertEquals(Integer.valueOf(-1), v.second); } @Test - public void testThreeTooLarge() throws Exception { + public void testThreeTooLarge() { Tuple2<HttpResponse, Integer> v = FeedHandler.doCheckProtocolVersion(THREE_TOO_LARGE_NUMBER); - assertThat(v.first, nullValue()); - assertThat(v.second, is(3)); + assertNull(v.first); + assertEquals(Integer.valueOf(3), v.second); } @Test - public void testTwoCommaTooLarge() throws Exception { + public void testTwoCommaTooLarge() { Tuple2<HttpResponse, Integer> v = FeedHandler.doCheckProtocolVersion(THREE_COMMA_TOO_LARGE_NUMBER); - assertThat(v.first, nullValue()); - assertThat(v.second, is(3)); + assertNull(v.first); + assertEquals(Integer.valueOf(3), v.second); } @Test - public void testGarbage() throws Exception { + public void testGarbage() { Tuple2<HttpResponse, Integer> v = FeedHandler.doCheckProtocolVersion(GARBAGE); - assertThat(v.first, instanceOf(ErrorHttpResponse.class)); - assertThat(v.second, is(-1)); + assertTrue(v.first instanceof ErrorHttpResponse); + assertEquals(Integer.valueOf(-1), v.second); } } diff --git a/yolean/src/test/java/com/yahoo/yolean/chain/ChainBuilderTest.java b/yolean/src/test/java/com/yahoo/yolean/chain/ChainBuilderTest.java index 349ba8998bd..1d5b6a6cac7 100644 --- a/yolean/src/test/java/com/yahoo/yolean/chain/ChainBuilderTest.java +++ b/yolean/src/test/java/com/yahoo/yolean/chain/ChainBuilderTest.java @@ -10,7 +10,6 @@ import java.util.List; import static com.yahoo.yolean.chain.Dependencies.after; import static com.yahoo.yolean.chain.Dependencies.before; import static com.yahoo.yolean.chain.Dependencies.provides; -import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; |