summaryrefslogtreecommitdiffstats
path: root/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java')
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java44
1 files changed, 20 insertions, 24 deletions
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java
index 1ce7586adea..79c03a67698 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java
@@ -4,22 +4,16 @@ package com.yahoo.vespa.clustercontroller.core;
import com.yahoo.vespa.clustercontroller.core.database.CasWriteFailed;
import com.yahoo.vespa.clustercontroller.core.database.Database;
import com.yahoo.vespa.clustercontroller.core.database.ZooKeeperDatabase;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.time.Duration;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
public class ZooKeeperDatabaseTest {
- @SuppressWarnings("deprecation")
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
private static class Fixture implements AutoCloseable {
final ZooKeeperTestServer zkServer;
ClusterFixture clusterFixture;
@@ -58,7 +52,7 @@ public class ZooKeeperDatabaseTest {
}
@Test
- public void can_store_and_load_cluster_state_bundle_from_database() throws Exception {
+ void can_store_and_load_cluster_state_bundle_from_database() throws Exception {
try (Fixture f = new Fixture()) {
f.createDatabase();
f.db().retrieveLastPublishedStateBundle(); // Must be called once prior to prime last known znode version
@@ -77,27 +71,29 @@ public class ZooKeeperDatabaseTest {
}
@Test
- public void storing_cluster_state_bundle_with_mismatching_expected_znode_version_throws_exception() throws Exception {
- expectedException.expect(CasWriteFailed.class);
- expectedException.expectMessage("version mismatch in cluster state bundle znode (expected -2)");
- try (Fixture f = new Fixture()) {
- f.createDatabase();
- f.db().storeLastPublishedStateBundle(dummyBundle());
- }
+ void storing_cluster_state_bundle_with_mismatching_expected_znode_version_throws_exception() throws Exception {
+ Throwable exception = assertThrows(CasWriteFailed.class, () -> {
+ try (Fixture f = new Fixture()) {
+ f.createDatabase();
+ f.db().storeLastPublishedStateBundle(dummyBundle());
+ }
+ });
+ assertTrue(exception.getMessage().contains("version mismatch in cluster state bundle znode (expected -2)"));
}
@Test
- public void storing_cluster_state_version_with_mismatching_expected_znode_version_throws_exception() throws Exception {
- expectedException.expect(CasWriteFailed.class);
- expectedException.expectMessage("version mismatch in cluster state version znode (expected -2)");
- try (Fixture f = new Fixture()) {
- f.createDatabase();
- f.db().storeLatestSystemStateVersion(12345);
- }
+ void storing_cluster_state_version_with_mismatching_expected_znode_version_throws_exception() throws Exception {
+ Throwable exception = assertThrows(CasWriteFailed.class, () -> {
+ try (Fixture f = new Fixture()) {
+ f.createDatabase();
+ f.db().storeLatestSystemStateVersion(12345);
+ }
+ });
+ assertTrue(exception.getMessage().contains("version mismatch in cluster state version znode (expected -2)"));
}
@Test
- public void empty_state_bundle_is_returned_if_no_bundle_already_stored_in_database() throws Exception {
+ void empty_state_bundle_is_returned_if_no_bundle_already_stored_in_database() throws Exception {
try (Fixture f = new Fixture()) {
f.createDatabase();
ClusterStateBundle bundleReceived = f.db().retrieveLastPublishedStateBundle();