This is an automated email from the ASF dual-hosted git repository.
technoboy pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-3.3 by this push:
new c8ff45af5de [fix][test] Fix remaining UnfinishedStubbingException
issue with AuthZTests (#24174)
c8ff45af5de is described below
commit c8ff45af5dea586a198545ac697a8db96f560cd5
Author: Lari Hotari <[email protected]>
AuthorDate: Fri Apr 11 12:38:25 2025 +0300
[fix][test] Fix remaining UnfinishedStubbingException issue with AuthZTests
(#24174)
---
.../org/apache/pulsar/broker/admin/AuthZTest.java | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
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 d09ffe268d1..2d46ce26334 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
@@ -23,6 +23,7 @@ import io.jsonwebtoken.Jwts;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
+import lombok.SneakyThrows;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.pulsar.broker.BrokerTestUtil;
import org.apache.pulsar.broker.authorization.AuthorizationService;
@@ -34,7 +35,6 @@ import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
public abstract class AuthZTest extends MockedPulsarStandalone {
@@ -44,8 +44,6 @@ public abstract class AuthZTest extends
MockedPulsarStandalone {
protected AuthorizationService authorizationService;
- protected AuthorizationService orignalAuthorizationService;
-
protected static final String TENANT_ADMIN_SUBJECT =
UUID.randomUUID().toString();
protected static final String TENANT_ADMIN_TOKEN = Jwts.builder()
.claim("sub", TENANT_ADMIN_SUBJECT).signWith(SECRET_KEY).compact();
@@ -63,15 +61,19 @@ public abstract class AuthZTest extends
MockedPulsarStandalone {
tenantManagerAdmin.close();
tenantManagerAdmin = null;
}
- authorizationService = null;
- orignalAuthorizationService = null;
+ if (authorizationService != null) {
+ Mockito.reset(authorizationService);
+ authorizationService = null;
+ }
super.close();
}
- @BeforeMethod(alwaysRun = true)
- public void before() throws IllegalAccessException {
- orignalAuthorizationService =
getPulsarService().getBrokerService().getAuthorizationService();
- authorizationService =
BrokerTestUtil.spyWithoutRecordingInvocations(orignalAuthorizationService);
+ @SneakyThrows
+ @Override
+ protected void start() {
+ super.start();
+ authorizationService = BrokerTestUtil.spyWithoutRecordingInvocations(
+
getPulsarService().getBrokerService().getAuthorizationService());
FieldUtils.writeField(getPulsarService().getBrokerService(),
"authorizationService",
authorizationService, true);
Mockito.doAnswer(invocationOnMock -> {
@@ -98,8 +100,6 @@ public abstract class AuthZTest extends
MockedPulsarStandalone {
@AfterMethod(alwaysRun = true)
public void after() throws IllegalAccessException {
- FieldUtils.writeField(getPulsarService().getBrokerService(),
"authorizationService",
- orignalAuthorizationService, true);
allowNamespaceOperationAsyncHandler = null;
allowTopicOperationAsyncHandler = null;
}