activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cshan...@apache.org
Subject activemq-cli-tools git commit: AMQCLI-3 - Added more tests and cleanup
Date Thu, 09 Mar 2017 13:38:35 GMT
Repository: activemq-cli-tools
Updated Branches:
  refs/heads/master 5637f0414 -> 9723dbfb4


AMQCLI-3 - Added more tests and cleanup

Added a builder to make export configuration easier
Added more CLI options


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

Branch: refs/heads/master
Commit: 9723dbfb4d7e65d13a03000fd05cdddfa1dd816c
Parents: 5637f04
Author: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Authored: Thu Mar 9 08:37:53 2017 -0500
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Thu Mar 9 08:37:53 2017 -0500

----------------------------------------------------------------------
 .../kahadb/exporter/ExportConfiguration.java    | 141 +++++++++++++++++
 .../activemq/cli/kahadb/exporter/Exporter.java  |  87 ++++++-----
 .../cli/kahadb/exporter/KahaDBExporter.java     |   2 +
 .../cli/kahadb/exporter/ExporterTest.java       | 151 ++++++++++++-------
 .../cli/kahadb/exporter/KahaDbExporterTest.java |   5 +-
 .../exporter/MultiKahaDbExporterTest.java       |   7 +-
 6 files changed, 293 insertions(+), 100 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-cli-tools/blob/9723dbfb/activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/ExportConfiguration.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/ExportConfiguration.java
b/activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/ExportConfiguration.java
new file mode 100644
index 0000000..3f7a7bd
--- /dev/null
+++ b/activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/ExportConfiguration.java
@@ -0,0 +1,141 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.cli.kahadb.exporter;
+
+import java.io.File;
+
+public class ExportConfiguration {
+
+    private File source;
+
+    private File target;
+
+    private String queuePattern;
+
+    private String topicPattern;
+
+    private boolean multiKaha;
+
+    private boolean compress;
+
+    private boolean overwrite;
+
+    public File getSource() {
+        return source;
+    }
+
+    public void setSource(File source) {
+        this.source = source;
+    }
+
+    public File getTarget() {
+        return target;
+    }
+
+    public void setTarget(File target) {
+        this.target = target;
+    }
+
+    public String getQueuePattern() {
+        return queuePattern;
+    }
+
+    public void setQueuePattern(String queuePattern) {
+        this.queuePattern = queuePattern;
+    }
+
+    public String getTopicPattern() {
+        return topicPattern;
+    }
+
+    public void setTopicPattern(String topicPattern) {
+        this.topicPattern = topicPattern;
+    }
+
+    public boolean isMultiKaha() {
+        return multiKaha;
+    }
+
+    public void setMultiKaha(boolean multiKaha) {
+        this.multiKaha = multiKaha;
+    }
+
+    public boolean isCompress() {
+        return compress;
+    }
+
+    public void setCompress(boolean compress) {
+        this.compress = compress;
+    }
+
+    public boolean isOverwrite() {
+        return overwrite;
+    }
+
+    public void setOverwrite(boolean overwrite) {
+        this.overwrite = overwrite;
+    }
+
+    public static class ExportConfigurationBuilder {
+
+        private final ExportConfiguration config = new ExportConfiguration();
+
+        public static ExportConfigurationBuilder newBuilder() {
+            return new ExportConfigurationBuilder();
+        }
+
+        public ExportConfigurationBuilder setSource(File source) {
+            config.setSource(source);
+            return this;
+        }
+
+        public ExportConfigurationBuilder setTarget(File target) {
+            config.setTarget(target);
+            return this;
+        }
+
+        public ExportConfigurationBuilder setMultiKaha(boolean multiKaha) {
+            config.setMultiKaha(multiKaha);
+            return this;
+        }
+
+        public ExportConfigurationBuilder setQueuePattern(String queuePattern) {
+            config.setQueuePattern(queuePattern);
+            return this;
+        }
+
+        public ExportConfigurationBuilder setTopicPattern(String topicPattern) {
+            config.setTopicPattern(topicPattern);
+            return this;
+        }
+
+        public ExportConfigurationBuilder setCompress(boolean compress) {
+            config.setCompress(compress);
+            return this;
+        }
+
+        public ExportConfigurationBuilder setOverwrite(boolean overwrite) {
+            config.setOverwrite(overwrite);
+            return this;
+        }
+
+        public ExportConfiguration build() {
+            return config;
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-cli-tools/blob/9723dbfb/activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/Exporter.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/Exporter.java
b/activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/Exporter.java
index ecb7abd..5a9c9d6 100644
--- a/activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/Exporter.java
+++ b/activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/Exporter.java
@@ -28,6 +28,7 @@ import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.activemq.cli.artemis.schema.ArtemisJournalMarshaller;
+import org.apache.activemq.cli.kahadb.exporter.ExportConfiguration.ExportConfigurationBuilder;
 import org.apache.activemq.cli.kahadb.exporter.artemis.ArtemisXmlMessageRecoveryListener;
 import org.apache.activemq.cli.kahadb.exporter.artemis.ArtemisXmlMetadataExporter;
 import org.apache.activemq.store.kahadb.FilteredKahaDBPersistenceAdapter;
@@ -66,18 +67,27 @@ public class Exporter {
 
     }
 
-    @Command(name = "kahadb", description = "Export KahaDb")
+    @Command(name = "kahadb", description = "Export a KahaDb store to Artemis XML")
     public static class ExportKahaDb implements Runnable
     {
-        @Option(name="-source", type = OptionType.COMMAND, description = "Data store directory
location")
+        @Option(name = {"-s", "--source"}, required = true, type = OptionType.COMMAND, description
= "Data store directory location")
         public String source;
 
-        @Option(name = "-target", type = OptionType.COMMAND, description = "Xml output file
location")
+        @Option(name = {"-t", "--target"}, required = true, type = OptionType.COMMAND, description
= "Xml output file location")
         public String target;
 
-        @Option(name = "-c", type = OptionType.COMMAND, description = "Compress output xml
file")
+        @Option(name = {"--qp", "--queuePattern"}, type = OptionType.COMMAND, description
= "Queue Export Pattern")
+        public String queuePattern;
+
+        @Option(name = {"--tp", "--queuePattern"}, type = OptionType.COMMAND, description
= "Topic Export Pattern")
+        public String topicPattern;
+
+        @Option(name = "-c", type = OptionType.COMMAND, description = "Compress output xml
file using gzip")
         public boolean compress;
 
+        @Option(name = "-f", type = OptionType.COMMAND, description = "Force XML output and
overwrite existing file")
+        public boolean overwrite;
+
         /* (non-Javadoc)
          * @see java.lang.Runnable#run()
          */
@@ -85,7 +95,13 @@ public class Exporter {
         public void run() {
             LOG.info("Starting store export");
             try {
-                Exporter.exportKahaDbStore(new File(source), new File(target), compress);
+                Exporter.exportStore(ExportConfigurationBuilder.newBuilder()
+                        .setSource(new File(source))
+                        .setTarget(new File(target))
+                        .setQueuePattern(queuePattern)
+                        .setTopicPattern(topicPattern)
+                        .setCompress(compress)
+                        .build());
             } catch (Exception e) {
                 LOG.error(e.getMessage(), e);
             }
@@ -93,7 +109,7 @@ public class Exporter {
         }
     }
 
-    @Command(name = "mkahadb", description = "Export MultiKahaDb")
+    @Command(name = "mkahadb", description = "Export a MultiKahaDb store to Artemis XML")
     public static class ExportMultiKahaDb extends ExportKahaDb
     {
 
@@ -104,7 +120,14 @@ public class Exporter {
         public void run() {
             LOG.info("Exporting");
             try {
-                Exporter.exportMultiKahaDbStore(new File(source), new File(target),  compress);
+                Exporter.exportStore(ExportConfigurationBuilder.newBuilder()
+                        .setMultiKaha(true)
+                        .setSource(new File(source))
+                        .setTarget(new File(target))
+                        .setQueuePattern(queuePattern)
+                        .setTopicPattern(topicPattern)
+                        .setCompress(compress)
+                        .build());
             } catch (Exception e) {
                 LOG.error(e.getMessage(), e);
             }
@@ -112,44 +135,27 @@ public class Exporter {
         }
     }
 
-    public static void exportKahaDbStore(final File kahaDbDir, final File artemisXml) throws
Exception {
-        Exporter.exportStore(kahaDbDir, artemisXml, false, false);
-    }
-
-    public static void exportKahaDbStore(final File kahaDbDir, final File artemisXml,
-            boolean compress) throws Exception {
-        Exporter.exportStore(kahaDbDir, artemisXml, false, compress);
-    }
-
-    public static void exportMultiKahaDbStore(final File kahaDbDir, final File artemisXml)
throws Exception {
-        Exporter.exportStore(kahaDbDir, artemisXml, true, false);
-    }
-
-    public static void exportMultiKahaDbStore(final File kahaDbDir, final File artemisXml,
-            boolean compress) throws Exception {
-        Exporter.exportStore(kahaDbDir, artemisXml, true, compress);
-    }
-
-    private static void exportStore(final File kahaDbDir, final File artemisXml,
-            boolean multiKaha, boolean compress) throws Exception {
+    public static void exportStore(final ExportConfiguration config) throws Exception {
 
-        if (artemisXml.exists()) {
-            throw new IllegalStateException("File: " + artemisXml + " already exists");
+        if (config.getTarget().exists()) {
+            throw new IllegalStateException("File: " + config.getTarget() + " already exists");
         }
 
         long start = System.currentTimeMillis();
-        try(OutputStream fos = new BufferedOutputStream(compress ? new GZIPOutputStream(
-                new FileOutputStream(artemisXml)) : new FileOutputStream(artemisXml))) {
+        try(OutputStream fos = new BufferedOutputStream(config.isCompress() ? new GZIPOutputStream(
+                new FileOutputStream(config.getTarget())) : new FileOutputStream(config.getTarget())))
{
 
             final XMLStreamWriter xmlWriter = XMLOutputFactory.newFactory().createXMLStreamWriter(fos);
             final ArtemisJournalMarshaller xmlMarshaller = new ArtemisJournalMarshaller(xmlWriter);
 
             xmlMarshaller.appendJournalOpen();
 
-            if (multiKaha) {
-                appendMultiKahaDbStore(xmlMarshaller, getMultiKahaDbAdapter(kahaDbDir));
+            if (config.isMultiKaha()) {
+                appendMultiKahaDbStore(xmlMarshaller, getMultiKahaDbAdapter(config.getSource()),
+                        config.getQueuePattern(), config.getTopicPattern());
             } else {
-                appendKahaDbStore(xmlMarshaller, getKahaDbAdapter(kahaDbDir));
+                appendKahaDbStore(xmlMarshaller, getKahaDbAdapter(config.getSource()),
+                        config.getQueuePattern(), config.getTopicPattern());
             }
 
             xmlMarshaller.appendJournalClose(true);
@@ -162,7 +168,8 @@ public class Exporter {
 
 
     private static void appendMultiKahaDbStore(final ArtemisJournalMarshaller xmlMarshaller,
-            MultiKahaDBPersistenceAdapter multiAdapter) throws Exception {
+            final MultiKahaDBPersistenceAdapter multiAdapter, final String queuePattern,
+            final String topicPattern) throws Exception {
 
         try {
             multiAdapter.start();
@@ -184,8 +191,8 @@ public class Exporter {
 
             xmlMarshaller.appendMessagesElement();
             for (KahaDBExporter dbExporter : dbExporters) {
-                dbExporter.exportQueues();
-                dbExporter.exportTopics();
+                dbExporter.exportQueues(queuePattern);
+                dbExporter.exportTopics(topicPattern);
             }
             xmlMarshaller.appendEndElement();
         } finally {
@@ -194,7 +201,7 @@ public class Exporter {
     }
 
     private static void appendKahaDbStore(final ArtemisJournalMarshaller xmlMarshaller,
-            KahaDBPersistenceAdapter adapter) throws Exception {
+            final KahaDBPersistenceAdapter adapter, final String queuePattern, final String
topicPattern) throws Exception {
 
         try {
             adapter.start();
@@ -207,8 +214,8 @@ public class Exporter {
             dbExporter.exportMetadata();
             xmlMarshaller.appendEndElement();
             xmlMarshaller.appendMessagesElement();
-            dbExporter.exportQueues();
-            dbExporter.exportTopics();
+            dbExporter.exportQueues(queuePattern);
+            dbExporter.exportTopics(topicPattern);
             xmlMarshaller.appendEndElement();
         } finally {
             adapter.stop();

http://git-wip-us.apache.org/repos/asf/activemq-cli-tools/blob/9723dbfb/activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/KahaDBExporter.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/KahaDBExporter.java
b/activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/KahaDBExporter.java
index 8bd1b90..ba5a0ef 100644
--- a/activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/KahaDBExporter.java
+++ b/activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/KahaDBExporter.java
@@ -67,11 +67,13 @@ public class KahaDBExporter implements MessageStoreExporter {
 
     @Override
     public void exportQueues(String pattern) throws IOException {
+        pattern = pattern != null ? pattern : DestinationFilter.ANY_DESCENDENT;
         exportDestinations(new ActiveMQQueue(pattern));
     }
 
     @Override
     public void exportTopics(String pattern) throws IOException {
+        pattern = pattern != null ? pattern : DestinationFilter.ANY_DESCENDENT;
         exportDestinations(new ActiveMQTopic(pattern));
     }
 

http://git-wip-us.apache.org/repos/asf/activemq-cli-tools/blob/9723dbfb/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/ExporterTest.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/ExporterTest.java
b/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/ExporterTest.java
index b89e035..ed252f6 100644
--- a/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/ExporterTest.java
+++ b/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/ExporterTest.java
@@ -52,6 +52,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 import org.apache.activemq.broker.ConnectionContext;
+import org.apache.activemq.cli.kahadb.exporter.ExportConfiguration.ExportConfigurationBuilder;
 import org.apache.activemq.cli.schema.ActivemqJournalType;
 import org.apache.activemq.cli.schema.ObjectFactory;
 import org.apache.activemq.command.ActiveMQBytesMessage;
@@ -84,81 +85,63 @@ public abstract class ExporterTest {
 
     public abstract PersistenceAdapter getPersistenceAdapter(File dir);
 
-    public abstract void exportStore(final File kahaDbDir, final File xmlFile) throws Exception;
+    public abstract void exportStore(final ExportConfigurationBuilder builder) throws Exception;
+
+    @Test
+    public void testExportQueuesPattern() throws Exception {
+        testExportQueues("test.>");
+    }
 
     /**
-     * TODO Improve test when real exporting is done, for now this just
-     * tests that the recovery listener iterates over all the queue messages
      *
      * @throws Exception
      */
     @Test
-    public void testExportQueues() throws Exception {
+    public void testExportQueuesAll() throws Exception {
+        testExportQueues(null);
+    }
 
-        File kahaDbDir = storeFolder.newFolder();
+    @Test
+    public void testExportQueuesPatternEmpty() throws Exception {
+        File sourceDir = storeFolder.newFolder();
         ActiveMQQueue queue = new ActiveMQQueue("test.queue");
-        PersistenceAdapter adapter = getPersistenceAdapter(kahaDbDir);
+        PersistenceAdapter adapter = getPersistenceAdapter(sourceDir);
         adapter.start();
         MessageStore messageStore = adapter.createQueueMessageStore(queue);
         messageStore.start();
+        publishQueueMessages(messageStore, queue, new Date(), new byte[] {10, 11, 12});
+        adapter.stop();
 
-        IdGenerator id = new IdGenerator();
-        ConnectionContext context = new ConnectionContext();
-        for (int i = 0; i < 5; i++) {
-            ActiveMQTextMessage message = new ActiveMQTextMessage();
-            message.setText("Test");
-            message.setProperty("MyStringProperty", "abc");
-            message.setProperty("MyIntegerProperty", 1);
-            message.setDestination(queue);
-            message.setMessageId(new MessageId(id.generateId() + ":1", i));
-            messageStore.addMessage(context, message);
-        }
-        byte[] bytes = new byte[] {10, 11, 12};
-        for (int i = 0; i < 3; i++) {
-            ActiveMQBytesMessage message = new ActiveMQBytesMessage();
+        File xmlFile = new File(storeFolder.getRoot().getAbsoluteFile(), "outputXml.xml");
+        exportStore(ExportConfigurationBuilder.newBuilder()
+                .setSource(sourceDir)
+                .setTarget(xmlFile)
+                .setQueuePattern("empty.>"));
 
-            message.setContent(new ByteSequence(bytes));
-            message.setProperty("MyStringProperty", "abc");
-            message.setProperty("MyByteProperty", (byte)10);
-            message.setDestination(queue);
-            message.setMessageId(new MessageId(id.generateId() + ":2", i));
-            messageStore.addMessage(context, message);
-        }
+        validate(xmlFile, 0);
+    }
 
-        for (int i = 0; i < 3; i++) {
-            ActiveMQMapMessage message = new ActiveMQMapMessage();
-            message.setObject("key", "value");
-            message.setObject("key2", 10);
-            message.setProperty("MyStringProperty", "abc");
-            message.setDestination(queue);
-            message.setMessageId(new MessageId(id.generateId() + ":3", i));
-            messageStore.addMessage(context, message);
-        }
 
-        Date date = new Date();
-        for (int i = 0; i < 3; i++) {
-            ActiveMQObjectMessage message = new ActiveMQObjectMessage();
-            message.setObject(date);
-            message.setDestination(queue);
-            message.setMessageId(new MessageId(id.generateId() + ":4", i));
-            messageStore.addMessage(context, message);
-        }
+    protected void testExportQueues(String pattern) throws Exception {
 
-        for (int i = 0; i < 3; i++) {
-            ActiveMQStreamMessage message = new ActiveMQStreamMessage();
-            message.writeByte((byte)10);
-            message.storeContentAndClear();
-            message.setDestination(queue);
-            message.setMessageId(new MessageId(id.generateId() + ":5", i));
-            messageStore.addMessage(context, message);
-        }
+        File kahaDbDir = storeFolder.newFolder();
+        ActiveMQQueue queue = new ActiveMQQueue("test.queue");
+        PersistenceAdapter adapter = getPersistenceAdapter(kahaDbDir);
+        adapter.start();
+        MessageStore messageStore = adapter.createQueueMessageStore(queue);
+        messageStore.start();
+
+        final byte[] bytes = new byte[] {10, 11, 12};
+        final Date date = new Date();
+        publishQueueMessages(messageStore, queue, date, bytes);
 
         adapter.stop();
 
         File xmlFile = new File(storeFolder.getRoot().getAbsoluteFile(), "outputXml.xml");
-        exportStore(kahaDbDir, xmlFile);
-
-      // printFile(xmlFile);
+        exportStore(ExportConfigurationBuilder.newBuilder()
+                .setSource(kahaDbDir)
+                .setTarget(xmlFile)
+                .setQueuePattern(pattern));
 
         validate(xmlFile, 17);
 
@@ -264,7 +247,9 @@ public abstract class ExporterTest {
         adapter.stop();
 
         File xmlFile = new File(storeFolder.getRoot().getAbsoluteFile(), "outputXml.xml");
-        exportStore(kahaDbDir, xmlFile);
+        exportStore(ExportConfigurationBuilder.newBuilder()
+                .setSource(kahaDbDir)
+                .setTarget(xmlFile));
 
         printFile(xmlFile);
 
@@ -339,6 +324,60 @@ public abstract class ExporterTest {
        return new ActiveMQServerImpl(configuration);
     }
 
+    private void publishQueueMessages(MessageStore messageStore, ActiveMQQueue queue,
+            Date date, byte[] bytes) throws Exception {
+        IdGenerator id = new IdGenerator();
+        ConnectionContext context = new ConnectionContext();
+        for (int i = 0; i < 5; i++) {
+            ActiveMQTextMessage message = new ActiveMQTextMessage();
+            message.setText("Test");
+            message.setProperty("MyStringProperty", "abc");
+            message.setProperty("MyIntegerProperty", 1);
+            message.setDestination(queue);
+            message.setMessageId(new MessageId(id.generateId() + ":1", i));
+            messageStore.addMessage(context, message);
+        }
+
+        for (int i = 0; i < 3; i++) {
+            ActiveMQBytesMessage message = new ActiveMQBytesMessage();
+
+            message.setContent(new ByteSequence(bytes));
+            message.setProperty("MyStringProperty", "abc");
+            message.setProperty("MyByteProperty", (byte)10);
+            message.setDestination(queue);
+            message.setMessageId(new MessageId(id.generateId() + ":2", i));
+            messageStore.addMessage(context, message);
+        }
+
+        for (int i = 0; i < 3; i++) {
+            ActiveMQMapMessage message = new ActiveMQMapMessage();
+            message.setObject("key", "value");
+            message.setObject("key2", 10);
+            message.setProperty("MyStringProperty", "abc");
+            message.setDestination(queue);
+            message.setMessageId(new MessageId(id.generateId() + ":3", i));
+            messageStore.addMessage(context, message);
+        }
+
+
+        for (int i = 0; i < 3; i++) {
+            ActiveMQObjectMessage message = new ActiveMQObjectMessage();
+            message.setObject(date);
+            message.setDestination(queue);
+            message.setMessageId(new MessageId(id.generateId() + ":4", i));
+            messageStore.addMessage(context, message);
+        }
+
+        for (int i = 0; i < 3; i++) {
+            ActiveMQStreamMessage message = new ActiveMQStreamMessage();
+            message.writeByte((byte)10);
+            message.storeContentAndClear();
+            message.setDestination(queue);
+            message.setMessageId(new MessageId(id.generateId() + ":5", i));
+            messageStore.addMessage(context, message);
+        }
+    }
+
     @SuppressWarnings("unchecked")
     private void validate(File file, int count) throws JAXBException {
         JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);

http://git-wip-us.apache.org/repos/asf/activemq-cli-tools/blob/9723dbfb/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/KahaDbExporterTest.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/KahaDbExporterTest.java
b/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/KahaDbExporterTest.java
index e9411af..6392631 100644
--- a/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/KahaDbExporterTest.java
+++ b/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/KahaDbExporterTest.java
@@ -18,6 +18,7 @@ package org.apache.activemq.cli.kahadb.exporter;
 
 import java.io.File;
 
+import org.apache.activemq.cli.kahadb.exporter.ExportConfiguration.ExportConfigurationBuilder;
 import org.apache.activemq.store.PersistenceAdapter;
 import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
 
@@ -32,7 +33,7 @@ public class KahaDbExporterTest extends ExporterTest {
     }
 
     @Override
-    public void exportStore(File kahaDbDir, File xmlFile) throws Exception {
-        Exporter.exportKahaDbStore(kahaDbDir, xmlFile);
+    public void exportStore(final ExportConfigurationBuilder builder) throws Exception {
+        Exporter.exportStore(builder.build());
     }
 }

http://git-wip-us.apache.org/repos/asf/activemq-cli-tools/blob/9723dbfb/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/MultiKahaDbExporterTest.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/MultiKahaDbExporterTest.java
b/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/MultiKahaDbExporterTest.java
index 31bfc8f..2af2ead 100644
--- a/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/MultiKahaDbExporterTest.java
+++ b/activemq-kahadb-exporter/src/test/java/org/apache/activemq/cli/kahadb/exporter/MultiKahaDbExporterTest.java
@@ -18,6 +18,7 @@ package org.apache.activemq.cli.kahadb.exporter;
 
 import java.io.File;
 
+import org.apache.activemq.cli.kahadb.exporter.ExportConfiguration.ExportConfigurationBuilder;
 import org.apache.activemq.store.PersistenceAdapter;
 import org.apache.activemq.store.kahadb.FilteredKahaDBPersistenceAdapter;
 import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
@@ -50,8 +51,10 @@ public class MultiKahaDbExporterTest extends ExporterTest {
      * @see org.apache.activemq.cli.kahadb.exporter.ExporterTest#exportStore(java.io.File,
java.io.File)
      */
     @Override
-    public void exportStore(File kahaDbDir, File xmlFile) throws Exception {
-        Exporter.exportMultiKahaDbStore(kahaDbDir, xmlFile);
+    public void exportStore(final ExportConfigurationBuilder builder) throws Exception {
+        Exporter.exportStore(builder
+                .setMultiKaha(true)
+                .build());
     }
 
 }


Mime
View raw message