import org.opendaylight.netconf.codec.FrameEncoder;
import org.opendaylight.netconf.codec.MessageDecoder;
import org.opendaylight.netconf.codec.MessageEncoder;
+import org.opendaylight.netconf.nettyutil.handler.HelloXMLMessageDecoder;
import org.opendaylight.netconf.nettyutil.handler.NetconfHelloMessageToXMLEncoder;
-import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
public abstract class AbstractChannelInitializer<S extends NetconfSession> {
public static final String NETCONF_SESSION_NEGOTIATOR = "negotiator";
protected void initializeMessageDecoder(final Channel ch) {
// Special decoding handler for hello message to parse additional header if available,
// it is thrown away after successful negotiation
- ch.pipeline().addLast(MessageDecoder.HANDLER_NAME, new NetconfXMLToHelloMessageDecoder());
+ ch.pipeline().addLast(MessageDecoder.HANDLER_NAME, new HelloXMLMessageDecoder());
}
/**
import org.opendaylight.netconf.codec.MessageEncoder;
import org.opendaylight.netconf.codec.XMLMessageDecoder;
import org.opendaylight.netconf.common.NetconfTimer;
+import org.opendaylight.netconf.nettyutil.handler.HelloXMLMessageDecoder;
import org.opendaylight.netconf.nettyutil.handler.NetconfMessageToXMLEncoder;
-import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
protected final void replaceHelloMessageInboundHandler(final S session) {
final var helloMessageHandler = replaceChannelHandler(channel, MessageDecoder.HANDLER_NAME,
new XMLMessageDecoder());
- if (!(helloMessageHandler instanceof NetconfXMLToHelloMessageDecoder helloDecorder)) {
+ if (!(helloMessageHandler instanceof HelloXMLMessageDecoder helloDecorder)) {
throw new IllegalStateException(
"Pipeline handlers misplaced on session: " + session + ", pipeline: " + channel.pipeline());
}
* Netconf messages after hello should be processed once the negotiation succeeded.
*
*/
-public final class NetconfXMLToHelloMessageDecoder extends MessageDecoder {
- private static final Logger LOG = LoggerFactory.getLogger(NetconfXMLToHelloMessageDecoder.class);
+public final class HelloXMLMessageDecoder extends MessageDecoder {
+ private static final Logger LOG = LoggerFactory.getLogger(HelloXMLMessageDecoder.class);
private static final List<byte[]> POSSIBLE_ENDS = List.of(
new byte[] { ']', '\n' },
import org.opendaylight.netconf.codec.MessageDecoder;
import org.opendaylight.netconf.codec.MessageEncoder;
import org.opendaylight.netconf.common.NetconfTimer;
-import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
+import org.opendaylight.netconf.nettyutil.handler.HelloXMLMessageDecoder;
@ExtendWith(MockitoExtension.class)
class AbstractNetconfSessionNegotiatorTest {
private final HelloMessage hello = HelloMessage.createClientHello(Set.of(), Optional.empty());
private final HelloMessage helloBase11 =
HelloMessage.createClientHello(Set.of(CapabilityURN.BASE_1_1), Optional.empty());
- private final NetconfXMLToHelloMessageDecoder xmlToHello = new NetconfXMLToHelloMessageDecoder();
+ private final HelloXMLMessageDecoder xmlToHello = new HelloXMLMessageDecoder();
private final EmbeddedChannel channel = new EmbeddedChannel();
@BeforeEach
import org.opendaylight.netconf.codec.MessageDecoder;
import org.opendaylight.netconf.codec.MessageEncoder;
import org.opendaylight.netconf.common.impl.DefaultNetconfTimer;
-import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
+import org.opendaylight.netconf.nettyutil.handler.HelloXMLMessageDecoder;
import org.opendaylight.netconf.test.util.XmlFileLoader;
@ExtendWith(MockitoExtension.class)
void setUp() {
channel.pipeline()
.addLast(MessageEncoder.HANDLER_NAME, new ChannelInboundHandlerAdapter())
- .addLast(MessageDecoder.HANDLER_NAME, new NetconfXMLToHelloMessageDecoder())
+ .addLast(MessageDecoder.HANDLER_NAME, new HelloXMLMessageDecoder())
.addLast(FrameEncoder.HANDLER_NAME, new EOMFrameEncoder())
.addLast(FrameDecoder.HANDLER_NAME, new EOMFrameDecoder());
negotiator = new TestSessionNegotiator(
import org.opendaylight.netconf.api.messages.HelloMessage;
import org.opendaylight.netconf.api.xml.XmlUtil;
-class NetconfXMLToHelloMessageDecoderTest {
-
+class HelloXMLMessageDecoderTest {
@Test
void testDecodeWithHeader() throws Exception {
final ByteBuf src = Unpooled.wrappedBuffer(String.format("%s\n%s",
"[tomas;10.0.0.0:10000;tcp;client;]",
"<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>").getBytes());
final List<Object> out = new ArrayList<>();
- new NetconfXMLToHelloMessageDecoder().decode(null, src, out);
+ new HelloXMLMessageDecoder().decode(null, src, out);
assertEquals(1, out.size());
final HelloMessage hello = assertInstanceOf(HelloMessage.class, out.get(0));
final ByteBuf src =
Unpooled.wrappedBuffer("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>".getBytes());
final List<Object> out = new ArrayList<>();
- new NetconfXMLToHelloMessageDecoder().decode(null, src, out);
+ new HelloXMLMessageDecoder().decode(null, src, out);
assertEquals(1, out.size());
final HelloMessage hello = assertInstanceOf(HelloMessage.class, out.get(0));
final ByteBuf src =
Unpooled.wrappedBuffer("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>".getBytes());
final List<Object> out = new ArrayList<>();
- final NetconfXMLToHelloMessageDecoder decoder = new NetconfXMLToHelloMessageDecoder();
+ final HelloXMLMessageDecoder decoder = new HelloXMLMessageDecoder();
decoder.decode(null, src, out);
decoder.decode(null, msg1, out);
decoder.decode(null, msg2, out);
final ByteBuf msg1 =
Unpooled.wrappedBuffer("<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>".getBytes());
final List<Object> out = new ArrayList<>();
- NetconfXMLToHelloMessageDecoder decoder = new NetconfXMLToHelloMessageDecoder();
+ HelloXMLMessageDecoder decoder = new HelloXMLMessageDecoder();
assertThrows(IllegalStateException.class, () -> decoder.decode(null, msg1, out));
}
}
class NetconfMessageFactoryTest {
@Test
void testAuth() throws Exception {
- NetconfXMLToHelloMessageDecoder parser = new NetconfXMLToHelloMessageDecoder();
+ HelloXMLMessageDecoder parser = new HelloXMLMessageDecoder();
File authHelloFile = new File(getClass().getResource("/netconfMessages/client_hello_with_auth.xml").getFile());
final List<Object> out = new ArrayList<>();
import org.opendaylight.netconf.codec.ChunkedFrameEncoder;
import org.opendaylight.netconf.codec.XMLMessageDecoder;
import org.opendaylight.netconf.common.impl.DefaultNetconfTimer;
+import org.opendaylight.netconf.nettyutil.handler.HelloXMLMessageDecoder;
import org.opendaylight.netconf.nettyutil.handler.NetconfEXIToMessageDecoder;
-import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
import org.opendaylight.netconf.nettyutil.handler.exi.EXIParameters;
import org.opendaylight.netconf.nettyutil.handler.exi.NetconfStartExiMessageProvider;
import org.opendaylight.netconf.test.util.XmlFileLoader;
doReturn(pipeline).when(pipeline).addLast(anyString(), any(ChannelHandler.class));
doReturn(handler).when(pipeline).replace(anyString(), anyString(), any(ChunkedFrameEncoder.class));
- NetconfXMLToHelloMessageDecoder messageDecoder = new NetconfXMLToHelloMessageDecoder();
+ HelloXMLMessageDecoder messageDecoder = new HelloXMLMessageDecoder();
doReturn(messageDecoder).when(pipeline).replace(anyString(), anyString(), any(XMLMessageDecoder.class));
doReturn(pipeline).when(pipeline).replace(any(ChannelHandler.class), anyString(),
any(NetconfClientSession.class));