Merge "Remove old drop-test module and files."
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / deserialization / action / SetMplsTtlActionDeserializerTest.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.action;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertTrue;
13
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
18
19 import io.netty.buffer.ByteBuf;
20 import io.netty.buffer.UnpooledByteBufAllocator;
21
22 public class SetMplsTtlActionDeserializerTest extends AbstractActionDeserializerTest {
23
24     @Test
25     public void testDeserialize() throws Exception {
26         final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
27         final short mplsTtl = 10;
28         writeHeader(in);
29         in.writeByte(mplsTtl);
30         in.writeZero(ActionConstants.SET_MPLS_TTL_PADDING);
31
32         final Action action = deserializeAction(in);
33         assertTrue(SetMplsTtlActionCase.class.isInstance(action));
34         assertEquals(mplsTtl, SetMplsTtlActionCase.class.cast(action).getSetMplsTtlAction().getMplsTtl().shortValue());
35         assertEquals(0, in.readableBytes());
36     }
37
38     @Override
39     protected short getType() {
40         return ActionConstants.SET_MPLS_TTL_CODE;
41     }
42
43     @Override
44     protected short getLength() {
45         return ActionConstants.GENERAL_ACTION_LENGTH;
46     }
47
48 }