1c63fc0fc2bf33ef304621243b0363b4037004df
[openflowjava.git] / util / src / test / java / org / opendaylight / openflowjava / util / ExperimenterDeserializerKeyFactoryTest.java
1 /*\r
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.openflowjava.util;\r
10 \r
11 import org.junit.Assert;\r
12 import org.junit.Test;\r
13 import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey;\r
14 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase;\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;\r
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;\r
21 \r
22 /**\r
23  * @author michal.polkorab\r
24  *\r
25  */\r
26 public class ExperimenterDeserializerKeyFactoryTest {\r
27 \r
28     /**\r
29      * Test ExperimenterDeserializerKeyFactory key creation\r
30      */\r
31     @Test\r
32     public void test() {\r
33         ExperimenterIdDeserializerKey createdKey = ExperimenterDeserializerKeyFactory\r
34                 .createExperimenterErrorDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L);\r
35         ExperimenterIdDeserializerKey comparationKey =\r
36                 new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ErrorMessage.class);\r
37         Assert.assertEquals("Wrong key created", comparationKey, createdKey);\r
38         createdKey = ExperimenterDeserializerKeyFactory.createExperimenterErrorDeserializerKey(\r
39                 EncodeConstants.OF10_VERSION_ID, null);\r
40         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,\r
41                 null, ErrorMessage.class);\r
42         Assert.assertEquals("Wrong key created", comparationKey, createdKey);\r
43         createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey(\r
44                 EncodeConstants.OF10_VERSION_ID, 43L);\r
45         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,\r
46                 43L, ExperimenterMessage.class);\r
47         Assert.assertEquals("Wrong key created", comparationKey, createdKey);\r
48         createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey(\r
49                 EncodeConstants.OF10_VERSION_ID, null);\r
50         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,\r
51                 null, ExperimenterMessage.class);\r
52         Assert.assertEquals("Wrong key created", comparationKey, createdKey);\r
53         createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey(\r
54                 EncodeConstants.OF10_VERSION_ID, 44L);\r
55         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,\r
56                 44L, MeterBandExperimenterCase.class);\r
57         Assert.assertEquals("Wrong key created", comparationKey, createdKey);\r
58         createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey(\r
59                 EncodeConstants.OF10_VERSION_ID, null);\r
60         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,\r
61                 null, MeterBandExperimenterCase.class);\r
62         Assert.assertEquals("Wrong key created", comparationKey, createdKey);\r
63         createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey(\r
64                 EncodeConstants.OF10_VERSION_ID, 45L);\r
65         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,\r
66                 45L, MultipartReplyExperimenterCase.class);\r
67         Assert.assertEquals("Wrong key created", comparationKey, createdKey);\r
68         createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey(\r
69                 EncodeConstants.OF10_VERSION_ID, null);\r
70         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,\r
71                 null, MultipartReplyExperimenterCase.class);\r
72         Assert.assertEquals("Wrong key created", comparationKey, createdKey);\r
73         createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey(\r
74                 EncodeConstants.OF10_VERSION_ID, null);\r
75         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,\r
76                 null, TableFeatureProperties.class);\r
77         Assert.assertEquals("Wrong key created", comparationKey, createdKey);\r
78         createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey(\r
79                 EncodeConstants.OF10_VERSION_ID, null);\r
80         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,\r
81                 null, TableFeatureProperties.class);\r
82         Assert.assertEquals("Wrong key created", comparationKey, createdKey);\r
83         createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey(\r
84                 EncodeConstants.OF10_VERSION_ID, null);\r
85         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,\r
86                 null, QueueProperty.class);\r
87         Assert.assertEquals("Wrong key created", comparationKey, createdKey);\r
88         createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey(\r
89                 EncodeConstants.OF10_VERSION_ID, null);\r
90         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,\r
91                 null, QueueProperty.class);\r
92         Assert.assertEquals("Wrong key created", comparationKey, createdKey);\r
93     }\r
94 }