Merge "Remove old drop-test module and files."
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / deserialization / match / PbbEntryDeserializerTest.java
1 /*
2  * Copyright (c) 2016 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.openflowplugin.impl.protocol.deserialization.match;
10
11 import static org.junit.Assert.assertEquals;
12
13 import org.junit.Test;
14 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
15 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields;
17
18 import io.netty.buffer.ByteBuf;
19 import io.netty.buffer.UnpooledByteBufAllocator;
20
21 public class PbbEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
22
23     @Test
24     public void deserializeEntry() throws Exception {
25         final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
26         final long pbb = 6;
27         final long pbbMask = 5;
28
29         writeHeader(in, false);
30         in.writeMedium((int) pbb);
31
32         ProtocolMatchFields match = deserialize(in).getProtocolMatchFields();
33         assertEquals(pbb, match.getPbb().getPbbIsid().longValue());
34         assertEquals(0, in.readableBytes());
35
36         writeHeader(in, true);
37         in.writeMedium((int) pbb);
38         in.writeMedium((int) pbbMask);
39
40         match = deserialize(in).getProtocolMatchFields();
41         assertEquals(pbb, match.getPbb().getPbbIsid().longValue());
42         assertEquals(pbbMask, match.getPbb().getPbbMask().longValue());
43         assertEquals(0, in.readableBytes());
44     }
45
46     @Override
47     protected int getOxmClassCode() {
48         return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
49     }
50
51     @Override
52     protected int getOxmFieldCode() {
53         return OxmMatchConstants.PBB_ISID;
54     }
55
56     @Override
57     protected int getValueLength() {
58         return EncodeConstants.SIZE_OF_3_BYTES;
59     }
60
61 }