2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.core;
11 import io.netty.buffer.ByteBuf;
12 import io.netty.channel.embedded.EmbeddedChannel;
14 import org.junit.Assert;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler.COMPONENT_NAMES;
21 * @author michal.polkorab
23 public class TlsDetectorTest {
25 private EmbeddedChannel embch;
28 * Sets up test environment
32 TlsDetector tlsDetector = new TlsDetector();
33 embch = new EmbeddedChannel(new DummyDecoder());
34 embch.pipeline().addFirst(TcpHandler.COMPONENT_NAMES.TLS_DETECTOR.name(), tlsDetector);
38 * Test of decode {@link TlsDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List) }
42 public void testDecodeNotEncryptedMessage() throws Exception {
43 byte[] msgs = new byte[]{0x04, 0x0, 0x0, 0x08, 0x0, 0x0, 0x0, 0x01};
44 ByteBuf writeObj = embch.alloc().buffer(64);
45 writeObj.writeBytes(msgs);
46 embch.writeInbound(writeObj);
48 Assert.assertNull(embch.pipeline().get(COMPONENT_NAMES.TLS_DETECTOR.name()));
49 Assert.assertNull(embch.pipeline().get(COMPONENT_NAMES.SSL_HANDLER.name()));