blob: 4948ec60afaaee39d97d48063ef641f2022f74da [file] [log] [blame]
package org.onosproject.isis.controller.impl;
import com.google.common.primitives.Bytes;
import org.easymock.EasyMock;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onosproject.isis.io.util.IsisUtil;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Unit test class for IsisMessageDecoder.
*/
public class IsisMessageDecoderTest {
private final byte[] hello = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-125, 20, 1, 0, 17, 1, 0, 0,
2, 51, 51, 51, 51, 51, 51, 0, 100, 5, -39, -126, 1, 4, 3,
73, 0, 0, -127, 1, -52, -124, 4, -64, -88, 56, 102
};
private final byte[] array2 = {0, 0, 0, 0, 0, 0, 0};
private final String id = "127.0.0.1";
private byte[] array1;
private IsisMessageDecoder isisMessageDecoder;
private ChannelHandlerContext ctx;
private Channel channel;
private SocketAddress socketAddress;
private ChannelBuffer channelBuffer;
@Before
public void setUp() throws Exception {
isisMessageDecoder = new IsisMessageDecoder();
}
@After
public void tearDown() throws Exception {
isisMessageDecoder = null;
}
@Test
public void testDecode() throws Exception {
channel = EasyMock.createMock(Channel.class);
socketAddress = InetSocketAddress.createUnresolved(id, 7000);
byte[] array = IsisUtil.getPaddingTlvs(hello.length - 17);
array1 = Bytes.concat(hello, array);
channelBuffer = ChannelBuffers.copiedBuffer(Bytes.concat(hello, array));
assertThat(isisMessageDecoder.decode(ctx, channel, channelBuffer), is(nullValue()));
}
}