ARTEMIS-4243 Fix export of bindings without routing types
This commit is contained in:
parent
673481369f
commit
4e77a34c29
|
@ -67,6 +67,7 @@ import org.apache.activemq.artemis.utils.collections.LinkedListIterator;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Command(name = "exp", description = "Export all message-data using an XML that could be interpreted by any system.")
|
||||
public final class XmlDataExporter extends DBOption {
|
||||
|
@ -340,11 +341,9 @@ public final class XmlDataExporter extends DBOption {
|
|||
for (Map.Entry<Long, PersistentAddressBindingEncoding> addressBindingEncodingEntry : addressBindings.entrySet()) {
|
||||
PersistentAddressBindingEncoding bindingEncoding = addressBindings.get(addressBindingEncodingEntry.getKey());
|
||||
xmlWriter.writeEmptyElement(XmlDataConstants.ADDRESS_BINDINGS_CHILD);
|
||||
StringBuilder routingTypes = new StringBuilder();
|
||||
for (RoutingType routingType : bindingEncoding.getRoutingTypes()) {
|
||||
routingTypes.append(routingType.toString()).append(", ");
|
||||
}
|
||||
xmlWriter.writeAttribute(XmlDataConstants.ADDRESS_BINDING_ROUTING_TYPE, routingTypes.toString().substring(0, routingTypes.length() - 2));
|
||||
String routingTypes = bindingEncoding.getRoutingTypes().stream().
|
||||
map(Enum::toString).collect(Collectors.joining(","));
|
||||
xmlWriter.writeAttribute(XmlDataConstants.ADDRESS_BINDING_ROUTING_TYPE, routingTypes);
|
||||
xmlWriter.writeAttribute(XmlDataConstants.ADDRESS_BINDING_NAME, bindingEncoding.getName().toString());
|
||||
xmlWriter.writeAttribute(XmlDataConstants.ADDRESS_BINDING_ID, Long.toString(bindingEncoding.getId()));
|
||||
bindingsPrinted++;
|
||||
|
|
|
@ -1164,6 +1164,42 @@ public class XmlImportExportTest extends ActiveMQTestBase {
|
|||
assertTrue(server.getAddressInfo(myAddress).getRoutingTypes().contains(RoutingType.MULTICAST));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyRoutingTypes() throws Exception {
|
||||
SimpleString myAddress = SimpleString.toSimpleString("myAddress");
|
||||
ClientSession session = basicSetUp();
|
||||
|
||||
EnumSet<RoutingType> routingTypes = EnumSet.noneOf(RoutingType.class);
|
||||
|
||||
session.createAddress(myAddress, routingTypes, false);
|
||||
|
||||
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());
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(new String(xmlOutputStream.toByteArray()));
|
||||
}
|
||||
|
||||
clearDataRecreateServerDirs();
|
||||
server.start();
|
||||
checkForLongs();
|
||||
locator = createInVMNonHALocator();
|
||||
factory = locator.createSessionFactory();
|
||||
session = factory.createSession(false, false, true);
|
||||
ClientSession managementSession = factory.createSession(false, true, true);
|
||||
|
||||
ByteArrayInputStream xmlInputStream = new ByteArrayInputStream(xmlOutputStream.toByteArray());
|
||||
XmlDataImporter xmlDataImporter = new XmlDataImporter();
|
||||
xmlDataImporter.validate(xmlInputStream);
|
||||
xmlInputStream.reset();
|
||||
xmlDataImporter.process(xmlInputStream, session, managementSession);
|
||||
|
||||
assertEquals(0, server.getAddressInfo(myAddress).getRoutingTypes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImportWrongRoutingType() throws Exception {
|
||||
SimpleString myAddress = SimpleString.toSimpleString("myAddress");
|
||||
|
|
Loading…
Reference in New Issue