Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
*/
package org.apache.pulsar.broker.intercept;

import static org.mockito.AdditionalAnswers.delegatesTo;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
Expand Down Expand Up @@ -93,7 +96,9 @@ public void setup() throws Exception {
@Override
protected void customizeMainPulsarTestContextBuilder(PulsarTestContext.Builder pulsarTestContextBuilder) {
HashMap<String, BrokerInterceptorWithClassLoader> brokerInterceptorWithClassLoaderHashMap = new HashMap<>();
NarClassLoader narClassLoader = mock(NarClassLoader.class);
// The filter chain uses this context class loader for resource and service-provider lookup.
NarClassLoader narClassLoader = mock(NarClassLoader.class,
delegatesTo(new URLClassLoader(new URL[0], getClass().getClassLoader())));
BrokerInterceptorWithClassLoader counterBrokerInterceptor =
new BrokerInterceptorWithClassLoader(new CounterBrokerInterceptor(), narClassLoader);
brokerInterceptorWithClassLoaderHashMap.put(CounterBrokerInterceptor.NAME, counterBrokerInterceptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
*/
package org.apache.pulsar.broker.intercept;

import static org.mockito.AdditionalAnswers.delegatesTo;
import static org.mockito.Mockito.mock;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -63,7 +66,9 @@ protected void cleanup() throws Exception {
protected void customizeMainPulsarTestContextBuilder(PulsarTestContext.Builder pulsarTestContextBuilder) {
Map<String, BrokerInterceptorWithClassLoader> listenerMap = new HashMap<>();
BrokerInterceptor interceptor = new ExceptionsBrokerInterceptor();
NarClassLoader narClassLoader = mock(NarClassLoader.class);
// The filter chain uses this context class loader for resource and service-provider lookup.
NarClassLoader narClassLoader = mock(NarClassLoader.class,
delegatesTo(new URLClassLoader(new URL[0], getClass().getClassLoader())));
listenerMap.put(interceptorName, new BrokerInterceptorWithClassLoader(interceptor, narClassLoader));
pulsarTestContextBuilder.brokerInterceptor(new BrokerInterceptors(listenerMap));
}
Expand Down
Loading