Avoid Class cast exception in test case.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1418706 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2012-12-08 16:46:11 +00:00
parent 77a679b03f
commit c65c25ddb6
2 changed files with 30 additions and 22 deletions

View File

@ -31,6 +31,7 @@ import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.store.PersistenceAdapter;
import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
import org.apache.activemq.store.kahadb.KahaDBStore;
import org.apache.activemq.util.Wait;
@ -200,18 +201,21 @@ public class DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest extends org
session.close();
con.close();
final KahaDBStore store = ((KahaDBPersistenceAdapter) broker.getPersistenceAdapter()).getStore();
LOG.info("Store page count: " + store.getPageFile().getPageCount());
LOG.info("Store free page count: " + store.getPageFile().getFreePageCount());
LOG.info("Store page in-use: " + (store.getPageFile().getPageCount() - store.getPageFile().getFreePageCount()));
PersistenceAdapter persistenceAdapter = broker.getPersistenceAdapter();
if( persistenceAdapter instanceof KahaDBPersistenceAdapter) {
final KahaDBStore store = ((KahaDBPersistenceAdapter) persistenceAdapter).getStore();
LOG.info("Store page count: " + store.getPageFile().getPageCount());
LOG.info("Store free page count: " + store.getPageFile().getFreePageCount());
LOG.info("Store page in-use: " + (store.getPageFile().getPageCount() - store.getPageFile().getFreePageCount()));
assertTrue("no leak of pages, always use just 10", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 10 == store.getPageFile().getPageCount() -
store.getPageFile().getFreePageCount();
}
}, TimeUnit.SECONDS.toMillis(10)));
assertTrue("no leak of pages, always use just 10", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 10 == store.getPageFile().getPageCount() -
store.getPageFile().getFreePageCount();
}
}, TimeUnit.SECONDS.toMillis(10)));
}
}
private void waitFor(final Listener listener, final int count) throws Exception {

View File

@ -30,6 +30,7 @@ import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.store.PersistenceAdapter;
import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
import org.apache.activemq.store.kahadb.KahaDBStore;
import org.apache.activemq.util.Wait;
@ -176,18 +177,21 @@ public class DurableSubsOfflineSelectorIndexUseTest extends org.apache.activemq.
session.close();
con.close();
final KahaDBStore store = ((KahaDBPersistenceAdapter) broker.getPersistenceAdapter()).getStore();
LOG.info("Store page count: " + store.getPageFile().getPageCount());
LOG.info("Store free page count: " + store.getPageFile().getFreePageCount());
LOG.info("Store page in-use: " + (store.getPageFile().getPageCount() - store.getPageFile().getFreePageCount()));
PersistenceAdapter persistenceAdapter = broker.getPersistenceAdapter();
if( persistenceAdapter instanceof KahaDBStore) {
final KahaDBStore store = ((KahaDBPersistenceAdapter) persistenceAdapter).getStore();
LOG.info("Store page count: " + store.getPageFile().getPageCount());
LOG.info("Store free page count: " + store.getPageFile().getFreePageCount());
LOG.info("Store page in-use: " + (store.getPageFile().getPageCount() - store.getPageFile().getFreePageCount()));
assertTrue("no leak of pages, always use just 10", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 10 == store.getPageFile().getPageCount() -
store.getPageFile().getFreePageCount();
}
}, TimeUnit.SECONDS.toMillis(10)));
assertTrue("no leak of pages, always use just 10", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 10 == store.getPageFile().getPageCount() -
store.getPageFile().getFreePageCount();
}
}, TimeUnit.SECONDS.toMillis(10)));
}
}
private void waitFor(final Listener listener, final int count) throws Exception {