2 * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.openflowjava.protocol.impl.serialization;
10 import static org.opendaylight.openflowjava.protocol.api.util.EncodeConstants.OF_VERSION_1_0;
11 import static org.opendaylight.openflowjava.protocol.api.util.EncodeConstants.OF_VERSION_1_3;
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
16 import org.opendaylight.openflowjava.protocol.impl.util.OF13MatchSerializer;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
20 * Unit tests for SerializerRegistryImpl.
24 public class SerializerRegistryImplTest {
27 * Test - register serializer without arguments.
29 @Test(expected = IllegalArgumentException.class)
30 public void testRegisterSerializerNoArgs() {
32 SerializerRegistryImpl serReg = new SerializerRegistryImpl();
33 serReg.registerSerializer(null, null);
37 * Test - unregister serializer without MessageTypeKey.
39 @Test(expected = IllegalArgumentException.class)
40 public void testUnRegisterSerializerNoMessageTypeKey() {
41 SerializerRegistryImpl serReg = new SerializerRegistryImpl();
43 serReg.registerSerializer(new MessageTypeKey<>(OF_VERSION_1_3, Match.class), new OF13MatchSerializer());
44 serReg.unregisterSerializer(null);
48 * Test - unregister serializer.
51 public void testUnRegisterSerializer() {
52 SerializerRegistryImpl serReg = new SerializerRegistryImpl();
54 serReg.registerSerializer(new MessageTypeKey<>(OF_VERSION_1_3, Match.class), new OF13MatchSerializer());
55 Assert.assertTrue("Wrong - unregister serializer",
56 serReg.unregisterSerializer(new MessageTypeKey<>(OF_VERSION_1_3, Match.class)));
58 serReg.registerSerializer(new MessageTypeKey<>(OF_VERSION_1_3, Match.class), new OF13MatchSerializer());
59 Assert.assertFalse("Wrong - unregister serializer",
60 serReg.unregisterSerializer(new MessageTypeKey<>(OF_VERSION_1_0, Match.class)));