diff --git a/pom.xml b/pom.xml index 966ba41..e64b825 100644 --- a/pom.xml +++ b/pom.xml @@ -96,7 +96,7 @@ https://sonarcloud.io -Xdoclint:none - 2.0.29 + 2.1.10 5.5.0 9+181-r4173-1 diff --git a/src/test/java/io/dropwizard/discovery/DiscoveryBundleIntegrationTest.java b/src/test/java/io/dropwizard/discovery/DiscoveryBundleIntegrationTest.java index e21b2e6..3dd7a44 100644 --- a/src/test/java/io/dropwizard/discovery/DiscoveryBundleIntegrationTest.java +++ b/src/test/java/io/dropwizard/discovery/DiscoveryBundleIntegrationTest.java @@ -10,9 +10,8 @@ import org.apache.curator.test.TestingServer; import org.apache.curator.x.discovery.ServiceInstance; import org.apache.curator.x.discovery.details.InstanceSerializer; -import org.junit.ClassRule; -import org.junit.Test; - +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.type.TypeReference; import io.dropwizard.discovery.core.InstanceMetadata; @@ -20,15 +19,16 @@ import io.dropwizard.discovery.testutil.TestApplication; import io.dropwizard.discovery.testutil.TestConfiguration; import io.dropwizard.testing.ResourceHelpers; -import io.dropwizard.testing.junit.DropwizardAppRule; +import io.dropwizard.testing.junit5.DropwizardAppExtension; +import io.dropwizard.testing.junit5.DropwizardExtensionsSupport; +@ExtendWith(DropwizardExtensionsSupport.class) public class DiscoveryBundleIntegrationTest { private static final String NAMESPACE = "dropwizard"; private static final String SERVICE_NAME = "test-service"; private static final String SERVICE_PATH = "/service/" + SERVICE_NAME; - @ClassRule - public static final DropwizardAppRule RULE = new DropwizardAppRule( + public static final DropwizardAppExtension RULE = new DropwizardAppExtension( TestApplication.class, ResourceHelpers.resourceFilePath("test-config.yaml")); InstanceSerializer serializer = new JacksonInstanceSerializer( @@ -40,7 +40,7 @@ private String instancePath(String instanceNode) { } @Test - public void testRegistration() throws Exception { + void testRegistration() throws Exception { // use a separate instance of curator to pull out the app's data TestingServer testingServer = RULE.getConfiguration().getTestingServer(); try (final CuratorFramework curatorFramework = CuratorFrameworkFactory @@ -60,4 +60,4 @@ public void testRegistration() throws Exception { assertThat(serviceInstanceMetadata.getName()).isEqualTo(SERVICE_NAME); } } -} \ No newline at end of file +} diff --git a/src/test/java/io/dropwizard/discovery/DiscoveryFactoryTest.java b/src/test/java/io/dropwizard/discovery/DiscoveryFactoryTest.java index 123e42c..409c03b 100644 --- a/src/test/java/io/dropwizard/discovery/DiscoveryFactoryTest.java +++ b/src/test/java/io/dropwizard/discovery/DiscoveryFactoryTest.java @@ -3,7 +3,7 @@ import io.dropwizard.util.Duration; import org.apache.curator.RetryPolicy; import org.apache.curator.retry.ExponentialBackoffRetry; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown; @@ -12,22 +12,22 @@ public class DiscoveryFactoryTest { private final DiscoveryFactory factory = new DiscoveryFactory(); @Test - public void testGetHosts() { + void testGetHosts() { assertThat(factory.getHosts()).containsOnly("localhost"); } @Test - public void testGetPort() { + void testGetPort() { assertThat(factory.getPort()).isEqualTo(2181); } @Test - public void testGetQuorumSpec() { + void testGetQuorumSpec() { assertThat(factory.getQuorumSpec()).isEqualTo("localhost:2181"); } @Test - public void testServiceNameAccessors() { + void testServiceNameAccessors() { assertThat(factory.getServiceName()).isEqualTo(""); factory.setServiceName("test-service-name"); try { @@ -39,7 +39,7 @@ public void testServiceNameAccessors() { } @Test - public void testNamespaceAccessors() { + void testNamespaceAccessors() { assertThat(factory.getNamespace()).isEqualTo("dropwizard"); factory.setNamespace("test-namespace"); try { @@ -51,7 +51,7 @@ public void testNamespaceAccessors() { } @Test - public void testBasePathAccessors() { + void testBasePathAccessors() { assertThat(factory.getBasePath()).isEqualTo("service"); factory.setBasePath("test-base-path"); try { @@ -63,7 +63,7 @@ public void testBasePathAccessors() { } @Test - public void testListenAddressAccessors() { + void testListenAddressAccessors() { assertThat(factory.getListenAddress()).isEqualTo(""); factory.setListenAddress("0.0.0.0"); try { @@ -75,7 +75,7 @@ public void testListenAddressAccessors() { } @Test - public void testConnectionTimeoutAccessors() { + void testConnectionTimeoutAccessors() { assertThat(factory.getConnectionTimeout()).isEqualTo(Duration.seconds(6)); factory.setConnectionTimeout(Duration.minutes(30)); try { @@ -87,7 +87,7 @@ public void testConnectionTimeoutAccessors() { } @Test - public void testSessionTimeoutAccessors() { + void testSessionTimeoutAccessors() { assertThat(factory.getSessionTimeout()).isEqualTo(Duration.seconds(6)); factory.setSessionTimeout(Duration.minutes(30)); try { @@ -99,28 +99,28 @@ public void testSessionTimeoutAccessors() { } @Test - public void testIsDisabledAccessors() { + void testIsDisabledAccessors() { assertThat(factory.isDisabled()).isFalse(); factory.setIsDisabled(true); assertThat(factory.isDisabled()).isTrue(); } @Test - public void testIsReadOnlyAccessors() { + void testIsReadOnlyAccessors() { assertThat(factory.isReadOnly()).isFalse(); factory.setIsReadOnly(true); assertThat(factory.isReadOnly()).isTrue(); } @Test - public void testMaxRetriesAccessors() { + void testMaxRetriesAccessors() { assertThat(factory.getMaxRetries()).isEqualTo(5); factory.setMaxRetries(20); assertThat(factory.getMaxRetries()).isEqualTo(20); } @Test - public void testBaseSleepTimeAccessors() { + void testBaseSleepTimeAccessors() { assertThat(factory.getBaseSleepTime()).isEqualTo(Duration.seconds(1)); factory.setBaseSleepTime(Duration.minutes(30)); try { @@ -132,7 +132,7 @@ public void testBaseSleepTimeAccessors() { } @Test - public void testGetRetryPolicy() { + void testGetRetryPolicy() { DiscoveryFactory factory = new DiscoveryFactory(); RetryPolicy retryPolicy = factory.getRetryPolicy(); assertThat(retryPolicy).isInstanceOf(ExponentialBackoffRetry.class); @@ -142,7 +142,7 @@ public void testGetRetryPolicy() { } @Test - public void testGetCompressionProvider() { + void testGetCompressionProvider() { assertThat(factory.getCompressionProvider()).isEqualTo(DiscoveryFactory.CompressionCodec.GZIP.getProvider()); } } diff --git a/src/test/java/io/dropwizard/discovery/client/DiscoveryClientManagerTest.java b/src/test/java/io/dropwizard/discovery/client/DiscoveryClientManagerTest.java index cc3f22f..ac9b025 100644 --- a/src/test/java/io/dropwizard/discovery/client/DiscoveryClientManagerTest.java +++ b/src/test/java/io/dropwizard/discovery/client/DiscoveryClientManagerTest.java @@ -1,11 +1,11 @@ package io.dropwizard.discovery.client; -import org.junit.Test; - import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import org.junit.jupiter.api.Test; + public class DiscoveryClientManagerTest { @SuppressWarnings("unchecked") @@ -14,7 +14,7 @@ public class DiscoveryClientManagerTest { DiscoveryClientManager manager = new DiscoveryClientManager(client); @Test - public void testConstructorInvalidClient() { + void testConstructorInvalidClient() { try { new DiscoveryClientManager(null); failBecauseExceptionWasNotThrown(NullPointerException.class); @@ -23,13 +23,13 @@ public void testConstructorInvalidClient() { } @Test - public void testStart() throws Exception { + void testStart() throws Exception { manager.start(); verify(client).start(); } @Test - public void testStop() throws Exception { + void testStop() throws Exception { manager.stop(); verify(client).close(); } diff --git a/src/test/java/io/dropwizard/discovery/client/DiscoveryClientTest.java b/src/test/java/io/dropwizard/discovery/client/DiscoveryClientTest.java index 63cb30d..7f741e1 100644 --- a/src/test/java/io/dropwizard/discovery/client/DiscoveryClientTest.java +++ b/src/test/java/io/dropwizard/discovery/client/DiscoveryClientTest.java @@ -1,9 +1,8 @@ package io.dropwizard.discovery.client; import org.apache.curator.x.discovery.*; -import org.junit.Before; -import org.junit.Test; - +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Arrays; @@ -34,7 +33,7 @@ public class DiscoveryClientTest { @SuppressWarnings("unchecked") ServiceCache serviceCache = mock(ServiceCache.class); - @Before + @BeforeEach public void setup() throws Exception { @SuppressWarnings("unchecked") ServiceProviderBuilder serviceProviderBuilder = mock(ServiceProviderBuilder.class); @@ -61,7 +60,7 @@ public void setup() throws Exception { @SuppressWarnings("resource") @Test - public void testConstructorInvalidServiceName() { + void testConstructorInvalidServiceName() { try { new DiscoveryClient(null, discovery, downInstancePolicy, providerStrategy); failBecauseExceptionWasNotThrown(NullPointerException.class); @@ -77,7 +76,7 @@ public void testConstructorInvalidServiceName() { @SuppressWarnings("resource") @Test - public void testConstructorInvalidProviderStrategy() { + void testConstructorInvalidProviderStrategy() { try { new DiscoveryClient(SERVICE_NAME, discovery, downInstancePolicy, null); failBecauseExceptionWasNotThrown(NullPointerException.class); @@ -87,7 +86,7 @@ public void testConstructorInvalidProviderStrategy() { @SuppressWarnings("resource") @Test - public void testConstructorInvalidServiceDiscovery() { + void testConstructorInvalidServiceDiscovery() { try { new DiscoveryClient(SERVICE_NAME, null, downInstancePolicy, providerStrategy); failBecauseExceptionWasNotThrown(NullPointerException.class); @@ -96,47 +95,47 @@ public void testConstructorInvalidServiceDiscovery() { } @Test - public void testGetServices() throws Exception { + void testGetServices() throws Exception { assertThat(client.getServices()).containsOnly("service-one", "service-two", "service-three"); } @Test - public void testGetInstancesByName() throws Exception { + void testGetInstancesByName() throws Exception { assertThat(client.getInstances("service-one")).containsOnly(instanceOne, instanceTwo, instanceThree); } @Test - public void testGetInstances() { + void testGetInstances() { assertThat(client.getInstances()).containsOnly(instanceOne, instanceTwo, instanceThree); } @Test - public void testGetInstance() throws Exception { + void testGetInstance() throws Exception { assertThat(client.getInstance()).isEqualTo(instanceOne); } @Test - public void testNoteError() { + void testNoteError() { client.noteError(instanceOne); verify(serviceProvider).noteError(instanceOne); } @Test - public void testStart() throws Exception { + void testStart() throws Exception { client.start(); verify(serviceProvider).start(); verify(serviceCache).start(); } @Test - public void testClose() throws Exception { + void testClose() throws Exception { client.close(); verify(serviceCache).close(); verify(serviceProvider).close(); } @Test - public void testCloseWithExceptionInCacheClose() throws Exception { + void testCloseWithExceptionInCacheClose() throws Exception { doThrow(IOException.class).when(serviceCache).close(); client.close(); verify(serviceCache).close(); @@ -144,7 +143,7 @@ public void testCloseWithExceptionInCacheClose() throws Exception { } @Test - public void testCloseWithExceptionInProviderClose() throws Exception { + void testCloseWithExceptionInProviderClose() throws Exception { doThrow(IOException.class).when(serviceProvider).close(); client.close(); verify(serviceCache).close(); diff --git a/src/test/java/io/dropwizard/discovery/core/CuratorAdvertiserTest.java b/src/test/java/io/dropwizard/discovery/core/CuratorAdvertiserTest.java index 44d22c7..41c5cbf 100644 --- a/src/test/java/io/dropwizard/discovery/core/CuratorAdvertiserTest.java +++ b/src/test/java/io/dropwizard/discovery/core/CuratorAdvertiserTest.java @@ -7,8 +7,8 @@ import java.util.Optional; import org.apache.curator.x.discovery.ServiceDiscovery; import org.apache.curator.x.discovery.ServiceInstance; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import io.dropwizard.discovery.DiscoveryFactory; public class CuratorAdvertiserTest { @@ -20,13 +20,13 @@ public class CuratorAdvertiserTest { private final CuratorAdvertiser advertiser = new CuratorAdvertiser( factory, discovery, new DefaultServiceInstanceFactory()); - @Before + @BeforeEach public void setUp() { factory.setServiceName("test-service"); } @Test - public void testInitListenInfo() throws Exception { + void testInitListenInfo() throws Exception { factory.setListenAddress("127.0.0.1"); advertiser.initListenInfo(8080, 8180); assertThat(advertiser.getListenPort()).isEqualTo(8080); @@ -35,7 +35,7 @@ public void testInitListenInfo() throws Exception { } @Test - public void testInitListenInfoNoAdmin() throws Exception { + void testInitListenInfoNoAdmin() throws Exception { factory.setListenAddress("127.0.0.1"); advertiser.initListenInfo(8080, null); assertThat(advertiser.getListenPort()).isEqualTo(8080); @@ -45,7 +45,7 @@ public void testInitListenInfoNoAdmin() throws Exception { } @Test - public void testCheckInitialized() throws Exception { + void testCheckInitialized() throws Exception { try { advertiser.checkInitialized(); failBecauseExceptionWasNotThrown(IllegalStateException.class); @@ -57,7 +57,7 @@ public void testCheckInitialized() throws Exception { } @Test - public void testRegisterAvailability() throws Exception { + void testRegisterAvailability() throws Exception { try { advertiser.registerAvailability(); failBecauseExceptionWasNotThrown(IllegalStateException.class); @@ -72,7 +72,7 @@ public void testRegisterAvailability() throws Exception { } @Test - public void testUnregisterAvailability() throws Exception { + void testUnregisterAvailability() throws Exception { try { advertiser.unregisterAvailability(); failBecauseExceptionWasNotThrown(IllegalStateException.class); diff --git a/src/test/java/io/dropwizard/discovery/core/CuratorFactoryTest.java b/src/test/java/io/dropwizard/discovery/core/CuratorFactoryTest.java index 2e9f6cc..234b9f0 100644 --- a/src/test/java/io/dropwizard/discovery/core/CuratorFactoryTest.java +++ b/src/test/java/io/dropwizard/discovery/core/CuratorFactoryTest.java @@ -13,9 +13,8 @@ import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.api.CompressionProvider; import org.apache.curator.test.TestingServer; -import org.junit.Before; -import org.junit.Test; - +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.codahale.metrics.health.HealthCheckRegistry; import io.dropwizard.discovery.DiscoveryFactory; @@ -43,7 +42,7 @@ public class CuratorFactoryTest { private CuratorFactory factory; - @Before + @BeforeEach public void setup() throws Exception { testingServer = new TestingServer(); @@ -64,7 +63,7 @@ public void setup() throws Exception { } @Test - public void testConstructorInvalidEnvironment() { + void testConstructorInvalidEnvironment() { try { new CuratorFactory(null); failBecauseExceptionWasNotThrown(NullPointerException.class); @@ -73,7 +72,7 @@ public void testConstructorInvalidEnvironment() { } @Test - public void testBuild() { + void testBuild() { factory.build(discoveryFactory); verify(lifecycle).manage(any(CuratorManager.class)); verify(healthchecks).register(eq("curator"), any(CuratorHealthCheck.class)); @@ -90,7 +89,7 @@ public void testBuild() { } @Test - public void testConnectionTimeout() { + void testConnectionTimeout() { CuratorFramework curatorFramework = factory.build(discoveryFactory); assertThat(curatorFramework.getZookeeperClient().getConnectionTimeoutMs()) .isEqualTo(connectionTimeout.toMilliseconds()); @@ -99,7 +98,7 @@ public void testConnectionTimeout() { // TODO: session timeout @Test - public void testRetryPolicy() { + void testRetryPolicy() { CuratorFramework curatorFramework = factory.build(discoveryFactory); assertThat(curatorFramework.getZookeeperClient().getRetryPolicy()).isEqualTo(retryPolicy); } @@ -107,7 +106,7 @@ public void testRetryPolicy() { // TODO: compression provider @Test - public void testQuorumSpec() { + void testQuorumSpec() { CuratorFramework curatorFramework = factory.build(discoveryFactory); assertThat(curatorFramework.getZookeeperClient().getCurrentConnectionString()) .isEqualTo(testingServer.getConnectString()); @@ -116,7 +115,7 @@ public void testQuorumSpec() { // TODO: read-only @Test - public void testNamespace() { + void testNamespace() { CuratorFramework curatorFramework = factory.build(discoveryFactory); assertThat(curatorFramework.getNamespace()).isEqualTo(namespace); } diff --git a/src/test/java/io/dropwizard/discovery/core/InstanceMetadataTest.java b/src/test/java/io/dropwizard/discovery/core/InstanceMetadataTest.java index a019501..91a2eac 100644 --- a/src/test/java/io/dropwizard/discovery/core/InstanceMetadataTest.java +++ b/src/test/java/io/dropwizard/discovery/core/InstanceMetadataTest.java @@ -4,8 +4,7 @@ import java.util.Optional; import java.util.UUID; - -import org.junit.Test; +import org.junit.jupiter.api.Test; public class InstanceMetadataTest { @@ -18,41 +17,41 @@ public class InstanceMetadataTest { Optional.of(ADMIN_PORT)); @Test - public void testGetInstance() { + void testGetInstance() { assertThat(metadata.getInstanceId()).isEqualTo(INSTANCE_ID); } @Test - public void testGetListenAddress() { + void testGetListenAddress() { assertThat(metadata.getListenAddress()).isEqualTo(LISTEN_ADDRESS); } @Test - public void testGetListenPort() { + void testGetListenPort() { assertThat(metadata.getListenPort()).isEqualTo(LISTEN_PORT); } @Test - public void testGetAdminPort() { + void testGetAdminPort() { assertThat(metadata.getAdminPort().isPresent()).isTrue(); assertThat(metadata.getAdminPort().get()).isEqualTo(ADMIN_PORT); } @Test - public void testGetAdminPortNull() { + void testGetAdminPortNull() { InstanceMetadata metadataAdminPortNull = new InstanceMetadata(INSTANCE_ID, LISTEN_ADDRESS, LISTEN_PORT, null); assertThat(metadataAdminPortNull.getAdminPort().isPresent()).isFalse(); } @Test - public void testGetAdminPortNotPresent() { + void testGetAdminPortNotPresent() { InstanceMetadata metadataAdminPortNotPresent = new InstanceMetadata(INSTANCE_ID, LISTEN_ADDRESS, LISTEN_PORT, Optional.empty()); assertThat(metadataAdminPortNotPresent.getAdminPort().isPresent()).isFalse(); } @Test - public void testEquals() { + void testEquals() { assertThat(metadata).isEqualTo(metadata); assertThat(metadata).isNotEqualTo(null); @@ -85,7 +84,7 @@ public void testEquals() { } @Test - public void testHashCode() { + void testHashCode() { assertThat(metadata.hashCode()).isEqualTo(metadata.hashCode()); InstanceMetadata equal = new InstanceMetadata(INSTANCE_ID, LISTEN_ADDRESS, LISTEN_PORT, Optional.of(ADMIN_PORT)); @@ -93,7 +92,7 @@ public void testHashCode() { } @Test - public void testToString() { + void testToString() { StringBuilder expectedString = new StringBuilder("InstanceMetadata{") .append("instanceId=").append(INSTANCE_ID.toString()).append(", ") .append("listenAddress=").append(LISTEN_ADDRESS).append(", ") diff --git a/src/test/java/io/dropwizard/discovery/health/CuratorHealthCheckTest.java b/src/test/java/io/dropwizard/discovery/health/CuratorHealthCheckTest.java index 3ecf380..7de5737 100644 --- a/src/test/java/io/dropwizard/discovery/health/CuratorHealthCheckTest.java +++ b/src/test/java/io/dropwizard/discovery/health/CuratorHealthCheckTest.java @@ -8,8 +8,8 @@ import org.apache.curator.framework.api.ExistsBuilder; import org.apache.curator.framework.imps.CuratorFrameworkState; import org.apache.zookeeper.data.Stat; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class CuratorHealthCheckTest { @@ -17,25 +17,25 @@ public class CuratorHealthCheckTest { private final ExistsBuilder exists = mock(ExistsBuilder.class); private final CuratorHealthCheck health = new CuratorHealthCheck(framework); - @Before + @BeforeEach public void setUp() { when(framework.checkExists()).thenReturn(exists); } @Test - public void testCheckHealthy() throws Exception { + void testCheckHealthy() throws Exception { when(framework.getState()).thenReturn(CuratorFrameworkState.STARTED); when(exists.forPath(anyString())).thenReturn(new Stat()); assertThat(health.check().isHealthy()).isTrue(); } @Test - public void testCheckNotStarted() throws Exception { + void testCheckNotStarted() throws Exception { assertThat(health.check().isHealthy()).isFalse(); } @Test - public void testCheckMissingRoot() throws Exception { + void testCheckMissingRoot() throws Exception { when(framework.getState()).thenReturn(CuratorFrameworkState.STARTED); when(exists.forPath(anyString())).thenReturn(null); assertThat(health.check().isHealthy()).isFalse(); diff --git a/src/test/java/io/dropwizard/discovery/manage/CuratorAdvertiserManagerTest.java b/src/test/java/io/dropwizard/discovery/manage/CuratorAdvertiserManagerTest.java index 4d30a55..07a20bc 100644 --- a/src/test/java/io/dropwizard/discovery/manage/CuratorAdvertiserManagerTest.java +++ b/src/test/java/io/dropwizard/discovery/manage/CuratorAdvertiserManagerTest.java @@ -4,7 +4,7 @@ import static org.mockito.Mockito.verify; import io.dropwizard.discovery.core.CuratorAdvertiser; import io.dropwizard.discovery.core.InstanceMetadata; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CuratorAdvertiserManagerTest { @@ -13,7 +13,7 @@ public class CuratorAdvertiserManagerTest { advertiser); @Test - public void testStop() throws Exception { + void testStop() throws Exception { manager.stop(); verify(advertiser).unregisterAvailability(); } diff --git a/src/test/java/io/dropwizard/discovery/manage/CuratorManagerTest.java b/src/test/java/io/dropwizard/discovery/manage/CuratorManagerTest.java index f188485..c7d831b 100644 --- a/src/test/java/io/dropwizard/discovery/manage/CuratorManagerTest.java +++ b/src/test/java/io/dropwizard/discovery/manage/CuratorManagerTest.java @@ -10,9 +10,9 @@ import org.apache.curator.framework.api.ExistsBuilder; import org.apache.curator.framework.api.ProtectACLCreateModeStatPathAndBytesable; import org.apache.zookeeper.data.Stat; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class CuratorManagerTest { @@ -24,34 +24,34 @@ public class CuratorManagerTest { ProtectACLCreateModeStatPathAndBytesable.class); private final CuratorManager manager = new CuratorManager(framework); - @Before + @BeforeEach public void setUp() { when(framework.create()).thenReturn(create); when(framework.checkExists()).thenReturn(exists); when(create.creatingParentsIfNeeded()).thenReturn(acl); } - @After + @AfterEach public void tearDown() { reset(framework); } @Test - public void testStartRootExists() throws Exception { + void testStartRootExists() throws Exception { when(exists.forPath("/")).thenReturn(new Stat()); manager.start(); verify(framework, never()).create(); } @Test - public void testStartRootMissing() throws Exception { + void testStartRootMissing() throws Exception { when(exists.forPath("/")).thenReturn(null); manager.start(); verify(framework).create(); } @Test - public void testStop() throws Exception { + void testStop() throws Exception { manager.stop(); verify(framework).close(); } diff --git a/src/test/java/io/dropwizard/discovery/manage/ServiceDiscoveryManagerTest.java b/src/test/java/io/dropwizard/discovery/manage/ServiceDiscoveryManagerTest.java index 783d613..0b392a8 100644 --- a/src/test/java/io/dropwizard/discovery/manage/ServiceDiscoveryManagerTest.java +++ b/src/test/java/io/dropwizard/discovery/manage/ServiceDiscoveryManagerTest.java @@ -3,7 +3,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import org.apache.curator.x.discovery.ServiceDiscovery; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ServiceDiscoveryManagerTest { @@ -13,13 +13,13 @@ public class ServiceDiscoveryManagerTest { discovery); @Test - public void testStart() throws Exception { + void testStart() throws Exception { manager.start(); verify(discovery).start(); } @Test - public void testStop() throws Exception { + void testStop() throws Exception { manager.stop(); verify(discovery).close(); }