use of org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator in project netconf by opendaylight.
the class MessageParserTest method testEOMFramingMechanismOnPipeline.
@Test
public void testEOMFramingMechanismOnPipeline() throws Exception {
EmbeddedChannel testChunkChannel = new EmbeddedChannel(FramingMechanismHandlerFactory.createHandler(FramingMechanism.EOM), new NetconfMessageToXMLEncoder(), new NetconfEOMAggregator(), new NetconfXMLToMessageDecoder());
testChunkChannel.writeOutbound(this.msg);
ByteBuf recievedOutbound = testChunkChannel.readOutbound();
byte[] endOfMsgBytes = NetconfMessageConstants.END_OF_MESSAGE.getBytes(StandardCharsets.UTF_8);
byte[] eom = new byte[endOfMsgBytes.length];
recievedOutbound.getBytes(recievedOutbound.readableBytes() - endOfMsgBytes.length, eom);
assertArrayEquals(endOfMsgBytes, eom);
testChunkChannel.writeInbound(recievedOutbound);
NetconfMessage receivedMessage = testChunkChannel.readInbound();
assertNotNull(receivedMessage);
XMLUnit.setIgnoreWhitespace(true);
assertXMLEqual(this.msg.getDocument(), receivedMessage.getDocument());
}
use of org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator in project netconf by opendaylight.
the class Netconf539Test method setUp.
@Before
public void setUp() throws Exception {
channel = new EmbeddedChannel();
channel.pipeline().addLast(AbstractChannelInitializer.NETCONF_MESSAGE_ENCODER, new ChannelInboundHandlerAdapter());
channel.pipeline().addLast(AbstractChannelInitializer.NETCONF_MESSAGE_DECODER, new NetconfXMLToHelloMessageDecoder());
channel.pipeline().addLast(NETCONF_MESSAGE_FRAME_ENCODER, FramingMechanismHandlerFactory.createHandler(FramingMechanism.EOM));
channel.pipeline().addLast(NETCONF_MESSAGE_AGGREGATOR, new NetconfEOMAggregator());
final NetconfHelloMessage serverHello = NetconfHelloMessage.createClientHello(Collections.singleton(XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_1), Optional.empty());
negotiator = new TestSessionNegotiator(new NetconfSessionPreferences(serverHello), promise, channel, new HashedWheelTimer(), listener, 100L);
}
use of org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator in project netconf by opendaylight.
the class AbstractChannelInitializer method initialize.
public void initialize(Channel ch, Promise<S> promise) {
ch.pipeline().addLast(NETCONF_MESSAGE_AGGREGATOR, new NetconfEOMAggregator());
initializeMessageDecoder(ch);
ch.pipeline().addLast(NETCONF_MESSAGE_FRAME_ENCODER, FramingMechanismHandlerFactory.createHandler(FramingMechanism.EOM));
initializeMessageEncoder(ch);
initializeSessionNegotiator(ch, promise);
}
use of org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator in project netconf by opendaylight.
the class AbstractNetconfSessionNegotiatorTest method setUp.
@Before
public void setUp() {
channel = new EmbeddedChannel();
xmlToHello = new NetconfXMLToHelloMessageDecoder();
channel.pipeline().addLast(AbstractChannelInitializer.NETCONF_MESSAGE_ENCODER, new ChannelInboundHandlerAdapter());
channel.pipeline().addLast(AbstractChannelInitializer.NETCONF_MESSAGE_DECODER, xmlToHello);
channel.pipeline().addLast(NETCONF_MESSAGE_FRAME_ENCODER, FramingMechanismHandlerFactory.createHandler(FramingMechanism.EOM));
channel.pipeline().addLast(NETCONF_MESSAGE_AGGREGATOR, new NetconfEOMAggregator());
hello = NetconfHelloMessage.createClientHello(Set.of(), Optional.empty());
helloBase11 = NetconfHelloMessage.createClientHello(Set.of(XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_1), Optional.empty());
prefs = new NetconfSessionPreferences(helloBase11);
doReturn(promise).when(promise).setFailure(any());
negotiator = new TestSessionNegotiator(prefs, promise, channel, timer, listener, 100L);
}
Aggregations