From 0fb623fe6310f894eb24797c56539694d4f44386 Mon Sep 17 00:00:00 2001 From: Masahiro Sakamoto Date: Fri, 5 Nov 2021 19:11:57 +0900 Subject: [PATCH] Add @Test annotation to test methods --- .../apache/pulsar/broker/admin/PersistentTopicsTest.java | 1 + .../intercept/BrokerInterceptorWithClassLoaderTest.java | 1 + .../broker/protocol/ProtocolHandlerWithClassLoaderTest.java | 1 + .../broker/resourcegroup/ResourceGroupRateLimiterTest.java | 2 +- .../pulsar/broker/stats/ManagedCursorMetricsTest.java | 1 + .../pulsar/client/api/SimpleProducerConsumerStatTest.java | 1 + .../src/test/java/org/apache/pulsar/schema/SchemaTest.java | 1 + .../java/org/apache/pulsar/admin/cli/TestCmdClusters.java | 3 ++- .../test/java/org/apache/pulsar/admin/cli/TestCmdSinks.java | 6 +++--- .../java/org/apache/pulsar/admin/cli/TestCmdSources.java | 6 +++--- .../runtime/kubernetes/KubernetesRuntimeFactoryTest.java | 2 +- .../functions/runtime/kubernetes/KubernetesRuntimeTest.java | 3 ++- .../io/elasticsearch/ElasticSearchClientSslTests.java | 2 +- .../pulsar/io/elasticsearch/ElasticSearchSinkTests.java | 2 +- .../proxy/extensions/ProxyExtensionWithClassLoaderTest.java | 1 + .../tests/integration/functions/PulsarFunctionsTest.java | 4 ++-- .../pulsar/tests/integration/offload/TestBaseOffload.java | 6 +++--- .../pulsar/tests/integration/topologies/PulsarTestBase.java | 6 +++--- .../offload/jcloud/impl/BufferedOffloadStreamTest.java | 2 +- 19 files changed, 30 insertions(+), 21 deletions(-) diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java index 9c3221d7d6ab6..0333a0b44e811 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java @@ -921,6 +921,7 @@ public void testSetReplicatedSubscriptionStatus() { Assert.assertEquals(responseCaptor.getValue().getStatus(), Response.Status.NO_CONTENT.getStatusCode()); } + @Test public void testGetMessageById() throws Exception { TenantInfoImpl tenantInfo = new TenantInfoImpl(Sets.newHashSet("role1", "role2"), Sets.newHashSet("test")); admin.tenants().createTenant("tenant-xyz", tenantInfo); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/intercept/BrokerInterceptorWithClassLoaderTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/intercept/BrokerInterceptorWithClassLoaderTest.java index aa4a5bc4562f1..ae669373ded70 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/intercept/BrokerInterceptorWithClassLoaderTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/intercept/BrokerInterceptorWithClassLoaderTest.java @@ -33,6 +33,7 @@ @Test(groups = "broker") public class BrokerInterceptorWithClassLoaderTest { + @Test public void testWrapper() throws Exception { BrokerInterceptor h = mock(BrokerInterceptor.class); NarClassLoader loader = mock(NarClassLoader.class); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/protocol/ProtocolHandlerWithClassLoaderTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/protocol/ProtocolHandlerWithClassLoaderTest.java index 42d26d53f27c6..75d8c646b6bc8 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/protocol/ProtocolHandlerWithClassLoaderTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/protocol/ProtocolHandlerWithClassLoaderTest.java @@ -74,6 +74,7 @@ public void testWrapper() throws Exception { verify(h, times(1)).getProtocolDataToAdvertise(); } + @Test public void testClassLoaderSwitcher() throws Exception { NarClassLoader loader = mock(NarClassLoader.class); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupRateLimiterTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupRateLimiterTest.java index 395f0869c287b..1887801dfe844 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupRateLimiterTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupRateLimiterTest.java @@ -80,7 +80,7 @@ public void deleteResourceGroup(String rgName) throws PulsarAdminException { .untilAsserted(() -> assertNull(pulsar.getResourceGroupServiceManager().resourceGroupGet(rgName))); } - public void testRateLimit() throws PulsarAdminException, PulsarClientException, + private void testRateLimit() throws PulsarAdminException, PulsarClientException, InterruptedException, ExecutionException, TimeoutException { createResourceGroup(rgName, testAddRg); admin.namespaces().setNamespaceResourceGroup(namespaceName, rgName); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/ManagedCursorMetricsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/ManagedCursorMetricsTest.java index 9b3b354aa28df..5e20c09fed1dd 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/ManagedCursorMetricsTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/ManagedCursorMetricsTest.java @@ -49,6 +49,7 @@ protected void cleanup() throws Exception { super.internalCleanup(); } + @Test public void testManagedCursorMetrics() throws Exception { final String subName = "my-sub"; final String topicName = "persistent://my-namespace/use/my-ns/my-topic1"; diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/SimpleProducerConsumerStatTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/SimpleProducerConsumerStatTest.java index cc83ba2c331ca..480d83544b28b 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/SimpleProducerConsumerStatTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/SimpleProducerConsumerStatTest.java @@ -335,6 +335,7 @@ public void testSendTimeout(int batchMessageDelayMs) throws Exception { log.info("-- Exiting {} test --", methodName); } + @Test public void testBatchMessagesRateOut() throws PulsarClientException, InterruptedException, PulsarAdminException { log.info("-- Starting {} test --", methodName); String topicName = "persistent://my-property/cluster/my-ns/testBatchMessagesRateOut"; diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/schema/SchemaTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/schema/SchemaTest.java index dab9d08ac143e..db56fbce5a19b 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/schema/SchemaTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/schema/SchemaTest.java @@ -800,6 +800,7 @@ public void testNullKey() throws Exception { assertEquals("foo", message.getValue()); } + @Test public void testConsumeMultipleSchemaMessages() throws Exception { final String namespace = "test-namespace-" + randomName(16); String ns = PUBLIC_TENANT + "/" + namespace; diff --git a/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdClusters.java b/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdClusters.java index 0ab093d56c26b..cd4c22f8b2473 100644 --- a/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdClusters.java +++ b/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdClusters.java @@ -62,7 +62,8 @@ public void testCmdClusterConfigFile() throws Exception { testCmdClusterConfigFile(clusterData, clusterData); } - public void testCmdClusterConfigFile(ClusterData testClusterData, ClusterData expectedClusterData) throws Exception { + private void testCmdClusterConfigFile(ClusterData testClusterData, ClusterData expectedClusterData) + throws Exception { File file = Files.createTempFile("tmp_cluster", ".yaml").toFile(); ObjectMapperFactory.getThreadLocalYaml().writeValue(file, testClusterData); Assert.assertEquals(testClusterData, CmdUtils.loadConfig(file.getAbsolutePath(), ClusterData.class)); diff --git a/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdSinks.java b/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdSinks.java index 87f9a3fff7eda..27402bddbf0e8 100644 --- a/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdSinks.java +++ b/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdSinks.java @@ -341,7 +341,7 @@ public void testMissingConfig() throws Exception { ); } - public void testCmdSinkCliMissingArgs( + private void testCmdSinkCliMissingArgs( String tenant, String namespace, String name, @@ -492,7 +492,7 @@ public void testCmdSinkConfigFileInvalidJar() throws Exception { testCmdSinkConfigFile(testSinkConfig, expectedSinkConfig); } - public void testCmdSinkConfigFile(SinkConfig testSinkConfig, SinkConfig expectedSinkConfig) throws Exception { + private void testCmdSinkConfigFile(SinkConfig testSinkConfig, SinkConfig expectedSinkConfig) throws Exception { File file = Files.createTempFile("", "").toFile(); @@ -572,7 +572,7 @@ public void testCliOverwriteConfigFile() throws Exception { ); } - public void testMixCliAndConfigFile( + private void testMixCliAndConfigFile( String tenant, String namespace, String name, diff --git a/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdSources.java b/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdSources.java index 5b4d906b81b75..ff75d26534153 100644 --- a/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdSources.java +++ b/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdSources.java @@ -261,7 +261,7 @@ public void testMissingConfig() throws Exception { ); } - public void testCmdSourceCliMissingArgs( + private void testCmdSourceCliMissingArgs( String tenant, String namespace, String name, @@ -500,7 +500,7 @@ public void testCliOverwriteConfigFile() throws Exception { ); } - public void testMixCliAndConfigFile( + private void testMixCliAndConfigFile( String tenant, String namespace, String name, @@ -674,4 +674,4 @@ public void testParseConfigs() throws Exception { Assert.assertEquals(config.get("float_string"), "1000.0"); Assert.assertEquals(config.get("created_at"), "Mon Jul 02 00:33:15 +0000 2018"); } -} \ No newline at end of file +} diff --git a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeFactoryTest.java b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeFactoryTest.java index 1b8946b64b41d..dc0119cab4625 100644 --- a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeFactoryTest.java +++ b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeFactoryTest.java @@ -333,7 +333,7 @@ public void testValidateResourcesGranularityAndProportion() throws Exception { "Per instance ram requested, 0, for function should be positive and a multiple of the granularity, 1000"); } - public void testAuthProvider(Optional authProvider) throws Exception { + private void testAuthProvider(Optional authProvider) throws Exception { factory = createKubernetesRuntimeFactory(null, null, null, null, false, authProvider, Optional.empty()); } diff --git a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java index 9f064f511f050..ca14c639833a3 100644 --- a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java +++ b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java @@ -358,7 +358,8 @@ public void testResources() throws Exception { testResources(1.0 / 1.5, 1000, 1.3, 1.0); } - public void testResources(double userCpuRequest, long userMemoryRequest, double cpuOverCommitRatio, double memoryOverCommitRatio) throws Exception { + private void testResources(double userCpuRequest, long userMemoryRequest, double cpuOverCommitRatio, + double memoryOverCommitRatio) throws Exception { Function.Resources resources = Function.Resources.newBuilder() .setRam(userMemoryRequest).setCpu(userCpuRequest).setDisk(10000L).build(); diff --git a/pulsar-io/elastic-search/src/test/java/org/apache/pulsar/io/elasticsearch/ElasticSearchClientSslTests.java b/pulsar-io/elastic-search/src/test/java/org/apache/pulsar/io/elasticsearch/ElasticSearchClientSslTests.java index 9f878aad1ad17..7cbd24991df8b 100644 --- a/pulsar-io/elastic-search/src/test/java/org/apache/pulsar/io/elasticsearch/ElasticSearchClientSslTests.java +++ b/pulsar-io/elastic-search/src/test/java/org/apache/pulsar/io/elasticsearch/ElasticSearchClientSslTests.java @@ -157,7 +157,7 @@ public void testSslWithClientAuth() throws IOException { } - public void testIndexExists(ElasticSearchClient client) throws IOException { + private void testIndexExists(ElasticSearchClient client) throws IOException { assertFalse(client.indexExists("mynewindex")); assertTrue(client.createIndexIfNeeded("mynewindex")); assertTrue(client.indexExists("mynewindex")); diff --git a/pulsar-io/elastic-search/src/test/java/org/apache/pulsar/io/elasticsearch/ElasticSearchSinkTests.java b/pulsar-io/elastic-search/src/test/java/org/apache/pulsar/io/elasticsearch/ElasticSearchSinkTests.java index 9e3363c84d76c..c7523543beeef 100644 --- a/pulsar-io/elastic-search/src/test/java/org/apache/pulsar/io/elasticsearch/ElasticSearchSinkTests.java +++ b/pulsar-io/elastic-search/src/test/java/org/apache/pulsar/io/elasticsearch/ElasticSearchSinkTests.java @@ -292,7 +292,7 @@ public void testNullValueDelete() throws Exception { testNullValue(ElasticSearchConfig.NullValueAction.DELETE); } - public void testNullValue(ElasticSearchConfig.NullValueAction action) throws Exception { + private void testNullValue(ElasticSearchConfig.NullValueAction action) throws Exception { String index = "testnullvalue" + action.toString().toLowerCase(Locale.ROOT); map.put("indexName", index); map.put("keyIgnore", "false"); diff --git a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/extensions/ProxyExtensionWithClassLoaderTest.java b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/extensions/ProxyExtensionWithClassLoaderTest.java index b43eb22ab8952..57882a6a4b33b 100644 --- a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/extensions/ProxyExtensionWithClassLoaderTest.java +++ b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/extensions/ProxyExtensionWithClassLoaderTest.java @@ -70,6 +70,7 @@ public void testWrapper() throws Exception { verify(h, times(1)).start(service); } + @Test public void testClassLoaderSwitcher() throws Exception { NarClassLoader loader = mock(NarClassLoader.class); diff --git a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/functions/PulsarFunctionsTest.java b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/functions/PulsarFunctionsTest.java index 97d2c7bb31c7f..d547b4689928c 100644 --- a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/functions/PulsarFunctionsTest.java +++ b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/functions/PulsarFunctionsTest.java @@ -120,7 +120,7 @@ protected Map produceMessagesToInputTopic(String inputTopicName, return kvs; } - public void testFunctionLocalRun(Runtime runtime) throws Exception { + protected void testFunctionLocalRun(Runtime runtime) throws Exception { if (functionRuntimeType == FunctionRuntimeType.THREAD) { return; } @@ -243,7 +243,7 @@ public void testFunctionLocalRun(Runtime runtime) throws Exception { } - public void testWindowFunction(String type, String[] expectedResults) throws Exception { + protected void testWindowFunction(String type, String[] expectedResults) throws Exception { int NUM_OF_MESSAGES = 100; int windowLengthCount = 10; int slidingIntervalCount = 5; diff --git a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/offload/TestBaseOffload.java b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/offload/TestBaseOffload.java index ad7a8fdf1d048..f5a320e582072 100644 --- a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/offload/TestBaseOffload.java +++ b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/offload/TestBaseOffload.java @@ -48,7 +48,7 @@ private static byte[] buildEntry(String pattern) { return entry; } - public void testPublishOffloadAndConsumeViaCLI(String serviceUrl, String adminUrl) throws Exception { + protected void testPublishOffloadAndConsumeViaCLI(String serviceUrl, String adminUrl) throws Exception { final String tenant = "offload-test-cli-" + randomName(4); final String namespace = tenant + "/ns1"; final String topic = "persistent://" + namespace + "/topic1"; @@ -120,7 +120,7 @@ public void testPublishOffloadAndConsumeViaCLI(String serviceUrl, String adminUr } } - public void testPublishOffloadAndConsumeViaThreshold(String serviceUrl, String adminUrl) throws Exception { + protected void testPublishOffloadAndConsumeViaThreshold(String serviceUrl, String adminUrl) throws Exception { final String tenant = "offload-test-threshold-" + randomName(4); final String namespace = tenant + "/ns1"; final String topic = "persistent://" + namespace + "/topic1"; @@ -240,7 +240,7 @@ public boolean ledgerExistsInBookKeeper(long ledgerId) throws Exception { } } - public void testPublishOffloadAndConsumeDeletionLag(String serviceUrl, String adminUrl) throws Exception { + protected void testPublishOffloadAndConsumeDeletionLag(String serviceUrl, String adminUrl) throws Exception { final String tenant = "offload-test-deletion-lag-" + randomName(4); final String namespace = tenant + "/ns1"; final String topic = "persistent://" + namespace + "/topic1"; diff --git a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/topologies/PulsarTestBase.java b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/topologies/PulsarTestBase.java index 9989b15faa95e..baa018619d39d 100644 --- a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/topologies/PulsarTestBase.java +++ b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/topologies/PulsarTestBase.java @@ -67,7 +67,7 @@ protected static String generateTopicName(String namespace, String topicPrefix, } } - public void testPublishAndConsume(String serviceUrl, boolean isPersistent) throws Exception { + protected void testPublishAndConsume(String serviceUrl, boolean isPersistent) throws Exception { String topicName = generateTopicName("testpubconsume", isPersistent); int numMessages = 10; @@ -98,7 +98,7 @@ public void testPublishAndConsume(String serviceUrl, boolean isPersistent) throw } } - public void testBatchMessagePublishAndConsume(String serviceUrl, boolean isPersistent) throws Exception { + protected void testBatchMessagePublishAndConsume(String serviceUrl, boolean isPersistent) throws Exception { String topicName = generateTopicName("test-batch-publish-consume", isPersistent); final int numMessages = 10000; @@ -133,7 +133,7 @@ public void testBatchMessagePublishAndConsume(String serviceUrl, boolean isPersi } } - public void testBatchIndexAckDisabled(String serviceUrl) throws Exception { + protected void testBatchIndexAckDisabled(String serviceUrl) throws Exception { String topicName = generateTopicName("test-batch-index-ack-disabled", true); final int numMessages = 100; try (PulsarClient client = PulsarClient.builder() diff --git a/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BufferedOffloadStreamTest.java b/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BufferedOffloadStreamTest.java index 4ebf9434952eb..a5dc7ba17076f 100644 --- a/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BufferedOffloadStreamTest.java +++ b/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BufferedOffloadStreamTest.java @@ -42,7 +42,7 @@ public class BufferedOffloadStreamTest { final Random random = new Random(); - public void testWithPadding(int paddingLen) throws Exception { + private void testWithPadding(int paddingLen) throws Exception { int blockSize = StreamingDataBlockHeaderImpl.getDataStartOffset(); List entryBuffer = new LinkedList<>(); final UUID uuid = UUID.randomUUID();