use of org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataExporter in project activemq-artemis by apache.
the class XmlImportExportTest method testBindingAttributes.
@Test
public void testBindingAttributes() throws Exception {
ClientSession session = basicSetUp();
session.createQueue("addressName1", RoutingType.MULTICAST, "queueName1", true);
session.createQueue("addressName1", RoutingType.MULTICAST, "queueName2", "bob", true);
session.close();
locator.close();
server.stop();
ByteArrayOutputStream xmlOutputStream = new ByteArrayOutputStream();
XmlDataExporter xmlDataExporter = new XmlDataExporter();
xmlDataExporter.process(xmlOutputStream, server.getConfiguration().getBindingsDirectory(), server.getConfiguration().getJournalDirectory(), server.getConfiguration().getPagingDirectory(), server.getConfiguration().getLargeMessagesDirectory());
System.out.print(new String(xmlOutputStream.toByteArray()));
clearDataRecreateServerDirs();
server.start();
checkForLongs();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
session = factory.createSession(false, true, true);
ByteArrayInputStream xmlInputStream = new ByteArrayInputStream(xmlOutputStream.toByteArray());
XmlDataImporter xmlDataImporter = new XmlDataImporter();
xmlDataImporter.validate(xmlInputStream);
xmlInputStream.reset();
xmlDataImporter.process(xmlInputStream, session);
ClientSession.QueueQuery queueQuery = session.queueQuery(new SimpleString("queueName1"));
assertEquals("addressName1", queueQuery.getAddress().toString());
assertNull(queueQuery.getFilterString());
queueQuery = session.queueQuery(new SimpleString("queueName2"));
assertEquals("addressName1", queueQuery.getAddress().toString());
assertEquals("bob", queueQuery.getFilterString().toString());
assertEquals(true, queueQuery.isDurable());
}
use of org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataExporter in project activemq-artemis by apache.
the class XmlImportExportTest method testMessageTypes.
@Test
public void testMessageTypes() throws Exception {
ClientSession session = basicSetUp();
session.createQueue(QUEUE_NAME, RoutingType.MULTICAST, QUEUE_NAME, true);
ClientProducer producer = session.createProducer(QUEUE_NAME);
ClientMessage msg = session.createMessage(Message.BYTES_TYPE, true);
producer.send(msg);
msg = session.createMessage(Message.DEFAULT_TYPE, true);
producer.send(msg);
msg = session.createMessage(Message.MAP_TYPE, true);
producer.send(msg);
msg = session.createMessage(Message.OBJECT_TYPE, true);
producer.send(msg);
msg = session.createMessage(Message.STREAM_TYPE, true);
producer.send(msg);
msg = session.createMessage(Message.TEXT_TYPE, true);
producer.send(msg);
msg = session.createMessage(true);
producer.send(msg);
session.close();
locator.close();
server.stop();
ByteArrayOutputStream xmlOutputStream = new ByteArrayOutputStream();
XmlDataExporter xmlDataExporter = new XmlDataExporter();
xmlDataExporter.process(xmlOutputStream, server.getConfiguration().getBindingsDirectory(), server.getConfiguration().getJournalDirectory(), server.getConfiguration().getPagingDirectory(), server.getConfiguration().getLargeMessagesDirectory());
System.out.print(new String(xmlOutputStream.toByteArray()));
clearDataRecreateServerDirs();
server.start();
checkForLongs();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
session = factory.createSession(false, true, true);
ByteArrayInputStream xmlInputStream = new ByteArrayInputStream(xmlOutputStream.toByteArray());
XmlDataImporter xmlDataImporter = new XmlDataImporter();
xmlDataImporter.validate(xmlInputStream);
xmlInputStream.reset();
xmlDataImporter.process(xmlInputStream, session);
ClientConsumer consumer = session.createConsumer(QUEUE_NAME);
session.start();
msg = consumer.receive(CONSUMER_TIMEOUT);
assertEquals(Message.BYTES_TYPE, msg.getType());
msg = consumer.receive(CONSUMER_TIMEOUT);
assertEquals(Message.DEFAULT_TYPE, msg.getType());
msg = consumer.receive(CONSUMER_TIMEOUT);
assertEquals(Message.MAP_TYPE, msg.getType());
msg = consumer.receive(CONSUMER_TIMEOUT);
assertEquals(Message.OBJECT_TYPE, msg.getType());
msg = consumer.receive(CONSUMER_TIMEOUT);
assertEquals(Message.STREAM_TYPE, msg.getType());
msg = consumer.receive(CONSUMER_TIMEOUT);
assertEquals(Message.TEXT_TYPE, msg.getType());
msg = consumer.receive(CONSUMER_TIMEOUT);
assertEquals(Message.DEFAULT_TYPE, msg.getType());
}
use of org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataExporter in project activemq-artemis by apache.
the class XmlImportExportTest method testPartialQueue.
@Test
public void testPartialQueue() throws Exception {
ClientSession session = basicSetUp();
session.createQueue("myAddress", RoutingType.MULTICAST, "myQueue1", true);
session.createQueue("myAddress", RoutingType.MULTICAST, "myQueue2", true);
ClientProducer producer = session.createProducer("myAddress");
ClientMessage msg = session.createMessage(true);
producer.send(msg);
ClientConsumer consumer = session.createConsumer("myQueue1");
session.start();
msg = consumer.receive(CONSUMER_TIMEOUT);
assertNotNull(msg);
msg.acknowledge();
consumer.close();
session.close();
locator.close();
server.stop();
ByteArrayOutputStream xmlOutputStream = new ByteArrayOutputStream();
XmlDataExporter xmlDataExporter = new XmlDataExporter();
xmlDataExporter.process(xmlOutputStream, server.getConfiguration().getBindingsDirectory(), server.getConfiguration().getJournalDirectory(), server.getConfiguration().getPagingDirectory(), server.getConfiguration().getLargeMessagesDirectory());
System.out.print(new String(xmlOutputStream.toByteArray()));
clearDataRecreateServerDirs();
server.start();
checkForLongs();
locator = createInVMNonHALocator();
factory = createSessionFactory(locator);
session = factory.createSession(false, true, true);
ByteArrayInputStream xmlInputStream = new ByteArrayInputStream(xmlOutputStream.toByteArray());
XmlDataImporter xmlDataImporter = new XmlDataImporter();
xmlDataImporter.validate(xmlInputStream);
xmlInputStream.reset();
xmlDataImporter.process(xmlInputStream, session);
consumer = session.createConsumer("myQueue1");
session.start();
msg = consumer.receive(CONSUMER_TIMEOUT);
assertNull(msg);
consumer.close();
consumer = session.createConsumer("myQueue2");
msg = consumer.receive(CONSUMER_TIMEOUT);
assertNotNull(msg);
}
Aggregations