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 org.junit.Assert;
11 import org.junit.Test;
12 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
14 import org.opendaylight.openflowjava.protocol.impl.util.OF13MatchSerializer;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
22 public class SerializerRegistryImplTest {
24 private static final short OF13 = EncodeConstants.OF13_VERSION_ID;
25 private static final short OF10 = EncodeConstants.OF10_VERSION_ID;
28 * Test - register serializer without arguments
30 @Test(expected = IllegalArgumentException.class)
31 public void testRegisterSerializerNoArgs(){
33 SerializerRegistryImpl serReg = new SerializerRegistryImpl();
34 serReg.registerSerializer(null, null);
38 * Test - unregister serializer without MessageTypeKye
40 @Test(expected = IllegalArgumentException.class)
41 public void testUnRegisterSerializerNoMessageTypeKey(){
42 SerializerRegistryImpl serReg = new SerializerRegistryImpl();
44 serReg.registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer());
45 serReg.unregisterSerializer(null);
49 * Test - unregister serializer
52 public void testUnRegisterSerializer(){
53 SerializerRegistryImpl serReg = new SerializerRegistryImpl();
55 serReg.registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer());
56 Assert.assertTrue("Wrong - unregister serializer",serReg.unregisterSerializer(new MessageTypeKey<>(OF13, Match.class)));
58 serReg.registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer());
59 Assert.assertFalse("Wrong - unregister serializer",serReg.unregisterSerializer(new MessageTypeKey<>(OF10, Match.class)));