From a3001fd9bd8456f30ba0ddddc9ba767e32bad7e1 Mon Sep 17 00:00:00 2001 From: feuillemorte Date: Thu, 13 Dec 2018 15:14:05 +0100 Subject: [PATCH] ARTEMIS-2201 Added tests on DEFAULT_JOURNAL_FILE_OPEN_TIMEOUT value --- .../artemis/core/journal/impl/JournalFilesRepository.java | 4 ++++ .../artemis/core/config/impl/FileConfigurationTest.java | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java index eb4740f41c..2c6033b536 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java @@ -242,6 +242,10 @@ public class JournalFilesRepository { return dataFiles.size(); } + public int getJournalFileOpenTimeout() { + return journalFileOpenTimeout; + } + public Collection getDataFiles() { return dataFiles; } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java index cf78e2d645..66d1e9ef50 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java @@ -29,6 +29,7 @@ import java.util.Map; import java.util.Set; import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; +import org.apache.activemq.artemis.core.journal.impl.JournalImpl; import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerBasePlugin; import org.apache.activemq.artemis.utils.RandomUtil; @@ -677,6 +678,8 @@ public class FileConfigurationTest extends ConfigurationImplTest { ActiveMQServerImpl server = new ActiveMQServerImpl(); try { server.start(); + JournalImpl journal = (JournalImpl) server.getStorageManager().getBindingsJournal(); + Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultJournalFileOpenTimeout(), journal.getFilesRepository().getJournalFileOpenTimeout()); Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultJournalFileOpenTimeout(), server.getConfiguration().getJournalFileOpenTimeout()); } finally { server.stop(); @@ -685,12 +688,14 @@ public class FileConfigurationTest extends ConfigurationImplTest { @Test public void testJournalFileOpenTimeoutValue() throws Exception { - int timeout = RandomUtil.randomInt(); + int timeout = RandomUtil.randomPositiveInt(); Configuration configuration = createConfiguration("shared-store-master-hapolicy-config.xml"); configuration.setJournalFileOpenTimeout(timeout); ActiveMQServerImpl server = new ActiveMQServerImpl(configuration); try { server.start(); + JournalImpl journal = (JournalImpl) server.getStorageManager().getBindingsJournal(); + Assert.assertEquals(timeout, journal.getFilesRepository().getJournalFileOpenTimeout()); Assert.assertEquals(timeout, server.getConfiguration().getJournalFileOpenTimeout()); } finally { server.stop();