ARTEMIS-1959 Fixing JournalDataPrintTest
This commit is contained in:
parent
048f46bd4f
commit
7c0f6633f1
|
@ -105,12 +105,12 @@ public final class DescribeJournal {
|
|||
|
||||
private final List<RecordInfo> records;
|
||||
private final List<PreparedTransactionInfo> preparedTransactions;
|
||||
private static final Configuration CONFIGURATION;
|
||||
|
||||
static {
|
||||
private static Configuration getConfiguration() {
|
||||
Configuration configuration;
|
||||
String instanceFolder = System.getProperty("artemis.instance");
|
||||
if (instanceFolder != null) {
|
||||
CONFIGURATION = new FileConfiguration();
|
||||
configuration = new FileConfiguration();
|
||||
File configFile = new File(instanceFolder + "/etc/broker.xml");
|
||||
URL url;
|
||||
|
||||
|
@ -121,19 +121,21 @@ public final class DescribeJournal {
|
|||
xml = XMLUtil.replaceSystemProps(xml);
|
||||
Element e = XMLUtil.stringToElement(xml);
|
||||
|
||||
String root = ((FileConfiguration) CONFIGURATION).getRootElement();
|
||||
String root = ((FileConfiguration) configuration).getRootElement();
|
||||
NodeList children = e.getElementsByTagName(root);
|
||||
if (root != null && children.getLength() > 0) {
|
||||
Node item = children.item(0);
|
||||
XMLUtil.validate(item, ((FileConfiguration) CONFIGURATION).getSchema());
|
||||
((FileConfiguration) CONFIGURATION).parse((Element) item, url);
|
||||
XMLUtil.validate(item, ((FileConfiguration) configuration).getSchema());
|
||||
((FileConfiguration) configuration).parse((Element) item, url);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("failed to load broker.xml", e);
|
||||
}
|
||||
} else {
|
||||
CONFIGURATION = new ConfigurationImpl();
|
||||
configuration = new ConfigurationImpl();
|
||||
}
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public DescribeJournal(List<RecordInfo> records, List<PreparedTransactionInfo> preparedTransactions) {
|
||||
|
@ -166,10 +168,11 @@ public final class DescribeJournal {
|
|||
}
|
||||
|
||||
public static DescribeJournal describeMessagesJournal(final File messagesDir, PrintStream out, boolean safe) throws Exception {
|
||||
Configuration configuration = getConfiguration();
|
||||
SequentialFileFactory messagesFF = new NIOSequentialFileFactory(messagesDir, null, 1);
|
||||
|
||||
// Will use only default values. The load function should adapt to anything different
|
||||
JournalImpl messagesJournal = new JournalImpl(CONFIGURATION.getJournalFileSize(), CONFIGURATION.getJournalMinFiles(), CONFIGURATION.getJournalPoolFiles(), 0, 0, messagesFF, "activemq-data", "amq", 1);
|
||||
JournalImpl messagesJournal = new JournalImpl(configuration.getJournalFileSize(), configuration.getJournalMinFiles(), configuration.getJournalPoolFiles(), 0, 0, messagesFF, "activemq-data", "amq", 1);
|
||||
|
||||
return describeJournal(messagesFF, messagesJournal, messagesDir, out, safe);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.activemq.artemis.cli.commands.tools.PrintData;
|
|||
import org.apache.activemq.artemis.core.config.FileDeploymentManager;
|
||||
import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration;
|
||||
import org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration;
|
||||
|
@ -32,6 +33,9 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class JournalDataPrintTest extends ActiveMQTestBase {
|
||||
|
||||
|
@ -49,9 +53,17 @@ public class JournalDataPrintTest extends ActiveMQTestBase {
|
|||
try {
|
||||
server.start();
|
||||
server.stop();
|
||||
// This will force some static load that used to be on the class, which would make this test to fail.
|
||||
DescribeJournal journal = new DescribeJournal(null, null);
|
||||
System.setProperty("artemis.instance",
|
||||
this.getClass().getClassLoader().getResource("dataprint").getFile());
|
||||
PrintData.printData(server.getConfiguration().getBindingsLocation().getAbsoluteFile(), server.getConfiguration().getJournalLocation().getAbsoluteFile(), server.getConfiguration().getPagingLocation().getAbsoluteFile());
|
||||
PrintData.printData(server.getConfiguration().getBindingsLocation().getAbsoluteFile(), server.getConfiguration().getJournalLocation().getAbsoluteFile(), server.getConfiguration().getPagingLocation().getAbsoluteFile(),
|
||||
new PrintStream(new OutputStream() {
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
// dev/null
|
||||
}
|
||||
}), false);
|
||||
|
||||
// list journal file
|
||||
File dirFile = server.getConfiguration().getJournalLocation().getAbsoluteFile();
|
||||
|
|
Loading…
Reference in New Issue