Mass replace CRLF->LF
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / VendorMessageFactoryTest.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;
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.util.ByteBufUtils;
23
24 /**
25  * @author michal.polkorab
26  *
27  */
28 @RunWith(MockitoJUnitRunner.class)
29 public class VendorMessageFactoryTest {
30
31     @Mock DeserializerRegistry registry;
32     @Mock ExperimenterMessageFactory deserializer;
33
34     /**
35      * Tests {@link VendorMessageFactory#deserialize(ByteBuf)}
36      */
37     @Test
38     public void test() {
39         Mockito.when(registry.getDeserializer(Matchers.any(MessageCodeKey.class))).thenReturn(deserializer);
40         ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("04 04 00 10 01 02 03 04 FF FF FF FF 80 00 00 00");
41         VendorMessageFactory factory = new VendorMessageFactory();
42         factory.injectDeserializerRegistry(registry);
43         factory.deserialize(buffer);
44
45         Mockito.verify(deserializer, Mockito.times(1)).deserialize(buffer);
46         Assert.assertEquals("Buffer index modified", 16, buffer.readableBytes());
47     }
48 }