3 * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.serialization;
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;
14 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
15 import org.opendaylight.openflowjava.protocol.impl.util.OF13MatchSerializer;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
23 public class SerializerRegistryImplTest {
25 private static final short OF13 = EncodeConstants.OF13_VERSION_ID;
26 private static final short OF10 = EncodeConstants.OF10_VERSION_ID;
29 * Test - register serializer without arguments
31 @Test(expected = IllegalArgumentException.class)
32 public void testRegisterSerializerNoArgs(){
34 SerializerRegistryImpl serReg = new SerializerRegistryImpl();
35 serReg.registerSerializer(null, null);
39 * Test - unregister serializer without MessageTypeKye
41 @Test(expected = IllegalArgumentException.class)
42 public void testUnRegisterSerializerNoMessageTypeKey(){
43 SerializerRegistryImpl serReg = new SerializerRegistryImpl();
45 serReg.registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer());
46 serReg.unregisterSerializer(null);
50 * Test - unregister serializer
53 public void testUnRegisterSerialize(){
54 SerializerRegistryImpl serReg = new SerializerRegistryImpl();
56 serReg.registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer());
57 Assert.assertTrue("Wrong - unregister serializer",serReg.unregisterSerializer(new MessageTypeKey<>(OF13, Match.class)));
59 serReg.registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer());
60 Assert.assertFalse("Wrong - unregister serializer",serReg.unregisterSerializer(new MessageTypeKey<>(OF10, Match.class)));