Search in sources :

Example 1 with MockZooKeeperSession

use of org.apache.zookeeper.MockZooKeeperSession in project pulsar by apache.

the class OwnerShipForCurrentServerTestBase method setupBrokerMocks.

protected void setupBrokerMocks(PulsarService pulsar) throws Exception {
    // Override default providers with mocked ones
    doReturn(mockBookKeeperClientFactory).when(pulsar).newBookKeeperClientFactory();
    MockZooKeeperSession mockZooKeeperSession = MockZooKeeperSession.newInstance(mockZooKeeper);
    doReturn(new ZKMetadataStore(mockZooKeeperSession)).when(pulsar).createLocalMetadataStore();
    doReturn(new ZKMetadataStore(mockZooKeeperSession)).when(pulsar).createConfigurationMetadataStore();
    Supplier<NamespaceService> namespaceServiceSupplier = () -> spyWithClassAndConstructorArgs(NamespaceService.class, pulsar);
    doReturn(namespaceServiceSupplier).when(pulsar).getNamespaceServiceProvider();
    SameThreadOrderedSafeExecutor executor = new SameThreadOrderedSafeExecutor();
    orderedExecutorList.add(executor);
    doReturn(executor).when(pulsar).getOrderedExecutor();
    doReturn(new CounterBrokerInterceptor()).when(pulsar).getBrokerInterceptor();
    doAnswer((invocation) -> spy(invocation.callRealMethod())).when(pulsar).newCompactor();
}
Also used : CounterBrokerInterceptor(org.apache.pulsar.broker.intercept.CounterBrokerInterceptor) MockZooKeeperSession(org.apache.zookeeper.MockZooKeeperSession) SameThreadOrderedSafeExecutor(org.apache.pulsar.broker.auth.SameThreadOrderedSafeExecutor) ZKMetadataStore(org.apache.pulsar.metadata.impl.ZKMetadataStore)

Example 2 with MockZooKeeperSession

use of org.apache.zookeeper.MockZooKeeperSession in project aop by streamnative.

the class AopProtocolHandlerTestBase method setupBrokerMocks.

protected void setupBrokerMocks(PulsarService pulsar) throws Exception {
    // Override default providers with mocked ones
    doReturn(mockBookKeeperClientFactory).when(pulsar).newBookKeeperClientFactory();
    MockZooKeeperSession mockZooKeeperSession = MockZooKeeperSession.newInstance(mockZooKeeper);
    doReturn(new ZKMetadataStore(mockZooKeeperSession)).when(pulsar).createLocalMetadataStore();
    doReturn(new ZKMetadataStore(mockZooKeeperSession)).when(pulsar).createConfigurationMetadataStore();
    Supplier<NamespaceService> namespaceServiceSupplier = () -> spy(new NamespaceService(pulsar));
    doReturn(namespaceServiceSupplier).when(pulsar).getNamespaceServiceProvider();
    doReturn(sameThreadOrderedSafeExecutor).when(pulsar).getOrderedExecutor();
}
Also used : NamespaceService(org.apache.pulsar.broker.namespace.NamespaceService) MockZooKeeperSession(org.apache.zookeeper.MockZooKeeperSession) ZKMetadataStore(org.apache.pulsar.metadata.impl.ZKMetadataStore)

Example 3 with MockZooKeeperSession

use of org.apache.zookeeper.MockZooKeeperSession in project aop by streamnative.

the class AmqpProtocolHandlerTestBase method setupBrokerMocks.

protected void setupBrokerMocks(PulsarService pulsar) throws Exception {
    // Override default providers with mocked ones
    doReturn(mockBookKeeperClientFactory).when(pulsar).newBookKeeperClientFactory();
    MockZooKeeperSession mockZooKeeperSession = MockZooKeeperSession.newInstance(mockZooKeeper);
    doReturn(new ZKMetadataStore(mockZooKeeperSession)).when(pulsar).createLocalMetadataStore();
    doReturn(new ZKMetadataStore(mockZooKeeperSession)).when(pulsar).createConfigurationMetadataStore();
    Supplier<NamespaceService> namespaceServiceSupplier = () -> spy(new NamespaceService(pulsar));
    doReturn(namespaceServiceSupplier).when(pulsar).getNamespaceServiceProvider();
    doReturn(sameThreadOrderedSafeExecutor).when(pulsar).getOrderedExecutor();
}
Also used : NamespaceService(org.apache.pulsar.broker.namespace.NamespaceService) MockZooKeeperSession(org.apache.zookeeper.MockZooKeeperSession) ZKMetadataStore(org.apache.pulsar.metadata.impl.ZKMetadataStore)

Example 4 with MockZooKeeperSession

use of org.apache.zookeeper.MockZooKeeperSession in project pulsar by apache.

the class TransactionTestBase method setupBrokerMocks.

protected void setupBrokerMocks(PulsarService pulsar) throws Exception {
    // Override default providers with mocked ones
    doReturn(mockBookKeeperClientFactory).when(pulsar).newBookKeeperClientFactory();
    MockZooKeeperSession mockZooKeeperSession = MockZooKeeperSession.newInstance(mockZooKeeper);
    doReturn(new ZKMetadataStore(mockZooKeeperSession)).when(pulsar).createLocalMetadataStore();
    doReturn(new ZKMetadataStore(mockZooKeeperSession)).when(pulsar).createConfigurationMetadataStore();
    Supplier<NamespaceService> namespaceServiceSupplier = () -> spyWithClassAndConstructorArgs(NamespaceService.class, pulsar);
    doReturn(namespaceServiceSupplier).when(pulsar).getNamespaceServiceProvider();
    SameThreadOrderedSafeExecutor executor = new SameThreadOrderedSafeExecutor();
    orderedExecutorList.add(executor);
    doReturn(executor).when(pulsar).getOrderedExecutor();
    doReturn(new CounterBrokerInterceptor()).when(pulsar).getBrokerInterceptor();
    doAnswer((invocation) -> spy(invocation.callRealMethod())).when(pulsar).newCompactor();
}
Also used : CounterBrokerInterceptor(org.apache.pulsar.broker.intercept.CounterBrokerInterceptor) NamespaceService(org.apache.pulsar.broker.namespace.NamespaceService) MockZooKeeperSession(org.apache.zookeeper.MockZooKeeperSession) SameThreadOrderedSafeExecutor(org.apache.pulsar.broker.auth.SameThreadOrderedSafeExecutor) ZKMetadataStore(org.apache.pulsar.metadata.impl.ZKMetadataStore)

Aggregations

ZKMetadataStore (org.apache.pulsar.metadata.impl.ZKMetadataStore)4 MockZooKeeperSession (org.apache.zookeeper.MockZooKeeperSession)4 NamespaceService (org.apache.pulsar.broker.namespace.NamespaceService)3 SameThreadOrderedSafeExecutor (org.apache.pulsar.broker.auth.SameThreadOrderedSafeExecutor)2 CounterBrokerInterceptor (org.apache.pulsar.broker.intercept.CounterBrokerInterceptor)2