Mass replace CRLF->LF
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / multipart / OF10StatsReplyExperimenterTest.java
1 /*
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart;
10
11 import io.netty.buffer.ByteBuf;
12
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.junit.runner.RunWith;
16 import org.mockito.Matchers;
17 import org.mockito.Mock;
18 import org.mockito.Mockito;
19 import org.mockito.runners.MockitoJUnitRunner;
20 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
21 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
22 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory;
23 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
25
26 /**
27  * @author michal.polkorab
28  *
29  */
30 @RunWith(MockitoJUnitRunner.class)
31 public class OF10StatsReplyExperimenterTest {
32
33     @Mock DeserializerRegistry registry;
34
35     /**
36      * Tests {@link OF10StatsReplyMessageFactory} for experimenter body translation
37      */
38     @Test
39     public void test() {
40         OF10StatsReplyMessageFactory factory = new OF10StatsReplyMessageFactory();
41         factory.injectDeserializerRegistry(registry);
42
43         ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 "
44                                             + "00 00 00 01"); // expID
45         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
46
47         BufferHelper.checkHeaderV10(builtByFactory);
48         Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue());
49         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
50         Mockito.verify(registry, Mockito.times(1)).getDeserializer(Matchers.any(MessageCodeKey.class));
51     }
52 }