Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.ospf.controller.impl; |
| 17 | |
| 18 | |
| 19 | import org.easymock.EasyMock; |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 20 | import org.jboss.netty.channel.Channel; |
| 21 | import org.jboss.netty.channel.ChannelHandlerContext; |
| 22 | import org.junit.After; |
| 23 | import org.junit.Before; |
| 24 | import org.junit.Test; |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 25 | |
| 26 | import static org.hamcrest.CoreMatchers.is; |
| 27 | import static org.hamcrest.CoreMatchers.notNullValue; |
| 28 | import static org.hamcrest.MatcherAssert.assertThat; |
| 29 | |
| 30 | /** |
| 31 | * Created by sdn on 13/1/16. |
| 32 | */ |
| 33 | public class OspfMessageEncoderTest { |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 34 | |
| 35 | private final byte[] object = {2, 1, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, 39, |
| 36 | 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 10, 2, 1, 0, 0, |
| 37 | 0, 40, -64, -88, -86, 8, 0, 0, 0, 0}; |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 38 | private OspfMessageEncoder ospfMessageEncoder; |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 39 | private ChannelHandlerContext channelHandlerContext; |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 40 | private Channel channel; |
| 41 | |
| 42 | @Before |
| 43 | public void setUp() throws Exception { |
| 44 | ospfMessageEncoder = new OspfMessageEncoder(); |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 45 | channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class); |
| 46 | channel = EasyMock.createMock(Channel.class); |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | @After |
| 50 | public void tearDown() throws Exception { |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 51 | ospfMessageEncoder = null; |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Tests encode() method. |
| 56 | */ |
| 57 | @Test |
| 58 | public void testEncode() throws Exception { |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 59 | assertThat(ospfMessageEncoder.encode(channelHandlerContext, channel, object), is(notNullValue())); |
Dhruv Dhody | b585012 | 2016-02-17 17:51:19 +0530 | [diff] [blame] | 60 | } |
| 61 | } |