activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject [2/5] activemq git commit: resolve intermittent failure verifying connector restart
Date Thu, 22 Jan 2015 14:14:11 GMT
resolve intermittent failure verifying connector restart


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/c28d5207
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/c28d5207
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/c28d5207

Branch: refs/heads/trunk
Commit: c28d520727854e933c45a05eb55336abbfe4dc59
Parents: 2a62b74
Author: gtully <gary.tully@gmail.com>
Authored: Thu Jan 22 13:44:22 2015 +0000
Committer: gtully <gary.tully@gmail.com>
Committed: Thu Jan 22 14:13:32 2015 +0000

----------------------------------------------------------------------
 .../store/jdbc/JDBCIOExceptionHandlerTest.java  | 24 +++++++++++++-------
 1 file changed, 16 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/c28d5207/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCIOExceptionHandlerTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCIOExceptionHandlerTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCIOExceptionHandlerTest.java
index d0ac1da..df10d73 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCIOExceptionHandlerTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCIOExceptionHandlerTest.java
@@ -45,6 +45,7 @@ public class JDBCIOExceptionHandlerTest extends TestCase {
     private static final Logger LOG = LoggerFactory.getLogger(JDBCIOExceptionHandlerTest.class);
     private static final String TRANSPORT_URL = "tcp://0.0.0.0:0";
 
+    private static final String DATABASE_NAME = "DERBY_OVERRIDE";
     private ActiveMQConnectionFactory factory;
     private ReconnectingEmbeddedDataSource dataSource;
     private BrokerService broker;
@@ -60,7 +61,7 @@ public class JDBCIOExceptionHandlerTest extends TestCase {
         broker.setUseJmx(withJMX);
 
         EmbeddedDataSource embeddedDataSource = new EmbeddedDataSource();
-        embeddedDataSource.setDatabaseName("derbydb_15");
+        embeddedDataSource.setDatabaseName(DATABASE_NAME);
         embeddedDataSource.setCreateDatabase("create");
 
         // create a wrapper to EmbeddedDataSource to allow the connection be
@@ -190,13 +191,20 @@ public class JDBCIOExceptionHandlerTest extends TestCase {
             // restart db underneath
             dataSource.restartDB();
 
-            // give the transport connector a moment to start
-            LOG.debug("*** Waiting for connector to start...");
-            TimeUnit.SECONDS.sleep(3);
+            Wait.waitFor(new Wait.Condition() {
+                @Override
+                public boolean isSatisified() throws Exception {
+                    LOG.debug("*** checking connector to start...");
+                    try {
+                        checkTransportConnectorStarted();
+                        return true;
+                    } catch (Throwable t) {
+                        LOG.debug(t.toString());
+                    }
+                    return false;
+                }
+            });
 
-            LOG.debug("*** checking connector to start...");
-            // check the connector has restarted
-            checkTransportConnectorStarted();
 
         } finally {
             LOG.debug("*** broker is stopping...");
@@ -289,7 +297,7 @@ public class JDBCIOExceptionHandlerTest extends TestCase {
          */
         public void restartDB() throws SQLException {
             EmbeddedDataSource newDatasource = new EmbeddedDataSource();
-            newDatasource.setDatabaseName(this.realDatasource.getDatabaseName());
+            newDatasource.setDatabaseName(DATABASE_NAME);
             newDatasource.getConnection();
             LOG.info("*** DB restarted now...");
             this.realDatasource = newDatasource;


Mime
View raw message