Remove trailing whitespace
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / match / OxmIcmpv4CodeSerializerTest.java
index 69dbad6c7d42f1a897b95dc6b0f475866f95bcc1..8afa0c1cbbe42f2c7322babe32f1f77613f0a3e7 100644 (file)
-/*\r
- * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.match;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertTrue;\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.PooledByteBufAllocator;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OxmIcmpv4CodeSerializerTest {\r
-\r
-    OxmIcmpv4CodeSerializer serializer = new OxmIcmpv4CodeSerializer();\r
-\r
-    /**\r
-     * Test correct serialization\r
-     */\r
-    @Test\r
-    public void testSerialize() {\r
-        MatchEntriesBuilder builder = prepareIcmpv4CodeMatchEntry((short) 200);\r
-        \r
-        ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();\r
-        serializer.serialize(builder.build(), buffer);\r
-\r
-        checkHeader(buffer, false);\r
-        assertEquals("Wrong value", 200, buffer.readUnsignedByte());\r
-        assertTrue("Unexpected data", buffer.readableBytes() == 0);\r
-    }\r
-\r
-    /**\r
-     * Test correct header serialization\r
-     */\r
-    @Test\r
-    public void testSerializeHeader() {\r
-        MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false);\r
-        \r
-        ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();\r
-        serializer.serializeHeader(builder.build(), buffer);\r
-\r
-        checkHeader(buffer, false);\r
-        assertTrue("Unexpected data", buffer.readableBytes() == 0);\r
-    }\r
-\r
-    /**\r
-     * Test correct oxm-class return value\r
-     */\r
-    @Test\r
-    public void testGetOxmClassCode() {\r
-        assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode());\r
-    }\r
-\r
-    /**\r
-     * Test correct oxm-field return value\r
-     */\r
-    @Test\r
-    public void getOxmFieldCode() {\r
-        assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV4_CODE, serializer.getOxmFieldCode());\r
-    }\r
-\r
-    /**\r
-     * Test correct value length return value\r
-     */\r
-    @Test\r
-    public void testGetValueLength() {\r
-        assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength());\r
-    }\r
-\r
-    \r
-    private static MatchEntriesBuilder prepareIcmpv4CodeMatchEntry(short value) {\r
-        MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false);\r
-        Icmpv4CodeMatchEntryBuilder icmpv4Builder = new Icmpv4CodeMatchEntryBuilder();\r
-        icmpv4Builder.setIcmpv4Code(value);\r
-        builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4Builder.build());\r
-        return builder;\r
-    }\r
-\r
-    private static MatchEntriesBuilder prepareIcmpv4CodeHeader(boolean hasMask) {\r
-        MatchEntriesBuilder builder = new MatchEntriesBuilder();\r
-        builder.setOxmClass(OpenflowBasicClass.class);\r
-        builder.setOxmMatchField(Icmpv4Code.class);\r
-        builder.setHasMask(hasMask);\r
-        return builder;\r
-    }\r
-\r
-    private static void checkHeader(ByteBuf buffer, boolean hasMask) {\r
-        assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort());\r
-        short fieldAndMask = buffer.readUnsignedByte();\r
-        assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV4_CODE, fieldAndMask >>> 1);\r
-        assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0);\r
-        assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte());\r
-    }\r
+/*
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.serialization.match;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.PooledByteBufAllocator;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OxmIcmpv4CodeSerializerTest {
+
+    OxmIcmpv4CodeSerializer serializer = new OxmIcmpv4CodeSerializer();
+
+    /**
+     * Test correct serialization
+     */
+    @Test
+    public void testSerialize() {
+        MatchEntriesBuilder builder = prepareIcmpv4CodeMatchEntry((short) 200);
+
+        ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
+        serializer.serialize(builder.build(), buffer);
+
+        checkHeader(buffer, false);
+        assertEquals("Wrong value", 200, buffer.readUnsignedByte());
+        assertTrue("Unexpected data", buffer.readableBytes() == 0);
+    }
+
+    /**
+     * Test correct header serialization
+     */
+    @Test
+    public void testSerializeHeader() {
+        MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false);
+
+        ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
+        serializer.serializeHeader(builder.build(), buffer);
+
+        checkHeader(buffer, false);
+        assertTrue("Unexpected data", buffer.readableBytes() == 0);
+    }
+
+    /**
+     * Test correct oxm-class return value
+     */
+    @Test
+    public void testGetOxmClassCode() {
+        assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode());
+    }
+
+    /**
+     * Test correct oxm-field return value
+     */
+    @Test
+    public void getOxmFieldCode() {
+        assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV4_CODE, serializer.getOxmFieldCode());
+    }
+
+    /**
+     * Test correct value length return value
+     */
+    @Test
+    public void testGetValueLength() {
+        assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength());
+    }
+
+
+    private static MatchEntriesBuilder prepareIcmpv4CodeMatchEntry(short value) {
+        MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false);
+        Icmpv4CodeMatchEntryBuilder icmpv4Builder = new Icmpv4CodeMatchEntryBuilder();
+        icmpv4Builder.setIcmpv4Code(value);
+        builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4Builder.build());
+        return builder;
+    }
+
+    private static MatchEntriesBuilder prepareIcmpv4CodeHeader(boolean hasMask) {
+        MatchEntriesBuilder builder = new MatchEntriesBuilder();
+        builder.setOxmClass(OpenflowBasicClass.class);
+        builder.setOxmMatchField(Icmpv4Code.class);
+        builder.setHasMask(hasMask);
+        return builder;
+    }
+
+    private static void checkHeader(ByteBuf buffer, boolean hasMask) {
+        assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort());
+        short fieldAndMask = buffer.readUnsignedByte();
+        assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV4_CODE, fieldAndMask >>> 1);
+        assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0);
+        assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte());
+    }
 }
\ No newline at end of file