-/*\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;\r
-\r
-import static org.junit.Assert.assertEquals;\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.extensibility.SerializerRegistry;\r
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class SerializationFactoryTest {\r
-\r
- /**\r
- * Test serializer lookup & serialization\r
- */\r
- @Test\r
- public void test() {\r
- SerializerRegistry registry = new SerializerRegistryImpl();\r
- registry.init();\r
- SerializationFactory factory = new SerializationFactory();\r
- factory.setSerializerTable(registry);\r
- ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();\r
- HelloInputBuilder helloBuilder = new HelloInputBuilder();\r
- helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID);\r
- helloBuilder.setXid(123456L);\r
- helloBuilder.setElements(null);\r
- factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, buffer, helloBuilder.build());\r
- assertEquals("Serialization failed", EncodeConstants.OFHEADER_SIZE, buffer.readableBytes());\r
- }\r
-\r
- /**\r
- * Test serializer not found scenario\r
- */\r
- @Test(expected=IllegalStateException.class)\r
- public void testNotExistingSerializer() {\r
- SerializerRegistry registry = new SerializerRegistryImpl();\r
- registry.init();\r
- SerializationFactory factory = new SerializationFactory();\r
- factory.setSerializerTable(registry);\r
- ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();\r
- HelloInputBuilder helloBuilder = new HelloInputBuilder();\r
- helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID);\r
- helloBuilder.setXid(123456L);\r
- helloBuilder.setElements(null);\r
- factory.messageToBuffer((short) 0, buffer, helloBuilder.build());\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;
+
+import static org.junit.Assert.assertEquals;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.PooledByteBufAllocator;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class SerializationFactoryTest {
+
+ /**
+ * Test serializer lookup & serialization
+ */
+ @Test
+ public void test() {
+ SerializerRegistry registry = new SerializerRegistryImpl();
+ registry.init();
+ SerializationFactory factory = new SerializationFactory();
+ factory.setSerializerTable(registry);
+ ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
+ HelloInputBuilder helloBuilder = new HelloInputBuilder();
+ helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+ helloBuilder.setXid(123456L);
+ helloBuilder.setElements(null);
+ factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, buffer, helloBuilder.build());
+ assertEquals("Serialization failed", EncodeConstants.OFHEADER_SIZE, buffer.readableBytes());
+ }
+
+ /**
+ * Test serializer not found scenario
+ */
+ @Test(expected=IllegalStateException.class)
+ public void testNotExistingSerializer() {
+ SerializerRegistry registry = new SerializerRegistryImpl();
+ registry.init();
+ SerializationFactory factory = new SerializationFactory();
+ factory.setSerializerTable(registry);
+ ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
+ HelloInputBuilder helloBuilder = new HelloInputBuilder();
+ helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+ helloBuilder.setXid(123456L);
+ helloBuilder.setElements(null);
+ factory.messageToBuffer((short) 0, buffer, helloBuilder.build());
+ }
}
\ No newline at end of file