You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by xy...@apache.org on 2025/07/17 12:29:30 UTC
(pulsar) 03/08: [improve][ci] Fixes #23079: Checkstyle checks applied to all test (#24492)
This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 2e07576dfa1cb33796e69da2778f3059871dc7f1
Author: Praveen Kumar <pr...@gmail.com>
AuthorDate: Fri Jul 11 09:33:39 2025 +0530
[improve][ci] Fixes #23079: Checkstyle checks applied to all test (#24492)
(cherry picked from commit 13e0a7b89c64bb516d66a48b0da5ede3cff0d8e2)
---
.../pulsar/client/TlsProducerConsumerBase.java | 1 -
.../pulsar/client/TlsProducerConsumerTest.java | 18 +-
.../src/main/resources/pulsar/suppressions.xml | 10 +-
.../BetweenTestClassesListenerAdapterTest.java | 12 +-
.../pulsar/tests/TestRetrySupportSuccessTest.java | 2 +-
.../mledger/impl/EntryCacheManagerTest.java | 6 +-
.../bookkeeper/mledger/impl/EntryCacheTest.java | 1 -
.../impl/InflightReadsLimiterIntegrationTest.java | 4 +-
.../mledger/impl/ManagedCursorConcurrencyTest.java | 40 +-
.../mledger/impl/ManagedCursorContainerTest.java | 18 +-
...ManagedCursorIndividualDeletedMessagesTest.java | 1 -
.../impl/ManagedCursorInfoMetadataTest.java | 2 +-
.../mledger/impl/ManagedCursorListAckTest.java | 3 -
.../bookkeeper/mledger/impl/ManagedCursorTest.java | 195 +++---
.../mledger/impl/ManagedLedgerBkTest.java | 49 +-
.../impl/ManagedLedgerFactoryShutdownTest.java | 3 -
.../mledger/impl/ManagedLedgerFactoryTest.java | 3 +-
.../impl/ManagedLedgerInfoMetadataTest.java | 15 +-
.../mledger/impl/ManagedLedgerMBeanTest.java | 3 +-
.../impl/ManagedLedgerSingleBookieTest.java | 1 -
.../mledger/impl/ManagedLedgerTerminationTest.java | 1 -
.../bookkeeper/mledger/impl/ManagedLedgerTest.java | 89 +--
.../bookkeeper/mledger/impl/MetaStoreImplTest.java | 2 +-
.../mledger/impl/NonDurableCursorTest.java | 11 +-
.../impl/OffloadEvictUnusedLedgersTest.java | 2 +-
.../mledger/impl/OffloadLedgerDeleteTest.java | 12 +-
.../mledger/impl/OffloadPrefixReadTest.java | 60 +-
.../bookkeeper/mledger/impl/OffloadPrefixTest.java | 54 +-
.../bookkeeper/mledger/impl/PositionTest.java | 41 +-
.../mledger/impl/RangeSetWrapperTest.java | 42 +-
.../mledger/impl/ReadOnlyCursorTest.java | 68 +-
.../mledger/impl/ShadowManagedLedgerImplTest.java | 4 +-
.../impl/cache/PendingReadsManagerTest.java | 43 +-
.../mledger/offload/OffloadUtilsTest.java | 6 +-
.../mledger/offload/OffloadersCacheTest.java | 4 +-
.../bookkeeper/mledger/util/CallbackMutexTest.java | 11 +-
.../bookkeeper/mledger/util/TestStatsBuckets.java | 5 +-
.../bookkeeper/test/MockedBookKeeperTestCase.java | 4 +-
...uthenticationProviderOpenIDIntegrationTest.java | 11 +-
.../oidc/AuthenticationProviderOpenIDTest.java | 3 +-
.../ProxySaslAuthenticationTest.java | 24 +-
.../authentication/SaslServerTokenSignerTest.java | 4 +-
.../BookieRackAffinityMappingTest.java | 101 +--
.../IsolatedBookieEnsemblePlacementPolicyTest.java | 99 +--
.../org/apache/pulsar/broker/BitRateUnitTest.java | 2 +-
.../AuthenticationProviderBasicTest.java | 3 +-
.../AuthenticationProviderTokenTest.java | 25 +-
.../OneStageAuthenticationStateTest.java | 10 +-
.../authorization/MockAuthorizationProvider.java | 2 +-
.../MultiRolesTokenAuthorizationProviderTest.java | 12 +-
.../broker/resources/LoadBalanceResourcesTest.java | 2 +-
.../broker/resources/TopicResourcesTest.java | 36 +-
.../stats/prometheus/PrometheusMetricsClient.java | 4 +-
.../PrometheusMetricsGeneratorUtilsTest.java | 2 +-
.../broker/validator/BindAddressValidatorTest.java | 3 +-
.../validator/MultipleListenerValidatorTest.java | 9 +-
.../pulsar/broker/web/GzipHandlerUtilTest.java | 3 +-
.../plugin/servlet/AdditionalServletUtilsTest.java | 13 +-
.../AdditionalServletWithClassLoaderTest.java | 5 +-
.../web/plugin/servlet/AdditionalServletsTest.java | 8 +-
.../web/plugin/servlet/MockAdditionalServlet.java | 1 -
.../PulsarConfigurationLoaderTest.java | 4 +-
.../jetty/tls/JettySslContextFactoryTest.java | 6 +-
.../JettySslContextFactoryWithKeyStoreTest.java | 50 +-
.../impl/MangedLedgerInterceptorImpl2Test.java | 2 +-
.../NonEntryCacheKeySharedSubscriptionV30Test.java | 14 +-
.../org/apache/pulsar/PulsarStandaloneTest.java | 1 -
.../broker/BookKeeperClientFactoryImplTest.java | 3 +-
.../pulsar/broker/BrokerAdditionalServletTest.java | 13 +-
.../org/apache/pulsar/broker/BrokerTestUtil.java | 15 +-
.../LedgerLostAndSkipNonRecoverableTest.java | 16 +-
.../broker/MockedBookKeeperClientFactory.java | 6 +-
.../pulsar/broker/MultiBrokerTestZKBaseTest.java | 2 +-
.../apache/pulsar/broker/PulsarServiceTest.java | 12 +-
.../pulsar/broker/TimeAverageBrokerDataTest.java | 5 +-
.../pulsar/broker/TopicEventsListenerTest.java | 11 +-
.../apache/pulsar/broker/admin/AdminApi2Test.java | 149 +++--
.../pulsar/broker/admin/AdminApiClusterTest.java | 2 +-
.../broker/admin/AdminApiDelayedDeliveryTest.java | 22 +-
.../admin/AdminApiDynamicConfigurationsTest.java | 11 +-
.../broker/admin/AdminApiGetLastMessageIdTest.java | 8 +-
.../broker/admin/AdminApiHealthCheckTest.java | 14 +-
.../admin/AdminApiMaxUnackedMessagesTest.java | 14 +-
.../broker/admin/AdminApiMultiBrokersTest.java | 4 +-
.../pulsar/broker/admin/AdminApiOffloadTest.java | 2 +-
.../broker/admin/AdminApiSchemaAutoUpdateTest.java | 12 +-
.../pulsar/broker/admin/AdminApiSchemaTest.java | 36 +-
.../AdminApiSchemaValidationEnforcedTest.java | 6 +-
.../broker/admin/AdminApiSchemaWithAuthTest.java | 10 +-
.../broker/admin/AdminApiSubscriptionTest.java | 28 +-
.../pulsar/broker/admin/AdminApiTenantTest.java | 7 +-
.../apache/pulsar/broker/admin/AdminApiTest.java | 120 ++--
.../pulsar/broker/admin/AdminApiTlsAuthTest.java | 8 +-
.../pulsar/broker/admin/AdminResourceTest.java | 1 -
.../apache/pulsar/broker/admin/AdminRestTest.java | 2 +-
.../org/apache/pulsar/broker/admin/AdminTest.java | 68 +-
.../pulsar/broker/admin/AdminTopicApiTest.java | 6 +-
.../admin/AnalyzeBacklogSubscriptionTest.java | 16 +-
.../org/apache/pulsar/broker/admin/AuthZTest.java | 16 +-
.../apache/pulsar/broker/admin/BookiesApiTest.java | 1 -
.../admin/BrokerEndpointsAuthorizationTest.java | 75 ++-
.../admin/ClusterEndpointsAuthorizationTest.java | 23 +-
.../broker/admin/CreateSubscriptionTest.java | 6 +-
.../broker/admin/GetPartitionMetadataTest.java | 10 +-
.../pulsar/broker/admin/MockServletContext.java | 2 -
.../pulsar/broker/admin/NamespaceAuthZTest.java | 258 +++++---
.../apache/pulsar/broker/admin/NamespacesTest.java | 167 +++--
.../pulsar/broker/admin/PersistentTopicsTest.java | 48 +-
.../pulsar/broker/admin/ResourceGroupsTest.java | 6 +-
.../admin/TenantEndpointsAuthorizationTest.java | 16 +-
.../apache/pulsar/broker/admin/TopicAuthZTest.java | 306 +++++----
.../pulsar/broker/admin/TopicAutoCreationTest.java | 4 +-
.../pulsar/broker/admin/TopicMessageTTLTest.java | 13 +-
.../broker/admin/TopicPoliciesAuthZTest.java | 14 +-
.../pulsar/broker/admin/TopicPoliciesTest.java | 687 +++++++++++++--------
.../admin/TopicPoliciesWithBrokerRestartTest.java | 4 +-
.../apache/pulsar/broker/admin/TopicsAuthTest.java | 12 +-
.../org/apache/pulsar/broker/admin/TopicsTest.java | 191 +++---
.../pulsar/broker/admin/TopicsWithoutTlsTest.java | 30 +-
.../admin/TransactionAndSchemaAuthZTest.java | 3 +-
...{V1_AdminApi2Test.java => V1AdminApi2Test.java} | 14 +-
.../{V1_AdminApiTest.java => V1AdminApiTest.java} | 46 +-
.../v3/AdminApiTransactionMultiBrokerTest.java | 5 +-
.../broker/admin/v3/AdminApiTransactionTest.java | 58 +-
.../pulsar/broker/admin/v3/PackagesApiTest.java | 16 +-
.../apache/pulsar/broker/auth/AuthLogsTest.java | 6 +-
.../broker/auth/AuthenticationServiceTest.java | 9 +-
.../pulsar/broker/auth/AuthorizationTest.java | 3 +-
.../broker/auth/AuthorizationWithAuthDataTest.java | 2 +-
.../MockAlwaysExpiredAuthenticationProvider.java | 7 +-
.../pulsar/broker/auth/MockAuthentication.java | 8 +-
.../auth/MockMultiStageAuthenticationProvider.java | 2 +-
.../auth/MockMultiStageAuthenticationState.java | 7 +-
.../auth/MockMutableAuthenticationProvider.java | 4 +-
.../auth/MockMutableAuthenticationState.java | 4 +-
.../broker/auth/MockedPulsarServiceBaseTest.java | 48 +-
.../apache/pulsar/broker/auth/PortForwarder.java | 2 +-
.../broker/auth/SameThreadOrderedSafeExecutor.java | 1 -
.../delayed/DelayedDeliveryTrackerFactoryTest.java | 4 +-
.../delayed/InMemoryDeliveryTrackerTest.java | 4 +-
.../broker/delayed/MockBucketSnapshotStorage.java | 2 +-
.../bucket/BucketDelayedDeliveryTrackerTest.java | 6 +-
.../delayed/bucket/DelayedIndexQueueTest.java | 4 +-
.../broker/intercept/BrokerInterceptorTest.java | 4 +-
.../intercept/BrokerInterceptorUtilsTest.java | 18 +-
.../BrokerInterceptorWithClassLoaderTest.java | 3 +-
.../broker/intercept/CounterBrokerInterceptor.java | 4 +-
.../intercept/ExceptionsBrokerInterceptorTest.java | 6 +-
.../ManagedLedgerInterceptorImplTest.java | 74 ++-
.../broker/intercept/MockBrokerInterceptor.java | 5 +-
.../loadbalance/AdvertisedListenersTest.java | 10 +-
.../AntiAffinityNamespaceGroupTest.java | 6 +-
.../loadbalance/BrokerVersionFilterTest.java | 6 +-
.../loadbalance/LeaderElectionServiceTest.java | 3 +-
.../broker/loadbalance/LoadBalancerTest.java | 46 +-
.../loadbalance/LoadBalancerTestingUtils.java | 5 +-
.../ModularLoadManagerStrategyTest.java | 39 +-
.../broker/loadbalance/SimpleBrokerStartTest.java | 6 +-
.../loadbalance/SimpleLoadManagerImplTest.java | 18 +-
.../ExtensibleLoadManagerImplBaseTest.java | 11 +-
.../extensions/ExtensibleLoadManagerImplTest.java | 76 ++-
...LoadManagerImplWithAdvertisedListenersTest.java | 4 +-
.../channel/ServiceUnitStateDataTest.java | 2 +-
.../extensions/data/BrokerLoadDataTest.java | 22 +-
.../extensions/data/BrokerLookupDataTest.java | 3 +-
.../extensions/filter/BrokerFilterTestBase.java | 2 -
.../filter/BrokerIsolationPoliciesFilterTest.java | 6 +-
.../filter/BrokerLoadManagerClassFilterTest.java | 7 +-
.../filter/BrokerMaxTopicCountFilterTest.java | 10 +-
.../extensions/filter/BrokerVersionFilterTest.java | 4 +-
.../extensions/manager/RedirectManagerTest.java | 15 +-
.../extensions/manager/SplitManagerTest.java | 2 +-
.../extensions/manager/UnloadManagerTest.java | 2 +-
.../extensions/models/TopKBundlesTest.java | 2 +-
.../reporter/BrokerLoadDataReporterTest.java | 8 +-
.../reporter/TopBundleLoadDataReporterTest.java | 12 +-
.../extensions/scheduler/SplitSchedulerTest.java | 2 +-
.../extensions/scheduler/TransferShedderTest.java | 90 +--
.../extensions/scheduler/UnloadSchedulerTest.java | 19 +-
.../extensions/store/LoadDataStoreTest.java | 7 +-
.../DefaultNamespaceBundleSplitStrategyTest.java | 4 +-
.../strategy/LeastResourceUsageWithWeightTest.java | 6 +-
.../broker/loadbalance/impl/AvgShedderTest.java | 22 +-
.../impl/BrokerLoadManagerClassFilterTest.java | 5 +-
.../loadbalance/impl/BundleSplitterTaskTest.java | 13 +-
.../impl/ModularLoadManagerImplTest.java | 75 ++-
.../loadbalance/impl/ThresholdShedderTest.java | 2 +-
.../loadbalance/impl/UniformLoadShedderTest.java | 17 +-
.../broker/lookup/http/HttpTopicLookupv2Test.java | 20 +-
.../broker/lookup/http/v2/TopicLookupTest.java | 6 +-
.../namespace/NamespaceCreateBundlesTest.java | 5 +-
...ts.java => NamespaceOwnershipListenerTest.java} | 18 +-
.../broker/namespace/NamespaceServiceTest.java | 80 ++-
.../broker/namespace/NamespaceUnloadingTest.java | 2 -
.../OwnerShipCacheForCurrentServerTest.java | 7 +-
.../OwnerShipForCurrentServerTestBase.java | 2 +-
.../broker/protocol/ProtocolHandlerUtilsTest.java | 1 -
.../ProtocolHandlerWithClassLoaderTest.java | 1 -
.../broker/protocol/ProtocolHandlersTest.java | 1 -
.../protocol/PulsarClientBasedHandlerTest.java | 8 +-
.../protocol/SimpleProtocolHandlerTestsBase.java | 38 +-
.../RGUsageMTAggrWaitForAllMsgsTest.java | 179 +++---
.../ResourceGroupConfigListenerTest.java | 9 +-
.../ResourceGroupRateLimiterTest.java | 7 +-
.../resourcegroup/ResourceGroupServiceTest.java | 33 +-
.../ResourceGroupUsageAggregationTest.java | 43 +-
.../ResourceUsageTransportManagerTest.java | 12 +-
.../broker/service/AbstractBaseDispatcherTest.java | 3 +-
.../broker/service/AdvertisedAddressTest.java | 17 +-
.../BacklogQuotaManagerConfigurationTest.java | 7 +-
.../broker/service/BacklogQuotaManagerTest.java | 83 ++-
.../pulsar/broker/service/BatchMessageTest.java | 95 ++-
.../BatchMessageWithBatchIndexLevelTest.java | 29 +-
.../pulsar/broker/service/BkEnsemblesTestBase.java | 10 +-
...emblesTests.java => BrokerBkEnsemblesTest.java} | 16 +-
.../broker/service/BrokerBookieIsolationTest.java | 28 +-
.../service/BrokerDispatchRateLimiterTest.java | 2 +-
.../broker/service/BrokerEntryMetadataE2ETest.java | 11 +-
...kerInternalClientConfigurationOverrideTest.java | 12 +-
.../BrokerServiceAutoSubscriptionCreationTest.java | 3 +-
.../BrokerServiceAutoTopicCreationTest.java | 14 +-
.../BrokerServiceBundlesCacheInvalidationTest.java | 2 +-
.../pulsar/broker/service/BrokerServiceTest.java | 61 +-
.../service/BrokerServiceThrottlingTest.java | 8 +-
.../pulsar/broker/service/BrokerTestBase.java | 6 +-
.../pulsar/broker/service/BusyWaitServiceTest.java | 5 +-
.../CanReconnectZKClientPulsarServiceBaseTest.java | 6 +-
.../broker/service/ClusterMigrationTest.java | 281 +++++----
...istentHashingStickyKeyConsumerSelectorTest.java | 54 +-
.../broker/service/ConsumedLedgersTrimTest.java | 4 +-
.../DeduplicationDisabledBrokerLevelTest.java | 4 +-
.../DispatchRateLimiterOverconsumingTest.java | 3 +-
.../broker/service/DistributedIdGeneratorTest.java | 17 +-
.../broker/service/EnableProxyProtocolTest.java | 9 +-
.../broker/service/ExclusiveProducerTest.java | 3 +-
...eoReplicationWithConfigurationSyncTestBase.java | 6 +-
...angeAutoSplitStickyKeyConsumerSelectorTest.java | 12 +-
.../broker/service/InactiveTopicDeleteTest.java | 50 +-
.../InmemoryTopicPoliciesServiceServiceTest.java | 3 +-
.../apache/pulsar/broker/service/KeyValueTest.java | 3 +-
.../broker/service/MessageCumulativeAckTest.java | 2 +-
.../pulsar/broker/service/MessageTTLTest.java | 3 +-
.../broker/service/NetworkErrorTestBase.java | 8 +-
.../broker/service/NonPersistentTopicE2ETest.java | 10 +-
.../service/OneWayReplicatorDeduplicationTest.java | 7 +-
.../broker/service/OneWayReplicatorTest.java | 6 +-
.../broker/service/OneWayReplicatorTestBase.java | 14 +-
...OneWayReplicatorUsingGlobalPartitionedTest.java | 24 +-
.../broker/service/OpportunisticStripingTest.java | 4 +-
.../pulsar/broker/service/PartitionKeyTest.java | 1 -
.../PersistentDispatcherFailoverConsumerTest.java | 23 +-
.../broker/service/PersistentFailoverE2ETest.java | 21 +-
.../service/PersistentMessageFinderTest.java | 36 +-
.../broker/service/PersistentQueueE2ETest.java | 14 +-
.../service/PersistentTopicConcurrentTest.java | 3 +-
.../broker/service/PersistentTopicE2ETest.java | 48 +-
.../PersistentTopicInitializeDelayTest.java | 23 +-
.../pulsar/broker/service/PersistentTopicTest.java | 10 +-
.../PublishRateLimiterOverconsumingTest.java | 6 +-
.../broker/service/PublishRateLimiterTest.java | 2 +-
.../pulsar/broker/service/RackAwareTest.java | 2 +-
.../broker/service/ReplicatedSubscriptionTest.java | 36 +-
.../ReplicatedSubscriptionWithTransactionTest.java | 2 +-
.../broker/service/ReplicatorGlobalNSTest.java | 5 +-
.../broker/service/ReplicatorRateLimiterTest.java | 20 +-
.../service/ReplicatorRemoveClusterTest.java | 2 +-
.../pulsar/broker/service/ReplicatorTest.java | 39 +-
.../pulsar/broker/service/ReplicatorTestBase.java | 30 +-
.../pulsar/broker/service/ReplicatorTlsTest.java | 2 +-
.../service/ReplicatorTopicPoliciesTest.java | 16 +-
.../pulsar/broker/service/ResendRequestTest.java | 6 +-
.../pulsar/broker/service/ServerCnxTest.java | 19 +-
.../pulsar/broker/service/StandaloneTest.java | 5 +-
.../pulsar/broker/service/SubscribeRateTest.java | 9 +-
.../SubscriptionConsumerCompatibilityTest.java | 8 +-
.../broker/service/SubscriptionSeekTest.java | 38 +-
.../SystemTopicBasedTopicPoliciesServiceTest.java | 67 +-
.../service/TopicDispatchRateLimiterTest.java | 2 +-
.../apache/pulsar/broker/service/TopicGCTest.java | 64 +-
.../broker/service/TopicListServiceTest.java | 24 +-
.../broker/service/TopicListWatcherTest.java | 12 +-
.../pulsar/broker/service/TopicOwnerTest.java | 9 +-
.../service/TopicPoliciesServiceDisableTest.java | 4 +-
.../service/TopicPublishRateThrottleTest.java | 9 +-
.../broker/service/TopicTerminationTest.java | 3 +-
.../service/TransactionMarkerDeleteTest.java | 2 +-
.../TransactionMetadataStoreServiceTest.java | 8 +-
.../TransactionalReplicateSubscriptionTest.java | 23 +-
.../pulsar/broker/service/ZkSessionExpireTest.java | 3 +-
...ntStickyKeyDispatcherMultipleConsumersTest.java | 5 +-
.../nonpersistent/NonPersistentTopicTest.java | 13 +-
.../persistent/BucketDelayedDeliveryTest.java | 28 +-
.../broker/service/persistent/ChecksumTest.java | 8 +-
.../service/persistent/DelayedDeliveryTest.java | 33 +-
.../service/persistent/MessageDuplicationTest.java | 20 +-
.../MessageRedeliveryControllerTest.java | 3 +-
.../PartitionKeywordCompatibilityTest.java | 3 +-
...tcherMultipleConsumerMaxEntriesInBatchTest.java | 12 +-
...tentDispatcherMultipleConsumersClassicTest.java | 9 +-
.../PersistentDispatcherMultipleConsumersTest.java | 9 +-
...rsistentDispatcherSingleActiveConsumerTest.java | 6 +-
.../PersistentReplicatorInflightTaskTest.java | 1 -
...yKeyDispatcherMultipleConsumersClassicTest.java | 8 +-
...ntStickyKeyDispatcherMultipleConsumersTest.java | 54 +-
.../persistent/PersistentSubscriptionTest.java | 14 +-
.../service/persistent/PersistentTopicTest.java | 45 +-
.../ReplicatedSubscriptionSnapshotCacheTest.java | 3 +-
...ReplicatedSubscriptionsSnapshotBuilderTest.java | 2 +-
.../persistent/RescheduleReadHandlerTest.java | 3 +-
.../broker/service/persistent/ShadowTopicTest.java | 4 +-
.../service/persistent/TopicDuplicationTest.java | 61 +-
.../broker/service/plugin/EntryFilter2Test.java | 2 +-
.../service/plugin/EntryFilterProviderTest.java | 5 +-
.../broker/service/plugin/EntryFilterTest.java | 1 -
.../broker/service/plugin/FilterEntryTest.java | 16 +-
.../schema/BaseAvroSchemaCompatibilityTest.java | 60 +-
.../schema/BookkeeperSchemaStorageTest.java | 15 +-
.../broker/service/schema/ClientGetSchemaTest.java | 18 +-
.../schema/JsonSchemaCompatibilityCheckTest.java | 12 +-
.../KeyValueSchemaCompatibilityCheckTest.java | 267 +++++---
.../schema/PartitionedTopicsSchemaTest.java | 14 +-
...ProtobufNativeSchemaCompatibilityCheckTest.java | 14 +-
.../broker/service/schema/SchemaServiceTest.java | 32 +-
.../schema/validator/SchemaDataValidatorTest.java | 1 -
...RegistryServiceWithSchemaDataValidatorTest.java | 5 +-
.../broker/service/utils/ClientChannelHelper.java | 34 +-
.../stats/AuthenticatedConsumerStatsTest.java | 16 +-
.../stats/BookieClientsStatsGeneratorTest.java | 9 +-
.../pulsar/broker/stats/ConsumerStatsTest.java | 33 +-
.../broker/stats/LedgerOffloaderMetricsTest.java | 2 +-
.../broker/stats/ManagedCursorMetricsTest.java | 2 +-
.../broker/stats/MetadataStoreStatsTest.java | 3 +-
.../stats/OpenTelemetryMetadataStoreStatsTest.java | 7 +-
.../pulsar/broker/stats/PrometheusMetricsTest.java | 84 ++-
.../pulsar/broker/stats/SubscriptionStatsTest.java | 15 +-
.../stats/TransactionBatchWriterMetricsTest.java | 27 +-
.../NamespaceEventsSystemTopicServiceTest.java | 1 -
.../systopic/PartitionedSystemTopicTest.java | 13 +-
.../testcontext/AbstractTestPulsarService.java | 3 +-
.../testcontext/MockEntryFilterProvider.java | 16 +-
.../broker/testcontext/NonClosingProxyHandler.java | 6 +-
.../broker/testcontext/PulsarTestContext.java | 13 +-
.../testinterceptor/BrokerTestInterceptor.java | 18 +-
.../apache/pulsar/broker/tools/BrokerToolTest.java | 2 +-
...thenticatedTransactionProducerConsumerTest.java | 18 +-
.../SegmentAbortedTxnProcessorTest.java | 25 +-
.../TopicTransactionBufferRecoverTest.java | 51 +-
.../broker/transaction/TransactionConsumeTest.java | 12 +-
.../broker/transaction/TransactionProduceTest.java | 9 +-
.../pulsar/broker/transaction/TransactionTest.java | 30 +-
.../broker/transaction/TransactionTestBase.java | 14 +-
.../buffer/InMemTransactionBufferReaderTest.java | 3 +-
.../buffer/TopicTransactionBufferTest.java | 15 +-
.../buffer/TransactionBufferClientTest.java | 7 +-
.../buffer/TransactionBufferHandlerImplTest.java | 20 +-
.../transaction/buffer/TransactionBufferTest.java | 5 +-
.../buffer/TransactionEntryImplTest.java | 1 -
.../buffer/TransactionLowWaterMarkTest.java | 49 +-
.../buffer/TransactionStablePositionTest.java | 34 +-
.../buffer/utils/TransactionBufferTestImpl.java | 3 +-
.../TransactionCoordinatorClientTest.java | 8 +-
.../TransactionMetaStoreAssignmentTest.java | 11 +-
.../coordinator/TransactionMetaStoreTestBase.java | 2 +-
.../pendingack/PendingAckInMemoryDeleteTest.java | 8 +-
.../pendingack/PendingAckPersistentTest.java | 6 +-
.../pendingack/impl/MLPendingAckStoreTest.java | 7 +-
.../recover/TransactionRecoverTrackerTest.java | 16 +-
.../broker/web/MaxRequestSizeFilterTest.java | 2 +-
.../broker/web/ProcessHandlerFilterTest.java | 2 +-
.../pulsar/broker/web/RestExceptionTest.java | 5 +-
.../broker/web/WebServiceOriginalClientIPTest.java | 3 +-
.../apache/pulsar/broker/web/WebServiceTest.java | 33 +-
.../AdditionalServletWithClassLoaderTest.java | 4 +-
.../broker/zookeeper/ClusterMetadataSetupTest.java | 12 +-
.../pulsar/broker/zookeeper/ZKReconnectTest.java | 4 +-
.../ZooKeeperSessionExpireRecoveryTest.java | 4 +-
.../api/AuthenticatedProducerConsumerTest.java | 16 +-
.../AuthenticationTlsHostnameVerificationTest.java | 16 +-
.../api/AuthorizationProducerConsumerTest.java | 30 +-
.../pulsar/client/api/BrokerServiceLookupTest.java | 10 +-
.../org/apache/pulsar/client/api/BytesKeyTest.java | 1 -
.../client/api/ClientDeduplicationFailureTest.java | 43 +-
.../apache/pulsar/client/api/ClientErrorsTest.java | 26 +-
.../pulsar/client/api/ConsumerAckListTest.java | 21 +-
.../client/api/ConsumerBatchReceiveTest.java | 30 +-
.../pulsar/client/api/ConsumerCleanupTest.java | 3 +-
.../pulsar/client/api/ConsumerRedeliveryTest.java | 16 +-
.../DeadLetterTopicDefaultMultiPartitionsTest.java | 54 +-
.../pulsar/client/api/DeadLetterTopicTest.java | 100 +--
.../client/api/DispatcherBlockConsumerTest.java | 6 +-
.../api/ExposeMessageRedeliveryCountTest.java | 7 +-
.../apache/pulsar/client/api/InterceptorsTest.java | 18 +-
...ySharedSubscriptionDisabledBrokerCacheTest.java | 2 +-
.../client/api/KeySharedSubscriptionTest.java | 87 +--
.../pulsar/client/api/LookupPropertiesTest.java | 8 +-
.../apache/pulsar/client/api/MemoryLimitTest.java | 10 +-
.../client/api/MessageDispatchThrottlingTest.java | 19 +-
.../client/api/MessageListenerExecutorTest.java | 6 +-
.../pulsar/client/api/MockBrokerService.java | 19 +-
.../pulsar/client/api/MockBrokerServiceHooks.java | 1 -
.../pulsar/client/api/MultiTopicsConsumerTest.java | 7 +-
.../client/api/MutualAuthenticationTest.java | 5 +-
.../client/api/NonDurableSubscriptionTest.java | 9 +-
.../pulsar/client/api/NonPersistentTopicTest.java | 25 +-
.../client/api/OrphanPersistentTopicTest.java | 7 +-
.../pulsar/client/api/PartitionCreationTest.java | 41 +-
.../api/PartitionedProducerConsumerTest.java | 71 ++-
.../client/api/PatternMultiTopicsConsumerTest.java | 3 +-
.../pulsar/client/api/ProducerCleanupTest.java | 5 +-
.../pulsar/client/api/ProducerCreationTest.java | 9 +-
.../pulsar/client/api/ProducerQueueSizeTest.java | 6 +-
.../pulsar/client/api/ProxyProtocolTest.java | 5 +-
...MultiListenersWithInternalListenerNameTest.java | 16 +-
.../apache/pulsar/client/api/RetryTopicTest.java | 42 +-
.../pulsar/client/api/ServiceUrlProviderTest.java | 14 +-
.../client/api/SimpleProducerConsumerStatTest.java | 25 +-
.../client/api/SimpleProducerConsumerTest.java | 339 ++++++----
.../apache/pulsar/client/api/SimpleSchemaTest.java | 86 ++-
.../api/SimpleTypedProducerConsumerTest.java | 26 +-
.../SubscriptionMessageDispatchThrottlingTest.java | 7 +-
.../api/SubscriptionPauseOnAckStatPersistTest.java | 8 +-
.../pulsar/client/api/TlsHostVerificationTest.java | 1 -
.../pulsar/client/api/TlsProducerConsumerBase.java | 5 +-
.../pulsar/client/api/TlsProducerConsumerTest.java | 18 +-
.../org/apache/pulsar/client/api/TlsSniTest.java | 4 +-
.../TokenAuthenticatedProducerConsumerTest.java | 30 +-
.../api/TokenExpirationProduceConsumerTest.java | 10 +-
...kenOauth2AuthenticatedProducerConsumerTest.java | 12 +-
.../apache/pulsar/client/api/TopicReaderTest.java | 131 ++--
.../pulsar/client/api/UnloadSubscriptionTest.java | 6 +-
...nsumerBase.java => V1ProducerConsumerBase.java} | 4 +-
...nsumerTest.java => V1ProducerConsumerTest.java} | 106 ++--
.../client/impl/AdminApiKeyStoreTlsAuthTest.java | 5 +-
.../AutoCloseUselessClientConMultiPartTest.java | 22 +-
.../AutoCloseUselessClientConMultiTopicTest.java | 60 +-
.../impl/AutoCloseUselessClientConNoPartTest.java | 22 +-
.../impl/AutoCloseUselessClientConSupports.java | 60 +-
.../impl/AutoCloseUselessClientConTXTest.java | 14 +-
.../impl/AutoScaledReceiverQueueSizeTest.java | 6 +-
.../impl/BatchMessageIdImplSerializationTest.java | 2 -
.../impl/BatchMessageIndexAckDisableTest.java | 11 +-
.../client/impl/BrokerClientIntegrationTest.java | 23 +-
.../apache/pulsar/client/impl/ClientCnxTest.java | 2 +-
.../client/impl/ClientWithSocks5ProxyTest.java | 12 +-
.../client/impl/CompactedOutBatchMessageTest.java | 15 +-
.../pulsar/client/impl/ConnectionHandlerTest.java | 1 -
.../pulsar/client/impl/ConnectionPoolTest.java | 2 +-
.../apache/pulsar/client/impl/ConsumerAckTest.java | 1 -
.../pulsar/client/impl/ConsumerCloseTest.java | 3 +-
.../client/impl/ConsumerConfigurationTest.java | 1 -
.../impl/ConsumerDedupPermitsUpdateTest.java | 3 -
.../client/impl/ConsumerUnsubscribeTest.java | 4 +-
...ests.java => DispatchAccordingPermitsTest.java} | 5 +-
.../impl/HierarchyTopicAutoCreationTest.java | 4 +-
...eySharedSubscriptionMaxUnackedMessagesTest.java | 4 +-
...eyStoreTlsProducerConsumerTestWithAuthTest.java | 31 +-
...toreTlsProducerConsumerTestWithoutAuthTest.java | 18 +-
.../pulsar/client/impl/MessageChecksumTest.java | 4 +-
.../pulsar/client/impl/MessageChunkingTest.java | 9 +-
.../client/impl/MessagePublishThrottlingTest.java | 4 +-
.../pulsar/client/impl/MessageRedeliveryTest.java | 11 +-
.../pulsar/client/impl/MultiTopicsReaderTest.java | 11 +-
.../pulsar/client/impl/NegativeAcksTest.java | 32 +-
.../impl/PartialPartitionedProducerTest.java | 29 +-
.../impl/PatternTopicsConsumerImplAuthTest.java | 26 +-
.../client/impl/PatternTopicsConsumerImplTest.java | 43 +-
.../PerMessageUnAcknowledgedRedeliveryTest.java | 2 -
.../client/impl/ProduceWithMessageIdTest.java | 2 +-
.../pulsar/client/impl/ProducerCloseTest.java | 17 +-
.../client/impl/ProducerConsumerInternalTest.java | 3 +-
.../client/impl/ProducerEmptySchemaCacheTest.java | 8 +-
.../pulsar/client/impl/ProducerMemoryLeakTest.java | 6 +-
.../pulsar/client/impl/ProducerSemaphoreTest.java | 31 +-
.../PulsarClientConfigurationOverrideTest.java | 3 +-
.../client/impl/PulsarMultiHostClientTest.java | 3 +-
.../pulsar/client/impl/PulsarTestClient.java | 3 +-
.../impl/RawBatchMessageContainerImplTest.java | 4 +-
.../pulsar/client/impl/RawMessageSerDeserTest.java | 9 +-
.../apache/pulsar/client/impl/RawReaderTest.java | 39 +-
.../org/apache/pulsar/client/impl/ReaderTest.java | 21 +-
.../apache/pulsar/client/impl/RetryUtilTest.java | 16 +-
.../pulsar/client/impl/SchemaDeleteTest.java | 3 -
.../client/impl/SequenceIdWithErrorTest.java | 8 +-
.../apache/pulsar/client/impl/TableViewTest.java | 3 +-
.../pulsar/client/impl/TopicDoesNotExistsTest.java | 5 +-
.../pulsar/client/impl/TopicFromMessageTest.java | 3 +-
.../pulsar/client/impl/TopicsConsumerImplTest.java | 127 ++--
.../client/impl/TransactionClientConnectTest.java | 3 +-
.../client/impl/TransactionEndToEndTest.java | 53 +-
...ransactionEndToEndWithoutBatchIndexAckTest.java | 4 +-
.../impl/UnAcknowledgedMessagesTimeoutTest.java | 2 -
.../pulsar/client/impl/ZeroQueueSizeTest.java | 7 +-
.../processor/CustomBatchPayloadProcessor.java | 2 +-
.../processor/DefaultProcessorWithRefCnt.java | 5 +-
.../processor/MessagePayloadProcessorTest.java | 2 +-
...OrQpsEquallyDivideBundleSplitAlgorithmTest.java | 15 +-
.../naming/NamespaceBundleSplitAlgorithmTest.java | 19 +-
.../pulsar/common/naming/NamespaceBundleTest.java | 26 +-
.../pulsar/common/naming/NamespaceBundlesTest.java | 21 +-
...RangeEquallyDivideBundleSplitAlgorithmTest.java | 14 +-
.../common/naming/ServiceConfigurationTest.java | 54 +-
...SpecifiedPositionsBundleSplitAlgorithmTest.java | 14 +-
...CountEquallyDivideBundleSplitAlgorithmTest.java | 7 +-
.../common/protocol/ProducerBatchSendTest.java | 3 +-
.../pulsar/compaction/CompactedTopicImplTest.java | 20 +-
.../pulsar/compaction/CompactedTopicTest.java | 63 +-
.../pulsar/compaction/CompactionRetentionTest.java | 11 +-
.../apache/pulsar/compaction/CompactionTest.java | 101 +--
.../pulsar/compaction/CompactorMXBeanImplTest.java | 3 +-
.../apache/pulsar/compaction/CompactorTest.java | 5 +-
.../pulsar/compaction/CompactorToolTest.java | 2 +-
.../compaction/EventTimeOrderCompactorTest.java | 1 -
.../compaction/ServiceUnitStateCompactionTest.java | 138 +++--
.../pulsar/compaction/StrategicCompactionTest.java | 11 +-
.../compaction/TopicCompactionServiceTest.java | 3 +-
.../apache/pulsar/functions/worker/FileServer.java | 3 +-
.../worker/PulsarFunctionE2ESecurityTest.java | 35 +-
.../worker/PulsarFunctionLocalRunTest.java | 112 ++--
.../worker/PulsarFunctionMetadataStoreTest.java | 2 +-
.../worker/PulsarFunctionPublishTest.java | 42 +-
.../PulsarFunctionTestTemporaryDirectory.java | 2 +-
.../functions/worker/PulsarFunctionTlsTest.java | 16 +-
.../worker/PulsarWorkerAssignmentTest.java | 16 +-
.../functions/worker/TestPulsarFunctionUtils.java | 10 +-
.../apache/pulsar/io/AbstractPulsarE2ETest.java | 45 +-
.../apache/pulsar/io/PulsarBatchSourceE2ETest.java | 35 +-
.../apache/pulsar/io/PulsarFunctionAdminTest.java | 15 +-
.../apache/pulsar/io/PulsarFunctionE2ETest.java | 141 +++--
.../apache/pulsar/io/PulsarFunctionTlsTest.java | 12 +-
.../org/apache/pulsar/io/PulsarSinkE2ETest.java | 139 +++--
.../org/apache/pulsar/io/PulsarSourceE2ETest.java | 53 +-
.../java/org/apache/pulsar/io/SinkForTest.java | 1 -
.../java/org/apache/pulsar/schema/SchemaTest.java | 95 +--
.../SchemaCompatibilityCheckTest.java | 40 +-
...hemaTypeCompatibilityCheckOnTopicLevelTest.java | 3 +-
.../SchemaTypeCompatibilityCheckTest.java | 19 +-
.../pulsar/security/MockedPulsarStandalone.java | 12 +-
.../tls/ec/TlsWithECCertificateFileTest.java | 2 +-
.../security/tls/ec/TlsWithECKeyStoreTest.java | 8 +-
.../socks5/handler/CommandRequestHandler.java | 9 +-
.../stats/client/PulsarBrokerStatsClientTest.java | 1 -
.../ConcurrentBitmapSortedLongPairSetTest.java | 8 +-
.../pulsar/utils/SimpleTextOutputStreamTest.java | 7 +-
.../apache/pulsar/utils/StatsOutputStreamTest.java | 7 +-
.../utils/auth/tokens/TokensCliUtilsTest.java | 8 +-
.../proxy/ClientSideEncryptionWssProducer.java | 2 +-
.../websocket/proxy/CryptoKeyReaderForTest.java | 20 +-
.../proxy/MockAuthenticationProvider.java | 2 -
.../proxy/MockUnauthenticationProvider.java | 3 +-
.../websocket/proxy/ProxyAuthenticationTest.java | 21 +-
.../websocket/proxy/ProxyAuthorizationTest.java | 2 +-
.../proxy/ProxyEncryptionPublishConsumeTest.java | 20 +-
.../websocket/proxy/ProxyIdleTimeoutTest.java | 4 +-
.../pulsar/websocket/proxy/ProxyPingTest.java | 4 +-
.../websocket/proxy/ProxyPublishConsumeTest.java | 148 +++--
.../proxy/ProxyPublishConsumeTlsTest.java | 10 +-
.../proxy/ProxyPublishConsumeWithoutZKTest.java | 6 +-
.../websocket/proxy/WssClientSideEncryptUtils.java | 5 +-
...ionTest.java => V1ProxyAuthenticationTest.java} | 24 +-
.../zookeeper/LocalBookkeeperEnsembleTest.java | 1 -
.../pulsar/cli/converters/TimeConversionTest.java | 12 +-
.../admin/internal/PulsarAdminBuilderImplTest.java | 7 +-
.../client/admin/internal/PulsarAdminGzipTest.java | 2 +-
.../client/admin/internal/PulsarAdminImplTest.java | 5 +-
.../client/admin/internal/SinksImplTest.java | 6 +-
.../client/impl/auth/AuthenticationAthenzTest.java | 40 +-
.../apache/pulsar/admin/cli/CmdFunctionsTest.java | 12 +-
.../pulsar/admin/cli/PulsarAdminToolTest.java | 371 ++++++-----
.../apache/pulsar/admin/cli/utils/IOUtilsTest.java | 1 -
.../pulsar/client/cli/PulsarClientToolTest.java | 20 +-
.../pulsar/client/cli/PulsarClientToolWsTest.java | 14 +-
.../pulsar/admin/cli/CmdTopicPoliciesTest.java | 2 +-
.../pulsar/admin/cli/TestCmdFunctionWorker.java | 9 +-
.../apache/pulsar/admin/cli/TestCmdNamespaces.java | 10 +-
.../apache/pulsar/admin/cli/TestCmdPackages.java | 4 +-
.../org/apache/pulsar/admin/cli/TestCmdSchema.java | 1 -
.../org/apache/pulsar/admin/cli/TestCmdSinks.java | 52 +-
.../apache/pulsar/admin/cli/TestCmdSources.java | 100 +--
.../apache/pulsar/client/cli/TestCmdConsume.java | 1 -
.../apache/pulsar/client/cli/TestCmdProduce.java | 34 +-
.../org/apache/pulsar/client/cli/TestCmdRead.java | 1 -
.../org/apache/pulsar/shell/ConfigShellTest.java | 24 +-
.../pulsar/client/api/AuthenticationTest.java | 9 +-
.../client/api/ConsumerConfigurationTest.java | 8 +-
.../apache/pulsar/client/api/ConsumerIdTest.java | 7 +-
.../apache/pulsar/client/api/MessageIdTest.java | 1 -
.../pulsar/client/api/MessageRouterTest.java | 1 -
.../api/MultiplierRedeliveryBackoffTest.java | 4 +-
.../pulsar/client/examples/TransactionExample.java | 3 +-
.../impl/AcknowledgementsGroupingTrackerTest.java | 11 +-
.../client/impl/BatchMessageContainerImplTest.java | 10 +-
.../client/impl/BinaryProtoLookupServiceTest.java | 8 +-
.../apache/pulsar/client/impl/BuildersTest.java | 20 +-
.../pulsar/client/impl/ClientBuilderImplTest.java | 11 +-
.../impl/ClientCnxRequestTimeoutQueueTest.java | 18 +-
.../apache/pulsar/client/impl/ClientCnxTest.java | 12 +-
.../pulsar/client/impl/ClientTestFixtures.java | 6 +-
.../client/impl/ConsumerBuilderImplTest.java | 12 +-
.../pulsar/client/impl/ConsumerImplTest.java | 7 +-
.../client/impl/ControlledClusterFailoverTest.java | 5 +-
.../client/impl/DefaultCryptoKeyReaderTest.java | 86 ++-
.../pulsar/client/impl/MessageIdAdvUtilsTest.java | 2 +-
.../pulsar/client/impl/MessageIdCompareToTest.java | 3 +-
.../apache/pulsar/client/impl/MessageImplTest.java | 57 +-
.../client/impl/PartitionedProducerImplTest.java | 23 +-
.../impl/PatternMultiTopicsConsumerImplTest.java | 7 +-
.../client/impl/ProducerBuilderImplTest.java | 3 +-
.../pulsar/client/impl/ProducerImplTest.java | 5 +-
.../pulsar/client/impl/PulsarClientImplTest.java | 4 +-
.../client/impl/PulsarServiceNameResolverTest.java | 1 -
.../apache/pulsar/client/impl/ReaderImplTest.java | 6 +-
.../RoundRobinPartitionMessageRouterImplTest.java | 2 -
.../impl/SinglePartitionMessageRouterImplTest.java | 7 +-
.../client/impl/TableViewBuilderImplTest.java | 3 +-
.../impl/TableViewConfigurationDataTest.java | 3 +-
.../pulsar/client/impl/TableViewImplTest.java | 10 +-
.../pulsar/client/impl/TopicListWatcherTest.java | 22 +-
.../pulsar/client/impl/TopicMessageIdImplTest.java | 1 -
.../pulsar/client/impl/TopicMetadataImplTest.java | 1 -
.../pulsar/client/impl/TransactionBuilderTest.java | 4 +-
.../impl/TransactionMetaStoreHandlerTest.java | 1 -
.../client/impl/TypedMessageBuilderImplTest.java | 140 +++--
.../client/impl/UnAckedMessageTrackerTest.java | 7 +-
.../client/impl/auth/AuthenticationTlsTest.java | 8 +-
.../client/impl/auth/AuthenticationTokenTest.java | 12 +-
.../client/impl/auth/MockAuthentication.java | 7 +-
.../MockEncodedAuthenticationParameterSupport.java | 12 +-
.../impl/auth/oauth2/AuthenticationOAuth2Test.java | 2 -
.../impl/auth/oauth2/protocol/TokenClientTest.java | 6 +-
.../impl/conf/ConfigurationDataUtilsTest.java | 21 +-
.../impl/conf/ConsumerConfigurationDataTest.java | 2 -
...efaultCryptoKeyReaderConfigurationDataTest.java | 11 +-
.../pulsar/client/impl/schema/AvroSchemaTest.java | 52 +-
.../pulsar/client/impl/schema/BytesSchemaTest.java | 3 +-
.../pulsar/client/impl/schema/DateSchemaTest.java | 7 +-
.../client/impl/schema/DefaultSchemasTest.java | 2 -
.../client/impl/schema/DoubleSchemaTest.java | 2 +-
.../pulsar/client/impl/schema/FloatSchemaTest.java | 2 +-
.../client/impl/schema/InstantSchemaTest.java | 4 +-
.../pulsar/client/impl/schema/IntSchemaTest.java | 2 +-
.../pulsar/client/impl/schema/JSONSchemaTest.java | 64 +-
.../client/impl/schema/KeyValueSchemaInfoTest.java | 9 +-
.../client/impl/schema/KeyValueSchemaTest.java | 76 ++-
.../client/impl/schema/LocalDateSchemaTest.java | 6 +-
.../impl/schema/LocalDateTimeSchemaTest.java | 4 +-
.../client/impl/schema/LocalTimeSchemaTest.java | 8 +-
.../pulsar/client/impl/schema/LongSchemaTest.java | 4 +-
.../client/impl/schema/PrimitiveSchemaTest.java | 33 +-
.../impl/schema/ProtobufNativeSchemaTest.java | 62 +-
.../impl/schema/ProtobufNativeSchemaUtilsTest.java | 3 +-
.../client/impl/schema/ProtobufSchemaTest.java | 91 +--
.../client/impl/schema/SchemaBuilderTest.java | 26 +-
.../pulsar/client/impl/schema/SchemaInfoTest.java | 8 +-
.../pulsar/client/impl/schema/SchemaTestUtils.java | 101 +--
.../pulsar/client/impl/schema/ShortSchemaTest.java | 4 +-
.../client/impl/schema/StringSchemaTest.java | 6 +-
.../schema/SupportVersioningAvroSchemaTest.java | 13 +-
.../SupportVersioningKeyValueSchemaTest.java | 11 +-
.../pulsar/client/impl/schema/TimeSchemaTest.java | 7 +-
.../client/impl/schema/TimestampSchemaTest.java | 7 +-
.../schema/generic/AbstractGenericSchemaTest.java | 28 +-
.../impl/schema/generic/GenericAvroReaderTest.java | 4 +-
.../impl/schema/generic/GenericAvroRecordTest.java | 4 +-
.../impl/schema/generic/GenericAvroSchemaTest.java | 10 +-
.../impl/schema/generic/GenericJsonRecordTest.java | 12 +-
.../generic/GenericProtobufNativeReaderTest.java | 26 +-
.../generic/GenericProtobufNativeSchemaTest.java | 9 +-
.../impl/schema/generic/GenericSchemaImplTest.java | 5 +-
.../impl/schema/generic/GenericSchemaTest.java | 27 +-
.../MultiVersionSchemaInfoProviderTest.java | 5 +-
.../client/tutorial/ContinuousAsyncProducer.java | 1 -
.../pulsar/client/tutorial/ContinuousProducer.java | 1 -
.../client/tutorial/SampleAsyncProducer.java | 4 +-
.../tutorial/SampleAsyncProducerWithSchema.java | 3 +-
.../pulsar/client/tutorial/SampleConsumer.java | 3 +-
.../client/tutorial/SampleConsumerListener.java | 4 +-
.../client/tutorial/SampleCryptoConsumer.java | 4 +-
.../client/tutorial/SampleCryptoProducer.java | 4 +-
.../pulsar/client/tutorial/SampleProducer.java | 1 -
.../apache/pulsar/client/util/ObjectCacheTest.java | 2 -
.../apache/pulsar/common/schema/KeyValueTest.java | 15 +-
.../apache/pulsar/AddMissingPatchVersionTest.java | 1 -
.../pulsar/common/api/raw/RawMessageImplTest.java | 6 +-
.../pulsar/common/compression/CommandsTest.java | 2 +-
.../compression/CompressionCodecZstdJNI.java | 3 -
.../CompressorCodecBackwardCompatTest.java | 11 +-
.../common/compression/CompressorCodecTest.java | 48 +-
.../common/compression/Crc32cChecksumTest.java | 5 +-
.../common/io/BatchSourceConfigParseTest.java | 48 +-
.../pulsar/common/lookup/data/LookupDataTest.java | 5 +-
.../{MetadataTests.java => MetadataTest.java} | 2 +-
.../pulsar/common/naming/NamespaceNameTest.java | 1 -
.../apache/pulsar/common/naming/TopicNameTest.java | 3 +-
.../apache/pulsar/common/nar/NarUnpackerTest.java | 3 +-
.../apache/pulsar/common/net/ServiceURITest.java | 11 +-
.../policies/data/AutoFailoverPolicyDataTest.java | 2 -
.../policies/data/AutoFailoverPolicyTypeTest.java | 2 -
.../data/AutoTopicCreationOverrideTest.java | 5 +-
.../common/policies/data/ClusterDataImplTest.java | 4 +-
.../common/policies/data/ClusterDataTest.java | 1 -
.../common/policies/data/ConsumerStatsTest.java | 17 +-
.../data/EnsemblePlacementPolicyConfigTest.java | 3 +-
.../common/policies/data/LocalPolicesTest.java | 22 +-
.../policies/data/NamespaceIsolationDataTest.java | 2 -
.../data/NamespaceOwnershipStatusTest.java | 10 +-
.../NonPersistentPartitionedTopicStatsTest.java | 8 +-
.../common/policies/data/OffloadPoliciesTest.java | 13 +-
.../pulsar/common/policies/data/OldPolicies.java | 24 +-
.../policies/data/PartitionedTopicStatsTest.java | 1 -
.../policies/data/PersistencePoliciesTest.java | 1 -
.../data/PersistentOfflineTopicStatsTest.java | 1 -
.../policies/data/PersistentTopicStatsTest.java | 8 +-
.../common/policies/data/PoliciesDataTest.java | 27 +-
.../common/policies/data/PublisherStatsTest.java | 21 +-
.../common/policies/data/RetentionPolicesTest.java | 1 -
.../impl/AutoFailoverPolicyFactoryTest.java | 1 -
.../policies/impl/MinAvailablePolicyTest.java | 1 -
.../impl/NamespaceIsolationPoliciesTest.java | 13 +-
.../impl/NamespaceIsolationPolicyImplTest.java | 11 +-
...ommandUtilsTests.java => CommandUtilsTest.java} | 32 +-
.../apache/pulsar/common/protocol/MarkersTest.java | 3 -
.../common/stats/CacheMetricsCollectorTest.java | 2 +-
.../stats/JvmDefaultGCMetricsLoggerTest.java | 5 +-
.../apache/pulsar/common/topics/TopicListTest.java | 30 +-
.../org/apache/pulsar/common/util/BackoffTest.java | 5 +-
.../common/util/DefaultPulsarSslFactoryTest.java | 18 +-
.../apache/pulsar/common/util/FieldParserTest.java | 4 +-
.../common/util/FileModifiedTimeUpdaterTest.java | 2 -
.../apache/pulsar/common/util/FutureUtilTest.java | 16 +-
.../apache/pulsar/common/util/PortManagerTest.java | 3 +-
.../apache/pulsar/common/util/ReflectionsTest.java | 30 +-
.../pulsar/common/util/RelativeTimeUtilTest.java | 2 -
.../pulsar/common/util/URIPreconditionsTest.java | 5 +-
.../collections/ConcurrentLongHashMapTest.java | 31 +-
.../ConcurrentLongLongPairHashMapTest.java | 2 -
.../collections/ConcurrentLongPairSetTest.java | 49 +-
.../util/collections/DefaultRangeSetTest.java | 15 +-
.../common/util/collections/FieldParserTest.java | 2 -
.../GrowableArrayBlockingQueueTest.java | 5 +-
.../GrowablePriorityLongPairQueueTest.java | 37 +-
.../util/collections/OpenLongPairRangeSetTest.java | 62 +-
.../collections/TripleLongPriorityQueueTest.java | 25 +-
.../common/util/netty/ChannelFuturesTest.java | 3 -
.../pulsar/common/util/netty/SslContextTest.java | 40 +-
.../pulsar/exception/PulsarExceptionTest.java | 3 +-
.../data/loadbalancer/LocalBrokerDataTest.java | 41 +-
.../config/validation/ConfigValidationTest.java | 10 +-
.../config/validation/ValidatorImplsTest.java | 9 +-
.../functions/instance/InstanceUtilsTest.java | 6 +-
.../instance/JavaInstanceRunnableTest.java | 2 +-
.../functions/instance/JavaInstanceTest.java | 40 +-
.../instance/ProducerBuilderFactoryTest.java | 12 +-
.../instance/state/BKStateStoreImplTest.java | 12 +-
.../pulsar/functions/sink/PulsarSinkTest.java | 16 +-
.../functions/source/PulsarFunctionRecordTest.java | 1 -
.../pulsar/functions/source/TopicSchemaTest.java | 16 +-
.../source/batch/BatchSourceExecutorTest.java | 5 +-
.../windowing/WaterMarkEventGeneratorTest.java | 2 +-
.../windowing/WindowFunctionExecutorTest.java | 8 +-
.../functions/windowing/WindowManagerTest.java | 34 +-
.../functions/instance/JavaInstanceDepsTest.java | 14 +-
.../ClearTextFunctionTokenAuthProviderTest.java | 12 +-
.../KubernetesSecretsTokenAuthProviderTest.java | 75 ++-
...ernetesServiceAccountTokenAuthProviderTest.java | 24 +-
.../pulsar/functions/config/TestWorkerConfig.java | 8 +-
.../pulsar/functions/runtime/RuntimeUtilsTest.java | 13 +-
.../BasicKubernetesManifestCustomizerTest.java | 21 +-
.../kubernetes/KubernetesRuntimeFactoryTest.java | 196 +++---
.../runtime/kubernetes/KubernetesRuntimeTest.java | 334 ++++++----
.../runtime/process/ProcessRuntimeTest.java | 37 +-
.../runtime/thread/ThreadRuntimeFactoryTest.java | 42 +-
.../worker/WorkerApiV2ResourceConfigTest.java | 15 +-
.../ClearTextSecretsProviderTest.java | 1 -
.../KubernetesSecretsProviderConfiguratorTest.java | 12 +-
.../apache/pulsar/functions/utils/ActionsTest.java | 7 +-
.../pulsar/functions/utils/ExceptionsTest.java | 10 +-
.../pulsar/functions/utils/FunctionCommonTest.java | 9 +-
.../functions/utils/FunctionConfigUtilsTest.java | 60 +-
.../functions/utils/FunctionMetaDataUtilsTest.java | 3 +-
.../functions/utils/SinkConfigUtilsTest.java | 69 ++-
.../functions/utils/SourceConfigUtilsTest.java | 51 +-
.../functions/utils/WindowConfigUtilsTest.java | 5 +-
.../worker/ClusterServiceCoordinatorTest.java | 3 +-
.../worker/FunctionMetaDataManagerTest.java | 10 +-
.../worker/FunctionRuntimeManagerTest.java | 39 +-
.../functions/worker/SchedulerManagerTest.java | 62 +-
.../functions/worker/dlog/DLInputStreamTest.java | 5 +-
.../worker/rest/api/FunctionsImplTest.java | 12 +-
.../api/PulsarFunctionTestTemporaryDirectory.java | 2 +-
.../rest/api/v2/FunctionApiV2ResourceTest.java | 41 +-
.../api/v3/AbstractFunctionApiResourceTest.java | 518 ++++++++--------
.../rest/api/v3/AbstractFunctionsResourceTest.java | 16 +-
.../rest/api/v3/FunctionApiV3ResourceTest.java | 102 +--
.../worker/rest/api/v3/SinkApiV3ResourceTest.java | 296 ++++-----
.../rest/api/v3/SourceApiV3ResourceTest.java | 258 ++++----
.../io/alluxio/sink/AlluxioSinkConfigTest.java | 10 +-
.../pulsar/io/alluxio/sink/AlluxioSinkTest.java | 20 +-
.../io/azuredataexplorer/ADXSinkConfigTest.java | 10 +-
.../io/azuredataexplorer/ADXSinkE2ETest.java | 22 +-
.../batchdatagenerator/BatchDataGeneratorExec.java | 7 +-
.../apache/pulsar/io/common/IOConfigUtilsTest.java | 38 +-
.../apache/pulsar/io/core/BatchPushSourceTest.java | 5 +-
.../java/org/apache/pulsar/io/core/SinkTest.java | 10 +-
.../java/org/apache/pulsar/io/core/SourceTest.java | 10 +-
.../io/debezium/PulsarDatabaseHistoryTest.java | 31 +-
...figTests.java => DynamoDBSourceConfigTest.java} | 49 +-
...chAuthTests.java => ElasticSearchAuthTest.java} | 4 +-
...archBWCTests.java => ElasticSearchBWCTest.java} | 11 +-
...lTests.java => ElasticSearchClientSslTest.java} | 88 ++-
...ientTests.java => ElasticSearchClientTest.java} | 22 +-
...nfigTests.java => ElasticSearchConfigTest.java} | 18 +-
...actTests.java => ElasticSearchExtractTest.java} | 47 +-
...dTests.java => ElasticSearchRawRecordTest.java} | 12 +-
...ests.java => ElasticSearchSinkRawDataTest.java} | 11 +-
...chSinkTests.java => ElasticSearchSinkTest.java} | 20 +-
.../io/elasticsearch/ElasticSearchTestBase.java | 6 +-
.../io/elasticsearch/IndexNameFormatterTest.java | 1 -
...nConverterTests.java => JsonConverterTest.java} | 55 +-
...yTests.java => RandomExponentialRetryTest.java} | 26 +-
.../client/RestClientFactoryTest.java | 4 +-
.../pulsar/io/elasticsearch/data/Profile.java | 1 -
.../pulsar/io/elasticsearch/data/UserProfile.java | 1 -
...tSslTests.java => OpenSearchClientSslTest.java} | 54 +-
...hClientTests.java => OpenSearchClientTest.java} | 6 +-
...taTests.java => OpenSearchSinkRawDataTest.java} | 6 +-
...earchSinkTests.java => OpenSearchSinkTest.java} | 6 +-
.../testcontainers/ElasticToxiproxiContainer.java | 9 +-
...7AuthTests.java => ElasticSearch7AuthTest.java} | 6 +-
...Tests.java => ElasticSearch7ClientSslTest.java} | 6 +-
...entTests.java => ElasticSearch7ClientTest.java} | 6 +-
...sts.java => ElasticSearch7SinkRawDataTest.java} | 6 +-
...7SinkTests.java => ElasticSearch7SinkTest.java} | 6 +-
...8AuthTests.java => ElasticSearch8AuthTest.java} | 6 +-
...Tests.java => ElasticSearch8ClientSslTest.java} | 6 +-
...entTests.java => ElasticSearch8ClientTest.java} | 6 +-
...sts.java => ElasticSearch8SinkRawDataTest.java} | 6 +-
...8SinkTests.java => ElasticSearch8SinkTest.java} | 6 +-
...bstractFileTests.java => AbstractFileTest.java} | 18 +-
...hreadTests.java => FileConsumerThreadTest.java} | 4 +-
...ThreadTests.java => FileListingThreadTest.java} | 6 +-
...eConfigTests.java => FileSourceConfigTest.java} | 50 +-
...readTests.java => ProcessedFileThreadTest.java} | 20 +-
.../apache/pulsar/io/file/TestFileGenerator.java | 22 +-
.../{GZipFilesTests.java => GZipFilesTest.java} | 16 +-
.../{ZipFilesTests.java => ZipFilesTest.java} | 16 +-
...tractFlumeTests.java => AbstractFlumeTest.java} | 2 +-
...TestAbstractZooKeeperConfigurationProvider.java | 3 +-
...PollingPropertiesFileConfigurationProvider.java | 2 +-
.../{StringSinkTests.java => StringSinkTest.java} | 9 +-
...tringSourceTests.java => StringSourceTest.java} | 6 +-
.../org/apache/pulsar/io/hbase/TableUtils.java | 7 +-
.../io/hbase/sink/HbaseGenericRecordSinkTest.java | 27 +-
.../pulsar/io/hbase/sink/HbaseSinkConfigTest.java | 12 +-
.../pulsar/io/hdfs3/sink/AbstractHdfsSinkTest.java | 3 +-
.../pulsar/io/hdfs3/sink/HdfsSinkConfigTest.java | 150 +++++
.../pulsar/io/hdfs3/sink/HdfsSinkConfigTests.java | 155 -----
...lSinkTests.java => HdfsSequentialSinkTest.java} | 2 +-
...dfsTextSinkTests.java => HdfsTextSinkTest.java} | 2 +-
...tringSinkTests.java => HdfsStringSinkTest.java} | 2 +-
.../org/apache/pulsar/io/http/HttpSinkTest.java | 3 +-
.../influxdb/v1/InfluxDBGenericRecordSinkTest.java | 23 +-
.../io/influxdb/v1/InfluxDBSinkConfigTest.java | 16 +-
.../pulsar/io/influxdb/v2/InfluxDBSinkTest.java | 15 +-
.../pulsar/io/jdbc/BaseJdbcAutoSchemaSinkTest.java | 15 +-
.../org/apache/pulsar/io/jdbc/JdbcUtilsTest.java | 63 +-
.../pulsar/io/jdbc/SqliteJdbcSinkBatchTest.java | 4 +-
.../apache/pulsar/io/jdbc/SqliteJdbcSinkTest.java | 90 +--
.../org/apache/pulsar/io/jdbc/SqliteUtils.java | 6 +-
.../io/kafka/connect/KafkaConnectSinkTest.java | 124 ++--
.../connect/KafkaConnectSourceErrRecTest.java | 27 +-
.../kafka/connect/KafkaConnectSourceErrTest.java | 33 +-
.../io/kafka/connect/KafkaConnectSourceTest.java | 7 +-
.../io/kafka/connect/MockGenericObjectWrapper.java | 3 +-
.../connect/PulsarSchemaToKafkaSchemaTest.java | 18 +-
.../connect/SchemaedFileStreamSinkConnector.java | 5 +-
.../kafka/connect/SchemaedFileStreamSinkTask.java | 9 +-
.../io/kafka/ByteBufferSchemaWrapperTest.java | 14 +-
.../pulsar/io/kafka/KafkaBytesSourceTest.java | 12 +-
.../io/kafka/sink/KafkaAbstractSinkTest.java | 41 +-
.../io/kafka/source/KafkaAbstractSourceTest.java | 38 +-
.../pulsar/io/kinesis/KinesisSinkAuthTest.java | 36 +-
...ConfigTests.java => KinesisSinkConfigTest.java} | 6 +-
.../apache/pulsar/io/kinesis/KinesisSinkTest.java | 15 +-
...nfigTests.java => KinesisSourceConfigTest.java} | 7 +-
.../org/apache/pulsar/io/kinesis/UtilsTest.java | 4 -
...nConverterTests.java => JsonConverterTest.java} | 55 +-
.../pulsar/io/mongodb/MongoSinkConfigTest.java | 8 +-
.../apache/pulsar/io/mongodb/MongoSinkTest.java | 25 +-
.../apache/pulsar/io/mongodb/MongoSourceTest.java | 24 +-
.../pulsar/io/netty/NettySourceConfigTest.java | 10 +-
.../http/NettyHttpChannelInitializerTest.java | 7 +-
.../pulsar/io/netty/server/NettyServerTest.java | 12 +-
.../netty/tcp/NettyTCPChannelInitializerTest.java | 10 +-
.../netty/udp/NettyUDPChannelInitializerTest.java | 8 +-
.../{NSQConfigTests.java => NSQConfigTest.java} | 28 +-
.../io/rabbitmq/sink/RabbitMQSinkConfigTest.java | 16 +-
.../rabbitmq/source/RabbitMQSourceConfigTest.java | 18 +-
.../io/rabbitmq/source/RabbitMQSourceTest.java | 5 +-
.../apache/pulsar/io/redis/EmbeddedRedisUtils.java | 9 +-
.../pulsar/io/redis/sink/RedisSinkConfigTest.java | 20 +-
.../apache/pulsar/io/redis/sink/RedisSinkTest.java | 13 +-
.../pulsar/io/solr/SolrGenericRecordSinkTest.java | 16 +-
.../org/apache/pulsar/io/solr/SolrServerUtil.java | 9 +-
.../apache/pulsar/io/solr/SolrSinkConfigTest.java | 18 +-
...igTests.java => TwitterFireHoseConfigTest.java} | 30 +-
.../replication/AuditorLedgerCheckerTest.java | 2 +-
.../replication/TestReplicationWorker.java | 20 +-
.../metadata/BacklogQuotaCompatibilityTest.java | 8 +-
.../pulsar/metadata/BaseMetadataStoreTest.java | 2 +-
.../apache/pulsar/metadata/MetadataBenchmark.java | 40 +-
.../apache/pulsar/metadata/MetadataCacheTest.java | 10 +-
.../pulsar/metadata/MetadataStoreBatchingTest.java | 7 +-
.../pulsar/metadata/MetadataStoreExtendedTest.java | 3 +-
.../metadata/MetadataStoreTableViewTest.java | 17 +-
.../apache/pulsar/metadata/MetadataStoreTest.java | 17 +-
.../org/apache/pulsar/metadata/TestZKServer.java | 3 +-
.../org/apache/pulsar/metadata/ZKSessionTest.java | 6 +-
.../pulsar/metadata/bookkeeper/EndToEndTest.java | 2 +-
.../bookkeeper/PulsarLedgerIdGeneratorTest.java | 6 +-
.../bookkeeper/PulsarRegistrationClientTest.java | 13 +-
.../metadata/impl/EtcdMetadataStoreTest.java | 1 -
.../impl/LocalMemoryMetadataStoreTest.java | 39 +-
.../impl/MetadataStoreFactoryImplTest.java | 3 +-
.../bookkeeper/BookKeeperPackagesStorageTest.java | 2 +-
.../storage/bookkeeper/DLInputStreamTest.java | 12 +-
.../storage/bookkeeper/DLOutputStreamTest.java | 16 +-
.../bookkeeper/test/MockedBookKeeperTestCase.java | 2 +-
.../bookkeeper/bookkeeper/test/PortManager.java | 17 +-
.../bookkeeper/bookkeeper/test/ZooKeeperUtil.java | 16 +-
.../core/impl/PackagesManagementImplTest.java | 8 +-
.../filesystem/FileSystemPackagesStorageTest.java | 2 +-
.../proxy/extensions/MockProxyExtension.java | 5 +-
.../proxy/extensions/ProxyExtensionUtilsTest.java | 17 +-
.../ProxyExtensionWithClassLoaderTest.java | 18 +-
.../proxy/extensions/ProxyExtensionsTest.java | 24 +-
.../extensions/SimpleProxyExtensionTestBase.java | 48 +-
.../server/AdminProxyHandlerKeystoreTLSTest.java | 21 +-
.../proxy/server/AuthedAdminProxyHandlerTest.java | 9 +-
.../proxy/server/BrokerProxyValidatorTest.java | 4 +-
.../proxy/server/FunctionWorkerRoutingTest.java | 11 +-
.../InvalidProxyConfigForAuthorizationTest.java | 1 -
.../proxy/server/ProxyAdditionalServletTest.java | 53 +-
.../ProxyAuthenticatedProducerConsumerTest.java | 36 +-
.../proxy/server/ProxyAuthenticationTest.java | 428 ++++++-------
.../proxy/server/ProxyConfigurationTest.java | 24 +-
.../server/ProxyConnectionThrottlingTest.java | 12 +-
.../server/ProxyEnableHAProxyProtocolTest.java | 16 +-
.../proxy/server/ProxyForwardAuthDataTest.java | 10 +-
.../pulsar/proxy/server/ProxyIsAHttpProxyTest.java | 29 +-
.../server/ProxyKeyStoreTlsTransportTest.java | 8 +-
.../proxy/server/ProxyKeyStoreTlsWithAuthTest.java | 9 +-
.../server/ProxyKeyStoreTlsWithoutAuthTest.java | 6 +-
.../proxy/server/ProxyLookupThrottlingTest.java | 19 +-
.../pulsar/proxy/server/ProxyMutualTlsTest.java | 22 +-
.../proxy/server/ProxyPrometheusMetricsTest.java | 3 +-
.../pulsar/proxy/server/ProxyRefreshAuthTest.java | 2 +-
.../proxy/server/ProxyRolesEnforcementTest.java | 3 +-
.../proxy/server/ProxyServiceStarterTest.java | 9 +-
.../proxy/server/ProxyServiceTlsStarterTest.java | 9 +-
.../apache/pulsar/proxy/server/ProxyStatsTest.java | 14 +-
.../org/apache/pulsar/proxy/server/ProxyTest.java | 8 +-
.../apache/pulsar/proxy/server/ProxyTlsTest.java | 16 +-
.../pulsar/proxy/server/ProxyTlsWithAuthTest.java | 21 +-
.../server/ProxyWithAuthorizationNegTest.java | 51 +-
.../proxy/server/ProxyWithAuthorizationTest.java | 123 ++--
.../server/ProxyWithJwtAuthorizationTest.java | 42 +-
.../server/ProxyWithoutServiceDiscoveryTest.java | 15 +-
.../SuperUserAuthedAdminProxyHandlerTest.java | 12 +-
.../server/UnauthedAdminProxyHandlerTest.java | 8 +-
.../proxy/util/CmdGenerateDocumentationTest.java | 2 +-
.../proxy/socket/client/PerformanceClientTest.java | 4 +-
.../Oauth2PerformanceTransactionTest.java | 2 +-
.../pulsar/testclient/PerfClientUtilsTest.java | 6 +-
.../testclient/PerformanceBaseArgumentsTest.java | 6 +-
.../pulsar/testclient/PerformanceProducerTest.java | 8 +-
.../testclient/PerformanceTransactionTest.java | 11 +-
.../testclient/TestDefaultMessageFormatter.java | 10 +-
.../MLTransactionMetadataStoreTest.java | 24 +-
.../TransactionMetadataStoreProviderTest.java | 2 -
.../transaction/coordinator/TxnStatusTest.java | 8 +-
.../coordinator/impl/MLTransactionLogImplTest.java | 37 +-
.../impl/TxnBatchedPositionImplTest.java | 10 +-
.../coordinator/impl/TxnLogBufferedWriterTest.java | 48 +-
.../coordinator/test/MockedBookKeeperTestCase.java | 2 +-
.../websocket/AbstractWebSocketHandlerTest.java | 17 +-
.../pulsar/websocket/LookupProtocolTest.java | 16 +-
.../pulsar/websocket/PingPongSupportTest.java | 11 +-
.../pulsar/websocket/ProducerHandlerTest.java | 32 +-
.../apache/pulsar/websocket/ReaderHandlerTest.java | 28 +-
.../WebSocketHttpServletRequestWrapperTest.java | 6 +-
.../websocket/WebSocketProxyConfigurationTest.java | 17 +-
.../websocket/admin/WebSocketWebResourceTest.java | 23 +-
.../service/WebSocketProxyConfigurationTest.java | 20 +-
.../slf4j/StructuredEventLogTest.java | 23 +-
.../pulsar/tests/integration/PulsarContainer.java | 6 +-
.../apache/pulsar/tests/integration/SmokeTest.java | 3 +-
.../pulsar/tests/integration/PulsarContainer.java | 6 +-
.../apache/pulsar/tests/integration/SmokeTest.java | 3 +-
.../pulsar/tests/integration/PulsarContainer.java | 6 +-
.../apache/pulsar/tests/integration/SmokeTest.java | 3 +-
.../pulsar/tests/integration/admin/AdminTest.java | 1 -
.../token/PulsarTokenAuthenticationBaseSuite.java | 8 +-
.../auth/token/TokenAuthWithPublicPrivateKeys.java | 3 -
.../auth/token/TokenAuthWithSymmetricKeys.java | 4 +-
.../{ClientTest2_3.java => ClientTest22.java} | 5 +-
.../{ClientTest2_2.java => ClientTest23.java} | 5 +-
.../{ClientTest2_4.java => ClientTest24.java} | 5 +-
.../{ClientTest2_5.java => ClientTest25.java} | 5 +-
...te2_2.java => PulsarStandaloneTestSuite22.java} | 4 +-
...te2_3.java => PulsarStandaloneTestSuite23.java} | 4 +-
...te2_4.java => PulsarStandaloneTestSuite24.java} | 4 +-
...te2_5.java => PulsarStandaloneTestSuite25.java} | 4 +-
.../{SmokeTest2_2.java => SmokeTest22.java} | 2 +-
.../{SmokeTest2_3.java => SmokeTest23.java} | 2 +-
.../{SmokeTest2_4.java => SmokeTest24.java} | 2 +-
.../{SmokeTest2_5.java => SmokeTest25.java} | 2 +-
...BookkeeperInstallWithHttpServerEnabledTest.java | 8 +-
...erInstallWithEntryMetadataInterceptorsTest.java | 11 +-
.../pulsar/tests/integration/cli/CLITest.java | 2 +-
.../tests/integration/cli/ClientToolTest.java | 15 +-
.../cli/ClusterMetadataTearDownTest.java | 5 +-
.../integration/cli/FileSystemPackagesCliTest.java | 12 +-
.../tests/integration/cli/FunctionsCLITest.java | 1 -
.../tests/integration/cli/HealthCheckTest.java | 5 -
.../tests/integration/cli/PackagesCliTest.java | 14 +-
.../pulsar/tests/integration/cli/PerfToolTest.java | 42 +-
.../tests/integration/cli/PulsarVersionTest.java | 4 +-
.../integration/cli/SchemaUpdateStrategyTest.java | 25 +-
.../SchemaCompatibilityStrategyTest.java | 5 +-
.../integration/compaction/TestCompaction.java | 25 +-
.../integration/containers/ChaosContainer.java | 3 +-
.../containers/DebeziumMsSqlContainer.java | 4 +-
.../containers/DebeziumOracleDbContainer.java | 4 +-
.../integration/containers/HdfsContainer.java | 30 +-
.../containers/PulsarInitMetadataContainer.java | 2 +-
.../tests/integration/containers/S3Container.java | 2 +-
.../containers/StandaloneContainer.java | 1 -
.../integration/functions/PulsarFunctionsTest.java | 25 +-
.../integration/functions/PulsarStateTest.java | 15 +-
.../functions/go/PulsarFunctionsGoTest.java | 6 +-
.../functions/java/PulsarFunctionsJavaTest.java | 8 +-
.../java/PulsarWorkerRebalanceDrainTest.java | 55 +-
.../python/PulsarFunctionsPythonTest.java | 6 +-
.../python/PulsarFunctionsPythonThreadTest.java | 2 +-
.../functions/utils/CommandGenerator.java | 4 +-
.../io/PulsarGenericObjectSinkTest.java | 41 +-
.../tests/integration/io/PulsarIOTestRunner.java | 18 +-
.../tests/integration/io/RabbitMQSinkTester.java | 19 +-
.../tests/integration/io/RabbitMQSourceTester.java | 8 +-
.../io/SinkWithTransformFunctionTest.java | 4 +-
.../integration/io/sinks/CassandraSinkTester.java | 15 +-
.../io/sinks/ElasticSearchSinkTester.java | 4 +-
.../tests/integration/io/sinks/HdfsSinkTester.java | 73 ++-
.../io/sinks/JdbcPostgresSinkTester.java | 21 +-
.../integration/io/sinks/KinesisSinkTester.java | 21 +-
.../integration/io/sinks/PulsarIOSinkRunner.java | 39 +-
.../tests/integration/io/sinks/SinkTester.java | 1 -
.../io/sources/AvroKafkaSourceTest.java | 30 +-
.../integration/io/sources/BatchSourceTest.java | 24 +-
.../io/sources/GenericRecordSourceTest.java | 11 +-
.../integration/io/sources/KafkaSourceTester.java | 1 -
.../integration/io/sources/MongoSourceTester.java | 30 +-
.../io/sources/PulsarIOSourceRunner.java | 26 +-
.../io/sources/PulsarSourcePropertyTest.java | 12 +-
.../tests/integration/io/sources/SourceTester.java | 24 +-
.../debezium/DebeziumMongoDbSourceTester.java | 42 +-
.../debezium/DebeziumMsSqlSourceTester.java | 12 +-
.../debezium/DebeziumMySqlSourceTester.java | 20 +-
.../debezium/DebeziumOracleDbSourceTester.java | 15 +-
.../debezium/DebeziumPostgreSqlSourceTester.java | 34 +-
.../debezium/PulsarDebeziumOracleSourceTest.java | 9 +-
.../debezium/PulsarDebeziumSourcesTest.java | 26 +-
.../debezium/PulsarIODebeziumSourceRunner.java | 5 +-
.../loadbalance/ExtensibleLoadManagerTest.java | 4 +-
.../integration/messaging/GeoReplicationTest.java | 12 +-
.../tests/integration/messaging/MessagingBase.java | 16 +-
.../integration/messaging/TopicMessagingBase.java | 31 +-
.../metrics/OpenTelemetrySanityTest.java | 3 +-
.../tests/integration/offload/TestBaseOffload.java | 17 +-
.../integration/offload/TestFileSystemOffload.java | 14 +-
.../integration/offload/TestOffloadDeletionFS.java | 14 +-
.../tests/integration/offload/TestS3Offload.java | 10 +-
.../offload/TestUniversalConfigurations.java | 14 +-
.../tests/integration/oxia/OxiaSmokeTest.java | 2 +-
.../plugins/TestAdditionalServlets.java | 13 +-
.../plugins/TestBrokerInterceptors.java | 7 +-
.../integration/plugins/TestEntryFilters.java | 6 +-
.../tests/integration/python/PythonSchemaTest.java | 8 +-
.../tests/integration/schema/JodaTimeTest.java | 24 +-
.../tests/integration/schema/SchemaTest.java | 25 +-
.../pulsar/tests/integration/schema/Schemas.java | 22 +-
.../tests/integration/semantics/SemanticsTest.java | 5 +-
.../tests/integration/suites/PulsarTestSuite.java | 7 +-
.../tests/integration/tls/ClientTlsTest.java | 6 +-
.../integration/topics/TestTopicDeletion.java | 26 +-
.../integration/topologies/ClientTestBase.java | 8 +-
.../integration/topologies/PulsarCluster.java | 2 +-
.../integration/topologies/PulsarClusterSpec.java | 10 +-
.../topologies/PulsarClusterTestBase.java | 6 +-
.../integration/topologies/PulsarGeoCluster.java | 2 +-
.../topologies/PulsarGeoClusterTestBase.java | 1 -
.../upgrade/PulsarUpgradeDowngradeTest.java | 11 +-
.../tests/integration/websocket/TestWebSocket.java | 4 +-
.../integration/websocket/WebSocketTestSuite.java | 24 +-
.../resources/pulsar-backwards-compatibility.xml | 16 +-
.../pulsar/tests/integration/PulsarContainer.java | 6 +-
.../integration/SimpleProducerConsumerTest.java | 101 +--
.../apache/pulsar/tests/integration/SmokeTest.java | 7 +-
.../pulsar/tests/integration/PulsarContainer.java | 6 +-
.../integration/SimpleProducerConsumerTest.java | 97 +--
.../apache/pulsar/tests/integration/SmokeTest.java | 7 +-
.../pulsar/tests/integration/PulsarContainer.java | 6 +-
.../integration/SimpleProducerConsumerTest.java | 97 +--
.../apache/pulsar/tests/integration/SmokeTest.java | 3 +-
.../offload/filesystem/FileStoreTestBase.java | 2 +-
.../impl/FileSystemManagedLedgerOffloaderTest.java | 12 +-
.../impl/FileSystemOffloaderLocalFileTest.java | 12 +-
.../jcloud/BlobStoreBackedInputStreamTest.java | 30 +-
.../mledger/offload/jcloud/BlobStoreTestBase.java | 6 +-
.../impl/BlobStoreManagedLedgerOffloaderBase.java | 10 +-
...obStoreManagedLedgerOffloaderStreamingTest.java | 6 +-
.../impl/BlobStoreManagedLedgerOffloaderTest.java | 63 +-
.../impl/BlockAwareSegmentInputStreamTest.java | 33 +-
.../jcloud/impl/BufferedOffloadStreamTest.java | 2 +-
.../offload/jcloud/impl/DataBlockHeaderTest.java | 6 +-
.../offload/jcloud/impl/DataBlockUtilsTest.java | 5 +-
.../offload/jcloud/impl/OffloadIndexTest.java | 11 +-
.../offload/jcloud/impl/OffsetsCacheTest.java | 4 +-
.../AbstractJCloudBlobStoreFactoryTest.java | 37 +-
...Tests.java => JCloudBlobStoreProviderTest.java} | 42 +-
...ts.java => TieredStorageConfigurationTest.java} | 58 +-
...sts.java => TransientBlobStoreFactoryTest.java} | 14 +-
1132 files changed, 13261 insertions(+), 10955 deletions(-)
diff --git a/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerBase.java b/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerBase.java
index 7a97a84bc84..92de6ef1e99 100644
--- a/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerBase.java
+++ b/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerBase.java
@@ -19,7 +19,6 @@
package org.apache.pulsar.client;
import static org.mockito.Mockito.spy;
-
import com.google.common.collect.Sets;
import java.util.HashMap;
import java.util.Map;
diff --git a/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerTest.java b/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerTest.java
index 624315ae0c9..6fe35deef28 100644
--- a/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerTest.java
+++ b/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerTest.java
@@ -34,7 +34,7 @@ public class TlsProducerConsumerTest extends TlsProducerConsumerBase {
/**
* verifies that messages whose size is larger than 2^14 bytes (max size of single TLS chunk) can be
- * produced/consumed
+ * produced/consumed.
*
* @throws Exception
*/
@@ -42,8 +42,8 @@ public class TlsProducerConsumerTest extends TlsProducerConsumerBase {
public void testTlsLargeSizeMessage() throws Exception {
log.info("-- Starting {} test --", methodName);
- final int MESSAGE_SIZE = 16 * 1024 + 1;
- log.info("-- message size {} --", MESSAGE_SIZE);
+ final int messageSize = 16 * 1024 + 1;
+ log.info("-- message size {} --", messageSize);
internalSetUpForClient(true, pulsar.getBrokerServiceUrlTls());
internalSetUpForNamespace();
@@ -54,7 +54,7 @@ public class TlsProducerConsumerTest extends TlsProducerConsumerBase {
Producer<byte[]> producer = pulsarClient.newProducer().topic("persistent://my-property/use/my-ns/my-topic1")
.create();
for (int i = 0; i < 10; i++) {
- byte[] message = new byte[MESSAGE_SIZE];
+ byte[] message = new byte[messageSize];
Arrays.fill(message, (byte) i);
producer.send(message);
}
@@ -62,7 +62,7 @@ public class TlsProducerConsumerTest extends TlsProducerConsumerBase {
Message<byte[]> msg = null;
for (int i = 0; i < 10; i++) {
msg = consumer.receive(5, TimeUnit.SECONDS);
- byte[] expected = new byte[MESSAGE_SIZE];
+ byte[] expected = new byte[messageSize];
Arrays.fill(expected, (byte) i);
Assert.assertEquals(expected, msg.getData());
}
@@ -76,8 +76,8 @@ public class TlsProducerConsumerTest extends TlsProducerConsumerBase {
public void testTlsClientAuthOverBinaryProtocol() throws Exception {
log.info("-- Starting {} test --", methodName);
- final int MESSAGE_SIZE = 16 * 1024 + 1;
- log.info("-- message size {} --", MESSAGE_SIZE);
+ final int messageSize = 16 * 1024 + 1;
+ log.info("-- message size {} --", messageSize);
internalSetUpForNamespace();
// Test 1 - Using TLS on binary protocol without sending certs - expect failure
@@ -106,8 +106,8 @@ public class TlsProducerConsumerTest extends TlsProducerConsumerBase {
public void testTlsClientAuthOverHTTPProtocol() throws Exception {
log.info("-- Starting {} test --", methodName);
- final int MESSAGE_SIZE = 16 * 1024 + 1;
- log.info("-- message size {} --", MESSAGE_SIZE);
+ final int messageSize = 16 * 1024 + 1;
+ log.info("-- message size {} --", messageSize);
internalSetUpForNamespace();
// Test 1 - Using TLS on https without sending certs - expect failure
diff --git a/buildtools/src/main/resources/pulsar/suppressions.xml b/buildtools/src/main/resources/pulsar/suppressions.xml
index 57a01c60f6a..33a3a81eac0 100644
--- a/buildtools/src/main/resources/pulsar/suppressions.xml
+++ b/buildtools/src/main/resources/pulsar/suppressions.xml
@@ -37,8 +37,14 @@
<suppress checks=".*" files=".+[\\/]generated-sources[\\/].+\.java"/>
<suppress checks=".*" files=".+[\\/]generated-test-sources[\\/].+\.java"/>
- <!-- suppress most all checks expect below-->
- <suppress checks="^(?!.*(UnusedImports|IllegalImport)).*$" files=".*[\\/]src[\\/]test[\\/].*"/>
+ <!-- suppress LineLength due to usage of multi-line String with split function -->
+ <suppress files="ExtensibleLoadManagerImplTest.java" checks="LineLength"/>
+ <suppress files="BundleSplitterTaskTest.java" checks="TodoComment"/>
+ <suppress files="BlobStoreTestBase.java" checks="TodoComment"/>
+ <suppress files="BlobStoreManagedLedgerOffloaderBase.java" checks="TodoComment"/>
+ <suppress files="DebeziumMsSqlSourceTester.java" checks="RegexpSinglelineJava"/>
+ <suppress files="DebeziumOracleDbSourceTester.java" checks="RegexpSinglelineJava"/>
+ <suppress files="PulsarIODebeziumSourceRunner.java" checks="RegexpSinglelineJava"/>
<suppress checks="IllegalImport" files="ProxyServiceStarter.java"/>
diff --git a/buildtools/src/test/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapterTest.java b/buildtools/src/test/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapterTest.java
index c25f751d741..cac450d4e21 100644
--- a/buildtools/src/test/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapterTest.java
+++ b/buildtools/src/test/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapterTest.java
@@ -353,9 +353,9 @@ public class BetweenTestClassesListenerAdapterTest {
@Override
public String toString() {
- return "FactoryMethodCase{" +
- "id=" + id +
- '}';
+ return "FactoryMethodCase{"
+ + "id=" + id
+ + '}';
}
}
@@ -387,9 +387,9 @@ public class BetweenTestClassesListenerAdapterTest {
@Override
public String toString() {
- return "FactoryMethodCaseWithoutAfterClass{" +
- "id=" + id +
- '}';
+ return "FactoryMethodCaseWithoutAfterClass{"
+ + "id=" + id
+ + '}';
}
}
}
\ No newline at end of file
diff --git a/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportSuccessTest.java b/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportSuccessTest.java
index d449f1ffb0a..7f5043b2f9e 100644
--- a/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportSuccessTest.java
+++ b/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportSuccessTest.java
@@ -24,7 +24,7 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
- * Tests that TestRetrySupport doesn't call setup & cleanup when tests are successful
+ * Tests that TestRetrySupport doesn't call setup & cleanup when tests are successful.
*/
public class TestRetrySupportSuccessTest extends TestRetrySupport {
private int setupCallCount;
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/EntryCacheManagerTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/EntryCacheManagerTest.java
index f00efb27ca5..8a1fd30e38e 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/EntryCacheManagerTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/EntryCacheManagerTest.java
@@ -20,19 +20,17 @@ package org.apache.bookkeeper.mledger.impl;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-
import lombok.Cleanup;
import org.apache.bookkeeper.client.api.ReadHandle;
import org.apache.bookkeeper.mledger.AsyncCallbacks;
@@ -397,7 +395,7 @@ public class EntryCacheManagerTest extends MockedBookKeeperTestCase {
when(ml1.getLastConfirmedEntry()).thenReturn(PositionFactory.create(1L, 1L));
when(ml1.getOptionalLedgerInfo(lh.getId())).thenReturn(Optional.of(mock(
MLDataFormats.ManagedLedgerInfo.LedgerInfo.class)));
- entryCache.asyncReadEntry(lh, PositionFactory.create(1L,1L), new AsyncCallbacks.ReadEntryCallback() {
+ entryCache.asyncReadEntry(lh, PositionFactory.create(1L, 1L), new AsyncCallbacks.ReadEntryCallback() {
public void readEntryComplete(Entry entry, Object ctx) {
Assert.assertNotEquals(entry, null);
entry.release();
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/EntryCacheTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/EntryCacheTest.java
index 551aa80bc07..a7ce874d7c3 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/EntryCacheTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/EntryCacheTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
-
import io.netty.buffer.Unpooled;
import java.util.ArrayList;
import java.util.List;
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/InflightReadsLimiterIntegrationTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/InflightReadsLimiterIntegrationTest.java
index 6676baf8b55..99bd50ecbe2 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/InflightReadsLimiterIntegrationTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/InflightReadsLimiterIntegrationTest.java
@@ -86,7 +86,7 @@ public class InflightReadsLimiterIntegrationTest extends MockedBookKeeperTestCas
final RangeEntryCacheManagerImpl rangeEntryCacheManager =
(RangeEntryCacheManagerImpl) factory.getEntryCacheManager();
final InflightReadsLimiter limiter = rangeEntryCacheManager.getInflightReadsLimiter();
- final long totalCapacity =limiter.getRemainingBytes();
+ final long totalCapacity = limiter.getRemainingBytes();
// final ManagedCursorImpl c1 = (ManagedCursorImpl) ml.openCursor("c1");
for (byte i = 1; i < 127; i++) {
log.info("add entry: " + i);
@@ -111,7 +111,7 @@ public class InflightReadsLimiterIntegrationTest extends MockedBookKeeperTestCas
readCompleteSignal1.await();
Object res = invocation.callRealMethod();
return res;
- } else if(secondReadEntries.contains(firstEntry)) {
+ } else if (secondReadEntries.contains(firstEntry)) {
final CompletableFuture res = new CompletableFuture<>();
threadFactory.newThread(() -> {
try {
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorConcurrencyTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorConcurrencyTest.java
index ebcbe31d5e7..f7b6e755bce 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorConcurrencyTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorConcurrencyTest.java
@@ -21,9 +21,7 @@ package org.apache.bookkeeper.mledger.impl;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
-
import com.google.common.collect.Lists;
-
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@@ -135,7 +133,7 @@ public class ManagedCursorConcurrencyTest extends MockedBookKeeperTestCase {
final ManagedCursor cursor = ledger.openCursor("c1");
final CompletableFuture<String> closeFuture = new CompletableFuture<>();
- final String CLOSED = "closed";
+ final String closed = "closed";
final List<Position> addedEntries = new ArrayList();
@@ -182,7 +180,7 @@ public class ManagedCursorConcurrencyTest extends MockedBookKeeperTestCase {
@Override
public void closeComplete(Object ctx) {
log.info("Successfully closed cursor ledger");
- closeFuture.complete(CLOSED);
+ closeFuture.complete(closed);
}
@Override
@@ -206,7 +204,7 @@ public class ManagedCursorConcurrencyTest extends MockedBookKeeperTestCase {
counter.await();
assertFalse(gotException.get());
- assertEquals(closeFuture.get(), CLOSED);
+ assertEquals(closeFuture.get(), closed);
}
@Test(timeOut = 30000)
@@ -270,27 +268,27 @@ public class ManagedCursorConcurrencyTest extends MockedBookKeeperTestCase {
final ManagedCursor cursor = ledger.openCursor("c1");
- final int N = 1000;
- final List<Position> addedEntries = Lists.newArrayListWithExpectedSize(N);
+ final int num = 1000;
+ final List<Position> addedEntries = Lists.newArrayListWithExpectedSize(num);
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
Position pos = ledger.addEntry("entry".getBytes());
addedEntries.add(pos);
}
- final int Threads = 10;
- final CyclicBarrier barrier = new CyclicBarrier(Threads);
- final CountDownLatch counter = new CountDownLatch(Threads);
+ final int threads = 10;
+ final CyclicBarrier barrier = new CyclicBarrier(threads);
+ final CountDownLatch counter = new CountDownLatch(threads);
final AtomicBoolean gotException = new AtomicBoolean(false);
- for (int thread = 0; thread < Threads; thread++) {
+ for (int thread = 0; thread < threads; thread++) {
final int myThread = thread;
cachedExecutor.execute(() -> {
try {
barrier.await();
- for (int i = 0; i < N; i++) {
- int threadId = i % Threads;
+ for (int i = 0; i < num; i++) {
+ int threadId = i % threads;
if (threadId == myThread) {
cursor.delete(addedEntries.get(i));
}
@@ -321,8 +319,8 @@ public class ManagedCursorConcurrencyTest extends MockedBookKeeperTestCase {
cursors.add(cursor);
}
- final int N = 100;
- for (int i = 0; i < N; i++) {
+ final int num = 100;
+ for (int i = 0; i < num; i++) {
ledger.addEntry(("entry" + i).getBytes());
}
long currentLedger = cursors.get(0).getMarkDeletedPosition().getLedgerId();
@@ -341,7 +339,7 @@ public class ManagedCursorConcurrencyTest extends MockedBookKeeperTestCase {
cachedExecutor.execute(() -> {
try {
barrier.await();
- for (int j = 0; j < N; j++) {
+ for (int j = 0; j < num; j++) {
String expected = "entry" + j;
String data = new String(cursor.readEntries(1).get(0).getDataAndRelease());
if ((!expected.equals(data)) && result.get() == null) {
@@ -368,10 +366,10 @@ public class ManagedCursorConcurrencyTest extends MockedBookKeeperTestCase {
final ManagedCursor cursor = ledger.openCursor("c1");
- final int N = 1000;
- final List<Position> addedEntries = Lists.newArrayListWithExpectedSize(N);
+ final int num = 1000;
+ final List<Position> addedEntries = Lists.newArrayListWithExpectedSize(num);
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
Position pos = ledger.addEntry("entry".getBytes());
addedEntries.add(pos);
}
@@ -407,7 +405,7 @@ public class ManagedCursorConcurrencyTest extends MockedBookKeeperTestCase {
counter.await();
- final int readEntries = N - deleteEntries;
+ final int readEntries = num - deleteEntries;
final CountDownLatch readCounter = new CountDownLatch(readEntries);
final AtomicInteger successReadEntries = new AtomicInteger(0);
for (int i = 1; i <= readEntries; i++) {
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorContainerTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorContainerTest.java
index 2afbcef0926..ea6e610ad9b 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorContainerTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorContainerTest.java
@@ -290,12 +290,14 @@ public class ManagedCursorContainerTest {
}
@Override
- public Set<? extends Position> asyncReplayEntries(Set<? extends Position> positions, ReadEntriesCallback callback, Object ctx) {
+ public Set<? extends Position> asyncReplayEntries(Set<? extends Position> positions,
+ ReadEntriesCallback callback, Object ctx) {
return Sets.newConcurrentHashSet();
}
@Override
- public Set<? extends Position> asyncReplayEntries(Set<? extends Position> positions, ReadEntriesCallback callback, Object ctx, boolean sortEntries) {
+ public Set<? extends Position> asyncReplayEntries(Set<? extends Position> positions,
+ ReadEntriesCallback callback, Object ctx, boolean sortEntries) {
return Sets.newConcurrentHashSet();
}
@@ -321,12 +323,12 @@ public class ManagedCursorContainerTest {
}
@Override
- public Entry getNthEntry(int N, IndividualDeletedEntries deletedEntries) {
+ public Entry getNthEntry(int num, IndividualDeletedEntries deletedEntries) {
return null;
}
@Override
- public void asyncGetNthEntry(int N, IndividualDeletedEntries deletedEntries, ReadEntryCallback callback,
+ public void asyncGetNthEntry(int num, IndividualDeletedEntries deletedEntries, ReadEntryCallback callback,
Object ctx) {
}
@@ -449,7 +451,7 @@ public class ManagedCursorContainerTest {
assertNull(container.getSlowestReaderPosition());
// Add no durable cursor
- Position position = PositionFactory.create(5,5);
+ Position position = PositionFactory.create(5, 5);
ManagedCursor cursor1 = spy(new MockManagedCursor(container, "test1", position));
doReturn(false).when(cursor1).isDurable();
doReturn(position).when(cursor1).getReadPosition();
@@ -457,7 +459,7 @@ public class ManagedCursorContainerTest {
assertEquals(container.getSlowestReaderPosition(), PositionFactory.create(5, 5));
// Add no durable cursor
- position = PositionFactory.create(1,1);
+ position = PositionFactory.create(1, 1);
ManagedCursor cursor2 = spy(new MockManagedCursor(container, "test2", position));
doReturn(false).when(cursor2).isDurable();
doReturn(position).when(cursor2).getReadPosition();
@@ -465,13 +467,13 @@ public class ManagedCursorContainerTest {
assertEquals(container.getSlowestReaderPosition(), PositionFactory.create(1, 1));
// Move forward cursor, cursor1 = 5:5, cursor2 = 5:6, slowest is 5:5
- position = PositionFactory.create(5,6);
+ position = PositionFactory.create(5, 6);
container.cursorUpdated(cursor2, position);
doReturn(position).when(cursor2).getReadPosition();
assertEquals(container.getSlowestReaderPosition(), PositionFactory.create(5, 5));
// Move forward cursor, cursor1 = 5:8, cursor2 = 5:6, slowest is 5:6
- position = PositionFactory.create(5,8);
+ position = PositionFactory.create(5, 8);
doReturn(position).when(cursor1).getReadPosition();
container.cursorUpdated(cursor1, position);
assertEquals(container.getSlowestReaderPosition(), PositionFactory.create(5, 6));
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorIndividualDeletedMessagesTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorIndividualDeletedMessagesTest.java
index 3d4de5b1f49..b6c4cc5895d 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorIndividualDeletedMessagesTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorIndividualDeletedMessagesTest.java
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.testng.Assert.assertEquals;
-
import com.google.common.collect.Range;
import java.lang.reflect.Method;
import java.util.ArrayList;
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorInfoMetadataTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorInfoMetadataTest.java
index 70ba4b543ec..1f8243469ce 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorInfoMetadataTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorInfoMetadataTest.java
@@ -36,7 +36,7 @@ import org.testng.annotations.Test;
*/
@Slf4j
public class ManagedCursorInfoMetadataTest {
- private final String INVALID_TYPE = "INVALID_TYPE";
+ private static final String INVALID_TYPE = "INVALID_TYPE";
@DataProvider(name = "compressionTypeProvider")
private Object[][] compressionTypeProvider() {
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorListAckTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorListAckTest.java
index 0a3afcb2a61..c4d3b076ba3 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorListAckTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorListAckTest.java
@@ -19,12 +19,9 @@
package org.apache.bookkeeper.mledger.impl;
import static org.testng.Assert.assertEquals;
-
import com.google.common.collect.Lists;
-
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
-
import org.apache.bookkeeper.mledger.ManagedCursor;
import org.apache.bookkeeper.mledger.ManagedLedger;
import org.apache.bookkeeper.mledger.ManagedLedgerConfig;
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
index ea805e99aa9..34b67c5d020 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
@@ -182,7 +182,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
ledger.addEntry(new byte[]{4});
ledger.addEntry(new byte[]{5});
- ManagedCursorImpl cursor = (ManagedCursorImpl) ledger.openCursor("c_testOpenCursorWithNullInitialPosition", null);
+ ManagedCursorImpl cursor =
+ (ManagedCursorImpl) ledger.openCursor("c_testOpenCursorWithNullInitialPosition", null);
assertEquals(cursor.getMarkDeletedPosition(), ledger.getLastConfirmedEntry());
}
@@ -352,7 +353,7 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
bkc.failNow(BKException.Code.NoBookieAvailableException);
// Verify the cursor status will be persistent to ZK even if the cursor ledger creation always fails.
// This time ZK will be written due to catch up.
- Position lastEntry = positions.get(entryCount -1);
+ Position lastEntry = positions.get(entryCount - 1);
cursor.markDelete(lastEntry);
long persistZookeeperSucceed2 = cursor.getStats().getPersistZookeeperSucceed();
assertTrue(persistZookeeperSucceed2 > persistZookeeperSucceed1);
@@ -928,20 +929,20 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
void testConcurrentResetCursor() throws Exception {
ManagedLedger ledger = factory.open("my_test_concurrent_move_ledger");
- final int Messages = 100;
- final int Consumers = 5;
+ final int messages = 100;
+ final int consumers = 5;
List<Future<AtomicBoolean>> futures = new ArrayList();
@Cleanup("shutdownNow")
ExecutorService executor = Executors.newCachedThreadPool();
- final CyclicBarrier barrier = new CyclicBarrier(Consumers + 1);
+ final CyclicBarrier barrier = new CyclicBarrier(consumers + 1);
- for (int i = 0; i < Messages; i++) {
+ for (int i = 0; i < messages; i++) {
ledger.addEntry("test".getBytes());
}
final Position lastPosition = ledger.addEntry("dummy-entry-4".getBytes(Encoding));
- for (int i = 0; i < Consumers; i++) {
+ for (int i = 0; i < consumers; i++) {
final ManagedCursor cursor = ledger.openCursor("tcrc" + i);
final int idx = i;
@@ -1339,9 +1340,9 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
final ManagedCursor c1 = ledger.openCursor("c1");
final AtomicReference<Position> lastPosition = new AtomicReference<Position>();
- final int N = 100;
- final CountDownLatch latch = new CountDownLatch(N);
- for (int i = 0; i < N; i++) {
+ final int num = 100;
+ final CountDownLatch latch = new CountDownLatch(num);
+ for (int i = 0; i < num; i++) {
ledger.asyncAddEntry("entry".getBytes(Encoding), new AddEntryCallback() {
@Override
public void addFailed(ManagedLedgerException exception, Object ctx) {
@@ -1383,16 +1384,16 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
new ManagedLedgerConfig().setMetadataMaxEntriesPerLedger(5));
final ManagedCursor c1 = ledger.openCursor("c1");
- final int N = 100;
+ final int num = 100;
List<Position> positions = new ArrayList();
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
Position p = ledger.addEntry("dummy-entry".getBytes(Encoding));
positions.add(p);
}
- Position lastPosition = positions.get(N - 1);
+ Position lastPosition = positions.get(num - 1);
- final CountDownLatch latch = new CountDownLatch(N);
+ final CountDownLatch latch = new CountDownLatch(num);
for (final Position p : positions) {
c1.asyncMarkDelete(p, new MarkDeleteCallback() {
@Override
@@ -2036,10 +2037,10 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
ManagedLedger ledger = factory.open("my_test_ledger",
new ManagedLedgerConfig().setUnackedRangesOpenCacheSetEnabled(useOpenRangeSet));
- final int Consumers = 10;
- final CountDownLatch counter = new CountDownLatch(Consumers);
+ final int consumers = 10;
+ final CountDownLatch counter = new CountDownLatch(consumers);
- for (int i = 0; i < Consumers; i++) {
+ for (int i = 0; i < consumers; i++) {
ManagedCursor c = ledger.openCursor("c" + i);
c.asyncReadEntriesOrWait(1, new ReadEntriesCallback() {
@@ -2065,15 +2066,15 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
void testReadEntriesOrWaitBlocking() throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger");
- final int Messages = 100;
- final int Consumers = 10;
+ final int messages = 100;
+ final int consumers = 10;
List<Future<Void>> futures = new ArrayList();
@Cleanup("shutdownNow")
ExecutorService executor = Executors.newCachedThreadPool();
- final CyclicBarrier barrier = new CyclicBarrier(Consumers + 1);
+ final CyclicBarrier barrier = new CyclicBarrier(consumers + 1);
- for (int i = 0; i < Consumers; i++) {
+ for (int i = 0; i < consumers; i++) {
final ManagedCursor cursor = ledger.openCursor("c" + i);
futures.add(executor.submit(new Callable<Void>() {
@@ -2081,7 +2082,7 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
public Void call() throws Exception {
barrier.await();
- int toRead = Messages;
+ int toRead = messages;
while (toRead > 0) {
List<Entry> entries = cursor.readEntriesOrWait(10);
assertTrue(entries.size() <= 10);
@@ -2095,7 +2096,7 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
}
barrier.await();
- for (int i = 0; i < Messages; i++) {
+ for (int i = 0; i < messages; i++) {
ledger.addEntry("test".getBytes());
}
@@ -2134,7 +2135,7 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
@Test(dataProvider = "testScanValues", timeOut = 30000)
void testScan(int numEntries, int batchSize) throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger_scan_" + numEntries
- + "_" +batchSize);
+ + "_" + batchSize);
ManagedCursorImpl c1 = (ManagedCursorImpl) ledger.openCursor("c1");
List<Position> positions = new ArrayList<>();
@@ -2235,7 +2236,7 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
positionsFinal.add(entry.getPosition());
return true;
}), batchSize, Long.MAX_VALUE, Long.MAX_VALUE).get());
- assertEquals(0,positionsFinal.size());
+ assertEquals(0, positionsFinal.size());
}
@@ -2855,7 +2856,7 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
ManagedCursorImpl c1 = (ManagedCursorImpl) ledger.openCursor("c1");
Position markDeletedPosition = c1.getMarkDeletedPosition();
- for(int i = 0; i < 10; i++) {
+ for (int i = 0; i < 10; i++) {
ledger.addEntry(("entry" + i).getBytes(Encoding));
}
Position p1 = PositionFactory.create(markDeletedPosition.getLedgerId(), markDeletedPosition.getEntryId() + 1);
@@ -2882,7 +2883,7 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
ManagedCursorImpl c1 = (ManagedCursorImpl) ledger.openCursor("c1");
Position markDeletedPosition = c1.getMarkDeletedPosition();
- for(int i = 0; i < 10; i++) {
+ for (int i = 0; i < 10; i++) {
ledger.addEntry(("entry" + i).getBytes(Encoding));
}
Position p1 = PositionFactory.create(markDeletedPosition.getLedgerId(), markDeletedPosition.getEntryId() + 1);
@@ -2921,26 +2922,26 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
ManagedLedger ledger = factory.open("outOfOrderAcks");
ManagedCursor c1 = ledger.openCursor("c1");
- int N = 10;
+ int num = 10;
List<Position> positions = new ArrayList<>();
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
positions.add(ledger.addEntry("entry".getBytes()));
}
- assertEquals(c1.getNumberOfEntriesInBacklog(false), N);
+ assertEquals(c1.getNumberOfEntriesInBacklog(false), num);
c1.delete(positions.get(3));
- assertEquals(c1.getNumberOfEntriesInBacklog(false), N - 1);
+ assertEquals(c1.getNumberOfEntriesInBacklog(false), num - 1);
c1.delete(positions.get(2));
- assertEquals(c1.getNumberOfEntriesInBacklog(false), N - 2);
+ assertEquals(c1.getNumberOfEntriesInBacklog(false), num - 2);
c1.delete(positions.get(1));
- assertEquals(c1.getNumberOfEntriesInBacklog(false), N - 3);
+ assertEquals(c1.getNumberOfEntriesInBacklog(false), num - 3);
c1.delete(positions.get(0));
- assertEquals(c1.getNumberOfEntriesInBacklog(false), N - 4);
+ assertEquals(c1.getNumberOfEntriesInBacklog(false), num - 4);
}
@Test(timeOut = 20000)
@@ -2948,19 +2949,19 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
ManagedLedger ledger = factory.open("outOfOrderAcks");
ManagedCursor c1 = ledger.openCursor("c1");
- int N = 10;
+ int num = 10;
List<Position> positions = new ArrayList<>();
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
positions.add(ledger.addEntry("entry".getBytes()));
}
- assertEquals(c1.getNumberOfEntriesInBacklog(false), N);
+ assertEquals(c1.getNumberOfEntriesInBacklog(false), num);
// Randomize the ack sequence
Collections.shuffle(positions);
- int toDelete = N;
+ int toDelete = num;
for (Position p : positions) {
assertEquals(c1.getNumberOfEntriesInBacklog(false), toDelete);
c1.delete(p);
@@ -3206,11 +3207,11 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
/**
* <pre>
* Verifies that {@link ManagedCursorImpl#createNewMetadataLedger()} cleans up orphan ledgers if fails to switch new
- * ledger
+ * ledger.
* </pre>
* @throws Exception
*/
- @Test(timeOut=5000)
+ @Test(timeOut = 5000)
public void testLeakFailedLedgerOfManageCursor() throws Exception {
ManagedLedgerConfig mlConfig = new ManagedLedgerConfig();
@@ -3265,7 +3266,7 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
/**
* Verifies cursor persists individually unack range into cursor-ledger if range count is higher than
- * MaxUnackedRangesToPersistInZk
+ * MaxUnackedRangesToPersistInZk.
*
* @throws Exception
*/
@@ -3354,7 +3355,7 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
}
/**
- * Close Cursor without MaxUnackedRangesToPersistInZK: It should store individually unack range into Zk
+ * Close Cursor without MaxUnackedRangesToPersistInZK: It should store individually unack range into Zk.
*
* @throws Exception
*/
@@ -3480,9 +3481,13 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
byte[] entryData = new byte[5];
// write 15 entries, saving position of 5th
- for (int i = 0; i < 4; i++) { ledger.addEntry(entryData); }
+ for (int i = 0; i < 4; i++) {
+ ledger.addEntry(entryData);
+ }
Position deleteAt = ledger.addEntry(entryData);
- for (int i = 0; i < 10; i++) { ledger.addEntry(entryData); }
+ for (int i = 0; i < 10; i++) {
+ ledger.addEntry(entryData);
+ }
assertEquals(cursor.getEstimatedSizeSinceMarkDeletePosition(), 15 * entryData.length);
@@ -3848,13 +3853,16 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
ledger = factory.open("test_batch_indexes_deletion_persistent", managedLedgerConfig);
cursor = ledger.openCursor("c1");
- List<IntRange> deletedIndexes = getAckedIndexRange(cursor.getDeletedBatchIndexesAsLongArray(positions[5]), 10);
+ List<IntRange> deletedIndexes =
+ getAckedIndexRange(cursor.getDeletedBatchIndexesAsLongArray(positions[5]), 10);
Assert.assertEquals(deletedIndexes.size(), 1);
Assert.assertEquals(deletedIndexes.get(0).getStart(), 3);
Assert.assertEquals(deletedIndexes.get(0).getEnd(), 6);
Assert.assertEquals(cursor.getMarkDeletedPosition(), positions[4]);
- deleteBatchIndex(cursor, positions[5], 10, Lists.newArrayList(new IntRange().setStart(0).setEnd(9)));
- deletedIndexes = getAckedIndexRange(cursor.getDeletedBatchIndexesAsLongArray(positions[5]), 10);
+ deleteBatchIndex(cursor, positions[5], 10,
+ Lists.newArrayList(new IntRange().setStart(0).setEnd(9)));
+ deletedIndexes =
+ getAckedIndexRange(cursor.getDeletedBatchIndexesAsLongArray(positions[5]), 10);
Assert.assertNull(deletedIndexes);
Assert.assertEquals(cursor.getMarkDeletedPosition(), positions[5]);
@@ -3872,7 +3880,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
deleteIndexes.forEach(intRange -> {
bitSet.clear(intRange.getStart(), intRange.getEnd() + 1);
});
- Position pos = AckSetStateUtil.createPositionWithAckSet(position.getLedgerId(), position.getEntryId(), bitSet.toLongArray());
+ Position pos = AckSetStateUtil.createPositionWithAckSet(position.getLedgerId(), position.getEntryId(),
+ bitSet.toLongArray());
cursor.asyncDelete(pos,
new DeleteCallback() {
@@ -3896,7 +3905,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
bitSet.set(0, batchSize);
bitSet.clear(0, batchIndex + 1);
- Position pos = AckSetStateUtil.createPositionWithAckSet(position.getLedgerId(), position.getEntryId(), bitSet.toLongArray());
+ Position pos = AckSetStateUtil.createPositionWithAckSet(position.getLedgerId(), position.getEntryId(),
+ bitSet.toLongArray());
cursor.asyncMarkDelete(pos, new MarkDeleteCallback() {
@Override
@@ -4191,7 +4201,7 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
}
assertEquals(c1.getTotalNonContiguousDeletedMessagesRange(), 0);
- assertEquals(c1.getMarkDeletedPosition(), positions.get(positions.size() -1));
+ assertEquals(c1.getMarkDeletedPosition(), positions.get(positions.size() - 1));
}
@Test
@@ -4272,7 +4282,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
Field field = ManagedLedgerImpl.class.getDeclaredField("ledgers");
field.setAccessible(true);
- ((ConcurrentSkipListMap<Long, MLDataFormats.ManagedLedgerInfo.LedgerInfo>) field.get(ledger)).remove(position.getLedgerId());
+ ((ConcurrentSkipListMap<Long, MLDataFormats.ManagedLedgerInfo.LedgerInfo>) field.get(ledger))
+ .remove(position.getLedgerId());
field = ManagedCursorImpl.class.getDeclaredField("markDeletePosition");
field.setAccessible(true);
field.set(managedCursor, PositionFactory.create(position1.getLedgerId(), -1));
@@ -4289,7 +4300,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
managedLedgerConfig.setMetadataMaxEntriesPerLedger(2);
managedLedgerConfig.setMinimumRolloverTime(0, TimeUnit.MILLISECONDS);
managedLedgerConfig.setThrottleMarkDelete(0);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("testCursorNoRolloverIfNoMetadataSession", managedLedgerConfig);
+ ManagedLedgerImpl ledger =
+ (ManagedLedgerImpl) factory.open("testCursorNoRolloverIfNoMetadataSession", managedLedgerConfig);
ManagedCursorImpl cursor = (ManagedCursorImpl) ledger.openCursor("test");
List<Position> positions = new ArrayList<>();
@@ -4381,8 +4393,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
};
@Cleanup final MockedStatic<OpReadEntry> mockedStaticOpReadEntry = Mockito.mockStatic(OpReadEntry.class);
- mockedStaticOpReadEntry.when(() -> OpReadEntry.create(any(), any(), anyInt(), any(), any(), any(), any()))
- .thenAnswer(__ -> createOpReadEntry.get());
+ mockedStaticOpReadEntry.when(() -> OpReadEntry.create(any(), any(), anyInt(), any(),
+ any(), any(), any())).thenAnswer(__ -> createOpReadEntry.get());
final ManagedLedgerConfig ledgerConfig = new ManagedLedgerConfig();
ledgerConfig.setNewEntriesCheckDelayInMillis(10);
@@ -4473,7 +4485,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
@Test
public void testLazyCursorLedgerCreationForSubscriptionCreation() throws Exception {
ManagedLedgerConfig managedLedgerConfig = new ManagedLedgerConfig();
- ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("testLazyCursorLedgerCreation", managedLedgerConfig);
+ ManagedLedgerImpl ledger =
+ (ManagedLedgerImpl) factory.open("testLazyCursorLedgerCreation", managedLedgerConfig);
Position p1 = ledger.addEntry("test".getBytes());
ManagedCursorImpl cursor = (ManagedCursorImpl) ledger.openCursor("test");
assertEquals(cursor.getMarkDeletedPosition(), p1);
@@ -4612,7 +4625,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
return inv.callRealMethod();
})
.when(ledger)
- .asyncReadEntry(Mockito.any(ReadHandle.class), Mockito.anyLong(), Mockito.anyLong(), Mockito.any(), Mockito.any());
+ .asyncReadEntry(Mockito.any(ReadHandle.class), Mockito.anyLong(),
+ Mockito.anyLong(), Mockito.any(), Mockito.any());
@Cleanup
ManagedCursor cursor = ledger.openCursor("c");
@@ -4717,7 +4731,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
return inv.callRealMethod();
})
.when(ledger)
- .asyncReadEntry(Mockito.any(ReadHandle.class), Mockito.anyLong(), Mockito.anyLong(), Mockito.any(), Mockito.any());
+ .asyncReadEntry(Mockito.any(ReadHandle.class), Mockito.anyLong(),
+ Mockito.anyLong(), Mockito.any(), Mockito.any());
@Cleanup
ManagedCursor cursor = ledger.openCursor("c");
@@ -4906,7 +4921,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
managedLedgerConfig.setMaxEntriesPerLedger(2);
managedLedgerConfig.setMinimumRolloverTime(0, TimeUnit.MILLISECONDS);
@Cleanup
- ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("testFindNewestMatching_SearchAllAvailableEntries_ByStartAndEnd", managedLedgerConfig);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory
+ .open("testFindNewestMatching_SearchAllAvailableEntries_ByStartAndEnd", managedLedgerConfig);
@Cleanup
ManagedCursor managedCursor = ledger.openCursor("test");
@@ -4928,7 +4944,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
AtomicBoolean failed = new AtomicBoolean(false);
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<Position> positionRef = new AtomicReference<>();
- managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchAllAvailableEntries, condition, position, position2, new AsyncCallbacks.FindEntryCallback() {
+ managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchAllAvailableEntries,
+ condition, position, position2, new AsyncCallbacks.FindEntryCallback() {
@Override
public void findEntryComplete(Position position, Object ctx) {
positionRef.set(position);
@@ -4936,7 +4953,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
}
@Override
- public void findEntryFailed(ManagedLedgerException exception, Optional<Position> failedReadPosition, Object ctx) {
+ public void findEntryFailed(ManagedLedgerException exception,
+ Optional<Position> failedReadPosition, Object ctx) {
failed.set(true);
latch.countDown();
}
@@ -4951,7 +4969,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
AtomicBoolean failed1 = new AtomicBoolean(false);
CountDownLatch latch1 = new CountDownLatch(1);
AtomicReference<Position> positionRef1 = new AtomicReference<>();
- managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchAllAvailableEntries, condition, position, null, new AsyncCallbacks.FindEntryCallback() {
+ managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchAllAvailableEntries,
+ condition, position, null, new AsyncCallbacks.FindEntryCallback() {
@Override
public void findEntryComplete(Position position, Object ctx) {
positionRef1.set(position);
@@ -4959,7 +4978,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
}
@Override
- public void findEntryFailed(ManagedLedgerException exception, Optional<Position> failedReadPosition, Object ctx) {
+ public void findEntryFailed(ManagedLedgerException exception,
+ Optional<Position> failedReadPosition, Object ctx) {
failed1.set(true);
latch1.countDown();
}
@@ -4973,7 +4993,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
AtomicBoolean failed2 = new AtomicBoolean(false);
CountDownLatch latch2 = new CountDownLatch(1);
AtomicReference<Position> positionRef2 = new AtomicReference<>();
- managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchAllAvailableEntries, condition, null, position2, new AsyncCallbacks.FindEntryCallback() {
+ managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchAllAvailableEntries,
+ condition, null, position2, new AsyncCallbacks.FindEntryCallback() {
@Override
public void findEntryComplete(Position position, Object ctx) {
positionRef2.set(position);
@@ -4981,7 +5002,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
}
@Override
- public void findEntryFailed(ManagedLedgerException exception, Optional<Position> failedReadPosition, Object ctx) {
+ public void findEntryFailed(ManagedLedgerException exception,
+ Optional<Position> failedReadPosition, Object ctx) {
failed2.set(true);
latch2.countDown();
}
@@ -4995,7 +5017,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
AtomicBoolean failed3 = new AtomicBoolean(false);
CountDownLatch latch3 = new CountDownLatch(1);
AtomicReference<Position> positionRef3 = new AtomicReference<>();
- managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchAllAvailableEntries, condition, null, null, new AsyncCallbacks.FindEntryCallback() {
+ managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchAllAvailableEntries,
+ condition, null, null, new AsyncCallbacks.FindEntryCallback() {
@Override
public void findEntryComplete(Position position, Object ctx) {
positionRef3.set(position);
@@ -5003,7 +5026,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
}
@Override
- public void findEntryFailed(ManagedLedgerException exception, Optional<Position> failedReadPosition, Object ctx) {
+ public void findEntryFailed(ManagedLedgerException exception,
+ Optional<Position> failedReadPosition, Object ctx) {
failed3.set(true);
latch3.countDown();
}
@@ -5017,7 +5041,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
AtomicBoolean failed4 = new AtomicBoolean(false);
CountDownLatch latch4 = new CountDownLatch(1);
AtomicReference<Position> positionRef4 = new AtomicReference<>();
- managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchAllAvailableEntries, entry -> {
+ managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchAllAvailableEntries,
+ entry -> {
try {
Position p = entry.getPosition();
return p.compareTo(position3) <= 0;
@@ -5032,7 +5057,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
}
@Override
- public void findEntryFailed(ManagedLedgerException exception, Optional<Position> failedReadPosition, Object ctx) {
+ public void findEntryFailed(ManagedLedgerException exception,
+ Optional<Position> failedReadPosition, Object ctx) {
failed4.set(true);
latch4.countDown();
}
@@ -5050,7 +5076,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
managedLedgerConfig.setMaxEntriesPerLedger(2);
managedLedgerConfig.setMinimumRolloverTime(0, TimeUnit.MILLISECONDS);
@Cleanup
- ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("testFindNewestMatching_SearchActiveEntries_ByStartAndEnd", managedLedgerConfig);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory
+ .open("testFindNewestMatching_SearchActiveEntries_ByStartAndEnd", managedLedgerConfig);
@Cleanup
ManagedCursorImpl managedCursor = (ManagedCursorImpl) ledger.openCursor("test");
@@ -5075,7 +5102,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
AtomicBoolean failed = new AtomicBoolean(false);
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<Position> positionRef = new AtomicReference<>();
- managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchActiveEntries, condition, position2, position4, new AsyncCallbacks.FindEntryCallback() {
+ managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchActiveEntries,
+ condition, position2, position4, new AsyncCallbacks.FindEntryCallback() {
@Override
public void findEntryComplete(Position position, Object ctx) {
positionRef.set(position);
@@ -5083,7 +5111,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
}
@Override
- public void findEntryFailed(ManagedLedgerException exception, Optional<Position> failedReadPosition, Object ctx) {
+ public void findEntryFailed(ManagedLedgerException exception,
+ Optional<Position> failedReadPosition, Object ctx) {
failed.set(true);
latch.countDown();
}
@@ -5097,7 +5126,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
AtomicBoolean failed1 = new AtomicBoolean(false);
CountDownLatch latch1 = new CountDownLatch(1);
AtomicReference<Position> positionRef1 = new AtomicReference<>();
- managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchActiveEntries, condition, position2, null, new AsyncCallbacks.FindEntryCallback() {
+ managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchActiveEntries,
+ condition, position2, null, new AsyncCallbacks.FindEntryCallback() {
@Override
public void findEntryComplete(Position position, Object ctx) {
positionRef1.set(position);
@@ -5105,7 +5135,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
}
@Override
- public void findEntryFailed(ManagedLedgerException exception, Optional<Position> failedReadPosition, Object ctx) {
+ public void findEntryFailed(ManagedLedgerException exception,
+ Optional<Position> failedReadPosition, Object ctx) {
failed1.set(true);
latch1.countDown();
}
@@ -5120,7 +5151,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
AtomicBoolean failed2 = new AtomicBoolean(false);
CountDownLatch latch2 = new CountDownLatch(1);
AtomicReference<Position> positionRef2 = new AtomicReference<>();
- managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchActiveEntries, condition, null, position4, new AsyncCallbacks.FindEntryCallback() {
+ managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchActiveEntries,
+ condition, null, position4, new AsyncCallbacks.FindEntryCallback() {
@Override
public void findEntryComplete(Position position, Object ctx) {
positionRef2.set(position);
@@ -5128,7 +5160,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
}
@Override
- public void findEntryFailed(ManagedLedgerException exception, Optional<Position> failedReadPosition, Object ctx) {
+ public void findEntryFailed(ManagedLedgerException exception,
+ Optional<Position> failedReadPosition, Object ctx) {
failed2.set(true);
latch2.countDown();
}
@@ -5143,7 +5176,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
AtomicBoolean failed3 = new AtomicBoolean(false);
CountDownLatch latch3 = new CountDownLatch(1);
AtomicReference<Position> positionRef3 = new AtomicReference<>();
- managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchActiveEntries, condition, null, null, new AsyncCallbacks.FindEntryCallback() {
+ managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchActiveEntries,
+ condition, null, null, new AsyncCallbacks.FindEntryCallback() {
@Override
public void findEntryComplete(Position position, Object ctx) {
positionRef3.set(position);
@@ -5151,7 +5185,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
}
@Override
- public void findEntryFailed(ManagedLedgerException exception, Optional<Position> failedReadPosition, Object ctx) {
+ public void findEntryFailed(ManagedLedgerException exception,
+ Optional<Position> failedReadPosition, Object ctx) {
failed3.set(true);
latch3.countDown();
}
@@ -5165,7 +5200,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
AtomicBoolean failed4 = new AtomicBoolean(false);
CountDownLatch latch4 = new CountDownLatch(1);
AtomicReference<Position> positionRef4 = new AtomicReference<>();
- managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchActiveEntries, entry -> {
+ managedCursor.asyncFindNewestMatching(ManagedCursor.FindPositionConstraint.SearchActiveEntries,
+ entry -> {
try {
Position p = entry.getPosition();
return p.compareTo(position4) <= 0;
@@ -5180,7 +5216,8 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
}
@Override
- public void findEntryFailed(ManagedLedgerException exception, Optional<Position> failedReadPosition, Object ctx) {
+ public void findEntryFailed(ManagedLedgerException exception,
+ Optional<Position> failedReadPosition, Object ctx) {
failed4.set(true);
latch4.countDown();
}
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerBkTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerBkTest.java
index 574ed2f3251..1ba3c0f1ed3 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerBkTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerBkTest.java
@@ -90,15 +90,15 @@ public class ManagedLedgerBkTest extends BookKeeperClusterTestCase {
ManagedLedger ledger = factory.open("my-ledger" + testName, config);
ManagedCursor cursor = ledger.openCursor("c1");
- int N = 1;
+ int num = 1;
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
String entry = "entry-" + i;
ledger.addEntry(entry.getBytes());
}
- List<Entry> entries = cursor.readEntries(N);
- assertEquals(N, entries.size());
+ List<Entry> entries = cursor.readEntries(num);
+ assertEquals(num, entries.size());
entries.forEach(Entry::release);
}
@@ -181,15 +181,15 @@ public class ManagedLedgerBkTest extends BookKeeperClusterTestCase {
conf.setEnsembleSize(2).setAckQuorumSize(2).setMetadataEnsembleSize(2);
final ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my-ledger" + testName, conf);
- int NumProducers = 1;
- int NumConsumers = 1;
+ int numProducers = 1;
+ int numConsumers = 1;
final AtomicBoolean done = new AtomicBoolean();
- final CyclicBarrier barrier = new CyclicBarrier(NumProducers + NumConsumers + 1);
+ final CyclicBarrier barrier = new CyclicBarrier(numProducers + numConsumers + 1);
List<Future<?>> futures = new ArrayList();
- for (int i = 0; i < NumProducers; i++) {
+ for (int i = 0; i < numProducers; i++) {
futures.add(executor.submit(() -> {
try {
barrier.await();
@@ -204,7 +204,7 @@ public class ManagedLedgerBkTest extends BookKeeperClusterTestCase {
}));
}
- for (int i = 0; i < NumConsumers; i++) {
+ for (int i = 0; i < numConsumers; i++) {
final int idx = i;
futures.add(executor.submit(() -> {
try {
@@ -260,16 +260,16 @@ public class ManagedLedgerBkTest extends BookKeeperClusterTestCase {
.setRetentionSizeInMB(-1).setRetentionTime(-1, TimeUnit.MILLISECONDS);
final ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my-ledger" + testName, conf);
- int NumProducers = 5;
- int NumConsumers = 10;
+ int numProducers = 5;
+ int numConsumers = 10;
final AtomicBoolean done = new AtomicBoolean();
- final CyclicBarrier barrier = new CyclicBarrier(NumProducers + NumConsumers + 1);
+ final CyclicBarrier barrier = new CyclicBarrier(numProducers + numConsumers + 1);
List<Future<?>> futures = new ArrayList();
List<Position> positions = new CopyOnWriteArrayList<>();
- for (int i = 0; i < NumProducers; i++) {
+ for (int i = 0; i < numProducers; i++) {
futures.add(executor.submit(() -> {
try {
// wait for all threads to be ready to start at once
@@ -289,7 +289,7 @@ public class ManagedLedgerBkTest extends BookKeeperClusterTestCase {
// create a dummy cursor since caching happens only when there are active consumers
ManagedCursor cursor = ledger.openCursor("dummy");
- for (int i = 0; i < NumConsumers; i++) {
+ for (int i = 0; i < numConsumers; i++) {
futures.add(executor.submit(() -> {
try {
// wait for all threads to be ready to start at once
@@ -494,7 +494,7 @@ public class ManagedLedgerBkTest extends BookKeeperClusterTestCase {
}
/**
- * When another process steals the ML, the old instance should not succeed in any operation
+ * When another process steals the ML, the old instance should not succeed in any operation.
*/
@Test
public void ledgerFencedByFailover() throws Exception {
@@ -545,15 +545,15 @@ public class ManagedLedgerBkTest extends BookKeeperClusterTestCase {
ManagedLedger ledger = factory.open("property/cluster/namespace/my-ledger", config);
ManagedCursor cursor = ledger.openCursor("c1");
- int N = 1;
+ int num = 1;
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
String entry = "entry-" + i;
ledger.addEntry(entry.getBytes());
}
- List<Entry> entries = cursor.readEntries(N);
- assertEquals(N, entries.size());
+ List<Entry> entries = cursor.readEntries(num);
+ assertEquals(num, entries.size());
entries.forEach(Entry::release);
ledger.close();
@@ -603,12 +603,12 @@ public class ManagedLedgerBkTest extends BookKeeperClusterTestCase {
config.setEnsembleSize(2).setAckQuorumSize(2).setMetadataEnsembleSize(2);
ManagedLedgerImpl ledger1 = (ManagedLedgerImpl) factory.open("my_test_ledger" + testName, config);
- int N = 100;
+ int num = 100;
AtomicReference<ManagedLedgerException> res = new AtomicReference<>();
- CountDownLatch latch = new CountDownLatch(N);
+ CountDownLatch latch = new CountDownLatch(num);
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
ledger1.asyncAddEntry(("entry-" + i).getBytes(), new AddEntryCallback() {
@Override
@@ -752,7 +752,8 @@ public class ManagedLedgerBkTest extends BookKeeperClusterTestCase {
log.info("before: {}", cursor1.getIndividuallyDeletedMessagesSet().asRanges());
log.info("after : {}", cursor2.getIndividuallyDeletedMessagesSet().asRanges());
- assertEquals(cursor1.getIndividuallyDeletedMessagesSet().asRanges(), cursor2.getIndividuallyDeletedMessagesSet().asRanges());
+ assertEquals(cursor1.getIndividuallyDeletedMessagesSet().asRanges(),
+ cursor2.getIndividuallyDeletedMessagesSet().asRanges());
assertEquals(cursor1.markDeletePosition, cursor2.markDeletePosition);
ledger2.close();
@@ -790,7 +791,7 @@ public class ManagedLedgerBkTest extends BookKeeperClusterTestCase {
entries.add(p);
}
// Make ack holes and trigger a mark deletion.
- for (int i = totalEntries - 1; i >=0 ; i--) {
+ for (int i = totalEntries - 1; i >= 0; i--) {
if (i % 2 == 0) {
cursor1.delete(entries.get(i));
}
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryShutdownTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryShutdownTest.java
index 00fc151c6d7..ecc3423e292 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryShutdownTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryShutdownTest.java
@@ -18,7 +18,6 @@
*/
package org.apache.bookkeeper.mledger.impl;
-
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
@@ -26,14 +25,12 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
-
import java.util.Collections;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-
import lombok.Cleanup;
import lombok.extern.slf4j.Slf4j;
import org.apache.bookkeeper.client.AsyncCallback;
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryTest.java
index dfff9ecb49a..32865fd4e6e 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryTest.java
@@ -20,7 +20,6 @@ package org.apache.bookkeeper.mledger.impl;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
-
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.apache.bookkeeper.mledger.ManagedCursor;
@@ -82,7 +81,7 @@ public class ManagedLedgerFactoryTest extends MockedBookKeeperTestCase {
}
/**
- * see: https://github.com/apache/pulsar/pull/18688
+ * see: https://github.com/apache/pulsar/pull/18688.
*/
@Test
public void testConcurrentCloseLedgerAndSwitchLedgerForReproduceIssue() throws Exception {
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerInfoMetadataTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerInfoMetadataTest.java
index 6e1f447225e..7eeac35da47 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerInfoMetadataTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerInfoMetadataTest.java
@@ -18,6 +18,8 @@
*/
package org.apache.bookkeeper.mledger.impl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
import com.google.protobuf.InvalidProtocolBufferException;
import java.io.IOException;
import java.util.ArrayList;
@@ -34,8 +36,6 @@ import org.apache.pulsar.common.api.proto.CompressionType;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
/**
* ManagedLedgerInfo metadata test.
@@ -59,7 +59,8 @@ public class ManagedLedgerInfoMetadataTest {
private MLDataFormats.ManagedLedgerInfo.Builder generateManagedLedgerInfo(long ledgerId, int ledgerInfoNumber) {
List<MLDataFormats.ManagedLedgerInfo.LedgerInfo> ledgerInfoList = new ArrayList<>();
for (int i = 0; i < ledgerInfoNumber; i++) {
- MLDataFormats.ManagedLedgerInfo.LedgerInfo.Builder builder = MLDataFormats.ManagedLedgerInfo.LedgerInfo.newBuilder();
+ MLDataFormats.ManagedLedgerInfo.LedgerInfo.Builder builder =
+ MLDataFormats.ManagedLedgerInfo.LedgerInfo.newBuilder();
builder.setLedgerId(ledgerId);
builder.setEntries(RandomUtils.nextInt());
builder.setSize(RandomUtils.nextLong());
@@ -82,7 +83,7 @@ public class ManagedLedgerInfoMetadataTest {
MLDataFormats.ManagedLedgerInfo.LedgerInfo ledgerInfo = builder.build();
ledgerInfoList.add(ledgerInfo);
- ledgerId ++;
+ ledgerId++;
}
return MLDataFormats.ManagedLedgerInfo.newBuilder()
@@ -92,7 +93,7 @@ public class ManagedLedgerInfoMetadataTest {
@Test(dataProvider = "compressionTypeProvider")
public void testEncodeAndDecode(String compressionType) throws IOException {
long ledgerId = 10000;
- MLDataFormats.ManagedLedgerInfo managedLedgerInfo = generateManagedLedgerInfo(ledgerId,100).build();
+ MLDataFormats.ManagedLedgerInfo managedLedgerInfo = generateManagedLedgerInfo(ledgerId, 100).build();
MetaStoreImpl metaStore;
try {
@@ -145,7 +146,7 @@ public class ManagedLedgerInfoMetadataTest {
MLDataFormats.ManagedLedgerInfo bigInfo = generateManagedLedgerInfo(ledgerId, 1000).build();
assertTrue(bigInfo.getSerializedSize() > compressThreshold);
- MLDataFormats.ManagedLedgerInfo managedLedgerInfo = generateManagedLedgerInfo(ledgerId,100).build();
+ MLDataFormats.ManagedLedgerInfo managedLedgerInfo = generateManagedLedgerInfo(ledgerId, 100).build();
MetaStoreImpl metaStore;
try {
@@ -171,6 +172,6 @@ public class ManagedLedgerInfoMetadataTest {
assertEquals(compressionBytes.length, smallInfo.getSerializedSize());
byte[] compressionBytesBig = metaStore.compressLedgerInfo(bigInfo);
- assertTrue(compressionBytesBig.length !=smallInfo.getSerializedSize());
+ assertTrue(compressionBytesBig.length != smallInfo.getSerializedSize());
}
}
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerMBeanTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerMBeanTest.java
index 5f6bd0b7ae6..eb33d8981ab 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerMBeanTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerMBeanTest.java
@@ -20,7 +20,6 @@ package org.apache.bookkeeper.mledger.impl;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
-
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.bookkeeper.mledger.Entry;
@@ -59,7 +58,7 @@ public class ManagedLedgerMBeanTest extends MockedBookKeeperTestCase {
mbean.addAddEntryLatencySample(1, TimeUnit.MILLISECONDS);
mbean.addAddEntryLatencySample(10, TimeUnit.MILLISECONDS);
mbean.addAddEntryLatencySample(1, TimeUnit.SECONDS);
-
+
mbean.addLedgerAddEntryLatencySample(1, TimeUnit.MILLISECONDS);
mbean.addLedgerAddEntryLatencySample(10, TimeUnit.MILLISECONDS);
mbean.addLedgerAddEntryLatencySample(1, TimeUnit.SECONDS);
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerSingleBookieTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerSingleBookieTest.java
index c982a5eefb3..582007cc120 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerSingleBookieTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerSingleBookieTest.java
@@ -21,7 +21,6 @@ package org.apache.bookkeeper.mledger.impl;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
-
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTerminationTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTerminationTest.java
index 11feb5a41cf..a061ead2419 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTerminationTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTerminationTest.java
@@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
-
import java.util.Collections;
import java.util.List;
import org.apache.bookkeeper.mledger.Entry;
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
index 5ec453a6d4e..6f5e409aff4 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
@@ -485,7 +485,8 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
}
@Test
- public void shouldKeepEntriesInCacheByEarliestMarkDeletePosition() throws ManagedLedgerException, InterruptedException {
+ public void shouldKeepEntriesInCacheByEarliestMarkDeletePosition()
+ throws ManagedLedgerException, InterruptedException {
// This test case reproduces issue #16054
ManagedLedgerConfig config = new ManagedLedgerConfig();
@@ -641,8 +642,9 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
ManagedCursor cursor = ledger.openCursor("c1");
- for (int i = 0; i < 11; i++)
+ for (int i = 0; i < 11; i++) {
ledger.addEntry(("dummy-entry-" + i).getBytes(Encoding));
+ }
List<Entry> entries = cursor.readEntries(100);
assertEquals(entries.size(), 11);
@@ -708,8 +710,9 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
byte[] content = new byte[1023 * 1024];
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++) {
ledger.addEntry(content);
+ }
List<Entry> entries = cursor.readEntries(100);
assertEquals(entries.size(), 3);
@@ -1734,7 +1737,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
}
/**
- * Reproduce a race condition between opening cursors and concurrent mark delete operations
+ * Reproduce a race condition between opening cursors and concurrent mark delete operations.
*/
@Test(timeOut = 20000)
public void testOpenRaceCondition() throws Exception {
@@ -1743,14 +1746,14 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
final ManagedLedger ledger = factory.open("my-ledger", config);
final ManagedCursor c1 = ledger.openCursor("c1");
- final int N = 1000;
+ final int num = 1000;
final Position position = ledger.addEntry("entry-0".getBytes());
@Cleanup("shutdownNow")
ExecutorService executor = Executors.newCachedThreadPool();
final CountDownLatch counter = new CountDownLatch(2);
executor.execute(() -> {
try {
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
c1.markDelete(position);
}
counter.countDown();
@@ -1761,7 +1764,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
executor.execute(() -> {
try {
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
ledger.openCursor("cursor-" + i);
}
counter.countDown();
@@ -2568,12 +2571,13 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
public void testGetPositionAfterN() throws Exception {
ManagedLedgerConfig managedLedgerConfig = new ManagedLedgerConfig();
managedLedgerConfig.setMaxEntriesPerLedger(5);
- ManagedLedgerImpl managedLedger = (ManagedLedgerImpl) factory.open("testGetPositionAfterN", managedLedgerConfig);
+ ManagedLedgerImpl managedLedger =
+ (ManagedLedgerImpl) factory.open("testGetPositionAfterN", managedLedgerConfig);
// open cursor to prevent ledger to be deleted when ledger rollover
ManagedCursorImpl managedCursor = (ManagedCursorImpl) managedLedger.openCursor("cursor");
Position positionMarkDelete = null;
- for (int i = 0; i < 10; i ++) {
+ for (int i = 0; i < 10; i++) {
if (i == 3) {
positionMarkDelete = managedLedger.addEntry(("entry-" + i).getBytes(Encoding));
continue;
@@ -2888,7 +2892,8 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
// Simulating time consuming cursor recovery.
CompletableFuture<Void> future = bkc.promiseAfter(2);
@Cleanup("shutdownNow")
- ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new DefaultThreadFactory("lazyCursorRecovery"));
+ ScheduledExecutorService scheduledExecutorService =
+ Executors.newSingleThreadScheduledExecutor(new DefaultThreadFactory("lazyCursorRecovery"));
scheduledExecutorService.schedule(() -> {
future.complete(null);
}, 10, TimeUnit.SECONDS);
@@ -3045,8 +3050,8 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
@Test
public void testConsumerSubscriptionInitializePosition() throws Exception{
- final int MAX_ENTRY_PER_LEDGER = 2;
- ManagedLedgerConfig config = new ManagedLedgerConfig().setMaxEntriesPerLedger(MAX_ENTRY_PER_LEDGER);
+ final int maxEntryPerLedger = 2;
+ ManagedLedgerConfig config = new ManagedLedgerConfig().setMaxEntriesPerLedger(maxEntryPerLedger);
ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("lastest_earliest_ledger", config);
final int totalInsertedEntries = 20;
@@ -3072,7 +3077,8 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
assertEquals(ledger.getNextValidPosition(earliestPositionAndCounter.getLeft()), p2);
assertEquals(latestPositionAndCounter.getRight().longValue(), totalInsertedEntries);
- assertEquals(earliestPositionAndCounter.getRight().longValue(), totalInsertedEntries - earliestCursor.getNumberOfEntriesInBacklog(false));
+ assertEquals(earliestPositionAndCounter.getRight().longValue(),
+ totalInsertedEntries - earliestCursor.getNumberOfEntriesInBacklog(false));
ledger.close();
@@ -3125,7 +3131,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
}
/**
- * It verifies that asyncRead timesout if it doesn't receive response from bk-client in configured timeout
+ * It verifies that asyncRead timesout if it doesn't receive response from bk-client in configured timeout.
*
* @throws Exception
*/
@@ -3510,7 +3516,8 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
managedLedgerConfig.setBookKeeperEnsemblePlacementPolicyProperties(Collections.singletonMap("key", "value"));
ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", managedLedgerConfig);
assertFalse(ledger.createdLedgerCustomMetadata.isEmpty());
- byte[] configData = ledger.createdLedgerCustomMetadata.get(EnsemblePlacementPolicyConfig.ENSEMBLE_PLACEMENT_POLICY_CONFIG);
+ byte[] configData =
+ ledger.createdLedgerCustomMetadata.get(EnsemblePlacementPolicyConfig.ENSEMBLE_PLACEMENT_POLICY_CONFIG);
EnsemblePlacementPolicyConfig config = EnsemblePlacementPolicyConfig.decode(configData);
assertEquals(config.getPolicyClass().getName(), MockedPlacementPolicy.class.getName());
assertEquals(config.getProperties().size(), 1);
@@ -3541,7 +3548,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
config.setMaxEntriesPerLedger(2);
config.setMaximumRolloverTime(500, TimeUnit.MILLISECONDS);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("test_managedLedger_rollOver", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("test_managedLedger_rollOver", config);
ManagedCursor cursor = ledger.openCursor("c1");
int msgNum = 10;
@@ -3593,7 +3600,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
ManagedLedgerConfig config = new ManagedLedgerConfig();
config.setMaxEntriesPerLedger(2);
- ManagedLedgerImpl ml = spy((ManagedLedgerImpl)factory.open("ledger-not-rollover-without-open-state", config));
+ ManagedLedgerImpl ml = spy((ManagedLedgerImpl) factory.open("ledger-not-rollover-without-open-state", config));
ml.addEntry("test1".getBytes()).getLedgerId();
long ledgerId2 = ml.addEntry("test2".getBytes()).getLedgerId();
Field stateUpdater = ManagedLedgerImpl.class.getDeclaredField("state");
@@ -3657,7 +3664,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
config.setRetentionSizeInMB(50);
config.setRetentionTime(1, TimeUnit.DAYS);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("truncate_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("truncate_ledger", config);
ManagedCursor cursor = ledger.openCursor("test-cursor");
ledger.addEntry("test-entry-1".getBytes(Encoding));
ledger.addEntry("test-entry-1".getBytes(Encoding));
@@ -3666,7 +3673,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
ledger.addEntry("test-entry-1".getBytes(Encoding));
ledger.close();
- ManagedLedgerImpl ledger2 = (ManagedLedgerImpl)factory.open("truncate_ledger", config);
+ ManagedLedgerImpl ledger2 = (ManagedLedgerImpl) factory.open("truncate_ledger", config);
ledger2.addEntry("test-entry-2".getBytes(Encoding));
@@ -3680,7 +3687,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
public void testAsyncTruncateLedgerSlowestCursor() throws Exception {
ManagedLedgerConfig config = new ManagedLedgerConfig();
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("truncate_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("truncate_ledger", config);
ManagedCursor cursor = ledger.openCursor("test-cursor");
ManagedCursor cursor2 = ledger.openCursor("test-cursor2");
ledger.addEntry("test-entry-1".getBytes(Encoding));
@@ -3690,7 +3697,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
ledger.addEntry("test-entry-1".getBytes(Encoding));
ledger.close();
- ManagedLedgerImpl ledger2 = (ManagedLedgerImpl)factory.open("truncate_ledger", config);
+ ManagedLedgerImpl ledger2 = (ManagedLedgerImpl) factory.open("truncate_ledger", config);
ledger2.addEntry("test-entry-2".getBytes(Encoding));
ManagedCursor cursor3 = ledger2.openCursor("test-cursor");
cursor3.resetCursor(PositionFactory.create(ledger2.getLastPosition()));
@@ -3710,13 +3717,13 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
long entryId = 12L;
long startTime = 1245L;
int dataLength = 566;
- String test = "OpAddEntry{" +
- "mlName=" + ml != null ? ml.getName() : "null" +
- ", ledgerId=" + ledger != null ? String.valueOf(ledger.getId()) : "null" +
- ", entryId=" + entryId +
- ", startTime=" + startTime +
- ", dataLength=" + dataLength +
- '}';
+ String test = "OpAddEntry{"
+ + "mlName=" + ml != null ? ml.getName() : "null"
+ + ", ledgerId=" + ledger != null ? String.valueOf(ledger.getId()) : "null"
+ + ", entryId=" + entryId
+ + ", startTime=" + startTime
+ + ", dataLength=" + dataLength
+ + '}';
}
@Test
@@ -3725,7 +3732,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
config.setMaxEntriesPerLedger(1);
// Verify the read handle should be invalidated after ledger been removed.
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("testInvalidateReadHandleWhenDeleteLedger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("testInvalidateReadHandleWhenDeleteLedger", config);
ManagedCursor cursor = ledger.openCursor("test-cursor");
ManagedCursor cursor2 = ledger.openCursor("test-cursor2");
final int entries = 3;
@@ -3762,7 +3769,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
ManagedLedgerConfig config = new ManagedLedgerConfig();
config.setMaxEntriesPerLedger(1);
- ManagedLedgerImpl ledger = spy((ManagedLedgerImpl)factory.open("testLockReleaseWhenTrimLedger", config));
+ ManagedLedgerImpl ledger = spy((ManagedLedgerImpl) factory.open("testLockReleaseWhenTrimLedger", config));
doThrow(new ManagedLedgerException.LedgerNotExistException("First non deleted Ledger is not found"))
.when(ledger).advanceCursorsIfNecessary(any());
final int entries = 10;
@@ -3797,7 +3804,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
// even if the ledger can not been removed due to the data retention
config.setRetentionSizeInMB(50);
config.setRetentionTime(1, TimeUnit.DAYS);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("testInvalidateReadHandleWhenConsumed", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("testInvalidateReadHandleWhenConsumed", config);
ManagedCursor cursor = ledger.openCursor("test-cursor");
ManagedCursor cursor2 = ledger.openCursor("test-cursor2");
final int entries = 3;
@@ -3858,7 +3865,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
when(ledgerOffloader.getOffloadPolicies().getManagedLedgerOffloadThresholdInSeconds()).thenReturn(-1L);
when(ledgerOffloader.getOffloadDriverName()).thenReturn("s3");
config.setLedgerOffloader(ledgerOffloader);
- ManagedLedgerImpl ledger = spy((ManagedLedgerImpl)factory.open(
+ ManagedLedgerImpl ledger = spy((ManagedLedgerImpl) factory.open(
"testDoNotGetOffloadPoliciesMultipleTimesWhenTrimLedgers", config));
doNothing().when(ledger).trimConsumedLedgersInBackground(any(CompletableFuture.class));
@@ -4061,7 +4068,8 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
offloadPolicies.setManagedLedgerOffloadThresholdInBytes(0L);
LedgerOffloader ledgerOffloader = Mockito.mock(LedgerOffloader.class);
Mockito.when(ledgerOffloader.getOffloadPolicies()).thenReturn(offloadPolicies);
- Mockito.when(ledgerOffloader.getOffloadDriverName()).thenReturn(offloadPolicies.getManagedLedgerOffloadDriver());
+ Mockito.when(ledgerOffloader.getOffloadDriverName())
+ .thenReturn(offloadPolicies.getManagedLedgerOffloadDriver());
config.setLedgerOffloader(ledgerOffloader);
CompletableFuture<ReadHandle> readHandle = new CompletableFuture<>();
@@ -4069,7 +4077,8 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
CompletableFuture<Void> offloadFuture = new CompletableFuture<>();
offloadFuture.complete(null);
- Mockito.when(ledgerOffloader.offload(any(ReadHandle.class), any(UUID.class), any(Map.class))).thenReturn(offloadFuture);
+ Mockito.when(ledgerOffloader.offload(any(ReadHandle.class), any(UUID.class),
+ any(Map.class))).thenReturn(offloadFuture);
final ManagedLedgerImpl ledgerInit = (ManagedLedgerImpl) factory.open("test-offload-task-close", config);
final ManagedLedgerImpl ledger = spy(ledgerInit);
@@ -4131,7 +4140,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
@Test
public void testIsNoMessagesAfterPos() throws Exception {
- final byte[] data = new byte[]{1,2,3};
+ final byte[] data = new byte[]{1, 2, 3};
final String cursorName = "c1";
final String mlName = UUID.randomUUID().toString().replaceAll("-", "");
final ManagedLedgerImpl ml = (ManagedLedgerImpl) factory.open(mlName);
@@ -4256,8 +4265,8 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
}, 5, 1000);
assertTrue(isRolledOver.booleanValue());
- Position Position = PositionFactory.create(-1L, -1L);
- assertNotNull(ml.newNonDurableCursor(Position));
+ Position position = PositionFactory.create(-1L, -1L);
+ assertNotNull(ml.newNonDurableCursor(position));
}
@Test(timeOut = 60 * 1000)
@@ -4310,7 +4319,7 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
}
/**
- * Calculate how many pending tasks in {@link OrderedScheduler}
+ * Calculate how many pending tasks in {@link OrderedScheduler}.
*/
private long calculatePendingTaskCount(OrderedScheduler orderedScheduler) {
ExecutorService[] threads = WhiteboxImpl.getInternalState(orderedScheduler, "threads");
@@ -4348,8 +4357,8 @@ public class ManagedLedgerTest extends MockedBookKeeperTestCase {
// the metadata store meets an exception.
AtomicInteger metadataPutCallCount = new AtomicInteger(0);
metadataStore.failConditional(new MetadataStoreException("mock completion error"),
- (key, value) -> key.equals(FaultInjectionMetadataStore.OperationType.PUT) &&
- metadataPutCallCount.incrementAndGet() == 2);
+ (key, value) -> key.equals(FaultInjectionMetadataStore.OperationType.PUT)
+ && metadataPutCallCount.incrementAndGet() == 2);
// prepare the arguments for the offloadLoop method
CompletableFuture<Position> future = new CompletableFuture<>();
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/MetaStoreImplTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/MetaStoreImplTest.java
index 40ecbde3c08..00ad494a5ca 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/MetaStoreImplTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/MetaStoreImplTest.java
@@ -35,10 +35,10 @@ import org.apache.bookkeeper.mledger.proto.MLDataFormats;
import org.apache.bookkeeper.mledger.proto.MLDataFormats.ManagedCursorInfo;
import org.apache.bookkeeper.mledger.proto.MLDataFormats.ManagedLedgerInfo;
import org.apache.bookkeeper.test.MockedBookKeeperTestCase;
-import org.apache.pulsar.metadata.impl.FaultInjectionMetadataStore;
import org.apache.pulsar.metadata.api.MetadataCache;
import org.apache.pulsar.metadata.api.MetadataStoreException;
import org.apache.pulsar.metadata.api.Stat;
+import org.apache.pulsar.metadata.impl.FaultInjectionMetadataStore;
import org.testng.annotations.Test;
public class MetaStoreImplTest extends MockedBookKeeperTestCase {
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/NonDurableCursorTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/NonDurableCursorTest.java
index 3e1bae7ea7b..0bb1b0fc972 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/NonDurableCursorTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/NonDurableCursorTest.java
@@ -25,9 +25,8 @@ import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
-
import com.google.common.collect.Iterables;
-
+import io.netty.buffer.ByteBuf;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@@ -37,8 +36,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
-
-import io.netty.buffer.ByteBuf;
import lombok.Cleanup;
import org.apache.bookkeeper.mledger.AsyncCallbacks;
import org.apache.bookkeeper.mledger.AsyncCallbacks.AddEntryCallback;
@@ -486,9 +483,9 @@ public class NonDurableCursorTest extends MockedBookKeeperTestCase {
final ManagedCursor c1 = ledger.openCursor("c1");
final AtomicReference<Position> lastPosition = new AtomicReference<Position>();
- final int N = 100;
- final CountDownLatch latch = new CountDownLatch(N);
- for (int i = 0; i < N; i++) {
+ final int num = 100;
+ final CountDownLatch latch = new CountDownLatch(num);
+ for (int i = 0; i < num; i++) {
ledger.asyncAddEntry("entry".getBytes(Encoding), new AddEntryCallback() {
@Override
public void addFailed(ManagedLedgerException exception, Object ctx) {
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadEvictUnusedLedgersTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadEvictUnusedLedgersTest.java
index c8f4602b538..6a449a2b27c 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadEvictUnusedLedgersTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadEvictUnusedLedgersTest.java
@@ -50,7 +50,7 @@ public class OffloadEvictUnusedLedgersTest extends MockedBookKeeperTestCase {
long inactiveOffloadedLedgerEvictionTimeMs = 1000;
config.setInactiveOffloadedLedgerEvictionTime(inactiveOffloadedLedgerEvictionTimeMs, TimeUnit.MILLISECONDS);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger_evict", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger_evict", config);
// no evict when no offloaded ledgers
assertTrue(ledger.internalEvictOffloadedLedgers().isEmpty());
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadLedgerDeleteTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadLedgerDeleteTest.java
index 3fd20490beb..a1ef8ad0e2c 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadLedgerDeleteTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadLedgerDeleteTest.java
@@ -19,7 +19,6 @@
package org.apache.bookkeeper.mledger.impl;
import static org.apache.bookkeeper.mledger.impl.OffloadPrefixTest.assertEventuallyTrue;
-
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@@ -29,7 +28,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
-
import org.apache.bookkeeper.client.BKException;
import org.apache.bookkeeper.client.api.ReadHandle;
import org.apache.bookkeeper.mledger.AsyncCallbacks;
@@ -43,14 +41,12 @@ import org.apache.bookkeeper.mledger.PositionFactory;
import org.apache.bookkeeper.mledger.proto.MLDataFormats;
import org.apache.bookkeeper.mledger.util.MockClock;
import org.apache.bookkeeper.test.MockedBookKeeperTestCase;
-
import org.apache.pulsar.common.policies.data.OffloadPoliciesImpl;
import org.apache.pulsar.common.policies.data.OffloadedReadPriority;
import org.awaitility.Awaitility;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -168,7 +164,7 @@ public class OffloadLedgerDeleteTest extends MockedBookKeeperTestCase {
config.setLedgerOffloader(offloader);
config.setClock(clock);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
int i = 0;
for (; i < 15; i++) {
String content = "entry-" + i;
@@ -232,7 +228,7 @@ public class OffloadLedgerDeleteTest extends MockedBookKeeperTestCase {
offloader.getOffloadPolicies().setManagedLedgerOffloadedReadPriority(OffloadedReadPriority.BOOKKEEPER_FIRST);
config.setLedgerOffloader(offloader);
ManagedLedgerImpl ml =
- (ManagedLedgerImpl)factory.open("testGetReadLedgerHandleAfterTrimOffloadedLedgers", config);
+ (ManagedLedgerImpl) factory.open("testGetReadLedgerHandleAfterTrimOffloadedLedgers", config);
ml.openCursor("c1");
// Write entries.
@@ -397,7 +393,7 @@ public class OffloadLedgerDeleteTest extends MockedBookKeeperTestCase {
config.setLedgerOffloader(offloader);
config.setClock(clock);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
int i = 0;
for (; i < 15; i++) {
String content = "entry-" + i;
@@ -444,7 +440,7 @@ public class OffloadLedgerDeleteTest extends MockedBookKeeperTestCase {
config.setLedgerOffloader(offloader);
config.setClock(clock);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
ManagedCursor cursor = ledger.openCursor("sub1");
for (int i = 0; i < 15; i++) {
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadPrefixReadTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadPrefixReadTest.java
index 9255cb188de..51366730838 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadPrefixReadTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadPrefixReadTest.java
@@ -305,7 +305,7 @@ public class OffloadPrefixReadTest extends MockedBookKeeperTestCase {
ConcurrentHashMap<UUID, ReadHandle> offloads = new ConcurrentHashMap<UUID, ReadHandle>();
- OffloadPoliciesImpl offloadPolicies = OffloadPoliciesImpl .create("S3", "", "", "",
+ OffloadPoliciesImpl offloadPolicies = OffloadPoliciesImpl.create("S3", "", "", "",
null, null,
null, null,
OffloadPoliciesImpl.DEFAULT_MAX_BLOCK_SIZE_IN_BYTES,
@@ -397,7 +397,9 @@ public class OffloadPrefixReadTest extends MockedBookKeeperTestCase {
}
@Override
- public long getId() { return id; }
+ public long getId() {
+ return id;
+ }
@Override
public LedgerMetadata getLedgerMetadata() {
@@ -413,7 +415,7 @@ public class OffloadPrefixReadTest extends MockedBookKeeperTestCase {
public CompletableFuture<LedgerEntries> readAsync(long firstEntry, long lastEntry) {
List<LedgerEntry> readEntries = new ArrayList();
for (long eid = firstEntry; eid <= lastEntry; eid++) {
- ByteBuf buf = entries.get((int)eid).retainedSlice();
+ ByteBuf buf = entries.get((int) eid).retainedSlice();
readEntries.add(LedgerEntryImpl.create(id, eid, buf.readableBytes(), buf));
}
return CompletableFuture.completedFuture(LedgerEntriesImpl.create(readEntries));
@@ -508,13 +510,19 @@ public class OffloadPrefixReadTest extends MockedBookKeeperTestCase {
}
@Override
- public boolean hasPassword() { return true; }
+ public boolean hasPassword() {
+ return true;
+ }
@Override
- public State getState() { return state; }
+ public State getState() {
+ return state;
+ }
@Override
- public int getMetadataFormatVersion() { return metadataFormatVersion; }
+ public int getMetadataFormatVersion() {
+ return metadataFormatVersion;
+ }
@Override
public long getCToken() {
@@ -522,34 +530,54 @@ public class OffloadPrefixReadTest extends MockedBookKeeperTestCase {
}
@Override
- public int getEnsembleSize() { return ensembleSize; }
+ public int getEnsembleSize() {
+ return ensembleSize;
+ }
@Override
- public int getWriteQuorumSize() { return writeQuorumSize; }
+ public int getWriteQuorumSize() {
+ return writeQuorumSize;
+ }
@Override
- public int getAckQuorumSize() { return ackQuorumSize; }
+ public int getAckQuorumSize() {
+ return ackQuorumSize;
+ }
@Override
- public long getLastEntryId() { return lastEntryId; }
+ public long getLastEntryId() {
+ return lastEntryId;
+ }
@Override
- public long getLength() { return length; }
+ public long getLength() {
+ return length;
+ }
@Override
- public DigestType getDigestType() { return digestType; }
+ public DigestType getDigestType() {
+ return digestType;
+ }
@Override
- public byte[] getPassword() { return password; }
+ public byte[] getPassword() {
+ return password;
+ }
@Override
- public long getCtime() { return ctime; }
+ public long getCtime() {
+ return ctime;
+ }
@Override
- public boolean isClosed() { return isClosed; }
+ public boolean isClosed() {
+ return isClosed;
+ }
@Override
- public Map<String, byte[]> getCustomMetadata() { return customMetadata; }
+ public Map<String, byte[]> getCustomMetadata() {
+ return customMetadata;
+ }
@Override
public List<BookieId> getEnsembleAt(long entryId) {
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadPrefixTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadPrefixTest.java
index 2dfc846bf42..09a0522bab4 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadPrefixTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/OffloadPrefixTest.java
@@ -24,6 +24,7 @@ import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertThrows;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
+import com.google.common.collect.Sets;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
@@ -38,8 +39,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BooleanSupplier;
import java.util.stream.Collectors;
-
-import com.google.common.collect.Sets;
import org.apache.bookkeeper.client.BKException;
import org.apache.bookkeeper.client.api.ReadHandle;
import org.apache.bookkeeper.mledger.AsyncCallbacks;
@@ -73,7 +72,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setMinimumRolloverTime(0, TimeUnit.SECONDS);
config.setRetentionTime(10, TimeUnit.MINUTES);
config.setRetentionSizeInMB(10);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
int i = 0;
for (; i < 25; i++) {
@@ -120,7 +119,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setRetentionTime(10, TimeUnit.MINUTES);
config.setRetentionSizeInMB(10);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
int i = 0;
for (; i < 25; i++) {
@@ -150,7 +149,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setRetentionTime(10, TimeUnit.MINUTES);
config.setRetentionSizeInMB(10);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
int i = 0;
for (; i < 25; i++) {
@@ -192,7 +191,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setRetentionTime(10, TimeUnit.MINUTES);
config.setRetentionSizeInMB(10);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
int i = 0;
for (; i < 25; i++) {
@@ -228,7 +227,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setRetentionTime(10, TimeUnit.MINUTES);
config.setRetentionSizeInMB(10);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
int i = 0;
for (; i < 20; i++) {
@@ -275,7 +274,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setMinimumRolloverTime(0, TimeUnit.SECONDS);
config.setRetentionTime(10, TimeUnit.MINUTES);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
for (int i = 0; i < 5; i++) {
String content = "entry-" + i;
@@ -284,7 +283,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
// Re-open to trigger the case of empty ledger
ledger.close();
- ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
assertEquals(ledger.getLedgersInfoAsList().size(), 2);
@@ -326,7 +325,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setMinimumRolloverTime(0, TimeUnit.SECONDS);
config.setRetentionTime(0, TimeUnit.MINUTES);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
ManagedCursor cursor = ledger.openCursor("foobar");
// Create 3 ledgers, saving position at start of each
@@ -390,7 +389,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setMinimumRolloverTime(0, TimeUnit.SECONDS);
config.setRetentionTime(0, TimeUnit.MINUTES);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
ManagedCursor cursor = ledger.openCursor("foobar");
for (int i = 0; i < 21; i++) {
@@ -437,7 +436,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setRetentionTime(10, TimeUnit.MINUTES);
config.setRetentionSizeInMB(10);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
for (int i = 0; i < 21; i++) {
String content = "entry-" + i;
@@ -469,7 +468,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setRetentionTime(10, TimeUnit.MINUTES);
config.setRetentionSizeInMB(10);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
int i = 0;
for (; i < 25; i++) {
@@ -505,7 +504,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setRetentionTime(10, TimeUnit.MINUTES);
config.setRetentionSizeInMB(10);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
int i = 0;
for (; i < 35; i++) {
@@ -556,7 +555,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setMinimumRolloverTime(0, TimeUnit.SECONDS);
config.setRetentionTime(10, TimeUnit.MINUTES);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
try {
ledger.offloadPrefix(ledger.getLastConfirmedEntry());
@@ -608,7 +607,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setMinimumRolloverTime(0, TimeUnit.SECONDS);
config.setRetentionTime(10, TimeUnit.MINUTES);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
for (int i = 0; i < 15; i++) {
String content = "entry-" + i;
@@ -662,7 +661,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
offloader.getOffloadPolicies().setManagedLedgerOffloadDeletionLagInMillis(100L);
offloader.getOffloadPolicies().setManagedLedgerOffloadThresholdInBytes(100L);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
ManagedCursor cursor = ledger.openCursor("foobar");
for (int i = 0; i < 15; i++) {
@@ -697,7 +696,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
offloader.getOffloadPolicies().setManagedLedgerOffloadDeletionLagInMillis(100L);
offloader.getOffloadPolicies().setManagedLedgerOffloadThresholdInBytes(100L);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
ManagedCursor cursor = ledger.openCursor("foobar");
for (int i = 0; i < 15; i++) {
@@ -768,7 +767,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setMinimumRolloverTime(0, TimeUnit.SECONDS);
config.setRetentionTime(0, TimeUnit.MINUTES);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
ManagedCursor cursor = ledger.openCursor("foobar");
for (int i = 0; i < 15; i++) {
String content = "entry-" + i;
@@ -809,7 +808,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
config.setRetentionTime(10, TimeUnit.MINUTES);
config.setRetentionSizeInMB(10);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
int i = 0;
for (; i < 35; i++) {
@@ -826,7 +825,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
// make an ledger empty
Field ledgersField = ledger.getClass().getDeclaredField("ledgers");
ledgersField.setAccessible(true);
- Map<Long, LedgerInfo> ledgers = (Map<Long,LedgerInfo>)ledgersField.get(ledger);
+ Map<Long, LedgerInfo> ledgers = (Map<Long, LedgerInfo>) ledgersField.get(ledger);
ledgers.put(secondLedgerId,
ledgers.get(secondLedgerId).toBuilder().setEntries(0).setSize(0).build());
@@ -876,7 +875,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
offloader.getOffloadPolicies().setManagedLedgerOffloadThresholdInSeconds(timeThreshold);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger" + UUID.randomUUID(), config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger" + UUID.randomUUID(), config);
// Ledger will roll twice, offload will run on first ledger after second closed
for (int i = 0; i < 25; i++) {
@@ -949,7 +948,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
offloader.getOffloadPolicies().setManagedLedgerOffloadThresholdInSeconds(timeThreshold);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
// Ledger will roll twice, offload will run on first ledger after second closed
for (int i = 0; i < 25; i++) {
@@ -1042,7 +1041,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
offloader.getOffloadPolicies().setManagedLedgerOffloadThresholdInSeconds(timeThreshold);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
// Ledger rolls once, threshold not hit so auto shouldn't run
for (int i = 0; i < 14; i++) {
@@ -1120,7 +1119,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
offloader.getOffloadPolicies().setManagedLedgerOffloadThresholdInSeconds(timeThreshold);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
// Ledger will roll twice, offload will run on first ledger after second closed
for (int i = 0; i < 25; i++) {
@@ -1199,7 +1198,7 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
offloader.getOffloadPolicies().setManagedLedgerOffloadThresholdInSeconds(timeThreshold);
config.setLedgerOffloader(offloader);
- ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("my_test_ledger", config);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger", config);
for (int i = 0; i < 11; i++) {
ledger.addEntry(buildEntry(10, "entry-" + i));
@@ -1293,7 +1292,8 @@ public class OffloadPrefixTest extends MockedBookKeeperTestCase {
public CompletableFuture<ReadHandle> readOffloaded(long ledgerId, UUID uuid,
Map<String, String> offloadDriverMetadata) {
CompletableFuture<ReadHandle> promise = new CompletableFuture<>();
- promise.completeExceptionally(new UnsupportedOperationException("MockLedgerOffloader does not support read"));
+ promise.completeExceptionally(new UnsupportedOperationException(
+ "MockLedgerOffloader does not support read"));
return promise;
}
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/PositionTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/PositionTest.java
index 763146b6c3f..fc60c3765a2 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/PositionTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/PositionTest.java
@@ -20,7 +20,6 @@ package org.apache.bookkeeper.mledger.impl;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;
-
import org.apache.bookkeeper.mledger.Position;
import org.apache.bookkeeper.mledger.PositionFactory;
import org.apache.bookkeeper.mledger.proto.MLDataFormats.PositionInfo;
@@ -46,30 +45,30 @@ public class PositionTest {
@Test
public void comparisons() {
- Position pos1_1 = PositionFactory.create(1, 1);
- Position pos2_5 = PositionFactory.create(2, 5);
- Position pos10_0 = PositionFactory.create(10, 0);
- Position pos10_1 = PositionFactory.create(10, 1);
+ Position pos11 = PositionFactory.create(1, 1);
+ Position pos25 = PositionFactory.create(2, 5);
+ Position pos100 = PositionFactory.create(10, 0);
+ Position pos101 = PositionFactory.create(10, 1);
- assertEquals(0, pos1_1.compareTo(pos1_1));
- assertEquals(-1, pos1_1.compareTo(pos2_5));
- assertEquals(-1, pos1_1.compareTo(pos10_0));
- assertEquals(-1, pos1_1.compareTo(pos10_1));
+ assertEquals(0, pos11.compareTo(pos11));
+ assertEquals(-1, pos11.compareTo(pos25));
+ assertEquals(-1, pos11.compareTo(pos100));
+ assertEquals(-1, pos11.compareTo(pos101));
- assertEquals(+1, pos2_5.compareTo(pos1_1));
- assertEquals(0, pos2_5.compareTo(pos2_5));
- assertEquals(-1, pos2_5.compareTo(pos10_0));
- assertEquals(-1, pos2_5.compareTo(pos10_1));
+ assertEquals(+1, pos25.compareTo(pos11));
+ assertEquals(0, pos25.compareTo(pos25));
+ assertEquals(-1, pos25.compareTo(pos100));
+ assertEquals(-1, pos25.compareTo(pos101));
- assertEquals(+1, pos10_0.compareTo(pos1_1));
- assertEquals(+1, pos10_0.compareTo(pos2_5));
- assertEquals(0, pos10_0.compareTo(pos10_0));
- assertEquals(-1, pos10_0.compareTo(pos10_1));
+ assertEquals(+1, pos100.compareTo(pos11));
+ assertEquals(+1, pos100.compareTo(pos25));
+ assertEquals(0, pos100.compareTo(pos100));
+ assertEquals(-1, pos100.compareTo(pos101));
- assertEquals(+1, pos10_1.compareTo(pos1_1));
- assertEquals(+1, pos10_1.compareTo(pos2_5));
- assertEquals(+1, pos10_1.compareTo(pos10_0));
- assertEquals(0, pos10_1.compareTo(pos10_1));
+ assertEquals(+1, pos101.compareTo(pos11));
+ assertEquals(+1, pos101.compareTo(pos25));
+ assertEquals(+1, pos101.compareTo(pos100));
+ assertEquals(0, pos101.compareTo(pos101));
}
@Test
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/RangeSetWrapperTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/RangeSetWrapperTest.java
index 89fbc26d41a..9012945ddf7 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/RangeSetWrapperTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/RangeSetWrapperTest.java
@@ -31,18 +31,18 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.apache.bookkeeper.mledger.ManagedLedgerConfig;
-import org.apache.pulsar.common.util.collections.LongPairRangeSet.RangeBoundConsumer;
import org.apache.pulsar.common.util.collections.LongPairRangeSet.LongPair;
import org.apache.pulsar.common.util.collections.LongPairRangeSet.LongPairConsumer;
+import org.apache.pulsar.common.util.collections.LongPairRangeSet.RangeBoundConsumer;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class RangeSetWrapperTest {
- static final LongPairConsumer<LongPair> consumer = (key, value) -> new LongPair(key, value);
- static final RangeBoundConsumer<LongPair> reverseConvert = (pair) -> pair;
-
+ static final LongPairConsumer<LongPair> CONSUMER = (key, value) -> new LongPair(key, value);
+ static final RangeBoundConsumer<LongPair> REVERSE_CONVERT = (pair) -> pair;
+
ManagedLedgerImpl managedLedger;
RangeSetWrapper<LongPair> set;
ManagedLedgerConfig managedLedgerConfig;
@@ -70,8 +70,8 @@ public class RangeSetWrapperTest {
@Test
public void testDirtyLedger() {
- RangeSetWrapper<LongPair> rangeSetWrapper = new RangeSetWrapper<>(consumer,
- reverseConvert,
+ RangeSetWrapper<LongPair> rangeSetWrapper = new RangeSetWrapper<>(CONSUMER,
+ REVERSE_CONVERT,
managedCursor);
// Test add range
rangeSetWrapper.addOpenClosed(10, 0, 20, 0);
@@ -98,7 +98,7 @@ public class RangeSetWrapperTest {
}
private void doTestAddForSameKey() {
- set = new RangeSetWrapper(consumer, reverseConvert, managedCursor);
+ set = new RangeSetWrapper(CONSUMER, REVERSE_CONVERT, managedCursor);
// add 0 to 5
set.addOpenClosed(0, 0, 0, 5);
// add 8,9,10
@@ -118,7 +118,7 @@ public class RangeSetWrapperTest {
@Test
public void testAddForDifferentKey() {
- set = new RangeSetWrapper<>(consumer, reverseConvert, managedCursor);
+ set = new RangeSetWrapper<>(CONSUMER, REVERSE_CONVERT, managedCursor);
// [98,100],[(1,5),(1,5)],[(1,10,1,15)],[(1,20),(1,20)],[(2,0),(2,10)]
set.addOpenClosed(0, 98, 0, 99);
set.addOpenClosed(0, 100, 1, 5);
@@ -136,7 +136,7 @@ public class RangeSetWrapperTest {
@Test
public void testAddForDifferentKey2() {
managedLedgerConfig.setUnackedRangesOpenCacheSetEnabled(false);
- set = new RangeSetWrapper<>(consumer, reverseConvert, managedCursor);
+ set = new RangeSetWrapper<>(CONSUMER, REVERSE_CONVERT, managedCursor);
// [98,100],[(1,5),(1,5)],[(1,10,1,15)],[(1,20),(1,20)],[(2,0),(2,10)]
set.addOpenClosed(0, 98, 0, 99);
set.addOpenClosed(0, 100, 1, 5);
@@ -153,7 +153,7 @@ public class RangeSetWrapperTest {
@Test
public void testAddCompareCompareWithGuava() {
- set = new RangeSetWrapper<>(consumer, reverseConvert, managedCursor);
+ set = new RangeSetWrapper<>(CONSUMER, REVERSE_CONVERT, managedCursor);
com.google.common.collect.RangeSet<LongPair> gSet = TreeRangeSet.create();
// add 10K values for key 0
@@ -192,7 +192,7 @@ public class RangeSetWrapperTest {
@Test
public void testDeleteCompareWithGuava() throws Exception {
- RangeSetWrapper<LongPair> set = new RangeSetWrapper<>(consumer, reverseConvert, managedCursor);
+ RangeSetWrapper<LongPair> set = new RangeSetWrapper<>(CONSUMER, REVERSE_CONVERT, managedCursor);
com.google.common.collect.RangeSet<LongPair> gSet = TreeRangeSet.create();
// add 10K values for key 0
@@ -246,7 +246,7 @@ public class RangeSetWrapperTest {
@Test
public void testSpanWithGuava() {
- set = new RangeSetWrapper<>(consumer, reverseConvert, managedCursor);
+ set = new RangeSetWrapper<>(CONSUMER, REVERSE_CONVERT, managedCursor);
com.google.common.collect.RangeSet<LongPair> gSet = TreeRangeSet.create();
set.addOpenClosed(0, 97, 0, 99);
gSet.add(Range.openClosed(new LongPair(0, 97), new LongPair(0, 99)));
@@ -271,7 +271,7 @@ public class RangeSetWrapperTest {
@Test
public void testFirstRange() {
- set = new RangeSetWrapper<>(consumer, reverseConvert, managedCursor);
+ set = new RangeSetWrapper<>(CONSUMER, REVERSE_CONVERT, managedCursor);
assertNull(set.firstRange());
set.addOpenClosed(0, 97, 0, 99);
assertEquals(set.firstRange(), Range.openClosed(new LongPair(0, 97), new LongPair(0, 99)));
@@ -286,7 +286,7 @@ public class RangeSetWrapperTest {
@Test
public void testLastRange() {
- set = new RangeSetWrapper<>(consumer, reverseConvert, managedCursor);
+ set = new RangeSetWrapper<>(CONSUMER, REVERSE_CONVERT, managedCursor);
assertNull(set.lastRange());
Range<LongPair> range = Range.openClosed(new LongPair(0, 97), new LongPair(0, 99));
set.addOpenClosed(0, 97, 0, 99);
@@ -307,7 +307,7 @@ public class RangeSetWrapperTest {
@Test
public void testToString() {
- set = new RangeSetWrapper<>(consumer, reverseConvert, managedCursor);
+ set = new RangeSetWrapper<>(CONSUMER, REVERSE_CONVERT, managedCursor);
set.addOpenClosed(0, 97, 0, 99);
assertEquals(set.toString(), "[(0:97..0:99]]");
set.addOpenClosed(0, 98, 0, 105);
@@ -318,7 +318,7 @@ public class RangeSetWrapperTest {
@Test
public void testDeleteForDifferentKey() {
- set = new RangeSetWrapper<>(consumer, reverseConvert, managedCursor);
+ set = new RangeSetWrapper<>(CONSUMER, REVERSE_CONVERT, managedCursor);
set.addOpenClosed(0, 97, 0, 99);
set.addOpenClosed(0, 99, 1, 5);
set.addOpenClosed(1, 9, 1, 15);
@@ -349,7 +349,7 @@ public class RangeSetWrapperTest {
@Test
public void testDeleteWithAtMost() {
- set = new RangeSetWrapper<>(consumer, reverseConvert, managedCursor);
+ set = new RangeSetWrapper<>(CONSUMER, REVERSE_CONVERT, managedCursor);
set.addOpenClosed(0, 98, 0, 99);
set.addOpenClosed(0, 100, 1, 5);
set.addOpenClosed(1, 10, 1, 15);
@@ -375,7 +375,7 @@ public class RangeSetWrapperTest {
@Test
public void testDeleteWithAtMost2() {
- set = new RangeSetWrapper<>(consumer, reverseConvert, managedCursor);
+ set = new RangeSetWrapper<>(CONSUMER, REVERSE_CONVERT, managedCursor);
set.addOpenClosed(0, 98, 0, 99);
set.addOpenClosed(0, 100, 1, 5);
set.addOpenClosed(1, 10, 1, 15);
@@ -395,7 +395,7 @@ public class RangeSetWrapperTest {
assertEquals(ranges.get(count), (Range.openClosed(new LongPair(2, 25), new LongPair(2, 28))));
managedLedgerConfig.setUnackedRangesOpenCacheSetEnabled(false);
- set = new RangeSetWrapper<>(consumer, reverseConvert, managedCursor);
+ set = new RangeSetWrapper<>(CONSUMER, REVERSE_CONVERT, managedCursor);
set.addOpenClosed(0, 98, 0, 99);
set.addOpenClosed(0, 100, 1, 5);
set.addOpenClosed(1, 10, 1, 15);
@@ -416,7 +416,7 @@ public class RangeSetWrapperTest {
@Test
public void testDeleteWithLeastMost() {
- set = new RangeSetWrapper<>(consumer, reverseConvert, managedCursor);
+ set = new RangeSetWrapper<>(CONSUMER, REVERSE_CONVERT, managedCursor);
set.addOpenClosed(0, 98, 0, 99);
set.addOpenClosed(0, 100, 1, 5);
set.addOpenClosed(1, 10, 1, 15);
@@ -444,7 +444,7 @@ public class RangeSetWrapperTest {
@Test
public void testRangeContaining() {
- set = new RangeSetWrapper<>(consumer, reverseConvert, managedCursor);
+ set = new RangeSetWrapper<>(CONSUMER, REVERSE_CONVERT, managedCursor);
set.add(Range.closed(new LongPair(0, 98), new LongPair(0, 99)));
set.add(Range.closed(new LongPair(0, 100), new LongPair(1, 5)));
com.google.common.collect.RangeSet<LongPair> gSet = TreeRangeSet.create();
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ReadOnlyCursorTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ReadOnlyCursorTest.java
index 80879b97a3e..f594b8e2f5f 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ReadOnlyCursorTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ReadOnlyCursorTest.java
@@ -57,19 +57,20 @@ public class ReadOnlyCursorTest extends MockedBookKeeperTestCase {
void simple() throws Exception {
ManagedLedger ledger = factory.open("simple", new ManagedLedgerConfig().setRetentionTime(1, TimeUnit.HOURS));
- int N = 10;
+ int num = 10;
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
ledger.addEntry(("entry-" + i).getBytes());
}
- ReadOnlyCursor cursor = factory.openReadOnlyCursor("simple", PositionFactory.EARLIEST, new ManagedLedgerConfig());
+ ReadOnlyCursor cursor = factory.openReadOnlyCursor("simple", PositionFactory.EARLIEST,
+ new ManagedLedgerConfig());
- assertEquals(cursor.getNumberOfEntries(), N);
+ assertEquals(cursor.getNumberOfEntries(), num);
assertTrue(cursor.hasMoreEntries());
- List<Entry> entries = cursor.readEntries(N);
- assertEquals(entries.size(), N);
+ List<Entry> entries = cursor.readEntries(num);
+ assertEquals(entries.size(), num);
assertEquals(cursor.getNumberOfEntries(), 0);
assertFalse(cursor.hasMoreEntries());
@@ -77,25 +78,25 @@ public class ReadOnlyCursorTest extends MockedBookKeeperTestCase {
cursor.close();
// Ensure we can still write to ledger
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
ledger.addEntry(("entry-" + i).getBytes());
}
// Open a new cursor
cursor = factory.openReadOnlyCursor("simple", PositionFactory.EARLIEST, new ManagedLedgerConfig());
- assertEquals(cursor.getNumberOfEntries(), 2 * N);
+ assertEquals(cursor.getNumberOfEntries(), 2 * num);
assertTrue(cursor.hasMoreEntries());
- entries = cursor.readEntries(N);
- assertEquals(entries.size(), N);
+ entries = cursor.readEntries(num);
+ assertEquals(entries.size(), num);
- assertEquals(cursor.getNumberOfEntries(), N);
+ assertEquals(cursor.getNumberOfEntries(), num);
assertTrue(cursor.hasMoreEntries());
entries.forEach(Entry::release);
- entries = cursor.readEntries(N);
- assertEquals(entries.size(), N);
+ entries = cursor.readEntries(num);
+ assertEquals(entries.size(), num);
assertEquals(cursor.getNumberOfEntries(), 0);
assertFalse(cursor.hasMoreEntries());
@@ -112,20 +113,20 @@ public class ReadOnlyCursorTest extends MockedBookKeeperTestCase {
.setRetentionTime(1, TimeUnit.HOURS)
.setRetentionSizeInMB(-1));
- int N = 10;
+ int num = 10;
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
ledger.addEntry(("entry-" + i).getBytes());
}
ReadOnlyCursor cursor = factory.openReadOnlyCursor("skip", PositionFactory.EARLIEST, new ManagedLedgerConfig());
- assertEquals(cursor.getNumberOfEntries(), N);
+ assertEquals(cursor.getNumberOfEntries(), num);
assertTrue(cursor.hasMoreEntries());
cursor.skipEntries(5);
- assertEquals(cursor.getNumberOfEntries(), N - 5);
+ assertEquals(cursor.getNumberOfEntries(), num - 5);
assertTrue(cursor.hasMoreEntries());
cursor.close();
@@ -136,19 +137,19 @@ public class ReadOnlyCursorTest extends MockedBookKeeperTestCase {
ManagedLedger ledger = factory.open("skip-all",
new ManagedLedgerConfig().setMaxEntriesPerLedger(7).setRetentionTime(1, TimeUnit.HOURS));
- int N = 10;
+ int num = 10;
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
ledger.addEntry(("entry-" + i).getBytes());
}
ReadOnlyCursor cursor = factory.openReadOnlyCursor("skip-all", PositionFactory.EARLIEST,
new ManagedLedgerConfig());
- assertEquals(cursor.getNumberOfEntries(), N);
+ assertEquals(cursor.getNumberOfEntries(), num);
assertTrue(cursor.hasMoreEntries());
- cursor.skipEntries(N);
+ cursor.skipEntries(num);
assertEquals(cursor.getNumberOfEntries(), 0);
assertFalse(cursor.hasMoreEntries());
@@ -164,15 +165,15 @@ public class ReadOnlyCursorTest extends MockedBookKeeperTestCase {
.setRetentionTime(1, TimeUnit.HOURS)
.setRetentionSizeInMB(-1));
- int N = 30;
+ int num = 30;
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
ledger.addEntry(("entry-" + i).getBytes());
}
ReadOnlyCursor cursor = factory.openReadOnlyCursor("skip", PositionFactory.EARLIEST, new ManagedLedgerConfig());
- assertEquals(cursor.getNumberOfEntries(), N);
+ assertEquals(cursor.getNumberOfEntries(), num);
assertTrue(cursor.hasMoreEntries());
cursor.skipEntries(25);
@@ -192,7 +193,8 @@ public class ReadOnlyCursorTest extends MockedBookKeeperTestCase {
void empty() throws Exception {
factory.open("empty", new ManagedLedgerConfig().setRetentionTime(1, TimeUnit.HOURS));
- ReadOnlyCursor cursor = factory.openReadOnlyCursor("empty", PositionFactory.EARLIEST, new ManagedLedgerConfig());
+ ReadOnlyCursor cursor = factory.openReadOnlyCursor("empty", PositionFactory.EARLIEST,
+ new ManagedLedgerConfig());
assertEquals(cursor.getNumberOfEntries(), 0);
assertFalse(cursor.hasMoreEntries());
@@ -204,21 +206,22 @@ public class ReadOnlyCursorTest extends MockedBookKeeperTestCase {
void specifyStartPosition() throws Exception {
ManagedLedger ledger = factory.open("simple", new ManagedLedgerConfig().setRetentionTime(1, TimeUnit.HOURS));
- int N = 10;
+ int num = 10;
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < num; i++) {
ledger.addEntry(("entry-" + i).getBytes());
}
- ReadOnlyCursor cursor = factory.openReadOnlyCursor("simple", PositionFactory.EARLIEST, new ManagedLedgerConfig());
+ ReadOnlyCursor cursor = factory.openReadOnlyCursor("simple", PositionFactory.EARLIEST,
+ new ManagedLedgerConfig());
- assertEquals(cursor.getNumberOfEntries(), N);
+ assertEquals(cursor.getNumberOfEntries(), num);
assertTrue(cursor.hasMoreEntries());
Position readPosition = cursor.getReadPosition();
cursor = factory.openReadOnlyCursor("simple", readPosition, new ManagedLedgerConfig());
- assertEquals(cursor.getNumberOfEntries(), N);
+ assertEquals(cursor.getNumberOfEntries(), num);
assertTrue(cursor.hasMoreEntries());
cursor.skipEntries(5);
@@ -226,7 +229,7 @@ public class ReadOnlyCursorTest extends MockedBookKeeperTestCase {
Position newReadPosition = cursor.getReadPosition();
cursor = factory.openReadOnlyCursor("simple", newReadPosition, new ManagedLedgerConfig());
- assertEquals(cursor.getNumberOfEntries(), N - 5);
+ assertEquals(cursor.getNumberOfEntries(), num - 5);
assertTrue(cursor.hasMoreEntries());
}
@@ -243,7 +246,8 @@ public class ReadOnlyCursorTest extends MockedBookKeeperTestCase {
payloads.add(payload);
}
- ReadOnlyCursor cursor = factory.openReadOnlyCursor("simple", PositionFactory.EARLIEST, new ManagedLedgerConfig());
+ ReadOnlyCursor cursor = factory.openReadOnlyCursor("simple", PositionFactory.EARLIEST,
+ new ManagedLedgerConfig());
int numberOfEntriesToRead = 8;
CompletableFuture<List<Entry>> future = new CompletableFuture<>();
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ShadowManagedLedgerImplTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ShadowManagedLedgerImplTest.java
index fc5450f2c4c..8c5d4088c39 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ShadowManagedLedgerImplTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ShadowManagedLedgerImplTest.java
@@ -18,7 +18,9 @@
*/
package org.apache.bookkeeper.mledger.impl;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertTrue;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.HashMap;
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/cache/PendingReadsManagerTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/cache/PendingReadsManagerTest.java
index 55068580f62..ebf01cba269 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/cache/PendingReadsManagerTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/cache/PendingReadsManagerTest.java
@@ -59,7 +59,7 @@ public class PendingReadsManagerTest {
static final Object CTX = "foo";
static final Object CTX2 = "far";
- static final long ledgerId = 123414L;
+ static final long LEDGER_ID = 123414L;
ExecutorService orderedExecutor;
PendingReadsManagerTest() {
@@ -148,7 +148,7 @@ public class PendingReadsManagerTest {
List<EntryImpl> result = new ArrayList<>();
for (long i = start; i <= end; i++) {
long entryId = i;
- EntryImpl entry = EntryImpl.create(ledgerId, entryId, "data".getBytes(StandardCharsets.UTF_8));
+ EntryImpl entry = EntryImpl.create(LEDGER_ID, entryId, "data".getBytes(StandardCharsets.UTF_8));
result.add(entry);
}
return result;
@@ -176,7 +176,7 @@ public class PendingReadsManagerTest {
@Override
public String toString() {
- return "PreparedReadFromStorage("+firstEntry+","+endEntry+","+shouldCacheEntry+")";
+ return "PreparedReadFromStorage(" + firstEntry + "," + endEntry + "," + shouldCacheEntry + ")";
}
public void storageReadCompleted() {
@@ -185,12 +185,13 @@ public class PendingReadsManagerTest {
}
private PreparedReadFromStorage prepareReadFromStorage(ReadHandle lh, RangeEntryCacheImpl rangeEntryCache,
- long firstEntry, long endEntry, boolean shouldCacheEntry) {
+ long firstEntry, long endEntry, boolean shouldCacheEntry) {
PreparedReadFromStorage read = new PreparedReadFromStorage(firstEntry, endEntry, shouldCacheEntry);
log.info("prepareReadFromStorage from {} to {} shouldCacheEntry {}", firstEntry, endEntry, shouldCacheEntry);
when(rangeEntryCache.readFromStorage(eq(lh), eq(firstEntry), eq(endEntry), eq(shouldCacheEntry))).thenAnswer(
(invocationOnMock -> {
- log.info("readFromStorage from {} to {} shouldCacheEntry {}", firstEntry, endEntry, shouldCacheEntry);
+ log.info("readFromStorage from {} to {} shouldCacheEntry {}", firstEntry, endEntry,
+ shouldCacheEntry);
return read;
})
);
@@ -204,8 +205,8 @@ public class PendingReadsManagerTest {
long endEntry = 199;
boolean shouldCacheEntry = false;
- PreparedReadFromStorage read1
- = prepareReadFromStorage(lh, rangeEntryCache, firstEntry, endEntry, shouldCacheEntry);
+ PreparedReadFromStorage read1 =
+ prepareReadFromStorage(lh, rangeEntryCache, firstEntry, endEntry, shouldCacheEntry);
CapturingReadEntriesCallback callback = new CapturingReadEntriesCallback();
pendingReadsManager.readEntries(lh, firstEntry, endEntry, shouldCacheEntry, callback, CTX);
@@ -229,7 +230,8 @@ public class PendingReadsManagerTest {
long endEntry = 199;
boolean shouldCacheEntry = false;
- PreparedReadFromStorage read1 = prepareReadFromStorage(lh, rangeEntryCache, firstEntry, endEntry, shouldCacheEntry);
+ PreparedReadFromStorage read1 =
+ prepareReadFromStorage(lh, rangeEntryCache, firstEntry, endEntry, shouldCacheEntry);
PendingReadsManager pendingReadsManager = new PendingReadsManager(rangeEntryCache);
CapturingReadEntriesCallback callback = new CapturingReadEntriesCallback();
@@ -252,7 +254,7 @@ public class PendingReadsManagerTest {
verifyRange(callback2.entries, firstEntry, endEntry);
int pos = 0;
- for (long entry = firstEntry; entry <= endEntry; entry++) {;
+ for (long entry = firstEntry; entry <= endEntry; entry++) {
assertNotSame(callback.entries.get(pos), callback2.entries.get(pos));
assertEquals(callback.entries.get(pos).getEntryId(), callback2.entries.get(pos).getEntryId());
pos++;
@@ -271,7 +273,8 @@ public class PendingReadsManagerTest {
boolean shouldCacheEntry = false;
- PreparedReadFromStorage read1 = prepareReadFromStorage(lh, rangeEntryCache, firstEntry, endEntry, shouldCacheEntry);
+ PreparedReadFromStorage read1 =
+ prepareReadFromStorage(lh, rangeEntryCache, firstEntry, endEntry, shouldCacheEntry);
PendingReadsManager pendingReadsManager = new PendingReadsManager(rangeEntryCache);
CapturingReadEntriesCallback callback = new CapturingReadEntriesCallback();
@@ -279,7 +282,8 @@ public class PendingReadsManagerTest {
CapturingReadEntriesCallback callback2 = new CapturingReadEntriesCallback();
- pendingReadsManager.readEntries(lh, firstEntrySecondRead, endEntrySecondRead, shouldCacheEntry, callback2, CTX2);
+ pendingReadsManager.readEntries(lh, firstEntrySecondRead, endEntrySecondRead,
+ shouldCacheEntry, callback2, CTX2);
// complete the read from BK
// only one read completes 2 callbacks
@@ -295,11 +299,12 @@ public class PendingReadsManagerTest {
verifyRange(callback2.entries, firstEntrySecondRead, endEntrySecondRead);
int pos = 0;
- for (long entry = firstEntry; entry <= endEntry; entry++) {;
+ for (long entry = firstEntry; entry <= endEntry; entry++) {
if (entry >= firstEntrySecondRead && entry <= endEntrySecondRead) {
int posInSecondList = (int) (pos - (firstEntrySecondRead - firstEntry));
assertNotSame(callback.entries.get(pos), callback2.entries.get(posInSecondList));
- assertEquals(callback.entries.get(pos).getEntryId(), callback2.entries.get(posInSecondList).getEntryId());
+ assertEquals(callback.entries.get(pos).getEntryId(),
+ callback2.entries.get(posInSecondList).getEntryId());
}
pos++;
}
@@ -328,7 +333,8 @@ public class PendingReadsManagerTest {
pendingReadsManager.readEntries(lh, firstEntry, endEntry, shouldCacheEntry, callback, CTX);
CapturingReadEntriesCallback callback2 = new CapturingReadEntriesCallback();
- pendingReadsManager.readEntries(lh, firstEntrySecondRead, endEntrySecondRead, shouldCacheEntry, callback2, CTX2);
+ pendingReadsManager.readEntries(lh, firstEntrySecondRead,
+ endEntrySecondRead, shouldCacheEntry, callback2, CTX2);
// complete the read from BK
read1.storageReadCompleted();
@@ -368,7 +374,8 @@ public class PendingReadsManagerTest {
pendingReadsManager.readEntries(lh, firstEntry, endEntry, shouldCacheEntry, callback, CTX);
CapturingReadEntriesCallback callback2 = new CapturingReadEntriesCallback();
- pendingReadsManager.readEntries(lh, firstEntrySecondRead, endEntrySecondRead, shouldCacheEntry, callback2, CTX2);
+ pendingReadsManager.readEntries(lh, firstEntrySecondRead,
+ endEntrySecondRead, shouldCacheEntry, callback2, CTX2);
// complete the read from BK
read1.storageReadCompleted();
@@ -411,7 +418,8 @@ public class PendingReadsManagerTest {
pendingReadsManager.readEntries(lh, firstEntry, endEntry, shouldCacheEntry, callback, CTX);
CapturingReadEntriesCallback callback2 = new CapturingReadEntriesCallback();
- pendingReadsManager.readEntries(lh, firstEntrySecondRead, endEntrySecondRead, shouldCacheEntry, callback2, CTX2);
+ pendingReadsManager.readEntries(lh, firstEntrySecondRead,
+ endEntrySecondRead, shouldCacheEntry, callback2, CTX2);
// complete the read from BK
read1.storageReadCompleted();
@@ -452,7 +460,8 @@ public class PendingReadsManagerTest {
pendingReadsManager.readEntries(lh, firstEntry, endEntry, shouldCacheEntry, callback, CTX);
CapturingReadEntriesCallback callback2 = new CapturingReadEntriesCallback();
- pendingReadsManager.readEntries(lh, firstEntrySecondRead, endEntrySecondRead, shouldCacheEntry, callback2, CTX2);
+ pendingReadsManager.readEntries(lh, firstEntrySecondRead,
+ endEntrySecondRead, shouldCacheEntry, callback2, CTX2);
read1.storageReadCompleted();
callback.get();
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/offload/OffloadUtilsTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/offload/OffloadUtilsTest.java
index 798dfda9d89..ee207740dfc 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/offload/OffloadUtilsTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/offload/OffloadUtilsTest.java
@@ -18,14 +18,12 @@
*/
package org.apache.bookkeeper.mledger.offload;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.bookkeeper.mledger.proto.MLDataFormats;
import org.testng.Assert;
import org.testng.annotations.Test;
-import java.util.HashMap;
-import java.util.Map;
-
-
public class OffloadUtilsTest {
@Test
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/offload/OffloadersCacheTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/offload/OffloadersCacheTest.java
index 78fe1bdb3b0..f20b9b9cbbf 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/offload/OffloadersCacheTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/offload/OffloadersCacheTest.java
@@ -18,11 +18,11 @@
*/
package org.apache.bookkeeper.mledger.offload;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.testng.Assert.assertSame;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.testng.annotations.Test;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.testng.Assert.assertSame;
public class OffloadersCacheTest {
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/util/CallbackMutexTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/util/CallbackMutexTest.java
index ae3dbad6368..94ff45d7bd2 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/util/CallbackMutexTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/util/CallbackMutexTest.java
@@ -37,8 +37,9 @@ public class CallbackMutexTest {
// We will test thread competition in unlock()
new Thread(() -> {
cbm.lock();
- if (salary.value() == 1000)
+ if (salary.value() == 1000) {
salary.add(2000);
+ }
cbm.unlock();
Assert.assertEquals(salary.value(), 3000);
}).start();
@@ -99,18 +100,20 @@ public class CallbackMutexTest {
// Protected Code
salary.set(0);
int raise = 0;
- if (ab.compareAndSet(false, true))
+ if (ab.compareAndSet(false, true)) {
raise = 2;
- else
+ } else {
raise = -2; // Due to protection no thread will ever execute this line
+ }
while (salary.value() < 1000000) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
- if (salary.value() % 2 == 0)
+ if (salary.value() % 2 == 0) {
salary.add(raise);
+ }
}
Assert.assertEquals(salary.value(), 1000000);
ab.compareAndSet(true, false);
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/util/TestStatsBuckets.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/util/TestStatsBuckets.java
index cb0fd2aa090..97955ae49b4 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/util/TestStatsBuckets.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/util/TestStatsBuckets.java
@@ -20,7 +20,6 @@ package org.apache.bookkeeper.mledger.util;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
-
import org.testng.annotations.Test;
public class TestStatsBuckets {
@@ -109,7 +108,7 @@ public class TestStatsBuckets {
StatsBuckets stats2 = new StatsBuckets(10, 20, 30);
stats2.addAll(stats);
stats2.refresh();
- assertEquals(stats2.getSum(),3);
- assertEquals(stats2.getCount(),2);
+ assertEquals(stats2.getSum(), 3);
+ assertEquals(stats2.getCount(), 2);
}
}
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/test/MockedBookKeeperTestCase.java b/managed-ledger/src/test/java/org/apache/bookkeeper/test/MockedBookKeeperTestCase.java
index c7685cfaa65..178a9cf984d 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/test/MockedBookKeeperTestCase.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/test/MockedBookKeeperTestCase.java
@@ -143,13 +143,13 @@ public abstract class MockedBookKeeperTestCase {
}
/**
- * Start cluster
+ * Start cluster.
*
* @throws Exception
*/
protected void startBookKeeper() throws Exception {
for (int i = 0; i < numBookies; i++) {
- metadataStore.put( "/ledgers/available/192.168.1.1:" + (5000 + i), new byte[0], Optional.empty()).join();
+ metadataStore.put("/ledgers/available/192.168.1.1:" + (5000 + i), new byte[0], Optional.empty()).join();
}
metadataStore.put("/ledgers/LAYOUT", "1\nflat:1".getBytes(), Optional.empty()).join();
diff --git a/pulsar-broker-auth-oidc/src/test/java/org/apache/pulsar/broker/authentication/oidc/AuthenticationProviderOpenIDIntegrationTest.java b/pulsar-broker-auth-oidc/src/test/java/org/apache/pulsar/broker/authentication/oidc/AuthenticationProviderOpenIDIntegrationTest.java
index f4663a9ee3c..dd313cdb73a 100644
--- a/pulsar-broker-auth-oidc/src/test/java/org/apache/pulsar/broker/authentication/oidc/AuthenticationProviderOpenIDIntegrationTest.java
+++ b/pulsar-broker-auth-oidc/src/test/java/org/apache/pulsar/broker/authentication/oidc/AuthenticationProviderOpenIDIntegrationTest.java
@@ -170,7 +170,7 @@ public class AuthenticationProviderOpenIDIntegrationTest {
// Set up JWKS endpoint with a valid and an invalid public key
// The url matches are for both the normal and the k8s endpoints
server.stubFor(
- get(urlMatching( "/keys|/k8s/openid/v1/jwks/"))
+ get(urlMatching("/keys|/k8s/openid/v1/jwks/"))
.willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBody(
@@ -215,7 +215,7 @@ public class AuthenticationProviderOpenIDIntegrationTest {
// Note that the state machine is circular to make it easier to verify the two code paths that rely on
// this logic.
server.stubFor(
- get(urlMatching( "/missing-kid/keys"))
+ get(urlMatching("/missing-kid/keys"))
.inScenario("Changing KIDs")
.whenScenarioStateIs(Scenario.STARTED)
.willSetStateTo("serve-kid")
@@ -223,7 +223,7 @@ public class AuthenticationProviderOpenIDIntegrationTest {
.withHeader("Content-Type", "application/json")
.withBody("{\"keys\":[]}")));
server.stubFor(
- get(urlMatching( "/missing-kid/keys"))
+ get(urlMatching("/missing-kid/keys"))
.inScenario("Changing KIDs")
.whenScenarioStateIs("serve-kid")
.willSetStateTo(Scenario.STARTED)
@@ -300,7 +300,7 @@ public class AuthenticationProviderOpenIDIntegrationTest {
@Test
public void testTokenWithInvalidJWK() throws Exception {
String role = "superuser";
- String token = generateToken(invalidJwk, issuer, role, "allowed-audience",0L, 0L, 10000L);
+ String token = generateToken(invalidJwk, issuer, role, "allowed-audience", 0L, 0L, 10000L);
try {
provider.authenticateAsync(new AuthenticationDataCommand(token)).get();
fail("Expected exception");
@@ -336,7 +336,8 @@ public class AuthenticationProviderOpenIDIntegrationTest {
@Test
public void testTokenWithInvalidIssuer() throws Exception {
String role = "superuser";
- String token = generateToken(validJwk, "https://not-an-allowed-issuer.com", role, "allowed-audience", 0L, 0L, 10000L);
+ String token = generateToken(validJwk, "https://not-an-allowed-issuer.com", role,
+ "allowed-audience", 0L, 0L, 10000L);
try {
provider.authenticateAsync(new AuthenticationDataCommand(token)).get();
fail("Expected exception");
diff --git a/pulsar-broker-auth-oidc/src/test/java/org/apache/pulsar/broker/authentication/oidc/AuthenticationProviderOpenIDTest.java b/pulsar-broker-auth-oidc/src/test/java/org/apache/pulsar/broker/authentication/oidc/AuthenticationProviderOpenIDTest.java
index 4a12f61528a..377588c4a5a 100644
--- a/pulsar-broker-auth-oidc/src/test/java/org/apache/pulsar/broker/authentication/oidc/AuthenticationProviderOpenIDTest.java
+++ b/pulsar-broker-auth-oidc/src/test/java/org/apache/pulsar/broker/authentication/oidc/AuthenticationProviderOpenIDTest.java
@@ -308,7 +308,8 @@ public class AuthenticationProviderOpenIDTest {
@Cleanup
AuthenticationProviderOpenID provider = new AuthenticationProviderOpenID();
Properties props = new Properties();
- props.setProperty(AuthenticationProviderOpenID.ALLOWED_TOKEN_ISSUERS, "https://myissuer.com,http://myissuer.com");
+ props.setProperty(AuthenticationProviderOpenID.ALLOWED_TOKEN_ISSUERS,
+ "https://myissuer.com,http://myissuer.com");
ServiceConfiguration config = new ServiceConfiguration();
config.setProperties(props);
Assert.assertThrows(IllegalArgumentException.class,
diff --git a/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/ProxySaslAuthenticationTest.java b/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/ProxySaslAuthenticationTest.java
index 7a50fa42089..db73bb7d2bb 100644
--- a/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/ProxySaslAuthenticationTest.java
+++ b/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/ProxySaslAuthenticationTest.java
@@ -19,7 +19,6 @@
package org.apache.pulsar.broker.authentication;
import com.google.common.collect.ImmutableSet;
-
import java.io.File;
import java.io.FileWriter;
import java.net.URI;
@@ -32,9 +31,7 @@ import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-
import javax.security.auth.login.Configuration;
-
import lombok.Cleanup;
import org.apache.commons.io.FileUtils;
import org.apache.pulsar.client.admin.PulsarAdmin;
@@ -209,8 +206,8 @@ public class ProxySaslAuthenticationTest extends ProducerConsumerBase {
closeAdmin();
admin = PulsarAdmin.builder()
.serviceHttpUrl(brokerUrl.toString())
- .authentication(AuthenticationFactory.create(AuthenticationSasl.class.getName(), clientSaslConfig))
- .build();
+ .authentication(AuthenticationFactory.create(AuthenticationSasl.class.getName(),
+ clientSaslConfig)).build();
super.producerBaseSetup();
log.info("-- {} --, end.", methodName);
}
@@ -247,8 +244,8 @@ public class ProxySaslAuthenticationTest extends ProducerConsumerBase {
// proxy connect to broker
proxyConfig.setBrokerClientAuthenticationPlugin(AuthenticationSasl.class.getName());
proxyConfig.setBrokerClientAuthenticationParameters(
- "{\"saslJaasClientSectionName\": " + "\"PulsarProxy\"," +
- "\"serverType\": " + "\"broker\"}");
+ "{\"saslJaasClientSectionName\": " + "\"PulsarProxy\","
+ + "\"serverType\": " + "\"broker\"}");
proxySecretKeyFile = File.createTempFile("saslRoleTokenSignerSecret", ".key");
Files.write(Paths.get(proxySecretKeyFile.toString()), "PulsarSecret".getBytes());
proxyConfig.setSaslJaasServerRoleTokenSignerSecretPath(proxySecretKeyFile.toString());
@@ -258,11 +255,11 @@ public class ProxySaslAuthenticationTest extends ProducerConsumerBase {
proxyConfig.setAuthenticationProviders(providers);
proxyConfig.setForwardAuthorizationCredentials(true);
- @Cleanup
AuthenticationService authenticationService = new AuthenticationService(
PulsarConfigurationLoader.convertFrom(proxyConfig));
@Cleanup
- final Authentication proxyClientAuthentication = AuthenticationFactory.create(proxyConfig.getBrokerClientAuthenticationPlugin(),
+ final Authentication proxyClientAuthentication =
+ AuthenticationFactory.create(proxyConfig.getBrokerClientAuthenticationPlugin(),
proxyConfig.getBrokerClientAuthenticationParameters());
proxyClientAuthentication.start();
ProxyService proxyService = new ProxyService(proxyConfig, authenticationService, proxyClientAuthentication);
@@ -279,7 +276,8 @@ public class ProxySaslAuthenticationTest extends ProducerConsumerBase {
Producer<byte[]> producer = proxyClient.newProducer(Schema.BYTES).topic(topicName).create();
log.info("3 created producer.");
- Consumer<byte[]> consumer = proxyClient.newConsumer(Schema.BYTES).topic(topicName).subscriptionName("test-sub").subscribe();
+ Consumer<byte[]> consumer = proxyClient.newConsumer(Schema.BYTES).topic(topicName)
+ .subscriptionName("test-sub").subscribe();
log.info("4 created consumer.");
for (int i = 0; i < 10; i++) {
@@ -304,12 +302,14 @@ public class ProxySaslAuthenticationTest extends ProducerConsumerBase {
proxyService.close();
}
- private PulsarClient createProxyClient(String proxyServiceUrl, int numberOfConnections) throws PulsarClientException {
+ private PulsarClient createProxyClient(String proxyServiceUrl, int numberOfConnections)
+ throws PulsarClientException {
Map<String, String> clientSaslConfig = new HashMap<>();
clientSaslConfig.put("saslJaasClientSectionName", "PulsarClient");
clientSaslConfig.put("serverType", "proxy");
log.info("set client jaas section name: PulsarClient, serverType: proxy");
- Authentication authSasl = AuthenticationFactory.create(AuthenticationSasl.class.getName(), clientSaslConfig);
+ Authentication authSasl =
+ AuthenticationFactory.create(AuthenticationSasl.class.getName(), clientSaslConfig);
return PulsarClient.builder().serviceUrl(proxyServiceUrl)
.authentication(authSasl).connectionsPerBroker(numberOfConnections).build();
diff --git a/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/SaslServerTokenSignerTest.java b/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/SaslServerTokenSignerTest.java
index b99c46c6573..5da1ecfac4d 100644
--- a/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/SaslServerTokenSignerTest.java
+++ b/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/SaslServerTokenSignerTest.java
@@ -19,7 +19,6 @@
package org.apache.pulsar.broker.authentication;
import javax.naming.AuthenticationException;
-
import lombok.extern.slf4j.Slf4j;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -32,8 +31,7 @@ public class SaslServerTokenSignerTest {
try {
new SaslRoleTokenSigner(null);
Assert.fail();
- }
- catch (IllegalArgumentException ex) {
+ } catch (IllegalArgumentException ex) {
}
}
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMappingTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMappingTest.java
index 3ca24a680bb..46466dc6f97 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMappingTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMappingTest.java
@@ -73,9 +73,9 @@ import org.testng.annotations.Test;
public class BookieRackAffinityMappingTest {
- private BookieSocketAddress BOOKIE1 = null;
- private BookieSocketAddress BOOKIE2 = null;
- private BookieSocketAddress BOOKIE3 = null;
+ private BookieSocketAddress bookie1 = null;
+ private BookieSocketAddress bookie2 = null;
+ private BookieSocketAddress bookie3 = null;
private MetadataStore store;
private final ObjectMapper jsonMapper = ObjectMapperFactory.create();
@@ -83,9 +83,9 @@ public class BookieRackAffinityMappingTest {
@BeforeMethod
public void setUp() throws Exception {
store = MetadataStoreFactory.create("memory:local", MetadataStoreConfig.builder().build());
- BOOKIE1 = new BookieSocketAddress("127.0.0.1:3181");
- BOOKIE2 = new BookieSocketAddress("127.0.0.2:3181");
- BOOKIE3 = new BookieSocketAddress("127.0.0.3:3181");
+ bookie1 = new BookieSocketAddress("127.0.0.1:3181");
+ bookie2 = new BookieSocketAddress("127.0.0.2:3181");
+ bookie3 = new BookieSocketAddress("127.0.0.3:3181");
}
@AfterMethod(alwaysRun = true)
@@ -95,8 +95,8 @@ public class BookieRackAffinityMappingTest {
@Test
public void testBasic() throws Exception {
- String data = "{\"group1\": {\"" + BOOKIE1
- + "\": {\"rack\": \"/rack0\", \"hostname\": \"bookie1.example.com\"}, \"" + BOOKIE2
+ String data = "{\"group1\": {\"" + bookie1
+ + "\": {\"rack\": \"/rack0\", \"hostname\": \"bookie1.example.com\"}, \"" + bookie2
+ "\": {\"rack\": \"/rack1\", \"hostname\": \"bookie2.example.com\"}}}";
store.put(BookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, data.getBytes(), Optional.empty()).join();
@@ -108,7 +108,7 @@ public class BookieRackAffinityMappingTest {
mapping.setBookieAddressResolver(BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
mapping.setConf(bkClientConf);
List<String> racks = mapping
- .resolve(Lists.newArrayList(BOOKIE1.getHostName(), BOOKIE2.getHostName(), BOOKIE3.getHostName()));
+ .resolve(Lists.newArrayList(bookie1.getHostName(), bookie2.getHostName(), bookie3.getHostName()));
assertEquals(racks.get(0), "/rack0");
assertEquals(racks.get(1), "/rack1");
@@ -129,8 +129,8 @@ public class BookieRackAffinityMappingTest {
@Test
public void testInvalidRackName() {
- String data = "{\"group1\": {\"" + BOOKIE1
- + "\": {\"rack\": \"/\", \"hostname\": \"bookie1.example.com\"}, \"" + BOOKIE2
+ String data = "{\"group1\": {\"" + bookie1
+ + "\": {\"rack\": \"/\", \"hostname\": \"bookie1.example.com\"}, \"" + bookie2
+ "\": {\"rack\": \"\", \"hostname\": \"bookie2.example.com\"}}}";
store.put(BookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, data.getBytes(), Optional.empty()).join();
@@ -143,7 +143,7 @@ public class BookieRackAffinityMappingTest {
mapping1.setBookieAddressResolver(BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
mapping1.setConf(bkClientConf1);
List<String> racks = mapping1
- .resolve(Lists.newArrayList(BOOKIE1.getHostName(), BOOKIE2.getHostName(), BOOKIE3.getHostName()));
+ .resolve(Lists.newArrayList(bookie1.getHostName(), bookie2.getHostName(), bookie3.getHostName()));
assertNull(racks.get(0));
assertNull(racks.get(1));
@@ -166,8 +166,8 @@ public class BookieRackAffinityMappingTest {
Map<String, Map<BookieSocketAddress, BookieInfo>> bookieMapping = new HashMap<>();
Map<BookieSocketAddress, BookieInfo> mainBookieGroup = new HashMap<>();
- mainBookieGroup.put(BOOKIE1, BookieInfo.builder().rack("/rack0").build());
- mainBookieGroup.put(BOOKIE2, BookieInfo.builder().rack("/rack1").build());
+ mainBookieGroup.put(bookie1, BookieInfo.builder().rack("/rack0").build());
+ mainBookieGroup.put(bookie2, BookieInfo.builder().rack("/rack1").build());
bookieMapping.put("group1", mainBookieGroup);
@@ -188,8 +188,8 @@ public class BookieRackAffinityMappingTest {
Map<String, Map<BookieSocketAddress, BookieInfo>> bookieMapping = new HashMap<>();
Map<BookieSocketAddress, BookieInfo> mainBookieGroup = new HashMap<>();
- mainBookieGroup.put(BOOKIE1, BookieInfo.builder().rack("rack0").build());
- mainBookieGroup.put(BOOKIE2, BookieInfo.builder().rack("rack1").build());
+ mainBookieGroup.put(bookie1, BookieInfo.builder().rack("rack0").build());
+ mainBookieGroup.put(bookie2, BookieInfo.builder().rack("rack1").build());
bookieMapping.put("group1", mainBookieGroup);
@@ -203,14 +203,14 @@ public class BookieRackAffinityMappingTest {
mapping.setBookieAddressResolver(BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
mapping.setConf(bkClientConf);
List<String> racks = mapping
- .resolve(Lists.newArrayList(BOOKIE1.getHostName(), BOOKIE2.getHostName(), BOOKIE3.getHostName()));
+ .resolve(Lists.newArrayList(bookie1.getHostName(), bookie2.getHostName(), bookie3.getHostName()));
assertEquals(racks.get(0), "/rack0");
assertEquals(racks.get(1), "/rack1");
assertNull(racks.get(2));
// add info for BOOKIE3 and check if the mapping picks up the change
Map<BookieSocketAddress, BookieInfo> secondaryBookieGroup = new HashMap<>();
- secondaryBookieGroup.put(BOOKIE3, BookieInfo.builder().rack("rack0").build());
+ secondaryBookieGroup.put(bookie3, BookieInfo.builder().rack("rack0").build());
bookieMapping.put("group2", secondaryBookieGroup);
store.put(BookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, jsonMapper.writeValueAsBytes(bookieMapping),
@@ -234,8 +234,8 @@ public class BookieRackAffinityMappingTest {
@Test
public void testWithPulsarRegistrationClient() throws Exception {
- String data = "{\"group1\": {\"" + BOOKIE1
- + "\": {\"rack\": \"/rack0\", \"hostname\": \"bookie1.example.com\"}, \"" + BOOKIE2
+ String data = "{\"group1\": {\"" + bookie1
+ + "\": {\"rack\": \"/rack0\", \"hostname\": \"bookie1.example.com\"}, \"" + bookie2
+ "\": {\"rack\": \"/rack1\", \"hostname\": \"bookie2.example.com\"}}}";
store.put(BookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, data.getBytes(), Optional.empty()).join();
@@ -249,12 +249,13 @@ public class BookieRackAffinityMappingTest {
@Cleanup
PulsarRegistrationClient pulsarRegistrationClient = new PulsarRegistrationClient(store, "/ledgers");
- DefaultBookieAddressResolver defaultBookieAddressResolver = new DefaultBookieAddressResolver(pulsarRegistrationClient);
+ DefaultBookieAddressResolver defaultBookieAddressResolver =
+ new DefaultBookieAddressResolver(pulsarRegistrationClient);
mapping.setBookieAddressResolver(defaultBookieAddressResolver);
mapping.setConf(bkClientConf);
List<String> racks = mapping
- .resolve(Lists.newArrayList(BOOKIE1.getHostName(), BOOKIE2.getHostName(), BOOKIE3.getHostName()))
+ .resolve(Lists.newArrayList(bookie1.getHostName(), bookie2.getHostName(), bookie3.getHostName()))
.stream().filter(Objects::nonNull).toList();
assertEquals(racks.size(), 0);
@@ -285,71 +286,75 @@ public class BookieRackAffinityMappingTest {
method.invoke(o);
Set<BookieId> bookieIds = new HashSet<>();
- bookieIds.add(BOOKIE1.toBookieId());
+ bookieIds.add(bookie1.toBookieId());
Field field2 = BookieServiceInfoSerde.class.getDeclaredField("INSTANCE");
field2.setAccessible(true);
BookieServiceInfoSerde serviceInfoSerde = (BookieServiceInfoSerde) field2.get(null);
- BookieServiceInfo bookieServiceInfo = BookieServiceInfoUtils.buildLegacyBookieServiceInfo(BOOKIE1.toString());
- store.put("/ledgers/available/" + BOOKIE1, serviceInfoSerde.serialize("", bookieServiceInfo),
+ BookieServiceInfo bookieServiceInfo = BookieServiceInfoUtils.buildLegacyBookieServiceInfo(bookie1.toString());
+ store.put("/ledgers/available/" + bookie1, serviceInfoSerde.serialize("", bookieServiceInfo),
Optional.of(-1L)).get();
- Awaitility.await().atMost(30, TimeUnit.SECONDS).until(() -> ((BookiesRackConfiguration)field.get(mapping)).get("group1").size() == 1);
+ Awaitility.await().atMost(30, TimeUnit.SECONDS).until(
+ () -> ((BookiesRackConfiguration) field.get(mapping)).get("group1").size() == 1);
racks = mapping
- .resolve(Lists.newArrayList(BOOKIE1.getHostName(), BOOKIE2.getHostName(), BOOKIE3.getHostName()))
+ .resolve(Lists.newArrayList(bookie1.getHostName(), bookie2.getHostName(), bookie3.getHostName()))
.stream().filter(Objects::nonNull).toList();
assertEquals(racks.size(), 1);
assertEquals(racks.get(0), "/rack0");
assertEquals(knownBookies.size(), 1);
- assertEquals(knownBookies.get(BOOKIE1.toBookieId()).getNetworkLocation(), "/rack0");
+ assertEquals(knownBookies.get(bookie1.toBookieId()).getNetworkLocation(), "/rack0");
- bookieServiceInfo = BookieServiceInfoUtils.buildLegacyBookieServiceInfo(BOOKIE2.toString());
- store.put("/ledgers/available/" + BOOKIE2, serviceInfoSerde.serialize("", bookieServiceInfo),
+ bookieServiceInfo = BookieServiceInfoUtils.buildLegacyBookieServiceInfo(bookie2.toString());
+ store.put("/ledgers/available/" + bookie2, serviceInfoSerde.serialize("", bookieServiceInfo),
Optional.of(-1L)).get();
- Awaitility.await().atMost(30, TimeUnit.SECONDS).until(() -> ((BookiesRackConfiguration)field.get(mapping)).get("group1").size() == 2);
+ Awaitility.await().atMost(30, TimeUnit.SECONDS).until(
+ () -> ((BookiesRackConfiguration) field.get(mapping)).get("group1").size() == 2);
racks = mapping
- .resolve(Lists.newArrayList(BOOKIE1.getHostName(), BOOKIE2.getHostName(), BOOKIE3.getHostName()))
+ .resolve(Lists.newArrayList(bookie1.getHostName(), bookie2.getHostName(), bookie3.getHostName()))
.stream().filter(Objects::nonNull).toList();
assertEquals(racks.size(), 2);
assertEquals(racks.get(0), "/rack0");
assertEquals(racks.get(1), "/rack1");
assertEquals(knownBookies.size(), 2);
- assertEquals(knownBookies.get(BOOKIE1.toBookieId()).getNetworkLocation(), "/rack0");
- assertEquals(knownBookies.get(BOOKIE2.toBookieId()).getNetworkLocation(), "/rack1");
+ assertEquals(knownBookies.get(bookie1.toBookieId()).getNetworkLocation(), "/rack0");
+ assertEquals(knownBookies.get(bookie2.toBookieId()).getNetworkLocation(), "/rack1");
- bookieServiceInfo = BookieServiceInfoUtils.buildLegacyBookieServiceInfo(BOOKIE3.toString());
- store.put("/ledgers/available/" + BOOKIE3, serviceInfoSerde.serialize("", bookieServiceInfo),
+ bookieServiceInfo = BookieServiceInfoUtils.buildLegacyBookieServiceInfo(bookie3.toString());
+ store.put("/ledgers/available/" + bookie3, serviceInfoSerde.serialize("", bookieServiceInfo),
Optional.of(-1L)).get();
- Awaitility.await().atMost(30, TimeUnit.SECONDS).until(() -> ((BookiesRackConfiguration)field.get(mapping)).get("group1").size() == 2);
+ Awaitility.await().atMost(30, TimeUnit.SECONDS).until(
+ () -> ((BookiesRackConfiguration) field.get(mapping)).get("group1").size() == 2);
racks = mapping
- .resolve(Lists.newArrayList(BOOKIE1.getHostName(), BOOKIE2.getHostName(), BOOKIE3.getHostName()))
+ .resolve(Lists.newArrayList(bookie1.getHostName(), bookie2.getHostName(), bookie3.getHostName()))
.stream().filter(Objects::nonNull).toList();
assertEquals(racks.size(), 2);
assertEquals(racks.get(0), "/rack0");
assertEquals(racks.get(1), "/rack1");
assertEquals(knownBookies.size(), 3);
- assertEquals(knownBookies.get(BOOKIE1.toBookieId()).getNetworkLocation(), "/rack0");
- assertEquals(knownBookies.get(BOOKIE2.toBookieId()).getNetworkLocation(), "/rack1");
- assertEquals(knownBookies.get(BOOKIE3.toBookieId()).getNetworkLocation(), "/default-rack");
+ assertEquals(knownBookies.get(bookie1.toBookieId()).getNetworkLocation(), "/rack0");
+ assertEquals(knownBookies.get(bookie2.toBookieId()).getNetworkLocation(), "/rack1");
+ assertEquals(knownBookies.get(bookie3.toBookieId()).getNetworkLocation(), "/default-rack");
//remove bookie2 rack, the bookie2 rack should be /default-rack
- data = "{\"group1\": {\"" + BOOKIE1
+ data = "{\"group1\": {\"" + bookie1
+ "\": {\"rack\": \"/rack0\", \"hostname\": \"bookie1.example.com\"}}}";
store.put(BookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, data.getBytes(), Optional.empty()).join();
- Awaitility.await().atMost(30, TimeUnit.SECONDS).until(() -> ((BookiesRackConfiguration)field.get(mapping)).get("group1").size() == 1);
+ Awaitility.await().atMost(30, TimeUnit.SECONDS).until(
+ () -> ((BookiesRackConfiguration) field.get(mapping)).get("group1").size() == 1);
racks = mapping
- .resolve(Lists.newArrayList(BOOKIE1.getHostName(), BOOKIE2.getHostName(), BOOKIE3.getHostName()))
+ .resolve(Lists.newArrayList(bookie1.getHostName(), bookie2.getHostName(), bookie3.getHostName()))
.stream().filter(Objects::nonNull).toList();
assertEquals(racks.size(), 1);
assertEquals(racks.get(0), "/rack0");
assertEquals(knownBookies.size(), 3);
- assertEquals(knownBookies.get(BOOKIE1.toBookieId()).getNetworkLocation(), "/rack0");
- assertEquals(knownBookies.get(BOOKIE2.toBookieId()).getNetworkLocation(), "/default-rack");
- assertEquals(knownBookies.get(BOOKIE3.toBookieId()).getNetworkLocation(), "/default-rack");
+ assertEquals(knownBookies.get(bookie1.toBookieId()).getNetworkLocation(), "/rack0");
+ assertEquals(knownBookies.get(bookie2.toBookieId()).getNetworkLocation(), "/default-rack");
+ assertEquals(knownBookies.get(bookie3.toBookieId()).getNetworkLocation(), "/default-rack");
}
@Test
@@ -399,7 +404,7 @@ public class BookieRackAffinityMappingTest {
executor2.submit(() -> {
Set<BookieId> writableBookies = new HashSet<>();
- writableBookies.add(BOOKIE1.toBookieId());
+ writableBookies.add(bookie1.toBookieId());
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < 2_000) {
repp.onClusterChanged(writableBookies, Collections.emptySet());
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/IsolatedBookieEnsemblePlacementPolicyTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/IsolatedBookieEnsemblePlacementPolicyTest.java
index 2c728120980..68f92ab416d 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/IsolatedBookieEnsemblePlacementPolicyTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/IsolatedBookieEnsemblePlacementPolicyTest.java
@@ -114,10 +114,12 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
ClientConfiguration bkClientConf = new ClientConfiguration();
bkClientConf.setProperty(BookieRackAffinityMapping.METADATA_STORE_INSTANCE, store);
bkClientConf.setProperty(IsolatedBookieEnsemblePlacementPolicy.ISOLATION_BOOKIE_GROUPS, isolationGroups);
- isolationPolicy.initialize(bkClientConf, Optional.empty(), timer, SettableFeatureProvider.DISABLE_ALL, NullStatsLogger.INSTANCE, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
+ isolationPolicy.initialize(bkClientConf, Optional.empty(), timer, SettableFeatureProvider.DISABLE_ALL,
+ NullStatsLogger.INSTANCE, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
isolationPolicy.onClusterChanged(writableBookies, readOnlyBookies);
- List<BookieId> ensemble = isolationPolicy.newEnsemble(2, 2, 2, Collections.emptyMap(), new HashSet<>()).getResult();
+ List<BookieId> ensemble = isolationPolicy.newEnsemble(2, 2, 2,
+ Collections.emptyMap(), new HashSet<>()).getResult();
assertFalse(ensemble.contains(new BookieSocketAddress(BOOKIE3).toBookieId()));
assertFalse(ensemble.contains(new BookieSocketAddress(BOOKIE4).toBookieId()));
}
@@ -186,7 +188,8 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
ClientConfiguration bkClientConf = new ClientConfiguration();
bkClientConf.setProperty(BookieRackAffinityMapping.METADATA_STORE_INSTANCE, store);
bkClientConf.setProperty(IsolatedBookieEnsemblePlacementPolicy.ISOLATION_BOOKIE_GROUPS, isolationGroups);
- isolationPolicy.initialize(bkClientConf, Optional.empty(), timer, SettableFeatureProvider.DISABLE_ALL, NullStatsLogger.INSTANCE, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
+ isolationPolicy.initialize(bkClientConf, Optional.empty(), timer, SettableFeatureProvider.DISABLE_ALL,
+ NullStatsLogger.INSTANCE, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
isolationPolicy.onClusterChanged(writableBookies, readOnlyBookies);
MutablePair<Set<String>, Set<String>> groups = new MutablePair<>();
@@ -250,19 +253,23 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
ClientConfiguration bkClientConf = new ClientConfiguration();
bkClientConf.setProperty(BookieRackAffinityMapping.METADATA_STORE_INSTANCE, store);
bkClientConf.setProperty(IsolatedBookieEnsemblePlacementPolicy.ISOLATION_BOOKIE_GROUPS, isolationGroups);
- isolationPolicy.initialize(bkClientConf, Optional.empty(), timer, SettableFeatureProvider.DISABLE_ALL, NullStatsLogger.INSTANCE, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
+ isolationPolicy.initialize(bkClientConf, Optional.empty(), timer, SettableFeatureProvider.DISABLE_ALL,
+ NullStatsLogger.INSTANCE, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
isolationPolicy.onClusterChanged(writableBookies, readOnlyBookies);
- List<BookieId> ensemble = isolationPolicy.newEnsemble(3, 3, 2, Collections.emptyMap(), new HashSet<>()).getResult();
+ List<BookieId> ensemble = isolationPolicy.newEnsemble(3, 3, 2,
+ Collections.emptyMap(), new HashSet<>()).getResult();
assertTrue(ensemble.contains(new BookieSocketAddress(BOOKIE1).toBookieId()));
assertTrue(ensemble.contains(new BookieSocketAddress(BOOKIE2).toBookieId()));
assertTrue(ensemble.contains(new BookieSocketAddress(BOOKIE4).toBookieId()));
- ensemble = isolationPolicy.newEnsemble(1, 1, 1, Collections.emptyMap(), new HashSet<>()).getResult();
+ ensemble = isolationPolicy.newEnsemble(1, 1, 1,
+ Collections.emptyMap(), new HashSet<>()).getResult();
assertFalse(ensemble.contains(new BookieSocketAddress(BOOKIE3).toBookieId()));
try {
- isolationPolicy.newEnsemble(4, 4, 4, Collections.emptyMap(), new HashSet<>());
+ isolationPolicy.newEnsemble(4, 4, 4, Collections.emptyMap(),
+ new HashSet<>());
fail("should not pass");
} catch (BKNotEnoughBookiesException e) {
// ok
@@ -271,7 +278,8 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
Set<BookieId> bookieToExclude = new HashSet<>();
bookieToExclude.add(new BookieSocketAddress(BOOKIE1).toBookieId());
try {
- isolationPolicy.newEnsemble(2, 2, 2, Collections.emptyMap(), bookieToExclude).getResult();
+ isolationPolicy.newEnsemble(2, 2, 2, Collections.emptyMap(),
+ bookieToExclude).getResult();
} catch (BKNotEnoughBookiesException e) {
Assert.assertEquals(e.getMessage(), "Not enough non-faulty bookies available");
}
@@ -283,13 +291,15 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
store.put(BookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, jsonMapper.writeValueAsBytes(bookieMapping),
Optional.empty()).join();
- ensemble = isolationPolicy.newEnsemble(2, 2, 2, Collections.emptyMap(), null).getResult();
+ ensemble = isolationPolicy.newEnsemble(2, 2, 2, Collections.emptyMap(),
+ null).getResult();
assertTrue(ensemble.contains(new BookieSocketAddress(BOOKIE1).toBookieId()));
assertTrue(ensemble.contains(new BookieSocketAddress(BOOKIE2).toBookieId()));
try {
- isolationPolicy.newEnsemble(3, 3, 3, Collections.emptyMap(), new HashSet<>());
+ isolationPolicy.newEnsemble(3, 3, 3, Collections.emptyMap(),
+ new HashSet<>());
fail("should not pass");
} catch (BKNotEnoughBookiesException e) {
// ok
@@ -305,7 +315,8 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
bookieToExclude = new HashSet<>();
bookieToExclude.add(new BookieSocketAddress(BOOKIE1).toBookieId());
- ensemble = isolationPolicy.newEnsemble(1, 1, 1, Collections.emptyMap(), bookieToExclude).getResult();
+ ensemble = isolationPolicy.newEnsemble(1, 1, 1, Collections.emptyMap(),
+ bookieToExclude).getResult();
BookieId chosenBookie = isolationPolicy.replaceBookie(1, 1, 1, Collections.emptyMap(),
ensemble, ensemble.get(0), new HashSet<>()).getResult();
assertEquals(new BookieSocketAddress(BOOKIE1).toBookieId(), chosenBookie);
@@ -317,7 +328,8 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
ClientConfiguration bkClientConf = new ClientConfiguration();
bkClientConf.setProperty(BookieRackAffinityMapping.METADATA_STORE_INSTANCE, store);
bkClientConf.setProperty(IsolatedBookieEnsemblePlacementPolicy.ISOLATION_BOOKIE_GROUPS, isolationGroups);
- isolationPolicy.initialize(bkClientConf, Optional.empty(), timer, SettableFeatureProvider.DISABLE_ALL, NullStatsLogger.INSTANCE, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
+ isolationPolicy.initialize(bkClientConf, Optional.empty(), timer, SettableFeatureProvider.DISABLE_ALL,
+ NullStatsLogger.INSTANCE, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
isolationPolicy.onClusterChanged(writableBookies, readOnlyBookies);
isolationPolicy.newEnsemble(4, 4, 4, Collections.emptyMap(), new HashSet<>());
@@ -331,12 +343,14 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
store.put(BookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, data.getBytes(StandardCharsets.UTF_8),
Optional.empty()).join();
- List<BookieId> ensemble = isolationPolicy.newEnsemble(2, 2, 2, Collections.emptyMap(), new HashSet<>()).getResult();
+ List<BookieId> ensemble = isolationPolicy.newEnsemble(2, 2, 2, Collections.emptyMap(),
+ new HashSet<>()).getResult();
assertTrue(ensemble.contains(new BookieSocketAddress(BOOKIE1).toBookieId()));
assertTrue(ensemble.contains(new BookieSocketAddress(BOOKIE2).toBookieId()));
try {
- isolationPolicy.newEnsemble(3, 3, 3, Collections.emptyMap(), new HashSet<>());
+ isolationPolicy.newEnsemble(3, 3, 3, Collections.emptyMap(),
+ new HashSet<>());
fail("should not pass");
} catch (BKNotEnoughBookiesException e) {
// ok
@@ -364,10 +378,12 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
ClientConfiguration bkClientConf = new ClientConfiguration();
bkClientConf.setProperty(IsolatedBookieEnsemblePlacementPolicy.ISOLATION_BOOKIE_GROUPS, isolationGroups);
bkClientConf.setProperty(BookieRackAffinityMapping.METADATA_STORE_INSTANCE, store);
- isolationPolicy.initialize(bkClientConf, Optional.empty(), timer, SettableFeatureProvider.DISABLE_ALL, NullStatsLogger.INSTANCE, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
+ isolationPolicy.initialize(bkClientConf, Optional.empty(), timer, SettableFeatureProvider.DISABLE_ALL,
+ NullStatsLogger.INSTANCE, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
isolationPolicy.onClusterChanged(writableBookies, readOnlyBookies);
- List<BookieId> ensemble = isolationPolicy.newEnsemble(2, 2, 2, Collections.emptyMap(), new HashSet<>()).getResult();
+ List<BookieId> ensemble = isolationPolicy.newEnsemble(2, 2, 2,
+ Collections.emptyMap(), new HashSet<>()).getResult();
assertTrue(ensemble.contains(new BookieSocketAddress(BOOKIE1).toBookieId()));
assertTrue(ensemble.contains(new BookieSocketAddress(BOOKIE2).toBookieId()));
@@ -386,7 +402,8 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
store.put(BookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, jsonMapper.writeValueAsBytes(bookieMapping),
Optional.empty()).join();
- ensemble = isolationPolicy.newEnsemble(3, 3, 3, Collections.emptyMap(), new HashSet<>()).getResult();
+ ensemble = isolationPolicy.newEnsemble(3, 3, 3, Collections.emptyMap(),
+ new HashSet<>()).getResult();
assertTrue(ensemble.contains(new BookieSocketAddress(BOOKIE1).toBookieId()));
assertTrue(ensemble.contains(new BookieSocketAddress(BOOKIE2).toBookieId()));
assertTrue(ensemble.contains(new BookieSocketAddress(BOOKIE3).toBookieId()));
@@ -418,7 +435,8 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
BookieId bookie2Id = new BookieSocketAddress(BOOKIE2).toBookieId();
BookieId bookie3Id = new BookieSocketAddress(BOOKIE3).toBookieId();
BookieId bookie4Id = new BookieSocketAddress(BOOKIE4).toBookieId();
- // when we set strictBookieAffinityEnabled=true and some namespace not set ISOLATION_BOOKIE_GROUPS there will set "" by default.
+ // when we set strictBookieAffinityEnabled=true and
+ // some namespace not set ISOLATION_BOOKIE_GROUPS there will set "" by default.
Map<String, Object> placementPolicyProperties1 = new HashMap<>();
placementPolicyProperties1.put(
IsolatedBookieEnsemblePlacementPolicy.ISOLATION_BOOKIE_GROUPS, "");
@@ -432,7 +450,7 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
customMetadata1.put(EnsemblePlacementPolicyConfig.ENSEMBLE_PLACEMENT_POLICY_CONFIG, policyConfig.encode());
BookieId replaceBookie1 = isolationPolicy.replaceBookie(3, 3, 3, customMetadata1,
- Arrays.asList(bookie1Id,bookie2Id,bookie3Id), bookie3Id, null).getResult();
+ Arrays.asList(bookie1Id, bookie2Id, bookie3Id), bookie3Id, null).getResult();
assertEquals(replaceBookie1, bookie4Id);
// when ISOLATION_BOOKIE_GROUPS miss.
@@ -444,7 +462,7 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
Map<String, byte[]> customMetadata2 = new HashMap<>();
customMetadata2.put(EnsemblePlacementPolicyConfig.ENSEMBLE_PLACEMENT_POLICY_CONFIG, policyConfig2.encode());
BookieId replaceBookie2 = isolationPolicy.replaceBookie(3, 3, 3, customMetadata2,
- Arrays.asList(bookie1Id,bookie2Id,bookie3Id), bookie3Id, null).getResult();
+ Arrays.asList(bookie1Id, bookie2Id, bookie3Id), bookie3Id, null).getResult();
assertEquals(replaceBookie2, bookie4Id);
}
@@ -528,7 +546,8 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
ClientConfiguration bkClientConf = new ClientConfiguration();
bkClientConf.setProperty(BookieRackAffinityMapping.METADATA_STORE_INSTANCE, store);
bkClientConf.setProperty(IsolatedBookieEnsemblePlacementPolicy.ISOLATION_BOOKIE_GROUPS, isolatedGroup);
- bkClientConf.setProperty(IsolatedBookieEnsemblePlacementPolicy.SECONDARY_ISOLATION_BOOKIE_GROUPS, secondaryIsolatedGroup);
+ bkClientConf.setProperty(IsolatedBookieEnsemblePlacementPolicy.SECONDARY_ISOLATION_BOOKIE_GROUPS,
+ secondaryIsolatedGroup);
isolationPolicy.initialize(bkClientConf, Optional.empty(), timer, SettableFeatureProvider.DISABLE_ALL,
NullStatsLogger.INSTANCE, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
isolationPolicy.onClusterChanged(writableBookies, readOnlyBookies);
@@ -649,23 +668,23 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
final String defaultSecondaryIsolatedGroup = "Group2";
final String customIsolatedGroup = "Group2";
- Map<String, BookieInfo> Group1 = new HashMap<>();
- Group1.put(BOOKIE1, BookieInfo.builder().rack("rack0").build());
- Group1.put(BOOKIE2, BookieInfo.builder().rack("rack0").build());
+ Map<String, BookieInfo> group1 = new HashMap<>();
+ group1.put(BOOKIE1, BookieInfo.builder().rack("rack0").build());
+ group1.put(BOOKIE2, BookieInfo.builder().rack("rack0").build());
- Map<String, BookieInfo> Group2 = new HashMap<>();
- Group2.put(BOOKIE3, BookieInfo.builder().rack("rack1").build());
- Group2.put(BOOKIE4, BookieInfo.builder().rack("rack1").build());
+ Map<String, BookieInfo> group2 = new HashMap<>();
+ group2.put(BOOKIE3, BookieInfo.builder().rack("rack1").build());
+ group2.put(BOOKIE4, BookieInfo.builder().rack("rack1").build());
- Set<BookieId> BookieIdGroup1 = new HashSet<>();
- BookieIdGroup1.add(new BookieSocketAddress(BOOKIE1).toBookieId());
- BookieIdGroup1.add(new BookieSocketAddress(BOOKIE2).toBookieId());
- Set<BookieId> BookieIdGroup2 = new HashSet<>();
- BookieIdGroup2.add(new BookieSocketAddress(BOOKIE3).toBookieId());
- BookieIdGroup2.add(new BookieSocketAddress(BOOKIE4).toBookieId());
+ Set<BookieId> bookieIdGroup1 = new HashSet<>();
+ bookieIdGroup1.add(new BookieSocketAddress(BOOKIE1).toBookieId());
+ bookieIdGroup1.add(new BookieSocketAddress(BOOKIE2).toBookieId());
+ Set<BookieId> bookieIdGroup2 = new HashSet<>();
+ bookieIdGroup2.add(new BookieSocketAddress(BOOKIE3).toBookieId());
+ bookieIdGroup2.add(new BookieSocketAddress(BOOKIE4).toBookieId());
- bookieMapping.put(defaultIsolatedGroup, Group1);
- bookieMapping.put(defaultSecondaryIsolatedGroup, Group2);
+ bookieMapping.put(defaultIsolatedGroup, group1);
+ bookieMapping.put(defaultSecondaryIsolatedGroup, group2);
store.put(BookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, jsonMapper.writeValueAsBytes(bookieMapping),
Optional.empty()).join();
@@ -674,7 +693,8 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
ClientConfiguration bkClientConf = new ClientConfiguration();
bkClientConf.setProperty(BookieRackAffinityMapping.METADATA_STORE_INSTANCE, store);
bkClientConf.setProperty(IsolatedBookieEnsemblePlacementPolicy.ISOLATION_BOOKIE_GROUPS, defaultIsolatedGroup);
- bkClientConf.setProperty(IsolatedBookieEnsemblePlacementPolicy.SECONDARY_ISOLATION_BOOKIE_GROUPS, defaultSecondaryIsolatedGroup);
+ bkClientConf.setProperty(IsolatedBookieEnsemblePlacementPolicy.SECONDARY_ISOLATION_BOOKIE_GROUPS,
+ defaultSecondaryIsolatedGroup);
isolationPolicy.initialize(bkClientConf, Optional.empty(), timer, SettableFeatureProvider.DISABLE_ALL,
NullStatsLogger.INSTANCE, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
isolationPolicy.onClusterChanged(writableBookies, readOnlyBookies);
@@ -694,10 +714,10 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
List<BookieId> customBookieList = isolationPolicy
.newEnsemble(2, 2, 2, customMetadata, new HashSet<>()).getResult();
- assertEquals(BookieIdGroup2.containsAll(customBookieList),true);
+ assertEquals(bookieIdGroup2.containsAll(customBookieList), true);
List<BookieId> defaultBookieList = isolationPolicy
.newEnsemble(2, 2, 2, Collections.emptyMap(), new HashSet<>()).getResult();
- assertEquals(BookieIdGroup1.containsAll(defaultBookieList),true);
+ assertEquals(bookieIdGroup1.containsAll(defaultBookieList), true);
}
@Test
@@ -725,7 +745,8 @@ public class IsolatedBookieEnsemblePlacementPolicyTest {
ClientConfiguration bkClientConf = new ClientConfiguration();
bkClientConf.setProperty(BookieRackAffinityMapping.METADATA_STORE_INSTANCE, store);
bkClientConf.setProperty(IsolatedBookieEnsemblePlacementPolicy.ISOLATION_BOOKIE_GROUPS, isolationGroup1);
- bkClientConf.setProperty(IsolatedBookieEnsemblePlacementPolicy.SECONDARY_ISOLATION_BOOKIE_GROUPS, isolationGroup2);
+ bkClientConf.setProperty(IsolatedBookieEnsemblePlacementPolicy.SECONDARY_ISOLATION_BOOKIE_GROUPS,
+ isolationGroup2);
isolationPolicy.initialize(bkClientConf, Optional.empty(), timer, SettableFeatureProvider.DISABLE_ALL,
NullStatsLogger.INSTANCE, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER);
isolationPolicy.onClusterChanged(writableBookies, readOnlyBookies);
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/BitRateUnitTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/BitRateUnitTest.java
index 60f009a27ca..19e49c10aac 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/BitRateUnitTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/BitRateUnitTest.java
@@ -56,7 +56,7 @@ public class BitRateUnitTest {
@Test
public void testGbps() {
double gbps = 1231434.12;
- assertEquals(BitRateUnit.Gigabit.toBit(gbps),gbps * 1000 * 1000 * 1000 );
+ assertEquals(BitRateUnit.Gigabit.toBit(gbps), gbps * 1000 * 1000 * 1000);
assertEquals(BitRateUnit.Gigabit.toByte(gbps), gbps * 1000 * 1000 * 1000 / 8);
assertEquals(BitRateUnit.Gigabit.toKilobit(gbps), gbps * 1000 * 1000);
assertEquals(BitRateUnit.Gigabit.toMegabit(gbps), gbps * 1000);
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderBasicTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderBasicTest.java
index f6e4b8e969a..d3b996295b5 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderBasicTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderBasicTest.java
@@ -34,7 +34,8 @@ import org.testng.annotations.Test;
public class AuthenticationProviderBasicTest {
private final String basicAuthConf = Resources.getResource("authentication/basic/.htpasswd").getPath();
- private final String basicAuthConfBase64 = Base64.getEncoder().encodeToString(Files.readAllBytes(Path.of(basicAuthConf)));
+ private final String basicAuthConfBase64 =
+ Base64.getEncoder().encodeToString(Files.readAllBytes(Path.of(basicAuthConf)));
public AuthenticationProviderBasicTest() throws IOException {
}
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderTokenTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderTokenTest.java
index 3e1a3e18034..8e1aa54522d 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderTokenTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderTokenTest.java
@@ -109,13 +109,14 @@ public class AuthenticationProviderTokenTest {
String privateKey = AuthTokenUtils.encodeKeyBase64(keyPair.getPrivate());
String publicKey = AuthTokenUtils.encodeKeyBase64(keyPair.getPublic());
- String token = AuthTokenUtils.createToken(AuthTokenUtils.decodePrivateKey(Decoders.BASE64.decode(privateKey), SignatureAlgorithm.RS256),
+ String token = AuthTokenUtils.createToken(
+ AuthTokenUtils.decodePrivateKey(Decoders.BASE64.decode(privateKey), SignatureAlgorithm.RS256),
SUBJECT,
Optional.empty());
@SuppressWarnings("unchecked")
- Jwt<?, Claims> jwt = Jwts.parserBuilder()
- .setSigningKey(AuthTokenUtils.decodePublicKey(Decoders.BASE64.decode(publicKey), SignatureAlgorithm.RS256))
+ Jwt<?, Claims> jwt = Jwts.parserBuilder().setSigningKey(
+ AuthTokenUtils.decodePublicKey(Decoders.BASE64.decode(publicKey), SignatureAlgorithm.RS256))
.build()
.parse(token);
@@ -375,7 +376,8 @@ public class AuthenticationProviderTokenTest {
provider.initialize(AuthenticationProvider.Context.builder().config(conf).build());
// Use private key to generate token
- PrivateKey privateKey = AuthTokenUtils.decodePrivateKey(Decoders.BASE64.decode(privateKeyStr), SignatureAlgorithm.RS256);
+ PrivateKey privateKey =
+ AuthTokenUtils.decodePrivateKey(Decoders.BASE64.decode(privateKeyStr), SignatureAlgorithm.RS256);
String token = AuthTokenUtils.createToken(privateKey, SUBJECT, Optional.empty());
// Pulsar protocol auth
@@ -418,7 +420,8 @@ public class AuthenticationProviderTokenTest {
provider.initialize(AuthenticationProvider.Context.builder().config(conf).build());
// Use private key to generate token
- PrivateKey privateKey = AuthTokenUtils.decodePrivateKey(Decoders.BASE64.decode(privateKeyStr), SignatureAlgorithm.RS256);
+ PrivateKey privateKey =
+ AuthTokenUtils.decodePrivateKey(Decoders.BASE64.decode(privateKeyStr), SignatureAlgorithm.RS256);
String token = Jwts.builder()
.setClaims(new HashMap<String, Object>() {{
put(authRoleClaim, authRole);
@@ -464,7 +467,8 @@ public class AuthenticationProviderTokenTest {
provider.initialize(AuthenticationProvider.Context.builder().config(conf).build());
// Use private key to generate token
- PrivateKey privateKey = AuthTokenUtils.decodePrivateKey(Decoders.BASE64.decode(privateKeyStr), SignatureAlgorithm.ES256);
+ PrivateKey privateKey =
+ AuthTokenUtils.decodePrivateKey(Decoders.BASE64.decode(privateKeyStr), SignatureAlgorithm.ES256);
String token = AuthTokenUtils.createToken(privateKey, SUBJECT, Optional.empty());
// Pulsar protocol auth
@@ -731,7 +735,7 @@ public class AuthenticationProviderTokenTest {
AuthData expiredAuthData = AuthData.of(expiringToken.getBytes());
// It is important that this call doesn't fail because we no longer authenticate the auth data at construction
- AuthenticationState authState = provider.newAuthState(expiredAuthData,null, null);
+ AuthenticationState authState = provider.newAuthState(expiredAuthData, null, null);
// The call to authenticate the token is the call that fails
assertThrows(AuthenticationException.class, () -> authState.authenticate(expiredAuthData));
}
@@ -844,7 +848,8 @@ public class AuthenticationProviderTokenTest {
provider.initialize(AuthenticationProvider.Context.builder().config(conf).build());
// Use private key to generate token
- PrivateKey privateKey = AuthTokenUtils.decodePrivateKey(Decoders.BASE64.decode(privateKeyStr), SignatureAlgorithm.RS256);
+ PrivateKey privateKey =
+ AuthTokenUtils.decodePrivateKey(Decoders.BASE64.decode(privateKeyStr), SignatureAlgorithm.RS256);
String token = Jwts.builder()
.setClaims(new HashMap<String, Object>() {{
put(authRoleClaim, Arrays.asList(authRole, "other-role"));
@@ -975,7 +980,7 @@ public class AuthenticationProviderTokenTest {
conf.setProperties(properties);
provider.initialize(AuthenticationProvider.Context.builder().config(conf).build());
- AuthenticationState authState = provider.newAuthState(null,null, null);
+ AuthenticationState authState = provider.newAuthState(null, null, null);
// Haven't authenticated yet, so cannot get role when using constructor with no auth data
assertThrows(AuthenticationException.class, authState::getAuthRole);
@@ -1017,7 +1022,7 @@ public class AuthenticationProviderTokenTest {
}
private static void testTokenAudienceWithDifferentConfig(Properties properties,
- String audienceClaim, List<String> audiences) throws Exception {
+ String audienceClaim, List<String> audiences) throws Exception {
@Cleanup
AuthenticationProviderToken provider = new AuthenticationProviderToken();
SecretKey secretKey = AuthTokenUtils.createSecretKey(SignatureAlgorithm.HS256);
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/OneStageAuthenticationStateTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/OneStageAuthenticationStateTest.java
index b394b3ee0c4..128c6020c53 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/OneStageAuthenticationStateTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/OneStageAuthenticationStateTest.java
@@ -28,14 +28,14 @@ import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertThrows;
import static org.testng.Assert.assertTrue;
-import org.apache.pulsar.broker.ServiceConfiguration;
-import org.apache.pulsar.common.api.AuthData;
-import org.testng.annotations.Test;
-import javax.naming.AuthenticationException;
-import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.LongAdder;
+import javax.naming.AuthenticationException;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.common.api.AuthData;
+import org.testng.annotations.Test;
public class OneStageAuthenticationStateTest {
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authorization/MockAuthorizationProvider.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authorization/MockAuthorizationProvider.java
index 4c939cbd972..9f9cd92cd0a 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authorization/MockAuthorizationProvider.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authorization/MockAuthorizationProvider.java
@@ -49,7 +49,7 @@ public class MockAuthorizationProvider implements AuthorizationProvider {
@Override
public CompletableFuture<Boolean> canConsumeAsync(TopicName topicName, String role,
- AuthenticationDataSource authenticationData, String subscription) {
+ AuthenticationDataSource authenticationData, String subscription) {
return shouldPass(role);
}
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authorization/MultiRolesTokenAuthorizationProviderTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authorization/MultiRolesTokenAuthorizationProviderTest.java
index ed9626dffe2..e6818dca4c0 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authorization/MultiRolesTokenAuthorizationProviderTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authorization/MultiRolesTokenAuthorizationProviderTest.java
@@ -24,7 +24,10 @@ import static org.testng.Assert.assertTrue;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
+import javax.crypto.SecretKey;
import lombok.Cleanup;
import org.apache.pulsar.broker.ServiceConfiguration;
import org.apache.pulsar.broker.authentication.AuthenticationDataSource;
@@ -32,9 +35,6 @@ import org.apache.pulsar.broker.authentication.AuthenticationDataSubscription;
import org.apache.pulsar.broker.authentication.utils.AuthTokenUtils;
import org.apache.pulsar.broker.resources.PulsarResources;
import org.testng.annotations.Test;
-import javax.crypto.SecretKey;
-import java.util.Set;
-import java.util.concurrent.CompletableFuture;
public class MultiRolesTokenAuthorizationProviderTest {
@@ -193,7 +193,8 @@ public class MultiRolesTokenAuthorizationProviderTest {
};
assertTrue(provider.authorize("test-role", null, authorizeFunc).get());
assertFalse(provider.authorize("test-role-x", null, authorizeFunc).get());
- assertTrue(provider.authorize("test-role", new AuthenticationDataSubscription(null, "test-sub"), authorizeFunc).get());
+ assertTrue(provider.authorize("test-role",
+ new AuthenticationDataSubscription(null, "test-sub"), authorizeFunc).get());
}
@Test
@@ -298,7 +299,8 @@ public class MultiRolesTokenAuthorizationProviderTest {
}
return CompletableFuture.completedFuture(false);
};
- assertTrue(provider.authorize(testAdminRole, ads, (String role) -> CompletableFuture.completedFuture(false)).get());
+ assertTrue(provider.authorize(testAdminRole, ads,
+ (String role) -> CompletableFuture.completedFuture(false)).get());
assertTrue(provider.authorize("admin1", null, authorizeFunc).get());
assertFalse(provider.authorize("admin2", null, authorizeFunc).get());
}
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/LoadBalanceResourcesTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/LoadBalanceResourcesTest.java
index cd7dd01b665..9889ca939be 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/LoadBalanceResourcesTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/LoadBalanceResourcesTest.java
@@ -49,7 +49,7 @@ public class LoadBalanceResourcesTest {
String namespaceBundlePath = joinPath(BUNDLE_DATA_BASE_PATH, ns.toString());
loadBalanceResources.getBundleDataResources().deleteBundleDataAsync(ns);
- String tenant="my-tenant";
+ String tenant = "my-tenant";
String tenantBundlePath = joinPath(BUNDLE_DATA_BASE_PATH, tenant);
loadBalanceResources.getBundleDataResources().deleteBundleDataTenantAsync(tenant);
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/TopicResourcesTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/TopicResourcesTest.java
index 9a0fe5b9fce..6db6b145cc7 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/TopicResourcesTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/TopicResourcesTest.java
@@ -18,18 +18,18 @@
*/
package org.apache.pulsar.broker.resources;
-import org.apache.pulsar.common.naming.NamespaceName;
-import org.apache.pulsar.metadata.api.MetadataStore;
-import org.apache.pulsar.metadata.api.Notification;
-import org.apache.pulsar.metadata.api.NotificationType;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.function.BiConsumer;
+import org.apache.pulsar.common.naming.NamespaceName;
+import org.apache.pulsar.metadata.api.MetadataStore;
+import org.apache.pulsar.metadata.api.Notification;
+import org.apache.pulsar.metadata.api.NotificationType;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
public class TopicResourcesTest {
@@ -51,7 +51,8 @@ public class TopicResourcesTest {
public void testListenerInvokedWhenTopicCreated() {
BiConsumer<String, NotificationType> listener = mock(BiConsumer.class);
topicResources.registerPersistentTopicListener(NamespaceName.get("tenant/namespace"), listener);
- topicResources.handleNotification(new Notification(NotificationType.Created, "/managed-ledgers/tenant/namespace/persistent/topic"));
+ topicResources.handleNotification(new Notification(NotificationType.Created,
+ "/managed-ledgers/tenant/namespace/persistent/topic"));
verify(listener).accept("persistent://tenant/namespace/topic", NotificationType.Created);
}
@@ -59,7 +60,8 @@ public class TopicResourcesTest {
public void testListenerInvokedWhenTopicV1Created() {
BiConsumer<String, NotificationType> listener = mock(BiConsumer.class);
topicResources.registerPersistentTopicListener(NamespaceName.get("tenant/cluster/namespace"), listener);
- topicResources.handleNotification(new Notification(NotificationType.Created, "/managed-ledgers/tenant/cluster/namespace/persistent/topic"));
+ topicResources.handleNotification(new Notification(NotificationType.Created,
+ "/managed-ledgers/tenant/cluster/namespace/persistent/topic"));
verify(listener).accept("persistent://tenant/cluster/namespace/topic", NotificationType.Created);
}
@@ -67,7 +69,8 @@ public class TopicResourcesTest {
public void testListenerInvokedWhenTopicDeleted() {
BiConsumer<String, NotificationType> listener = mock(BiConsumer.class);
topicResources.registerPersistentTopicListener(NamespaceName.get("tenant/namespace"), listener);
- topicResources.handleNotification(new Notification(NotificationType.Deleted, "/managed-ledgers/tenant/namespace/persistent/topic"));
+ topicResources.handleNotification(new Notification(NotificationType.Deleted,
+ "/managed-ledgers/tenant/namespace/persistent/topic"));
verify(listener).accept("persistent://tenant/namespace/topic", NotificationType.Deleted);
}
@@ -75,7 +78,8 @@ public class TopicResourcesTest {
public void testListenerNotInvokedWhenSubscriptionCreated() {
BiConsumer<String, NotificationType> listener = mock(BiConsumer.class);
topicResources.registerPersistentTopicListener(NamespaceName.get("tenant/namespace"), listener);
- topicResources.handleNotification(new Notification(NotificationType.Created, "/managed-ledgers/tenant/namespace/persistent/topic/subscription"));
+ topicResources.handleNotification(new Notification(NotificationType.Created,
+ "/managed-ledgers/tenant/namespace/persistent/topic/subscription"));
verifyNoInteractions(listener);
}
@@ -83,7 +87,8 @@ public class TopicResourcesTest {
public void testListenerNotInvokedWhenTopicCreatedInOtherNamespace() {
BiConsumer<String, NotificationType> listener = mock(BiConsumer.class);
topicResources.registerPersistentTopicListener(NamespaceName.get("tenant/namespace"), listener);
- topicResources.handleNotification(new Notification(NotificationType.Created, "/managed-ledgers/tenant/namespace2/persistent/topic"));
+ topicResources.handleNotification(new Notification(NotificationType.Created,
+ "/managed-ledgers/tenant/namespace2/persistent/topic"));
verifyNoInteractions(listener);
}
@@ -91,7 +96,8 @@ public class TopicResourcesTest {
public void testListenerNotInvokedWhenTopicModified() {
BiConsumer<String, NotificationType> listener = mock(BiConsumer.class);
topicResources.registerPersistentTopicListener(NamespaceName.get("tenant/namespace"), listener);
- topicResources.handleNotification(new Notification(NotificationType.Modified, "/managed-ledgers/tenant/namespace/persistent/topic"));
+ topicResources.handleNotification(new Notification(NotificationType.Modified,
+ "/managed-ledgers/tenant/namespace/persistent/topic"));
verifyNoInteractions(listener);
}
@@ -99,10 +105,12 @@ public class TopicResourcesTest {
public void testListenerNotInvokedAfterDeregistered() {
BiConsumer<String, NotificationType> listener = mock(BiConsumer.class);
topicResources.registerPersistentTopicListener(NamespaceName.get("tenant/namespace"), listener);
- topicResources.handleNotification(new Notification(NotificationType.Created, "/managed-ledgers/tenant/namespace/persistent/topic"));
+ topicResources.handleNotification(new Notification(NotificationType.Created,
+ "/managed-ledgers/tenant/namespace/persistent/topic"));
verify(listener).accept("persistent://tenant/namespace/topic", NotificationType.Created);
topicResources.deregisterPersistentTopicListener(listener);
- topicResources.handleNotification(new Notification(NotificationType.Created, "/managed-ledgers/tenant/namespace/persistent/topic2"));
+ topicResources.handleNotification(new Notification(NotificationType.Created,
+ "/managed-ledgers/tenant/namespace/persistent/topic2"));
verifyNoMoreInteractions(listener);
}
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsClient.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsClient.java
index 6d724c289b5..cf6d63e96ce 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsClient.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsClient.java
@@ -144,8 +144,8 @@ public class PrometheusMetricsClient {
public final Metric findSingleMetricByNameAndLabels(String metricName, Pair<String, String>... nameValuePairs) {
List<Metric> metricByNameAndLabels = findByNameAndLabels(metricName, nameValuePairs);
if (metricByNameAndLabels.size() != 1) {
- fail("Expected to find 1 metric, but found the following: "+metricByNameAndLabels +
- ". Metrics are = "+nameToDataPoints.get(metricName)+". Labels requested = "+ Arrays.toString(
+ fail("Expected to find 1 metric, but found the following: " + metricByNameAndLabels
+ + ". Metrics are = " + nameToDataPoints.get(metricName) + ". Labels requested = " + Arrays.toString(
nameValuePairs));
}
return metricByNameAndLabels.get(0);
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorUtilsTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorUtilsTest.java
index 0ac3e221976..4c4a862d4fe 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorUtilsTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorUtilsTest.java
@@ -18,7 +18,7 @@
*/
package org.apache.pulsar.broker.stats.prometheus;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertTrue;
import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.Counter;
import java.io.ByteArrayOutputStream;
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/BindAddressValidatorTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/BindAddressValidatorTest.java
index 2e354acbdc8..a1af57b633c 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/BindAddressValidatorTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/BindAddressValidatorTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.pulsar.broker.validator;
+import static org.testng.AssertJUnit.assertEquals;
import java.net.URI;
import java.util.Arrays;
import java.util.Collections;
@@ -27,8 +28,6 @@ import org.apache.pulsar.broker.ServiceConfiguration;
import org.apache.pulsar.common.configuration.BindAddress;
import org.testng.annotations.Test;
-import static org.testng.AssertJUnit.assertEquals;
-
/**
* testcase for BindAddressValidator.
*/
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/MultipleListenerValidatorTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/MultipleListenerValidatorTest.java
index 5f5c536c93c..7e79a40355f 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/MultipleListenerValidatorTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/MultipleListenerValidatorTest.java
@@ -18,15 +18,13 @@
*/
package org.apache.pulsar.broker.validator;
+import static org.testng.AssertJUnit.assertEquals;
import java.net.InetAddress;
+import java.util.Optional;
import org.apache.pulsar.broker.ServiceConfiguration;
import org.apache.pulsar.broker.ServiceConfigurationUtils;
import org.testng.annotations.Test;
-import java.util.Optional;
-
-import static org.testng.AssertJUnit.assertEquals;
-
/**
* testcase for MultipleListenerValidator.
*/
@@ -95,7 +93,8 @@ public class MultipleListenerValidatorTest {
@Test(expectedExceptions = IllegalArgumentException.class)
public void testListenerDuplicate_3() {
ServiceConfiguration config = new ServiceConfiguration();
- config.setAdvertisedListeners(" internal:pulsar+ssl://127.0.0.1:6661," + " internal:pulsar+ssl://192.168.1.11:6661");
+ config.setAdvertisedListeners(" internal:pulsar+ssl://127.0.0.1:6661,"
+ + " internal:pulsar+ssl://192.168.1.11:6661");
config.setInternalListenerName("internal");
MultipleListenerValidator.validateAndAnalysisAdvertisedListener(config);
}
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/GzipHandlerUtilTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/GzipHandlerUtilTest.java
index d6958695dec..233be88ac83 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/GzipHandlerUtilTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/GzipHandlerUtilTest.java
@@ -18,7 +18,8 @@
*/
package org.apache.pulsar.broker.web;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
import java.util.Arrays;
import org.testng.annotations.Test;
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletUtilsTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletUtilsTest.java
index 6cfab9d560c..1d3dd9a7ba4 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletUtilsTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletUtilsTest.java
@@ -18,6 +18,12 @@
*/
package org.apache.pulsar.broker.web.plugin.servlet;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.RETURNS_SELF;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.AssertJUnit.assertSame;
+import static org.testng.AssertJUnit.assertTrue;
import java.io.IOException;
import java.nio.file.Paths;
import org.apache.pulsar.common.nar.NarClassLoader;
@@ -27,13 +33,6 @@ import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.testng.annotations.Test;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.RETURNS_SELF;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.testng.AssertJUnit.assertSame;
-import static org.testng.AssertJUnit.assertTrue;
-
public class AdditionalServletUtilsTest {
@Test
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletWithClassLoaderTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletWithClassLoaderTest.java
index 2392b5e0528..2650ce87fdb 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletWithClassLoaderTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletWithClassLoaderTest.java
@@ -18,14 +18,13 @@
*/
package org.apache.pulsar.broker.web.plugin.servlet;
-import org.apache.pulsar.common.nar.NarClassLoader;
-import org.testng.annotations.Test;
-
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
+import org.apache.pulsar.common.nar.NarClassLoader;
+import org.testng.annotations.Test;
/**
* Unit test {@link AdditionalServletWithClassLoader}.
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletsTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletsTest.java
index dd5045b1b09..15373ab5fa5 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletsTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletsTest.java
@@ -20,14 +20,14 @@ package org.apache.pulsar.broker.web.plugin.servlet;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
+import java.io.IOException;
+import java.nio.file.Paths;
+import java.util.Properties;
import org.apache.pulsar.common.configuration.PulsarConfiguration;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.testng.Assert;
import org.testng.annotations.Test;
-import java.io.IOException;
-import java.nio.file.Paths;
-import java.util.Properties;
public class AdditionalServletsTest {
@@ -72,7 +72,7 @@ public class AdditionalServletsTest {
as.setDefinition(new AdditionalServletDefinition());
as.getDefinition().setName("as" + index);
as.getDefinition().setAdditionalServletClass("com.example.AS" + index);
- as.getDefinition().setDescription("Additional Servlet " +index);
+ as.getDefinition().setDescription("Additional Servlet " + index);
return as;
}
}
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/MockAdditionalServlet.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/MockAdditionalServlet.java
index 22b8fa5ea35..65cc10e0d3b 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/MockAdditionalServlet.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/MockAdditionalServlet.java
@@ -19,7 +19,6 @@
package org.apache.pulsar.broker.web.plugin.servlet;
import org.apache.pulsar.common.configuration.PulsarConfiguration;
-import org.apache.pulsar.broker.web.plugin.servlet.AdditionalServlet;
import org.eclipse.jetty.servlet.ServletHolder;
public class MockAdditionalServlet implements AdditionalServlet {
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoaderTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoaderTest.java
index afbec583b4d..4cf84d7048d 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoaderTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoaderTest.java
@@ -24,7 +24,6 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertThrows;
import static org.testng.Assert.assertTrue;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -34,7 +33,6 @@ import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Optional;
import java.util.Properties;
-
import org.apache.bookkeeper.client.api.DigestType;
import org.apache.pulsar.broker.ServiceConfiguration;
import org.testng.annotations.Test;
@@ -52,7 +50,7 @@ public class PulsarConfigurationLoaderTest {
// This unused field is intentionally included to test the ignoreNonExistentMember feature of
// PulsarConfigurationLoader.convertFrom()
- private String A_FIELD_THAT_IS_NOT_DECLARED_IN_ServiceConfiguration = "x";
+ private static final String A_FIELD_THAT_IS_NOT_DECLARED_IN_ServiceConfiguration = "x";
@Override
public Properties getProperties() {
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryTest.java
index 019627f52cb..3a4664c9208 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryTest.java
@@ -37,14 +37,14 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.pulsar.common.util.DefaultPulsarSslFactory;
+import org.apache.pulsar.common.util.PulsarSslConfiguration;
+import org.apache.pulsar.common.util.PulsarSslFactory;
import org.apache.pulsar.common.util.SecurityUtility;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.testng.annotations.Test;
-import org.apache.pulsar.common.util.DefaultPulsarSslFactory;
-import org.apache.pulsar.common.util.PulsarSslConfiguration;
-import org.apache.pulsar.common.util.PulsarSslFactory;
@Slf4j
public class JettySslContextFactoryTest {
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryWithKeyStoreTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryWithKeyStoreTest.java
index 30fbc50257d..3020b8f8ed9 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryWithKeyStoreTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryWithKeyStoreTest.java
@@ -53,16 +53,16 @@ import org.testng.annotations.Test;
@Slf4j
public class JettySslContextFactoryWithKeyStoreTest {
- final static String brokerKeyStorePath =
+ static final String BROKEN_KEY_STORE_PATH =
Resources.getResource("certificate-authority/jks/broker.keystore.jks").getPath();
- final static String brokerTrustStorePath =
+ static final String BROKER_TRUST_STORE_PATH =
Resources.getResource("certificate-authority/jks/broker.truststore.jks").getPath();
- final static String clientKeyStorePath =
+ static final String CLIENT_KEY_STORE_PATH =
Resources.getResource("certificate-authority/jks/client.keystore.jks").getPath();
- final static String clientTrustStorePath =
+ static final String CLIENT_TRUST_STORE_PATH =
Resources.getResource("certificate-authority/jks/client.truststore.jks").getPath();
- final static String keyStoreType = "JKS";
- final static String keyStorePassword = "111111";
+ static final String KEY_STORE_TYPE = "JKS";
+ static final String KEY_STORE_PASSWORD = "111111";
@Test
public void testJettyTlsServerTls() throws Exception {
@@ -70,12 +70,12 @@ public class JettySslContextFactoryWithKeyStoreTest {
Server server = new Server();
List<ServerConnector> connectors = new ArrayList<>();
PulsarSslConfiguration sslConfiguration = PulsarSslConfiguration.builder()
- .tlsKeyStoreType(keyStoreType)
- .tlsKeyStorePath(brokerKeyStorePath)
- .tlsKeyStorePassword(keyStorePassword)
- .tlsTrustStoreType(keyStoreType)
- .tlsTrustStorePath(clientTrustStorePath)
- .tlsTrustStorePassword(keyStorePassword)
+ .tlsKeyStoreType(KEY_STORE_TYPE)
+ .tlsKeyStorePath(BROKEN_KEY_STORE_PATH)
+ .tlsKeyStorePassword(KEY_STORE_PASSWORD)
+ .tlsTrustStoreType(KEY_STORE_TYPE)
+ .tlsTrustStorePath(CLIENT_TRUST_STORE_PATH)
+ .tlsTrustStorePassword(KEY_STORE_PASSWORD)
.requireTrustedClientCertOnConnect(true)
.tlsEnabledWithKeystore(true)
.isHttps(true)
@@ -111,12 +111,12 @@ public class JettySslContextFactoryWithKeyStoreTest {
Server server = new Server();
List<ServerConnector> connectors = new ArrayList<>();
PulsarSslConfiguration sslConfiguration = PulsarSslConfiguration.builder()
- .tlsKeyStoreType(keyStoreType)
- .tlsKeyStorePath(brokerKeyStorePath)
- .tlsKeyStorePassword(keyStorePassword)
- .tlsTrustStoreType(keyStoreType)
- .tlsTrustStorePath(clientTrustStorePath)
- .tlsTrustStorePassword(keyStorePassword)
+ .tlsKeyStoreType(KEY_STORE_TYPE)
+ .tlsKeyStorePath(BROKEN_KEY_STORE_PATH)
+ .tlsKeyStorePassword(KEY_STORE_PASSWORD)
+ .tlsTrustStoreType(KEY_STORE_TYPE)
+ .tlsTrustStorePath(CLIENT_TRUST_STORE_PATH)
+ .tlsTrustStorePassword(KEY_STORE_PASSWORD)
.tlsProtocols(new HashSet<String>() {
{
this.add("TLSv1.3");
@@ -161,12 +161,12 @@ public class JettySslContextFactoryWithKeyStoreTest {
Server server = new Server();
List<ServerConnector> connectors = new ArrayList<>();
PulsarSslConfiguration sslConfiguration = PulsarSslConfiguration.builder()
- .tlsKeyStoreType(keyStoreType)
- .tlsKeyStorePath(brokerKeyStorePath)
- .tlsKeyStorePassword(keyStorePassword)
- .tlsTrustStoreType(keyStoreType)
- .tlsTrustStorePath(clientTrustStorePath)
- .tlsTrustStorePassword(keyStorePassword)
+ .tlsKeyStoreType(KEY_STORE_TYPE)
+ .tlsKeyStorePath(BROKEN_KEY_STORE_PATH)
+ .tlsKeyStorePassword(KEY_STORE_PASSWORD)
+ .tlsTrustStoreType(KEY_STORE_TYPE)
+ .tlsTrustStorePath(CLIENT_TRUST_STORE_PATH)
+ .tlsTrustStorePassword(KEY_STORE_PASSWORD)
.tlsCiphers(new HashSet<String>() {
{
this.add("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256");
@@ -218,7 +218,7 @@ public class JettySslContextFactoryWithKeyStoreTest {
}
private static SSLContext getClientSslContext() {
- return getSslContext(clientKeyStorePath, keyStorePassword, brokerTrustStorePath, keyStorePassword);
+ return getSslContext(CLIENT_KEY_STORE_PATH, KEY_STORE_PASSWORD, BROKER_TRUST_STORE_PATH, KEY_STORE_PASSWORD);
}
private static SSLContext getSslContext(String keyStorePath, String keyStorePassword,
diff --git a/pulsar-broker/src/test/java/org/apache/bookkeeper/mledger/impl/MangedLedgerInterceptorImpl2Test.java b/pulsar-broker/src/test/java/org/apache/bookkeeper/mledger/impl/MangedLedgerInterceptorImpl2Test.java
index ec05f4dc381..0a7effc9988 100644
--- a/pulsar-broker/src/test/java/org/apache/bookkeeper/mledger/impl/MangedLedgerInterceptorImpl2Test.java
+++ b/pulsar-broker/src/test/java/org/apache/bookkeeper/mledger/impl/MangedLedgerInterceptorImpl2Test.java
@@ -18,8 +18,8 @@
*/
package org.apache.bookkeeper.mledger.impl;
-import static org.testng.Assert.assertEquals;
import static org.apache.pulsar.broker.intercept.ManagedLedgerInterceptorImplTest.TestPayloadProcessor;
+import static org.testng.Assert.assertEquals;
import java.util.HashSet;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
diff --git a/pulsar-broker/src/test/java/org/apache/bookkeeper/mledger/impl/NonEntryCacheKeySharedSubscriptionV30Test.java b/pulsar-broker/src/test/java/org/apache/bookkeeper/mledger/impl/NonEntryCacheKeySharedSubscriptionV30Test.java
index 0de3d4edfad..734d2806840 100644
--- a/pulsar-broker/src/test/java/org/apache/bookkeeper/mledger/impl/NonEntryCacheKeySharedSubscriptionV30Test.java
+++ b/pulsar-broker/src/test/java/org/apache/bookkeeper/mledger/impl/NonEntryCacheKeySharedSubscriptionV30Test.java
@@ -135,12 +135,12 @@ public class NonEntryCacheKeySharedSubscriptionV30Test extends ProducerConsumerB
ackAllMessages(consumer1, consumer2);
Position mdPosition = (Position) cursor.getMarkDeletedPosition();
Position readPosition = (Position) cursor.getReadPosition();
- Position LAC = (Position) ml.getLastConfirmedEntry();
- assertTrue(readPosition.compareTo(LAC) >= 0);
+ Position lastConfirmed = (Position) ml.getLastConfirmedEntry();
+ assertTrue(readPosition.compareTo(lastConfirmed) >= 0);
Position firstWaitingAckPos = ml.getNextValidPosition(mdPosition);
log.info("md-pos {}:{}", mdPosition.getLedgerId(), mdPosition.getEntryId());
log.info("rd-pos {}:{}", readPosition.getLedgerId(), readPosition.getEntryId());
- log.info("lac-pos {}:{}", LAC.getLedgerId(), LAC.getEntryId());
+ log.info("lac-pos {}:{}", lastConfirmed.getLedgerId(), lastConfirmed.getEntryId());
log.info("first-waiting-ack-pos {}:{}", firstWaitingAckPos.getLedgerId(), firstWaitingAckPos.getEntryId());
// Inject a delay for the next replay read.
@@ -225,15 +225,15 @@ public class NonEntryCacheKeySharedSubscriptionV30Test extends ProducerConsumerB
if (dispatcher.getRecentlyJoinedConsumers().size() > 0) {
Position mdPosition2 = (Position) cursor.getMarkDeletedPosition();
Position readPosition2 = (Position) cursor.getReadPosition();
- Position LAC2 = (Position) ml.getLastConfirmedEntry();
- assertTrue(readPosition.compareTo(LAC) >= 0);
+ Position lastConfirmed2 = (Position) ml.getLastConfirmedEntry();
+ assertTrue(readPosition.compareTo(lastConfirmed) >= 0);
Position firstWaitingAckPos2 = ml.getNextValidPosition(mdPosition);
- if(readPosition2.compareTo(firstWaitingAckPos) > 0) {
+ if (readPosition2.compareTo(firstWaitingAckPos) > 0) {
keepPublishing.set(false);
log.info("consumer-index: {}", i);
log.info("md-pos-2 {}:{}", mdPosition2.getLedgerId(), mdPosition2.getEntryId());
log.info("rd-pos-2 {}:{}", readPosition2.getLedgerId(), readPosition2.getEntryId());
- log.info("lac-pos-2 {}:{}", LAC2.getLedgerId(), LAC2.getEntryId());
+ log.info("lac-pos-2 {}:{}", lastConfirmed2.getLedgerId(), lastConfirmed2.getEntryId());
log.info("first-waiting-ack-pos-2 {}:{}", firstWaitingAckPos2.getLedgerId(),
firstWaitingAckPos2.getEntryId());
// finish the replay read here.
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/PulsarStandaloneTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/PulsarStandaloneTest.java
index 3d22feb822e..77c1aced14d 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/PulsarStandaloneTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/PulsarStandaloneTest.java
@@ -21,7 +21,6 @@ package org.apache.pulsar;
import static org.apache.commons.io.FileUtils.cleanDirectory;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
-
import java.io.File;
import java.util.Collections;
import java.util.List;
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/BookKeeperClientFactoryImplTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/BookKeeperClientFactoryImplTest.java
index ca73b979258..fdf8dea0f04 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/BookKeeperClientFactoryImplTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/BookKeeperClientFactoryImplTest.java
@@ -188,7 +188,8 @@ public class BookKeeperClientFactoryImplTest {
BookKeeperClientFactoryImpl factory = new BookKeeperClientFactoryImpl();
ServiceConfiguration conf = new ServiceConfiguration();
conf.setMetadataStoreUrl("zk:localhost:2181");
- assertEquals(factory.createBkClientConfiguration(mock(MetadataStoreExtended.class), conf).getExplictLacInterval(),
+ assertEquals(factory.createBkClientConfiguration(mock(MetadataStoreExtended.class), conf)
+ .getExplictLacInterval(),
0);
conf.setBookkeeperExplicitLacIntervalInMills(5);
assertEquals(
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/BrokerAdditionalServletTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/BrokerAdditionalServletTest.java
index c9432d65fa2..dc21a6a6933 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/BrokerAdditionalServletTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/BrokerAdditionalServletTest.java
@@ -49,9 +49,9 @@ import org.testng.annotations.Test;
@Test(groups = "broker")
public class BrokerAdditionalServletTest extends MockedPulsarServiceBaseTest {
- private final String BASE_PATH = "/additional/servlet";
- private final String WITH_PULSAR_SERVICE_BASE_PATH = "/additional/servlet/with/pulsar/service";
- private final String QUERY_PARAM = "param";
+ private static final String BASE_PATH = "/additional/servlet";
+ private static final String WITH_PULSAR_SERVICE_BASE_PATH = "/additional/servlet/with/pulsar/service";
+ private static final String QUERY_PARAM = "param";
@Override
@BeforeClass
@@ -110,7 +110,8 @@ public class BrokerAdditionalServletTest extends MockedPulsarServiceBaseTest {
AdditionalServlets brokerAdditionalServlets = Mockito.mock(AdditionalServlets.class);
Map<String, AdditionalServletWithClassLoader> map = new HashMap<>();
map.put("broker-additional-servlet", new AdditionalServletWithClassLoader(brokerAdditionalServlet, null));
- map.put("broker-additional-servlet-with-pulsar-service", new AdditionalServletWithClassLoader(brokerAdditionalServletWithPulsarService, null));
+ map.put("broker-additional-servlet-with-pulsar-service", new
+ AdditionalServletWithClassLoader(brokerAdditionalServletWithPulsarService, null));
Mockito.when(brokerAdditionalServlets.getServlets()).thenReturn(map);
Mockito.when(pulsar.getBrokerAdditionalServlets()).thenReturn(brokerAdditionalServlets);
@@ -124,9 +125,9 @@ public class BrokerAdditionalServletTest extends MockedPulsarServiceBaseTest {
String response = httpGet("http://localhost:" + httpPort + BASE_PATH + "?" + QUERY_PARAM + "=" + paramValue);
Assert.assertEquals(response, paramValue);
- String WithPulsarServiceParamValue = PulsarService.class.getName();
+ String withPulsarServiceParamValue = PulsarService.class.getName();
String withPulsarServiceResponse = httpGet("http://localhost:" + httpPort + WITH_PULSAR_SERVICE_BASE_PATH);
- Assert.assertEquals(WithPulsarServiceParamValue, withPulsarServiceResponse);
+ Assert.assertEquals(withPulsarServiceParamValue, withPulsarServiceResponse);
}
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/BrokerTestUtil.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/BrokerTestUtil.java
index e97928c4c66..71e6c0f5f59 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/BrokerTestUtil.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/BrokerTestUtil.java
@@ -112,7 +112,7 @@ public class BrokerTestUtil {
}
/**
- * Uses Jackson to create a JSON string for the given object
+ * Uses Jackson to create a JSON string for the given object.
* @param object to convert to JSON
* @return JSON string
*/
@@ -128,7 +128,7 @@ public class BrokerTestUtil {
}
/**
- * Logs the topic stats and internal stats for the given topic
+ * Logs the topic stats and internal stats for the given topic.
* @param logger logger to use
* @param pulsarAdmin PulsarAdmin client to use
* @param topic topic name
@@ -144,7 +144,7 @@ public class BrokerTestUtil {
}
/**
- * Logs the topic stats and internal stats for the given topic
+ * Logs the topic stats and internal stats for the given topic.
* @param logger logger to use
* @param baseUrl Pulsar service URL
* @param topic topic name
@@ -154,7 +154,7 @@ public class BrokerTestUtil {
}
/**
- * Logs the topic stats and internal stats for the given topic
+ * Logs the topic stats and internal stats for the given topic.
* @param logger logger to use
* @param baseUrl Pulsar service URL
* @param tenant tenant name
@@ -171,7 +171,7 @@ public class BrokerTestUtil {
}
/**
- * Pretty print the given JSON string
+ * Pretty print the given JSON string.
* @param jsonString JSON string to pretty print
* @return pretty printed JSON string
*/
@@ -187,7 +187,7 @@ public class BrokerTestUtil {
}
/**
- * Get the resource as a string from the given URI
+ * Get the resource as a string from the given URI.
*/
@SneakyThrows
public static String getJsonResourceAsString(String uri) {
@@ -365,7 +365,8 @@ public class BrokerTestUtil {
return createMockConsumer(consumerName, consumerName + " consumerId:" + consumerId, consumerId);
}
- public static org.apache.pulsar.broker.service.Consumer createMockConsumer(String consumerName, String toString, long consumerId) {
+ public static org.apache.pulsar.broker.service.Consumer createMockConsumer(String consumerName,
+ String toString, long consumerId) {
// without stubOnly, the mock will record method invocations and could run into OOME
org.apache.pulsar.broker.service.Consumer
consumer = mock(org.apache.pulsar.broker.service.Consumer.class, Mockito.withSettings().stubOnly());
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/LedgerLostAndSkipNonRecoverableTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/LedgerLostAndSkipNonRecoverableTest.java
index dbaaee8f48c..d4d25120296 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/LedgerLostAndSkipNonRecoverableTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/LedgerLostAndSkipNonRecoverableTest.java
@@ -105,7 +105,7 @@ public class LedgerLostAndSkipNonRecoverableTest extends ProducerConsumerBase {
log.info("make individual ack.");
ConsumerAndReceivedMessages consumerAndReceivedMessages1 =
- waitConsumeAndAllMessages(topicName, subName, enabledBatch,false);
+ waitConsumeAndAllMessages(topicName, subName, enabledBatch, false);
List<MessageIdImpl>[] messageIds = consumerAndReceivedMessages1.messageIds;
Consumer consumer = consumerAndReceivedMessages1.consumer;
MessageIdImpl individualPosition = messageIds[1].get(messageCountPerEntry - 1);
@@ -137,10 +137,10 @@ public class LedgerLostAndSkipNonRecoverableTest extends ProducerConsumerBase {
}
private ManagedCursorImpl getCursor(String topicName, String subName) throws Exception {
- PersistentSubscription subscription_ =
+ PersistentSubscription subscription =
(PersistentSubscription) pulsar.getBrokerService().getTopic(topicName, false)
.get().get().getSubscription(subName);
- return (ManagedCursorImpl) subscription_.getCursor();
+ return (ManagedCursorImpl) subscription.getCursor();
}
private void waitMarkDeleteLargeAndEquals(String topicName, String subName, final long markDeletedLedgerId,
@@ -229,7 +229,7 @@ public class LedgerLostAndSkipNonRecoverableTest extends ProducerConsumerBase {
}
producer.close();
FutureUtil.waitForAll(messageIdFutures).get();
- return messageIdFutures.stream().map(f -> (MessageIdImpl)f.join()).collect(Collectors.toList());
+ return messageIdFutures.stream().map(f -> (MessageIdImpl) f.join()).collect(Collectors.toList());
}
private ConsumerAndReceivedMessages waitConsumeAndAllMessages(String topicName, String subName,
@@ -271,11 +271,11 @@ public class LedgerLostAndSkipNonRecoverableTest extends ProducerConsumerBase {
if (enabledBatch){
BatchMessageIdImpl mb1 = (BatchMessageIdImpl) m1;
BatchMessageIdImpl mb2 = (BatchMessageIdImpl) m2;
- return (int) (mb1.getLedgerId() * 1000000 + mb1.getEntryId() * 1000 + mb1.getBatchIndex() -
- mb2.getLedgerId() * 1000000 + mb2.getEntryId() * 1000 + mb2.getBatchIndex());
+ return (int) (mb1.getLedgerId() * 1000000 + mb1.getEntryId() * 1000 + mb1.getBatchIndex()
+ - mb2.getLedgerId() * 1000000 + mb2.getEntryId() * 1000 + mb2.getBatchIndex());
}
- return (int) (m1.getLedgerId() * 1000 + m1.getEntryId() -
- m2.getLedgerId() * 1000 + m2.getEntryId());
+ return (int) (m1.getLedgerId() * 1000 + m1.getEntryId()
+ - m2.getLedgerId() * 1000 + m2.getEntryId());
});
}
return res;
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/MockedBookKeeperClientFactory.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/MockedBookKeeperClientFactory.java
index 887e35e2774..d2ed4ac8021 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/MockedBookKeeperClientFactory.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/MockedBookKeeperClientFactory.java
@@ -52,9 +52,9 @@ public class MockedBookKeeperClientFactory implements BookKeeperClientFactory {
@Override
public CompletableFuture<BookKeeper> create(ServiceConfiguration conf, MetadataStoreExtended store,
- EventLoopGroup eventLoopGroup,
- Optional<Class<? extends EnsemblePlacementPolicy>> ensemblePlacementPolicyClass,
- Map<String, Object> properties) {
+ EventLoopGroup eventLoopGroup,
+ Optional<Class<? extends EnsemblePlacementPolicy>> ensemblePlacementPolicyClass,
+ Map<String, Object> properties) {
return CompletableFuture.completedFuture(mockedBk);
}
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/MultiBrokerTestZKBaseTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/MultiBrokerTestZKBaseTest.java
index 96d88032302..06c28c3b3ce 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/MultiBrokerTestZKBaseTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/MultiBrokerTestZKBaseTest.java
@@ -29,7 +29,7 @@ import org.apache.pulsar.metadata.api.extended.MetadataStoreExtended;
import org.jspecify.annotations.NonNull;
/**
- * Multiple brokers with a real test Zookeeper server (instead of the mock server)
+ * Multiple brokers with a real test Zookeeper server (instead of the mock server).
*/
@Slf4j
public abstract class MultiBrokerTestZKBaseTest extends MultiBrokerBaseTest {
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/PulsarServiceTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/PulsarServiceTest.java
index dd2f9288071..b47011f2070 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/PulsarServiceTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/PulsarServiceTest.java
@@ -189,10 +189,14 @@ public class PulsarServiceTest extends MockedPulsarServiceBaseTest {
assertEquals(conf, pulsar.getConfiguration());
assertEquals(conf.getBrokerServicePortTls(), pulsar.getBrokerListenPortTls());
assertEquals(conf.getBrokerServicePort(), pulsar.getBrokerListenPort());
- assertEquals(pulsar.getBrokerServiceUrlTls(), "pulsar+ssl://localhost:" + pulsar.getBrokerListenPortTls().get());
- assertEquals(pulsar.getBrokerServiceUrl(), "pulsar://localhost:" + pulsar.getBrokerListenPort().get());
- assertEquals(pulsar.getWebServiceAddress(), "http://localhost:" + pulsar.getWebService().getListenPortHTTP().get());
- assertEquals(pulsar.getWebServiceAddressTls(), "https://localhost:" + pulsar.getWebService().getListenPortHTTPS().get());
+ assertEquals(pulsar.getBrokerServiceUrlTls(),
+ "pulsar+ssl://localhost:" + pulsar.getBrokerListenPortTls().get());
+ assertEquals(pulsar.getBrokerServiceUrl(),
+ "pulsar://localhost:" + pulsar.getBrokerListenPort().get());
+ assertEquals(pulsar.getWebServiceAddress(),
+ "http://localhost:" + pulsar.getWebService().getListenPortHTTP().get());
+ assertEquals(pulsar.getWebServiceAddressTls(),
+ "https://localhost:" + pulsar.getWebService().getListenPortHTTPS().get());
}
@Test
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/TimeAverageBrokerDataTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/TimeAverageBrokerDataTest.java
index 30d7fd48ae5..51a44c9a838 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/TimeAverageBrokerDataTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/TimeAverageBrokerDataTest.java
@@ -18,13 +18,14 @@
*/
package org.apache.pulsar.broker;
-import static org.testng.Assert.*;
-import org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertThrows;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.pulsar.policies.data.loadbalancer.BundleData;
+import org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats;
import org.apache.pulsar.policies.data.loadbalancer.TimeAverageBrokerData;
import org.apache.pulsar.policies.data.loadbalancer.TimeAverageMessageData;
import org.testng.annotations.Test;
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/TopicEventsListenerTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/TopicEventsListenerTest.java
index 152b4aeeeb2..b597d98efc3 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/TopicEventsListenerTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/TopicEventsListenerTest.java
@@ -18,8 +18,9 @@
*/
package org.apache.pulsar.broker;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
import com.google.common.collect.Sets;
-
import java.util.Queue;
import java.util.UUID;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -44,13 +45,10 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
@Slf4j
public class TopicEventsListenerTest extends BrokerTestBase {
- final static Queue<String> events = new ConcurrentLinkedQueue<>();
+ final Queue<String> events = new ConcurrentLinkedQueue<>();
volatile String topicNameToWatch;
String namespace;
@@ -262,7 +260,8 @@ public class TopicEventsListenerTest extends BrokerTestBase {
);
}
- private void createTopicAndVerifyEvents(String topicDomain, String topicTypePartitioned, String topicName) throws Exception {
+ private void createTopicAndVerifyEvents(String topicDomain, String topicTypePartitioned, String topicName)
+ throws Exception {
final String[] expectedEvents;
if (topicDomain.equalsIgnoreCase("persistent") || topicTypePartitioned.equals("partitioned")) {
if (topicTypePartitioned.equals("partitioned")) {
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java
index 76559297d34..801b888f91c 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java
@@ -22,7 +22,9 @@ import static java.util.concurrent.TimeUnit.MINUTES;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.pulsar.broker.BrokerTestUtil.newUniqueName;
import static org.apache.pulsar.broker.resources.LoadBalanceResources.BUNDLE_DATA_BASE_PATH;
-import static org.apache.pulsar.common.policies.data.NamespaceIsolationPolicyUnloadScope.*;
+import static org.apache.pulsar.common.policies.data.NamespaceIsolationPolicyUnloadScope.all_matching;
+import static org.apache.pulsar.common.policies.data.NamespaceIsolationPolicyUnloadScope.changed;
+import static org.apache.pulsar.common.policies.data.NamespaceIsolationPolicyUnloadScope.none;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.spy;
@@ -113,7 +115,29 @@ import org.apache.pulsar.client.impl.MessageIdImpl;
import org.apache.pulsar.common.naming.NamespaceName;
import org.apache.pulsar.common.naming.TopicDomain;
import org.apache.pulsar.common.naming.TopicName;
-import org.apache.pulsar.common.policies.data.*;
+import org.apache.pulsar.common.policies.data.AuthAction;
+import org.apache.pulsar.common.policies.data.AutoFailoverPolicyData;
+import org.apache.pulsar.common.policies.data.AutoFailoverPolicyType;
+import org.apache.pulsar.common.policies.data.AutoTopicCreationOverride;
+import org.apache.pulsar.common.policies.data.BacklogQuota;
+import org.apache.pulsar.common.policies.data.BrokerNamespaceIsolationData;
+import org.apache.pulsar.common.policies.data.BrokerNamespaceIsolationDataImpl;
+import org.apache.pulsar.common.policies.data.BundlesData;
+import org.apache.pulsar.common.policies.data.ClusterData;
+import org.apache.pulsar.common.policies.data.ConsumerStats;
+import org.apache.pulsar.common.policies.data.EntryFilters;
+import org.apache.pulsar.common.policies.data.FailureDomain;
+import org.apache.pulsar.common.policies.data.NamespaceIsolationData;
+import org.apache.pulsar.common.policies.data.NamespaceIsolationPolicyUnloadScope;
+import org.apache.pulsar.common.policies.data.NonPersistentTopicStats;
+import org.apache.pulsar.common.policies.data.PartitionedTopicStats;
+import org.apache.pulsar.common.policies.data.PersistencePolicies;
+import org.apache.pulsar.common.policies.data.PersistentTopicInternalStats;
+import org.apache.pulsar.common.policies.data.RetentionPolicies;
+import org.apache.pulsar.common.policies.data.SubscriptionStats;
+import org.apache.pulsar.common.policies.data.TenantInfoImpl;
+import org.apache.pulsar.common.policies.data.TopicStats;
+import org.apache.pulsar.common.policies.data.TopicType;
import org.apache.pulsar.common.policies.data.impl.BacklogQuotaImpl;
import org.apache.pulsar.common.protocol.schema.SchemaData;
import org.awaitility.Awaitility;
@@ -425,7 +449,8 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
//setup cluster with 3 broker
admin.clusters().updateCluster("test",
- ClusterData.builder().serviceUrl((pulsar.getWebServiceAddress() + ",localhost:1026," + "localhost:2050")).build());
+ ClusterData.builder().serviceUrl((pulsar.getWebServiceAddress()
+ + ",localhost:1026," + "localhost:2050")).build());
TenantInfoImpl tenantInfo = new TenantInfoImpl(Set.of("role1", "role2"), Set.of("test"));
String tenantName = newUniqueName("prop-xyz2");
admin.tenants().createTenant(tenantName, tenantInfo);
@@ -537,7 +562,7 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
}
/**
- * verifies validation on persistent-policies
+ * verifies validation on persistent-policies.
*
* @throws Exception
*/
@@ -575,7 +600,7 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
}
/**
- * validates update of persistent-policies reflects on managed-ledger and managed-cursor
+ * validates update of persistent-policies reflects on managed-ledger and managed-cursor.
*
* @throws Exception
*/
@@ -616,7 +641,7 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
}
/**
- * Verify unloading topic
+ * Verify unloading topic.
*
* @throws Exception
*/
@@ -808,7 +833,7 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
}
/**
- * It verifies that pulsar with different load-manager generates different load-report and returned by admin-api
+ * It verifies that pulsar with different load-manager generates different load-report and returned by admin-api.
*
* @throws Exception
*/
@@ -871,7 +896,7 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
}
/**
- * It validates that peer-cluster can't coexist in replication-cluster list
+ * It validates that peer-cluster can't coexist in replication-cluster list.
*
* @throws Exception
*/
@@ -1411,7 +1436,7 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
assertEquals(admin.clusters().getClusters(), List.of(cluster));
}
/**
- * verifies cluster has been set before create topic
+ * verifies cluster has been set before create topic.
*
* @throws PulsarAdminException
*/
@@ -1421,7 +1446,7 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
final String topicName = "partitionedTopic";
final int partitions = 4;
final String persistentPartitionedTopicName = "persistent://" + defaultTenant + "/ns2/" + topicName;
- final String NonPersistentPartitionedTopicName = "non-persistent://" + defaultTenant + "/ns2/" + topicName;
+ final String nonPersistentPartitionedTopicName = "non-persistent://" + defaultTenant + "/ns2/" + topicName;
admin.namespaces().createNamespace(defaultTenant + "/ns2");
// By default the cluster will configure as configuration file. So the create topic operation
@@ -1429,7 +1454,7 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
admin.namespaces().setNamespaceReplicationClusters(defaultTenant + "/ns2", Sets.newHashSet(configClusterName));
admin.topics().createPartitionedTopic(persistentPartitionedTopicName, partitions);
- admin.topics().createPartitionedTopic(NonPersistentPartitionedTopicName, partitions);
+ admin.topics().createPartitionedTopic(nonPersistentPartitionedTopicName, partitions);
}
@Test
@@ -1444,7 +1469,8 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
}
@Test(timeOut = 30000)
- public void testConsumerStatsLastTimestamp() throws PulsarClientException, PulsarAdminException, InterruptedException {
+ public void testConsumerStatsLastTimestamp() throws PulsarClientException, PulsarAdminException,
+ InterruptedException {
long timestamp = System.currentTimeMillis();
final String topicName = "consumer-stats-" + timestamp;
final String subscribeName = topicName + "-test-stats-sub";
@@ -1576,11 +1602,13 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
Message<byte[]> message = consumer.receive();
assertNotNull(message);
- // Mock the entries added count. Default is disable the precise backlog, so the backlog is entries added count - consumed count
+ // Mock the entries added count. Default is disable the precise backlog,
+ // so the backlog is entries added count - consumed count
// Since message have not acked, so the backlog is 10
- PersistentSubscription subscription = (PersistentSubscription)pulsar.getBrokerService().getTopicReference(topic).get().getSubscription(subName);
+ PersistentSubscription subscription = (PersistentSubscription) pulsar.getBrokerService()
+ .getTopicReference(topic).get().getSubscription(subName);
assertNotNull(subscription);
- ((ManagedLedgerImpl)subscription.getCursor().getManagedLedger()).setEntriesAddedCounter(10L);
+ ((ManagedLedgerImpl) subscription.getCursor().getManagedLedger()).setEntriesAddedCounter(10L);
TopicStats topicStats = admin.topics().getStats(topic);
assertEquals(topicStats.getSubscriptions().get(subName).getMsgBacklog(), 10);
@@ -1813,7 +1841,8 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
@Test(timeOut = 30000)
public void testBacklogNoDelayed() throws PulsarClientException, PulsarAdminException, InterruptedException {
- final String topic = "persistent://" + defaultNamespace + "/precise-back-log-no-delayed-" + UUID.randomUUID().toString();
+ final String topic = "persistent://" + defaultNamespace + "/precise-back-log-no-delayed-"
+ + UUID.randomUUID().toString();
final String subName = "sub-name";
@Cleanup
@@ -1916,12 +1945,14 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
Message<byte[]> message = consumer.receive();
assertNotNull(message);
- // Mock the entries added count. Default is disable the precise backlog, so the backlog is entries added count - consumed count
+ // Mock the entries added count. Default is disable the precise backlog,
+ // so the backlog is entries added count - consumed count
// Since message have not acked, so the backlog is 10
for (int i = 0; i < 2; i++) {
- PersistentSubscription subscription = (PersistentSubscription)pulsar.getBrokerService().getTopicReference(topic + "-partition-" + i).get().getSubscription(subName);
+ PersistentSubscription subscription = (PersistentSubscription) pulsar.getBrokerService().
+ getTopicReference(topic + "-partition-" + i).get().getSubscription(subName);
assertNotNull(subscription);
- ((ManagedLedgerImpl)subscription.getCursor().getManagedLedger()).setEntriesAddedCounter(10L);
+ ((ManagedLedgerImpl) subscription.getCursor().getManagedLedger()).setEntriesAddedCounter(10L);
}
TopicStats topicStats = admin.topics().getPartitionedStats(topic, false);
@@ -1933,7 +1964,8 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
}
@Test(timeOut = 30000)
- public void testBacklogNoDelayedForPartitionedTopic() throws PulsarClientException, PulsarAdminException, InterruptedException {
+ public void testBacklogNoDelayedForPartitionedTopic() throws PulsarClientException,
+ PulsarAdminException, InterruptedException {
final String topic = "persistent://" + defaultNamespace + "/precise-back-log-no-delayed-partitioned-topic";
admin.topics().createPartitionedTopic(topic, 2);
final String subName = "sub-name";
@@ -2373,19 +2405,20 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
assertNull(admin.namespaces().getMaxSubscriptionsPerTopic(myNamespace));
- admin.namespaces().setMaxSubscriptionsPerTopic(myNamespace,100);
- assertEquals(admin.namespaces().getMaxSubscriptionsPerTopic(myNamespace).intValue(),100);
+ admin.namespaces().setMaxSubscriptionsPerTopic(myNamespace, 100);
+ assertEquals(admin.namespaces().getMaxSubscriptionsPerTopic(myNamespace).intValue(), 100);
admin.namespaces().removeMaxSubscriptionsPerTopic(myNamespace);
assertNull(admin.namespaces().getMaxSubscriptionsPerTopic(myNamespace));
- admin.namespaces().setMaxSubscriptionsPerTopicAsync(myNamespace,200).get();
- assertEquals(admin.namespaces().getMaxSubscriptionsPerTopicAsync(myNamespace).get().intValue(),200);
+ admin.namespaces().setMaxSubscriptionsPerTopicAsync(myNamespace, 200).get();
+ assertEquals(admin.namespaces().getMaxSubscriptionsPerTopicAsync(myNamespace).get().intValue(),
+ 200);
admin.namespaces().removeMaxSubscriptionsPerTopicAsync(myNamespace);
Awaitility.await().untilAsserted(()
-> assertNull(admin.namespaces().getMaxSubscriptionsPerTopicAsync(myNamespace).get()));
try {
- admin.namespaces().setMaxSubscriptionsPerTopic(myNamespace,-100);
+ admin.namespaces().setMaxSubscriptionsPerTopic(myNamespace, -100);
fail("should fail");
} catch (PulsarAdminException ignore) {
}
@@ -2613,7 +2646,7 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
.get()
.getEntryFilters();
assertEquals(entryFilters.size(), 1);
- assertEquals(((EntryFilterWithClassLoader)entryFilters.get(0))
+ assertEquals(((EntryFilterWithClassLoader) entryFilters.get(0))
.getEntryFilter().getClass(), EntryFilterTest.class);
});
@@ -2684,16 +2717,16 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
fail();
} catch (PulsarAdminException e) {
assertEquals(e.getStatusCode(), 400);
- assertEquals(e.getMessage(), "entryFilterNames can't be empty. " +
- "To remove entry filters use the remove method.");
+ assertEquals(e.getMessage(), "entryFilterNames can't be empty. "
+ + "To remove entry filters use the remove method.");
}
try {
admin.namespaces().setNamespaceEntryFilters(myNamespace, new EntryFilters(","));
fail();
} catch (PulsarAdminException e) {
assertEquals(e.getStatusCode(), 400);
- assertEquals(e.getMessage(), "entryFilterNames can't be empty. " +
- "To remove entry filters use the remove method.");
+ assertEquals(e.getMessage(), "entryFilterNames can't be empty. "
+ + "To remove entry filters use the remove method.");
}
try {
admin.namespaces().setNamespaceEntryFilters(myNamespace, new EntryFilters("test,notexists"));
@@ -2748,16 +2781,16 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
fail();
} catch (PulsarAdminException e) {
assertEquals(e.getStatusCode(), 400);
- assertEquals(e.getMessage(), "entryFilterNames can't be empty. " +
- "To remove entry filters use the remove method.");
+ assertEquals(e.getMessage(), "entryFilterNames can't be empty. "
+ + "To remove entry filters use the remove method.");
}
try {
admin.topicPolicies().setEntryFiltersPerTopic(topicName, new EntryFilters(","));
fail();
} catch (PulsarAdminException e) {
assertEquals(e.getStatusCode(), 400);
- assertEquals(e.getMessage(), "entryFilterNames can't be empty. " +
- "To remove entry filters use the remove method.");
+ assertEquals(e.getMessage(), "entryFilterNames can't be empty. "
+ + "To remove entry filters use the remove method.");
}
try {
admin.topicPolicies().setEntryFiltersPerTopic(topicName, new EntryFilters("test,notexists"));
@@ -2783,7 +2816,8 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
pulsarClient.newProducer().topic(topic).create().close();
final int maxSub = 2;
admin.namespaces().setMaxSubscriptionsPerTopic(myNamespace, maxSub);
- PersistentTopic persistentTopic = (PersistentTopic) pulsar.getBrokerService().getTopicIfExists(topic).get().get();
+ PersistentTopic persistentTopic = (PersistentTopic) pulsar.getBrokerService()
+ .getTopicIfExists(topic).get().get();
Awaitility.await().until(() ->
persistentTopic.getHierarchyTopicPolicies().getMaxSubscriptionsPerTopic().get() == maxSub);
@@ -2794,7 +2828,7 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
consumerList.add(consumer);
}
//Create a client that can fail quickly
- try (PulsarClient client = PulsarClient.builder().operationTimeout(2,TimeUnit.SECONDS)
+ try (PulsarClient client = PulsarClient.builder().operationTimeout(2, TimeUnit.SECONDS)
.serviceUrl(brokerUrl.toString()).build()){
@Cleanup
Consumer<byte[]> subscribe =
@@ -2828,7 +2862,7 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
final String topic = "persistent://" + myNamespace + "/testMaxSubPerTopic";
//Create a client that can fail quickly
@Cleanup
- PulsarClient client = PulsarClient.builder().operationTimeout(2,TimeUnit.SECONDS)
+ PulsarClient client = PulsarClient.builder().operationTimeout(2, TimeUnit.SECONDS)
.serviceUrl(brokerUrl.toString()).build();
//We can only create 2 consumers
List<Consumer<?>> consumerList = new ArrayList<>(brokerLevelMaxSub);
@@ -2848,7 +2882,8 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
//Set namespace-level policy,the limit should up to 4
final int nsLevelMaxSub = 4;
admin.namespaces().setMaxSubscriptionsPerTopic(myNamespace, nsLevelMaxSub);
- PersistentTopic persistentTopic = (PersistentTopic) pulsar.getBrokerService().getTopicIfExists(topic).get().get();
+ PersistentTopic persistentTopic = (PersistentTopic) pulsar.getBrokerService()
+ .getTopicIfExists(topic).get().get();
Awaitility.await().until(() -> persistentTopic.getHierarchyTopicPolicies()
.getMaxSubscriptionsPerTopic().get() == nsLevelMaxSub);
Consumer<?> consumer = pulsarClient.newConsumer().topic(topic).subscriptionName(UUID.randomUUID().toString())
@@ -3023,7 +3058,8 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
@Test
public void testClearBacklogForTheSubscriptionThatNoConsumers() throws Exception {
- final String topic = "persistent://" + defaultNamespace + "/clear_backlog_no_consumers" + UUID.randomUUID().toString();
+ final String topic = "persistent://" + defaultNamespace + "/clear_backlog_no_consumers"
+ + UUID.randomUUID().toString();
final String sub = "my-sub";
admin.topics().createNonPartitionedTopic(topic);
admin.topics().createSubscription(topic, sub, MessageId.earliest);
@@ -3059,7 +3095,8 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
final String topic = "persistent://" + namespace + "/topic" + UUID.randomUUID();
pulsarClient.newProducer().topic(topic).create().close();
TopicName topicName = TopicName.get(topic);
- PersistentTopic persistentTopic = (PersistentTopic) pulsar.getBrokerService().getTopicIfExists(topic).get().get();
+ PersistentTopic persistentTopic = (PersistentTopic) pulsar.getBrokerService()
+ .getTopicIfExists(topic).get().get();
PersistentTopic mockTopic = spy(persistentTopic);
mockTopic.checkCompaction();
// Disabled by default
@@ -3281,7 +3318,8 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
public void testPartitionedStatsAggregationByProducerName(String topicType) throws Exception {
restartClusterIfReused();
conf.setAggregatePublisherStatsByProducerName(true);
- final String topic = topicType + "://" + defaultNamespace + "/test-partitioned-stats-aggregation-by-producer-name";
+ final String topic = topicType + "://" + defaultNamespace
+ + "/test-partitioned-stats-aggregation-by-producer-name";
admin.topics().createPartitionedTopic(topic, 10);
@Cleanup
@@ -3328,7 +3366,8 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
PartitionedTopicStats topicStats = admin.topics().getPartitionedStats(topic, true);
assertEquals(topicStats.getPartitions().size(), 10);
assertEquals(topicStats.getPartitions().values().stream().mapToInt(e -> e.getPublishers().size()).sum(), 10);
- assertEquals(topicStats.getPartitions().values().stream().map(e -> e.getPublishers().get(0).getProducerName()).distinct().count(), 2);
+ assertEquals(topicStats.getPartitions().values().stream().map(e -> e.getPublishers()
+ .get(0).getProducerName()).distinct().count(), 2);
assertEquals(topicStats.getPublishers().size(), 2);
topicStats.getPublishers().forEach(p -> assertTrue(p.isSupportsPartialProducer()));
}
@@ -3337,7 +3376,8 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
public void testPartitionedStatsAggregationByProducerNamePerPartition(String topicType) throws Exception {
restartClusterIfReused();
conf.setAggregatePublisherStatsByProducerName(true);
- final String topic = topicType + "://" + defaultNamespace + "/test-partitioned-stats-aggregation-by-producer-name-per-pt";
+ final String topic = topicType + "://" + defaultNamespace
+ + "/test-partitioned-stats-aggregation-by-producer-name-per-pt";
admin.topics().createPartitionedTopic(topic, 2);
@Cleanup
@@ -3353,7 +3393,8 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
PartitionedTopicStats topicStats = admin.topics().getPartitionedStats(topic, true);
assertEquals(topicStats.getPartitions().size(), 2);
assertEquals(topicStats.getPartitions().values().stream().mapToInt(e -> e.getPublishers().size()).sum(), 2);
- assertEquals(topicStats.getPartitions().values().stream().map(e -> e.getPublishers().get(0).getProducerName()).distinct().count(), 2);
+ assertEquals(topicStats.getPartitions().values().stream().map(e -> e.getPublishers()
+ .get(0).getProducerName()).distinct().count(), 2);
assertEquals(topicStats.getPublishers().size(), 2);
topicStats.getPublishers().forEach(p -> assertTrue(p.isSupportsPartialProducer()));
}
@@ -3535,7 +3576,8 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
return true;
}
- private void loadTopics(List<String> topics) throws PulsarClientException, ExecutionException, InterruptedException {
+ private void loadTopics(List<String> topics) throws PulsarClientException,
+ ExecutionException, InterruptedException {
// create a topic by creating a producer so that the topic is present on the broker
for (String topic : topics) {
Producer<byte[]> producer = pulsarClient.newProducer().topic(topic).create();
@@ -3723,7 +3765,7 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
final String topic1 = "persistent://" + namespace + "/test1";
final String topic2 = "persistent://" + namespace + "/test2";
final String topic3 = "non-persistent://" + namespace + "/test3";
- final String topic4 = "persistent://" + namespace2 + "/test4";;
+ final String topic4 = "persistent://" + namespace2 + "/test4";
admin.topics().createPartitionedTopic(topic1, 3);
admin.topics().createPartitionedTopic(topic2, 3);
@@ -3735,8 +3777,10 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
pulsarClient.newProducer().topic(topic4).create().close();
List<GrantTopicPermissionOptions> grantPermissionOptions = new ArrayList<>();
- grantPermissionOptions.add(GrantTopicPermissionOptions.builder().topic(topic1).role("role1").actions(Set.of(AuthAction.produce)).build());
- grantPermissionOptions.add(GrantTopicPermissionOptions.builder().topic(topic4).role("role4").actions(Set.of(AuthAction.produce)).build());
+ grantPermissionOptions.add(GrantTopicPermissionOptions.builder().topic(topic1).role("role1")
+ .actions(Set.of(AuthAction.produce)).build());
+ grantPermissionOptions.add(GrantTopicPermissionOptions.builder().topic(topic4).role("role4")
+ .actions(Set.of(AuthAction.produce)).build());
try {
admin.namespaces().grantPermissionOnTopics(grantPermissionOptions);
fail("Should go here, because there are two namespaces");
@@ -3744,9 +3788,12 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
Assert.assertTrue(ex != null);
}
grantPermissionOptions.clear();
- grantPermissionOptions.add(GrantTopicPermissionOptions.builder().topic(topic1).role("role1").actions(Set.of(AuthAction.produce)).build());
- grantPermissionOptions.add(GrantTopicPermissionOptions.builder().topic(topic2).role("role2").actions(Set.of(AuthAction.consume)).build());
- grantPermissionOptions.add(GrantTopicPermissionOptions.builder().topic(topic3).role("role3").actions(Set.of(AuthAction.produce, AuthAction.consume)).build());
+ grantPermissionOptions.add(GrantTopicPermissionOptions.builder().topic(topic1).role("role1")
+ .actions(Set.of(AuthAction.produce)).build());
+ grantPermissionOptions.add(GrantTopicPermissionOptions.builder().topic(topic2).role("role2")
+ .actions(Set.of(AuthAction.consume)).build());
+ grantPermissionOptions.add(GrantTopicPermissionOptions.builder().topic(topic3).role("role3")
+ .actions(Set.of(AuthAction.produce, AuthAction.consume)).build());
admin.namespaces().grantPermissionOnTopics(grantPermissionOptions);
final Map<String, Set<AuthAction>> permissions1 = admin.topics().getPermissions(topic1);
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiClusterTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiClusterTest.java
index 28ebe39e0aa..63dcc0c799b 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiClusterTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiClusterTest.java
@@ -39,7 +39,7 @@ import org.testng.annotations.Test;
@Test(groups = "broker-admin")
@Slf4j
public class AdminApiClusterTest extends MockedPulsarServiceBaseTest {
- private final String CLUSTER = "test";
+ private static final String CLUSTER = "test";
@BeforeMethod
@Override
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiDelayedDeliveryTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiDelayedDeliveryTest.java
index c9752750a8d..81a9513b439 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiDelayedDeliveryTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiDelayedDeliveryTest.java
@@ -18,10 +18,23 @@
*/
package org.apache.pulsar.broker.admin;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
import lombok.Cleanup;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest;
-import org.apache.pulsar.client.api.*;
+import org.apache.pulsar.client.api.Consumer;
+import org.apache.pulsar.client.api.Message;
+import org.apache.pulsar.client.api.Producer;
+import org.apache.pulsar.client.api.Schema;
+import org.apache.pulsar.client.api.SubscriptionType;
import org.apache.pulsar.common.policies.data.ClusterData;
import org.apache.pulsar.common.policies.data.DelayedDeliveryPolicies;
import org.apache.pulsar.common.policies.data.TenantInfoImpl;
@@ -30,13 +43,6 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-
-import static org.testng.Assert.*;
-
@Test(groups = "broker-admin")
@Slf4j
public class AdminApiDelayedDeliveryTest extends MockedPulsarServiceBaseTest {
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiDynamicConfigurationsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiDynamicConfigurationsTest.java
index aa7c2d720e3..e54885897ff 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiDynamicConfigurationsTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiDynamicConfigurationsTest.java
@@ -53,24 +53,25 @@ public class AdminApiDynamicConfigurationsTest extends MockedPulsarServiceBaseTe
}
@Test
- public void TestGetAllDynamicConfigurations() throws Exception {
- Map<String,String> configs = admin.brokers().getAllDynamicConfigurations();
+ public void testGetAllDynamicConfigurations() throws Exception {
+ Map<String, String> configs = admin.brokers().getAllDynamicConfigurations();
assertNotNull(configs);
}
@Test
- public void TestDeleteDynamicConfiguration() throws Exception {
+ public void testDeleteDynamicConfiguration() throws Exception {
admin.brokers().deleteDynamicConfiguration("dispatcherMinReadBatchSize");
}
@Test
- public void TestDeleteInvalidDynamicConfiguration() {
+ public void testDeleteInvalidDynamicConfiguration() {
try {
admin.brokers().deleteDynamicConfiguration("errorName");
fail("exception should be thrown");
} catch (Exception e) {
if (e instanceof PulsarAdminException) {
- assertEquals(((PulsarAdminException) e).getStatusCode(), Response.Status.PRECONDITION_FAILED.getStatusCode());
+ assertEquals(((PulsarAdminException) e).getStatusCode(),
+ Response.Status.PRECONDITION_FAILED.getStatusCode());
} else {
fail("PulsarAdminException should be thrown");
}
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiGetLastMessageIdTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiGetLastMessageIdTest.java
index 27d72f98c2c..1ec8f160dfb 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiGetLastMessageIdTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiGetLastMessageIdTest.java
@@ -190,8 +190,8 @@ public class AdminApiGetLastMessageIdTest extends MockedPulsarServiceBaseTest {
persistentTopics.getLastMessageId(asyncResponse, "prop", "ns-abc", "my-topic", true);
Awaitility.await().until(() -> id[0] != null);
- Assert.assertTrue(((MessageIdImpl)id[0]).getLedgerId() >= 0);
- Assert.assertEquals(numberOfMessages-1, ((MessageIdImpl)id[0]).getEntryId());
+ Assert.assertTrue(((MessageIdImpl) id[0]).getLedgerId() >= 0);
+ Assert.assertEquals(numberOfMessages - 1, ((MessageIdImpl) id[0]).getEntryId());
messageId = id[0];
@@ -204,8 +204,8 @@ public class AdminApiGetLastMessageIdTest extends MockedPulsarServiceBaseTest {
while (id[0] == messageId) {
Thread.sleep(1);
}
- Assert.assertTrue(((MessageIdImpl)id[0]).getLedgerId() > 0);
- Assert.assertEquals( 2 * numberOfMessages -1, ((MessageIdImpl)id[0]).getEntryId());
+ Assert.assertTrue(((MessageIdImpl) id[0]).getLedgerId() > 0);
+ Assert.assertEquals(2 * numberOfMessages - 1, ((MessageIdImpl) id[0]).getEntryId());
}
/**
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiHealthCheckTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiHealthCheckTest.java
index b39f1f955a3..5b274c211e6 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiHealthCheckTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiHealthCheckTest.java
@@ -106,7 +106,7 @@ public class AdminApiHealthCheckTest extends MockedPulsarServiceBaseTest {
}
}
future.complete(null);
- }catch (PulsarAdminException e) {
+ } catch (PulsarAdminException e) {
future.completeExceptionally(e);
}
});
@@ -122,7 +122,8 @@ public class AdminApiHealthCheckTest extends MockedPulsarServiceBaseTest {
NamespaceName namespaceName = (topicVersion == TopicVersion.V2)
? NamespaceService.getHeartbeatNamespaceV2(brokerId, pulsar.getConfiguration())
: NamespaceService.getHeartbeatNamespace(brokerId, pulsar.getConfiguration());
- final String testHealthCheckTopic = String.format("persistent://%s/%s", namespaceName, HEALTH_CHECK_TOPIC_SUFFIX);
+ final String testHealthCheckTopic = String.format("persistent://%s/%s",
+ namespaceName, HEALTH_CHECK_TOPIC_SUFFIX);
Awaitility.await().untilAsserted(() -> {
assertFalse(future.isCompletedExceptionally());
});
@@ -136,7 +137,8 @@ public class AdminApiHealthCheckTest extends MockedPulsarServiceBaseTest {
);
}
- @Test(expectedExceptions= PulsarAdminException.class, expectedExceptionsMessageRegExp = ".*Deadlocked threads detected.*")
+ @Test(expectedExceptions = PulsarAdminException.class, expectedExceptionsMessageRegExp =
+ ".*Deadlocked threads detected.*")
public void testHealthCheckupDetectsDeadlock() throws Exception {
// simulate a deadlock in the Test JVM
// the broker used in unit tests runs in the test JVM and the
@@ -144,7 +146,7 @@ public class AdminApiHealthCheckTest extends MockedPulsarServiceBaseTest {
Lock lock1 = new ReentrantReadWriteLock().writeLock();
Lock lock2 = new ReentrantReadWriteLock().writeLock();
final Phaser phaser = new Phaser(3);
- Thread thread1=new Thread(() -> {
+ Thread thread1 = new Thread(() -> {
phaser.arriveAndAwaitAdvance();
try {
deadlock(lock1, lock2, 1000L);
@@ -152,7 +154,7 @@ public class AdminApiHealthCheckTest extends MockedPulsarServiceBaseTest {
phaser.arriveAndDeregister();
}
}, "deadlockthread-1");
- Thread thread2=new Thread(() -> {
+ Thread thread2 = new Thread(() -> {
phaser.arriveAndAwaitAdvance();
try {
deadlock(lock2, lock1, 2000L);
@@ -198,7 +200,7 @@ public class AdminApiHealthCheckTest extends MockedPulsarServiceBaseTest {
@Test(timeOut = 5000L)
public void testDeadlockDetectionOverhead() {
- for (int i=0; i < 1000; i++) {
+ for (int i = 0; i < 1000; i++) {
long[] threadIds = threadBean.findDeadlockedThreads();
// assert that there's no deadlock
assertNull(threadIds);
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiMaxUnackedMessagesTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiMaxUnackedMessagesTest.java
index 9b95e41bb64..1a0d4fa75b8 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiMaxUnackedMessagesTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiMaxUnackedMessagesTest.java
@@ -106,8 +106,8 @@ public class AdminApiMaxUnackedMessagesTest extends MockedPulsarServiceBaseTest
admin.namespaces().createNamespace("max-unacked-messages/default-on-consumers");
String namespace = "max-unacked-messages/default-on-consumers";
assertNull(admin.namespaces().getMaxUnackedMessagesPerConsumer(namespace));
- admin.namespaces().setMaxUnackedMessagesPerConsumer(namespace, 2*50000);
- assertEquals(2*50000, admin.namespaces().getMaxUnackedMessagesPerConsumer(namespace).intValue());
+ admin.namespaces().setMaxUnackedMessagesPerConsumer(namespace, 2 * 50000);
+ assertEquals(2 * 50000, admin.namespaces().getMaxUnackedMessagesPerConsumer(namespace).intValue());
}
@Test
@@ -115,9 +115,10 @@ public class AdminApiMaxUnackedMessagesTest extends MockedPulsarServiceBaseTest
admin.namespaces().createNamespace("max-unacked-messages/default-on-subscription");
String namespace = "max-unacked-messages/default-on-subscription";
assertNull(admin.namespaces().getMaxUnackedMessagesPerSubscription(namespace));
- admin.namespaces().setMaxUnackedMessagesPerSubscription(namespace, 2*200000);
+ admin.namespaces().setMaxUnackedMessagesPerSubscription(namespace, 2 * 200000);
Awaitility.await().untilAsserted(()
- -> assertEquals(2*200000, admin.namespaces().getMaxUnackedMessagesPerSubscription(namespace).intValue()));
+ -> assertEquals(2 * 200000, admin.namespaces()
+ .getMaxUnackedMessagesPerSubscription(namespace).intValue()));
admin.namespaces().removeMaxUnackedMessagesPerSubscription(namespace);
Awaitility.await().untilAsserted(()
@@ -156,7 +157,8 @@ public class AdminApiMaxUnackedMessagesTest extends MockedPulsarServiceBaseTest
.subscriptionType(SubscriptionType.Shared)
.subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
.subscriptionName("sub").topic(topic).receiverQueueSize(1).subscribe();
- PersistentTopic persistentTopic = (PersistentTopic) pulsar.getBrokerService().getTopicIfExists(topic).get().get();
+ PersistentTopic persistentTopic = (PersistentTopic) pulsar.getBrokerService()
+ .getTopicIfExists(topic).get().get();
org.apache.pulsar.broker.service.Consumer serverConsumer =
persistentTopic.getSubscription("sub").getConsumers().get(0);
assertEquals(serverConsumer.getMaxUnackedMessages(), topicLevelPolicy);
@@ -196,7 +198,7 @@ public class AdminApiMaxUnackedMessagesTest extends MockedPulsarServiceBaseTest
private List<Message> consumeMsg(Consumer<?> consumer, int msgNum) throws Exception {
List<Message> list = new ArrayList<>();
- for (int i = 0; i <msgNum; i++) {
+ for (int i = 0; i < msgNum; i++) {
Message message = consumer.receive(1500, TimeUnit.MILLISECONDS);
if (message == null) {
break;
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiMultiBrokersTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiMultiBrokersTest.java
index 46b24abd6d4..ae6ef0b6ee6 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiMultiBrokersTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiMultiBrokersTest.java
@@ -21,14 +21,12 @@ package org.apache.pulsar.broker.admin;
import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
-
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
-
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.pulsar.broker.MultiBrokerBaseTest;
@@ -104,7 +102,7 @@ public class AdminApiMultiBrokersTest extends MultiBrokerBaseTest {
PulsarAdmin admin0 = getAllAdmins().get(0);
String namespace = RandomStringUtils.randomAlphabetic(5);
- admin0.namespaces().createNamespace( "public/" + namespace, 3);
+ admin0.namespaces().createNamespace("public/" + namespace, 3);
admin0.namespaces().setAutoTopicCreation("public/" + namespace,
AutoTopicCreationOverride.builder().allowAutoTopicCreation(false).build());
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiOffloadTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiOffloadTest.java
index 9aa2dcc700c..5c24b8b1c41 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiOffloadTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiOffloadTest.java
@@ -263,7 +263,7 @@ public class AdminApiOffloadTest extends MockedPulsarServiceBaseTest {
pulsarClient.newProducer().topic(topicName).create().close();
OffloadPoliciesImpl offloadPolicies = (OffloadPoliciesImpl) admin.topics().getOffloadPolicies(topicName, true);
OffloadPoliciesImpl brokerPolicies = OffloadPoliciesImpl
- .mergeConfiguration(null,null, pulsar.getConfiguration().getProperties());
+ .mergeConfiguration(null, null, pulsar.getConfiguration().getProperties());
assertEquals(offloadPolicies, brokerPolicies);
//Since off loader is not really set, avoid code exceptions
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaAutoUpdateTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaAutoUpdateTest.java
index 8dd998baadb..cabeb917533 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaAutoUpdateTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaAutoUpdateTest.java
@@ -129,7 +129,7 @@ public class AdminApiSchemaAutoUpdateTest extends MockedPulsarServiceBaseTest {
log.info("try with fully compat");
try (Producer<V4Data> p = pulsarClient.newProducer(Schema.AVRO(V4Data.class)).topic(topicName).create()) {
- p.send(new V4Data("test2", 1, (short)100));
+ p.send(new V4Data("test2", 1, (short) 100));
}
}
@@ -177,11 +177,11 @@ public class AdminApiSchemaAutoUpdateTest extends MockedPulsarServiceBaseTest {
log.info("try with fully compat, again");
try (Producer<V4Data> p = pulsarClient.newProducer(Schema.AVRO(V4Data.class)).topic(topicName).create()) {
- p.send(new V4Data("test2", 1, (short)100));
+ p.send(new V4Data("test2", 1, (short) 100));
}
}
- @AvroAlias(space="blah", alias="data")
+ @AvroAlias(space = "blah", alias = "data")
static class V1Data {
String foo;
int bar;
@@ -193,7 +193,7 @@ public class AdminApiSchemaAutoUpdateTest extends MockedPulsarServiceBaseTest {
}
// backward compatible with V1Data
- @AvroAlias(space="blah", alias="data")
+ @AvroAlias(space = "blah", alias = "data")
static class V2Data {
String foo;
@@ -203,7 +203,7 @@ public class AdminApiSchemaAutoUpdateTest extends MockedPulsarServiceBaseTest {
}
// forward compatible with V1Data
- @AvroAlias(space="blah", alias="data")
+ @AvroAlias(space = "blah", alias = "data")
static class V3Data {
String foo;
int bar;
@@ -217,7 +217,7 @@ public class AdminApiSchemaAutoUpdateTest extends MockedPulsarServiceBaseTest {
}
// fully compatible with V1Data
- @AvroAlias(space="blah", alias="data")
+ @AvroAlias(space = "blah", alias = "data")
static class V4Data {
String foo;
int bar;
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaTest.java
index 34d7dbeb818..54c1be3e204 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaTest.java
@@ -79,11 +79,12 @@ public class AdminApiSchemaTest extends MockedPulsarServiceBaseTest {
super.internalSetup();
// Setup namespaces
- admin.clusters().createCluster(cluster, ClusterData.builder().serviceUrl(pulsar.getWebServiceAddress()).build());
+ admin.clusters().createCluster(cluster, ClusterData.builder()
+ .serviceUrl(pulsar.getWebServiceAddress()).build());
TenantInfoImpl tenantInfo = new TenantInfoImpl(Set.of("role1", "role2"), Set.of("test"));
admin.tenants().createTenant("schematest", tenantInfo);
admin.namespaces().createNamespace("schematest/test", Set.of("test"));
- admin.namespaces().createNamespace("schematest/"+cluster+"/test", Set.of("test"));
+ admin.namespaces().createNamespace("schematest/" + cluster + "/test", Set.of("test"));
admin.namespaces().createNamespace(schemaCompatibilityNamespace, Set.of("test"));
}
@@ -176,13 +177,13 @@ public class AdminApiSchemaTest extends MockedPulsarServiceBaseTest {
SchemaInfo readSi = admin.schemas().getSchemaInfo(topicName);
log.info("Read schema of topic {} : {}", topicName, readSi);
- ((SchemaInfoImpl)readSi).setTimestamp(0);
+ ((SchemaInfoImpl) readSi).setTimestamp(0);
assertEquals(readSi, si);
readSi = admin.schemas().getSchemaInfo(topicName + "-partition-0");
log.info("Read schema of topic {} : {}", topicName, readSi);
- ((SchemaInfoImpl)readSi).setTimestamp(0);
+ ((SchemaInfoImpl) readSi).setTimestamp(0);
assertEquals(readSi, si);
}
@@ -191,14 +192,15 @@ public class AdminApiSchemaTest extends MockedPulsarServiceBaseTest {
public void testPostSchemaCompatibilityStrategy(ApiVersion version) throws PulsarAdminException {
String namespace = format("%s%s%s", "schematest", (ApiVersion.V1.equals(version) ? "/" + cluster + "/" : "/"),
"test");
- String topicName = "persistent://"+namespace + "/testStrategyChange";
+ String topicName = "persistent://" + namespace + "/testStrategyChange";
SchemaInfo fooSchemaInfo = Schema.AVRO(SchemaDefinition.builder()
.withAlwaysAllowNull(false)
.withPojo(Foo.class).build())
.getSchemaInfo();
admin.schemas().createSchema(topicName, fooSchemaInfo);
- admin.namespaces().setSchemaAutoUpdateCompatibilityStrategy(namespace, SchemaAutoUpdateCompatibilityStrategy.Backward);
+ admin.namespaces().setSchemaAutoUpdateCompatibilityStrategy(namespace,
+ SchemaAutoUpdateCompatibilityStrategy.Backward);
SchemaInfo foo1SchemaInfo = Schema.AVRO(SchemaDefinition.builder()
.withAlwaysAllowNull(false)
.withPojo(Foo1.class).build())
@@ -231,14 +233,14 @@ public class AdminApiSchemaTest extends MockedPulsarServiceBaseTest {
SchemaInfoWithVersion readSi = admin.schemas().getSchemaInfoWithVersion(topicName);
log.info("Read schema of topic {} : {}", topicName, readSi);
- ((SchemaInfoImpl)readSi.getSchemaInfo()).setTimestamp(0);
+ ((SchemaInfoImpl) readSi.getSchemaInfo()).setTimestamp(0);
assertEquals(readSi.getSchemaInfo(), si);
assertEquals(readSi.getVersion(), 0);
readSi = admin.schemas().getSchemaInfoWithVersion(topicName + "-partition-0");
log.info("Read schema of topic {} : {}", topicName, readSi);
- ((SchemaInfoImpl)readSi.getSchemaInfo()).setTimestamp(0);
+ ((SchemaInfoImpl) readSi.getSchemaInfo()).setTimestamp(0);
assertEquals(readSi.getSchemaInfo(), si);
assertEquals(readSi.getVersion(), 0);
@@ -248,7 +250,7 @@ public class AdminApiSchemaTest extends MockedPulsarServiceBaseTest {
public void createKeyValueSchema(ApiVersion version) throws Exception {
String namespace = format("%s%s%s", "schematest", (ApiVersion.V1.equals(version) ? "/" + cluster + "/" : "/"),
"test");
- String topicName = "persistent://"+namespace + "/test-key-value-schema";
+ String topicName = "persistent://" + namespace + "/test-key-value-schema";
Schema keyValueSchema = Schema.KeyValue(Schema.AVRO(Foo.class), Schema.AVRO(Foo.class));
admin.schemas().createSchema(topicName, keyValueSchema.getSchemaInfo());
SchemaInfo schemaInfo = admin.schemas().getSchemaInfo(topicName);
@@ -257,7 +259,7 @@ public class AdminApiSchemaTest extends MockedPulsarServiceBaseTest {
assertNotEquals(keyValueSchema.getSchemaInfo().getTimestamp(), timestamp);
assertNotEquals(0, timestamp);
- ((SchemaInfoImpl)keyValueSchema.getSchemaInfo()).setTimestamp(schemaInfo.getTimestamp());
+ ((SchemaInfoImpl) keyValueSchema.getSchemaInfo()).setTimestamp(schemaInfo.getTimestamp());
assertEquals(keyValueSchema.getSchemaInfo(), schemaInfo);
admin.schemas().createSchema(topicName, keyValueSchema.getSchemaInfo());
@@ -270,7 +272,7 @@ public class AdminApiSchemaTest extends MockedPulsarServiceBaseTest {
public void testInvalidSchemaDataException(ApiVersion version) {
String namespace = format("%s%s%s", "schematest", (ApiVersion.V1.equals(version) ? "/" + cluster + "/" : "/"),
"test");
- String topicName = "persistent://"+ namespace + "/test-invalid-schema-data-exception";
+ String topicName = "persistent://" + namespace + "/test-invalid-schema-data-exception";
SchemaInfo schemaInfo = SchemaInfo.builder()
.schema(new byte[0])
.type(SchemaType.AVRO)
@@ -486,15 +488,19 @@ public class AdminApiSchemaTest extends MockedPulsarServiceBaseTest {
IsCompatibilityResponse isCompatibilityResponse =
admin.schemas().testCompatibility(topicName, postSchemaPayload);
assertTrue(isCompatibilityResponse.isCompatibility());
- assertEquals(isCompatibilityResponse.getSchemaCompatibilityStrategy(), SchemaCompatibilityStrategy.FULL.name());
+ assertEquals(isCompatibilityResponse.getSchemaCompatibilityStrategy(),
+ SchemaCompatibilityStrategy.FULL.name());
// set schema compatibility strategy is FULL_TRANSITIVE to cover checkCompatibilityWithAll
- admin.namespaces().setSchemaCompatibilityStrategy(schemaCompatibilityNamespace, SchemaCompatibilityStrategy.FULL_TRANSITIVE);
+ admin.namespaces().setSchemaCompatibilityStrategy(schemaCompatibilityNamespace,
+ SchemaCompatibilityStrategy.FULL_TRANSITIVE);
isCompatibilityResponse = admin.schemas().testCompatibility(topicName, postSchemaPayload);
assertTrue(isCompatibilityResponse.isCompatibility());
- assertEquals(isCompatibilityResponse.getSchemaCompatibilityStrategy(), SchemaCompatibilityStrategy.FULL_TRANSITIVE.name());
+ assertEquals(isCompatibilityResponse.getSchemaCompatibilityStrategy(),
+ SchemaCompatibilityStrategy.FULL_TRANSITIVE.name());
// set back to FULL
- admin.namespaces().setSchemaCompatibilityStrategy(schemaCompatibilityNamespace, SchemaCompatibilityStrategy.FULL);
+ admin.namespaces().setSchemaCompatibilityStrategy(schemaCompatibilityNamespace,
+ SchemaCompatibilityStrategy.FULL);
}
}
}
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaValidationEnforcedTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaValidationEnforcedTest.java
index 180551d14ce..5c7f81892b1 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaValidationEnforcedTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaValidationEnforcedTest.java
@@ -131,7 +131,7 @@ public class AdminApiSchemaValidationEnforcedTest extends MockedPulsarServiceBas
String namespace = "schema-validation-enforced/enable-no-schema";
String topicName = "persistent://schema-validation-enforced/enable-no-schema/test";
assertFalse(admin.namespaces().getSchemaValidationEnforced(namespace));
- admin.namespaces().setSchemaValidationEnforced(namespace,true);
+ admin.namespaces().setSchemaValidationEnforced(namespace, true);
try {
admin.schemas().getSchemaInfo(topicName);
fail();
@@ -149,7 +149,7 @@ public class AdminApiSchemaValidationEnforcedTest extends MockedPulsarServiceBas
String namespace = "schema-validation-enforced/enable-has-schema-mismatch";
String topicName = "persistent://schema-validation-enforced/enable-has-schema-mismatch/test";
assertFalse(admin.namespaces().getSchemaValidationEnforced(namespace));
- admin.namespaces().setSchemaValidationEnforced(namespace,true);
+ admin.namespaces().setSchemaValidationEnforced(namespace, true);
assertTrue(admin.namespaces().getSchemaValidationEnforced(namespace));
admin.topics().createNonPartitionedTopic(topicName);
admin.topics().getStats(topicName);
@@ -190,7 +190,7 @@ public class AdminApiSchemaValidationEnforcedTest extends MockedPulsarServiceBas
} catch (PulsarAdminException.NotFoundException e) {
assertEquals(e.getMessage(), "Schema not found");
}
- admin.namespaces().setSchemaValidationEnforced(namespace,true);
+ admin.namespaces().setSchemaValidationEnforced(namespace, true);
Map<String, String> properties = new HashMap<>();
SchemaInfo schemaInfo = SchemaInfo.builder()
.type(SchemaType.STRING)
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaWithAuthTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaWithAuthTest.java
index 2dcb930fbe7..81bdae3ebb9 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaWithAuthTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaWithAuthTest.java
@@ -132,21 +132,23 @@ public class AdminApiSchemaWithAuthTest extends MockedPulsarServiceBaseTest {
assertThrows(PulsarAdminException.class, () -> adminWithoutPermission.schemas().getSchemaInfo(topicName));
SchemaInfo readSi = adminWithConsumePermission.schemas().getSchemaInfo(topicName);
- ((SchemaInfoImpl)readSi).setTimestamp(0);
+ ((SchemaInfoImpl) readSi).setTimestamp(0);
assertEquals(readSi, si);
assertThrows(PulsarAdminException.class, () -> adminWithoutPermission.schemas().getSchemaInfo(topicName, 0));
readSi = adminWithConsumePermission.schemas().getSchemaInfo(topicName, 0);
- ((SchemaInfoImpl)readSi).setTimestamp(0);
+ ((SchemaInfoImpl) readSi).setTimestamp(0);
assertEquals(readSi, si);
List<SchemaInfo> allSchemas = adminWithConsumePermission.schemas().getAllSchemas(topicName);
assertEquals(allSchemas.size(), 1);
SchemaInfo schemaInfo2 = Schema.BOOL.getSchemaInfo();
- assertThrows(PulsarAdminException.class, () -> adminWithoutPermission.schemas().testCompatibility(topicName, schemaInfo2));
+ assertThrows(PulsarAdminException.class, () -> adminWithoutPermission.schemas()
+ .testCompatibility(topicName, schemaInfo2));
assertTrue(adminWithAdminPermission.schemas().testCompatibility(topicName, schemaInfo2).isCompatibility());
- assertThrows(PulsarAdminException.class, () -> adminWithoutPermission.schemas().getVersionBySchema(topicName, si));
+ assertThrows(PulsarAdminException.class, () -> adminWithoutPermission.schemas()
+ .getVersionBySchema(topicName, si));
Long versionBySchema = adminWithConsumePermission.schemas().getVersionBySchema(topicName, si);
assertEquals(versionBySchema, Long.valueOf(0L));
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSubscriptionTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSubscriptionTest.java
index 994e0eb2325..7c466b12f97 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSubscriptionTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSubscriptionTest.java
@@ -21,7 +21,6 @@ package org.apache.pulsar.broker.admin;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.expectThrows;
-
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -153,7 +152,8 @@ public class AdminApiSubscriptionTest extends MockedPulsarServiceBaseTest {
.getSubscriptions().get(subscriptionName);
assertEquals(value, subscriptionStats.getSubscriptionProperties().get("foo"));
- Map<String, String> props = admin.topics().getSubscriptionProperties(topic + "-partition-" + i, subscriptionName);
+ Map<String, String> props = admin.topics().getSubscriptionProperties(topic + "-partition-" + i,
+ subscriptionName);
assertEquals(value, props.get("foo"));
}
@@ -163,7 +163,8 @@ public class AdminApiSubscriptionTest extends MockedPulsarServiceBaseTest {
.getSubscriptions().get(subscriptionName2);
assertTrue(subscriptionStats.getSubscriptionProperties().isEmpty());
- Map<String, String> props = admin.topics().getSubscriptionProperties(topic + "-partition-" + i, subscriptionName2);
+ Map<String, String> props = admin.topics().getSubscriptionProperties(topic + "-partition-" + i,
+ subscriptionName2);
assertTrue(props.isEmpty());
}
@@ -176,13 +177,15 @@ public class AdminApiSubscriptionTest extends MockedPulsarServiceBaseTest {
assertEquals(value, props.get("foo"));
} else {
- SubscriptionStats subscriptionStats = admin.topics().getStats(topic).getSubscriptions().get(subscriptionName);
+ SubscriptionStats subscriptionStats = admin.topics().getStats(topic)
+ .getSubscriptions().get(subscriptionName);
assertEquals(value, subscriptionStats.getSubscriptionProperties().get("foo"));
Map<String, String> props = admin.topics().getSubscriptionProperties(topic, subscriptionName);
assertEquals(value, props.get("foo"));
- SubscriptionStats subscriptionStats2 = admin.topics().getStats(topic).getSubscriptions().get(subscriptionName2);
+ SubscriptionStats subscriptionStats2 = admin.topics().getStats(topic)
+ .getSubscriptions().get(subscriptionName2);
assertTrue(subscriptionStats2.getSubscriptionProperties().isEmpty());
Map<String, String> props2 = admin.topics().getSubscriptionProperties(topic, subscriptionName2);
@@ -199,7 +202,8 @@ public class AdminApiSubscriptionTest extends MockedPulsarServiceBaseTest {
.getSubscriptions().get(subscriptionName);
assertTrue(subscriptionStats.getSubscriptionProperties().isEmpty());
- Map<String, String> props = admin.topics().getSubscriptionProperties(topic + "-partition-" + i, subscriptionName);
+ Map<String, String> props = admin.topics().getSubscriptionProperties(topic + "-partition-" + i,
+ subscriptionName);
assertTrue(props.isEmpty());
}
@@ -212,7 +216,8 @@ public class AdminApiSubscriptionTest extends MockedPulsarServiceBaseTest {
assertTrue(props.isEmpty());
} else {
- SubscriptionStats subscriptionStats = admin.topics().getStats(topic).getSubscriptions().get(subscriptionName);
+ SubscriptionStats subscriptionStats = admin.topics().getStats(topic)
+ .getSubscriptions().get(subscriptionName);
assertTrue(subscriptionStats.getSubscriptionProperties().isEmpty());
Map<String, String> props = admin.topics().getSubscriptionProperties(topic, subscriptionName);
@@ -229,7 +234,8 @@ public class AdminApiSubscriptionTest extends MockedPulsarServiceBaseTest {
.getSubscriptions().get(subscriptionName);
assertEquals(value, subscriptionStats.getSubscriptionProperties().get("foo"));
- Map<String, String> props = admin.topics().getSubscriptionProperties(topic + "-partition-" + i, subscriptionName);
+ Map<String, String> props = admin.topics().getSubscriptionProperties(topic + "-partition-" + i,
+ subscriptionName);
assertEquals(value, props.get("foo"));
}
@@ -242,13 +248,15 @@ public class AdminApiSubscriptionTest extends MockedPulsarServiceBaseTest {
assertEquals(value, props.get("foo"));
} else {
- SubscriptionStats subscriptionStats = admin.topics().getStats(topic).getSubscriptions().get(subscriptionName);
+ SubscriptionStats subscriptionStats = admin.topics().getStats(topic)
+ .getSubscriptions().get(subscriptionName);
assertEquals(value, subscriptionStats.getSubscriptionProperties().get("foo"));
Map<String, String> props = admin.topics().getSubscriptionProperties(topic, subscriptionName);
assertEquals(value, props.get("foo"));
- SubscriptionStats subscriptionStats2 = admin.topics().getStats(topic).getSubscriptions().get(subscriptionName2);
+ SubscriptionStats subscriptionStats2 = admin.topics().getStats(topic)
+ .getSubscriptions().get(subscriptionName2);
assertTrue(subscriptionStats2.getSubscriptionProperties().isEmpty());
Map<String, String> props2 = admin.topics().getSubscriptionProperties(topic, subscriptionName2);
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTenantTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTenantTest.java
index 1750929be3b..974ed6df696 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTenantTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTenantTest.java
@@ -37,7 +37,7 @@ import org.testng.annotations.Test;
@Test(groups = "broker-admin")
@Slf4j
public class AdminApiTenantTest extends MockedPulsarServiceBaseTest {
- private final String CLUSTER = "test";
+ private static final String CLUSTER = "test";
@BeforeClass
@Override
@@ -60,8 +60,9 @@ public class AdminApiTenantTest extends MockedPulsarServiceBaseTest {
@Test
public void testCreateAndDeleteTenant() throws PulsarAdminException {
- String tenant = "test-tenant-"+ UUID.randomUUID();
- admin.tenants().createTenant(tenant, TenantInfo.builder().allowedClusters(Collections.singleton(CLUSTER)).build());
+ String tenant = "test-tenant-" + UUID.randomUUID();
+ admin.tenants().createTenant(tenant, TenantInfo.builder()
+ .allowedClusters(Collections.singleton(CLUSTER)).build());
List<String> tenants = admin.tenants().getTenants();
assertTrue(tenants.contains(tenant));
admin.tenants().deleteTenant(tenant);
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTest.java
index d60ac3c32ef..76de965ceca 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTest.java
@@ -194,7 +194,8 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
conf.setNumExecutorThreadPoolSize(5);
}
- private void setupConfigAndStart(java.util.function.Consumer<ServiceConfiguration> configurationConsumer) throws Exception {
+ private void setupConfigAndStart(java.util.function.Consumer<ServiceConfiguration> configurationConsumer)
+ throws Exception {
applyDefaultConfig();
if (configurationConsumer != null) {
configurationConsumer.accept(conf);
@@ -327,7 +328,8 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
// Check name validation
try {
- admin.clusters().createCluster("bf!", ClusterData.builder().serviceUrl("http://dummy.messaging.example.com").build());
+ admin.clusters().createCluster("bf!", ClusterData.builder()
+ .serviceUrl("http://dummy.messaging.example.com").build());
fail("should have failed");
} catch (PulsarAdminException e) {
assertTrue(e instanceof PreconditionFailedException);
@@ -374,7 +376,8 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
admin.clusters().createNamespaceIsolationPolicy("test", policyName2, nsPolicyData2);
// verify create indirectly with get
- Map<String, ? extends NamespaceIsolationData> policiesMap = admin.clusters().getNamespaceIsolationPolicies("test");
+ Map<String, ? extends NamespaceIsolationData> policiesMap = admin.clusters()
+ .getNamespaceIsolationPolicies("test");
assertEquals(policiesMap.get(policyName1), nsPolicyData1);
assertEquals(policiesMap.get(policyName2), nsPolicyData2);
@@ -413,7 +416,8 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
assertEquals(policiesMap.get(policyName1), nsPolicyData1);
// verify single get
- NamespaceIsolationDataImpl policy1Data = (NamespaceIsolationDataImpl) admin.clusters().getNamespaceIsolationPolicy("test", policyName1);
+ NamespaceIsolationDataImpl policy1Data = (NamespaceIsolationDataImpl) admin.clusters()
+ .getNamespaceIsolationPolicy("test", policyName1);
assertEquals(policy1Data, nsPolicyData1);
// verify creation of more than one policy
@@ -499,7 +503,7 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
try {
admin.clusters().createNamespaceIsolationPolicy("test", "invalid_primary", nsRegexPolicy.build());
fail("should have failed with invalid regex");
- }catch (PulsarAdminException e) {
+ } catch (PulsarAdminException e) {
//Ok
}
@@ -844,12 +848,14 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
Policies policies = new Policies();
policies.replication_clusters = Set.of("test");
policies.bundles = PoliciesUtil.defaultBundle();
- policies.auth_policies.getNamespaceAuthentication().put("spiffe://developer/passport-role", EnumSet.allOf(AuthAction.class));
+ policies.auth_policies.getNamespaceAuthentication().put("spiffe://developer/passport-role",
+ EnumSet.allOf(AuthAction.class));
policies.auth_policies.getNamespaceAuthentication().put("my-role", EnumSet.allOf(AuthAction.class));
policies.is_allow_auto_update_schema = conf.isAllowAutoUpdateSchemaEnabled();
assertEquals(admin.namespaces().getPolicies("prop-xyz/ns1"), policies);
- assertEquals(admin.namespaces().getPermissions("prop-xyz/ns1"), policies.auth_policies.getNamespaceAuthentication());
+ assertEquals(admin.namespaces().getPermissions("prop-xyz/ns1"),
+ policies.auth_policies.getNamespaceAuthentication());
assertEquals(admin.namespaces().getTopics("prop-xyz/ns1"), new ArrayList<>());
@@ -1028,7 +1034,7 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
@SneakyThrows
@Override
public void received(Consumer<byte[]> consumer, Message<byte[]> msg) {
- if (total.get() %2 !=0){
+ if (total.get() % 2 != 0){
// artificially created 50 hollow messages
consumer.acknowledge(msg);
}
@@ -1044,7 +1050,7 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
TimeUnit.SECONDS.sleep(2);
TopicStats topicStats = admin.topics().getStats(persistentTopicName);
long msgBacklog = topicStats.getSubscriptions().get(subName).getMsgBacklog();
- log.info("back={}",msgBacklog);
+ log.info("back={}", msgBacklog);
int skipNumber = 20;
admin.topics().skipMessages(persistentTopicName, subName, skipNumber);
topicStats = admin.topics().getStats(persistentTopicName);
@@ -1170,9 +1176,9 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
} catch (NotFoundException expected) {
}
- PartitionedTopicStats topicStats = admin.topics().getPartitionedStats(partitionedTopicName,false);
+ PartitionedTopicStats topicStats = admin.topics().getPartitionedStats(partitionedTopicName, false);
- // check the getPartitionedStats for PartitionedTopic returns only partitions metadata, and no partitions info
+ // check the getPartitionedStats for PartitionedTopic returns only partitions metadata, and no partitions info
assertEquals(admin.topics().getPartitionedTopicMetadata(partitionedTopicName).partitions,
topicStats.getMetadata().partitions);
@@ -1238,7 +1244,7 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
partitionedTopicName + "-partition-2", partitionedTopicName + "-partition-3"));
// test cumulative stats for partitioned topic
- topicStats = admin.topics().getPartitionedStats(partitionedTopicName,false);
+ topicStats = admin.topics().getPartitionedStats(partitionedTopicName, false);
if (isPersistent) {
// TODO: for non-persistent topics, the subscription doesn't exist
assertEquals(topicStats.getSubscriptions().keySet(), Set.of("my-sub"));
@@ -1249,7 +1255,7 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
assertEquals(topicStats.getPartitions(), new HashMap<>());
// test per partition stats for partitioned topic
- topicStats = admin.topics().getPartitionedStats(partitionedTopicName,true);
+ topicStats = admin.topics().getPartitionedStats(partitionedTopicName, true);
assertEquals(topicStats.getMetadata().partitions, 4);
assertEquals(topicStats.getPartitions().keySet(),
Set.of(partitionedTopicName + "-partition-0", partitionedTopicName + "-partition-1",
@@ -1362,7 +1368,8 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
partitionedManagedLedgerInfo.partitions.put(partitionTopic1,
ObjectMapperFactory.getMapper().reader().readValue(partitionTopic1InfoResponse, ManagedLedgerInfo.class));
- String expectedResult = ObjectMapperFactory.getMapper().writer().writeValueAsString(partitionedManagedLedgerInfo);
+ String expectedResult = ObjectMapperFactory.getMapper()
+ .writer().writeValueAsString(partitionedManagedLedgerInfo);
String partitionTopicInfoResponse = admin.topics().getInternalInfo(partitionedTopicName);
assertEquals(partitionTopicInfoResponse, expectedResult);
@@ -1454,12 +1461,14 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
// expected internal stats
PartitionedTopicMetadata partitionedTopicMetadata = new PartitionedTopicMetadata(2);
- PartitionedTopicInternalStats expectedInternalStats = new PartitionedTopicInternalStats(partitionedTopicMetadata);
+ PartitionedTopicInternalStats expectedInternalStats =
+ new PartitionedTopicInternalStats(partitionedTopicMetadata);
expectedInternalStats.partitions.put(partitionTopic0, internalStats0);
expectedInternalStats.partitions.put(partitionTopic1, internalStats1);
// partitioned internal stats
- PartitionedTopicInternalStats partitionedInternalStats = admin.topics().getPartitionedInternalStats(partitionedTopicName);
+ PartitionedTopicInternalStats partitionedInternalStats = admin.topics()
+ .getPartitionedInternalStats(partitionedTopicName);
String expectedResult = ObjectMapperFactory.getMapper().writer().writeValueAsString(expectedInternalStats);
String result = ObjectMapperFactory.getMapper().writer().writeValueAsString(partitionedInternalStats);
@@ -1670,8 +1679,10 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
// Force to create a topic
final String namespace = "prop-xyz/ns1";
List<String> topicNames = List.of(
- (new StringBuilder("persistent://")).append(namespace).append("/topicCountEquallyDivideAlgorithum-1").toString(),
- (new StringBuilder("persistent://")).append(namespace).append("/topicCountEquallyDivideAlgorithum-2").toString());
+ (new StringBuilder("persistent://")).append(namespace)
+ .append("/topicCountEquallyDivideAlgorithum-1").toString(),
+ (new StringBuilder("persistent://")).append(namespace)
+ .append("/topicCountEquallyDivideAlgorithum-2").toString());
List<Producer<byte[]>> producers = new ArrayList<>(2);
for (String topicName : topicNames) {
@@ -1709,7 +1720,7 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
public void testNamespacesGetTopicHashPositions() throws Exception {
// Force to create a namespace with only one bundle and create a topic
final String namespace = "prop-xyz/ns-one-bundle";
- final String topic = "persistent://"+ namespace + "/topic";
+ final String topic = "persistent://" + namespace + "/topic";
final int topicPartitionNumber = 4;
Policies policies = new Policies();
@@ -1799,7 +1810,7 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
public void testNamespaceSplitBundleWithSpecifiedPositionsDivideAlgorithm() throws Exception {
// 1. Force to create a topic
final String namespace = "prop-xyz/ns-one-bundle";
- final String topic = "persistent://"+ namespace + "/topic";
+ final String topic = "persistent://" + namespace + "/topic";
final int topicPartitionNumber = 4;
Policies policies = new Policies();
@@ -1841,7 +1852,7 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
Collections.sort(hashPositions);
String[] splitRange = {
- "0x00000000_" + String.format("0x%08x",hashPositions.get(0)),
+ "0x00000000_" + String.format("0x%08x", hashPositions.get(0)),
String.format("0x%08x", hashPositions.get(0)) + "_" + String.format("0x%08x", hashPositions.get(1)),
String.format("0x%08x", hashPositions.get(1)) + "_" + String.format("0x%08x", hashPositions.get(2)),
String.format("0x%08x", hashPositions.get(2)) + "_" + String.format("0x%08x", hashPositions.get(3)),
@@ -1870,10 +1881,14 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
// 9. test split at full upper and lower boundaries
List<Long> fullBoundaries =
Lists.newArrayList(NamespaceBundles.FULL_UPPER_BOUND, NamespaceBundles.FULL_UPPER_BOUND);
- admin.namespaces().splitNamespaceBundle(namespace, "0x00000000_" + String.format("0x%08x",hashPositions.get(0)),
- false, NamespaceBundleSplitAlgorithm.SPECIFIED_POSITIONS_DIVIDE, fullBoundaries);
- admin.namespaces().splitNamespaceBundle(namespace, String.format("0x%08x", hashPositions.get(3)) + "_0xffffffff",
- false, NamespaceBundleSplitAlgorithm.SPECIFIED_POSITIONS_DIVIDE, fullBoundaries);
+ admin.namespaces().splitNamespaceBundle(namespace,
+ "0x00000000_" + String.format("0x%08x", hashPositions.get(0)),
+ false, NamespaceBundleSplitAlgorithm.SPECIFIED_POSITIONS_DIVIDE,
+ fullBoundaries);
+ admin.namespaces().splitNamespaceBundle(namespace,
+ String.format("0x%08x", hashPositions.get(3)) + "_0xffffffff",
+ false, NamespaceBundleSplitAlgorithm.SPECIFIED_POSITIONS_DIVIDE,
+ fullBoundaries);
// 10. full upper or lower boundaries does not split bundle
NamespaceBundles nbs = bundleFactory.getBundles(NamespaceName.get(namespace));
@@ -1904,8 +1919,10 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
// Force to create a topic
final String namespace = "prop-xyz/ns1";
List<String> topicNames = Lists.newArrayList(
- (new StringBuilder("persistent://")).append(namespace).append("/topicCountEquallyDivideAlgorithum-1").toString(),
- (new StringBuilder("persistent://")).append(namespace).append("/topicCountEquallyDivideAlgorithum-2").toString());
+ (new StringBuilder("persistent://")).append(namespace)
+ .append("/topicCountEquallyDivideAlgorithum-1").toString(),
+ (new StringBuilder("persistent://")).append(namespace)
+ .append("/topicCountEquallyDivideAlgorithum-2").toString());
List<Producer<byte[]>> producers = new ArrayList<>(2);
for (String topicName : topicNames) {
@@ -2858,7 +2875,8 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
admin.topics().expireMessages("persistent://prop-xyz/ns1/ds2", "my-sub1", 1);
// Wait at most 2 seconds for sub1's message to expire.
Awaitility.await().untilAsserted(() -> assertTrue(
- admin.topics().getStats("persistent://prop-xyz/ns1/ds2").getSubscriptions().get("my-sub1").getLastMarkDeleteAdvancedTimestamp() > 0L));
+ admin.topics().getStats("persistent://prop-xyz/ns1/ds2").getSubscriptions()
+ .get("my-sub1").getLastMarkDeleteAdvancedTimestamp() > 0L));
topicStats = admin.topics().getStats("persistent://prop-xyz/ns1/ds2");
SubscriptionStats subStats1 = topicStats.getSubscriptions().get("my-sub1");
assertEquals(subStats1.getMsgBacklog(), 0);
@@ -2873,7 +2891,8 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
messageIds.get(4), false);
// Wait at most 2 seconds for sub2's message to expire.
Awaitility.await().untilAsserted(() -> assertTrue(
- admin.topics().getStats("persistent://prop-xyz/ns1/ds2").getSubscriptions().get("my-sub2").getLastMarkDeleteAdvancedTimestamp() > 0L));
+ admin.topics().getStats("persistent://prop-xyz/ns1/ds2")
+ .getSubscriptions().get("my-sub2").getLastMarkDeleteAdvancedTimestamp() > 0L));
topicStats = admin.topics().getStats("persistent://prop-xyz/ns1/ds2");
subStats1 = topicStats.getSubscriptions().get("my-sub1");
assertEquals(subStats1.getMsgBacklog(), 0);
@@ -2893,7 +2912,8 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
}
// Wait at most 2 seconds for sub3's message to expire.
Awaitility.await().untilAsserted(() -> assertTrue(
- admin.topics().getStats("persistent://prop-xyz/ns1/ds2").getSubscriptions().get("my-sub3").getLastMarkDeleteAdvancedTimestamp() > 0L));
+ admin.topics().getStats("persistent://prop-xyz/ns1/ds2")
+ .getSubscriptions().get("my-sub3").getLastMarkDeleteAdvancedTimestamp() > 0L));
topicStats = admin.topics().getStats("persistent://prop-xyz/ns1/ds2");
subStats1 = topicStats.getSubscriptions().get("my-sub1");
assertEquals(subStats1.getMsgBacklog(), 0);
@@ -2940,7 +2960,7 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
}
/**
- * Verify: PersistentTopicsBase.expireMessages()/expireMessagesForAllSubscriptions() for PartitionTopic
+ * Verify: PersistentTopicsBase.expireMessages()/expireMessagesForAllSubscriptions() for PartitionTopic.
*
* @throws Exception
*/
@@ -3129,7 +3149,8 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
// (3) Get Topic Stats
final CompletableFuture<TopicStats> urlStats = new CompletableFuture<>();
// (a) Url encoding
- persistent.asyncGetRequest(persistentTopics.path("persistent").path(ns1).path(urlEncodedTopic + "-partition-1").path("stats"),
+ persistent.asyncGetRequest(persistentTopics.path("persistent").path(ns1)
+ .path(urlEncodedTopic + "-partition-1").path("stats"),
new InvocationCallback<TopicStats>() {
@Override
public void completed(TopicStats response) {
@@ -3218,7 +3239,7 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
// mock actual compaction, we don't need to really run it
CompletableFuture<Long> promise = new CompletableFuture<Long>();
- Compactor compactor = ((PulsarCompactionServiceFactory)pulsar.getCompactionServiceFactory()).getCompactor();
+ Compactor compactor = ((PulsarCompactionServiceFactory) pulsar.getCompactionServiceFactory()).getCompactor();
doReturn(promise).when(compactor).compact(topicName);
admin.topics().triggerCompaction(topicName);
@@ -3254,7 +3275,7 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
// mock actual compaction, we don't need to really run it
CompletableFuture<Long> promise = new CompletableFuture<>();
- Compactor compactor = ((PulsarCompactionServiceFactory)pulsar.getCompactionServiceFactory()).getCompactor();
+ Compactor compactor = ((PulsarCompactionServiceFactory) pulsar.getCompactionServiceFactory()).getCompactor();
doReturn(promise).when(compactor).compact(topicName + "-partition-0");
CompletableFuture<Long> promise1 = new CompletableFuture<>();
@@ -3298,7 +3319,7 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
// mock actual compaction, we don't need to really run it
CompletableFuture<Long> promise = new CompletableFuture<Long>();
- Compactor compactor = ((PulsarCompactionServiceFactory)pulsar.getCompactionServiceFactory()).getCompactor();
+ Compactor compactor = ((PulsarCompactionServiceFactory) pulsar.getCompactionServiceFactory()).getCompactor();
doReturn(promise).when(compactor).compact(topicName);
admin.topics().triggerCompaction(topicName);
@@ -3321,7 +3342,8 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
}
@Test(timeOut = 20000)
- public void testTopicStatsLastExpireTimestampForSubscription() throws PulsarAdminException, PulsarClientException, InterruptedException {
+ public void testTopicStatsLastExpireTimestampForSubscription() throws PulsarAdminException,
+ PulsarClientException, InterruptedException {
admin.namespaces().setNamespaceMessageTTL("prop-xyz/ns1", 10);
final String topic = "persistent://prop-xyz/ns1/testTopicStatsLastExpireTimestampForSubscription";
@Cleanup
@@ -3339,11 +3361,13 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
.subscribe();
Assert.assertEquals(admin.topics().getStats(topic).getSubscriptions().size(), 1);
- Assert.assertEquals(admin.topics().getStats(topic).getSubscriptions().values().iterator().next().getLastExpireTimestamp(), 0L);
+ Assert.assertEquals(admin.topics().getStats(topic).getSubscriptions().values().iterator()
+ .next().getLastExpireTimestamp(), 0L);
Thread.sleep(10000);
// Update policy to trigger message expiry check.
admin.namespaces().setNamespaceMessageTTL("prop-xyz/ns1", 5);
- Awaitility.await().until(() -> admin.topics().getStats(topic).getSubscriptions().values().iterator().next().getLastExpireTimestamp() > 0L);
+ Awaitility.await().until(() -> admin.topics().getStats(topic).getSubscriptions()
+ .values().iterator().next().getLastExpireTimestamp() > 0L);
}
@Test(timeOut = 150000)
@@ -3449,7 +3473,8 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
@Test
public void testPartitionedTopicMsgDelayedAggregated() throws Exception {
- final String topic = "persistent://prop-xyz/ns1/testPartitionedTopicMsgDelayedAggregated-" + UUID.randomUUID().toString();
+ final String topic = "persistent://prop-xyz/ns1/testPartitionedTopicMsgDelayedAggregated-"
+ + UUID.randomUUID().toString();
final String subName = "my-sub";
final int numPartitions = 2;
cleanup();
@@ -3497,7 +3522,7 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
long sumMsgBacklog = 0;
long sumMsgBacklogNoDelayed = 0;
long sumMsgDelayed = 0;
- for(TopicStats stats: partitionedTopicStats.getPartitions().values()){
+ for (TopicStats stats: partitionedTopicStats.getPartitions().values()){
Assert.assertNotNull(stats);
SubscriptionStats partitionedSubStats = stats.getSubscriptions().get(subName);
Assert.assertNotNull(partitionedSubStats);
@@ -3515,8 +3540,9 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
public void testPartitionedTopicTruncate() throws Exception {
final String topicName = "persistent://prop-xyz/ns1/testTruncateTopic2-" + UUID.randomUUID().toString();
final String subName = "my-sub";
- admin.topics().createPartitionedTopic(topicName,6);
- admin.namespaces().setRetention("prop-xyz/ns1", new RetentionPolicies(60, 50));
+ admin.topics().createPartitionedTopic(topicName, 6);
+ admin.namespaces().setRetention("prop-xyz/ns1",
+ new RetentionPolicies(60, 50));
List<MessageId> messageIds = publishMessagesOnPersistentTopic(topicName, 10);
admin.topics().createSubscription(topicName, subName, messageIds.get(0));
admin.topics().unload(topicName);
@@ -3541,7 +3567,8 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
conf.setSystemTopicEnabled(true);
});
admin.topics().createNonPartitionedTopic(topicName);
- admin.namespaces().setRetention("prop-xyz/ns1", new RetentionPolicies(60, 50));
+ admin.namespaces().setRetention("prop-xyz/ns1",
+ new RetentionPolicies(60, 50));
List<MessageId> messageIds = publishMessagesOnPersistentTopic(topicName, 10);
admin.topics().createSubscription(topicName, subName, messageIds.get(0));
admin.topics().unload(topicName);
@@ -3557,7 +3584,9 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
public void testNonPersistentTopicTruncate() throws Exception {
final String topicName = "non-persistent://prop-xyz/ns1/testTruncateTopic3-" + UUID.randomUUID().toString();
admin.topics().createNonPartitionedTopic(topicName);
- assertThrows(() -> {admin.topics().truncate(topicName);});
+ assertThrows(() -> {
+ admin.topics().truncate(topicName);
+ });
}
@Test(timeOut = 20000)
@@ -3674,7 +3703,8 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
final String topic = "persistent://" + namespace + random;
final String subject = UUID.randomUUID().toString();
assertThrows(NotFoundException.class, () -> admin.topics().getPermissions(topic));
- assertThrows(NotFoundException.class, () -> admin.topics().grantPermission(topic, subject, Set.of(AuthAction.produce)));
+ assertThrows(NotFoundException.class, () -> admin.topics().grantPermission(topic,
+ subject, Set.of(AuthAction.produce)));
assertThrows(NotFoundException.class, () -> admin.topics().revokePermissions(topic, subject));
}
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTlsAuthTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTlsAuthTest.java
index 47bfd3d7bfa..9d7bbfc3242 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTlsAuthTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTlsAuthTest.java
@@ -84,7 +84,8 @@ public class AdminApiTlsAuthTest extends MockedPulsarServiceBaseTest {
conf.setBrokerClientAuthenticationPlugin("org.apache.pulsar.client.impl.auth.AuthenticationTls");
conf.setBrokerClientAuthenticationParameters(
- String.format("tlsCertFile:%s,tlsKeyFile:%s", getTlsFileForClient("admin.cert"), getTlsFileForClient("admin.key-pk8")));
+ String.format("tlsCertFile:%s,tlsKeyFile:%s", getTlsFileForClient("admin.cert"),
+ getTlsFileForClient("admin.key-pk8")));
conf.setBrokerClientTrustCertsFilePath(CA_CERT_FILE_PATH);
conf.setBrokerClientTlsEnabled(true);
conf.setNumExecutorThreadPoolSize(5);
@@ -473,7 +474,8 @@ public class AdminApiTlsAuthTest extends MockedPulsarServiceBaseTest {
Path keyFilePath = Paths.get(keyFile.getAbsolutePath());
int autoCertRefreshTimeSec = 1;
try {
- Files.copy(Paths.get(getTlsFileForClient(user2 + ".key-pk8")), keyFilePath, StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(Paths.get(getTlsFileForClient(user2 + ".key-pk8")), keyFilePath,
+ StandardCopyOption.REPLACE_EXISTING);
@Cleanup
PulsarAdmin admin = PulsarAdmin.builder()
.allowTlsInsecureConnection(false)
@@ -503,7 +505,7 @@ public class AdminApiTlsAuthTest extends MockedPulsarServiceBaseTest {
new TenantInfoImpl(Set.of("foobar"), Set.of("test")));
success.setValue(true);
return true;
- }catch(Exception e) {
+ } catch (Exception e) {
return false;
}
}, 5, 1000);
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminResourceTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminResourceTest.java
index 68e1172f01d..d4980426f68 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminResourceTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminResourceTest.java
@@ -21,7 +21,6 @@ package org.apache.pulsar.broker.admin;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
-
import javax.ws.rs.core.Response.Status;
import org.apache.pulsar.broker.service.BrokerTestBase;
import org.apache.pulsar.broker.web.RestException;
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminRestTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminRestTest.java
index 6d199c1c426..57a4fc32dd7 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminRestTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminRestTest.java
@@ -60,7 +60,7 @@ public class AdminRestTest extends MockedPulsarServiceBaseTest {
Client client = ClientBuilder.newClient();
WebTarget target = client.target("http://127.0.0.1:" + port
+ "/admin/v2/persistent/" + namespaceName + "/" + topicNameSuffix + "/retention");
- Map<String,Object> data = new HashMap<>();
+ Map<String, Object> data = new HashMap<>();
data.put("retention_size_in_mb", -1);
data.put("retention_time_in_minutes", 40320);
// Configuration default, response success.
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminTest.java
index 2894903c0d0..dbff93319a0 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminTest.java
@@ -616,7 +616,8 @@ public class AdminTest extends MockedPulsarServiceBaseTest {
.build();
response = asyncRequests(ctx -> properties.createTenant(ctx, "my-tenant", newPropertyAdmin2));
- response = asyncRequests(ctx -> namespaces.createNamespace(ctx,"my-tenant", "use", "my-namespace", BundlesData.builder().build()));
+ response = asyncRequests(ctx -> namespaces.createNamespace(ctx, "my-tenant",
+ "use", "my-namespace", BundlesData.builder().build()));
try {
response = asyncRequests(ctx -> properties.deleteTenant(ctx, "my-tenant", false));
@@ -649,7 +650,8 @@ public class AdminTest extends MockedPulsarServiceBaseTest {
.allowedClusters(blankClusters)
.build();
try {
- response = asyncRequests(ctx -> properties.createTenant(ctx, "tenant-config-is-empty", tenantWithEmptyCluster));
+ response = asyncRequests(ctx -> properties.createTenant(ctx,
+ "tenant-config-is-empty", tenantWithEmptyCluster));
fail("should have failed");
} catch (RestException e) {
assertEquals(e.getResponse().getStatus(), Status.PRECONDITION_FAILED.getStatusCode());
@@ -663,7 +665,8 @@ public class AdminTest extends MockedPulsarServiceBaseTest {
.allowedClusters(containBlankClusters)
.build();
try {
- response = asyncRequests(ctx -> properties.createTenant(ctx, "tenant-config-contain-empty", tenantContainEmptyCluster));
+ response = asyncRequests(ctx -> properties.createTenant(ctx,
+ "tenant-config-contain-empty", tenantContainEmptyCluster));
fail("should have failed");
} catch (RestException e) {
assertEquals(e.getResponse().getStatus(), Status.PRECONDITION_FAILED.getStatusCode());
@@ -673,7 +676,7 @@ public class AdminTest extends MockedPulsarServiceBaseTest {
int maxTenants = pulsar.getConfiguration().getMaxTenants();
List<String> tenants = pulsar.getPulsarResources().getTenantResources().listTenants();
- for(int tenantSize = tenants.size();tenantSize < maxTenants; tenantSize++ ){
+ for (int tenantSize = tenants.size(); tenantSize < maxTenants; tenantSize++) {
final int tenantIndex = tenantSize;
Response obj = (Response) asyncRequests(ctx ->
properties.createTenant(ctx, "test-tenant-" + tenantIndex, tenantInfo));
@@ -689,7 +692,8 @@ public class AdminTest extends MockedPulsarServiceBaseTest {
// Check creating existing property when tenant reach max count.
try {
- response = asyncRequests(ctx -> properties.createTenant(ctx, "test-tenant-" + (maxTenants-1), tenantInfo));
+ response = asyncRequests(ctx -> properties.createTenant(ctx,
+ "test-tenant-" + (maxTenants - 1), tenantInfo));
fail("should have failed");
} catch (RestException e) {
assertEquals(e.getResponse().getStatus(), Status.CONFLICT.getStatusCode());
@@ -725,7 +729,7 @@ public class AdminTest extends MockedPulsarServiceBaseTest {
assertEquals(activeBrokers, Set.of(pulsar.getBrokerId()));
Object leaderBrokerRes = asyncRequests(ctx -> brokers.getLeaderBroker(ctx));
assertTrue(leaderBrokerRes instanceof BrokerInfo);
- BrokerInfo leaderBroker = (BrokerInfo)leaderBrokerRes;
+ BrokerInfo leaderBroker = (BrokerInfo) leaderBrokerRes;
assertEquals(leaderBroker.getBrokerId(),
pulsar.getLeaderElectionService().getCurrentLeader().map(LeaderBroker::getBrokerId).get());
}
@@ -752,19 +756,23 @@ public class AdminTest extends MockedPulsarServiceBaseTest {
String namespace = "ns";
String bundleRange = "0x00000000_0xffffffff";
Policies policies = new Policies();
- doReturn(policies).when(resourceQuotas).getNamespacePolicies(NamespaceName.get(property, cluster, namespace));
- doReturn(CompletableFuture.completedFuture(policies)).when(resourceQuotas).getNamespacePoliciesAsync(NamespaceName.get(property, cluster, namespace));
+ doReturn(policies).when(resourceQuotas).getNamespacePolicies(
+ NamespaceName.get(property, cluster, namespace));
+ doReturn(CompletableFuture.completedFuture(policies)).when(resourceQuotas)
+ .getNamespacePoliciesAsync(NamespaceName.get(property, cluster, namespace));
doReturn("client-id").when(resourceQuotas).clientAppId();
try {
- asyncRequests(ctx -> resourceQuotas.setNamespaceBundleResourceQuota(ctx, property, cluster, namespace, bundleRange, quota));
+ asyncRequests(ctx -> resourceQuotas.setNamespaceBundleResourceQuota(
+ ctx, property, cluster, namespace, bundleRange, quota));
fail();
} catch (Exception e) {
// OK : should fail without creating policies
}
try {
- asyncRequests(ctx -> resourceQuotas.removeNamespaceBundleResourceQuota(ctx, property, cluster, namespace, bundleRange));
+ asyncRequests(ctx -> resourceQuotas.removeNamespaceBundleResourceQuota(
+ ctx, property, cluster, namespace, bundleRange));
fail();
} catch (Exception e) {
// OK : should fail without creating policies
@@ -775,7 +783,7 @@ public class AdminTest extends MockedPulsarServiceBaseTest {
.allowedClusters(Collections.singleton(cluster))
.build();
ClusterDataImpl clusterData = ClusterDataImpl.builder().serviceUrl("http://example.pulsar").build();
- asyncRequests(ctx -> clusters.createCluster(ctx, cluster, clusterData ));
+ asyncRequests(ctx -> clusters.createCluster(ctx, cluster, clusterData));
asyncRequests(ctx -> properties.createTenant(ctx, property, admin));
// customized bandwidth for this namespace
@@ -784,14 +792,18 @@ public class AdminTest extends MockedPulsarServiceBaseTest {
quota.setBandwidthOut(customizeBandwidth);
// set and get Resource Quota
- asyncRequests(ctx -> resourceQuotas.setNamespaceBundleResourceQuota(ctx, property, cluster, namespace, bundleRange, quota));
- ResourceQuota bundleQuota = (ResourceQuota) asyncRequests(ctx -> resourceQuotas.getNamespaceBundleResourceQuota(ctx, property, cluster, namespace,
+ asyncRequests(ctx -> resourceQuotas.setNamespaceBundleResourceQuota(
+ ctx, property, cluster, namespace, bundleRange, quota));
+ ResourceQuota bundleQuota = (ResourceQuota) asyncRequests(ctx -> resourceQuotas
+ .getNamespaceBundleResourceQuota(ctx, property, cluster, namespace,
bundleRange));
assertEquals(quota, bundleQuota);
// remove quota which sets to default quota
- asyncRequests(ctx -> resourceQuotas.removeNamespaceBundleResourceQuota(ctx, property, cluster, namespace, bundleRange));
- bundleQuota = (ResourceQuota) asyncRequests(ctx -> resourceQuotas.getNamespaceBundleResourceQuota(ctx, property, cluster, namespace, bundleRange));
+ asyncRequests(ctx -> resourceQuotas.removeNamespaceBundleResourceQuota(
+ ctx, property, cluster, namespace, bundleRange));
+ bundleQuota = (ResourceQuota) asyncRequests(ctx -> resourceQuotas
+ .getNamespaceBundleResourceQuota(ctx, property, cluster, namespace, bundleRange));
assertEquals(defaultBandwidth, bundleQuota.getBandwidthIn());
assertEquals(defaultBandwidth, bundleQuota.getBandwidthOut());
}
@@ -914,17 +926,22 @@ public class AdminTest extends MockedPulsarServiceBaseTest {
AsyncResponse response1 = mock(AsyncResponse.class);
ArgumentCaptor<Response> responseCaptor = ArgumentCaptor.forClass(Response.class);
- persistentTopics.createPartitionedTopic(response1, property, cluster, namespace, partitionedTopicName, 5, false);
+ persistentTopics.createPartitionedTopic(response1, property, cluster, namespace,
+ partitionedTopicName, 5, false);
verify(response1, timeout(5000).times(1)).resume(responseCaptor.capture());
- Assert.assertEquals(responseCaptor.getValue().getStatus(), Response.Status.NO_CONTENT.getStatusCode());
+ Assert.assertEquals(responseCaptor.getValue().getStatus(),
+ Response.Status.NO_CONTENT.getStatusCode());
AsyncResponse response2 = mock(AsyncResponse.class);
responseCaptor = ArgumentCaptor.forClass(Response.class);
- persistentTopics.createPartitionedTopic(response2, property, cluster, namespace, partitionedTopicName2, 2, false);
+ persistentTopics.createPartitionedTopic(response2, property, cluster, namespace,
+ partitionedTopicName2, 2, false);
verify(response2, timeout(5000).times(1)).resume(responseCaptor.capture());
- Assert.assertEquals(responseCaptor.getValue().getStatus(), Response.Status.NO_CONTENT.getStatusCode());
+ Assert.assertEquals(responseCaptor.getValue().getStatus(),
+ Response.Status.NO_CONTENT.getStatusCode());
- persistentTopics.updatePartitionedTopic(response2, property, cluster, namespace, partitionedTopicName2, false, false,
+ persistentTopics.updatePartitionedTopic(response2, property, cluster, namespace,
+ partitionedTopicName2, false, false,
false, 10);
}
@@ -940,10 +957,15 @@ public class AdminTest extends MockedPulsarServiceBaseTest {
CompletableFuture<List<String>> future = new CompletableFuture();
future.completeExceptionally(new RuntimeException("500 error contains error message"));
NamespaceService namespaceService = pulsar.getNamespaceService();
+
doReturn(future).when(namespaceService).getListOfTopics(namespaceName, CommandGetTopicsOfNamespace.Mode.ALL);
- persistentTopics.createPartitionedTopic(response1, property, cluster, namespace, partitionedTopicName, 5, false);
+ persistentTopics.createPartitionedTopic(response1, property, cluster, namespace,
+ partitionedTopicName, 5, false);
+
verify(response1, timeout(5000).times(1)).resume(responseCaptor.capture());
- Assert.assertEquals(responseCaptor.getValue().getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
- Assert.assertTrue(((ErrorData)responseCaptor.getValue().getResponse().getEntity()).reason.contains("500 error contains error message"));
+ Assert.assertEquals(responseCaptor.getValue().getResponse().getStatus(),
+ Status.INTERNAL_SERVER_ERROR.getStatusCode());
+ Assert.assertTrue(((ErrorData) responseCaptor.getValue().getResponse().getEntity())
+ .reason.contains("500 error contains error message"));
}
}
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminTopicApiTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminTopicApiTest.java
index 0a334cd7e81..b9a0849e01f 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminTopicApiTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminTopicApiTest.java
@@ -181,10 +181,10 @@ public class AdminTopicApiTest extends ProducerConsumerBase {
return new Object[]{
// v1 topic
TopicDomain.persistent + "://my-property/test/my-ns/" + UUID.randomUUID(),
- TopicDomain.non_persistent+ "://my-property/test/my-ns/" + UUID.randomUUID(),
+ TopicDomain.non_persistent + "://my-property/test/my-ns/" + UUID.randomUUID(),
//v2 topic
- TopicDomain.persistent+ "://my-property/my-ns/" + UUID.randomUUID(),
- TopicDomain.non_persistent+ "://my-property/my-ns/" + UUID.randomUUID(),
+ TopicDomain.persistent + "://my-property/my-ns/" + UUID.randomUUID(),
+ TopicDomain.non_persistent + "://my-property/my-ns/" + UUID.randomUUID(),
};
}
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AnalyzeBacklogSubscriptionTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AnalyzeBacklogSubscriptionTest.java
index f8aa3dc355d..dbc632c6cf3 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AnalyzeBacklogSubscriptionTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AnalyzeBacklogSubscriptionTest.java
@@ -89,8 +89,8 @@ public class AnalyzeBacklogSubscriptionTest extends ProducerConsumerBase {
List<CompletableFuture<MessageId>> handles = new ArrayList<>();
for (int i = 0; i < numMessages; i++) {
- CompletableFuture<MessageId> handle
- = p.sendAsync(("test-" + i).getBytes());
+ CompletableFuture<MessageId> handle =
+ p.sendAsync(("test-" + i).getBytes());
handles.add(handle);
}
FutureUtil.waitForAll(handles).get();
@@ -140,19 +140,19 @@ public class AnalyzeBacklogSubscriptionTest extends ProducerConsumerBase {
verifyBacklog(topic, subName, numEntries - (5 / batchSize), numMessages - 5);
int count = numMessages - 5;
- while (count -- > 0) {
+ while (count-- > 0) {
Message m = consumer.receive();
consumer.acknowledge(m);
}
- verifyBacklog(topic, subName, 0,0);
+ verifyBacklog(topic, subName, 0, 0);
}
}
private void verifyBacklog(String topic, String subscription, int numEntries, int numMessages) throws Exception {
- AnalyzeSubscriptionBacklogResult analyzeSubscriptionBacklogResult
- = admin.topics().analyzeSubscriptionBacklog(topic, subscription, Optional.empty());
+ AnalyzeSubscriptionBacklogResult analyzeSubscriptionBacklogResult =
+ admin.topics().analyzeSubscriptionBacklog(topic, subscription, Optional.empty());
assertEquals(analyzeSubscriptionBacklogResult.getEntries(), numEntries);
assertEquals(analyzeSubscriptionBacklogResult.getFilterAcceptedEntries(), numEntries);
@@ -183,8 +183,8 @@ public class AnalyzeBacklogSubscriptionTest extends ProducerConsumerBase {
});
// you can access single partitions
- AnalyzeSubscriptionBacklogResult analyzeSubscriptionBacklogResult
- = admin.topics().analyzeSubscriptionBacklog(topic + "-partition-0", "sub-1", Optional.empty());
+ AnalyzeSubscriptionBacklogResult analyzeSubscriptionBacklogResult =
+ admin.topics().analyzeSubscriptionBacklog(topic + "-partition-0", "sub-1", Optional.empty());
assertEquals(0, analyzeSubscriptionBacklogResult.getEntries());
}
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AuthZTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AuthZTest.java
index 2d46ce26334..4eb79fb8c5c 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AuthZTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AuthZTest.java
@@ -108,19 +108,19 @@ public abstract class AuthZTest extends MockedPulsarStandalone {
AtomicBoolean execFlag = new AtomicBoolean(false);
if (operation instanceof TopicOperation) {
allowTopicOperationAsyncHandler = invocationOnMock -> {
- String role_ = invocationOnMock.getArgument(2);
- if (role.equals(role_)) {
- TopicOperation operation_ = invocationOnMock.getArgument(1);
- Assert.assertEquals(operation_, operation);
+ String role1 = invocationOnMock.getArgument(2);
+ if (role.equals(role1)) {
+ TopicOperation operation1 = invocationOnMock.getArgument(1);
+ Assert.assertEquals(operation1, operation);
}
execFlag.set(true);
};
} else if (operation instanceof NamespaceOperation) {
allowNamespaceOperationAsyncHandler = invocationOnMock -> {
- String role_ = invocationOnMock.getArgument(2);
- if (role.equals(role_)) {
- TopicOperation operation_ = invocationOnMock.getArgument(1);
- Assert.assertEquals(operation_, operation);
+ String role1 = invocationOnMock.getArgument(2);
+ if (role.equals(role1)) {
+ TopicOperation operation1 = invocationOnMock.getArgument(1);
+ Assert.assertEquals(operation1, operation);
}
execFlag.set(true);
};
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/BookiesApiTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/BookiesApiTest.java
index 1bd1de2130b..6a3fe601d0d 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/BookiesApiTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/BookiesApiTest.java
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.doReturn;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
-
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.broker.ServiceConfiguration;
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/BrokerEndpointsAuthorizationTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/BrokerEndpointsAuthorizationTest.java
index ef66f005b3c..7fd5fc1cc85 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/BrokerEndpointsAuthorizationTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/BrokerEndpointsAuthorizationTest.java
@@ -74,7 +74,8 @@ public class BrokerEndpointsAuthorizationTest extends MockedPulsarStandalone {
@AfterMethod(alwaysRun = true)
public void after() throws IllegalAccessException {
if (orignalAuthorizationService != null) {
- FieldUtils.writeField(getPulsarService().getBrokerService(), "authorizationService", orignalAuthorizationService, true);
+ FieldUtils.writeField(getPulsarService().getBrokerService(), "authorizationService",
+ orignalAuthorizationService, true);
}
}
@@ -97,12 +98,14 @@ public class BrokerEndpointsAuthorizationTest extends MockedPulsarStandalone {
final String clusterName = getPulsarService().getConfiguration().getClusterName();
// test allow broker operation
verify(spyAuthorizationService)
- .allowBrokerOperationAsync(eq(clusterName), eq(brokerId), eq(BrokerOperation.LIST_BROKERS), any(), any(), any());
+ .allowBrokerOperationAsync(eq(clusterName), eq(brokerId),
+ eq(BrokerOperation.LIST_BROKERS), any(), any(), any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.brokers().getActiveBrokers());
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
+ () -> nobodyAdmin.brokers().getActiveBrokers());
}
@Test
@@ -112,12 +115,14 @@ public class BrokerEndpointsAuthorizationTest extends MockedPulsarStandalone {
final String brokerId = getPulsarService().getBrokerId();
// test allow broker operation
verify(spyAuthorizationService)
- .allowBrokerOperationAsync(eq(clusterName), eq(brokerId), eq(BrokerOperation.LIST_BROKERS), any(), any(), any());
+ .allowBrokerOperationAsync(eq(clusterName), eq(brokerId),
+ eq(BrokerOperation.LIST_BROKERS), any(), any(), any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.brokers().getActiveBrokers(clusterName));
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
+ () -> nobodyAdmin.brokers().getActiveBrokers(clusterName));
}
@Test
@@ -127,12 +132,14 @@ public class BrokerEndpointsAuthorizationTest extends MockedPulsarStandalone {
final String brokerId = getPulsarService().getBrokerId();
// test allow broker operation
verify(spyAuthorizationService)
- .allowBrokerOperationAsync(eq(clusterName), eq(brokerId), eq(BrokerOperation.GET_LEADER_BROKER), any(), any(), any());
+ .allowBrokerOperationAsync(eq(clusterName), eq(brokerId),
+ eq(BrokerOperation.GET_LEADER_BROKER), any(), any(), any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.brokers().getLeaderBroker());
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
+ () -> nobodyAdmin.brokers().getLeaderBroker());
}
@Test
@@ -142,12 +149,14 @@ public class BrokerEndpointsAuthorizationTest extends MockedPulsarStandalone {
superUserAdmin.brokers().getOwnedNamespaces(clusterName, brokerId);
// test allow broker operation
verify(spyAuthorizationService)
- .allowBrokerOperationAsync(eq(clusterName), eq(brokerId), eq(BrokerOperation.LIST_OWNED_NAMESPACES), any(), any(), any());
+ .allowBrokerOperationAsync(eq(clusterName), eq(brokerId),
+ eq(BrokerOperation.LIST_OWNED_NAMESPACES), any(), any(), any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.brokers().getOwnedNamespaces(clusterName, brokerId));
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
+ () -> nobodyAdmin.brokers().getOwnedNamespaces(clusterName, brokerId));
}
@Test
@@ -157,12 +166,14 @@ public class BrokerEndpointsAuthorizationTest extends MockedPulsarStandalone {
superUserAdmin.brokers().updateDynamicConfiguration("maxTenants", "10");
// test allow broker operation
verify(spyAuthorizationService)
- .allowBrokerOperationAsync(eq(clusterName), eq(brokerId), eq(BrokerOperation.UPDATE_DYNAMIC_CONFIGURATION), any(), any(), any());
+ .allowBrokerOperationAsync(eq(clusterName), eq(brokerId),
+ eq(BrokerOperation.UPDATE_DYNAMIC_CONFIGURATION), any(), any(), any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.brokers().updateDynamicConfiguration("maxTenants", "10"));
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
+ () -> nobodyAdmin.brokers().updateDynamicConfiguration("maxTenants", "10"));
}
@Test
@@ -172,12 +183,14 @@ public class BrokerEndpointsAuthorizationTest extends MockedPulsarStandalone {
superUserAdmin.brokers().deleteDynamicConfiguration("maxTenants");
// test allow broker operation
verify(spyAuthorizationService)
- .allowBrokerOperationAsync(eq(clusterName), eq(brokerId), eq(BrokerOperation.DELETE_DYNAMIC_CONFIGURATION), any(), any(), any());
+ .allowBrokerOperationAsync(eq(clusterName), eq(brokerId),
+ eq(BrokerOperation.DELETE_DYNAMIC_CONFIGURATION), any(), any(), any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.brokers().deleteDynamicConfiguration("maxTenants"));
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
+ () -> nobodyAdmin.brokers().deleteDynamicConfiguration("maxTenants"));
}
@@ -188,12 +201,14 @@ public class BrokerEndpointsAuthorizationTest extends MockedPulsarStandalone {
superUserAdmin.brokers().getAllDynamicConfigurations();
// test allow broker operation
verify(spyAuthorizationService)
- .allowBrokerOperationAsync(eq(clusterName), eq(brokerId), eq(BrokerOperation.LIST_DYNAMIC_CONFIGURATIONS), any(), any(), any());
+ .allowBrokerOperationAsync(eq(clusterName), eq(brokerId),
+ eq(BrokerOperation.LIST_DYNAMIC_CONFIGURATIONS), any(), any(), any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.brokers().getAllDynamicConfigurations());
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
+ () -> nobodyAdmin.brokers().getAllDynamicConfigurations());
}
@@ -204,12 +219,14 @@ public class BrokerEndpointsAuthorizationTest extends MockedPulsarStandalone {
superUserAdmin.brokers().getDynamicConfigurationNames();
// test allow broker operation
verify(spyAuthorizationService)
- .allowBrokerOperationAsync(eq(clusterName), eq(brokerId), eq(BrokerOperation.LIST_DYNAMIC_CONFIGURATIONS), any(), any(), any());
+ .allowBrokerOperationAsync(eq(clusterName), eq(brokerId),
+ eq(BrokerOperation.LIST_DYNAMIC_CONFIGURATIONS), any(), any(), any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.brokers().getDynamicConfigurationNames());
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
+ () -> nobodyAdmin.brokers().getDynamicConfigurationNames());
}
@@ -220,12 +237,14 @@ public class BrokerEndpointsAuthorizationTest extends MockedPulsarStandalone {
superUserAdmin.brokers().getRuntimeConfigurations();
// test allow broker operation
verify(spyAuthorizationService)
- .allowBrokerOperationAsync(eq(clusterName), eq(brokerId), eq(BrokerOperation.LIST_RUNTIME_CONFIGURATIONS), any(), any(), any());
+ .allowBrokerOperationAsync(eq(clusterName), eq(brokerId),
+ eq(BrokerOperation.LIST_RUNTIME_CONFIGURATIONS), any(), any(), any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.brokers().getRuntimeConfigurations());
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
+ () -> nobodyAdmin.brokers().getRuntimeConfigurations());
}
@@ -236,12 +255,14 @@ public class BrokerEndpointsAuthorizationTest extends MockedPulsarStandalone {
superUserAdmin.brokers().getInternalConfigurationData();
// test allow broker operation
verify(spyAuthorizationService)
- .allowBrokerOperationAsync(eq(clusterName), eq(brokerId), eq(BrokerOperation.GET_INTERNAL_CONFIGURATION_DATA), any(), any(), any());
+ .allowBrokerOperationAsync(eq(clusterName), eq(brokerId),
+ eq(BrokerOperation.GET_INTERNAL_CONFIGURATION_DATA), any(), any(), any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.brokers().getInternalConfigurationData());
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
+ () -> nobodyAdmin.brokers().getInternalConfigurationData());
}
@@ -252,12 +273,14 @@ public class BrokerEndpointsAuthorizationTest extends MockedPulsarStandalone {
superUserAdmin.brokers().backlogQuotaCheck();
// test allow broker operation
verify(spyAuthorizationService)
- .allowBrokerOperationAsync(eq(clusterName), eq(brokerId), eq(BrokerOperation.CHECK_BACKLOG_QUOTA), any(), any(), any());
+ .allowBrokerOperationAsync(eq(clusterName), eq(brokerId),
+ eq(BrokerOperation.CHECK_BACKLOG_QUOTA), any(), any(), any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.brokers().backlogQuotaCheck());
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
+ () -> nobodyAdmin.brokers().backlogQuotaCheck());
}
@Test
@@ -267,11 +290,13 @@ public class BrokerEndpointsAuthorizationTest extends MockedPulsarStandalone {
superUserAdmin.brokers().healthcheck(TopicVersion.V2);
// test allow broker operation
verify(spyAuthorizationService)
- .allowBrokerOperationAsync(eq(clusterName), eq(brokerId), eq(BrokerOperation.HEALTH_CHECK), any(), any(), any());
+ .allowBrokerOperationAsync(eq(clusterName), eq(brokerId),
+ eq(BrokerOperation.HEALTH_CHECK), any(), any(), any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.brokers().healthcheck(TopicVersion.V2));
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
+ () -> nobodyAdmin.brokers().healthcheck(TopicVersion.V2));
}
}
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/ClusterEndpointsAuthorizationTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/ClusterEndpointsAuthorizationTest.java
index ccf5ccb9481..d6ad8207bd5 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/ClusterEndpointsAuthorizationTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/ClusterEndpointsAuthorizationTest.java
@@ -22,6 +22,8 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
+import java.util.LinkedHashSet;
+import java.util.UUID;
import lombok.SneakyThrows;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.pulsar.broker.authorization.AuthorizationService;
@@ -43,8 +45,6 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.LinkedHashSet;
-import java.util.UUID;
@Test(groups = "broker-admin")
@@ -83,7 +83,8 @@ public class ClusterEndpointsAuthorizationTest extends MockedPulsarStandalone {
@AfterMethod(alwaysRun = true)
public void after() throws IllegalAccessException {
if (orignalAuthorizationService != null) {
- FieldUtils.writeField(getPulsarService().getBrokerService(), "authorizationService", orignalAuthorizationService, true);
+ FieldUtils.writeField(getPulsarService().getBrokerService(), "authorizationService",
+ orignalAuthorizationService, true);
}
}
@@ -361,7 +362,9 @@ public class ClusterEndpointsAuthorizationTest extends MockedPulsarStandalone {
// test allow cluster operation
verify(spyAuthorizationService)
- .allowClusterOperationAsync(eq(clusterName), eq(ClusterOperation.UPDATE_FAILURE_DOMAIN), any(), any(), any());
+ .allowClusterOperationAsync(eq(clusterName),
+ eq(ClusterOperation.UPDATE_FAILURE_DOMAIN), any(), any(),
+ any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
@@ -377,7 +380,9 @@ public class ClusterEndpointsAuthorizationTest extends MockedPulsarStandalone {
// test allow cluster operation
verify(spyAuthorizationService)
- .allowClusterOperationAsync(eq(clusterName), eq(ClusterOperation.GET_FAILURE_DOMAIN), any(), any(), any());
+ .allowClusterOperationAsync(eq(clusterName),
+ eq(ClusterOperation.GET_FAILURE_DOMAIN), any(), any(),
+ any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
@@ -397,7 +402,9 @@ public class ClusterEndpointsAuthorizationTest extends MockedPulsarStandalone {
// test allow cluster operation
verify(spyAuthorizationService)
- .allowClusterOperationAsync(eq(clusterName), eq(ClusterOperation.GET_FAILURE_DOMAIN), any(), any(), any());
+ .allowClusterOperationAsync(eq(clusterName),
+ eq(ClusterOperation.GET_FAILURE_DOMAIN), any(), any(),
+ any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
@@ -416,7 +423,9 @@ public class ClusterEndpointsAuthorizationTest extends MockedPulsarStandalone {
// test allow cluster operation
verify(spyAuthorizationService)
- .allowClusterOperationAsync(eq(clusterName), eq(ClusterOperation.DELETE_FAILURE_DOMAIN), any(), any(), any());
+ .allowClusterOperationAsync(eq(clusterName),
+ eq(ClusterOperation.DELETE_FAILURE_DOMAIN), any(), any(),
+ any());
// fallback to superuser
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/CreateSubscriptionTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/CreateSubscriptionTest.java
index c121ea44387..6fcd5f6f3c5 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/CreateSubscriptionTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/CreateSubscriptionTest.java
@@ -140,7 +140,7 @@ public class CreateSubscriptionTest extends ProducerConsumerBase {
admin.topics().createPartitionedTopic(topic, 10);
// create subscription for one partition
- final String partitionedTopic0 = topic+"-partition-0";
+ final String partitionedTopic0 = topic + "-partition-0";
admin.topics().createSubscription(partitionedTopic0, "sub-1", MessageId.latest);
admin.topics().createSubscription(topic, "sub-1", MessageId.latest);
@@ -473,14 +473,14 @@ public class CreateSubscriptionTest extends ProducerConsumerBase {
@Test
public void testWaitingCurosrCausedMemoryLeak() throws Exception {
String topic = "persistent://my-property/my-ns/my-topic";
- for (int i = 0; i < 10; i ++) {
+ for (int i = 0; i < 10; i++) {
Consumer<String> consumer = pulsarClient.newConsumer(Schema.STRING).topic(topic)
.subscriptionType(SubscriptionType.Failover).subscriptionName("test" + i).subscribe();
Awaitility.await().untilAsserted(() -> assertTrue(consumer.isConnected()));
consumer.close();
}
PersistentTopic topicRef = (PersistentTopic) pulsar.getBrokerService().getTopicReference(topic).get();
- ManagedLedgerImpl ml = (ManagedLedgerImpl)(topicRef.getManagedLedger());
+ ManagedLedgerImpl ml = (ManagedLedgerImpl) (topicRef.getManagedLedger());
assertEquals(ml.getWaitingCursorsCount(), 0);
}
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/GetPartitionMetadataTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/GetPartitionMetadataTest.java
index f3237676c86..4b796fcca33 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/GetPartitionMetadataTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/GetPartitionMetadataTest.java
@@ -588,7 +588,8 @@ public class GetPartitionMetadataTest extends TestRetrySupport {
public void testNamespaceNotExist(TopicDomain topicDomain) throws Exception {
int lookupPermitsBefore = getLookupRequestPermits();
final String namespaceNotExist = BrokerTestUtil.newUniqueName("public/ns");
- final String topicNameStr = BrokerTestUtil.newUniqueName(topicDomain.toString() + "://" + namespaceNotExist + "/tp");
+ final String topicNameStr = BrokerTestUtil.newUniqueName(topicDomain.toString()
+ + "://" + namespaceNotExist + "/tp");
PulsarClientImpl[] clientArray = getClientsToTest(false);
for (PulsarClientImpl client : clientArray) {
try {
@@ -613,7 +614,8 @@ public class GetPartitionMetadataTest extends TestRetrySupport {
int lookupPermitsBefore = getLookupRequestPermits();
final String tenantNotExist = BrokerTestUtil.newUniqueName("tenant");
final String namespaceNotExist = BrokerTestUtil.newUniqueName(tenantNotExist + "/default");
- final String topicNameStr = BrokerTestUtil.newUniqueName(topicDomain.toString() + "://" + namespaceNotExist + "/tp");
+ final String topicNameStr = BrokerTestUtil.newUniqueName(topicDomain.toString()
+ + "://" + namespaceNotExist + "/tp");
PulsarClientImpl[] clientArray = getClientsToTest(false);
for (PulsarClientImpl client : clientArray) {
try {
@@ -624,8 +626,8 @@ public class GetPartitionMetadataTest extends TestRetrySupport {
fail("Expected a not found ex");
} catch (Exception ex) {
Throwable unwrapEx = FutureUtil.unwrapCompletionException(ex);
- assertTrue(unwrapEx instanceof PulsarClientException.BrokerMetadataException ||
- unwrapEx instanceof PulsarClientException.TopicDoesNotExistException);
+ assertTrue(unwrapEx instanceof PulsarClientException.BrokerMetadataException
+ || unwrapEx instanceof PulsarClientException.TopicDoesNotExistException);
}
}
// Verify: lookup semaphore has been releases.
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/MockServletContext.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/MockServletContext.java
index cdd33da09b8..7ae63c500df 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/MockServletContext.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/MockServletContext.java
@@ -25,7 +25,6 @@ import java.util.Enumeration;
import java.util.EventListener;
import java.util.Map;
import java.util.Set;
-
import javax.servlet.Filter;
import javax.servlet.FilterRegistration;
import javax.servlet.RequestDispatcher;
@@ -37,7 +36,6 @@ import javax.servlet.ServletRegistration.Dynamic;
import javax.servlet.SessionCookieConfig;
import javax.servlet.SessionTrackingMode;
import javax.servlet.descriptor.JspConfigDescriptor;
-
import org.eclipse.jetty.util.AttributesMap;
public class MockServletContext extends AttributesMap implements ServletContext {
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/NamespaceAuthZTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/NamespaceAuthZTest.java
index 8a9e38d166f..4b87d11298c 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/NamespaceAuthZTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/NamespaceAuthZTest.java
@@ -175,10 +175,10 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
private AtomicBoolean setAuthorizationOperationChecker(String role, NamespaceOperation operation) {
AtomicBoolean execFlag = new AtomicBoolean(false);
allowNamespaceOperationAsyncHandler = invocationOnMock -> {
- String role_ = invocationOnMock.getArgument(2);
- if (role.equals(role_)) {
- NamespaceOperation operation_ = invocationOnMock.getArgument(1);
- Assert.assertEquals(operation_, operation);
+ String role1 = invocationOnMock.getArgument(2);
+ if (role.equals(role1)) {
+ NamespaceOperation operation1 = invocationOnMock.getArgument(1);
+ Assert.assertEquals(operation1, operation);
}
execFlag.set(true);
};
@@ -193,12 +193,12 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
AtomicBoolean execFlag = new AtomicBoolean(false);
if (operation instanceof PolicyOperation) {
allowNamespacePolicyOperationAsyncHandler = invocationOnMock -> {
- String role_ = invocationOnMock.getArgument(3);
- if (role.equals(role_)) {
- PolicyName policyName_ = invocationOnMock.getArgument(1);
- PolicyOperation operation_ = invocationOnMock.getArgument(2);
- assertEquals(operation_, operation);
- assertEquals(policyName_, policyName);
+ String role1 = invocationOnMock.getArgument(3);
+ if (role.equals(role1)) {
+ PolicyName policyName1 = invocationOnMock.getArgument(1);
+ PolicyOperation operation1 = invocationOnMock.getArgument(2);
+ assertEquals(operation1, operation);
+ assertEquals(policyName1, policyName);
}
execFlag.set(true);
};
@@ -861,7 +861,7 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
public void testUnsubscribeNamespaceBundle() throws Exception {
final String random = UUID.randomUUID().toString();
final String namespace = "public/default";
- final String topic = "persistent://" + namespace + "/" + random ;
+ final String topic = "persistent://" + namespace + "/" + random;
final String subject = UUID.randomUUID().toString();
final String token = Jwts.builder()
.claim("sub", subject).signWith(SECRET_KEY).compact();
@@ -1195,8 +1195,10 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
() -> subAdmin.namespaces().getSubscriptionDispatchRate(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RATE, PolicyOperation.WRITE);
- DispatchRate dispatchRate = DispatchRate.builder().dispatchThrottlingRateInMsg(10).dispatchThrottlingRateInByte(10).build();
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RATE, PolicyOperation.WRITE);
+ DispatchRate dispatchRate = DispatchRate.builder().dispatchThrottlingRateInMsg(10)
+ .dispatchThrottlingRateInByte(10).build();
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setSubscriptionDispatchRate(namespace, dispatchRate));
Assert.assertTrue(execFlag.get());
@@ -1226,7 +1228,7 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.COMPACTION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.namespaces().setCompactionThreshold(namespace, 100L * 1024L *1024L));
+ () -> subAdmin.namespaces().setCompactionThreshold(namespace, 100L * 1024L * 1024L));
Assert.assertTrue(execFlag.get());
execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.COMPACTION, PolicyOperation.WRITE);
@@ -1432,18 +1434,21 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.BACKLOG, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.BACKLOG, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getBacklogQuotaMap(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.BACKLOG, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.BACKLOG, PolicyOperation.WRITE);
BacklogQuota backlogQuota = BacklogQuota.builder().limitTime(10).limitSize(10).build();
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setBacklogQuota(namespace, backlogQuota));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.BACKLOG, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.BACKLOG,
+ PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeBacklogQuota(namespace));
Assert.assertTrue(execFlag.get());
@@ -1460,17 +1465,20 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.DEDUPLICATION_SNAPSHOT, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DEDUPLICATION_SNAPSHOT, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getDeduplicationSnapshotInterval(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.DEDUPLICATION_SNAPSHOT, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DEDUPLICATION_SNAPSHOT, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setDeduplicationSnapshotInterval(namespace, 100));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.DEDUPLICATION_SNAPSHOT, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DEDUPLICATION_SNAPSHOT, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeDeduplicationSnapshotInterval(namespace));
Assert.assertTrue(execFlag.get());
@@ -1488,17 +1496,20 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.authentication(new AuthenticationToken(token))
.build();
AtomicBoolean execFlag =
- setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_SUBSCRIPTIONS, PolicyOperation.READ);
+ setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_SUBSCRIPTIONS, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getMaxSubscriptionsPerTopic(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_SUBSCRIPTIONS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_SUBSCRIPTIONS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setMaxSubscriptionsPerTopic(namespace, 10));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_SUBSCRIPTIONS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_SUBSCRIPTIONS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeMaxSubscriptionsPerTopic(namespace));
Assert.assertTrue(execFlag.get());
@@ -1516,17 +1527,20 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.authentication(new AuthenticationToken(token))
.build();
AtomicBoolean execFlag =
- setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_PRODUCERS, PolicyOperation.READ);
+ setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_PRODUCERS, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getMaxProducersPerTopic(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_PRODUCERS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_PRODUCERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setMaxProducersPerTopic(namespace, 10));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_PRODUCERS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_PRODUCERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeMaxProducersPerTopic(namespace));
Assert.assertTrue(execFlag.get());
@@ -1544,17 +1558,20 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.authentication(new AuthenticationToken(token))
.build();
AtomicBoolean execFlag =
- setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_CONSUMERS, PolicyOperation.READ);
+ setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_CONSUMERS, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getMaxConsumersPerTopic(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setMaxConsumersPerTopic(namespace, 10));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeMaxConsumersPerTopic(namespace));
Assert.assertTrue(execFlag.get());
@@ -1572,12 +1589,14 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.authentication(new AuthenticationToken(token))
.build();
AtomicBoolean execFlag =
- setAuthorizationPolicyOperationChecker(subject, PolicyName.REPLICATION, PolicyOperation.READ);
+ setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.REPLICATION, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getNamespaceReplicationClusters(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.REPLICATION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.REPLICATION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setNamespaceReplicationClusters(namespace, Sets.newHashSet("test")));
Assert.assertTrue(execFlag.get());
@@ -1595,19 +1614,23 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.authentication(new AuthenticationToken(token))
.build();
AtomicBoolean execFlag =
- setAuthorizationPolicyOperationChecker(subject, PolicyName.REPLICATION_RATE, PolicyOperation.READ);
+ setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.REPLICATION_RATE, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getReplicatorDispatchRate(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.REPLICATION_RATE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.REPLICATION_RATE, PolicyOperation.WRITE);
DispatchRate build =
- DispatchRate.builder().dispatchThrottlingRateInByte(10).dispatchThrottlingRateInMsg(10).build();
+ DispatchRate.builder().dispatchThrottlingRateInByte(10)
+ .dispatchThrottlingRateInMsg(10).build();
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setReplicatorDispatchRate(namespace, build));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.REPLICATION_RATE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.REPLICATION_RATE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeReplicatorDispatchRate(namespace));
Assert.assertTrue(execFlag.get());
@@ -1625,17 +1648,20 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.authentication(new AuthenticationToken(token))
.build();
AtomicBoolean execFlag =
- setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_CONSUMERS, PolicyOperation.READ);
+ setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_CONSUMERS, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getMaxConsumersPerSubscription(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setMaxConsumersPerSubscription(namespace, 10));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeMaxConsumersPerSubscription(namespace));
Assert.assertTrue(execFlag.get());
@@ -1652,12 +1678,14 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.OFFLOAD, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.OFFLOAD, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getOffloadThreshold(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.OFFLOAD, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.OFFLOAD, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setOffloadThreshold(namespace, 10));
Assert.assertTrue(execFlag.get());
@@ -1674,18 +1702,22 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.OFFLOAD, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.OFFLOAD, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getOffloadPolicies(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.OFFLOAD, PolicyOperation.WRITE);
- OffloadPolicies offloadPolicies = OffloadPolicies.builder().managedLedgerOffloadThresholdInBytes(10L).build();
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.OFFLOAD, PolicyOperation.WRITE);
+ OffloadPolicies offloadPolicies = OffloadPolicies.builder()
+ .managedLedgerOffloadThresholdInBytes(10L).build();
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setOffloadPolicies(namespace, offloadPolicies));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.OFFLOAD, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.OFFLOAD, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeOffloadPolicies(namespace));
Assert.assertTrue(execFlag.get());
@@ -1702,17 +1734,20 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_TOPICS, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_TOPICS, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getMaxTopicsPerNamespace(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_TOPICS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_TOPICS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setMaxTopicsPerNamespace(namespace, 10));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_TOPICS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_TOPICS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeMaxTopicsPerNamespace(namespace));
Assert.assertTrue(execFlag.get());
@@ -1730,17 +1765,20 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.authentication(new AuthenticationToken(token))
.build();
AtomicBoolean execFlag =
- setAuthorizationPolicyOperationChecker(subject, PolicyName.DEDUPLICATION, PolicyOperation.READ);
+ setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DEDUPLICATION, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getDeduplicationStatus(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.DEDUPLICATION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DEDUPLICATION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setDeduplicationStatus(namespace, true));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.DEDUPLICATION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DEDUPLICATION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeDeduplicationStatus(namespace));
Assert.assertTrue(execFlag.get());
@@ -1758,17 +1796,21 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.authentication(new AuthenticationToken(token))
.build();
AtomicBoolean execFlag =
- setAuthorizationPolicyOperationChecker(subject, PolicyName.PERSISTENCE, PolicyOperation.READ);
+ setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.PERSISTENCE, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getPersistence(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.PERSISTENCE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.PERSISTENCE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.namespaces().setPersistence(namespace, new PersistencePolicies(10, 10, 10, 10)));
+ () -> subAdmin.namespaces().setPersistence(namespace,
+ new PersistencePolicies(10, 10, 10, 10)));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.PERSISTENCE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.PERSISTENCE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removePersistence(namespace));
Assert.assertTrue(execFlag.get());
@@ -1785,17 +1827,20 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.TTL, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.TTL, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getNamespaceMessageTTL(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.TTL, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.TTL, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setNamespaceMessageTTL(namespace, 10));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.TTL, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.TTL, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeNamespaceMessageTTL(namespace));
Assert.assertTrue(execFlag.get());
@@ -1819,12 +1864,14 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
() -> subAdmin.namespaces().getSubscriptionExpirationTime(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.SUBSCRIPTION_EXPIRATION_TIME, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.SUBSCRIPTION_EXPIRATION_TIME, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setSubscriptionExpirationTime(namespace, 10));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.SUBSCRIPTION_EXPIRATION_TIME, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.SUBSCRIPTION_EXPIRATION_TIME, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeSubscriptionExpirationTime(namespace));
Assert.assertTrue(execFlag.get());
@@ -1843,7 +1890,8 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.authentication(new AuthenticationToken(token))
.build();
AtomicBoolean execFlag =
- setAuthorizationPolicyOperationChecker(subject, PolicyName.DELAYED_DELIVERY, PolicyOperation.READ);
+ setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DELAYED_DELIVERY, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getDelayedDelivery(namespace));
Assert.assertTrue(execFlag.get());
@@ -1860,17 +1908,21 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RETENTION, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RETENTION, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getRetention(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RETENTION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RETENTION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.namespaces().setRetention(namespace, new RetentionPolicies(10, 10)));
+ () -> subAdmin.namespaces().setRetention(namespace,
+ new RetentionPolicies(10, 10)));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RETENTION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RETENTION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeRetention(namespace));
Assert.assertTrue(execFlag.get());
@@ -1887,19 +1939,23 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.INACTIVE_TOPIC, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.INACTIVE_TOPIC, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getInactiveTopicPolicies(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.INACTIVE_TOPIC, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.INACTIVE_TOPIC, PolicyOperation.WRITE);
InactiveTopicPolicies inactiveTopicPolicies = new InactiveTopicPolicies(
- InactiveTopicDeleteMode.delete_when_no_subscriptions, 10, false);
+ InactiveTopicDeleteMode.delete_when_no_subscriptions,
+ 10, false);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setInactiveTopicPolicies(namespace, inactiveTopicPolicies));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.INACTIVE_TOPIC, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.INACTIVE_TOPIC, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeInactiveTopicPolicies(namespace));
Assert.assertTrue(execFlag.get());
@@ -1916,14 +1972,17 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.ANTI_AFFINITY, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.ANTI_AFFINITY, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getNamespaceAntiAffinityGroup(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.ANTI_AFFINITY, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.ANTI_AFFINITY, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.namespaces().setNamespaceAntiAffinityGroup(namespace, "invalid-group"));
+ () -> subAdmin.namespaces().setNamespaceAntiAffinityGroup(namespace,
+ "invalid-group"));
Assert.assertTrue(execFlag.get());
}
@@ -1938,12 +1997,14 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.OFFLOAD, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.OFFLOAD, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getOffloadDeleteLagMs(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.OFFLOAD, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.OFFLOAD, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setOffloadDeleteLag(namespace, 100, TimeUnit.HOURS));
Assert.assertTrue(execFlag.get());
@@ -1966,7 +2027,8 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
() -> subAdmin.namespaces().getOffloadThresholdInSeconds(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.OFFLOAD, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.OFFLOAD, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setOffloadThresholdInSeconds(namespace, 10000));
Assert.assertTrue(execFlag.get());
@@ -1983,17 +2045,21 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.ENTRY_FILTERS, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.ENTRY_FILTERS, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getNamespaceEntryFilters(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.ENTRY_FILTERS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.ENTRY_FILTERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.namespaces().setNamespaceEntryFilters(namespace, new EntryFilters("filter1")));
+ () -> subAdmin.namespaces().setNamespaceEntryFilters(namespace,
+ new EntryFilters("filter1")));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.ENTRY_FILTERS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.ENTRY_FILTERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeNamespaceEntryFilters(namespace));
Assert.assertTrue(execFlag.get());
@@ -2010,12 +2076,14 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.ENCRYPTION, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.ENCRYPTION, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getEncryptionRequiredStatus(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.ENCRYPTION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.ENCRYPTION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setEncryptionRequiredStatus(namespace, false));
Assert.assertTrue(execFlag.get());
@@ -2038,12 +2106,15 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
() -> subAdmin.namespaces().getSubscriptionTypesEnabled(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.SUBSCRIPTION_AUTH_MODE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.SUBSCRIPTION_AUTH_MODE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.namespaces().setSubscriptionTypesEnabled(namespace, Sets.newHashSet(SubscriptionType.Failover)));
+ () -> subAdmin.namespaces().setSubscriptionTypesEnabled(namespace,
+ Sets.newHashSet(SubscriptionType.Failover)));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.SUBSCRIPTION_AUTH_MODE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.SUBSCRIPTION_AUTH_MODE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().removeSubscriptionTypesEnabled(namespace));
Assert.assertTrue(execFlag.get());
@@ -2060,12 +2131,14 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.SCHEMA_COMPATIBILITY_STRATEGY, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.SCHEMA_COMPATIBILITY_STRATEGY, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getIsAllowAutoUpdateSchema(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.SCHEMA_COMPATIBILITY_STRATEGY, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.SCHEMA_COMPATIBILITY_STRATEGY, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setIsAllowAutoUpdateSchema(namespace, true));
Assert.assertTrue(execFlag.get());
@@ -2082,14 +2155,17 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.SCHEMA_COMPATIBILITY_STRATEGY, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.SCHEMA_COMPATIBILITY_STRATEGY, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getSchemaAutoUpdateCompatibilityStrategy(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.SCHEMA_COMPATIBILITY_STRATEGY, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.SCHEMA_COMPATIBILITY_STRATEGY, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.namespaces().setSchemaAutoUpdateCompatibilityStrategy(namespace, AutoUpdateDisabled));
+ () -> subAdmin.namespaces().setSchemaAutoUpdateCompatibilityStrategy(namespace,
+ AutoUpdateDisabled));
Assert.assertTrue(execFlag.get());
}
@@ -2104,12 +2180,14 @@ public class NamespaceAuthZTest extends MockedPulsarStandalone {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.SCHEMA_COMPATIBILITY_STRATEGY, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.SCHEMA_COMPATIBILITY_STRATEGY, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().getSchemaValidationEnforced(namespace));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.SCHEMA_COMPATIBILITY_STRATEGY, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.SCHEMA_COMPATIBILITY_STRATEGY, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.namespaces().setSchemaValidationEnforced(namespace, true));
Assert.assertTrue(execFlag.get());
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/NamespacesTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/NamespacesTest.java
index 26107c4bab9..71396b3ef66 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/NamespacesTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/NamespacesTest.java
@@ -79,8 +79,8 @@ import org.apache.pulsar.broker.namespace.NamespaceEphemeralData;
import org.apache.pulsar.broker.namespace.NamespaceService;
import org.apache.pulsar.broker.namespace.OwnershipCache;
import org.apache.pulsar.broker.service.AbstractTopic;
-import org.apache.pulsar.broker.service.TopicPolicyTestUtils;
import org.apache.pulsar.broker.service.Topic;
+import org.apache.pulsar.broker.service.TopicPolicyTestUtils;
import org.apache.pulsar.broker.web.PulsarWebResource;
import org.apache.pulsar.broker.web.RestException;
import org.apache.pulsar.client.admin.PulsarAdminException;
@@ -254,7 +254,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
@Test
public void testCreateNamespaces() throws Exception {
try {
- asyncRequests(response -> namespaces.createNamespace(response, this.testTenant, "other-colo", "my-namespace",
+ asyncRequests(response -> namespaces.createNamespace(response,
+ this.testTenant, "other-colo", "my-namespace",
BundlesData.builder().build()));
fail("should have failed");
} catch (RestException e) {
@@ -276,7 +277,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
}
try {
- asyncRequests(response -> namespaces.createNamespace(response,"non-existing-tenant", "use", "create-namespace-1",
+ asyncRequests(response -> namespaces.createNamespace(response, "non-existing-tenant",
+ "use", "create-namespace-1",
BundlesData.builder().build()));
fail("should have failed");
} catch (RestException e) {
@@ -297,7 +299,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
&& path.equals("/admin/policies/my-tenant/use/my-namespace-3");
});
try {
- asyncRequests(response -> namespaces.createNamespace(response, this.testTenant, "use", "my-namespace-3", BundlesData.builder().build()));
+ asyncRequests(response -> namespaces.createNamespace(response, this.testTenant,
+ "use", "my-namespace-3", BundlesData.builder().build()));
fail("should have failed");
} catch (RestException e) {
// Ok
@@ -384,7 +387,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
assertEquals(asyncRequests(ctx -> namespaces.getPolicies(ctx, this.testTenant, this.testLocalCluster,
this.testLocalNamespaces.get(0).getLocalName())), expectedPolicies);
assertEquals(asyncRequests(ctx -> namespaces.getPermissions(ctx, this.testTenant, this.testLocalCluster,
- this.testLocalNamespaces.get(0).getLocalName())), expectedPolicies.auth_policies.getNamespaceAuthentication());
+ this.testLocalNamespaces.get(0).getLocalName())),
+ expectedPolicies.auth_policies.getNamespaceAuthentication());
asyncRequests(ctx -> namespaces.grantPermissionOnNamespace(ctx, this.testTenant, this.testLocalCluster,
this.testLocalNamespaces.get(0).getLocalName(), "my-role", EnumSet.of(AuthAction.produce)));
@@ -393,7 +397,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
assertEquals(asyncRequests(ctx -> namespaces.getPolicies(ctx, this.testTenant, this.testLocalCluster,
this.testLocalNamespaces.get(0).getLocalName())), expectedPolicies);
assertEquals(asyncRequests(ctx -> namespaces.getPermissions(ctx, this.testTenant, this.testLocalCluster,
- this.testLocalNamespaces.get(0).getLocalName())), expectedPolicies.auth_policies.getNamespaceAuthentication());
+ this.testLocalNamespaces.get(0).getLocalName())),
+ expectedPolicies.auth_policies.getNamespaceAuthentication());
asyncRequests(ctx -> namespaces.grantPermissionOnNamespace(ctx, this.testTenant, this.testLocalCluster,
this.testLocalNamespaces.get(0).getLocalName(), "other-role", EnumSet.of(AuthAction.consume)));
@@ -401,7 +406,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
assertEquals(asyncRequests(ctx -> namespaces.getPolicies(ctx, this.testTenant, this.testLocalCluster,
this.testLocalNamespaces.get(0).getLocalName())), expectedPolicies);
assertEquals(asyncRequests(ctx -> namespaces.getPermissions(ctx, this.testTenant, this.testLocalCluster,
- this.testLocalNamespaces.get(0).getLocalName())), expectedPolicies.auth_policies.getNamespaceAuthentication());
+ this.testLocalNamespaces.get(0).getLocalName())),
+ expectedPolicies.auth_policies.getNamespaceAuthentication());
asyncRequests(ctx -> namespaces.revokePermissionsOnNamespace(ctx, this.testTenant, this.testLocalCluster,
this.testLocalNamespaces.get(0).getLocalName(), "my-role"));
@@ -409,18 +415,21 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
assertEquals(asyncRequests(ctx -> namespaces.getPolicies(ctx, this.testTenant, this.testLocalCluster,
this.testLocalNamespaces.get(0).getLocalName())), expectedPolicies);
assertEquals(asyncRequests(ctx -> namespaces.getPermissions(ctx, this.testTenant, this.testLocalCluster,
- this.testLocalNamespaces.get(0).getLocalName())), expectedPolicies.auth_policies.getNamespaceAuthentication());
+ this.testLocalNamespaces.get(0).getLocalName())),
+ expectedPolicies.auth_policies.getNamespaceAuthentication());
// Non-existing namespaces
try {
- asyncRequests(ctx -> namespaces.getPolicies(ctx, this.testTenant, this.testLocalCluster, "non-existing-namespace-1"));
+ asyncRequests(ctx -> namespaces.getPolicies(ctx, this.testTenant,
+ this.testLocalCluster, "non-existing-namespace-1"));
fail("should have failed");
} catch (RestException e) {
assertEquals(e.getResponse().getStatus(), Status.NOT_FOUND.getStatusCode());
}
try {
- asyncRequests(ctx -> namespaces.getPermissions(ctx, this.testTenant, this.testLocalCluster, "non-existing-namespace-1"));
+ asyncRequests(ctx -> namespaces.getPermissions(ctx, this.testTenant,
+ this.testLocalCluster, "non-existing-namespace-1"));
fail("should have failed");
} catch (RestException e) {
assertEquals(e.getResponse().getStatus(), Status.NOT_FOUND.getStatusCode());
@@ -454,7 +463,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
});
try {
- asyncRequests(ctx -> namespaces.getPolicies(ctx, testNs.getTenant(), testNs.getCluster(), testNs.getLocalName()));
+ asyncRequests(ctx -> namespaces.getPolicies(ctx, testNs.getTenant(),
+ testNs.getCluster(), testNs.getLocalName()));
fail("should have failed");
} catch (RestException e) {
// Ok
@@ -468,7 +478,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
return true;
});
try {
- asyncRequests(ctx -> namespaces.getPermissions(ctx, testNs.getTenant(), testNs.getCluster(), testNs.getLocalName()));
+ asyncRequests(ctx -> namespaces.getPermissions(ctx, testNs.getTenant(),
+ testNs.getCluster(), testNs.getLocalName()));
fail("should have failed");
} catch (RestException e) {
// Ok
@@ -733,7 +744,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
// check the bundle should not unload to an inactive destination broker
response = mock(AsyncResponse.class);
namespaces.unloadNamespaceBundle(response, this.testTenant, this.testOtherCluster,
- this.testLocalNamespaces.get(2).getLocalName(), "0x00000000_0xffffffff", false, "inactive_destination:8080");
+ this.testLocalNamespaces.get(2).getLocalName(), "0x00000000_0xffffffff",
+ false, "inactive_destination:8080");
captor = ArgumentCaptor.forClass(WebApplicationException.class);
verify(response, timeout(5000).atLeast(1)).resume(captor.capture());
assertEquals(captor.getValue().getResponse().getStatus(), Status.CONFLICT.getStatusCode());
@@ -761,7 +773,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
response = mock(AsyncResponse.class);
namespaces.deleteNamespace(response, this.testLocalNamespaces.get(2).getTenant(),
- this.testLocalNamespaces.get(2).getCluster(), this.testLocalNamespaces.get(2).getLocalName(), false, false);
+ this.testLocalNamespaces.get(2).getCluster(), this.testLocalNamespaces.get(2).getLocalName(),
+ false, false);
captor = ArgumentCaptor.forClass(WebApplicationException.class);
verify(response, timeout(5000).times(1)).resume(captor.capture());
assertEquals(captor.getValue().getResponse().getStatus(), Status.TEMPORARY_REDIRECT.getStatusCode());
@@ -775,7 +788,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
@Test
public void testDeleteNamespaces() throws Exception {
AsyncResponse response = mock(AsyncResponse.class);
- namespaces.deleteNamespace(response, this.testTenant, this.testLocalCluster, "non-existing-namespace-1", false, false);
+ namespaces.deleteNamespace(response, this.testTenant, this.testLocalCluster,
+ "non-existing-namespace-1", false, false);
ArgumentCaptor<RestException> errorCaptor = ArgumentCaptor.forClass(RestException.class);
verify(response, timeout(5000).times(1)).resume(errorCaptor.capture());
assertEquals(errorCaptor.getValue().getResponse().getStatus(), Status.NOT_FOUND.getStatusCode());
@@ -787,12 +801,14 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
// setup ownership to localhost
URL localWebServiceUrl = new URL(pulsar.getSafeWebServiceAddress());
- LookupOptions options = LookupOptions.builder().authoritative(false).readOnly(false).requestHttps(false).build();
+ LookupOptions options = LookupOptions.builder().authoritative(false)
+ .readOnly(false).requestHttps(false).build();
doReturn(Optional.of(localWebServiceUrl)).when(nsSvc).getWebServiceUrl(testNs, options);
doReturn(true).when(nsSvc).isServiceUnitOwned(testNs);
response = mock(AsyncResponse.class);
- namespaces.deleteNamespace(response, testNs.getTenant(), testNs.getCluster(), testNs.getLocalName(), false, false);
+ namespaces.deleteNamespace(response, testNs.getTenant(), testNs.getCluster(),
+ testNs.getLocalName(), false, false);
errorCaptor = ArgumentCaptor.forClass(RestException.class);
// Ok, namespace not empty
verify(response, timeout(5000).times(1)).resume(errorCaptor.capture());
@@ -806,7 +822,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
new byte[0], null, null);
response = mock(AsyncResponse.class);
- namespaces.deleteNamespace(response, testNs.getTenant(), testNs.getCluster(), testNs.getLocalName(), false, false);
+ namespaces.deleteNamespace(response, testNs.getTenant(), testNs.getCluster(),
+ testNs.getLocalName(), false, false);
errorCaptor = ArgumentCaptor.forClass(RestException.class);
// Ok, namespace not empty
verify(response, timeout(5000).times(1)).resume(errorCaptor.capture());
@@ -819,7 +836,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
doReturn(Optional.of(localWebServiceUrl)).when(nsSvc).getWebServiceUrl(testNs, options);
doReturn(true).when(nsSvc).isServiceUnitOwned(testNs);
response = mock(AsyncResponse.class);
- namespaces.deleteNamespace(response, testNs.getTenant(), testNs.getCluster(), testNs.getLocalName(), false, false);
+ namespaces.deleteNamespace(response, testNs.getTenant(), testNs.getCluster(),
+ testNs.getLocalName(), false, false);
ArgumentCaptor<Response> responseCaptor = ArgumentCaptor.forClass(Response.class);
verify(response, timeout(5000).times(1)).resume(responseCaptor.capture());
assertEquals(responseCaptor.getValue().getStatus(), Status.NO_CONTENT.getStatusCode());
@@ -829,7 +847,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
doReturn(Optional.of(localWebServiceUrl)).when(nsSvc).getWebServiceUrl(testNs, options);
doReturn(true).when(nsSvc).isServiceUnitOwned(testNs);
response = mock(AsyncResponse.class);
- namespaces.deleteNamespace(response, testNs.getTenant(), testNs.getCluster(), testNs.getLocalName(), false, false);
+ namespaces.deleteNamespace(response, testNs.getTenant(), testNs.getCluster(),
+ testNs.getLocalName(), false, false);
responseCaptor = ArgumentCaptor.forClass(Response.class);
verify(response, timeout(5000).times(1)).resume(responseCaptor.capture());
assertEquals(responseCaptor.getValue().getStatus(), Status.NO_CONTENT.getStatusCode());
@@ -845,7 +864,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
doReturn(Optional.of(localWebServiceUrl)).when(nsSvc).getWebServiceUrl(testNs, options);
doReturn(true).when(nsSvc).isServiceUnitOwned(testNs);
response = mock(AsyncResponse.class);
- namespaces.deleteNamespace(response, testNs.getTenant(), testNs.getCluster(), testNs.getLocalName(), false, false);
+ namespaces.deleteNamespace(response, testNs.getTenant(), testNs.getCluster(),
+ testNs.getLocalName(), false, false);
responseCaptor = ArgumentCaptor.forClass(Response.class);
verify(response, timeout(5000).times(1)).resume(responseCaptor.capture());
assertEquals(responseCaptor.getValue().getStatus(), Status.NO_CONTENT.getStatusCode());
@@ -904,7 +924,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
verify(response, timeout(5000).times(1)).resume(captor.capture());
assertEquals(captor.getValue().getResponse().getStatus(), Status.PRECONDITION_FAILED.getStatusCode());
// make one bundle owned
- LookupOptions optionsHttps = LookupOptions.builder().authoritative(false).requestHttps(true).readOnly(false).build();
+ LookupOptions optionsHttps = LookupOptions.builder().authoritative(false)
+ .requestHttps(true).readOnly(false).build();
doReturn(CompletableFuture.completedFuture(Optional.of(localWebServiceUrl))).when(nsSvc)
.getWebServiceUrlAsync(nsBundles.getBundles().get(0), optionsHttps);
doReturn(CompletableFuture.completedFuture(true)).when(nsSvc)
@@ -966,17 +987,19 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
createBundledTestNamespaces(this.testTenant, this.testLocalCluster, bundledNsLocal, bundleData);
final NamespaceName testNs = NamespaceName.get(this.testTenant, this.testLocalCluster, bundledNsLocal);
- OwnershipCache MockOwnershipCache = spy(pulsar.getNamespaceService().getOwnershipCache());
- doReturn(CompletableFuture.completedFuture(null)).when(MockOwnershipCache).disableOwnership(any(NamespaceBundle.class));
+ OwnershipCache mockOwnershipCache = spy(pulsar.getNamespaceService().getOwnershipCache());
+ doReturn(CompletableFuture.completedFuture(null)).when(mockOwnershipCache)
+ .disableOwnership(any(NamespaceBundle.class));
Field ownership = NamespaceService.class.getDeclaredField("ownershipCache");
ownership.setAccessible(true);
- ownership.set(pulsar.getNamespaceService(), MockOwnershipCache);
+ ownership.set(pulsar.getNamespaceService(), mockOwnershipCache);
mockWebUrl(localWebServiceUrl, testNs);
// split bundles
try {
AsyncResponse response = mock(AsyncResponse.class);
- namespaces.splitNamespaceBundle(response, testTenant, testLocalCluster, bundledNsLocal, "0x00000000_0xffffffff",
+ namespaces.splitNamespaceBundle(response, testTenant, testLocalCluster, bundledNsLocal,
+ "0x00000000_0xffffffff",
false, true, null, null);
ArgumentCaptor<Response> captor = ArgumentCaptor.forClass(Response.class);
verify(response, timeout(5000).times(1)).resume(captor.capture());
@@ -1008,11 +1031,12 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
createBundledTestNamespaces(this.testTenant, this.testLocalCluster, bundledNsLocal, bundleData);
final NamespaceName testNs = NamespaceName.get(this.testTenant, this.testLocalCluster, bundledNsLocal);
- OwnershipCache MockOwnershipCache = spy(pulsar.getNamespaceService().getOwnershipCache());
- doReturn(CompletableFuture.completedFuture(null)).when(MockOwnershipCache).disableOwnership(any(NamespaceBundle.class));
+ OwnershipCache mockOwnershipCache = spy(pulsar.getNamespaceService().getOwnershipCache());
+ doReturn(CompletableFuture.completedFuture(null)).when(mockOwnershipCache)
+ .disableOwnership(any(NamespaceBundle.class));
Field ownership = NamespaceService.class.getDeclaredField("ownershipCache");
ownership.setAccessible(true);
- ownership.set(pulsar.getNamespaceService(), MockOwnershipCache);
+ ownership.set(pulsar.getNamespaceService(), mockOwnershipCache);
mockWebUrl(localWebServiceUrl, testNs);
// split bundles
@@ -1047,12 +1071,15 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
NamespaceBundles nsBundles = nsSvc.getNamespaceBundleFactory().getBundles(testNs, bundleData);
NamespaceBundle testBundle = nsBundles.getBundles().get(0);
// make one bundle owned
- LookupOptions optionsHttps = LookupOptions.builder().authoritative(false).requestHttps(true).readOnly(false).build();
- doReturn(CompletableFuture.completedFuture(Optional.of(localWebServiceUrl))).when(nsSvc).getWebServiceUrlAsync(testBundle, optionsHttps);
+ LookupOptions optionsHttps = LookupOptions.builder().authoritative(false)
+ .requestHttps(true).readOnly(false).build();
+ doReturn(CompletableFuture.completedFuture(Optional.of(localWebServiceUrl)))
+ .when(nsSvc).getWebServiceUrlAsync(testBundle, optionsHttps);
doReturn(true).when(nsSvc).isServiceUnitOwned(testBundle);
doReturn(CompletableFuture.completedFuture(null)).when(nsSvc).unloadNamespaceBundle(testBundle);
AsyncResponse response = mock(AsyncResponse.class);
- namespaces.unloadNamespaceBundle(response, testTenant, testLocalCluster, bundledNsLocal, "0x00000000_0x80000000",
+ namespaces.unloadNamespaceBundle(response, testTenant, testLocalCluster, bundledNsLocal,
+ "0x00000000_0x80000000",
false, null);
verify(response, timeout(5000).times(1)).resume(any(RestException.class));
@@ -1071,7 +1098,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
private void createTestNamespaces(List<NamespaceName> nsnames, BundlesData bundle) throws Exception {
for (NamespaceName nsName : nsnames) {
- asyncRequests(ctx -> namespaces.createNamespace(ctx, nsName.getTenant(), nsName.getCluster(), nsName.getLocalName(), bundle));
+ asyncRequests(ctx -> namespaces.createNamespace(ctx, nsName.getTenant(),
+ nsName.getCluster(), nsName.getLocalName(), bundle));
}
}
@@ -1105,11 +1133,12 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
final NamespaceName testNs = NamespaceName.get(this.testTenant, this.testLocalCluster, bundledNsLocal);
mockWebUrl(localWebServiceUrl, testNs);
- OwnershipCache MockOwnershipCache = spy(pulsar.getNamespaceService().getOwnershipCache());
- doReturn(CompletableFuture.completedFuture(null)).when(MockOwnershipCache).disableOwnership(any(NamespaceBundle.class));
+ OwnershipCache mockOwnershipCache = spy(pulsar.getNamespaceService().getOwnershipCache());
+ doReturn(CompletableFuture.completedFuture(null)).when(mockOwnershipCache)
+ .disableOwnership(any(NamespaceBundle.class));
Field ownership = NamespaceService.class.getDeclaredField("ownershipCache");
ownership.setAccessible(true);
- ownership.set(pulsar.getNamespaceService(), MockOwnershipCache);
+ ownership.set(pulsar.getNamespaceService(), mockOwnershipCache);
RetentionPolicies retention = new RetentionPolicies(10, 10);
namespaces.setRetention(this.testTenant, this.testLocalCluster, bundledNsLocal, retention);
AsyncResponse response = mock(AsyncResponse.class);
@@ -1143,7 +1172,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
NamespaceName testNs = this.testLocalNamespaces.get(0);
PersistencePolicies persistence1 = new PersistencePolicies(3, 2, 1, 0.0);
AsyncResponse response = mock(AsyncResponse.class);
- namespaces.setPersistence(response, testNs.getTenant(), testNs.getCluster(), testNs.getLocalName(), persistence1);
+ namespaces.setPersistence(response, testNs.getTenant(), testNs.getCluster(),
+ testNs.getLocalName(), persistence1);
ArgumentCaptor<Response> responseCaptor = ArgumentCaptor.forClass(Response.class);
verify(response, timeout(5000).times(1)).resume(responseCaptor.capture());
assertEquals(responseCaptor.getValue().getStatus(), Response.Status.NO_CONTENT.getStatusCode());
@@ -1160,7 +1190,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
NamespaceName testNs = this.testLocalNamespaces.get(0);
PersistencePolicies persistence1 = new PersistencePolicies(ensembleSize, writeQuorum, ackQuorum, 0.0);
AsyncResponse response = mock(AsyncResponse.class);
- namespaces.setPersistence(response, testNs.getTenant(), testNs.getCluster(), testNs.getLocalName(), persistence1);
+ namespaces.setPersistence(response, testNs.getTenant(), testNs.getCluster(),
+ testNs.getLocalName(), persistence1);
ArgumentCaptor<RestException> responseCaptor = ArgumentCaptor.forClass(RestException.class);
verify(response, timeout(5000).times(1)).resume(responseCaptor.capture());
assertEquals(responseCaptor.getValue().getResponse().getStatus(), Status.BAD_REQUEST.getStatusCode());
@@ -1171,7 +1202,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
NamespaceName testNs = this.testLocalNamespaces.get(3);
PersistencePolicies persistence = new PersistencePolicies(3, 2, 1, 0.0);
AsyncResponse response = mock(AsyncResponse.class);
- namespaces.setPersistence(response, testNs.getTenant(), testNs.getCluster(), testNs.getLocalName(), persistence);
+ namespaces.setPersistence(response, testNs.getTenant(), testNs.getCluster(),
+ testNs.getLocalName(), persistence);
ArgumentCaptor<RestException> errorCaptor = ArgumentCaptor.forClass(RestException.class);
verify(response, timeout(5000).times(1)).resume(errorCaptor.capture());
assertEquals(errorCaptor.getValue().getResponse().getStatus(), Response.Status.UNAUTHORIZED.getStatusCode());
@@ -1188,11 +1220,12 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
.build();
createBundledTestNamespaces(this.testTenant, this.testLocalCluster, bundledNsLocal, bundleData);
final NamespaceName testNs = NamespaceName.get(this.testTenant, this.testLocalCluster, bundledNsLocal);
- OwnershipCache MockOwnershipCache = spy(pulsar.getNamespaceService().getOwnershipCache());
- doReturn(CompletableFuture.completedFuture(null)).when(MockOwnershipCache).disableOwnership(any(NamespaceBundle.class));
+ OwnershipCache mockOwnershipCache = spy(pulsar.getNamespaceService().getOwnershipCache());
+ doReturn(CompletableFuture.completedFuture(null)).when(mockOwnershipCache)
+ .disableOwnership(any(NamespaceBundle.class));
Field ownership = NamespaceService.class.getDeclaredField("ownershipCache");
ownership.setAccessible(true);
- ownership.set(pulsar.getNamespaceService(), MockOwnershipCache);
+ ownership.set(pulsar.getNamespaceService(), mockOwnershipCache);
TopicName topicName = TopicName.get(testNs.getPersistentTopicName("my-topic"));
PersistentTopics topics = spy(PersistentTopics.class);
topics.setServletContext(new MockServletContext());
@@ -1218,7 +1251,7 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
}
/**
- * Verifies that deleteNamespace cleans up policies(global,local), bundle cache and bundle ownership
+ * Verifies that deleteNamespace cleans up policies(global,local), bundle cache and bundle ownership.
* @throws Exception
*/
@@ -1249,7 +1282,7 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
}
/**
- * Verifies that force deleteNamespace delete all topics in the namespace
+ * Verifies that force deleteNamespace delete all topics in the namespace.
* @throws Exception
*/
@Test
@@ -1259,13 +1292,13 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
String namespace = BrokerTestUtil.newUniqueName(this.testTenant + "/namespace");
String topic = namespace + "/topic";
- String non_persistent_topic = "non-persistent://" + topic;
+ String nonPersistentTopic = "non-persistent://" + topic;
admin.namespaces().createNamespace(namespace, 100);
admin.topics().createPartitionedTopic(topic, 10);
- admin.topics().createNonPartitionedTopic(non_persistent_topic);
+ admin.topics().createNonPartitionedTopic(nonPersistentTopic);
List<String> topicList = admin.topics().getList(namespace);
assertFalse(topicList.isEmpty());
@@ -1312,13 +1345,13 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
String namespace = BrokerTestUtil.newUniqueName(this.testTenant + "/namespace");
String topic = namespace + "/topic";
- String non_persistent_topic = "non-persistent://" + topic;
+ String nonPersistentTopic = "non-persistent://" + topic;
admin.namespaces().createNamespace(namespace, 100);
admin.topics().createPartitionedTopic(topic, 10);
- admin.topics().createNonPartitionedTopic(non_persistent_topic);
+ admin.topics().createNonPartitionedTopic(nonPersistentTopic);
List<String> topicList = admin.topics().getList(namespace);
assertFalse(topicList.isEmpty());
@@ -1461,16 +1494,20 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
asyncRequests(response -> namespaces.setNamespaceMessageTTL(response, this.testTenant, this.testLocalCluster,
namespace, 100));
- int namespaceMessageTTL = (Integer) asyncRequests(response -> namespaces.getNamespaceMessageTTL(response, this.testTenant, this.testLocalCluster,
+ int namespaceMessageTTL = (Integer) asyncRequests(response -> namespaces
+ .getNamespaceMessageTTL(response, this.testTenant, this.testLocalCluster,
namespace));
assertEquals(100, namespaceMessageTTL);
- asyncRequests(response -> namespaces.removeNamespaceMessageTTL(response, this.testTenant, this.testLocalCluster, namespace));
- assertNull(asyncRequests(response -> namespaces.getNamespaceMessageTTL(response, this.testTenant, this.testLocalCluster,
+ asyncRequests(response -> namespaces.removeNamespaceMessageTTL(response,
+ this.testTenant, this.testLocalCluster, namespace));
+ assertNull(asyncRequests(response -> namespaces.getNamespaceMessageTTL(response,
+ this.testTenant, this.testLocalCluster,
namespace)));
try {
- asyncRequests(response -> namespaces.setNamespaceMessageTTL(response, this.testTenant, this.testLocalCluster,
+ asyncRequests(response -> namespaces.setNamespaceMessageTTL(response,
+ this.testTenant, this.testLocalCluster,
namespace, -1));
fail("should have failed");
} catch (RestException e) {
@@ -1698,7 +1735,7 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
admin.namespaces().setMaxTopicsPerNamespace(namespace, 0);
// set namespace policy to no limit
- for (int i = 0; i< 10; ++i) {
+ for (int i = 0; i < 10; ++i) {
admin.topics().createPartitionedTopic(topic + "_v" + i, 2);
admin.topics().createNonPartitionedTopic(topic + "_vn" + i);
}
@@ -1768,7 +1805,7 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
// remove namespace limit
admin.namespaces().removeMaxTopicsPerNamespace(namespace);
- for (int i = 0; i< 10; ++i) {
+ for (int i = 0; i < 10; ++i) {
pulsarClient.newProducer().topic(topic + "_p" + i).create().close();
pulsarClient.newConsumer().topic(topic + "_c" + i).subscriptionName("test_sub").subscribe().close();
}
@@ -1954,7 +1991,7 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
URL localWebServiceUrl = new URL(pulsar.getSafeWebServiceAddress());
final NamespaceName testNs = NamespaceName.get(namespace);
mockWebUrl(localWebServiceUrl, testNs);
- for (int i = 0; i < 10; i ++) {
+ for (int i = 0; i < 10; i++) {
final BundlesData bundles = admin.namespaces().getBundles(namespace);
final String bundle = bundles.getBoundaries().get(0) + "_" + bundles.getBoundaries().get(1);
admin.namespaces().splitNamespaceBundle(namespace, bundle, true, null);
@@ -1980,7 +2017,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
namespace, BundlesData.builder().build()));
// 1. set subscription dispatch
- asyncRequests(response -> namespaces.setSubscriptionDispatchRate(response, this.testTenant, this.testLocalCluster,
+ asyncRequests(response -> namespaces.setSubscriptionDispatchRate(response,
+ this.testTenant, this.testLocalCluster,
namespace, DispatchRateImpl.builder().build()));
// 2. check subscription dispatch
@@ -2007,7 +2045,7 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
}
}
/**
- * see {@link #cleanupNamespaceByNsCollection(Collection)}
+ * see {@link #cleanupNamespaceByNsCollection(Collection)}.
*/
private void cleanupNamespaceByPredicate(String tenant, Predicate<String> predicate) throws Exception{
cleanupNamespaceByNsCollection(admin.namespaces().getNamespaces(tenant).stream()
@@ -2115,14 +2153,16 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
admin.topics().delete(systemTopic, true);
Awaitility.await().atMost(3, TimeUnit.SECONDS).untilAsserted(() -> assertTrue(
- TopicPolicyTestUtils.getTopicPoliciesBypassCache(pulsar.getTopicPoliciesService(), TopicName.get(systemTopic))
+ TopicPolicyTestUtils.getTopicPoliciesBypassCache(pulsar.getTopicPoliciesService(),
+ TopicName.get(systemTopic))
.isEmpty()));
}
@Test
public void testCreateNamespacesWithPolicy() throws Exception {
try {
- asyncRequests(response -> namespaces.createNamespace(response, this.testTenant, "other-colo", "my-namespace",
+ asyncRequests(response -> namespaces.createNamespace(response, this.testTenant,
+ "other-colo", "my-namespace",
new Policies()));
fail("should have failed");
} catch (RestException e) {
@@ -2147,7 +2187,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
}
try {
- asyncRequests(response -> namespaces.createNamespace(response,"non-existing-tenant", "use", "create-namespace-1",
+ asyncRequests(response -> namespaces.createNamespace(response, "non-existing-tenant",
+ "use", "create-namespace-1",
new Policies()));
fail("should have failed");
} catch (RestException e) {
@@ -2169,7 +2210,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
&& path.equals("/admin/policies/my-tenant/use/my-namespace-3");
});
try {
- asyncRequests(response -> namespaces.createNamespace(response, this.testTenant, "use", "my-namespace-3", new Policies()));
+ asyncRequests(response -> namespaces.createNamespace(response, this.testTenant,
+ "use", "my-namespace-3", new Policies()));
fail("should have failed");
} catch (RestException e) {
// Ok
@@ -2179,7 +2221,8 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
private void createTestNamespaces(List<NamespaceName> nsnames, Policies policies) throws Exception {
for (NamespaceName nsName : nsnames) {
- asyncRequests(ctx -> namespaces.createNamespace(ctx, nsName.getTenant(), nsName.getCluster(), nsName.getLocalName(), policies));
+ asyncRequests(ctx -> namespaces.createNamespace(ctx, nsName.getTenant(),
+ nsName.getCluster(), nsName.getLocalName(), policies));
}
}
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 ad6412caa27..3fe61afbcdb 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
@@ -302,9 +302,9 @@ public class PersistentTopicsTest extends MockedPulsarServiceBaseTest {
@Test
public void testCreateSubscriptions() throws Exception {
final int numberOfMessages = 5;
- final String SUB_EARLIEST = "sub-earliest";
- final String SUB_LATEST = "sub-latest";
- final String SUB_NONE_MESSAGE_ID = "sub-none-message-id";
+ final String subEarliest = "sub-earliest";
+ final String subLatest = "sub-latest";
+ final String subNoneMessageId = "sub-none-message-id";
String testLocalTopicName = "subWithPositionOrNot";
final String topicName = "persistent://" + testTenant + "/" + testNamespace + "/" + testLocalTopicName;
@@ -321,56 +321,59 @@ public class PersistentTopicsTest extends MockedPulsarServiceBaseTest {
// 2) Create a subscription from earliest position
AsyncResponse response = mock(AsyncResponse.class);
- persistentTopics.createSubscription(response, testTenant, testNamespace, testLocalTopicName, SUB_EARLIEST, true,
+ persistentTopics.createSubscription(response, testTenant, testNamespace, testLocalTopicName, subEarliest, true,
new ResetCursorData(MessageId.earliest), false);
ArgumentCaptor<Response> responseCaptor = ArgumentCaptor.forClass(Response.class);
verify(response, timeout(5000).times(1)).resume(responseCaptor.capture());
Assert.assertEquals(responseCaptor.getValue().getStatus(), Response.Status.NO_CONTENT.getStatusCode());
response = mock(AsyncResponse.class);
- persistentTopics.getStats(response, testTenant, testNamespace, testLocalTopicName, true, true, false, false, false, false);
+ persistentTopics.getStats(response, testTenant, testNamespace, testLocalTopicName,
+ true, true, false, false, false, false);
ArgumentCaptor<TopicStats> statCaptor = ArgumentCaptor.forClass(TopicStats.class);
verify(response, timeout(5000).times(1)).resume(statCaptor.capture());
TopicStats topicStats = statCaptor.getValue();
- long msgBacklog = topicStats.getSubscriptions().get(SUB_EARLIEST).getMsgBacklog();
- log.info("Message back log for " + SUB_EARLIEST + " is :" + msgBacklog);
+ long msgBacklog = topicStats.getSubscriptions().get(subEarliest).getMsgBacklog();
+ log.info("Message back log for " + subEarliest + " is :" + msgBacklog);
Assert.assertEquals(msgBacklog, numberOfMessages);
// 3) Create a subscription with form latest position
response = mock(AsyncResponse.class);
- persistentTopics.createSubscription(response, testTenant, testNamespace, testLocalTopicName, SUB_LATEST, true,
+ persistentTopics.createSubscription(response, testTenant, testNamespace, testLocalTopicName, subLatest, true,
new ResetCursorData(MessageId.latest), false);
responseCaptor = ArgumentCaptor.forClass(Response.class);
verify(response, timeout(5000).times(1)).resume(responseCaptor.capture());
Assert.assertEquals(responseCaptor.getValue().getStatus(), Response.Status.NO_CONTENT.getStatusCode());
response = mock(AsyncResponse.class);
- persistentTopics.getStats(response, testTenant, testNamespace, testLocalTopicName, true, true, false, false, false, false);
+ persistentTopics.getStats(response, testTenant, testNamespace, testLocalTopicName,
+ true, true, false, false, false, false);
statCaptor = ArgumentCaptor.forClass(TopicStats.class);
verify(response, timeout(5000).times(1)).resume(statCaptor.capture());
topicStats = statCaptor.getValue();
- msgBacklog = topicStats.getSubscriptions().get(SUB_LATEST).getMsgBacklog();
- log.info("Message back log for " + SUB_LATEST + " is :" + msgBacklog);
+ msgBacklog = topicStats.getSubscriptions().get(subLatest).getMsgBacklog();
+ log.info("Message back log for " + subLatest + " is :" + msgBacklog);
Assert.assertEquals(msgBacklog, 0);
// 4) Create a subscription without position
response = mock(AsyncResponse.class);
persistentTopics.createSubscription(response, testTenant, testNamespace, testLocalTopicName,
- SUB_NONE_MESSAGE_ID, true,
+ subNoneMessageId, true,
null, false);
responseCaptor = ArgumentCaptor.forClass(Response.class);
verify(response, timeout(5000).times(1)).resume(responseCaptor.capture());
Assert.assertEquals(responseCaptor.getValue().getStatus(), Response.Status.NO_CONTENT.getStatusCode());
response = mock(AsyncResponse.class);
- persistentTopics.getStats(response, testTenant, testNamespace, testLocalTopicName, true, true, false, false, false, false);
+ persistentTopics.getStats(response, testTenant, testNamespace, testLocalTopicName,
+ true, true, false, false, false, false);
statCaptor = ArgumentCaptor.forClass(TopicStats.class);
verify(response, timeout(5000).times(1)).resume(statCaptor.capture());
topicStats = statCaptor.getValue();
- msgBacklog = topicStats.getSubscriptions().get(SUB_NONE_MESSAGE_ID).getMsgBacklog();
- log.info("Message back log for " + SUB_NONE_MESSAGE_ID + " is :" + msgBacklog);
+ msgBacklog = topicStats.getSubscriptions().get(subNoneMessageId).getMsgBacklog();
+ log.info("Message back log for " + subNoneMessageId + " is :" + msgBacklog);
Assert.assertEquals(msgBacklog, 0);
// 5) Create replicated subscription
@@ -384,7 +387,8 @@ public class PersistentTopicsTest extends MockedPulsarServiceBaseTest {
Assert.assertEquals(responseCaptor.getValue().getStatus(), Response.Status.NO_CONTENT.getStatusCode());
response = mock(AsyncResponse.class);
- persistentTopics.getStats(response, testTenant, testNamespace, testLocalTopicName, true, true, false, false, false, false);
+ persistentTopics.getStats(response, testTenant, testNamespace, testLocalTopicName,
+ true, true, false, false, false, false);
statCaptor = ArgumentCaptor.forClass(TopicStats.class);
verify(response, timeout(5000).times(1)).resume(statCaptor.capture());
topicStats = statCaptor.getValue();
@@ -691,7 +695,8 @@ public class PersistentTopicsTest extends MockedPulsarServiceBaseTest {
AsyncResponse response2 = mock(AsyncResponse.class);
ArgumentCaptor<PartitionedTopicMetadata> responseCaptor2 =
ArgumentCaptor.forClass(PartitionedTopicMetadata.class);
- persistentTopics.updatePartitionedTopic(response2, tenant, namespace, topic, false, false, false, updatedPartition);
+ persistentTopics.updatePartitionedTopic(response2, tenant, namespace, topic,
+ false, false, false, updatedPartition);
Awaitility.await().untilAsserted(() -> {
persistentTopics.getPartitionedMetadata(response2,
tenant, namespace, topic, true, false);
@@ -1865,8 +1870,8 @@ public class PersistentTopicsTest extends MockedPulsarServiceBaseTest {
public void testNamespaceResources() throws Exception {
String ns1V1 = "test/" + testNamespace + "v1";
String ns1V2 = testNamespace + "v2";
- admin.namespaces().createNamespace(testTenant+"/"+ns1V1);
- admin.namespaces().createNamespace(testTenant+"/"+ns1V2);
+ admin.namespaces().createNamespace(testTenant + "/" + ns1V1);
+ admin.namespaces().createNamespace(testTenant + "/" + ns1V2);
List<String> namespaces = pulsar.getPulsarResources().getNamespaceResources().listNamespacesAsync(testTenant)
.get();
@@ -1877,7 +1882,8 @@ public class PersistentTopicsTest extends MockedPulsarServiceBaseTest {
@Test
public void testCreateMissingPartitions() throws Exception {
String topicName = "persistent://" + testTenant + "/" + testNamespaceLocal + "/testCreateMissingPartitions";
- assertThrows(PulsarAdminException.NotFoundException.class, () -> admin.topics().createMissedPartitions(topicName));
+ assertThrows(PulsarAdminException.NotFoundException.class, () -> admin.topics()
+ .createMissedPartitions(topicName));
}
@Test
@@ -1915,7 +1921,7 @@ public class PersistentTopicsTest extends MockedPulsarServiceBaseTest {
admin.topics().createNonPartitionedTopic(topic);
@Cleanup
- Reader<String> __ = pulsarClient.newReader(Schema.STRING)
+ Reader<String> reader = pulsarClient.newReader(Schema.STRING)
.startMessageId(MessageId.earliest)
.subscriptionName(subscription)
.topic(topic)
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/ResourceGroupsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/ResourceGroupsTest.java
index f2266d3ed5f..b8b4f0ea160 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/ResourceGroupsTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/ResourceGroupsTest.java
@@ -132,9 +132,9 @@ public class ResourceGroupsTest extends MockedPulsarServiceBaseTest {
}
// delete the ResourceGroups we created.
- Iterator<String> rg_Iterator = expectedRgNames.iterator();
- while (rg_Iterator.hasNext()) {
- resourcegroups.deleteResourceGroup(rg_Iterator.next());
+ Iterator<String> rgIterator = expectedRgNames.iterator();
+ while (rgIterator.hasNext()) {
+ resourcegroups.deleteResourceGroup(rgIterator.next());
}
}
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TenantEndpointsAuthorizationTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TenantEndpointsAuthorizationTest.java
index 2cf3ea374c3..0d454abf41b 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TenantEndpointsAuthorizationTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TenantEndpointsAuthorizationTest.java
@@ -23,6 +23,8 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
+import java.util.Set;
+import java.util.UUID;
import lombok.SneakyThrows;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.pulsar.broker.authorization.AuthorizationService;
@@ -39,8 +41,6 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.Set;
-import java.util.UUID;
@Test(groups = "broker-admin")
public class TenantEndpointsAuthorizationTest extends MockedPulsarStandalone {
@@ -78,7 +78,8 @@ public class TenantEndpointsAuthorizationTest extends MockedPulsarStandalone {
@AfterMethod(alwaysRun = true)
public void after() throws IllegalAccessException {
if (orignalAuthorizationService != null) {
- FieldUtils.writeField(getPulsarService().getBrokerService(), "authorizationService", orignalAuthorizationService, true);
+ FieldUtils.writeField(getPulsarService().getBrokerService(), "authorizationService",
+ orignalAuthorizationService, true);
}
}
@@ -104,7 +105,8 @@ public class TenantEndpointsAuthorizationTest extends MockedPulsarStandalone {
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.tenants().getTenants());
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin
+ .tenants().getTenants());
}
@@ -119,7 +121,8 @@ public class TenantEndpointsAuthorizationTest extends MockedPulsarStandalone {
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.tenants().getTenantInfo(tenantName));
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin
+ .tenants().getTenantInfo(tenantName));
}
@Test
@@ -155,6 +158,7 @@ public class TenantEndpointsAuthorizationTest extends MockedPulsarStandalone {
verify(spyAuthorizationService).isSuperUser(any(), any());
// ---- test nobody
- Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin.tenants().deleteTenant(tenantName));
+ Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class, () -> nobodyAdmin
+ .tenants().deleteTenant(tenantName));
}
}
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicAuthZTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicAuthZTest.java
index 2e05b28e747..c9fdf1980f6 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicAuthZTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicAuthZTest.java
@@ -81,7 +81,7 @@ public class TopicAuthZTest extends AuthZTest {
configureTokenAuthentication();
configureDefaultAuthorization();
start();
- this.superUserAdmin =PulsarAdmin.builder()
+ this.superUserAdmin = PulsarAdmin.builder()
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(SUPER_USER_TOKEN))
.build();
@@ -103,18 +103,18 @@ public class TopicAuthZTest extends AuthZTest {
private AtomicBoolean setAuthorizationPolicyOperationChecker(String role, Object policyName, Object operation) {
AtomicBoolean execFlag = new AtomicBoolean(false);
- if (operation instanceof PolicyOperation ) {
+ if (operation instanceof PolicyOperation) {
doReturn(true)
.when(authorizationService).isValidOriginalPrincipal(Mockito.any(), Mockito.any(), Mockito.any());
Mockito.doAnswer(invocationOnMock -> {
- String role_ = invocationOnMock.getArgument(4);
- if (role.equals(role_)) {
- PolicyName policyName_ = invocationOnMock.getArgument(1);
- PolicyOperation operation_ = invocationOnMock.getArgument(2);
- Assert.assertEquals(operation_, operation);
- Assert.assertEquals(policyName_, policyName);
+ String role1 = invocationOnMock.getArgument(4);
+ if (role.equals(role1)) {
+ PolicyName policyName1 = invocationOnMock.getArgument(1);
+ PolicyOperation operation1 = invocationOnMock.getArgument(2);
+ Assert.assertEquals(operation1, operation);
+ Assert.assertEquals(policyName1, policyName);
}
execFlag.set(true);
return invocationOnMock.callRealMethod();
@@ -307,19 +307,23 @@ public class TopicAuthZTest extends AuthZTest {
superUserAdmin.topics().createSubscription(topic, "test-sub" + suffix.incrementAndGet(), MessageId.earliest);
// test tenant manager
- tenantManagerAdmin.topics().createSubscription(topic, "test-sub" + suffix.incrementAndGet(), MessageId.earliest);
+ tenantManagerAdmin.topics().createSubscription(topic, "test-sub" + suffix.incrementAndGet(),
+ MessageId.earliest);
// test nobody
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topics().createSubscription(topic, "test-sub" + suffix.incrementAndGet(), MessageId.earliest));
+ () -> subAdmin.topics().createSubscription(topic, "test-sub"
+ + suffix.incrementAndGet(), MessageId.earliest));
for (AuthAction action : AuthAction.values()) {
superUserAdmin.topics().grantPermission(topic, subject, Set.of(action));
if (action == AuthAction.consume) {
- subAdmin.topics().createSubscription(topic, "test-sub" + suffix.incrementAndGet(), MessageId.earliest);
+ subAdmin.topics().createSubscription(topic, "test-sub" + suffix.incrementAndGet(),
+ MessageId.earliest);
} else {
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topics().createSubscription(topic, "test-sub" + suffix.incrementAndGet(), MessageId.earliest));
+ () -> subAdmin.topics().createSubscription(topic, "test-sub"
+ + suffix.incrementAndGet(), MessageId.earliest));
}
superUserAdmin.topics().revokePermissions(topic, subject);
}
@@ -329,12 +333,14 @@ public class TopicAuthZTest extends AuthZTest {
// test superuser
superUserAdmin.topics().updateSubscriptionProperties(topic, "test-sub" , properties);
superUserAdmin.topics().getSubscriptionProperties(topic, "test-sub");
- superUserAdmin.topics().analyzeSubscriptionBacklog(TopicName.get(topic).getPartition(0).getLocalName(), "test-sub", Optional.empty());
+ superUserAdmin.topics().analyzeSubscriptionBacklog(TopicName.get(topic).getPartition(0)
+ .getLocalName(), "test-sub", Optional.empty());
// test tenant manager
tenantManagerAdmin.topics().updateSubscriptionProperties(topic, "test-sub" , properties);
tenantManagerAdmin.topics().getSubscriptionProperties(topic, "test-sub");
- tenantManagerAdmin.topics().analyzeSubscriptionBacklog(TopicName.get(topic).getPartition(0).getLocalName(), "test-sub", Optional.empty());
+ tenantManagerAdmin.topics().analyzeSubscriptionBacklog(TopicName.get(topic).getPartition(0)
+ .getLocalName(), "test-sub", Optional.empty());
// test nobody
AtomicBoolean execFlag = setAuthorizationTopicOperationChecker(subject, TopicOperation.CONSUME);
@@ -349,7 +355,8 @@ public class TopicAuthZTest extends AuthZTest {
execFlag = setAuthorizationTopicOperationChecker(subject, TopicOperation.CONSUME);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topics().analyzeSubscriptionBacklog(TopicName.get(topic).getPartition(0).getLocalName(), "test-sub", Optional.empty()));
+ () -> subAdmin.topics().analyzeSubscriptionBacklog(TopicName.get(topic)
+ .getPartition(0).getLocalName(), "test-sub", Optional.empty()));
Assert.assertTrue(execFlag.get());
for (AuthAction action : AuthAction.values()) {
@@ -357,7 +364,8 @@ public class TopicAuthZTest extends AuthZTest {
if (action == AuthAction.consume) {
subAdmin.topics().updateSubscriptionProperties(topic, "test-sub", properties);
subAdmin.topics().getSubscriptionProperties(topic, "test-sub");
- subAdmin.topics().analyzeSubscriptionBacklog(TopicName.get(topic).getPartition(0).getLocalName(), "test-sub", Optional.empty());
+ subAdmin.topics().analyzeSubscriptionBacklog(TopicName.get(topic).getPartition(0)
+ .getLocalName(), "test-sub", Optional.empty());
} else {
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topics().updateSubscriptionProperties(topic, "test-sub", properties));
@@ -366,7 +374,8 @@ public class TopicAuthZTest extends AuthZTest {
() -> subAdmin.topics().getSubscriptionProperties(topic, "test-sub"));
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topics().analyzeSubscriptionBacklog(TopicName.get(topic).getPartition(0).getLocalName(), "test-sub", Optional.empty()));
+ () -> subAdmin.topics().analyzeSubscriptionBacklog(TopicName.get(topic).getPartition(0)
+ .getLocalName(), "test-sub", Optional.empty()));
}
superUserAdmin.topics().revokePermissions(topic, subject);
}
@@ -767,7 +776,7 @@ public class TopicAuthZTest extends AuthZTest {
for (AuthAction action : AuthAction.values()) {
superUserAdmin.topics().grantPermission(topic, subject, Set.of(action));
if (AuthAction.consume == action) {
- subAdmin.topics().skipAllMessages(topic,subName);
+ subAdmin.topics().skipAllMessages(topic, subName);
} else {
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topics().skipAllMessages(topic, subName));
@@ -966,7 +975,8 @@ public class TopicAuthZTest extends AuthZTest {
subAdmin.topics().getMessagesById(topic, messageId.getLedgerId(), messageId.getEntryId());
} else {
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topics().getMessagesById(topic, messageId.getLedgerId(), messageId.getEntryId()));
+ () -> subAdmin.topics().getMessagesById(topic, messageId.getLedgerId(),
+ messageId.getEntryId()));
}
superUserAdmin.topics().revokePermissions(topic, subject);
}
@@ -1223,7 +1233,8 @@ public class TopicAuthZTest extends AuthZTest {
// test tenant manager
tenantManagerAdmin.topicPolicies().getEntryFiltersPerTopic(topic, true);
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.ENTRY_FILTERS, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.ENTRY_FILTERS, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getEntryFiltersPerTopic(topic, false));
Assert.assertTrue(execFlag.get());
@@ -1252,7 +1263,8 @@ public class TopicAuthZTest extends AuthZTest {
.authentication(new AuthenticationToken(token))
.build();
//
- final EntryFilterProvider oldEntryFilterProvider = getPulsarService().getBrokerService().getEntryFilterProvider();
+ final EntryFilterProvider oldEntryFilterProvider = getPulsarService()
+ .getBrokerService().getEntryFilterProvider();
@Cleanup
final MockEntryFilterProvider testEntryFilterProvider =
new MockEntryFilterProvider(getServiceConfiguration());
@@ -1271,7 +1283,8 @@ public class TopicAuthZTest extends AuthZTest {
// test tenant manager
tenantManagerAdmin.topicPolicies().setEntryFiltersPerTopic(topic, entryFilter);
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.ENTRY_FILTERS, PolicyOperation.WRITE);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.ENTRY_FILTERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().setEntryFiltersPerTopic(topic, entryFilter));
Assert.assertTrue(execFlag.get());
@@ -1301,7 +1314,8 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- final EntryFilterProvider oldEntryFilterProvider = getPulsarService().getBrokerService().getEntryFilterProvider();
+ final EntryFilterProvider oldEntryFilterProvider = getPulsarService()
+ .getBrokerService().getEntryFilterProvider();
@Cleanup
final MockEntryFilterProvider testEntryFilterProvider =
new MockEntryFilterProvider(getServiceConfiguration());
@@ -1361,14 +1375,16 @@ public class TopicAuthZTest extends AuthZTest {
tenantManagerAdmin.topics().removeShadowTopics(topic);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topics().setShadowTopics(topic, Lists.newArrayList(shadowTopic)));
+ () -> subAdmin.topics().setShadowTopics(topic,
+ Lists.newArrayList(shadowTopic)));
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topics().getShadowTopics(topic));
for (AuthAction action : AuthAction.values()) {
superUserAdmin.topics().grantPermission(topic, subject, Set.of(action));
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topics().setShadowTopics(topic, Lists.newArrayList(shadowTopic)));
+ () -> subAdmin.topics().setShadowTopics(topic,
+ Lists.newArrayList(shadowTopic)));
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topics().getShadowTopics(topic));
superUserAdmin.topics().revokePermissions(topic, subject);
@@ -1390,7 +1406,8 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationTopicOperationChecker(subject, NamespaceOperation.GET_TOPICS);
+ AtomicBoolean execFlag = setAuthorizationTopicOperationChecker(subject,
+ NamespaceOperation.GET_TOPICS);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topics().getList("public/default"));
Assert.assertTrue(execFlag.get());
@@ -1419,18 +1436,21 @@ public class TopicAuthZTest extends AuthZTest {
.build();
//
superUserAdmin.topics().getPermissions(topic);
- superUserAdmin.topics().grantPermission(topic, subject, Sets.newHashSet(AuthAction.functions));
+ superUserAdmin.topics().grantPermission(topic, subject,
+ Sets.newHashSet(AuthAction.functions));
superUserAdmin.topics().revokePermissions(topic, subject);
// test tenant manager
tenantManagerAdmin.topics().getPermissions(topic);
- tenantManagerAdmin.topics().grantPermission(topic, subject, Sets.newHashSet(AuthAction.functions));
+ tenantManagerAdmin.topics().grantPermission(topic, subject,
+ Sets.newHashSet(AuthAction.functions));
tenantManagerAdmin.topics().revokePermissions(topic, subject);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topics().getPermissions(topic));
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topics().grantPermission(topic, subject, Sets.newHashSet(AuthAction.functions)));
+ () -> subAdmin.topics().grantPermission(topic, subject,
+ Sets.newHashSet(AuthAction.functions)));
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topics().revokePermissions(topic, subject));
@@ -1451,17 +1471,21 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.OFFLOAD, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.OFFLOAD, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getOffloadPolicies(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.OFFLOAD, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.OFFLOAD, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topicPolicies().setOffloadPolicies(topic, OffloadPolicies.builder().build()));
+ () -> subAdmin.topicPolicies().setOffloadPolicies(topic,
+ OffloadPolicies.builder().build()));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.OFFLOAD, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.OFFLOAD, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeOffloadPolicies(topic));
Assert.assertTrue(execFlag.get());
@@ -1483,17 +1507,20 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_UNACKED, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_UNACKED, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getMaxUnackedMessagesOnConsumer(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_UNACKED, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_UNACKED,
+ PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().setMaxUnackedMessagesOnConsumer(topic, 2));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_UNACKED, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_UNACKED,
+ PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeMaxUnackedMessagesOnConsumer(topic));
Assert.assertTrue(execFlag.get());
@@ -1515,17 +1542,20 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.DEDUPLICATION_SNAPSHOT, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DEDUPLICATION_SNAPSHOT, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getDeduplicationSnapshotInterval(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.DEDUPLICATION_SNAPSHOT, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DEDUPLICATION_SNAPSHOT, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().setDeduplicationSnapshotInterval(topic, 2));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.DEDUPLICATION_SNAPSHOT, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DEDUPLICATION_SNAPSHOT, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeDeduplicationSnapshotInterval(topic));
Assert.assertTrue(execFlag.get());
@@ -1547,17 +1577,21 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.INACTIVE_TOPIC, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.INACTIVE_TOPIC, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getInactiveTopicPolicies(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.INACTIVE_TOPIC, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.INACTIVE_TOPIC, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topicPolicies().setInactiveTopicPolicies(topic, new InactiveTopicPolicies()));
+ () -> subAdmin.topicPolicies().setInactiveTopicPolicies(topic,
+ new InactiveTopicPolicies()));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.INACTIVE_TOPIC, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.INACTIVE_TOPIC, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeInactiveTopicPolicies(topic));
Assert.assertTrue(execFlag.get());
@@ -1579,17 +1613,20 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_UNACKED, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_UNACKED, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getMaxUnackedMessagesOnSubscription(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_UNACKED, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_UNACKED, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().setMaxUnackedMessagesOnSubscription(topic, 2));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_UNACKED, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_UNACKED, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeMaxUnackedMessagesOnSubscription(topic));
Assert.assertTrue(execFlag.get());
@@ -1611,17 +1648,21 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.DELAYED_DELIVERY, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DELAYED_DELIVERY, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getDelayedDeliveryPolicy(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.DELAYED_DELIVERY, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DELAYED_DELIVERY, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topicPolicies().setDelayedDeliveryPolicy(topic, DelayedDeliveryPolicies.builder().build()));
+ () -> subAdmin.topicPolicies().setDelayedDeliveryPolicy(topic,
+ DelayedDeliveryPolicies.builder().build()));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.DELAYED_DELIVERY, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DELAYED_DELIVERY, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeDelayedDeliveryPolicy(topic));
Assert.assertTrue(execFlag.get());
@@ -1643,17 +1684,21 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.AUTO_SUBSCRIPTION_CREATION, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.AUTO_SUBSCRIPTION_CREATION, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getAutoSubscriptionCreation(topic, false));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.AUTO_SUBSCRIPTION_CREATION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.AUTO_SUBSCRIPTION_CREATION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topicPolicies().setAutoSubscriptionCreation(topic, AutoSubscriptionCreationOverride.builder().build()));
+ () -> subAdmin.topicPolicies().setAutoSubscriptionCreation(topic,
+ AutoSubscriptionCreationOverride.builder().build()));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.AUTO_SUBSCRIPTION_CREATION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.AUTO_SUBSCRIPTION_CREATION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeAutoSubscriptionCreation(topic));
Assert.assertTrue(execFlag.get());
@@ -1675,17 +1720,20 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RATE, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RATE, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getSubscribeRate(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RATE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RATE,
+ PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().setSubscribeRate(topic, new SubscribeRate()));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RATE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RATE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeSubscribeRate(topic));
Assert.assertTrue(execFlag.get());
@@ -1707,17 +1755,21 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.SUBSCRIPTION_AUTH_MODE, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.SUBSCRIPTION_AUTH_MODE, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getSubscriptionTypesEnabled(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.SUBSCRIPTION_AUTH_MODE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.SUBSCRIPTION_AUTH_MODE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topicPolicies().setSubscriptionTypesEnabled(topic, new HashSet<>()));
+ () -> subAdmin.topicPolicies().setSubscriptionTypesEnabled(topic,
+ new HashSet<>()));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.SUBSCRIPTION_AUTH_MODE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.SUBSCRIPTION_AUTH_MODE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeSubscriptionTypesEnabled(topic));
Assert.assertTrue(execFlag.get());
@@ -1739,17 +1791,20 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RATE, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RATE, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getPublishRate(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RATE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RATE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().setPublishRate(topic, new PublishRate()));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RATE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RATE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removePublishRate(topic));
Assert.assertTrue(execFlag.get());
@@ -1771,17 +1826,21 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_CONSUMERS, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_CONSUMERS, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getMaxConsumersPerSubscription(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topicPolicies().setMaxConsumersPerSubscription(topic, 2));
+ () -> subAdmin.topicPolicies().setMaxConsumersPerSubscription(topic,
+ 2));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeMaxConsumersPerSubscription(topic));
Assert.assertTrue(execFlag.get());
@@ -1803,17 +1862,20 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.COMPACTION, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.COMPACTION, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getCompactionThreshold(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.COMPACTION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.COMPACTION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().setCompactionThreshold(topic, 20000));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.COMPACTION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.COMPACTION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeCompactionThreshold(topic));
Assert.assertTrue(execFlag.get());
@@ -1835,17 +1897,21 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RATE, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RATE, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getDispatchRate(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RATE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RATE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topicPolicies().setDispatchRate(topic, DispatchRate.builder().build()));
+ () -> subAdmin.topicPolicies().setDispatchRate(topic,
+ DispatchRate.builder().build()));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RATE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RATE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeDispatchRate(topic));
Assert.assertTrue(execFlag.get());
@@ -1867,17 +1933,20 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_CONSUMERS, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_CONSUMERS, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getMaxConsumers(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().setMaxConsumers(topic, 2));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_CONSUMERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeMaxConsumers(topic));
Assert.assertTrue(execFlag.get());
@@ -1899,17 +1968,20 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_PRODUCERS, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_PRODUCERS, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getMaxProducers(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_PRODUCERS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_PRODUCERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().setMaxProducers(topic, 2));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.MAX_PRODUCERS, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.MAX_PRODUCERS, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeMaxProducers(topic));
Assert.assertTrue(execFlag.get());
@@ -1931,17 +2003,21 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.REPLICATION_RATE, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.REPLICATION_RATE, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getReplicatorDispatchRate(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.REPLICATION_RATE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.REPLICATION_RATE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topicPolicies().setReplicatorDispatchRate(topic, DispatchRate.builder().build()));
+ () -> subAdmin.topicPolicies().setReplicatorDispatchRate(topic,
+ DispatchRate.builder().build()));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.REPLICATION_RATE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.REPLICATION_RATE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeReplicatorDispatchRate(topic));
Assert.assertTrue(execFlag.get());
@@ -1963,17 +2039,21 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.PERSISTENCE, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.PERSISTENCE, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getPersistence(topic));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.PERSISTENCE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.PERSISTENCE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topicPolicies().setPersistence(topic, new PersistencePolicies()));
+ () -> subAdmin.topicPolicies().setPersistence(topic,
+ new PersistencePolicies()));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.PERSISTENCE, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.PERSISTENCE, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removePersistence(topic));
Assert.assertTrue(execFlag.get());
@@ -1995,17 +2075,20 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RETENTION, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RETENTION, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getRetention(topic, false));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RETENTION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RETENTION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().setRetention(topic, new RetentionPolicies()));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.RETENTION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.RETENTION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeRetention(topic));
Assert.assertTrue(execFlag.get());
@@ -2027,17 +2110,20 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.DEDUPLICATION, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DEDUPLICATION, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getDeduplicationStatus(topic, false));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.DEDUPLICATION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DEDUPLICATION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().setDeduplicationStatus(topic, false));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.DEDUPLICATION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.DEDUPLICATION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeDeduplicationStatus(topic));
Assert.assertTrue(execFlag.get());
@@ -2059,17 +2145,20 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.TTL, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.TTL, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getMessageTTL(topic, false));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.TTL, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.TTL, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().setMessageTTL(topic, 2));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.TTL, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.TTL, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeMessageTTL(topic));
Assert.assertTrue(execFlag.get());
@@ -2091,17 +2180,21 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.BACKLOG, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.BACKLOG, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().getBacklogQuotaMap(topic, false));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.BACKLOG, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.BACKLOG, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
- () -> subAdmin.topicPolicies().setBacklogQuota(topic, BacklogQuota.builder().build()));
+ () -> subAdmin.topicPolicies().setBacklogQuota(topic,
+ BacklogQuota.builder().build()));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.BACKLOG, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.BACKLOG, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topicPolicies().removeBacklogQuota(topic));
Assert.assertTrue(execFlag.get());
@@ -2123,17 +2216,20 @@ public class TopicAuthZTest extends AuthZTest {
.serviceHttpUrl(getPulsarService().getWebServiceAddress())
.authentication(new AuthenticationToken(token))
.build();
- AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.REPLICATION, PolicyOperation.READ);
+ AtomicBoolean execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.REPLICATION, PolicyOperation.READ);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topics().getReplicationClusters(topic, false));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.REPLICATION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.REPLICATION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topics().setReplicationClusters(topic, new ArrayList<>()));
Assert.assertTrue(execFlag.get());
- execFlag = setAuthorizationPolicyOperationChecker(subject, PolicyName.REPLICATION, PolicyOperation.WRITE);
+ execFlag = setAuthorizationPolicyOperationChecker(subject,
+ PolicyName.REPLICATION, PolicyOperation.WRITE);
Assert.assertThrows(PulsarAdminException.NotAuthorizedException.class,
() -> subAdmin.topics().removeReplicationClusters(topic));
Assert.assertTrue(execFlag.get());
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicAutoCreationTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicAutoCreationTest.java
index c90ad15242c..ca2091816cc 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicAutoCreationTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicAutoCreationTest.java
@@ -143,8 +143,8 @@ public class TopicAutoCreationTest extends ProducerConsumerBase {
new InetSocketAddress(pulsar.getAdvertisedAddress(), pulsar.getBrokerListenPort().get());
return CompletableFuture.completedFuture(new LookupTopicResult(brokerAddress, brokerAddress, false));
... 60750 lines suppressed ...