-/*\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.factories.multipart;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;\r
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OF10StatsRequestAggregateTest {\r
-\r
- private SerializerRegistry registry;\r
- private OFSerializer<MultipartRequestInput> statsFactory;\r
-\r
- /**\r
- * Initializes serializer registry and stores correct factory in field\r
- */\r
- @Before\r
- public void startUp() {\r
- registry = new SerializerRegistryImpl();\r
- registry.init();\r
- statsFactory = registry.getSerializer(\r
- new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MultipartRequestInput.class));\r
- }\r
-\r
- /**\r
- * Tests {@link OF10StatsRequestInputFactory} for correct serialization\r
- * @throws Exception \r
- */\r
- @Test\r
- public void test() throws Exception {\r
- MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
- BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);\r
- builder.setType(MultipartType.OFPMPAGGREGATE);\r
- builder.setFlags(new MultipartRequestFlags(false));\r
- MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder();\r
- MultipartRequestAggregateBuilder aggBuilder = new MultipartRequestAggregateBuilder();\r
- MatchV10Builder matchBuilder = new MatchV10Builder();\r
- matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true,\r
- true, true, true, true));\r
- matchBuilder.setNwSrcMask((short) 8);\r
- matchBuilder.setNwDstMask((short) 16);\r
- matchBuilder.setInPort(51);\r
- matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05"));\r
- matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00"));\r
- matchBuilder.setDlVlan(52);\r
- matchBuilder.setDlVlanPcp((short) 53);\r
- matchBuilder.setDlType(54);\r
- matchBuilder.setNwTos((short) 55);\r
- matchBuilder.setNwProto((short) 56);\r
- matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1"));\r
- matchBuilder.setNwDst(new Ipv4Address("10.0.0.2"));\r
- matchBuilder.setTpSrc(57);\r
- matchBuilder.setTpDst(58);\r
- aggBuilder.setMatchV10(matchBuilder.build());\r
- aggBuilder.setTableId((short) 5);\r
- aggBuilder.setOutPort(42L);\r
- caseBuilder.setMultipartRequestAggregate(aggBuilder.build());\r
- builder.setMultipartRequestBody(caseBuilder.build());\r
- MultipartRequestInput message = builder.build();\r
-\r
- ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
- statsFactory.serialize(message, out);\r
-\r
- BufferHelper.checkHeaderV10(out, (byte) 16, 56);\r
- Assert.assertEquals("Wrong type", 2, out.readUnsignedShort());\r
- Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());\r
- out.skipBytes(40); // skip match check\r
- Assert.assertEquals("Wrong table-id", 5, out.readUnsignedByte());\r
- out.skipBytes(1);\r
- Assert.assertEquals("Wrong out port", 42, out.readUnsignedShort());\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.factories.multipart;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OF10StatsRequestAggregateTest {
+
+ private SerializerRegistry registry;
+ private OFSerializer<MultipartRequestInput> statsFactory;
+
+ /**
+ * Initializes serializer registry and stores correct factory in field
+ */
+ @Before
+ public void startUp() {
+ registry = new SerializerRegistryImpl();
+ registry.init();
+ statsFactory = registry.getSerializer(
+ new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MultipartRequestInput.class));
+ }
+
+ /**
+ * Tests {@link OF10StatsRequestInputFactory} for correct serialization
+ * @throws Exception
+ */
+ @Test
+ public void test() throws Exception {
+ MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+ BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+ builder.setType(MultipartType.OFPMPAGGREGATE);
+ builder.setFlags(new MultipartRequestFlags(false));
+ MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder();
+ MultipartRequestAggregateBuilder aggBuilder = new MultipartRequestAggregateBuilder();
+ MatchV10Builder matchBuilder = new MatchV10Builder();
+ matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true,
+ true, true, true, true));
+ matchBuilder.setNwSrcMask((short) 8);
+ matchBuilder.setNwDstMask((short) 16);
+ matchBuilder.setInPort(51);
+ matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05"));
+ matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00"));
+ matchBuilder.setDlVlan(52);
+ matchBuilder.setDlVlanPcp((short) 53);
+ matchBuilder.setDlType(54);
+ matchBuilder.setNwTos((short) 55);
+ matchBuilder.setNwProto((short) 56);
+ matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1"));
+ matchBuilder.setNwDst(new Ipv4Address("10.0.0.2"));
+ matchBuilder.setTpSrc(57);
+ matchBuilder.setTpDst(58);
+ aggBuilder.setMatchV10(matchBuilder.build());
+ aggBuilder.setTableId((short) 5);
+ aggBuilder.setOutPort(42L);
+ caseBuilder.setMultipartRequestAggregate(aggBuilder.build());
+ builder.setMultipartRequestBody(caseBuilder.build());
+ MultipartRequestInput message = builder.build();
+
+ ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+ statsFactory.serialize(message, out);
+
+ BufferHelper.checkHeaderV10(out, (byte) 16, 56);
+ Assert.assertEquals("Wrong type", 2, out.readUnsignedShort());
+ Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
+ out.skipBytes(40); // skip match check
+ Assert.assertEquals("Wrong table-id", 5, out.readUnsignedByte());
+ out.skipBytes(1);
+ Assert.assertEquals("Wrong out port", 42, out.readUnsignedShort());
+ }
}
\ No newline at end of file