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
9 package org.opendaylight.openflowjava.util;
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdMeterSubTypeSerializerKey;
14 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey;
15 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey;
16 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterMeterBandSubType;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
23 * Test ExperimenterSerializerKeyFactory key creation
24 * @author michal.polkorab
27 public class ExperimenterSerializerKeyFactoryTest {
30 public void testCreateExperimenterMessageSerializerKey() throws Exception {
31 ExperimenterIdSerializerKey<?> createdKey;
32 ExperimenterIdSerializerKey<?> comparationKey;
34 createdKey = ExperimenterSerializerKeyFactory
35 .createExperimenterMessageSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, 1L);
36 comparationKey = new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
37 42L, 1L, ExperimenterDataOfChoice.class);
38 Assert.assertEquals("Wrong key created", comparationKey, createdKey);
42 public void testCreateMultipartRequestSerializerKey() throws Exception {
43 ExperimenterIdSerializerKey<?> createdKey;
44 ExperimenterIdSerializerKey<?> comparationKey;
46 createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey(
47 EncodeConstants.OF10_VERSION_ID, 44L, 1L);
48 comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
49 44L, ExperimenterDataOfChoice.class);
50 Assert.assertEquals("Wrong key created", comparationKey, createdKey);
54 public void testCreateMultipartRequestTFSerializerKey() throws Exception {
55 ExperimenterIdSerializerKey<?> createdKey;
56 ExperimenterIdSerializerKey<?> comparationKey;
58 createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey(
59 EncodeConstants.OF10_VERSION_ID, 45L);
60 comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
61 45L, TableFeatureProperties.class);
62 Assert.assertEquals("Wrong key created", comparationKey, createdKey);
66 public void testCreateMeterBandSerializerKey() throws Exception {
67 ExperimenterIdSerializerKey<?> createdKey;
68 ExperimenterIdSerializerKey<?> comparationKey;
70 createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey(
71 EncodeConstants.OF10_VERSION_ID, 43L);
72 comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
73 43L, MeterBandExperimenterCase.class);
74 Assert.assertEquals("Wrong key created", comparationKey, createdKey);
78 public void testCreateMeterBandSubTypeSerializerKey() throws Exception {
79 ExperimenterIdSerializerKey<?> createdKey;
80 ExperimenterIdSerializerKey<?> comparationKey1;
81 ExperimenterIdSerializerKey<?> comparationKey2;
82 ExperimenterIdSerializerKey<?> comparationKey3;
83 ExperimenterIdSerializerKey<?> comparationKey4;
84 ExperimenterIdSerializerKey<?> comparationKey5;
86 createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey(
87 EncodeConstants.OF10_VERSION_ID, 43L, ExperimenterMeterBandSubType.class);
88 comparationKey1 = new ExperimenterIdMeterSubTypeSerializerKey<>(EncodeConstants.OF13_VERSION_ID,
89 43L, MeterBandExperimenterCase.class, ExperimenterMeterBandSubType.class);
90 comparationKey2 = new ExperimenterIdMeterSubTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
91 42L, MeterBandExperimenterCase.class, ExperimenterMeterBandSubType.class);
92 comparationKey3 = new ExperimenterIdMeterSubTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
93 43L, null, ExperimenterMeterBandSubType.class);
94 comparationKey4 = new ExperimenterIdMeterSubTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
95 43L, MeterBandExperimenterCase.class, null);
96 comparationKey5 = new ExperimenterIdMeterSubTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
97 43L, MeterBandExperimenterCase.class, ExperimenterMeterBandSubType.class);
98 Assert.assertNotEquals("Wrong key created", comparationKey1, createdKey);
99 Assert.assertNotEquals("Wrong key created", comparationKey2, createdKey);
100 Assert.assertNotEquals("Wrong key created", comparationKey3, createdKey);
101 Assert.assertNotEquals("Wrong key created", comparationKey4, createdKey);
102 Assert.assertEquals("Wrong key created", comparationKey5, createdKey);