Remove trailing whitespace
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / DeserializerRegistryImplTest.java
1 /*
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowjava.protocol.impl.deserialization;
9
10 import org.junit.Assert;
11 import org.junit.Test;
12 import org.opendaylight.openflowjava.protocol.api.extensibility.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.rev130731.match.grouping.Match;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
17 /**
18  *
19  * @author madamjak
20  *
21  */
22 public class DeserializerRegistryImplTest {
23
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;
27
28     /**
29      * Test - register deserializer without arguments
30      */
31     @Test(expected = IllegalArgumentException.class)
32     public void testRegisterDeserializerNoArgs(){
33         DeserializerRegistryImpl serReg = new DeserializerRegistryImpl();
34         serReg.registerDeserializer(null, null);
35     }
36
37     /**
38      * Test - register deserializer with no key
39      */
40     @Test(expected = IllegalArgumentException.class)
41     public void testRegisterDeserializerNoKey(){
42         DeserializerRegistryImpl serReg = new DeserializerRegistryImpl();
43         serReg.registerDeserializer(null, new MatchDeserializer());
44     }
45
46     /**
47      * Test - register deserializer with no deserializer
48      */
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);
53     }
54
55     /**
56      * Test - unregister deserializer without MessageTypeKey
57      */
58     @Test(expected = IllegalArgumentException.class)
59     public void testUnRegisterDeserializerNoMessageTypeKey(){
60         DeserializerRegistryImpl derserReg = new DeserializerRegistryImpl();
61         derserReg.init();
62         derserReg.unregisterDeserializer(null);
63     }
64
65     /**
66      * Test - unregister deserializer
67      */
68     @Test
69     public void testUnRegisterDeserializer(){
70         DeserializerRegistryImpl derserReg = new DeserializerRegistryImpl();
71         derserReg.init();
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)));
74     }
75
76     /**
77      * Test - get deserializer
78      */
79     @Test(expected=IllegalStateException.class)
80     public void testGetDeserializer(){
81         DeserializerRegistryImpl registry = new DeserializerRegistryImpl();
82         registry.init();
83         registry.getDeserializer(new MessageCodeKey((short) 5000, EncodeConstants.EMPTY_VALUE, MatchV10.class));
84         Assert.fail();
85     }
86 }