Mass replace CRLF->LF
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / ExperimenterInputMessageFactoryTest.java
index 17b3f7addbb6814de34e73d00867340071c36c5e..77cc5c32d2e88eb9e69669ba80fabb938c0d88ba 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.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import org.junit.Test;\r
-import org.mockito.Matchers;\r
-import org.mockito.Mock;\r
-import org.mockito.Mockito;\r
-import org.mockito.MockitoAnnotations;\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.extensibility.SerializerRegistryInjector;\r
-import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey;\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.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class ExperimenterInputMessageFactoryTest {\r
-\r
-    @Mock SerializerRegistry registry;\r
-    @Mock OFSerializer<ExperimenterInput> serializer;\r
-    private OFSerializer<ExperimenterInput> expFactory;\r
-\r
-    /**\r
-     * Sets up ExperimenterInputMessageFactory\r
-     * @param real true if setup should use real registry, false when mock is desired\r
-     */\r
-    public void startUp(boolean real) {\r
-        MockitoAnnotations.initMocks(this);\r
-        expFactory = new ExperimenterInputMessageFactory();\r
-        if (real) {\r
-            SerializerRegistry realRegistry = new SerializerRegistryImpl();\r
-            realRegistry.init();\r
-            ((SerializerRegistryInjector) expFactory).injectSerializerRegistry(realRegistry);\r
-        } else {\r
-            ((SerializerRegistryInjector) expFactory).injectSerializerRegistry(registry);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Testing of {@link ExperimenterInputMessageFactory} for correct serializer\r
-     * lookup and serialization\r
-     * @throws Exception \r
-     */\r
-    @Test(expected=IllegalStateException.class)\r
-    public void testV10Real() throws Exception {\r
-        startUp(true);\r
-        ExperimenterInputBuilder builder = new ExperimenterInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);\r
-        builder.setExperimenter(new ExperimenterId(42L));\r
-        ExperimenterInput input = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        expFactory.serialize(input, out);\r
-    }\r
-\r
-    /**\r
-     * Testing of {@link ExperimenterInputMessageFactory} for correct serializer\r
-     * lookup and serialization\r
-     * @throws Exception \r
-     */\r
-    @Test(expected=IllegalStateException.class)\r
-    public void testV13Real() throws Exception {\r
-        startUp(true);\r
-        ExperimenterInputBuilder builder = new ExperimenterInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setExperimenter(new ExperimenterId(42L));\r
-        ExperimenterInput input = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        expFactory.serialize(input, out);\r
-    }\r
-\r
-    /**\r
-     * Testing of {@link ExperimenterInputMessageFactory} for correct serializer\r
-     * lookup and serialization\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testV10() throws Exception {\r
-        startUp(false);\r
-        ExperimenterInputBuilder builder = new ExperimenterInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);\r
-        builder.setExperimenter(new ExperimenterId(42L));\r
-        ExperimenterInput input = builder.build();\r
-\r
-        Mockito.when(registry.getSerializer(\r
-                (ExperimenterIdSerializerKey<?>) Matchers.any())).thenReturn(serializer);\r
-\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        expFactory.serialize(input, out);\r
-    }\r
-\r
-    /**\r
-     * Testing of {@link ExperimenterInputMessageFactory} for correct serializer\r
-     * lookup and serialization\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testV13() throws Exception {\r
-        startUp(false);\r
-        ExperimenterInputBuilder builder = new ExperimenterInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setExperimenter(new ExperimenterId(42L));\r
-        ExperimenterInput input = builder.build();\r
-\r
-        Mockito.when(registry.getSerializer(\r
-                (ExperimenterIdSerializerKey<?>) Matchers.any())).thenReturn(serializer);\r
-\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        expFactory.serialize(input, out);\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;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Test;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class ExperimenterInputMessageFactoryTest {
+
+    @Mock SerializerRegistry registry;
+    @Mock OFSerializer<ExperimenterInput> serializer;
+    private OFSerializer<ExperimenterInput> expFactory;
+
+    /**
+     * Sets up ExperimenterInputMessageFactory
+     * @param real true if setup should use real registry, false when mock is desired
+     */
+    public void startUp(boolean real) {
+        MockitoAnnotations.initMocks(this);
+        expFactory = new ExperimenterInputMessageFactory();
+        if (real) {
+            SerializerRegistry realRegistry = new SerializerRegistryImpl();
+            realRegistry.init();
+            ((SerializerRegistryInjector) expFactory).injectSerializerRegistry(realRegistry);
+        } else {
+            ((SerializerRegistryInjector) expFactory).injectSerializerRegistry(registry);
+        }
+    }
+
+    /**
+     * Testing of {@link ExperimenterInputMessageFactory} for correct serializer
+     * lookup and serialization
+     * @throws Exception 
+     */
+    @Test(expected=IllegalStateException.class)
+    public void testV10Real() throws Exception {
+        startUp(true);
+        ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setExperimenter(new ExperimenterId(42L));
+        ExperimenterInput input = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        expFactory.serialize(input, out);
+    }
+
+    /**
+     * Testing of {@link ExperimenterInputMessageFactory} for correct serializer
+     * lookup and serialization
+     * @throws Exception 
+     */
+    @Test(expected=IllegalStateException.class)
+    public void testV13Real() throws Exception {
+        startUp(true);
+        ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setExperimenter(new ExperimenterId(42L));
+        ExperimenterInput input = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        expFactory.serialize(input, out);
+    }
+
+    /**
+     * Testing of {@link ExperimenterInputMessageFactory} for correct serializer
+     * lookup and serialization
+     * @throws Exception 
+     */
+    @Test
+    public void testV10() throws Exception {
+        startUp(false);
+        ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setExperimenter(new ExperimenterId(42L));
+        ExperimenterInput input = builder.build();
+
+        Mockito.when(registry.getSerializer(
+                (ExperimenterIdSerializerKey<?>) Matchers.any())).thenReturn(serializer);
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        expFactory.serialize(input, out);
+    }
+
+    /**
+     * Testing of {@link ExperimenterInputMessageFactory} for correct serializer
+     * lookup and serialization
+     * @throws Exception 
+     */
+    @Test
+    public void testV13() throws Exception {
+        startUp(false);
+        ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setExperimenter(new ExperimenterId(42L));
+        ExperimenterInput input = builder.build();
+
+        Mockito.when(registry.getSerializer(
+                (ExperimenterIdSerializerKey<?>) Matchers.any())).thenReturn(serializer);
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        expFactory.serialize(input, out);
+    }
 }
\ No newline at end of file