activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1418706 - in /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases: DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest.java DurableSubsOfflineSelectorIndexUseTest.java
Date Sat, 08 Dec 2012 16:46:12 GMT
Author: chirino
Date: Sat Dec  8 16:46:11 2012
New Revision: 1418706

URL: http://svn.apache.org/viewvc?rev=1418706&view=rev
Log:
Avoid Class cast exception in test case.

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorIndexUseTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest.java?rev=1418706&r1=1418705&r2=1418706&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorConcurrentConsumeIndexUseTest.java
Sat Dec  8 16:46:11 2012
@@ -31,6 +31,7 @@ import org.apache.activemq.ActiveMQConne
 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 DurableSubsOfflineSelectorC
         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()));
-
-        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)));
+        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)));
+        }
     }
 
     private void waitFor(final Listener listener, final int count) throws Exception {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorIndexUseTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorIndexUseTest.java?rev=1418706&r1=1418705&r2=1418706&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorIndexUseTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubsOfflineSelectorIndexUseTest.java
Sat Dec  8 16:46:11 2012
@@ -30,6 +30,7 @@ import org.apache.activemq.ActiveMQConne
 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 DurableSubsOfflineSelectorI
         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()));
-
-        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)));
+        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)));
+        }
     }
 
     private void waitFor(final Listener listener, final int count) throws Exception {



Mime
View raw message