aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-12-19 14:21:48 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2021-12-19 14:21:48 +0100
commit87ed9372267b3e73714b6f0130b86eb29d3e23d7 (patch)
treec0b9754e5c230df9cb6f2ff7c93727ee7bb27e7e
parent63da9a412b31fb1badc787e4ae8550a0c2b50fc0 (diff)
Simnplify testing by sticking to assertEquals/True/False
-rw-r--r--container-disc/src/test/java/com/yahoo/container/jdisc/FilterBindingsProviderTest.java14
-rw-r--r--container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/ClientThreadingTestCase.java9
-rw-r--r--container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/MbusServerConformanceTest.java127
-rw-r--r--container-messagebus/src/test/java/com/yahoo/messagebus/jdisc/ServerThreadingTestCase.java27
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/ConfigServerApiImplTest.java3
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/flags/RealFlagRepositoryTest.java9
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/RealNodeRepositoryTest.java12
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/systemd/SystemCtlTest.java4
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageNameTest.java4
-rw-r--r--vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerCompressionTest.java7
-rw-r--r--vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerV3Test.java19
-rw-r--r--vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/VersionsTestCase.java77
12 files changed, 149 insertions, 163 deletions
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/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..db33d0b300f 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,7 +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;
@@ -88,7 +87,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();
}
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..70987faa54d 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
@@ -103,13 +103,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);
}
}