Search in sources :

Example 1 with NetconfEOMAggregator

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());
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) NetconfXMLToMessageDecoder(org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) ByteBuf(io.netty.buffer.ByteBuf) NetconfMessageToXMLEncoder(org.opendaylight.netconf.nettyutil.handler.NetconfMessageToXMLEncoder) NetconfEOMAggregator(org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator) Test(org.junit.Test)

Example 2 with NetconfEOMAggregator

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);
}
Also used : NetconfXMLToHelloMessageDecoder(org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) NetconfHelloMessage(org.opendaylight.netconf.api.messages.NetconfHelloMessage) HashedWheelTimer(io.netty.util.HashedWheelTimer) NetconfSessionPreferences(org.opendaylight.netconf.api.NetconfSessionPreferences) NetconfEOMAggregator(org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator) ChannelInboundHandlerAdapter(io.netty.channel.ChannelInboundHandlerAdapter) Before(org.junit.Before)

Example 3 with NetconfEOMAggregator

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);
}
Also used : NetconfEOMAggregator(org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator)

Example 4 with NetconfEOMAggregator

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);
}
Also used : NetconfXMLToHelloMessageDecoder(org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) NetconfSessionPreferences(org.opendaylight.netconf.api.NetconfSessionPreferences) NetconfEOMAggregator(org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator) ChannelInboundHandlerAdapter(io.netty.channel.ChannelInboundHandlerAdapter) Before(org.junit.Before)

Aggregations

NetconfEOMAggregator (org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator)4 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)3 ChannelInboundHandlerAdapter (io.netty.channel.ChannelInboundHandlerAdapter)2 Before (org.junit.Before)2 NetconfSessionPreferences (org.opendaylight.netconf.api.NetconfSessionPreferences)2 NetconfXMLToHelloMessageDecoder (org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder)2 ByteBuf (io.netty.buffer.ByteBuf)1 HashedWheelTimer (io.netty.util.HashedWheelTimer)1 Test (org.junit.Test)1 NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)1 NetconfHelloMessage (org.opendaylight.netconf.api.messages.NetconfHelloMessage)1 NetconfMessageToXMLEncoder (org.opendaylight.netconf.nettyutil.handler.NetconfMessageToXMLEncoder)1 NetconfXMLToMessageDecoder (org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder)1