Add some additionlay capabilites for failing the connection when certain events occur
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/44ccf5f1 Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/44ccf5f1 Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/44ccf5f1 Branch: refs/heads/master Commit: 44ccf5f115f1a7155e4998745fe39cb203fb391b Parents: 86d1405 Author: Timothy Bish <tabish...@gmail.com> Authored: Thu Feb 12 16:19:08 2015 -0500 Committer: Timothy Bish <tabish...@gmail.com> Committed: Thu Feb 12 16:19:08 2015 -0500 ---------------------------------------------------------------------- .../FailoverProviderOfflineBehaviorTest.java | 40 +++++- .../provider/failover/FailoverProviderTest.java | 40 +++--- .../failover/FailoverProviderTestSupport.java | 14 +- .../qpid/jms/provider/mock/MockProvider.java | 23 ++- .../jms/provider/mock/MockProviderContext.java | 87 ------------ .../jms/provider/mock/MockProviderFactory.java | 8 +- .../qpid/jms/provider/mock/MockRemotePeer.java | 142 +++++++++++++++++++ .../provider/mock/ResourceLifecycleFilter.java | 29 ++++ 8 files changed, 256 insertions(+), 127 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/44ccf5f1/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderOfflineBehaviorTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderOfflineBehaviorTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderOfflineBehaviorTest.java index 64ab24b..3b15b8c 100644 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderOfflineBehaviorTest.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderOfflineBehaviorTest.java @@ -16,6 +16,7 @@ */ package org.apache.qpid.jms.provider.failover; +import java.io.IOException; import java.net.URI; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -29,7 +30,9 @@ import org.apache.qpid.jms.JmsConnection; import org.apache.qpid.jms.JmsConnectionFactory; import org.apache.qpid.jms.JmsConnectionListener; import org.apache.qpid.jms.message.JmsInboundMessageDispatch; -import org.apache.qpid.jms.provider.mock.MockProviderContext; +import org.apache.qpid.jms.meta.JmsResource; +import org.apache.qpid.jms.meta.JmsSessionInfo; +import org.apache.qpid.jms.provider.mock.ResourceLifecycleFilter; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -64,7 +67,7 @@ public class FailoverProviderOfflineBehaviorTest extends FailoverProviderTestSup connection = (JmsConnection) factory.createConnection(); connection.addConnectionListener(new ConnectionInterruptionListener()); connection.start(); - MockProviderContext.INSTANCE.shutdown(); + mockPeer.shutdown(); connectionInterrupted.await(9, TimeUnit.SECONDS); connection.close(); } @@ -75,7 +78,7 @@ public class FailoverProviderOfflineBehaviorTest extends FailoverProviderTestSup connection.addConnectionListener(new ConnectionInterruptionListener()); connection.start(); Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); - MockProviderContext.INSTANCE.shutdown(); + mockPeer.shutdown(); connectionInterrupted.await(9, TimeUnit.SECONDS); session.close(); connection.close(); @@ -91,7 +94,7 @@ public class FailoverProviderOfflineBehaviorTest extends FailoverProviderTestSup Queue queue = session.createQueue(_testName.getMethodName()); MessageProducer producer = session.createProducer(queue); - MockProviderContext.INSTANCE.shutdown(); + mockPeer.shutdown(); connectionInterrupted.await(9, TimeUnit.SECONDS); producer.close(); @@ -108,7 +111,7 @@ public class FailoverProviderOfflineBehaviorTest extends FailoverProviderTestSup Queue queue = session.createQueue(_testName.getMethodName()); MessageConsumer consumer = session.createConsumer(queue); - MockProviderContext.INSTANCE.shutdown(); + mockPeer.shutdown(); connectionInterrupted.await(9, TimeUnit.SECONDS); consumer.close(); @@ -116,6 +119,29 @@ public class FailoverProviderOfflineBehaviorTest extends FailoverProviderTestSup } @Test(timeout=10000) + public void testSessionCloseWhenDestroyCallFailsDoesNotBlock() throws Exception { + mockPeer.setResourceDestroyFilter(new ResourceLifecycleFilter() { + + @Override + public void onLifecycleEvent(JmsResource resource) throws Exception { + if (resource instanceof JmsSessionInfo) { + mockPeer.shutdownQuietly(); + throw new IOException(); + } + } + }); + + connection = (JmsConnection) factory.createConnection(); + connection.addConnectionListener(new ConnectionInterruptionListener()); + connection.start(); + + Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); + session.close(); + + connection.close(); + } + + @Test(timeout=10000) public void testSessionCloseWithOpenResourcesDoesNotBlock() throws Exception { connection = (JmsConnection) factory.createConnection(); connection.addConnectionListener(new ConnectionInterruptionListener()); @@ -126,7 +152,7 @@ public class FailoverProviderOfflineBehaviorTest extends FailoverProviderTestSup session.createConsumer(queue); session.createProducer(queue); - MockProviderContext.INSTANCE.shutdown(); + mockPeer.shutdown(); connectionInterrupted.await(9, TimeUnit.SECONDS); session.close(); @@ -140,7 +166,7 @@ public class FailoverProviderOfflineBehaviorTest extends FailoverProviderTestSup connection.start(); Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); - MockProviderContext.INSTANCE.shutdown(); + mockPeer.shutdown(); connectionInterrupted.await(9, TimeUnit.SECONDS); session.recover(); http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/44ccf5f1/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderTest.java index 719f348..0b7533f 100644 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderTest.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderTest.java @@ -168,8 +168,8 @@ public class FailoverProviderTest extends FailoverProviderTestSupport { provider.close(); - assertEquals(1, context.getContextStats().getProvidersCreated()); - assertEquals(1, context.getContextStats().getConnectionAttempts()); + assertEquals(1, mockPeer.getContextStats().getProvidersCreated()); + assertEquals(1, mockPeer.getContextStats().getConnectionAttempts()); } @Test(timeout = 30000) @@ -205,9 +205,9 @@ public class FailoverProviderTest extends FailoverProviderTestSupport { connection.close(); } - assertEquals(5, context.getContextStats().getProvidersCreated()); - assertEquals(5, context.getContextStats().getConnectionAttempts()); - assertEquals(5, context.getContextStats().getCloseAttempts()); + assertEquals(5, mockPeer.getContextStats().getProvidersCreated()); + assertEquals(5, mockPeer.getContextStats().getConnectionAttempts()); + assertEquals(5, mockPeer.getContextStats().getCloseAttempts()); } @Test(timeout = 30000) @@ -227,9 +227,9 @@ public class FailoverProviderTest extends FailoverProviderTestSupport { connection.close(); } - assertEquals(5, context.getContextStats().getProvidersCreated()); - assertEquals(5, context.getContextStats().getConnectionAttempts()); - assertEquals(5, context.getContextStats().getCloseAttempts()); + assertEquals(5, mockPeer.getContextStats().getProvidersCreated()); + assertEquals(5, mockPeer.getContextStats().getConnectionAttempts()); + assertEquals(5, mockPeer.getContextStats().getCloseAttempts()); } @Test(timeout = 30000) @@ -241,9 +241,9 @@ public class FailoverProviderTest extends FailoverProviderTestSupport { connection.start(); connection.close(); - assertEquals(1, context.getContextStats().getProvidersCreated()); - assertEquals(1, context.getContextStats().getConnectionAttempts()); - assertEquals(1, context.getContextStats().getCloseAttempts()); + assertEquals(1, mockPeer.getContextStats().getProvidersCreated()); + assertEquals(1, mockPeer.getContextStats().getConnectionAttempts()); + assertEquals(1, mockPeer.getContextStats().getCloseAttempts()); } @Test(timeout = 30000) @@ -256,8 +256,8 @@ public class FailoverProviderTest extends FailoverProviderTestSupport { connection.createSession(false, Session.AUTO_ACKNOWLEDGE).close(); connection.close(); - assertEquals(1, context.getContextStats().getCreateResourceCalls(JmsSessionInfo.class)); - assertEquals(1, context.getContextStats().getDestroyResourceCalls(JmsSessionInfo.class)); + assertEquals(1, mockPeer.getContextStats().getCreateResourceCalls(JmsSessionInfo.class)); + assertEquals(1, mockPeer.getContextStats().getDestroyResourceCalls(JmsSessionInfo.class)); } @Test(timeout = 30000) @@ -272,9 +272,9 @@ public class FailoverProviderTest extends FailoverProviderTestSupport { session.createConsumer(destination).close(); connection.close(); - assertEquals(1, context.getContextStats().getCreateResourceCalls(JmsConsumerInfo.class)); - assertEquals(1, context.getContextStats().getStartResourceCalls(JmsConsumerInfo.class)); - assertEquals(1, context.getContextStats().getDestroyResourceCalls(JmsConsumerInfo.class)); + assertEquals(1, mockPeer.getContextStats().getCreateResourceCalls(JmsConsumerInfo.class)); + assertEquals(1, mockPeer.getContextStats().getStartResourceCalls(JmsConsumerInfo.class)); + assertEquals(1, mockPeer.getContextStats().getDestroyResourceCalls(JmsConsumerInfo.class)); } @Test(timeout = 30000) @@ -289,8 +289,8 @@ public class FailoverProviderTest extends FailoverProviderTestSupport { session.createProducer(destination).close(); connection.close(); - assertEquals(1, context.getContextStats().getCreateResourceCalls(JmsProducerInfo.class)); - assertEquals(1, context.getContextStats().getDestroyResourceCalls(JmsProducerInfo.class)); + assertEquals(1, mockPeer.getContextStats().getCreateResourceCalls(JmsProducerInfo.class)); + assertEquals(1, mockPeer.getContextStats().getDestroyResourceCalls(JmsProducerInfo.class)); } @Test(timeout = 30000) @@ -304,7 +304,7 @@ public class FailoverProviderTest extends FailoverProviderTestSupport { session.recover(); connection.close(); - assertEquals(1, context.getContextStats().getRecoverCalls()); + assertEquals(1, mockPeer.getContextStats().getRecoverCalls()); } @Test(timeout = 30000) @@ -318,6 +318,6 @@ public class FailoverProviderTest extends FailoverProviderTestSupport { session.unsubscribe("some-subscription"); connection.close(); - assertEquals(1, context.getContextStats().getUnsubscribeCalls()); + assertEquals(1, mockPeer.getContextStats().getUnsubscribeCalls()); } } http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/44ccf5f1/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderTestSupport.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderTestSupport.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderTestSupport.java index 879b807..106c002 100644 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderTestSupport.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverProviderTestSupport.java @@ -24,7 +24,7 @@ import org.apache.qpid.jms.meta.JmsConsumerId; import org.apache.qpid.jms.meta.JmsConsumerInfo; import org.apache.qpid.jms.meta.JmsSessionId; import org.apache.qpid.jms.meta.JmsSessionInfo; -import org.apache.qpid.jms.provider.mock.MockProviderContext; +import org.apache.qpid.jms.provider.mock.MockRemotePeer; import org.apache.qpid.jms.test.QpidJmsTestCase; import org.apache.qpid.jms.util.IdGenerator; import org.junit.After; @@ -39,7 +39,7 @@ public class FailoverProviderTestSupport extends QpidJmsTestCase { private final AtomicLong nextSessionId = new AtomicLong(); private final AtomicLong nextConsumerId = new AtomicLong(); - protected MockProviderContext context; + protected MockRemotePeer mockPeer; @Override @Before @@ -47,8 +47,8 @@ public class FailoverProviderTestSupport extends QpidJmsTestCase { nextSessionId.set(0); nextConsumerId.set(0); - context = new MockProviderContext(); - context.start(); + mockPeer = new MockRemotePeer(); + mockPeer.start(); super.setUp(); } @@ -56,9 +56,9 @@ public class FailoverProviderTestSupport extends QpidJmsTestCase { @Override @After public void tearDown() throws Exception { - if (context != null) { - context.shutdown(); - context = null; + if (mockPeer != null) { + mockPeer.shutdown(); + mockPeer = null; } super.tearDown(); http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/44ccf5f1/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockProvider.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockProvider.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockProvider.java index 3872302..ace5703 100644 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockProvider.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockProvider.java @@ -62,7 +62,7 @@ public class MockProvider implements Provider { private final MockProviderConfiguration configuration; private final ScheduledExecutorService serializer; private final AtomicBoolean closed = new AtomicBoolean(); - private final MockProviderContext context; + private final MockRemotePeer context; private long connectTimeout = JmsConnectionInfo.DEFAULT_CONNECT_TIMEOUT; private long closeTimeout = JmsConnectionInfo.DEFAULT_CLOSE_TIMEOUT; @@ -70,7 +70,7 @@ public class MockProvider implements Provider { private MockProviderListener eventListener; private ProviderListener listener; - public MockProvider(URI remoteURI, MockProviderConfiguration configuration, MockProviderContext context) { + public MockProvider(URI remoteURI, MockProviderConfiguration configuration, MockRemotePeer context) { this.remoteURI = remoteURI; this.configuration = configuration; this.context = context; @@ -176,6 +176,10 @@ public class MockProvider implements Provider { checkClosed(); stats.recordCreateResourceCall(resource); + if (context != null) { + context.createResource(resource); + } + if (resource instanceof JmsConnectionInfo) { if (listener != null) { listener.onConnectionEstablished(remoteURI); @@ -200,6 +204,11 @@ public class MockProvider implements Provider { try { checkClosed(); stats.recordStartResourceCall(resource); + + if (context != null) { + context.startResource(resource); + } + request.onSuccess(); } catch (Exception error) { request.onFailure(error); @@ -217,6 +226,11 @@ public class MockProvider implements Provider { public void run() { try { checkClosed(); + + if (context != null) { + context.stopResource(resource); + } + stats.recordStopResourceCall(resource); request.onSuccess(); } catch (Exception error) { @@ -236,6 +250,11 @@ public class MockProvider implements Provider { try { checkClosed(); stats.recordDestroyResourceCall(resource); + + if (context != null) { + context.destroyResource(resource); + } + request.onSuccess(); } catch (Exception error) { request.onFailure(error); http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/44ccf5f1/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockProviderContext.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockProviderContext.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockProviderContext.java deleted file mode 100644 index 5b55532..0000000 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockProviderContext.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.qpid.jms.provider.mock; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Context shared between all MockProvider instances. - */ -public class MockProviderContext { - - public static MockProviderContext INSTANCE; - - private final Map<String, MockProvider> activeProviders = new ConcurrentHashMap<String, MockProvider>(); - private final MockProviderStats contextStats = new MockProviderStats(); - - private MockProvider lastRegistered; - private boolean offline; - - public void connect(MockProvider provider) throws IOException { - if (offline) { - throw new IOException(); - } - - if (provider != null) { - activeProviders.put(provider.getProviderId(), provider); - lastRegistered = provider; - } - } - - public void disconnect(MockProvider provider) { - if (provider != null) { - activeProviders.remove(provider.getProviderId()); - } - } - - public void start() { - contextStats.reset(); - activeProviders.clear(); - lastRegistered = null; - offline = false; - - MockProviderContext.INSTANCE = this; - } - - public void shutdown() { - offline = true; - List<MockProvider> active = new ArrayList<MockProvider>(activeProviders.values()); - for (MockProvider provider : active) { - provider.signalConnectionFailed(); - } - activeProviders.clear(); - lastRegistered = null; - - MockProviderContext.INSTANCE = null; - } - - public MockProvider getProvider(String providerId) { - return activeProviders.get(providerId); - } - - public MockProvider getLastRegistered() { - return lastRegistered; - } - - public MockProviderStats getContextStats() { - return contextStats; - } -} http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/44ccf5f1/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockProviderFactory.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockProviderFactory.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockProviderFactory.java index 979aaf8..6785b68 100644 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockProviderFactory.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockProviderFactory.java @@ -36,9 +36,9 @@ public class MockProviderFactory extends ProviderFactory { remoteURI = PropertyUtil.replaceQuery(remoteURI, map); MockProviderConfiguration configuration = new MockProviderConfiguration(); - MockProviderContext context = MockProviderContext.INSTANCE; - if (context != null) { - context.getContextStats().recordProviderCreated(); + MockRemotePeer remote = MockRemotePeer.INSTANCE; + if (remote != null) { + remote.getContextStats().recordProviderCreated(); } Map<String, String> unused = PropertyUtil.setProperties(configuration, providerOptions); @@ -51,7 +51,7 @@ public class MockProviderFactory extends ProviderFactory { throw new IllegalArgumentException(msg); } - return new MockProvider(remoteURI, configuration, context); + return new MockProvider(remoteURI, configuration, remote); } @Override http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/44ccf5f1/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockRemotePeer.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockRemotePeer.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockRemotePeer.java new file mode 100644 index 0000000..df8bdb7 --- /dev/null +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/MockRemotePeer.java @@ -0,0 +1,142 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.qpid.jms.provider.mock; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.qpid.jms.meta.JmsResource; + +/** + * Context shared between all MockProvider instances. + */ +public class MockRemotePeer { + + public static MockRemotePeer INSTANCE; + + private final Map<String, MockProvider> activeProviders = new ConcurrentHashMap<String, MockProvider>(); + private final MockProviderStats contextStats = new MockProviderStats(); + + private MockProvider lastRegistered; + private boolean offline; + + private ResourceLifecycleFilter createFilter; + private ResourceLifecycleFilter startFilter; + private ResourceLifecycleFilter stopFilter; + private ResourceLifecycleFilter destroyFilter; + + public void connect(MockProvider provider) throws IOException { + if (offline) { + throw new IOException(); + } + + if (provider != null) { + activeProviders.put(provider.getProviderId(), provider); + lastRegistered = provider; + } + } + + public void disconnect(MockProvider provider) { + if (provider != null) { + activeProviders.remove(provider.getProviderId()); + } + } + + public void createResource(JmsResource resource) throws Exception { + if (createFilter != null) { + createFilter.onLifecycleEvent(resource); + } + } + + public void startResource(JmsResource resource) throws Exception { + if (startFilter != null) { + startFilter.onLifecycleEvent(resource); + } + } + + public void stopResource(JmsResource resource) throws Exception { + if (stopFilter != null) { + stopFilter.onLifecycleEvent(resource); + } + } + + public void destroyResource(JmsResource resource) throws Exception { + if (destroyFilter != null) { + destroyFilter.onLifecycleEvent(resource); + } + } + + public void start() { + contextStats.reset(); + activeProviders.clear(); + lastRegistered = null; + offline = false; + + MockRemotePeer.INSTANCE = this; + } + + public void shutdown() { + offline = true; + List<MockProvider> active = new ArrayList<MockProvider>(activeProviders.values()); + for (MockProvider provider : active) { + provider.signalConnectionFailed(); + } + activeProviders.clear(); + lastRegistered = null; + + MockRemotePeer.INSTANCE = null; + } + + public void shutdownQuietly() { + offline = true; + activeProviders.clear(); + lastRegistered = null; + + MockRemotePeer.INSTANCE = null; + } + + public MockProvider getProvider(String providerId) { + return activeProviders.get(providerId); + } + + public MockProvider getLastRegistered() { + return lastRegistered; + } + + public MockProviderStats getContextStats() { + return contextStats; + } + + public void setResourceCreateFilter(ResourceLifecycleFilter filter) { + createFilter = filter; + } + + public void setResourceStartFilter(ResourceLifecycleFilter filter) { + startFilter = filter; + } + + public void setResourceStopFilter(ResourceLifecycleFilter filter) { + stopFilter = filter; + } + + public void setResourceDestroyFilter(ResourceLifecycleFilter filter) { + destroyFilter = filter; + } +} http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/44ccf5f1/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/ResourceLifecycleFilter.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/ResourceLifecycleFilter.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/ResourceLifecycleFilter.java new file mode 100644 index 0000000..f749cfd --- /dev/null +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/mock/ResourceLifecycleFilter.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.qpid.jms.provider.mock; + +import org.apache.qpid.jms.meta.JmsResource; + +/** + * Interface for an event listener on resource lifecycle events such + * as create and destroy. + */ +public interface ResourceLifecycleFilter { + + void onLifecycleEvent(JmsResource resource) throws Exception; + +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org