blob: 4178d388bb69bccb39132e92b0e0a948addeb05d [file] [log] [blame]
Tomek OsiƄskie9ccf412018-01-13 19:44:11 +01001/*
2 * Copyright 2018-present Open Networking Foundation
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
17package org.onosproject.xmpp.core.ctl.handlers;
18
19import io.netty.buffer.ByteBuf;
20import io.netty.buffer.Unpooled;
21import io.netty.channel.ChannelHandlerContext;
22import org.easymock.EasyMock;
23import org.hamcrest.Matchers;
24import org.junit.After;
25import org.junit.Before;
26import org.junit.Test;
27import org.xmpp.packet.IQ;
28import org.xmpp.packet.Packet;
29
30import static org.hamcrest.MatcherAssert.assertThat;
31
32/**
33 * Test class for XmppEncoder class.
34 */
35public class XmppEncoderTest {
36
37 private XmppEncoder xmppEncoder;
38 private ChannelHandlerContext channelHandlerContext;
39
40 @Before
41 public void setUp() throws Exception {
42 xmppEncoder = new XmppEncoder();
43 channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
44 }
45
46 @After
47 public void tearDown() throws Exception {
48 xmppEncoder = null;
49 }
50
51 @Test
52 public void testEncode() throws Exception {
53 Packet iq = new IQ();
54 ByteBuf buffer = Unpooled.buffer();
55 xmppEncoder.encode(channelHandlerContext, iq, buffer);
56 assertThat(buffer.hasArray(), Matchers.is(true));
57 }
58
59}