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.deserialization;
10 import org.junit.Assert;
11 import org.junit.Test;
12 import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
14 import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10;
22 public class DeserializerRegistryImplTest {
24 private static final short OF13 = EncodeConstants.OF13_VERSION_ID;
25 private static final short OF10 = EncodeConstants.OF10_VERSION_ID;
26 private static final int EMPTY_VALUE = EncodeConstants.EMPTY_VALUE;
29 * Test - register deserializer without arguments
31 @Test(expected = IllegalArgumentException.class)
32 public void testRegisterDeserializerNoArgs(){
33 DeserializerRegistryImpl serReg = new DeserializerRegistryImpl();
34 serReg.registerDeserializer(null, null);
38 * Test - register deserializer with no key
40 @Test(expected = IllegalArgumentException.class)
41 public void testRegisterDeserializerNoKey(){
42 DeserializerRegistryImpl serReg = new DeserializerRegistryImpl();
43 serReg.registerDeserializer(null, new MatchDeserializer());
47 * Test - register deserializer with no deserializer
49 @Test(expected = IllegalArgumentException.class)
50 public void testRegisterDeserializerNoDeserializer(){
51 DeserializerRegistryImpl serReg = new DeserializerRegistryImpl();
52 serReg.registerDeserializer(new MessageCodeKey(OF13, EMPTY_VALUE, Match.class), null);
56 * Test - unregister deserializer without MessageTypeKey
58 @Test(expected = IllegalArgumentException.class)
59 public void testUnRegisterDeserializerNoMessageTypeKey(){
60 DeserializerRegistryImpl derserReg = new DeserializerRegistryImpl();
62 derserReg.unregisterDeserializer(null);
66 * Test - unregister deserializer
69 public void testUnRegisterDeserializer(){
70 DeserializerRegistryImpl derserReg = new DeserializerRegistryImpl();
72 Assert.assertTrue("Wrong - unregister serializer",derserReg.unregisterDeserializer(new MessageCodeKey(OF13,EMPTY_VALUE, Match.class)));
73 Assert.assertFalse("Wrong - unregister serializer",derserReg.unregisterDeserializer(new MessageCodeKey(OF10,EMPTY_VALUE, Match.class)));
77 * Test - get deserializer
79 @Test(expected=IllegalStateException.class)
80 public void testGetDeserializer(){
81 DeserializerRegistryImpl registry = new DeserializerRegistryImpl();
83 registry.getDeserializer(new MessageCodeKey((short) 5000, EncodeConstants.EMPTY_VALUE, MatchV10.class));