use of org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder 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.NetconfXMLToHelloMessageDecoder in project netconf by opendaylight.
the class NetconfClientSessionNegotiatorTest method mockChannelPipeline.
private static ChannelPipeline mockChannelPipeline() {
ChannelPipeline pipeline = mock(ChannelPipeline.class);
ChannelHandler handler = mock(ChannelHandler.class);
doReturn(pipeline).when(pipeline).addAfter(anyString(), anyString(), any(ChannelHandler.class));
doReturn(null).when(pipeline).get(SslHandler.class);
doReturn(pipeline).when(pipeline).addLast(anyString(), any(ChannelHandler.class));
doReturn(handler).when(pipeline).replace(anyString(), anyString(), any(ChunkedFramingMechanismEncoder.class));
NetconfXMLToHelloMessageDecoder messageDecoder = new NetconfXMLToHelloMessageDecoder();
doReturn(messageDecoder).when(pipeline).replace(anyString(), anyString(), any(NetconfXMLToMessageDecoder.class));
doReturn(pipeline).when(pipeline).replace(any(ChannelHandler.class), anyString(), any(NetconfClientSession.class));
doReturn(null).when(pipeline).replace(anyString(), anyString(), any(MessageToByteEncoder.class));
doReturn(null).when(pipeline).replace(anyString(), anyString(), any(NetconfEXIToMessageDecoder.class));
return pipeline;
}
use of org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder in project netconf by opendaylight.
the class AbstractNetconfSessionNegotiator method replaceHelloMessageInboundHandler.
/**
* Remove special inbound handler for hello message. Insert regular netconf xml message (en|de)coders.
*
* <p>
* Inbound hello message handler should be kept until negotiation is successful
* It caches any non-hello messages while negotiation is still in progress
*/
protected final void replaceHelloMessageInboundHandler(final S session) {
ChannelHandler helloMessageHandler = replaceChannelHandler(channel, AbstractChannelInitializer.NETCONF_MESSAGE_DECODER, new NetconfXMLToMessageDecoder());
checkState(helloMessageHandler instanceof NetconfXMLToHelloMessageDecoder, "Pipeline handlers misplaced on session: %s, pipeline: %s", session, channel.pipeline());
Iterable<NetconfMessage> netconfMessagesFromNegotiation = ((NetconfXMLToHelloMessageDecoder) helloMessageHandler).getPostHelloNetconfMessages();
// It means, we are now using the thread now
for (NetconfMessage message : netconfMessagesFromNegotiation) {
session.handleMessage(message);
}
}
use of org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder 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