1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
\r
2 package org.opendaylight.openflowjava.protocol.impl.core;
\r
4 import io.netty.buffer.ByteBuf;
\r
5 import io.netty.channel.embedded.EmbeddedChannel;
\r
7 import org.junit.Assert;
\r
8 import org.junit.Before;
\r
9 import org.junit.Test;
\r
10 import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler.COMPONENT_NAMES;
\r
14 * @author michal.polkorab
\r
16 public class TlsDetectorTest {
\r
18 private EmbeddedChannel embch;
\r
21 * Sets up test environment
\r
24 public void setUp() {
\r
25 TlsDetector tlsDetector = new TlsDetector();
\r
26 embch = new EmbeddedChannel(new DummyDecoder());
\r
27 embch.pipeline().addFirst(TcpHandler.COMPONENT_NAMES.TLS_DETECTOR.name(), tlsDetector);
\r
31 * Test of decode {@link TlsDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List) }
\r
32 * @throws Exception
\r
35 public void testDecodeNotEncryptedMessage() throws Exception {
\r
36 byte[] msgs = new byte[]{0x04, 0x0, 0x0, 0x08, 0x0, 0x0, 0x0, 0x01};
\r
37 ByteBuf writeObj = embch.alloc().buffer(64);
\r
38 writeObj.writeBytes(msgs);
\r
39 embch.writeInbound(writeObj);
\r
41 Assert.assertNull(embch.pipeline().get(COMPONENT_NAMES.TLS_DETECTOR.name()));
\r
42 Assert.assertNull(embch.pipeline().get(COMPONENT_NAMES.SSL_HANDLER.name()));
\r