String encoded = testWriter.toString();
Assert.assertEquals(encoded, testRemoveBroker);
}
public void testReplaceBrokerConnection() throws Exception {
DefaultEncodingRegistry der = new DefaultEncodingRegistry();
ReplaceBrokerConnectionEnDeCoder rbced = new ReplaceBrokerConnectionEnDeCoder(der);
rbced.start();
RemovedBrokerEnDeCoder rbed = new RemovedBrokerEnDeCoder(der);
rbed.start();
EndpointReferenceEnDeCoder epred = new EndpointReferenceEnDeCoder(der);
epred.start();
EndpointAddressEnDeCoder eaed = new EndpointAddressEnDeCoder(der);
eaed.start();
ReferencePropertiesEnDeCoder rped = new ReferencePropertiesEnDeCoder(der);
rped.start();
BrokerIDEnDeCoder bied = new BrokerIDEnDeCoder(der);
bied.start();
BrokerEnDeCoder bed = new BrokerEnDeCoder(der);
bed.start();
BrokerConsumerReferenceEnDeCoder bcred = new BrokerConsumerReferenceEnDeCoder(der);
bcred.start();
BrokerProducerReferenceEnDeCoder bpred = new BrokerProducerReferenceEnDeCoder(der);
bpred.start();
NeighborsEnDeCoder nced = new NeighborsEnDeCoder(der);
nced.start();
XMLInputFactory xif = XMLInputFactory.newInstance();
XMLStreamReader reader = xif.createXMLStreamReader(new StringReader(testReplaceBrokerConnection));
reader.next();
ReplaceBrokerConnection replaceBrokerConnection = (ReplaceBrokerConnection)der.decode(reader);
Assert.assertEquals(replaceBrokerConnection.getRemovedBroker().getReference().getEndpointAddress().getAddress().toString(),
testUrl);
Neighbors neighbors = replaceBrokerConnection.getNeighbors();
Assert.assertEquals(neighbors.getBrokerSequence().get(0)
.getBrokerConsumerReference().getReference().getEndpointAddress().getAddress().toString(),
testUrl1);
Assert.assertEquals(neighbors.getBrokerSequence().get(0)
.getBrokerProducerReference().getReference().getEndpointAddress().getAddress().toString(),
testUrl2);
XMLOutputFactory xof = XMLOutputFactory.newInstance();
StringWriter testWriter = new StringWriter();
XMLStreamWriter writer = xof.createXMLStreamWriter(testWriter);
der.encode(replaceBrokerConnection, writer);
writer.flush();
String encoded = testWriter.toString();
Assert.assertEquals(encoded, testReplaceBrokerConnection);
}