From decd15c6f97a9c16b556605304f6887693ec6f6b Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 24 Sep 2020 19:21:32 +0200 Subject: [PATCH] Migrate openflowplugim-impl tests to uint types This migrates the entire openflowplugin-impl test suite to use Uint types. We borrow EncodeConstants to get at Uint8-specified protocol numbers, which is probably not what we want, but then there seems to be variance of opinion whether to use that or OFConstants. This is fine for this migration, we will address the OFConstants/EncodeConstants duplicity when we migrate production code. JIRA: OPNFLWPLUG-1099 Change-Id: I088597573037b8a662840aff62b0593a058a10b4 Signed-off-by: Robert Varga --- .../MultipartReplyTranslatorUtilTest.java | 34 +++---- .../ConfigurationServiceFactoryImplTest.java | 19 ++-- .../connection/ConnectionManagerImplTest.java | 42 +++++---- .../connection/HandshakeManagerImplTest.java | 10 +- ...enflowProtocolListenerInitialImplTest.java | 12 +-- .../SystemNotificationsListenerImplTest.java | 3 +- .../testutil/MsgGeneratorTestUtils.java | 3 +- .../impl/device/DeviceContextImplTest.java | 10 +- .../impl/device/DeviceManagerImplTest.java | 8 +- .../impl/device/SwitchFeaturesUtilTest.java | 11 ++- .../OF10DeviceInitializerTest.java | 2 +- .../OpenflowProtocolListenerFullImplTest.java | 22 ++--- .../lifecycle/ContextChainHolderImplTest.java | 3 +- .../actions/GroupActionSerializerTest.java | 11 +-- .../actions/OutputActionSerializerTest.java | 7 +- .../actions/PopMplsActionSerializerTest.java | 10 +- .../actions/PushMplsActionSerializerTest.java | 10 +- .../actions/PushPbbActionSerializerTest.java | 10 +- .../actions/PushVlanActionSerializerTest.java | 8 +- .../SetMplsTtlActionSerializerTest.java | 10 +- .../actions/SetNwTtlActionSerializerTest.java | 10 +- .../actions/SetQueueActionSerializerTest.java | 10 +- .../actions/SetTpDstActionSerializerTest.java | 7 +- .../actions/SetTpSrcActionSerializerTest.java | 6 +- .../SetVlanIdActionSerializerTest.java | 10 +- .../SetVlanPcpActionSerializerTest.java | 10 +- .../GoToTableInstructionSerializerTest.java | 10 +- .../MeterInstructionSerializerTest.java | 10 +- ...riteMetadataInstructionSerializerTest.java | 13 +-- .../match/ArpOpEntrySerializerTest.java | 9 +- .../EthernetTypeEntrySerializerTest.java | 3 +- .../match/Icmpv4CodeEntrySerializerTest.java | 5 +- .../match/Icmpv4TypeEntrySerializerTest.java | 5 +- .../match/Icmpv6CodeEntrySerializerTest.java | 5 +- .../match/Icmpv6TypeEntrySerializerTest.java | 5 +- .../match/IpDscpEntrySerializerTest.java | 5 +- .../match/IpEcnEntrySerializerTest.java | 9 +- .../match/IpProtoEntrySerializerTest.java | 5 +- .../Ipv6ExtHeaderEntrySerializerTest.java | 10 +- .../match/Ipv6LabelEntrySerializerTest.java | 10 +- .../match/MetadataEntrySerializerTest.java | 8 +- .../match/MplsBosEntrySerializerTest.java | 11 +-- .../match/MplsLabelEntrySerializerTest.java | 9 +- .../match/MplsTcEntrySerializerTest.java | 9 +- .../match/PacketTypeEntrySerializerTest.java | 5 +- .../match/PbbEntrySerializerTest.java | 14 ++- ...ctpDestinationPortEntrySerializerTest.java | 9 +- .../SctpSourcePortEntrySerializerTest.java | 9 +- ...TcpDestinationPortEntrySerializerTest.java | 9 +- .../match/TcpFlagsEntrySerializerTest.java | 11 +-- .../TcpSourcePortEntrySerializerTest.java | 9 +- .../match/TunnelIdEntrySerializerTest.java | 8 +- ...UdpDestinationPortEntrySerializerTest.java | 9 +- .../UdpSourcePortEntrySerializerTest.java | 9 +- .../match/VlanPcpEntrySerializerTest.java | 9 +- .../match/VlanVidEntrySerializerTest.java | 9 +- .../AsyncConfigMessageSerializerTest.java | 8 +- .../messages/FlowMessageSerializerTest.java | 44 ++++----- .../messages/GroupMessageSerializerTest.java | 17 ++-- .../messages/MeterMessageSerializerTest.java | 28 +++--- .../messages/PortMessageSerializerTest.java | 9 +- ...questFlowAggregateStatsSerializerTest.java | 21 +++-- ...ltipartRequestFlowStatsSerializerTest.java | 20 ++-- ...tipartRequestGroupStatsSerializerTest.java | 6 +- ...MultipartRequestMessageSerializerTest.java | 13 +-- ...ipartRequestMeterConfigSerializerTest.java | 7 +- ...tipartRequestMeterStatsSerializerTest.java | 6 +- ...tipartRequestQueueStatsSerializerTest.java | 6 +- ...artRequestTableFeaturesSerializerTest.java | 24 ++--- .../flow/DeviceFlowRegistryImplTest.java | 9 +- .../flow/FlowRegistryKeyFactoryTest.java | 20 ++-- .../impl/registry/flow/TestFlowHelper.java | 11 ++- .../group/DeviceGroupRegistryImplTest.java | 6 +- .../meter/DeviceMeterRegistryImplTest.java | 5 +- .../impl/rpc/RpcManagerImplTest.java | 7 +- .../MultipartRequestOnTheFlyCallbackTest.java | 21 +++-- .../impl/services/ServiceMocking.java | 2 +- .../batch/FlatBatchFlowAdaptersTest.java | 9 +- .../batch/FlatBatchGroupAdaptersTest.java | 30 +++--- .../batch/FlatBatchMeterAdaptersTest.java | 30 +++--- .../sal/SalBundleServiceImplTest.java | 4 +- ...SalExperimenterMessageServiceImplTest.java | 2 +- .../sal/SalFlatBatchServiceImplTest.java | 68 +++++++------- .../services/sal/SalFlowServiceImplTest.java | 25 ++--- .../sal/SalFlowsBatchServiceImplTest.java | 10 +- .../services/sal/SalGroupServiceImplTest.java | 3 +- .../sal/SalGroupsBatchServiceImplTest.java | 5 +- .../services/sal/SalMeterServiceImplTest.java | 5 +- .../sal/SalMetersBatchServiceImplTest.java | 5 +- .../services/sal/SalRoleServiceImplTest.java | 12 +-- .../services/sal/SalTableServiceImplTest.java | 10 +- ...ayerAggregateFlowMultipartServiceTest.java | 6 +- .../SingleLayerFlowServiceTest.java | 9 +- .../SingleLayerGroupServiceTest.java | 5 +- .../SingleLayerMeterServiceTest.java | 6 +- .../SingleLayerTableMultipartServiceTest.java | 11 ++- .../MultipartReplyTranslatorTest.java | 4 +- .../StatisticsContextImplParamTest.java | 7 +- .../statistics/StatisticsContextImplTest.java | 4 +- .../StatisticsGatheringUtilsTest.java | 88 +++++++++--------- .../statistics/StatisticsManagerImplTest.java | 7 +- ...aylightFlowStatisticsServiceImpl1Test.java | 8 +- ...aylightFlowStatisticsServiceImpl2Test.java | 10 +- ...aylightFlowStatisticsServiceImpl3Test.java | 9 +- ...ghtFlowTableStatisticsServiceImplTest.java | 22 ++--- ...aylightGroupStatisticsServiceImplTest.java | 38 ++++---- ...aylightMeterStatisticsServiceImplTest.java | 44 ++++----- ...daylightPortStatisticsServiceImplTest.java | 38 ++++---- ...aylightQueueStatisticsServiceImplTest.java | 25 ++--- .../AbstractCompatibleStatServiceTest.java | 20 ++-- ...FlowStatisticsServiceDelegateImplTest.java | 92 +++++++++---------- .../FlowDirectStatisticsServiceTest.java | 10 +- .../GroupDirectStatisticsServiceTest.java | 12 +-- .../MeterDirectStatisticsServiceTest.java | 7 +- .../FlowDirectStatisticsServiceTest.java | 17 ++-- .../GroupDirectStatisticsServiceTest.java | 2 +- .../MeterDirectStatisticsServiceTest.java | 14 +-- .../QueueDirectStatisticsServiceTest.java | 10 +- ...ggregatedFlowStatisticsTranslatorTest.java | 10 +- .../translator/FlowRemovedTranslatorTest.java | 10 +- .../PacketReceivedTranslatorTest.java | 18 ++-- .../translator/PortUpdateTranslatorTest.java | 7 +- .../util/DeviceInitializationUtilTest.java | 5 +- .../impl/util/FlatBatchUtilTest.java | 26 +++--- .../impl/util/FlowCreatorUtilTest.java | 56 ++++++----- .../impl/util/GroupUtilTest.java | 4 +- .../impl/util/MatchNormalizationUtilTest.java | 4 +- .../impl/util/MatchUtilTest.java | 24 ++--- .../impl/util/MeterUtilTest.java | 5 +- .../NodeConnectorRefToPortTranslatorTest.java | 12 +-- 130 files changed, 876 insertions(+), 887 deletions(-) diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtilTest.java index a0b3387d1c..2d701f2dc1 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/common/MultipartReplyTranslatorUtilTest.java @@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.impl.common; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; -import java.math.BigInteger; import java.util.Collections; import java.util.Optional; import org.junit.Before; @@ -67,12 +66,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTableBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(MockitoJUnitRunner.class) public class MultipartReplyTranslatorUtilTest { @Mock private DeviceInfo deviceInfo; - private ConvertorExecutor convertorExecutor = ConvertorManagerFactory.createDefaultManager(); + private final ConvertorExecutor convertorExecutor = ConvertorManagerFactory.createDefaultManager(); private TranslatorLibrarian translatorLibrarian; @Before @@ -168,9 +170,9 @@ public class MultipartReplyTranslatorUtilTest { MultipartType.OFPMPAGGREGATE, new MultipartReplyAggregateCaseBuilder() .setMultipartReplyAggregate(new MultipartReplyAggregateBuilder() - .setByteCount(BigInteger.ONE) - .setFlowCount(10L) - .setPacketCount(BigInteger.ONE) + .setByteCount(Uint64.ONE) + .setFlowCount(Uint32.TEN) + .setPacketCount(Uint64.ONE) .build()) .build()); @@ -278,7 +280,7 @@ public class MultipartReplyTranslatorUtilTest { MultipartType.OFPMPMETERFEATURES, new MultipartReplyMeterFeaturesCaseBuilder() .setMultipartReplyMeterFeatures(new MultipartReplyMeterFeaturesBuilder() - .setMaxMeter(10L) + .setMaxMeter(Uint32.TEN) .setCapabilities(new MeterFlags(true, false, false, false)) .setBandTypes(new MeterBandTypeBitmap(true, false)) .build()) @@ -294,10 +296,10 @@ public class MultipartReplyTranslatorUtilTest { new MultipartReplyTableCaseBuilder() .setMultipartReplyTable(new MultipartReplyTableBuilder() .setTableStats(Collections.singletonList(new TableStatsBuilder() - .setActiveCount(10L) - .setLookupCount(BigInteger.ONE) - .setMatchedCount(BigInteger.ONE) - .setTableId((short) 10) + .setActiveCount(Uint32.TEN) + .setLookupCount(Uint64.ONE) + .setMatchedCount(Uint64.ONE) + .setTableId(Uint8.TEN) .build())) .build()) .build()); @@ -312,12 +314,12 @@ public class MultipartReplyTranslatorUtilTest { new MultipartReplyQueueCaseBuilder() .setMultipartReplyQueue(new MultipartReplyQueueBuilder() .setQueueStats(Collections.singletonList(new QueueStatsBuilder() - .setTxErrors(BigInteger.ONE) - .setTxBytes(BigInteger.ONE) - .setTxPackets(BigInteger.ONE) - .setDurationNsec(10L) - .setDurationSec(10L) - .setQueueId(10L) + .setTxErrors(Uint64.ONE) + .setTxBytes(Uint64.ONE) + .setTxPackets(Uint64.ONE) + .setDurationNsec(Uint32.TEN) + .setDurationSec(Uint32.TEN) + .setQueueId(Uint32.TEN) .build())) .build()) .build()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImplTest.java index 7039c5edc5..ba3d3efc01 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImplTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.configuration; import static org.junit.Assert.assertEquals; @@ -36,25 +35,25 @@ import org.opendaylight.yangtools.yang.common.Uint32; public class ConfigurationServiceFactoryImplTest { private static final int CONFIG_PROP_COUNT = 25; private static final boolean IS_STATISTICS_POLLING_ON = true; - private static final int BARRIER_COUNT_LIMIT = 2000; - private static final long BARRIER_INTERVAL_TIMEOUT_LIMIT = 3000; - private static final long ECHO_REPLY_TIMEOUT = 4000; + private static final Uint16 BARRIER_COUNT_LIMIT = Uint16.valueOf(2000); + private static final Uint32 BARRIER_INTERVAL_TIMEOUT_LIMIT = Uint32.valueOf(3000); + private static final Uint32 ECHO_REPLY_TIMEOUT = Uint32.valueOf(4000); private static final boolean ENABLE_FLOW_REMOVED_NOTIFICATION = true; private static final boolean SKIP_TABLE_FEATURES = true; - private static final long BASIC_TIMER_DELAY = 2690; - private static final long MAXIMUM_TIMER_DELAY = 3679; + private static final Uint32 BASIC_TIMER_DELAY = Uint32.valueOf(2690); + private static final Uint32 MAXIMUM_TIMER_DELAY = Uint32.valueOf(3679); private static final boolean SWITCH_FEATURES_MANDATORY = false; private static final boolean IS_STATISTICS_RPC_ENABLED = false; private static final boolean USE_SINGLE_LAYER_SERIALIZATION = true; - private static final int RPC_REQUESTS_QUOTA = 2500; + private static final Uint16 RPC_REQUESTS_QUOTA = Uint16.valueOf(2500); private static final Uint32 GLOBAL_NOTIFICATION_QUOTA = Uint32.valueOf(9000); private static final Uint16 THREAD_POOL_MIN_THREADS = Uint16.valueOf(3); private static final int THREAD_POOL_MIN_THREADS_UPDATE = 4; - private static final int THREAD_POOL_MAX_THREADS = 1000; + private static final Uint16 THREAD_POOL_MAX_THREADS = Uint16.valueOf(1000); private static final Uint32 THREAD_POOL_TIMEOUT = Uint32.valueOf(60); private static final Uint16 DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = Uint16.ZERO; private static final Uint16 DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS = Uint16.valueOf(60); - private static final long DEVICE_DATASTORE_REMOVAL_DELAY = 500; + private static final Uint32 DEVICE_DATASTORE_REMOVAL_DELAY = Uint32.valueOf(500); @Mock private OpenflowProviderConfig config; @@ -124,7 +123,7 @@ public class ConfigurationServiceFactoryImplTest { final int tpMaxThreads = configurationService .getProperty(ConfigurationProperty.THREAD_POOL_MAX_THREADS.toString(), Integer::valueOf); - assertEquals(THREAD_POOL_MAX_THREADS, tpMaxThreads); + assertEquals(THREAD_POOL_MAX_THREADS.intValue(), tpMaxThreads); } @Test diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImplTest.java index 25321260a4..4299e033a9 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImplTest.java @@ -29,7 +29,7 @@ import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; -import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceConnectedHandler; import org.opendaylight.openflowplugin.impl.util.ThreadPoolLoggingExecutor; @@ -46,6 +46,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfigBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Test of {@link ConnectionManagerImpl} - lightweight version, using basic ways (TDD). @@ -69,9 +73,9 @@ public class ConnectionManagerImplTest { @Mock DataBroker dataBroker; - private static final long ECHO_REPLY_TIMEOUT = 500; - private static final int DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = 0; - private static final int DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS = 60; + private static final Uint32 ECHO_REPLY_TIMEOUT = Uint32.valueOf(500); + private static final Uint16 DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = Uint16.ZERO; + private static final Uint16 DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS = Uint16.valueOf(60); private static final boolean ENABLE_CUSTOM_TRUST_MANAGER = false; @Before @@ -139,19 +143,22 @@ public class ConnectionManagerImplTest { //set dpn last connected time to be before dpn hold time seconds from now connectionManagerImpl.getDeviceConnectionStatusProvider().addDeviceLastConnectionTime(BigInteger.TEN, - LocalDateTime.now().minusSeconds(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS)); + LocalDateTime.now().minusSeconds(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS.toJava())); // send hello reply - final HelloMessage hello = new HelloMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(1L).build(); + final HelloMessage hello = new HelloMessageBuilder() + .setVersion(EncodeConstants.OF_VERSION_1_3) + .setXid(Uint32.ONE) + .build(); ofpListenerAC.getValue().onHelloMessage(hello); // deliver getFeature output Thread.sleep(100L); final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder() - .setDatapathId(BigInteger.TEN) - .setVersion(OFConstants.OFP_VERSION_1_3) - .setXid(2L) - .setTables((short) 15) + .setDatapathId(Uint64.TEN) + .setVersion(EncodeConstants.OF_VERSION_1_3) + .setXid(Uint32.TWO) + .setTables(Uint8.valueOf(15)) .build(); final RpcResult rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build(); featureResponseFx.set(rpcFeaturesOutput); @@ -190,10 +197,13 @@ public class ConnectionManagerImplTest { //set dpn last connected time to be before dpn hold time seconds from now connectionManagerImpl.getDeviceConnectionStatusProvider().addDeviceLastConnectionTime(BigInteger.TEN, - LocalDateTime.now().minusSeconds(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS)); + LocalDateTime.now().minusSeconds(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS.toJava())); // fire handshake - send hello reply - final HelloMessage hello = new HelloMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(1L).build(); + final HelloMessage hello = new HelloMessageBuilder() + .setVersion(EncodeConstants.OF_VERSION_1_3) + .setXid(Uint32.ONE) + .build(); ofpListenerAC.getValue().onHelloMessage(hello); // notify about connection ready @@ -207,10 +217,10 @@ public class ConnectionManagerImplTest { // deliver getFeature output Thread.sleep(100L); final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder() - .setDatapathId(BigInteger.TEN) - .setVersion(OFConstants.OFP_VERSION_1_3) - .setXid(2L) - .setTables((short) 15) + .setDatapathId(Uint64.TEN) + .setVersion(EncodeConstants.OF_VERSION_1_3) + .setXid(Uint32.TWO) + .setTables(Uint8.valueOf(15)) .build(); final RpcResult rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build(); featureResponseFx.set(rpcFeaturesOutput); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/HandshakeManagerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/HandshakeManagerImplTest.java index 496b4714b0..1294fa8262 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/HandshakeManagerImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/HandshakeManagerImplTest.java @@ -43,6 +43,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfigBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,7 +57,7 @@ import org.slf4j.LoggerFactory; public class HandshakeManagerImplTest { private static final Logger LOG = LoggerFactory.getLogger(HandshakeManagerImplTest.class); - private static final int DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = 0; + private static final Uint16 DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = Uint16.ZERO; private static final int DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS = 60; private HandshakeManagerImpl handshakeManager; @@ -85,7 +89,7 @@ public class HandshakeManagerImplTest { errorHandler, handshakeListener, false, deviceConnectionRateLimiter, DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS, deviceConnectionStatusProvider); - resultFeatures = RpcResultBuilder.success(new GetFeaturesOutputBuilder().setDatapathId(BigInteger.ONE).build()) + resultFeatures = RpcResultBuilder.success(new GetFeaturesOutputBuilder().setDatapathId(Uint64.ONE).build()) .build(); Mockito.when(adapter.hello(any(HelloInput.class))) @@ -519,7 +523,7 @@ public class HandshakeManagerImplTest { * @return builder */ private static HelloMessageBuilder createHelloMessage(short ofpVersion10, long helloXid) { - return new HelloMessageBuilder().setVersion(ofpVersion10).setXid(helloXid); + return new HelloMessageBuilder().setVersion(Uint8.valueOf(ofpVersion10)).setXid(Uint32.valueOf(helloXid)); } /** diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/OpenflowProtocolListenerInitialImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/OpenflowProtocolListenerInitialImplTest.java index fd2d2f14d9..d5114bb476 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/OpenflowProtocolListenerInitialImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/OpenflowProtocolListenerInitialImplTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.connection.listener; import org.junit.Assert; @@ -17,12 +16,13 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; -import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.connection.HandshakeContext; import org.opendaylight.openflowplugin.api.openflow.md.core.HandshakeManager; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link OpenflowProtocolListenerInitialImpl}. @@ -55,8 +55,8 @@ public class OpenflowProtocolListenerInitialImplTest { @Test public void testOnEchoRequestMessage() { EchoRequestMessageBuilder echoRequestMessageBld = new EchoRequestMessageBuilder() - .setXid(42L) - .setVersion(OFConstants.OFP_VERSION_1_3); + .setXid(Uint32.valueOf(42)) + .setVersion(EncodeConstants.OF_VERSION_1_3); openflowProtocolListenerInitial.onEchoRequestMessage(echoRequestMessageBld.build()); Mockito.verify(connectionAdapter).echoReply(ArgumentMatchers.any()); @@ -65,8 +65,8 @@ public class OpenflowProtocolListenerInitialImplTest { @Test public void testOnHelloMessage() { HelloMessageBuilder helloMessageBld = new HelloMessageBuilder() - .setXid(42L) - .setVersion(OFConstants.OFP_VERSION_1_3); + .setXid(Uint32.valueOf(42)) + .setVersion(EncodeConstants.OF_VERSION_1_3); openflowProtocolListenerInitial.onHelloMessage(helloMessageBld.build()); Mockito.verify(handshakeManager).shake(ArgumentMatchers.any()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.java index 667e2779c9..effbf13bf8 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.java @@ -40,6 +40,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.S import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint8; /** @@ -160,7 +161,7 @@ public class SystemNotificationsListenerImplTest { @Test public void testOnSwitchIdleEvent1() throws Exception { final ListenableFuture> echoReply = - Futures.immediateFuture(RpcResultBuilder.success(new EchoOutputBuilder().setXid(0L).build()).build()); + RpcResultBuilder.success(new EchoOutputBuilder().setXid(Uint32.ZERO).build()).buildFuture(); Mockito.when(connectionAdapter.echo(any(EchoInput.class))).thenReturn(echoReply); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/testutil/MsgGeneratorTestUtils.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/testutil/MsgGeneratorTestUtils.java index 2a209e9779..bce5d97676 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/testutil/MsgGeneratorTestUtils.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/testutil/MsgGeneratorTestUtils.java @@ -14,6 +14,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public final class MsgGeneratorTestUtils { @@ -30,7 +31,7 @@ public final class MsgGeneratorTestUtils { MultipartReplyMessageBuilder messageBuilder = new MultipartReplyMessageBuilder() .setMultipartReplyBody(replyBody) - .setXid(xid) + .setXid(Uint32.valueOf(xid)) .setFlags(new MultipartRequestFlags(hasNext)) .setType(MultipartType.OFPMPDESC); return messageBuilder; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java index b96f6b0e3d..76462bbd50 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java @@ -23,7 +23,6 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import io.netty.util.HashedWheelTimer; -import java.math.BigInteger; import java.util.Optional; import java.util.concurrent.atomic.AtomicLong; import org.junit.Before; @@ -110,6 +109,7 @@ import org.opendaylight.yangtools.util.concurrent.NotificationManager; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint64; import org.opendaylight.yangtools.yang.common.Uint8; @@ -432,9 +432,9 @@ public class DeviceContextImplTest { public void testProcessFlowRemovedMessage() { // prepare translation result final FlowRemovedBuilder flowRemovedMdsalBld = new FlowRemovedBuilder() - .setTableId((short) 0) - .setPriority(42) - .setCookie(new FlowCookie(BigInteger.ONE)) + .setTableId(Uint8.ZERO) + .setPriority(Uint16.valueOf(42)) + .setCookie(new FlowCookie(Uint64.ONE)) .setMatch(new MatchBuilder().build()); final NotificationPublishService mockedNotificationPublishService = mock(NotificationPublishService.class); @@ -454,7 +454,7 @@ public class DeviceContextImplTest { // prepare path to flow to be removed final KeyedInstanceIdentifier flowToBeRemovedPath = nodeKeyIdent .augmentation(FlowCapableNode.class) - .child(Table.class, new TableKey((short) 0)) + .child(Table.class, new TableKey(Uint8.ZERO)) .child(Flow.class, new FlowKey(new FlowId("ut-ofp:f456"))); deviceContext.setNotificationPublishService(mockedNotificationPublishService); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java index c657fc7b08..f64100a67d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java @@ -59,13 +59,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfigBuilder; import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; @RunWith(MockitoJUnitRunner.class) public class DeviceManagerImplTest { - private static final long TEST_VALUE_GLOBAL_NOTIFICATION_QUOTA = 2000L; - private static final int BARRIER_COUNT_LIMIT = 25600; - private static final long BARRIER_INTERVAL_NANOS = 500; + private static final Uint32 TEST_VALUE_GLOBAL_NOTIFICATION_QUOTA = Uint32.valueOf(2000); + private static final Uint16 BARRIER_COUNT_LIMIT = Uint16.valueOf(25600); + private static final Uint32 BARRIER_INTERVAL_NANOS = Uint32.valueOf(500); private static final NodeId DUMMY_NODE_ID = new NodeId("dummyNodeId"); private static final KeyedInstanceIdentifier DUMMY_IDENTIFIER = DeviceStateUtil .createNodeInstanceIdentifier(DUMMY_NODE_ID); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtilTest.java index a96c5061a8..870437bb23 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/SwitchFeaturesUtilTest.java @@ -14,6 +14,7 @@ import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Tests for setting switch features for different version of OF plugin. @@ -53,7 +54,7 @@ public class SwitchFeaturesUtilTest { @Test public void testSwFeaturesCapabilitiesV10() { CapabilitiesV10 capabilities = new CapabilitiesV10(true, false, true, false, true, false, true, false); - featuresOutputBuilder.setCapabilitiesV10(capabilities).setVersion((short) 1); + featuresOutputBuilder.setCapabilitiesV10(capabilities).setVersion(Uint8.ONE); Assert.assertNotNull(swUtil.buildSwitchFeatures(featuresOutputBuilder.build())); } @@ -67,7 +68,7 @@ public class SwitchFeaturesUtilTest { @Test public void testSwFeaturesCapabilitiesV13() { Capabilities capabilities = new Capabilities(true, false, true, false, true, false, true); - featuresOutputBuilder.setCapabilities(capabilities).setCapabilitiesV10(null).setVersion((short) 4); + featuresOutputBuilder.setCapabilities(capabilities).setCapabilitiesV10(null).setVersion(Uint8.valueOf(4)); Assert.assertNotNull(swUtil.buildSwitchFeatures(featuresOutputBuilder.build())); } @@ -81,7 +82,7 @@ public class SwitchFeaturesUtilTest { //@Test TODO:do we need to check if capability is null? public void testSwFeaturesCapabilitiesMalformed() { CapabilitiesV10 capabilities = new CapabilitiesV10(true, false, true, false, true, false, true, null); - featuresOutputBuilder.setCapabilitiesV10(capabilities).setCapabilities(null).setVersion((short) 1); + featuresOutputBuilder.setCapabilitiesV10(capabilities).setCapabilities(null).setVersion(Uint8.ONE); Assert.assertNull(swUtil.buildSwitchFeatures(featuresOutputBuilder.build())); } @@ -95,7 +96,7 @@ public class SwitchFeaturesUtilTest { @Test public void testSwFeaturesCapabilitiesVersionMismatch() { CapabilitiesV10 capabilities = new CapabilitiesV10(true, false, true, false, true, false, true, false); - featuresOutputBuilder.setCapabilitiesV10(capabilities).setCapabilities(null).setVersion((short) 4); + featuresOutputBuilder.setCapabilitiesV10(capabilities).setCapabilities(null).setVersion(Uint8.valueOf(4)); Assert.assertNull(swUtil.buildSwitchFeatures(featuresOutputBuilder.build())); } @@ -108,7 +109,7 @@ public class SwitchFeaturesUtilTest { @Test public void testSwFeaturesCapabilitiesNonexistingVersion() { CapabilitiesV10 capabilities = new CapabilitiesV10(true, false, true, false, true, false, true, false); - featuresOutputBuilder.setCapabilitiesV10(capabilities).setCapabilities(null).setVersion((short) 0); + featuresOutputBuilder.setCapabilitiesV10(capabilities).setCapabilities(null).setVersion(Uint8.ZERO); Assert.assertNull(swUtil.buildSwitchFeatures(featuresOutputBuilder.build())); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializerTest.java index 8869734b1a..d5929bdec4 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializerTest.java @@ -84,7 +84,7 @@ public class OF10DeviceInitializerTest { when(featuresReply.getCapabilitiesV10()).thenReturn(capabilitiesV10); when(featuresReply.getPhyPort()).thenReturn(Collections .singletonList(new PhyPortBuilder() - .setPortNo(42L) + .setPortNo(Uint32.valueOf(42)) .build())); when(connectionContext.getFeatures()).thenReturn(featuresReply); when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/listener/OpenflowProtocolListenerFullImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/listener/OpenflowProtocolListenerFullImplTest.java index d56dbb9052..ffe7362f6d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/listener/OpenflowProtocolListenerFullImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/listener/OpenflowProtocolListenerFullImplTest.java @@ -19,7 +19,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; -import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; @@ -37,14 +37,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * openflowplugin-impl * org.opendaylight.openflowplugin.impl.connection.listener * test of {@link OpenflowProtocolListenerFullImpl} - lightweight version, using basic ways (TDD). * - * @author Vaclav Demcak - * + * @author Vaclav Demcak */ @RunWith(MockitoJUnitRunner.class) public class OpenflowProtocolListenerFullImplTest { @@ -56,7 +56,7 @@ public class OpenflowProtocolListenerFullImplTest { @Mock private ConnectionAdapter connectionAdapter; - private final long xid = 42L; + private final Uint32 xid = Uint32.valueOf(42); @Before public void setUp() { @@ -81,7 +81,7 @@ public class OpenflowProtocolListenerFullImplTest { @Test public void testOnEchoRequestMessage() { EchoRequestMessage echoRequestMessage = new EchoRequestMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3).setXid(xid).build(); + .setVersion(EncodeConstants.OF_VERSION_1_3).setXid(xid).build(); ofProtocolListener.onEchoRequestMessage(echoRequestMessage); Mockito.verify(connectionAdapter).echoReply(any(EchoReplyInput.class)); @@ -95,7 +95,7 @@ public class OpenflowProtocolListenerFullImplTest { @Test public void testOnErrorMessage() { ErrorMessage errorMessage = new ErrorMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3).setXid(xid).build(); + .setVersion(EncodeConstants.OF_VERSION_1_3).setXid(xid).build(); ofProtocolListener.onErrorMessage(errorMessage); Mockito.verify(deviceReplyProcessor).processReply(any(ErrorMessage.class)); @@ -109,7 +109,7 @@ public class OpenflowProtocolListenerFullImplTest { @Test public void testOnExperimenterMessage() { ExperimenterMessage experimenterMessage = new ExperimenterMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3).setXid(xid).build(); + .setVersion(EncodeConstants.OF_VERSION_1_3).setXid(xid).build(); ofProtocolListener.onExperimenterMessage(experimenterMessage); Mockito.verify(deviceReplyProcessor).processExperimenterMessage(ArgumentMatchers.any()); @@ -123,7 +123,7 @@ public class OpenflowProtocolListenerFullImplTest { @Test public void testOnFlowRemovedMessage() { FlowRemovedMessage flowRemovedMessage = new FlowRemovedMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3).setXid(xid).build(); + .setVersion(EncodeConstants.OF_VERSION_1_3).setXid(xid).build(); ofProtocolListener.onFlowRemovedMessage(flowRemovedMessage); Mockito.verify(deviceReplyProcessor).processFlowRemovedMessage(any(FlowRemovedMessage.class)); @@ -137,7 +137,7 @@ public class OpenflowProtocolListenerFullImplTest { @Test public void testOnHelloMessage() { HelloMessage helloMessage = new HelloMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3).setXid(xid).build(); + .setVersion(EncodeConstants.OF_VERSION_1_3).setXid(xid).build(); ofProtocolListener.onHelloMessage(helloMessage); Mockito.verify(connectionAdapter).getRemoteAddress(); @@ -152,7 +152,7 @@ public class OpenflowProtocolListenerFullImplTest { @Test public void testOnPacketInMessage() { PacketInMessage packetInMessage = new PacketInMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3).setXid(xid).build(); + .setVersion(EncodeConstants.OF_VERSION_1_3).setXid(xid).build(); ofProtocolListener.onPacketInMessage(packetInMessage); Mockito.verify(deviceReplyProcessor).processPacketInMessage(any(PacketInMessage.class)); @@ -166,7 +166,7 @@ public class OpenflowProtocolListenerFullImplTest { @Test public void testOnPortStatusMessage() { PortStatusMessage portStatusMessage = new PortStatusMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3).setXid(xid).build(); + .setVersion(EncodeConstants.OF_VERSION_1_3).setXid(xid).build(); ofProtocolListener.onPortStatusMessage(portStatusMessage); Mockito.verify(deviceReplyProcessor).processPortStatusMessage(any(PortStatusMessage.class)); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImplTest.java index 96dcb510bc..914c947909 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImplTest.java @@ -43,6 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint32Type; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.rf.state.rev170713.ResultState; +import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(MockitoJUnitRunner.class) @@ -51,7 +52,7 @@ public class ContextChainHolderImplTest { private static final String ENTITY_TEST = "EntityTest"; private static final String OPENFLOW_TEST = "openflow:test"; private static final Uint8 AUXILIARY_ID = Uint8.ZERO; - private static final Long DEVICE_DATASTORE_REMOVAL_DELAY = 500L; + private static final Uint32 DEVICE_DATASTORE_REMOVAL_DELAY = Uint32.valueOf(500); @Mock private StatisticsManager statisticsManager; @Mock diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/GroupActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/GroupActionSerializerTest.java index 08a721d9a5..47241c3e53 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/GroupActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/GroupActionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.actions; import static org.junit.Assert.assertEquals; @@ -16,20 +15,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class GroupActionSerializerTest extends AbstractActionSerializerTest { @Test public void testSerialize() { - final long group = 10L; - final Action action = new GroupActionCaseBuilder() - .setGroupAction(new GroupActionBuilder() - .setGroupId(group) - .build()) + .setGroupAction(new GroupActionBuilder().setGroupId(Uint32.TEN).build()) .build(); - assertAction(action, out -> assertEquals(out.readUnsignedInt(), group)); + assertAction(action, out -> assertEquals(out.readUnsignedInt(), 10)); } @Override @@ -46,5 +42,4 @@ public class GroupActionSerializerTest extends AbstractActionSerializerTest { protected int getLength() { return ActionConstants.GENERAL_ACTION_LENGTH; } - } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializerTest.java index bbe5360eb6..c0a9d85806 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.actions; import static org.junit.Assert.assertEquals; @@ -20,24 +19,24 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValues; +import org.opendaylight.yangtools.yang.common.Uint16; public class OutputActionSerializerTest extends AbstractActionSerializerTest { @Test public void testSerialize() { - final int length = 10; final String port = OutputPortValues.LOCAL.toString(); final Action action = new OutputActionCaseBuilder() .setOutputAction(new OutputActionBuilder() .setOutputNodeConnector(new Uri("openflow:1:" + port)) - .setMaxLength(length) + .setMaxLength(Uint16.TEN) .build()) .build(); assertAction(action, out -> { assertEquals(out.readUnsignedInt(), BinContent.intToUnsignedLong(PortNumberValues.LOCAL.getIntValue())); - assertEquals(out.readUnsignedShort(), length); + assertEquals(out.readUnsignedShort(), 10); out.skipBytes(ActionConstants.OUTPUT_PADDING); }); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopMplsActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopMplsActionSerializerTest.java index b3b2d56cad..196b4c47f2 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopMplsActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PopMplsActionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.actions; import static org.junit.Assert.assertEquals; @@ -16,21 +15,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class PopMplsActionSerializerTest extends AbstractActionSerializerTest { @Test public void testSerialize() { - final int ethType = 10; - final Action action = new PopMplsActionCaseBuilder() - .setPopMplsAction(new PopMplsActionBuilder() - .setEthernetType(ethType) - .build()) + .setPopMplsAction(new PopMplsActionBuilder().setEthernetType(Uint16.TEN).build()) .build(); assertAction(action, out -> { - assertEquals(out.readUnsignedShort(), ethType); + assertEquals(out.readUnsignedShort(), 10); out.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); }); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializerTest.java index 07bf12e9b9..c63fa239f7 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushMplsActionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.actions; import static org.junit.Assert.assertEquals; @@ -16,21 +15,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class PushMplsActionSerializerTest extends AbstractActionSerializerTest { @Test public void testSerialize() { - final int ethType = 10; - final Action action = new PushMplsActionCaseBuilder() - .setPushMplsAction(new PushMplsActionBuilder() - .setEthernetType(ethType) - .build()) + .setPushMplsAction(new PushMplsActionBuilder().setEthernetType(Uint16.TEN).build()) .build(); assertAction(action, out -> { - assertEquals(out.readUnsignedShort(), ethType); + assertEquals(out.readUnsignedShort(), 10); out.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); }); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializerTest.java index d97492168e..f524770226 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushPbbActionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.actions; import static org.junit.Assert.assertEquals; @@ -16,21 +15,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class PushPbbActionSerializerTest extends AbstractActionSerializerTest { @Test public void testSerialize() { - final int ethType = 10; - final Action action = new PushPbbActionCaseBuilder() - .setPushPbbAction(new PushPbbActionBuilder() - .setEthernetType(ethType) - .build()) + .setPushPbbAction(new PushPbbActionBuilder().setEthernetType(Uint16.TEN).build()) .build(); assertAction(action, out -> { - assertEquals(out.readUnsignedShort(), ethType); + assertEquals(out.readUnsignedShort(), 10); out.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); }); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializerTest.java index 5dd7d71517..53ef6e4cef 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/PushVlanActionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.actions; import static org.junit.Assert.assertEquals; @@ -16,21 +15,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class PushVlanActionSerializerTest extends AbstractActionSerializerTest { @Test public void testSerialize() { - final int ethType = 10; - final Action action = new PushVlanActionCaseBuilder() .setPushVlanAction(new PushVlanActionBuilder() - .setEthernetType(ethType) + .setEthernetType(Uint16.TEN) .build()) .build(); assertAction(action, out -> { - assertEquals(out.readUnsignedShort(), ethType); + assertEquals(out.readUnsignedShort(), 10); out.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); }); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializerTest.java index ba7ee370ea..d3b7783494 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetMplsTtlActionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.actions; import static org.junit.Assert.assertEquals; @@ -16,21 +15,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class SetMplsTtlActionSerializerTest extends AbstractActionSerializerTest { @Test public void testSerialize() { - final short mpls = (short) 10; - final Action action = new SetMplsTtlActionCaseBuilder() - .setSetMplsTtlAction(new SetMplsTtlActionBuilder() - .setMplsTtl(mpls) - .build()) + .setSetMplsTtlAction(new SetMplsTtlActionBuilder().setMplsTtl(Uint8.TEN).build()) .build(); assertAction(action, out -> { - assertEquals(out.readUnsignedByte(), mpls); + assertEquals(out.readUnsignedByte(), (short) 10); out.skipBytes(ActionConstants.SET_MPLS_TTL_PADDING); }); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializerTest.java index a79a34adf1..826472b871 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetNwTtlActionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.actions; import static org.junit.Assert.assertEquals; @@ -16,21 +15,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class SetNwTtlActionSerializerTest extends AbstractActionSerializerTest { @Test public void testSerialize() { - final short ttl = 10; - final Action action = new SetNwTtlActionCaseBuilder() - .setSetNwTtlAction(new SetNwTtlActionBuilder() - .setNwTtl(ttl) - .build()) + .setSetNwTtlAction(new SetNwTtlActionBuilder().setNwTtl(Uint8.TEN).build()) .build(); assertAction(action, out -> { - assertEquals(out.readUnsignedByte(), ttl); + assertEquals(out.readUnsignedByte(), 10); out.skipBytes(ActionConstants.SET_NW_TTL_PADDING); }); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetQueueActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetQueueActionSerializerTest.java index 989a2c1b23..cc09bedbe5 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetQueueActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetQueueActionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.actions; import static org.junit.Assert.assertEquals; @@ -16,20 +15,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class SetQueueActionSerializerTest extends AbstractActionSerializerTest { @Test public void testSerialize() { - final long queue = 10; - final Action action = new SetQueueActionCaseBuilder() - .setSetQueueAction(new SetQueueActionBuilder() - .setQueueId(queue) - .build()) + .setSetQueueAction(new SetQueueActionBuilder().setQueueId(Uint32.TEN).build()) .build(); - assertAction(action, out -> assertEquals(out.readUnsignedInt(), queue)); + assertAction(action, out -> assertEquals(out.readUnsignedInt(), 10)); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializerTest.java index 438e85c741..22b924e404 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpDstActionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.actions; import static org.junit.Assert.assertEquals; @@ -17,18 +16,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder; import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint8; public class SetTpDstActionSerializerTest extends AbstractSetFieldActionSerializerTest { @Test public void testSerialize() { - final PortNumber port = new PortNumber(20); - final short protocol = 6; // TCP + final PortNumber port = new PortNumber(Uint16.valueOf(20)); final Action action = new SetTpDstActionCaseBuilder() .setSetTpDstAction(new SetTpDstActionBuilder() .setPort(port) - .setIpProtocol(protocol) + .setIpProtocol(Uint8.valueOf(6)) .build()) .build(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializerTest.java index 56ea107427..990413a29a 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetTpSrcActionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.actions; import static org.junit.Assert.assertEquals; @@ -17,18 +16,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder; import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint8; public class SetTpSrcActionSerializerTest extends AbstractSetFieldActionSerializerTest { @Test public void testSerialize() { - final PortNumber port = new PortNumber(20); + final PortNumber port = new PortNumber(Uint16.valueOf(20)); final short protocol = 6; // TCP final Action action = new SetTpSrcActionCaseBuilder() .setSetTpSrcAction(new SetTpSrcActionBuilder() .setPort(port) - .setIpProtocol(protocol) + .setIpProtocol(Uint8.valueOf(protocol)) .build()) .build(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanIdActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanIdActionSerializerTest.java index c90c554f60..fc6425dea4 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanIdActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanIdActionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.actions; import static org.junit.Assert.assertEquals; @@ -16,20 +15,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId; +import org.opendaylight.yangtools.yang.common.Uint16; public class SetVlanIdActionSerializerTest extends AbstractSetFieldActionSerializerTest { @Test public void testSerialize() { - final int vlan = 1; - final Action action = new SetVlanIdActionCaseBuilder() - .setSetVlanIdAction(new SetVlanIdActionBuilder() - .setVlanId(new VlanId(vlan)) - .build()) + .setSetVlanIdAction(new SetVlanIdActionBuilder().setVlanId(new VlanId(Uint16.ONE)).build()) .build(); - assertAction(action, out -> assertEquals(out.readShort(), vlan | (1 << 12))); + assertAction(action, out -> assertEquals(out.readShort(), 1 | 1 << 12)); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanPcpActionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanPcpActionSerializerTest.java index e45692fde9..23d8fb553b 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanPcpActionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetVlanPcpActionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.actions; import static org.junit.Assert.assertEquals; @@ -16,20 +15,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp; +import org.opendaylight.yangtools.yang.common.Uint8; public class SetVlanPcpActionSerializerTest extends AbstractSetFieldActionSerializerTest { @Test public void testSerialize() { - final short vlan = 1; - final Action action = new SetVlanPcpActionCaseBuilder() - .setSetVlanPcpAction(new SetVlanPcpActionBuilder() - .setVlanPcp(new VlanPcp(vlan)) - .build()) + .setSetVlanPcpAction(new SetVlanPcpActionBuilder().setVlanPcp(new VlanPcp(Uint8.ONE)).build()) .build(); - assertAction(action, out -> assertEquals(out.readUnsignedByte(), vlan)); + assertAction(action, out -> assertEquals(out.readUnsignedByte(), 1)); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/GoToTableInstructionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/GoToTableInstructionSerializerTest.java index a139636b1e..5c29390e0a 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/GoToTableInstructionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/GoToTableInstructionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.instructions; import static org.junit.Assert.assertEquals; @@ -16,21 +15,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class GoToTableInstructionSerializerTest extends AbstractInstructionSerializerTest { @Test public void testSerialize() { - final short table = 2; - final Instruction instruction = new GoToTableCaseBuilder() - .setGoToTable(new GoToTableBuilder() - .setTableId(table) - .build()) + .setGoToTable(new GoToTableBuilder().setTableId(Uint8.TWO).build()) .build(); assertInstruction(instruction, out -> { - assertEquals(out.readUnsignedByte(), table); + assertEquals(out.readUnsignedByte(), 2); out.skipBytes(InstructionConstants.PADDING_IN_GOTO_TABLE); }); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/MeterInstructionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/MeterInstructionSerializerTest.java index 4ef6b3d5f9..6cf1c9691d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/MeterInstructionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/MeterInstructionSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.instructions; import static org.junit.Assert.assertEquals; @@ -17,20 +16,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId; +import org.opendaylight.yangtools.yang.common.Uint32; public class MeterInstructionSerializerTest extends AbstractInstructionSerializerTest { @Test public void testSerialize() { - final long meter = 2; - final Instruction instruction = new MeterCaseBuilder() - .setMeter(new MeterBuilder() - .setMeterId(new MeterId(meter)) - .build()) + .setMeter(new MeterBuilder().setMeterId(new MeterId(Uint32.TWO)).build()) .build(); - assertInstruction(instruction, out -> assertEquals(out.readUnsignedInt(), meter)); + assertInstruction(instruction, out -> assertEquals(out.readUnsignedInt(), 2L)); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/WriteMetadataInstructionSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/WriteMetadataInstructionSerializerTest.java index a7fec8abf3..df22c96f1d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/WriteMetadataInstructionSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/instructions/WriteMetadataInstructionSerializerTest.java @@ -10,32 +10,29 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.instructions import static org.junit.Assert.assertEquals; -import java.math.BigInteger; import org.junit.Test; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; public class WriteMetadataInstructionSerializerTest extends AbstractInstructionSerializerTest { @Test public void testSerialize() { - final long metadata = 10L; - final long metadataMask = 10L; - final Instruction instruction = new WriteMetadataCaseBuilder() .setWriteMetadata(new WriteMetadataBuilder() - .setMetadata(BigInteger.valueOf(metadata)) - .setMetadataMask(BigInteger.valueOf(metadataMask)) + .setMetadata(Uint64.TEN) + .setMetadataMask(Uint64.TEN) .build()) .build(); assertInstruction(instruction, out -> { out.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA); - assertEquals(out.readLong(), metadata); - assertEquals(out.readLong(), metadataMask); + assertEquals(out.readLong(), 10); + assertEquals(out.readLong(), 10); }); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/ArpOpEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/ArpOpEntrySerializerTest.java index eeac39a210..90d1a58d81 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/ArpOpEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/ArpOpEntrySerializerTest.java @@ -14,19 +14,18 @@ import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class ArpOpEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final int arpOp = 42; + final Uint16 arpOp = Uint16.valueOf(42); final Match arpOpMatch = new MatchBuilder() - .setLayer3Match(new ArpMatchBuilder() - .setArpOp(arpOp) - .build()) + .setLayer3Match(new ArpMatchBuilder().setArpOp(arpOp).build()) .build(); - assertMatch(arpOpMatch, false, (out) -> assertEquals(out.readShort(), arpOp)); + assertMatch(arpOpMatch, false, (out) -> assertEquals(out.readShort(), arpOp.intValue())); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/EthernetTypeEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/EthernetTypeEntrySerializerTest.java index 393bd01445..7bd4249a90 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/EthernetTypeEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/EthernetTypeEntrySerializerTest.java @@ -16,6 +16,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class EthernetTypeEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test @@ -25,7 +26,7 @@ public class EthernetTypeEntrySerializerTest extends AbstractMatchEntrySerialize final Match match = new MatchBuilder() .setEthernetMatch(new EthernetMatchBuilder() .setEthernetType(new EthernetTypeBuilder() - .setType(new EtherType(ethType)) + .setType(new EtherType(Uint32.valueOf(ethType))) .build()) .build()) .build(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4CodeEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4CodeEntrySerializerTest.java index 6a7327c5f9..55d51da9ee 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4CodeEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4CodeEntrySerializerTest.java @@ -14,6 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class Icmpv4CodeEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test @@ -21,9 +22,7 @@ public class Icmpv4CodeEntrySerializerTest extends AbstractMatchEntrySerializerT final short code = 200; final Match match = new MatchBuilder() - .setIcmpv4Match(new Icmpv4MatchBuilder() - .setIcmpv4Code(code) - .build()) + .setIcmpv4Match(new Icmpv4MatchBuilder().setIcmpv4Code(Uint8.valueOf(code)).build()) .build(); assertMatch(match, false, (out) -> assertEquals(out.readUnsignedByte(), code)); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4TypeEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4TypeEntrySerializerTest.java index eb0dbbd7b2..12b3658984 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4TypeEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv4TypeEntrySerializerTest.java @@ -14,6 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class Icmpv4TypeEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test @@ -21,9 +22,7 @@ public class Icmpv4TypeEntrySerializerTest extends AbstractMatchEntrySerializerT final short type = 128; final Match match = new MatchBuilder() - .setIcmpv4Match(new Icmpv4MatchBuilder() - .setIcmpv4Type(type) - .build()) + .setIcmpv4Match(new Icmpv4MatchBuilder().setIcmpv4Type(Uint8.valueOf(type)).build()) .build(); assertMatch(match, false, (out) -> assertEquals(out.readUnsignedByte(), type)); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6CodeEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6CodeEntrySerializerTest.java index cea7f7f1c4..0c9da54bf7 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6CodeEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6CodeEntrySerializerTest.java @@ -14,6 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class Icmpv6CodeEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test @@ -21,9 +22,7 @@ public class Icmpv6CodeEntrySerializerTest extends AbstractMatchEntrySerializerT final short code = 101; final Match match = new MatchBuilder() - .setIcmpv6Match(new Icmpv6MatchBuilder() - .setIcmpv6Code(code) - .build()) + .setIcmpv6Match(new Icmpv6MatchBuilder().setIcmpv6Code(Uint8.valueOf(code)).build()) .build(); assertMatch(match, false, (out) -> assertEquals(out.readUnsignedByte(), code)); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6TypeEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6TypeEntrySerializerTest.java index aaaffb7dee..747bc873e3 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6TypeEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Icmpv6TypeEntrySerializerTest.java @@ -14,6 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class Icmpv6TypeEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test @@ -21,9 +22,7 @@ public class Icmpv6TypeEntrySerializerTest extends AbstractMatchEntrySerializerT final short type = 123; final Match match = new MatchBuilder() - .setIcmpv6Match(new Icmpv6MatchBuilder() - .setIcmpv6Type(type) - .build()) + .setIcmpv6Match(new Icmpv6MatchBuilder().setIcmpv6Type(Uint8.valueOf(type)).build()) .build(); assertMatch(match, false, (out) -> assertEquals(out.readUnsignedByte(), type)); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpDscpEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpDscpEntrySerializerTest.java index 8638d4cfa2..6eef9d8ef2 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpDscpEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpDscpEntrySerializerTest.java @@ -15,6 +15,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class IpDscpEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test @@ -22,9 +23,7 @@ public class IpDscpEntrySerializerTest extends AbstractMatchEntrySerializerTest final short dscp = (short) 58; final Match match = new MatchBuilder() - .setIpMatch(new IpMatchBuilder() - .setIpDscp(new Dscp(dscp)) - .build()) + .setIpMatch(new IpMatchBuilder().setIpDscp(new Dscp(Uint8.valueOf(dscp))).build()) .build(); assertMatch(match, false, (out) -> assertEquals(out.readUnsignedByte(), dscp)); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpEcnEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpEcnEntrySerializerTest.java index c2ea23e77b..57d538d54a 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpEcnEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpEcnEntrySerializerTest.java @@ -14,19 +14,18 @@ import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class IpEcnEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final short ecn = (short) 58; + final Uint8 ecn = Uint8.valueOf(58); final Match match = new MatchBuilder() - .setIpMatch(new IpMatchBuilder() - .setIpEcn(ecn) - .build()) + .setIpMatch(new IpMatchBuilder().setIpEcn(ecn).build()) .build(); - assertMatch(match, false, (out) -> assertEquals(out.readUnsignedByte(), ecn)); + assertMatch(match, false, (out) -> assertEquals(out.readUnsignedByte(), ecn.shortValue())); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpProtoEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpProtoEntrySerializerTest.java index e1514a197b..a4a785a695 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpProtoEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/IpProtoEntrySerializerTest.java @@ -14,6 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class IpProtoEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test @@ -21,9 +22,7 @@ public class IpProtoEntrySerializerTest extends AbstractMatchEntrySerializerTest final short proto = (short) 6; // TCP final Match match = new MatchBuilder() - .setIpMatch(new IpMatchBuilder() - .setIpProtocol(proto) - .build()) + .setIpMatch(new IpMatchBuilder().setIpProtocol(Uint8.valueOf(proto)).build()) .build(); assertMatch(match, false, (out) -> assertEquals(out.readUnsignedByte(), proto)); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Ipv6ExtHeaderEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Ipv6ExtHeaderEntrySerializerTest.java index 1d3597886a..e20fb7bf5e 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Ipv6ExtHeaderEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Ipv6ExtHeaderEntrySerializerTest.java @@ -17,12 +17,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class Ipv6ExtHeaderEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final int ipv6extHdr = 358; - final int ipv6extHdrMask = 100; + final Uint16 ipv6extHdr = Uint16.valueOf(358); + final Uint16 ipv6extHdrMask = Uint16.valueOf(100); final Match ipv6extHdrMatch = new MatchBuilder() .setLayer3Match(new Ipv6MatchBuilder() @@ -34,7 +35,7 @@ public class Ipv6ExtHeaderEntrySerializerTest extends AbstractMatchEntrySerializ .build(); assertMatch(ipv6extHdrMatch, true, (out) -> { - assertEquals(out.readUnsignedShort(), ipv6extHdr); + assertEquals(out.readUnsignedShort(), ipv6extHdr.intValue()); byte[] mask = new byte[2]; out.readBytes(mask); @@ -49,7 +50,8 @@ public class Ipv6ExtHeaderEntrySerializerTest extends AbstractMatchEntrySerializ .build()) .build(); - assertMatch(ipv6exyHdrMatchNoMask, false, (out) -> assertEquals(out.readUnsignedShort(), ipv6extHdr)); + assertMatch(ipv6exyHdrMatchNoMask, false, + (out) -> assertEquals(out.readUnsignedShort(), ipv6extHdr.intValue())); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Ipv6LabelEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Ipv6LabelEntrySerializerTest.java index 9d4b084e6a..1b2a6a1408 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Ipv6LabelEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/Ipv6LabelEntrySerializerTest.java @@ -18,12 +18,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class Ipv6LabelEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final long ipv6flowLabel = 358; - final long ipv6flowLabelMask = 100; + final Uint32 ipv6flowLabel = Uint32.valueOf(358); + final Uint32 ipv6flowLabelMask = Uint32.valueOf(100); final Match ipv6flowLabelMatch = new MatchBuilder() .setLayer3Match(new Ipv6MatchBuilder() @@ -35,7 +36,7 @@ public class Ipv6LabelEntrySerializerTest extends AbstractMatchEntrySerializerTe .build(); assertMatch(ipv6flowLabelMatch, true, (out) -> { - assertEquals(out.readUnsignedInt(), ipv6flowLabel); + assertEquals(out.readUnsignedInt(), ipv6flowLabel.longValue()); byte[] mask = new byte[4]; out.readBytes(mask); @@ -50,7 +51,8 @@ public class Ipv6LabelEntrySerializerTest extends AbstractMatchEntrySerializerTe .build()) .build(); - assertMatch(ipv6exyHdrMatchNoMask, false, (out) -> assertEquals(out.readUnsignedInt(), ipv6flowLabel)); + assertMatch(ipv6exyHdrMatchNoMask, false, + (out) -> assertEquals(out.readUnsignedInt(), ipv6flowLabel.longValue())); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MetadataEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MetadataEntrySerializerTest.java index 4d72c27073..14dee79ef5 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MetadataEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MetadataEntrySerializerTest.java @@ -10,12 +10,12 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.match; import static org.junit.Assert.assertArrayEquals; import com.google.common.primitives.Longs; -import java.math.BigInteger; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; public class MetadataEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test @@ -26,8 +26,8 @@ public class MetadataEntrySerializerTest extends AbstractMatchEntrySerializerTes final Match metadataMatch = new MatchBuilder() .setMetadata(new MetadataBuilder() - .setMetadata(BigInteger.valueOf(Longs.fromByteArray(metadata))) - .setMetadataMask(BigInteger.valueOf(Longs.fromByteArray(metadataMask))) + .setMetadata(Uint64.valueOf(Longs.fromByteArray(metadata))) + .setMetadataMask(Uint64.valueOf(Longs.fromByteArray(metadataMask))) .build()) .build(); @@ -43,7 +43,7 @@ public class MetadataEntrySerializerTest extends AbstractMatchEntrySerializerTes final Match metadataMatchNoMask = new MatchBuilder() .setMetadata(new MetadataBuilder() - .setMetadata(BigInteger.valueOf(Longs.fromByteArray(metadata))) + .setMetadata(Uint64.valueOf(Longs.fromByteArray(metadata))) .build()) .build(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsBosEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsBosEntrySerializerTest.java index d2e2773158..4a66f8dde9 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsBosEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsBosEntrySerializerTest.java @@ -7,27 +7,24 @@ */ package org.opendaylight.openflowplugin.impl.protocol.serialization.match; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class MplsBosEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final short mplsBos = (short) 1; - final Match mplsBosMatch = new MatchBuilder() - .setProtocolMatchFields(new ProtocolMatchFieldsBuilder() - .setMplsBos(mplsBos) - .build()) + .setProtocolMatchFields(new ProtocolMatchFieldsBuilder().setMplsBos(Uint8.ONE).build()) .build(); // TODO: Why are we using short in models instead of boolean? - assertMatch(mplsBosMatch, false, (out) -> assertEquals(out.readBoolean(), mplsBos != 0)); + assertMatch(mplsBosMatch, false, (out) -> assertTrue(out.readBoolean())); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsLabelEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsLabelEntrySerializerTest.java index 50650d2350..afb2e71b04 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsLabelEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsLabelEntrySerializerTest.java @@ -14,19 +14,16 @@ import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class MplsLabelEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final long mplsLabel = 10L; - final Match mplsLabelMatch = new MatchBuilder() - .setProtocolMatchFields(new ProtocolMatchFieldsBuilder() - .setMplsLabel(mplsLabel) - .build()) + .setProtocolMatchFields(new ProtocolMatchFieldsBuilder().setMplsLabel(Uint32.TEN).build()) .build(); - assertMatch(mplsLabelMatch, false, (out) -> assertEquals(out.readUnsignedInt(), mplsLabel)); + assertMatch(mplsLabelMatch, false, (out) -> assertEquals(out.readUnsignedInt(), 10L)); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsTcEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsTcEntrySerializerTest.java index f01b89d679..69943b6a9a 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsTcEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MplsTcEntrySerializerTest.java @@ -14,19 +14,16 @@ import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class MplsTcEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final short mplsTc = (short) 1; - final Match mplsTcMatch = new MatchBuilder() - .setProtocolMatchFields(new ProtocolMatchFieldsBuilder() - .setMplsTc(mplsTc) - .build()) + .setProtocolMatchFields(new ProtocolMatchFieldsBuilder().setMplsTc(Uint8.ONE).build()) .build(); - assertMatch(mplsTcMatch, false, (out) -> assertEquals(out.readUnsignedByte(), mplsTc)); + assertMatch(mplsTcMatch, false, (out) -> assertEquals(out.readUnsignedByte(), (short) 1)); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/PacketTypeEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/PacketTypeEntrySerializerTest.java index 0085c6cccb..cd6fbc9fef 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/PacketTypeEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/PacketTypeEntrySerializerTest.java @@ -15,13 +15,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.PacketTypeMatch; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.PacketTypeMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class PacketTypeEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void serializeTest() { final long packetType = 0x1894f; - PacketTypeMatch packetTypeMatch = new PacketTypeMatchBuilder().setPacketType(packetType).build(); + PacketTypeMatch packetTypeMatch = new PacketTypeMatchBuilder() + .setPacketType(Uint32.valueOf(packetType)) + .build(); final Match match = new MatchBuilder().setPacketTypeMatch(packetTypeMatch).build(); assertMatch(match, false, byteBuf -> assertEquals(packetType, byteBuf.readUnsignedInt())); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/PbbEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/PbbEntrySerializerTest.java index 733b81b7e3..874fe18865 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/PbbEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/PbbEntrySerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.match; import static org.junit.Assert.assertArrayEquals; @@ -14,34 +13,33 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class PbbEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final long pbbId = 6789; - final byte[] pbbIdMask = new byte[] { 0, 15, 10 }; + final Uint32 pbbId = Uint32.valueOf(6789); final Match pbbMatch = new MatchBuilder() .setProtocolMatchFields(new ProtocolMatchFieldsBuilder() .setPbb(new PbbBuilder() .setPbbIsid(pbbId) - .setPbbMask(ByteUtil.bytesToUnsignedMedium(pbbIdMask)) + .setPbbMask(Uint32.valueOf(0xF0A)) .build()) .build()) .build(); assertMatch(pbbMatch, true, (out) -> { - assertEquals(out.readUnsignedMedium(), pbbId); + assertEquals(out.readUnsignedMedium(), pbbId.intValue()); final byte[] mask = new byte[3]; out.readBytes(mask); - assertArrayEquals(mask, pbbIdMask); + assertArrayEquals(new byte[] { 0, 15, 10 }, mask); }); final Match pbbMatchNoMask = new MatchBuilder() @@ -52,7 +50,7 @@ public class PbbEntrySerializerTest extends AbstractMatchEntrySerializerTest { .build()) .build(); - assertMatch(pbbMatchNoMask, false, (out) -> assertEquals(out.readUnsignedMedium(), pbbId)); + assertMatch(pbbMatchNoMask, false, (out) -> assertEquals(out.readUnsignedMedium(), pbbId.intValue())); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpDestinationPortEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpDestinationPortEntrySerializerTest.java index c236e1b361..6e9c69b56b 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpDestinationPortEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpDestinationPortEntrySerializerTest.java @@ -15,19 +15,16 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class SctpDestinationPortEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final int sctp = 10; - final Match sctpMatch = new MatchBuilder() - .setLayer4Match(new SctpMatchBuilder() - .setSctpDestinationPort(new PortNumber(sctp)) - .build()) + .setLayer4Match(new SctpMatchBuilder().setSctpDestinationPort(new PortNumber(Uint16.TEN)).build()) .build(); - assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), sctp)); + assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), 10)); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpSourcePortEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpSourcePortEntrySerializerTest.java index 67a35caf7f..20a80a9355 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpSourcePortEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/SctpSourcePortEntrySerializerTest.java @@ -15,19 +15,16 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class SctpSourcePortEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final int sctp = 10; - final Match sctpMatch = new MatchBuilder() - .setLayer4Match(new SctpMatchBuilder() - .setSctpSourcePort(new PortNumber(sctp)) - .build()) + .setLayer4Match(new SctpMatchBuilder().setSctpSourcePort(new PortNumber(Uint16.TEN)).build()) .build(); - assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), sctp)); + assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), 10)); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpDestinationPortEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpDestinationPortEntrySerializerTest.java index 1ebc6b5fbe..171c39bc2e 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpDestinationPortEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpDestinationPortEntrySerializerTest.java @@ -15,19 +15,16 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class TcpDestinationPortEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final int tcp = 10; - final Match sctpMatch = new MatchBuilder() - .setLayer4Match(new TcpMatchBuilder() - .setTcpDestinationPort(new PortNumber(tcp)) - .build()) + .setLayer4Match(new TcpMatchBuilder().setTcpDestinationPort(new PortNumber(Uint16.TEN)).build()) .build(); - assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), tcp)); + assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), 10)); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpFlagsEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpFlagsEntrySerializerTest.java index 30732f87e2..461e9c9c27 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpFlagsEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpFlagsEntrySerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.match; import static org.junit.Assert.assertArrayEquals; @@ -14,27 +13,27 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class TcpFlagsEntrySerializerTest extends AbstractExperimenterMatchEntrySerializerTest { @Test public void testSerialize() { - final int tcp = 8; + final Uint16 tcp = Uint16.valueOf(8); final byte[] tcpMask = new byte[] { 30, 30 }; final Match tcpFlagsMatch = new MatchBuilder() .setTcpFlagsMatch(new TcpFlagsMatchBuilder() .setTcpFlags(tcp) - .setTcpFlagsMask(ByteUtil.bytesToUnsignedShort(tcpMask)) + .setTcpFlagsMask(Uint16.valueOf(0x1E1E)) .build()) .build(); assertMatch(tcpFlagsMatch, true, (out) -> { - assertEquals(out.readUnsignedShort(), tcp); + assertEquals(out.readUnsignedShort(), tcp.intValue()); byte[] mask = new byte[2]; out.readBytes(mask); @@ -47,7 +46,7 @@ public class TcpFlagsEntrySerializerTest extends AbstractExperimenterMatchEntryS .build()) .build(); - assertMatch(tcpFlagsMatchNoMask, false, (out) -> assertEquals(out.readUnsignedShort(), tcp)); + assertMatch(tcpFlagsMatchNoMask, false, (out) -> assertEquals(out.readUnsignedShort(), tcp.intValue())); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpSourcePortEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpSourcePortEntrySerializerTest.java index bea689d1e4..605dc8e719 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpSourcePortEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TcpSourcePortEntrySerializerTest.java @@ -15,19 +15,16 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class TcpSourcePortEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final int tcp = 10; - final Match sctpMatch = new MatchBuilder() - .setLayer4Match(new TcpMatchBuilder() - .setTcpSourcePort(new PortNumber(tcp)) - .build()) + .setLayer4Match(new TcpMatchBuilder().setTcpSourcePort(new PortNumber(Uint16.TEN)).build()) .build(); - assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), tcp)); + assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), 10)); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TunnelIdEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TunnelIdEntrySerializerTest.java index f6957f8107..2657c8a4c4 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TunnelIdEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/TunnelIdEntrySerializerTest.java @@ -10,13 +10,13 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.match; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; -import java.math.BigInteger; import java.nio.ByteBuffer; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder; +import org.opendaylight.yangtools.yang.common.Uint64; public class TunnelIdEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test @@ -30,8 +30,8 @@ public class TunnelIdEntrySerializerTest extends AbstractMatchEntrySerializerTes final Match tcpFlagsMatch = new MatchBuilder() .setTunnel(new TunnelBuilder() - .setTunnelId(BigInteger.valueOf(tunnelId)) - .setTunnelMask(BigInteger.valueOf(maskBuff.getLong())) + .setTunnelId(Uint64.valueOf(tunnelId)) + .setTunnelMask(Uint64.valueOf(maskBuff.getLong())) .build()) .build(); @@ -45,7 +45,7 @@ public class TunnelIdEntrySerializerTest extends AbstractMatchEntrySerializerTes final Match tcpFlagsMatchNoMask = new MatchBuilder() .setTunnel(new TunnelBuilder() - .setTunnelId(BigInteger.valueOf(tunnelId)) + .setTunnelId(Uint64.valueOf(tunnelId)) .build()) .build(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpDestinationPortEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpDestinationPortEntrySerializerTest.java index ad6226dc36..bd62edc78d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpDestinationPortEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpDestinationPortEntrySerializerTest.java @@ -15,19 +15,16 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class UdpDestinationPortEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final int tcp = 10; - final Match sctpMatch = new MatchBuilder() - .setLayer4Match(new UdpMatchBuilder() - .setUdpDestinationPort(new PortNumber(tcp)) - .build()) + .setLayer4Match(new UdpMatchBuilder().setUdpDestinationPort(new PortNumber(Uint16.TEN)).build()) .build(); - assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), tcp)); + assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), 10)); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpSourcePortEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpSourcePortEntrySerializerTest.java index 782661918f..90ea6acfd2 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpSourcePortEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/UdpSourcePortEntrySerializerTest.java @@ -15,19 +15,16 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class UdpSourcePortEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final int tcp = 10; - final Match sctpMatch = new MatchBuilder() - .setLayer4Match(new UdpMatchBuilder() - .setUdpSourcePort(new PortNumber(tcp)) - .build()) + .setLayer4Match(new UdpMatchBuilder().setUdpSourcePort(new PortNumber(Uint16.TEN)).build()) .build(); - assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), tcp)); + assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), 10)); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanPcpEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanPcpEntrySerializerTest.java index 810d9be90e..a7b792c152 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanPcpEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanPcpEntrySerializerTest.java @@ -15,19 +15,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint8; public class VlanPcpEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final short vlan = (short) 1; - final Match vlanMatch = new MatchBuilder() - .setVlanMatch(new VlanMatchBuilder() - .setVlanPcp(new VlanPcp(vlan)) - .build()) + .setVlanMatch(new VlanMatchBuilder().setVlanPcp(new VlanPcp(Uint8.ONE)).build()) .build(); - assertMatch(vlanMatch, false, (out) -> assertEquals(out.readUnsignedByte(), vlan)); + assertMatch(vlanMatch, false, (out) -> assertEquals(out.readUnsignedByte(), 1)); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanVidEntrySerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanVidEntrySerializerTest.java index e0f3e99e35..6e0ae5a8af 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanVidEntrySerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/VlanVidEntrySerializerTest.java @@ -17,22 +17,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; public class VlanVidEntrySerializerTest extends AbstractMatchEntrySerializerTest { @Test public void testSerialize() { - final int vlan = (short) 1; - final Match vlanMatch = new MatchBuilder() .setVlanMatch(new VlanMatchBuilder() .setVlanId(new VlanIdBuilder() - .setVlanId(new VlanId(vlan)) + .setVlanId(new VlanId(Uint16.ONE)) .setVlanIdPresent(true) .build()) .build()) .build(); - assertMatch(vlanMatch, false, (out) -> assertEquals(out.readShort(), vlan | (1 << 12))); + assertMatch(vlanMatch, false, (out) -> assertEquals(out.readShort(), 1 | 1 << 12)); final Match vlanMatchMaskOnly = new MatchBuilder() .setVlanMatch(new VlanMatchBuilder() @@ -43,7 +42,7 @@ public class VlanVidEntrySerializerTest extends AbstractMatchEntrySerializerTest .build(); assertMatch(vlanMatchMaskOnly, true, out -> { - assertEquals(out.readShort(), (1 << 12)); + assertEquals(out.readShort(), 1 << 12); byte[] mask = new byte[2]; out.readBytes(mask); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/AsyncConfigMessageSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/AsyncConfigMessageSerializerTest.java index 5b03b581d4..84b95c93ac 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/AsyncConfigMessageSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/AsyncConfigMessageSerializerTest.java @@ -28,12 +28,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; public class AsyncConfigMessageSerializerTest extends AbstractSerializerTest { private static final short LENGTH = 32; - private static final Long XID = 42L; - private static final short VERSION = EncodeConstants.OF13_VERSION_ID; + private static final Uint32 XID = Uint32.valueOf(42); + private static final Uint8 VERSION = EncodeConstants.OF_VERSION_1_3; // Packet in mask private static final Boolean MASTER_IS_NOMATCH = true; @@ -88,7 +90,7 @@ public class AsyncConfigMessageSerializerTest extends AbstractSerializerTest { serializer.serialize(MESSAGE, out); // Header - assertEquals(out.readByte(), VERSION); + assertEquals(out.readByte(), VERSION.byteValue()); assertEquals(out.readByte(), serializer.getMessageType()); assertEquals(out.readShort(), LENGTH); assertEquals(out.readInt(), XID.intValue()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializerTest.java index 32e128555b..dff09b2e8f 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.messages; import static org.junit.Assert.assertArrayEquals; @@ -13,7 +12,6 @@ import static org.junit.Assert.assertEquals; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import java.math.BigInteger; import java.util.Arrays; import java.util.Collections; import org.junit.Test; @@ -48,27 +46,31 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; public class FlowMessageSerializerTest extends AbstractSerializerTest { private static final byte PADDING_IN_FLOW_MOD_MESSAGE = 2; - private static final Long XID = 42L; - private static final Short VERSION = EncodeConstants.OF13_VERSION_ID; - private static final Short TABLE_ID = 2; + private static final Uint32 XID = Uint32.valueOf(42); + private static final Uint8 VERSION = EncodeConstants.OF_VERSION_1_3; + private static final Uint8 TABLE_ID = Uint8.TWO; private static final Boolean STRICT = true; - private static final Integer PRIORITY = 10; + private static final Uint16 PRIORITY = Uint16.TEN; private static final FlowModCommand COMMAND = FlowModCommand.OFPFCADD; private static final Boolean BARRIER = false; - private static final Long BUFFER_ID = 12L; + private static final Uint32 BUFFER_ID = Uint32.valueOf(12); private static final String CONTAINER_NAME = "openflow:1"; - private static final FlowCookie COOKIE = new FlowCookie(BigInteger.ONE); - private static final FlowCookie COOKIE_MASK = new FlowCookie(BigInteger.ZERO); + private static final FlowCookie COOKIE = new FlowCookie(Uint64.ONE); + private static final FlowCookie COOKIE_MASK = new FlowCookie(Uint64.ZERO); private static final String FLOW_NAME = "flowflow"; - private static final Integer HARD_TIMEOUT = 10; - private static final Integer IDLE_TIMEOUT = 5; + private static final Uint16 HARD_TIMEOUT = Uint16.TEN; + private static final Uint16 IDLE_TIMEOUT = Uint16.valueOf(5); private static final Boolean INSTALL_HW = true; - private static final Long OUT_GROUP = 1L; - private static final BigInteger OUT_PORT = BigInteger.TEN; + private static final Uint32 OUT_GROUP = Uint32.ONE; + private static final Uint64 OUT_PORT = Uint64.TEN; private static final Boolean IS_CHECKOVERLAP = true; @@ -83,11 +85,11 @@ public class FlowMessageSerializerTest extends AbstractSerializerTest { IS_RESETCOUNTS, IS_SENDFLOWREM); - private static final Integer VLAN_ID = 1; - private static final Short IP_PROTOCOL = (short) 6; // TCP + private static final Uint16 VLAN_ID = Uint16.ONE; + private static final Uint8 IP_PROTOCOL = Uint8.valueOf(6); // TCP - private static final Integer TP_SRC_PORT = 22; - private static final Integer TP_DST_PORT = 23; + private static final Uint16 TP_SRC_PORT = Uint16.valueOf(22); + private static final Uint16 TP_DST_PORT = Uint16.valueOf(23); private static final Instructions INSTRUCTIONS = new InstructionsBuilder() .setInstruction(Arrays.asList( new InstructionBuilder() @@ -145,7 +147,7 @@ public class FlowMessageSerializerTest extends AbstractSerializerTest { .build())) .build(); - private static final Short IP_PROTOCOL_MATCH = (short) 17; + private static final Uint8 IP_PROTOCOL_MATCH = Uint8.valueOf(17); private static final Match MATCH = new MatchBuilder() .setIpMatch(new IpMatchBuilder() .setIpProtocol(IP_PROTOCOL_MATCH) @@ -262,7 +264,7 @@ public class FlowMessageSerializerTest extends AbstractSerializerTest { assertEquals(out.readUnsignedShort(), OxmMatchConstants.OPENFLOW_BASIC_CLASS); assertEquals(out.readUnsignedByte(), OxmMatchConstants.VLAN_VID << 1); assertEquals(out.readUnsignedByte(), Short.BYTES); - assertEquals(out.readUnsignedShort(), VLAN_ID | (1 << 12)); + assertEquals(out.readUnsignedShort(), VLAN_ID.toJava() | 1 << 12); paddingRemainder = (out.readerIndex() - setVlanStartIndex) % EncodeConstants.PADDING; if (paddingRemainder != 0) { @@ -349,7 +351,7 @@ public class FlowMessageSerializerTest extends AbstractSerializerTest { assertEquals(out.readUnsignedShort(), OxmMatchConstants.OPENFLOW_BASIC_CLASS); assertEquals(out.readUnsignedByte(), OxmMatchConstants.VLAN_VID << 1 | 1); assertEquals(out.readUnsignedByte(), Short.BYTES * 2); - assertEquals(out.readUnsignedShort(), (1 << 12)); + assertEquals(out.readUnsignedShort(), 1 << 12); byte[] vlanMask = new byte[2]; out.readBytes(vlanMask); assertArrayEquals(vlanMask, new byte[] { 16, 0 }); @@ -379,7 +381,7 @@ public class FlowMessageSerializerTest extends AbstractSerializerTest { assertEquals(out.readUnsignedShort(), OxmMatchConstants.OPENFLOW_BASIC_CLASS); assertEquals(out.readUnsignedByte(), OxmMatchConstants.VLAN_VID << 1); assertEquals(out.readUnsignedByte(), Short.BYTES); - assertEquals(out.readUnsignedShort(), VLAN_ID | (1 << 12)); + assertEquals(out.readUnsignedShort(), VLAN_ID.toJava() | 1 << 12); paddingRemainder = (out.readerIndex() - setVlanStartIndex) % EncodeConstants.PADDING; if (paddingRemainder != 0) { diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/GroupMessageSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/GroupMessageSerializerTest.java index 743ed2fb7b..905caa5ded 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/GroupMessageSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/GroupMessageSerializerTest.java @@ -37,25 +37,28 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; public class GroupMessageSerializerTest extends AbstractSerializerTest { private static final byte PADDING_IN_GROUP_MOD_MESSAGE = 1; private static final byte PADDING_IN_BUCKET = 4; - private static final Long XID = 42L; - private static final Short VERSION = EncodeConstants.OF13_VERSION_ID; + private static final Uint32 XID = Uint32.valueOf(42); + private static final Uint8 VERSION = EncodeConstants.OF_VERSION_1_3; private static final Boolean BARRIER = false; private static final GroupModCommand COMMAND = GroupModCommand.OFPGCADD; private static final String CONTAINER_NAME = "openflow:1"; - private static final GroupId GROUP_ID = new GroupId(41L); + private static final GroupId GROUP_ID = new GroupId(Uint32.valueOf(41)); private static final String GROUP_NAME = "group41"; private static final GroupTypes GROUP_TYPE = GroupTypes.GroupAll; - private static final BucketId BUCKET_ID = new BucketId(40L); + private static final BucketId BUCKET_ID = new BucketId(Uint32.valueOf(40)); private static final BucketKey BUCKET_KEY = new BucketKey(BUCKET_ID); - private static final Long BUCKET_WATCH_GROUP = 12L; - private static final Long BUCKET_WATCH_PORT = 6L; - private static final Integer BUCKET_WEIGHT = 50; + private static final Uint32 BUCKET_WATCH_GROUP = Uint32.valueOf(12); + private static final Uint32 BUCKET_WATCH_PORT = Uint32.valueOf(6); + private static final Uint16 BUCKET_WEIGHT = Uint16.valueOf(50); private static final Integer ACTION_ORDER = 0; private static final ActionKey ACTION_KEY = new ActionKey(ACTION_ORDER); private static final Ipv4Prefix IPV4_PREFIX = new Ipv4Prefix("192.168.76.0/32"); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/MeterMessageSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/MeterMessageSerializerTest.java index 6786b2bae3..3e67e27657 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/MeterMessageSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/MeterMessageSerializerTest.java @@ -31,6 +31,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; public class MeterMessageSerializerTest extends AbstractSerializerTest { // Meter message constants @@ -38,10 +40,10 @@ public class MeterMessageSerializerTest extends AbstractSerializerTest { private static final short LENGTH_OF_METER_BANDS = 16; private static final short PADDING_IN_METER_BAND_DROP = 4; private static final short PADDING_IN_METER_BAND_DSCP_REMARK = 3; - private static final Long XID = 42L; + private static final Uint32 XID = Uint32.valueOf(42); private static final String CONTAINER_NAME = "container"; private static final String METER_NAME = "meter"; - private static final Long METER_ID = 1L; + private static final Uint32 METER_ID = Uint32.ONE; private static final Boolean BARRIER = false; private static final short VERSION = EncodeConstants.OF13_VERSION_ID; private static final MeterModCommand COMMAND = MeterModCommand.OFPMCADD; @@ -51,14 +53,14 @@ public class MeterMessageSerializerTest extends AbstractSerializerTest { private static final Boolean IS_METER_PKTPS = false; private static final Boolean IS_METER_STATS = true; // Bands - private static final Long BAND_BURST_SIZE = 50L; - private static final Long BAND_ID = 8L; - private static final Long BAND_RATE = 25L; - private static final Long DROP_RATE = 12L; - private static final Long DROP_BURST_SIZE = 24L; - private static final Long DSCP_RATE = 13L; - private static final Long DSCP_BURST_SIZE = 26L; - private static final short DSCP_PREC_LEVEL = (short) 4; + private static final Uint32 BAND_BURST_SIZE = Uint32.valueOf(50); + private static final Uint32 BAND_ID = Uint32.valueOf(8); + private static final Uint32 BAND_RATE = Uint32.valueOf(25); + private static final Uint32 DROP_RATE = Uint32.valueOf(12); + private static final Uint32 DROP_BURST_SIZE = Uint32.valueOf(24); + private static final Uint32 DSCP_RATE = Uint32.valueOf(13); + private static final Uint32 DSCP_BURST_SIZE = Uint32.valueOf(26); + private static final Uint8 DSCP_PREC_LEVEL = Uint8.valueOf(4); // Message private static final MeterMessage MESSAGE = new MeterMessageBuilder() @@ -68,7 +70,7 @@ public class MeterMessageSerializerTest extends AbstractSerializerTest { .setFlags(new MeterFlags(IS_METER_BURST, IS_METER_KBPS, IS_METER_PKTPS, IS_METER_STATS)) .setMeterId(new MeterId(METER_ID)) .setXid(XID) - .setVersion(VERSION) + .setVersion(EncodeConstants.OF_VERSION_1_3) .setMeterName(METER_NAME) .setMeterBandHeaders(new MeterBandHeadersBuilder() .setMeterBandHeader(Arrays.asList( @@ -91,7 +93,7 @@ public class MeterMessageSerializerTest extends AbstractSerializerTest { .meter.types.rev130918.MeterBandType(false, true, false)) .build()) .setBandBurstSize(BAND_BURST_SIZE) - .withKey(new MeterBandHeaderKey(new BandId(BAND_ID + 1))) + .withKey(new MeterBandHeaderKey(new BandId(Uint32.valueOf(9)))) .setBandRate(BAND_RATE) .setBandType(new DscpRemarkBuilder() .setDscpRemarkBurstSize(DSCP_BURST_SIZE) @@ -143,7 +145,7 @@ public class MeterMessageSerializerTest extends AbstractSerializerTest { assertEquals(out.readShort(), LENGTH_OF_METER_BANDS); assertEquals(out.readInt(), DSCP_RATE.intValue()); assertEquals(out.readInt(), DSCP_BURST_SIZE.intValue()); - assertEquals(out.readByte(), DSCP_PREC_LEVEL); + assertEquals(out.readByte(), DSCP_PREC_LEVEL.byteValue()); out.skipBytes(PADDING_IN_METER_BAND_DSCP_REMARK); assertEquals(out.readableBytes(), 0); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/PortMessageSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/PortMessageSerializerTest.java index 2af05a9912..d348a79990 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/PortMessageSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/PortMessageSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.messages; import static org.junit.Assert.assertEquals; @@ -27,6 +26,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.P import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValues; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; public class PortMessageSerializerTest extends AbstractSerializerTest { @@ -34,8 +35,8 @@ public class PortMessageSerializerTest extends AbstractSerializerTest { private static final byte PADDING_IN_PORT_MOD_MESSAGE_02 = 2; private static final byte PADDING_IN_PORT_MOD_MESSAGE_03 = 4; private static final short LENGTH = 40; - private static final Long XID = 42L; - private static final short VERSION = EncodeConstants.OF13_VERSION_ID; + private static final Uint32 XID = Uint32.valueOf(42); + private static final Uint8 VERSION = EncodeConstants.OF_VERSION_1_3; private static final String PORT_NUMBER = OutputPortValues.ALL.toString(); private static final Long PORT_NUMBER_VAL = BinContent.intToUnsignedLong(PortNumberValues.ALL.getIntValue()); private static final String MAC_ADDRESS = "E9:2A:55:BA:FA:4D"; @@ -104,7 +105,7 @@ public class PortMessageSerializerTest extends AbstractSerializerTest { serializer.serialize(MESSAGE, out); // Header - assertEquals(out.readByte(), VERSION); + assertEquals(out.readByte(), VERSION.byteValue()); assertEquals(out.readByte(), serializer.getMessageType()); assertEquals(out.readShort(), LENGTH); assertEquals(out.readInt(), XID.intValue()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowAggregateStatsSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowAggregateStatsSerializerTest.java index eb10ecdf2f..1af8d6bf5c 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowAggregateStatsSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowAggregateStatsSerializerTest.java @@ -5,14 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart; import static org.junit.Assert.assertEquals; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import java.math.BigInteger; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; @@ -25,16 +23,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multip import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowAggregateStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.multipart.request.flow.aggregate.stats.FlowAggregateStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; public class MultipartRequestFlowAggregateStatsSerializerTest extends AbstractSerializerTest { private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01 = 3; private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02 = 4; - private static final short TABLE_ID = 42; - private static final BigInteger OUT_PORT = BigInteger.ONE; - private static final long OUT_GROUP = 10; - private static final FlowCookie COOKIE = new FlowCookie(BigInteger.valueOf(8)); - private static final FlowCookie COOKIE_MASK = new FlowCookie(BigInteger.TEN); - private static final Short IP_PROTOCOL_MATCH = (short) 17; + private static final Uint8 TABLE_ID = Uint8.valueOf(42); + private static final Uint64 OUT_PORT = Uint64.ONE; + private static final Uint32 OUT_GROUP = Uint32.TEN; + private static final FlowCookie COOKIE = new FlowCookie(Uint64.valueOf(8)); + private static final FlowCookie COOKIE_MASK = new FlowCookie(Uint64.TEN); + private static final Uint8 IP_PROTOCOL_MATCH = Uint8.valueOf(17); private static final Match MATCH = new MatchBuilder() .setIpMatch(new IpMatchBuilder() .setIpProtocol(IP_PROTOCOL_MATCH) @@ -63,10 +64,10 @@ public class MultipartRequestFlowAggregateStatsSerializerTest extends AbstractSe final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(BODY, out); - assertEquals(out.readUnsignedByte(), TABLE_ID); + assertEquals(out.readUnsignedByte(), TABLE_ID.shortValue()); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01); assertEquals(out.readUnsignedInt(), OUT_PORT.longValue()); - assertEquals(out.readUnsignedInt(), OUT_GROUP); + assertEquals(out.readUnsignedInt(), OUT_GROUP.longValue()); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02); assertEquals(out.readLong(), COOKIE.getValue().longValue()); assertEquals(out.readLong(), COOKIE_MASK.getValue().longValue()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowStatsSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowStatsSerializerTest.java index 439cc09c4c..31faa9571e 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowStatsSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowStatsSerializerTest.java @@ -12,7 +12,6 @@ import static org.junit.Assert.assertEquals; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import java.math.BigInteger; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; @@ -25,16 +24,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multip import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.multipart.request.flow.stats.FlowStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; public class MultipartRequestFlowStatsSerializerTest extends AbstractSerializerTest { private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01 = 3; private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02 = 4; - private static final short TABLE_ID = 42; - private static final BigInteger OUT_PORT = BigInteger.ONE; - private static final long OUT_GROUP = 10; - private static final FlowCookie COOKIE = new FlowCookie(BigInteger.valueOf(8)); - private static final FlowCookie COOKIE_MASK = new FlowCookie(BigInteger.TEN); - private static final Short IP_PROTOCOL_MATCH = (short) 17; + private static final Uint8 TABLE_ID = Uint8.valueOf(42); + private static final Uint64 OUT_PORT = Uint64.ONE; + private static final Uint32 OUT_GROUP = Uint32.TEN; + private static final FlowCookie COOKIE = new FlowCookie(Uint64.valueOf(8)); + private static final FlowCookie COOKIE_MASK = new FlowCookie(Uint64.TEN); + private static final Uint8 IP_PROTOCOL_MATCH = Uint8.valueOf(17); private static final Match MATCH = new MatchBuilder() .setIpMatch(new IpMatchBuilder() .setIpProtocol(IP_PROTOCOL_MATCH) @@ -63,10 +65,10 @@ public class MultipartRequestFlowStatsSerializerTest extends AbstractSerializerT final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(BODY, out); - assertEquals(out.readUnsignedByte(), TABLE_ID); + assertEquals(out.readUnsignedByte(), TABLE_ID.shortValue()); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01); assertEquals(out.readUnsignedInt(), OUT_PORT.longValue()); - assertEquals(out.readUnsignedInt(), OUT_GROUP); + assertEquals(out.readUnsignedInt(), OUT_GROUP.longValue()); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02); assertEquals(out.readLong(), COOKIE.getValue().longValue()); assertEquals(out.readLong(), COOKIE_MASK.getValue().longValue()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupStatsSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupStatsSerializerTest.java index 8095de642f..f0159fac94 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupStatsSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestGroupStatsSerializerTest.java @@ -19,12 +19,12 @@ import org.opendaylight.openflowplugin.impl.protocol.serialization.AbstractSeria import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId; +import org.opendaylight.yangtools.yang.common.Uint32; public class MultipartRequestGroupStatsSerializerTest extends AbstractSerializerTest { private static final byte PADDING_IN_MULTIPART_REQUEST_GROUP_BODY = 4; - private static final long GROUP_ID = 42; private static final MultipartRequestGroupStats BODY = new MultipartRequestGroupStatsBuilder() - .setGroupId(new GroupId(GROUP_ID)) + .setGroupId(new GroupId(Uint32.valueOf(42))) .build(); private MultipartRequestGroupStatsSerializer serializer; @@ -40,7 +40,7 @@ public class MultipartRequestGroupStatsSerializerTest extends AbstractSerializer final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(BODY, out); - assertEquals(out.readUnsignedInt(), GROUP_ID); + assertEquals(out.readUnsignedInt(), 42); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_GROUP_BODY); assertEquals(out.readableBytes(), 0); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMessageSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMessageSerializerTest.java index 9b996e781d..a2e48f4658 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMessageSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMessageSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart; import static org.junit.Assert.assertEquals; @@ -23,17 +22,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.M import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequestBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.request.multipart.request.body.MultipartRequestQueueStatsBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; public class MultipartRequestMessageSerializerTest extends AbstractSerializerTest { // Multipart request message constants private static final byte PADDING_IN_MULTIPART_REQUEST_MESSAGE = 4; private static final short LENGTH = 24; - private static final Long XID = 42L; - private static final short VERSION = EncodeConstants.OF13_VERSION_ID; + private static final Uint32 XID = Uint32.valueOf(42); + private static final Uint8 VERSION = EncodeConstants.OF_VERSION_1_3; private static final boolean IS_REQUEST_MORE = false; private static final MultipartType MULTIPART_TYPE = MultipartType.OFPMPQUEUE; private static final int MESSAGE_TYPE = 18; - private static final long QUEUE_ID = 44; + private static final Uint32 QUEUE_ID = Uint32.valueOf(44); private static final long PORT = 12; // Message @@ -62,7 +63,7 @@ public class MultipartRequestMessageSerializerTest extends AbstractSerializerTes serializer.serialize(MESSAGE, out); // Header - assertEquals(out.readByte(), VERSION); + assertEquals(out.readByte(), VERSION.byteValue()); assertEquals(out.readByte(), MESSAGE_TYPE); assertEquals(out.readUnsignedShort(), LENGTH); assertEquals(out.readInt(), XID.intValue()); @@ -72,7 +73,7 @@ public class MultipartRequestMessageSerializerTest extends AbstractSerializerTes // Body assertEquals(out.readUnsignedInt(), PORT); - assertEquals(out.readUnsignedInt(), QUEUE_ID); + assertEquals(out.readUnsignedInt(), QUEUE_ID.longValue()); assertEquals(out.readableBytes(), 0); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterConfigSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterConfigSerializerTest.java index 4286199b06..04c5fbd464 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterConfigSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterConfigSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart; import static org.junit.Assert.assertEquals; @@ -19,12 +18,12 @@ import org.opendaylight.openflowplugin.impl.protocol.serialization.AbstractSeria import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterConfigBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId; +import org.opendaylight.yangtools.yang.common.Uint32; public class MultipartRequestMeterConfigSerializerTest extends AbstractSerializerTest { private static final byte PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY = 4; - private static final long METER_ID = 42; private static final MultipartRequestMeterConfig BODY = new MultipartRequestMeterConfigBuilder() - .setMeterId(new MeterId(METER_ID)) + .setMeterId(new MeterId(Uint32.valueOf(42))) .build(); private MultipartRequestMeterConfigSerializer serializer; @@ -40,7 +39,7 @@ public class MultipartRequestMeterConfigSerializerTest extends AbstractSerialize final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(BODY, out); - assertEquals(out.readUnsignedInt(), METER_ID); + assertEquals(out.readUnsignedInt(), 42); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY); assertEquals(out.readableBytes(), 0); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterStatsSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterStatsSerializerTest.java index 18f6ad529d..64cb77766c 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterStatsSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterStatsSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart; import static org.junit.Assert.assertEquals; @@ -19,10 +18,11 @@ import org.opendaylight.openflowplugin.impl.protocol.serialization.AbstractSeria import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId; +import org.opendaylight.yangtools.yang.common.Uint32; public class MultipartRequestMeterStatsSerializerTest extends AbstractSerializerTest { private static final byte PADDING_IN_MULTIPART_REQUEST_METER_BODY = 4; - private static final long METER_ID = 42; + private static final Uint32 METER_ID = Uint32.valueOf(42); private static final MultipartRequestMeterStats BODY = new MultipartRequestMeterStatsBuilder() .setStatMeterId(new MeterId(METER_ID)) .build(); @@ -40,7 +40,7 @@ public class MultipartRequestMeterStatsSerializerTest extends AbstractSerializer final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(BODY, out); - assertEquals(out.readUnsignedInt(), METER_ID); + assertEquals(out.readUnsignedInt(), METER_ID.longValue()); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_METER_BODY); assertEquals(out.readableBytes(), 0); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestQueueStatsSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestQueueStatsSerializerTest.java index 160dff6994..89315cbfe9 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestQueueStatsSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestQueueStatsSerializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart; import static org.junit.Assert.assertEquals; @@ -20,10 +19,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925. import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.request.multipart.request.body.MultipartRequestQueueStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.request.multipart.request.body.MultipartRequestQueueStatsBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; public class MultipartRequestQueueStatsSerializerTest extends AbstractSerializerTest { private static final long PORT = 42; - private static final long QUEUE_ID = 43; + private static final Uint32 QUEUE_ID = Uint32.valueOf(43); private static final MultipartRequestQueueStats BODY = new MultipartRequestQueueStatsBuilder() .setNodeConnectorId(new NodeConnectorId("openflow:1:" + PORT)) .setQueueId(new QueueId(QUEUE_ID)) @@ -43,7 +43,7 @@ public class MultipartRequestQueueStatsSerializerTest extends AbstractSerializer serializer.serialize(BODY, out); assertEquals(out.readUnsignedInt(), PORT); - assertEquals(out.readUnsignedInt(), QUEUE_ID); + assertEquals(out.readUnsignedInt(), QUEUE_ID.longValue()); assertEquals(out.readableBytes(), 0); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializerTest.java index 22449955f7..18f74d409d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializerTest.java @@ -5,14 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart; import static org.junit.Assert.assertEquals; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import java.math.BigInteger; import java.util.Collections; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; @@ -30,16 +28,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; import org.opendaylight.yangtools.yang.common.Uint8; public class MultipartRequestTableFeaturesSerializerTest extends AbstractSerializerTest { private static final byte PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY = 5; private static final byte MAX_TABLE_NAME_LENGTH = 32; - private static final short TABLE_ID = 42; + private static final Uint8 TABLE_ID = Uint8.valueOf(42); private static final String NAME = "table_prop"; - private static final BigInteger METADATA_MATCH = BigInteger.ONE; - private static final BigInteger METADATA_WRITE = BigInteger.TEN; - private static final long MAX_ENTRIES = 12; + private static final Uint64 METADATA_MATCH = Uint64.ONE; + private static final Uint64 METADATA_WRITE = Uint64.TEN; + private static final Uint32 MAX_ENTRIES = Uint32.valueOf(12); private static final boolean IS_DEPRECATED_MASK = true; private static final Uint8 NEXT_TABLE_ID = Uint8.valueOf(43); @@ -81,17 +81,13 @@ public class MultipartRequestTableFeaturesSerializerTest extends AbstractSeriali serializer.serialize(BODY, out); out.skipBytes(Short.BYTES); // skip length - assertEquals(TABLE_ID, out.readUnsignedByte()); + assertEquals(TABLE_ID.shortValue(), out.readUnsignedByte()); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY); assertEquals(NAME, ByteBufUtils.decodeNullTerminatedString(out, MAX_TABLE_NAME_LENGTH)); - final byte[] match = new byte[Long.BYTES]; - out.readBytes(match); - assertEquals(METADATA_MATCH, new BigInteger(1, match)); - final byte[] write = new byte[Long.BYTES]; - out.readBytes(write); - assertEquals(METADATA_WRITE, new BigInteger(1, write)); + assertEquals(METADATA_MATCH.longValue(), out.readLong()); + assertEquals(METADATA_WRITE.longValue(), out.readLong()); assertEquals(IS_DEPRECATED_MASK, (out.readUnsignedInt() & 3) != 0); - assertEquals(MAX_ENTRIES, out.readUnsignedInt()); + assertEquals(MAX_ENTRIES.longValue(), out.readUnsignedInt()); assertEquals(NEXT_TABLE_TYPE.getIntValue(), out.readUnsignedShort()); final int propLength = out.readUnsignedShort(); final int paddingRemainder = propLength % EncodeConstants.PADDING; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java index 01751cf99a..f3e463e9f4 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java @@ -16,7 +16,6 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.math.BigInteger; import java.util.Collections; import java.util.Map; import java.util.Optional; @@ -52,6 +51,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint64; import org.opendaylight.yangtools.yang.common.Uint8; /** @@ -93,9 +94,9 @@ public class DeviceFlowRegistryImplTest { final InstanceIdentifier path = nodeInstanceIdentifier.augmentation(FlowCapableNode.class); final Flow flow = new FlowBuilder() - .setTableId((short)1) - .setPriority(10) - .setCookie(new FlowCookie(BigInteger.TEN)) + .setTableId(Uint8.ONE) + .setPriority(Uint16.TEN) + .setCookie(new FlowCookie(Uint64.TEN)) .setId(new FlowId("HELLO")) .build(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java index 2651f75f84..badc8717b0 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java @@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.impl.registry.flow; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; -import java.math.BigInteger; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -37,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCo import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder; import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint64; import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -93,7 +93,7 @@ public class FlowRegistryKeyFactoryTest { // different priority flowStatisticsMapListBld2 = new FlowAndStatisticsMapListBuilder(flowStatisticsMapList1); - flowStatisticsMapListBld2.setPriority(flowStatisticsMapListBld2.getPriority().toJava() + 1); + flowStatisticsMapListBld2.setPriority(Uint16.valueOf(flowStatisticsMapListBld2.getPriority().toJava() + 1)); key2 = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), flowStatisticsMapListBld2.build()); Assert.assertFalse(key1.equals(key2)); @@ -105,7 +105,7 @@ public class FlowRegistryKeyFactoryTest { // different tableId flowStatisticsMapListBld2 = new FlowAndStatisticsMapListBuilder(flowStatisticsMapList1); - flowStatisticsMapListBld2.setTableId((short) (flowStatisticsMapListBld2.getTableId().toJava() + 1)); + flowStatisticsMapListBld2.setTableId(Uint8.valueOf(flowStatisticsMapListBld2.getTableId().toJava() + 1)); key2 = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), flowStatisticsMapListBld2.build()); Assert.assertFalse(key1.equals(key2)); @@ -117,10 +117,10 @@ public class FlowRegistryKeyFactoryTest { MatchBuilder match1Builder = new MatchBuilder().setLayer3Match(new Ipv4MatchBuilder() .setIpv4Destination(new Ipv4Prefix("10.0.1.157/32")).build()); FlowBuilder flow1Builder = new FlowBuilder() - .setCookie(new FlowCookie(BigInteger.valueOf(483))) + .setCookie(new FlowCookie(Uint64.valueOf(483))) .setMatch(match1Builder.build()) - .setPriority(2) - .setTableId((short) 0); + .setPriority(Uint16.TWO) + .setTableId(Uint8.ZERO); FlowRegistryKey flow1Hash = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), flow1Builder.build()); LOG.info("flowHash1: {}", flow1Hash.hashCode()); @@ -129,7 +129,7 @@ public class FlowRegistryKeyFactoryTest { MatchBuilder match2Builder = new MatchBuilder().setLayer3Match(new Ipv4MatchBuilder() .setIpv4Destination(new Ipv4Prefix("10.0.0.242/32")).build()); FlowBuilder flow2Builder = new FlowBuilder(flow1Builder.build()) - .setCookie(new FlowCookie(BigInteger.valueOf(148))) + .setCookie(new FlowCookie(Uint64.valueOf(148))) .setMatch(match2Builder.build()); FlowRegistryKey flow2Hash = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), flow2Builder.build()); @@ -143,10 +143,10 @@ public class FlowRegistryKeyFactoryTest { MatchBuilder match1Builder = new MatchBuilder().setLayer3Match(new Ipv4MatchBuilder() .setIpv4Destination(new Ipv4Prefix("10.0.1.157/32")).build()); FlowBuilder flow1Builder = new FlowBuilder() - .setCookie(new FlowCookie(BigInteger.valueOf(483))) + .setCookie(new FlowCookie(Uint64.valueOf(483))) .setMatch(match1Builder.build()) - .setPriority(2) - .setTableId((short) 0); + .setPriority(Uint16.TWO) + .setTableId(Uint8.ZERO); FlowBuilder fb1 = new FlowBuilder(flow1Builder.build()); fb1.setTableId((Uint8) null); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/TestFlowHelper.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/TestFlowHelper.java index 09ff0ce300..9512cbd470 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/TestFlowHelper.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/TestFlowHelper.java @@ -5,10 +5,8 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.registry.flow; -import java.math.BigInteger; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder; @@ -17,6 +15,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Flow building helper. @@ -33,9 +34,9 @@ public final class TestFlowHelper { */ protected static FlowAndStatisticsMapListBuilder createFlowAndStatisticsMapListBuilder(int index) { FlowAndStatisticsMapListBuilder flowAndStatisticsMapListBuilder = new FlowAndStatisticsMapListBuilder(); - flowAndStatisticsMapListBuilder.setPriority(index); - flowAndStatisticsMapListBuilder.setTableId((short) index); - flowAndStatisticsMapListBuilder.setCookie(new FlowCookie(BigInteger.TEN)); + flowAndStatisticsMapListBuilder.setPriority(Uint16.valueOf(index)); + flowAndStatisticsMapListBuilder.setTableId(Uint8.valueOf(index)); + flowAndStatisticsMapListBuilder.setCookie(new FlowCookie(Uint64.TEN)); EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/group/DeviceGroupRegistryImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/group/DeviceGroupRegistryImplTest.java index d65db0647e..1d4f08e30f 100755 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/group/DeviceGroupRegistryImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/group/DeviceGroupRegistryImplTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.registry.group; import java.util.concurrent.atomic.AtomicInteger; @@ -13,6 +12,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link DeviceGroupRegistryImpl}. @@ -26,8 +26,8 @@ public class DeviceGroupRegistryImplTest { @Before public void setUp() { deviceGroupRegistry = new DeviceGroupRegistryImpl(); - groupId = new GroupId(42L); - groupId2 = new GroupId(84L); + groupId = new GroupId(Uint32.valueOf(42)); + groupId2 = new GroupId(Uint32.valueOf(84)); Assert.assertEquals(0, deviceGroupRegistry.getAllGroupIds().size()); deviceGroupRegistry.store(groupId); Assert.assertEquals(1, deviceGroupRegistry.getAllGroupIds().size()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/meter/DeviceMeterRegistryImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/meter/DeviceMeterRegistryImplTest.java index 477001c461..382674161b 100755 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/meter/DeviceMeterRegistryImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/meter/DeviceMeterRegistryImplTest.java @@ -13,6 +13,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link DeviceMeterRegistryImpl}. @@ -26,8 +27,8 @@ public class DeviceMeterRegistryImplTest { @Before public void setUp() { deviceMeterRegistry = new DeviceMeterRegistryImpl(); - meterId = new MeterId(42L); - meterId2 = new MeterId(84L); + meterId = new MeterId(Uint32.valueOf(42)); + meterId2 = new MeterId(Uint32.valueOf(84)); Assert.assertEquals(0, deviceMeterRegistry.getAllMeterIds().size()); deviceMeterRegistry.store(meterId); Assert.assertEquals(1, deviceMeterRegistry.getAllMeterIds().size()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImplTest.java index 1119f97f5f..a58bdeba21 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImplTest.java @@ -20,7 +20,7 @@ import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.binding.api.RpcProviderService; -import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowplugin.api.openflow.FlowGroupCacheManager; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; @@ -40,11 +40,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; +import org.opendaylight.yangtools.yang.common.Uint16; @RunWith(MockitoJUnitRunner.class) public class RpcManagerImplTest { - private static final int QUOTA_VALUE = 5; + private static final Uint16 QUOTA_VALUE = Uint16.valueOf(5); private RpcManagerImpl rpcManager; @Mock @@ -89,7 +90,7 @@ public class RpcManagerImplTest { flowGroupCacheManager); FeaturesReply features = new GetFeaturesOutputBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3) + .setVersion(EncodeConstants.OF_VERSION_1_3) .build(); Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java index 5066dcbf08..a2c069a7bf 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java @@ -17,7 +17,6 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.math.BigInteger; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -69,8 +68,10 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(MockitoJUnitRunner.class) public class MultipartRequestOnTheFlyCallbackTest { @@ -107,7 +108,7 @@ public class MultipartRequestOnTheFlyCallbackTest { private AbstractRequestContext> dummyRequestContext; private final EventIdentifier dummyEventIdentifier = new EventIdentifier(DUMMY_EVENT_NAME, DUMMY_DEVICE_ID); private AbstractMultipartRequestOnTheFlyCallback multipartRequestOnTheFlyCallback; - private final short tableId = 0; + private final Uint8 tableId = Uint8.ZERO; @Before public void initialization() { @@ -129,7 +130,7 @@ public class MultipartRequestOnTheFlyCallbackTest { final InstanceIdentifier nodePath = mockedDeviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class); final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder(); - flowNodeBuilder.setTable(Collections.emptyList()); + flowNodeBuilder.setTable(Collections.emptyMap()); final Optional flowNodeOpt = Optional.of(flowNodeBuilder.build()); dummyRequestContext = new AbstractRequestContext<>(DUMMY_XID) { @@ -196,12 +197,12 @@ public class MultipartRequestOnTheFlyCallbackTest { .setMatchEntry(Collections.emptyList()); final FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder() .setTableId(tableId) - .setPriority(2) - .setCookie(BigInteger.ZERO) - .setByteCount(BigInteger.TEN) - .setPacketCount(BigInteger.ONE) - .setDurationSec(11L) - .setDurationNsec(12L) + .setPriority(Uint16.TWO) + .setCookie(Uint64.ZERO) + .setByteCount(Uint64.TEN) + .setPacketCount(Uint64.ONE) + .setDurationSec(Uint32.valueOf(11)) + .setDurationNsec(Uint32.valueOf(12)) .setMatch(matchBuilder.build()) .setFlags(new FlowModFlags(true, false, false, false, false)); final MultipartReplyFlowBuilder multipartReplyFlowBuilder = new MultipartReplyFlowBuilder() @@ -212,7 +213,7 @@ public class MultipartRequestOnTheFlyCallbackTest { .setType(MultipartType.OFPMPFLOW) .setFlags(new MultipartRequestFlags(true)) .setMultipartReplyBody(multipartReplyFlowCaseBuilder.build()) - .setXid(21L); + .setXid(Uint32.valueOf(21)); final InstanceIdentifier nodePath = mockedDeviceInfo.getNodeInstanceIdentifier() .augmentation(FlowCapableNode.class); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java index 2ebef15ced..e37b4b9681 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java @@ -58,7 +58,7 @@ public abstract class ServiceMocking { protected static final Uint8 DUMMY_VERSION = Uint8.valueOf(OFConstants.OFP_VERSION_1_3); protected static final Uint32 DUMMY_XID_VALUE = Uint32.valueOf(2121L); protected static final Xid DUMMY_XID = new Xid(DUMMY_XID_VALUE); - protected static final long DUMMY_EXPERIMENTER_ID = 42L; + protected static final Uint32 DUMMY_EXPERIMENTER_ID = Uint32.valueOf(42); protected static final String DUMMY_NODE_ID = "444"; protected static final KeyedInstanceIdentifier DUMMY_NODE_II = InstanceIdentifier diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdaptersTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdaptersTest.java index f22546aa4c..20fae3697c 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdaptersTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdaptersTest.java @@ -42,6 +42,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; /** * Test for {@link FlatBatchFlowAdapters}. @@ -130,8 +131,8 @@ public class FlatBatchFlowAdaptersTest { .withError(RpcError.ErrorType.APPLICATION, "ut-flowError") .withResult(new AddFlowsBatchOutputBuilder() .setBatchFailedFlowsOutput(Lists.newArrayList( - createBatchFailedFlowsOutput(0, "f1"), - createBatchFailedFlowsOutput(1, "f2") + createBatchFailedFlowsOutput(Uint16.ZERO, "f1"), + createBatchFailedFlowsOutput(Uint16.ONE, "f2") )) .build()) .build(); @@ -166,7 +167,7 @@ public class FlatBatchFlowAdaptersTest { Assert.assertEquals(0, rpcResult.getResult().nonnullBatchFailure().size()); } - private static BatchFailedFlowsOutput createBatchFailedFlowsOutput(final Integer batchOrder, + private static BatchFailedFlowsOutput createBatchFailedFlowsOutput(final Uint16 batchOrder, final String flowIdValue) { return new BatchFailedFlowsOutputBuilder() .setFlowId(new FlowId(flowIdValue)) @@ -174,7 +175,7 @@ public class FlatBatchFlowAdaptersTest { .build(); } - private static BatchFailure createChainFailure(final int batchOrder, final String flowIdValue) { + private static BatchFailure createChainFailure(final Uint16 batchOrder, final String flowIdValue) { return new BatchFailureBuilder() .setBatchOrder(batchOrder) .setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder() diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdaptersTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdaptersTest.java index 35a8d62720..effc4c0b89 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdaptersTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdaptersTest.java @@ -43,6 +43,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link FlatBatchGroupAdapters}. @@ -59,8 +61,8 @@ public class FlatBatchGroupAdaptersTest { final BatchPlanStep planStep = new BatchPlanStep(BatchStepType.FLOW_ADD); planStep.setBarrierAfter(true); planStep.getTaskBag().addAll(Lists.newArrayList( - createAddGroupBatch(1L), - createAddGroupBatch(2L))); + createAddGroupBatch(Uint32.ONE), + createAddGroupBatch(Uint32.TWO))); final AddGroupsBatchInput addGroupsBatchInput = FlatBatchGroupAdapters.adaptFlatBatchAddGroup(planStep, NODE_REF); @@ -72,19 +74,19 @@ public class FlatBatchGroupAdaptersTest { Assert.assertEquals(2L, iterator.next().getGroupId().getValue().longValue()); } - private static FlatBatchAddGroup createAddGroupBatch(final long groupIdValue) { + private static FlatBatchAddGroup createAddGroupBatch(final Uint32 groupIdValue) { return new FlatBatchAddGroupBuilder() .setGroupId(new GroupId(groupIdValue)) .build(); } - private static FlatBatchRemoveGroup createRemoveGroupBatch(final long groupIdValue) { + private static FlatBatchRemoveGroup createRemoveGroupBatch(final Uint32 groupIdValue) { return new FlatBatchRemoveGroupBuilder() .setGroupId(new GroupId(groupIdValue)) .build(); } - private static FlatBatchUpdateGroup createUpdateGroupBatch(final long groupIdValue) { + private static FlatBatchUpdateGroup createUpdateGroupBatch(final Uint32 groupIdValue) { return new FlatBatchUpdateGroupBuilder() .setOriginalBatchedGroup(new OriginalBatchedGroupBuilder() .setGroupId(new GroupId(groupIdValue)) @@ -100,8 +102,8 @@ public class FlatBatchGroupAdaptersTest { final BatchPlanStep planStep = new BatchPlanStep(BatchStepType.FLOW_REMOVE); planStep.setBarrierAfter(true); planStep.getTaskBag().addAll(Lists.newArrayList( - createRemoveGroupBatch(1L), - createRemoveGroupBatch(2L))); + createRemoveGroupBatch(Uint32.ONE), + createRemoveGroupBatch(Uint32.TWO))); final RemoveGroupsBatchInput removeGroupsBatchInput = FlatBatchGroupAdapters.adaptFlatBatchRemoveGroup(planStep, NODE_REF); @@ -118,8 +120,8 @@ public class FlatBatchGroupAdaptersTest { final BatchPlanStep planStep = new BatchPlanStep(BatchStepType.FLOW_UPDATE); planStep.setBarrierAfter(true); planStep.getTaskBag().addAll(Lists.newArrayList( - createUpdateGroupBatch(1L), - createUpdateGroupBatch(2L))); + createUpdateGroupBatch(Uint32.ONE), + createUpdateGroupBatch(Uint32.TWO))); final UpdateGroupsBatchInput updateGroupsBatchInput = FlatBatchGroupAdapters.adaptFlatBatchUpdateGroup(planStep, NODE_REF); @@ -138,8 +140,8 @@ public class FlatBatchGroupAdaptersTest { .withError(RpcError.ErrorType.APPLICATION, "ut-groupError") .withResult(new AddGroupsBatchOutputBuilder() .setBatchFailedGroupsOutput(Lists.newArrayList( - createBatchFailedGroupsOutput(0, 1L), - createBatchFailedGroupsOutput(1, 2L) + createBatchFailedGroupsOutput(Uint16.ZERO, Uint32.ONE), + createBatchFailedGroupsOutput(Uint16.ONE, Uint32.TWO) )) .build()) .build(); @@ -172,15 +174,15 @@ public class FlatBatchGroupAdaptersTest { Assert.assertEquals(0, rpcResult.getResult().nonnullBatchFailure().size()); } - private static BatchFailedGroupsOutput createBatchFailedGroupsOutput(final Integer batchOrder, - final long groupIdValue) { + private static BatchFailedGroupsOutput createBatchFailedGroupsOutput(final Uint16 batchOrder, + final Uint32 groupIdValue) { return new BatchFailedGroupsOutputBuilder() .setGroupId(new GroupId(groupIdValue)) .setBatchOrder(batchOrder) .build(); } - private static BatchFailure createChainFailure(final int batchOrder, final long groupIdValue) { + private static BatchFailure createChainFailure(final Uint16 batchOrder, final Uint32 groupIdValue) { return new BatchFailureBuilder() .setBatchOrder(batchOrder) .setBatchItemIdChoice(new FlatBatchFailureGroupIdCaseBuilder() diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdaptersTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdaptersTest.java index a7b34ee650..93a7e9d417 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdaptersTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdaptersTest.java @@ -43,6 +43,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link FlatBatchMeterAdapters}. @@ -59,8 +61,8 @@ public class FlatBatchMeterAdaptersTest { final BatchPlanStep planStep = new BatchPlanStep(BatchStepType.FLOW_ADD); planStep.setBarrierAfter(true); planStep.getTaskBag().addAll(Lists.newArrayList( - createAddMeterBatch(1L), - createAddMeterBatch(2L))); + createAddMeterBatch(Uint32.ONE), + createAddMeterBatch(Uint32.TWO))); final AddMetersBatchInput addMetersBatchInput = FlatBatchMeterAdapters.adaptFlatBatchAddMeter(planStep, NODE_REF); @@ -73,19 +75,19 @@ public class FlatBatchMeterAdaptersTest { Assert.assertEquals(2L, it.next().getMeterId().getValue().longValue()); } - private static FlatBatchAddMeter createAddMeterBatch(final long groupIdValue) { + private static FlatBatchAddMeter createAddMeterBatch(final Uint32 groupIdValue) { return new FlatBatchAddMeterBuilder() .setMeterId(new MeterId(groupIdValue)) .build(); } - private static FlatBatchRemoveMeter createRemoveMeterBatch(final long groupIdValue) { + private static FlatBatchRemoveMeter createRemoveMeterBatch(final Uint32 groupIdValue) { return new FlatBatchRemoveMeterBuilder() .setMeterId(new MeterId(groupIdValue)) .build(); } - private static FlatBatchUpdateMeter createUpdateMeterBatch(final long groupIdValue) { + private static FlatBatchUpdateMeter createUpdateMeterBatch(final Uint32 groupIdValue) { return new FlatBatchUpdateMeterBuilder() .setOriginalBatchedMeter(new OriginalBatchedMeterBuilder() .setMeterId(new MeterId(groupIdValue)) @@ -101,8 +103,8 @@ public class FlatBatchMeterAdaptersTest { final BatchPlanStep planStep = new BatchPlanStep(BatchStepType.FLOW_REMOVE); planStep.setBarrierAfter(true); planStep.getTaskBag().addAll(Lists.newArrayList( - createRemoveMeterBatch(1L), - createRemoveMeterBatch(2L))); + createRemoveMeterBatch(Uint32.ONE), + createRemoveMeterBatch(Uint32.TWO))); final RemoveMetersBatchInput removeMetersBatchInput = FlatBatchMeterAdapters.adaptFlatBatchRemoveMeter(planStep, NODE_REF); @@ -119,8 +121,8 @@ public class FlatBatchMeterAdaptersTest { final BatchPlanStep planStep = new BatchPlanStep(BatchStepType.FLOW_UPDATE); planStep.setBarrierAfter(true); planStep.getTaskBag().addAll(Lists.newArrayList( - createUpdateMeterBatch(1L), - createUpdateMeterBatch(2L))); + createUpdateMeterBatch(Uint32.ONE), + createUpdateMeterBatch(Uint32.TWO))); final UpdateMetersBatchInput updateMetersBatchInput = FlatBatchMeterAdapters.adaptFlatBatchUpdateMeter(planStep, NODE_REF); @@ -139,8 +141,8 @@ public class FlatBatchMeterAdaptersTest { .withError(RpcError.ErrorType.APPLICATION, "ut-meterError") .withResult(new AddMetersBatchOutputBuilder() .setBatchFailedMetersOutput(Lists.newArrayList( - createBatchFailedMetersOutput(0, 1L), - createBatchFailedMetersOutput(1, 2L) + createBatchFailedMetersOutput(Uint16.ZERO, Uint32.ONE), + createBatchFailedMetersOutput(Uint16.ONE, Uint32.TWO) )) .build()) .build(); @@ -173,15 +175,15 @@ public class FlatBatchMeterAdaptersTest { Assert.assertEquals(0, rpcResult.getResult().nonnullBatchFailure().size()); } - private static BatchFailedMetersOutput createBatchFailedMetersOutput(final Integer batchOrder, - final long groupIdValue) { + private static BatchFailedMetersOutput createBatchFailedMetersOutput(final Uint16 batchOrder, + final Uint32 groupIdValue) { return new BatchFailedMetersOutputBuilder() .setMeterId(new MeterId(groupIdValue)) .setBatchOrder(batchOrder) .build(); } - private static BatchFailure createChainFailure(final int batchOrder, final long groupIdValue) { + private static BatchFailure createChainFailure(final Uint16 batchOrder, final Uint32 groupIdValue) { return new BatchFailureBuilder() .setBatchOrder(batchOrder) .setBatchItemIdChoice(new FlatBatchFailureMeterIdCaseBuilder() diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalBundleServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalBundleServiceImplTest.java index 3d6e5081c4..1f944d7afd 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalBundleServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalBundleServiceImplTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.services.sal; import static org.mockito.ArgumentMatchers.any; @@ -51,13 +50,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.on import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; @RunWith(MockitoJUnitRunner.class) public class SalBundleServiceImplTest { private static final NodeRef NODE_REF = new NodeRef(InstanceIdentifier.create(Nodes.class) .child(Node.class, new NodeKey(new NodeId("openflow:1")))); - private static final BundleId BUNDLE_ID = new BundleId(1L); + private static final BundleId BUNDLE_ID = new BundleId(Uint32.ONE); private static final BundleFlags BUNDLE_FLAGS = new BundleFlags(true, false); private SalBundleService service; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalExperimenterMessageServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalExperimenterMessageServiceImplTest.java index 6b60dc7f2c..991944f40d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalExperimenterMessageServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalExperimenterMessageServiceImplTest.java @@ -51,7 +51,7 @@ public class SalExperimenterMessageServiceImplTest extends ServiceMocking { extensionConverterProvider); Mockito.when(extensionConverterProvider.getMessageConverter(ArgumentMatchers.any())) .thenReturn(extensionConverter); - Mockito.when(extensionConverter.getExperimenterId()).thenReturn(new ExperimenterId(43L)); + Mockito.when(extensionConverter.getExperimenterId()).thenReturn(new ExperimenterId(Uint32.valueOf(43))); Mockito.when(extensionConverter.getType()).thenReturn(44L); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImplTest.java index eca5e7c7b8..0d2c64a6ce 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImplTest.java @@ -13,7 +13,9 @@ import com.google.common.util.concurrent.ListenableFuture; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.Future; import org.junit.After; import org.junit.Assert; @@ -94,6 +96,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link org.opendaylight.openflowplugin.impl.services.sal.SalFlatBatchServiceImpl}. @@ -288,7 +292,7 @@ public class SalFlatBatchServiceImplTest { .withResult(new RemoveFlowsBatchOutputBuilder() .setBatchFailedFlowsOutput(Lists.newArrayList( new BatchFailedFlowsOutputBuilder() - .setBatchOrder(1) + .setBatchOrder(Uint16.ONE) .setFlowId(new FlowId("123")) .build())) .build()) @@ -312,28 +316,27 @@ public class SalFlatBatchServiceImplTest { .thenReturn(RpcResultBuilder.success(new UpdateMetersBatchOutputBuilder().build()).buildFuture()); } - private Batch createFlowAddBatch(final int batchOrder, final String flowIdValue) { + private static Batch createFlowAddBatch(final int batchOrder, final String flowIdValue) { return createFlowAddBatch(batchOrder, flowIdValue, 1); } private static Batch createFlowAddBatch(final int batchOrder, final String flowIdValue, final int amount) { return new BatchBuilder() - .setBatchOrder(batchOrder) + .setBatchOrder(Uint16.valueOf(batchOrder)) .setBatchChoice(new FlatBatchAddFlowCaseBuilder() .setFlatBatchAddFlow(repeatFlatBatchAddFlowInList(flowIdValue, amount)) .build()) .build(); } - private static List repeatFlatBatchAddFlowInList(final String flowIdValue, final int amount) { - final List list = new ArrayList<>(); + private static Map repeatFlatBatchAddFlowInList(final String flowIdValue, + final int amount) { + final Map map = new LinkedHashMap<>(); for (int i = 0; i < amount; i++) { - list.add(new FlatBatchAddFlowBuilder() - .setFlowId(new FlowId(flowIdValue + i)) - .withKey(new FlatBatchAddFlowKey(i)) - .build()); + final FlatBatchAddFlowKey key = new FlatBatchAddFlowKey(Uint16.valueOf(i)); + map.put(key, new FlatBatchAddFlowBuilder().withKey(key).setFlowId(new FlowId(flowIdValue + i)).build()); } - return list; + return map; } private static List repeatInList(final T item, final int amount) { @@ -346,7 +349,7 @@ public class SalFlatBatchServiceImplTest { private static Batch createFlowRemoveBatch(final int batchOrder, final String flowIdValue) { return new BatchBuilder() - .setBatchOrder(batchOrder) + .setBatchOrder(Uint16.valueOf(batchOrder)) .setBatchChoice(new FlatBatchRemoveFlowCaseBuilder() .setFlatBatchRemoveFlow(Collections.singletonList(new FlatBatchRemoveFlowBuilder() .setFlowId(new FlowId(flowIdValue)) @@ -356,9 +359,10 @@ public class SalFlatBatchServiceImplTest { } private static Batch createFlowUpdateBatch(final int batchOrder, final String flowIdValue) { + final Uint16 uint = Uint16.valueOf(batchOrder); return new BatchBuilder() - .setBatchOrder(batchOrder) - .withKey(new BatchKey(batchOrder)) + .setBatchOrder(uint) + .withKey(new BatchKey(uint)) .setBatchChoice(new FlatBatchUpdateFlowCaseBuilder() .setFlatBatchUpdateFlow(Collections.singletonList(new FlatBatchUpdateFlowBuilder() .setFlowId(new FlowId(flowIdValue)) @@ -369,10 +373,10 @@ public class SalFlatBatchServiceImplTest { private static Batch createGroupAddBatch(final int batchOrder, final long groupIdValue) { return new BatchBuilder() - .setBatchOrder(batchOrder) + .setBatchOrder(Uint16.valueOf(batchOrder)) .setBatchChoice(new FlatBatchAddGroupCaseBuilder() .setFlatBatchAddGroup(Collections.singletonList(new FlatBatchAddGroupBuilder() - .setGroupId(new GroupId(groupIdValue)) + .setGroupId(new GroupId(Uint32.valueOf(groupIdValue))) .build())) .build()) .build(); @@ -380,10 +384,10 @@ public class SalFlatBatchServiceImplTest { private static Batch createGroupRemoveBatch(final int batchOrder, final long groupIdValue) { return new BatchBuilder() - .setBatchOrder(batchOrder) + .setBatchOrder(Uint16.valueOf(batchOrder)) .setBatchChoice(new FlatBatchRemoveGroupCaseBuilder() .setFlatBatchRemoveGroup(Collections.singletonList(new FlatBatchRemoveGroupBuilder() - .setGroupId(new GroupId(groupIdValue)) + .setGroupId(new GroupId(Uint32.valueOf(groupIdValue))) .build())) .build()) .build(); @@ -391,14 +395,14 @@ public class SalFlatBatchServiceImplTest { private static Batch createGroupUpdateBatch(final int batchOrder, final long groupIdValue) { return new BatchBuilder() - .setBatchOrder(batchOrder) + .setBatchOrder(Uint16.valueOf(batchOrder)) .setBatchChoice(new FlatBatchUpdateGroupCaseBuilder() .setFlatBatchUpdateGroup(Collections.singletonList(new FlatBatchUpdateGroupBuilder() .setOriginalBatchedGroup(new OriginalBatchedGroupBuilder() - .setGroupId(new GroupId(groupIdValue)) + .setGroupId(new GroupId(Uint32.valueOf(groupIdValue))) .build()) .setUpdatedBatchedGroup(new UpdatedBatchedGroupBuilder() - .setGroupId(new GroupId(groupIdValue)) + .setGroupId(new GroupId(Uint32.valueOf(groupIdValue))) .build()) .build())) .build()) @@ -407,10 +411,10 @@ public class SalFlatBatchServiceImplTest { private static Batch createMeterAddBatch(final int batchOrder, final long groupIdValue) { return new BatchBuilder() - .setBatchOrder(batchOrder) + .setBatchOrder(Uint16.valueOf(batchOrder)) .setBatchChoice(new FlatBatchAddMeterCaseBuilder() .setFlatBatchAddMeter(Collections.singletonList(new FlatBatchAddMeterBuilder() - .setMeterId(new MeterId(groupIdValue)) + .setMeterId(new MeterId(Uint32.valueOf(groupIdValue))) .build())) .build()) .build(); @@ -418,10 +422,10 @@ public class SalFlatBatchServiceImplTest { private static Batch createMeterRemoveBatch(final int batchOrder, final long groupIdValue) { return new BatchBuilder() - .setBatchOrder(batchOrder) + .setBatchOrder(Uint16.valueOf(batchOrder)) .setBatchChoice(new FlatBatchRemoveMeterCaseBuilder() .setFlatBatchRemoveMeter(Collections.singletonList(new FlatBatchRemoveMeterBuilder() - .setMeterId(new MeterId(groupIdValue)) + .setMeterId(new MeterId(Uint32.valueOf(groupIdValue))) .build())) .build()) .build(); @@ -429,14 +433,14 @@ public class SalFlatBatchServiceImplTest { private static Batch createMeterUpdateBatch(final int batchOrder, final long groupIdValue) { return new BatchBuilder() - .setBatchOrder(batchOrder) + .setBatchOrder(Uint16.valueOf(batchOrder)) .setBatchChoice(new FlatBatchUpdateMeterCaseBuilder() .setFlatBatchUpdateMeter(Collections.singletonList(new FlatBatchUpdateMeterBuilder() .setOriginalBatchedMeter(new OriginalBatchedMeterBuilder() - .setMeterId(new MeterId(groupIdValue)) + .setMeterId(new MeterId(Uint32.valueOf(groupIdValue))) .build()) .setUpdatedBatchedMeter(new UpdatedBatchedMeterBuilder() - .setMeterId(new MeterId(groupIdValue)) + .setMeterId(new MeterId(Uint32.valueOf(groupIdValue))) .build()) .build())) .build()) @@ -465,8 +469,8 @@ public class SalFlatBatchServiceImplTest { final ListenableFuture> failedChainOutput = RpcResultBuilder.failed() .withError(RpcError.ErrorType.APPLICATION, "ut-chainError") - .withResult(createFlatBatchOutput(createFlowBatchFailure(0, "f1"), - createFlowBatchFailure(1, "f2"))) + .withResult(createFlatBatchOutput(createFlowBatchFailure(Uint16.ZERO, "f1"), + createFlowBatchFailure(Uint16.ONE, "f2"))) .buildFuture(); Mockito.when(batchStepJob1.getStepFunction().apply(ArgumentMatchers.any())) @@ -491,7 +495,7 @@ public class SalFlatBatchServiceImplTest { .getFlowId().getValue()); } - private static BatchFailure createFlowBatchFailure(final int batchOrder, final String flowIdValue) { + private static BatchFailure createFlowBatchFailure(final Uint16 batchOrder, final String flowIdValue) { return new BatchFailureBuilder() .setBatchOrder(batchOrder) .setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder() @@ -561,11 +565,11 @@ public class SalFlatBatchServiceImplTest { .withResult(new AddFlowsBatchOutputBuilder() .setBatchFailedFlowsOutput(Lists.newArrayList( new BatchFailedFlowsOutputBuilder() - .setBatchOrder(0) + .setBatchOrder(Uint16.ZERO) .setFlowId(new FlowId("f1")) .build(), new BatchFailedFlowsOutputBuilder() - .setBatchOrder(1) + .setBatchOrder(Uint16.ONE) .setFlowId(new FlowId("f2")) .build())) .build()) diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImplTest.java index 97350e440b..f982788c6a 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImplTest.java @@ -73,6 +73,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint64; import org.opendaylight.yangtools.yang.common.Uint8; @@ -83,7 +84,7 @@ public class SalFlowServiceImplTest extends TestCase { private static final Uint64 DUMMY_DATAPATH_ID = Uint64.valueOf(444); private static final String DUMMY_NODE_ID = "dummyNodeID"; private static final String DUMMY_FLOW_ID = "dummyFlowID"; - private static final Short DUMMY_TABLE_ID = (short) 0; + private static final Uint8 DUMMY_TABLE_ID = Uint8.ZERO; private static final KeyedInstanceIdentifier NODE_II = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(DUMMY_NODE_ID))); @@ -91,7 +92,7 @@ public class SalFlowServiceImplTest extends TestCase { private static final KeyedInstanceIdentifier TABLE_II = NODE_II.augmentation(FlowCapableNode.class).child(Table.class, new TableKey(DUMMY_TABLE_ID)); - private NodeRef noderef = new NodeRef(NODE_II); + private final NodeRef noderef = new NodeRef(NODE_II); private static final String KEY = "0"; private static FlowGroupCache flowcache = new FlowGroupCache("0","mock class", FlowGroupStatus.ADDED, LocalDateTime.MAX); @@ -191,7 +192,7 @@ public class SalFlowServiceImplTest extends TestCase { private void addFlowFailCallback(final short version) throws InterruptedException, ExecutionException { AddFlowInput mockedAddFlowInput = new AddFlowInputBuilder() .setMatch(match) - .setTableId((short)1) + .setTableId(Uint8.ONE) .setNode(noderef) .build(); @@ -219,7 +220,7 @@ public class SalFlowServiceImplTest extends TestCase { private void removeFlowFailCallback(final short version) throws InterruptedException, ExecutionException { RemoveFlowInput mockedRemoveFlowInput = new RemoveFlowInputBuilder() - .setTableId((short)1) + .setTableId(Uint8.ONE) .setMatch(match) .setNode(noderef) .build(); @@ -245,7 +246,7 @@ public class SalFlowServiceImplTest extends TestCase { private void addFlow(final short version) throws ExecutionException, InterruptedException { AddFlowInput mockedAddFlowInput = new AddFlowInputBuilder() .setMatch(match) - .setTableId((short)1) + .setTableId(Uint8.ONE) .setNode(noderef) .build(); SalFlowServiceImpl salFlowService = mockSalFlowService(version); @@ -268,7 +269,7 @@ public class SalFlowServiceImplTest extends TestCase { private void removeFlow(final short version) throws Exception { RemoveFlowInput mockedRemoveFlowInput = new RemoveFlowInputBuilder() .setMatch(match) - .setTableId((short)1) + .setTableId(Uint8.ONE) .setNode(noderef) .build(); @@ -294,13 +295,13 @@ public class SalFlowServiceImplTest extends TestCase { UpdatedFlow mockedUpdateFlow = new UpdatedFlowBuilder() .setMatch(match) - .setTableId((short)1) + .setTableId(Uint8.ONE) .build(); UpdatedFlow mockedUpdateFlow1 = new UpdatedFlowBuilder() .setMatch(match) - .setTableId((short)1) - .setPriority(1) + .setTableId(Uint8.ONE) + .setPriority(Uint16.ONE) .build(); when(mockedUpdateFlowInput.getUpdatedFlow()).thenReturn(mockedUpdateFlow); @@ -314,13 +315,13 @@ public class SalFlowServiceImplTest extends TestCase { OriginalFlow mockedOriginalFlow = new OriginalFlowBuilder() .setMatch(match) - .setTableId((short)1) + .setTableId(Uint8.ONE) .build(); OriginalFlow mockedOriginalFlow1 = new OriginalFlowBuilder() .setMatch(match) - .setTableId((short)1) - .setPriority(2) + .setTableId(Uint8.ONE) + .setPriority(Uint16.TWO) .build(); when(mockedUpdateFlowInput.getOriginalFlow()).thenReturn(mockedOriginalFlow); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImplTest.java index 145d802a25..d61d9170ce 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImplTest.java @@ -65,6 +65,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -186,18 +188,18 @@ public class SalFlowsBatchServiceImplTest { private static BatchAddFlows createEmptyBatchAddFlow(final String flowIdValue, final int priority) { return new BatchAddFlowsBuilder() .setFlowId(new FlowId(flowIdValue)) - .setPriority(priority) + .setPriority(Uint16.valueOf(priority)) .setMatch(new MatchBuilder().build()) - .setTableId((short) 0) + .setTableId(Uint8.ZERO) .build(); } private static BatchRemoveFlows createEmptyBatchRemoveFlow(final String flowIdValue, final int priority) { return new BatchRemoveFlowsBuilder() .setFlowId(new FlowId(flowIdValue)) - .setPriority(priority) + .setPriority(Uint16.valueOf(priority)) .setMatch(new MatchBuilder().build()) - .setTableId((short) 0) + .setTableId(Uint8.ZERO) .build(); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupServiceImplTest.java index 895f65e902..594976ad01 100755 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupServiceImplTest.java @@ -37,10 +37,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; public class SalGroupServiceImplTest extends ServiceMocking { - private static final Long DUMMY_GROUP_ID = 15L; + private static final Uint32 DUMMY_GROUP_ID = Uint32.valueOf(15); private static final KeyedInstanceIdentifier NODE_II = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(DUMMY_NODE_ID))); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImplTest.java index ba70b49515..5aff78ee92 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImplTest.java @@ -64,6 +64,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link org.opendaylight.openflowplugin.impl.services.sal.SalGroupsBatchServiceImpl}. @@ -306,13 +307,13 @@ public class SalGroupsBatchServiceImplTest { private static BatchAddGroups createEmptyBatchAddGroup(final long groupIdValue) { return new BatchAddGroupsBuilder() - .setGroupId(new GroupId(groupIdValue)) + .setGroupId(new GroupId(Uint32.valueOf(groupIdValue))) .build(); } private static BatchRemoveGroups createEmptyBatchRemoveGroup(final long groupIdValue) { return new BatchRemoveGroupsBuilder() - .setGroupId(new GroupId(groupIdValue)) + .setGroupId(new GroupId(Uint32.valueOf(groupIdValue))) .build(); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMeterServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMeterServiceImplTest.java index 001a6d2c99..59b2f34e36 100755 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMeterServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMeterServiceImplTest.java @@ -28,11 +28,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.met import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeter; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId; +import org.opendaylight.yangtools.yang.common.Uint32; public class SalMeterServiceImplTest extends ServiceMocking { - private static final Long DUMMY_METER_ID = 15L; - private static final Long DUMMY_METTER_ID = 2000L; + private static final Uint32 DUMMY_METER_ID = Uint32.valueOf(15); + private static final Uint32 DUMMY_METTER_ID = Uint32.valueOf(2000); @Mock DeviceMeterRegistry mockedDeviceMeterRegistry; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImplTest.java index e19e022e5a..74f7c57fc2 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImplTest.java @@ -66,6 +66,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link org.opendaylight.openflowplugin.impl.services.sal.SalMetersBatchServiceImpl}. @@ -307,13 +308,13 @@ public class SalMetersBatchServiceImplTest { private static BatchAddMeters createEmptyBatchAddMeter(final long groupIdValue) { return new BatchAddMetersBuilder() - .setMeterId(new MeterId(groupIdValue)) + .setMeterId(new MeterId(Uint32.valueOf(groupIdValue))) .build(); } private static BatchRemoveMeters createEmptyBatchRemoveMeter(final long groupIdValue) { return new BatchRemoveMetersBuilder() - .setMeterId(new MeterId(groupIdValue)) + .setMeterId(new MeterId(Uint32.valueOf(groupIdValue))) .build(); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImplTest.java index 59827b7cff..cbb9c53a95 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImplTest.java @@ -84,7 +84,7 @@ public class SalRoleServiceImplTest { private final NodeId testNodeId = new NodeId(Uri.getDefaultInstance("openflow:1")); - private static long testXid = 100L; + private static final Uint32 TEST_XID = Uint32.valueOf(100); private static final String ROLEREQUESTFAILED = org.opendaylight.yang.gen.v1.urn .opendaylight.openflow.common.types.rev130731.ErrorType.ROLEREQUESTFAILED.name(); @@ -108,7 +108,7 @@ public class SalRoleServiceImplTest { Mockito.when(mockFeaturesReply.getVersion()).thenReturn(testVersion); Mockito.when(mockDeviceContext.getMessageSpy()).thenReturn(mockMessageSpy); Mockito.when(mockRequestContextStack.createRequestContext()).thenReturn(mockRequestContext); - Mockito.when(mockRequestContext.getXid()).thenReturn(new Xid(Uint32.valueOf(testXid))); + Mockito.when(mockRequestContext.getXid()).thenReturn(new Xid(TEST_XID)); Mockito.when(mockConnectionContext.getOutboundQueueProvider()).thenReturn(mockOutboundQueue); Mockito.when(mockDeviceContext.getPrimaryConnectionContext().getConnectionState()) .thenReturn(ConnectionContext.CONNECTION_STATE.WORKING); @@ -124,7 +124,7 @@ public class SalRoleServiceImplTest { @Test public void testSetRole() throws Exception { RoleRequestOutput roleRequestOutput = new RoleRequestOutputBuilder() - .setXid(testXid).setGenerationId(Uint64.ONE).build(); + .setXid(TEST_XID).setGenerationId(Uint64.ONE).build(); ListenableFuture> futureOutput = RpcResultBuilder.success().withResult(roleRequestOutput).buildFuture(); @@ -146,7 +146,7 @@ public class SalRoleServiceImplTest { SetRoleOutput setRoleOutput = roleOutputRpcResult.getResult(); assertNotNull(setRoleOutput); - assertEquals(Uint64.valueOf(testXid), setRoleOutput.getTransactionId().getValue()); + assertEquals(Uint64.valueOf(TEST_XID), setRoleOutput.getTransactionId().getValue()); } @@ -155,7 +155,7 @@ public class SalRoleServiceImplTest { // set role to slave RoleRequestOutput roleRequestOutput = new RoleRequestOutputBuilder() - .setXid(testXid).setGenerationId(Uint64.ONE).build(); + .setXid(TEST_XID).setGenerationId(Uint64.ONE).build(); ListenableFuture> futureOutput = RpcResultBuilder.success().withResult(roleRequestOutput).buildFuture(); @@ -176,7 +176,7 @@ public class SalRoleServiceImplTest { SetRoleOutput setRoleOutput = roleOutputRpcResult.getResult(); assertNotNull(setRoleOutput); - assertEquals(Uint64.valueOf(testXid), setRoleOutput.getTransactionId().getValue()); + assertEquals(Uint64.valueOf(TEST_XID), setRoleOutput.getTransactionId().getValue()); // make another role change with the same role - slave Future> future2 = salRoleService.setRole(setRoleInput); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalTableServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalTableServiceImplTest.java index a73ed9aa46..e7969139e3 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalTableServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalTableServiceImplTest.java @@ -40,6 +40,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.Upd import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; public class SalTableServiceImplTest extends ServiceMocking { @@ -99,9 +101,9 @@ public class SalTableServiceImplTest extends ServiceMocking { public void testUpdateTableSuccess() { Mockito.doAnswer((Answer) invocation -> { TableFeaturesBuilder tableFeaturesBld = new TableFeaturesBuilder() - .setTableId((short) 0) + .setTableId(Uint8.ZERO) .setName("Zafod") - .setMaxEntries(42L) + .setMaxEntries(Uint32.valueOf(42)) .setTableFeatureProperties(Collections.emptyList()); MultipartReplyTableFeaturesBuilder mpTableFeaturesBld = new MultipartReplyTableFeaturesBuilder() .setTableFeatures(Collections.singletonList(tableFeaturesBld.build())); @@ -110,7 +112,7 @@ public class SalTableServiceImplTest extends ServiceMocking { MultipartReplyMessageBuilder mpResultBld = new MultipartReplyMessageBuilder() .setType(MultipartType.OFPMPTABLEFEATURES) .setMultipartReplyBody(mpBodyBld.build()) - .setXid(21L); + .setXid(Uint32.valueOf(21)); final RpcResult> rpcResult = RpcResultBuilder .success(Collections.singletonList((MultipartReply) mpResultBld.build())) .build(); @@ -126,7 +128,7 @@ public class SalTableServiceImplTest extends ServiceMocking { private static UpdateTableInput prepareUpdateTable() { UpdateTableInputBuilder updateTableInputBuilder = new UpdateTableInputBuilder(); UpdatedTableBuilder updatedTableBuilder = new UpdatedTableBuilder(); - updatedTableBuilder.setTableFeatures(Collections.emptyList()); + updatedTableBuilder.setTableFeatures(Collections.emptyMap()); updateTableInputBuilder.setUpdatedTable(updatedTableBuilder.build()); return updateTableInputBuilder.build(); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerAggregateFlowMultipartServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerAggregateFlowMultipartServiceTest.java index 849d528e29..450f4b4c1e 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerAggregateFlowMultipartServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerAggregateFlowMultipartServiceTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.services.singlelayer; import static org.junit.Assert.assertEquals; @@ -25,9 +24,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.M import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; public class SingleLayerAggregateFlowMultipartServiceTest extends ServiceMocking { - private static final short TABLE_ID = 42; + private static final Uint8 TABLE_ID = Uint8.valueOf(42); private static final Uint64 BYTE_COUNT = Uint64.valueOf(10); private SingleLayerAggregateFlowMultipartService service; @@ -50,7 +50,7 @@ public class SingleLayerAggregateFlowMultipartServiceTest extends ServiceMocking (MultipartRequestFlowAggregateStats) ((MultipartRequest) ofHeader) .getMultipartRequestBody(); - assertEquals(TABLE_ID, result.getFlowAggregateStats().getTableId().shortValue()); + assertEquals(TABLE_ID, result.getFlowAggregateStats().getTableId()); } @Test diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerFlowServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerFlowServiceTest.java index 88146e68ab..bb0abb281e 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerFlowServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerFlowServiceTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.services.singlelayer; import static org.junit.Assert.assertEquals; @@ -18,15 +17,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddF import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.common.Uint8; public class SingleLayerFlowServiceTest extends ServiceMocking { - private static final short TABLE_ID = 42; + private static final Uint8 TABLE_ID = Uint8.valueOf(42); private SingleLayerFlowService service; @Override protected void setup() { - service = new SingleLayerFlowService<>(mockedRequestContextStack, - mockedDeviceContext, AddFlowOutput.class); + service = new SingleLayerFlowService<>(mockedRequestContextStack, mockedDeviceContext, AddFlowOutput.class); } @Test @@ -41,6 +40,6 @@ public class SingleLayerFlowServiceTest extends ServiceMocking { final FlowMessage result = (FlowMessage) ofHeader; assertEquals(FlowModCommand.OFPFCADD, result.getCommand()); - assertEquals(TABLE_ID, result.getTableId().shortValue()); + assertEquals(TABLE_ID, result.getTableId()); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerGroupServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerGroupServiceTest.java index 6ae09813b8..6d4abb8c81 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerGroupServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerGroupServiceTest.java @@ -19,9 +19,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.common.Uint32; public class SingleLayerGroupServiceTest extends ServiceMocking { - private static final long GROUP_ID = 42; + private static final Uint32 GROUP_ID = Uint32.valueOf(42); private SingleLayerGroupService service; @Override @@ -42,6 +43,6 @@ public class SingleLayerGroupServiceTest extends ServiceMocking { final GroupMessage result = (GroupMessage) ofHeader; assertEquals(GroupModCommand.OFPGCADD, result.getCommand()); - assertEquals(GROUP_ID, result.getGroupId().getValue().longValue()); + assertEquals(GROUP_ID, result.getGroupId().getValue()); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerMeterServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerMeterServiceTest.java index d512a39028..ab9be96d95 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerMeterServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerMeterServiceTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.services.singlelayer; import static org.junit.Assert.assertEquals; @@ -19,9 +18,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.common.Uint32; public class SingleLayerMeterServiceTest extends ServiceMocking { - private static final long METER_ID = 42; + private static final Uint32 METER_ID = Uint32.valueOf(42); private SingleLayerMeterService service; @Override @@ -42,6 +42,6 @@ public class SingleLayerMeterServiceTest extends ServiceMocking { final MeterMessage result = (MeterMessage) ofHeader; assertEquals(MeterModCommand.OFPMCADD, result.getCommand()); - assertEquals(METER_ID, result.getMeterId().getValue().longValue()); + assertEquals(METER_ID, result.getMeterId().getValue()); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartServiceTest.java index 50005bd334..b692a9dac7 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartServiceTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.services.singlelayer; import static org.junit.Assert.assertEquals; @@ -27,10 +26,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multi import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.request.multipart.request.body.MultipartRequestTableFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; public class SingleLayerTableMultipartServiceTest extends ServiceMocking { - private static final long MAX_ENTRIES = 42; - private static final long XID = 43; + private static final Uint32 MAX_ENTRIES = Uint32.valueOf(42); + private static final Uint32 XID = Uint32.valueOf(43); private SingleLayerTableMultipartService service; @Override @@ -55,7 +56,7 @@ public class SingleLayerTableMultipartServiceTest extends ServiceMocking { final MultipartRequestTableFeatures result = (MultipartRequestTableFeatures) ((MultipartRequest) ofHeader) .getMultipartRequestBody(); - assertEquals(MAX_ENTRIES, result.nonnullTableFeatures().values().iterator().next().getMaxEntries().longValue()); + assertEquals(MAX_ENTRIES, result.nonnullTableFeatures().values().iterator().next().getMaxEntries()); } @Test @@ -84,6 +85,6 @@ public class SingleLayerTableMultipartServiceTest extends ServiceMocking { rpcResultFuture.get(); assertTrue(result.isSuccessful()); - assertEquals(XID, result.getResult().getTransactionId().getValue().longValue()); + assertEquals(Uint64.valueOf(XID), result.getResult().getTransactionId().getValue()); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/MultipartReplyTranslatorTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/MultipartReplyTranslatorTest.java index c5f605f7a5..dee46593f0 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/MultipartReplyTranslatorTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/MultipartReplyTranslatorTest.java @@ -64,7 +64,7 @@ public class MultipartReplyTranslatorTest { private static final Uint64 DUMMY_BYTE_COUNT = Uint64.valueOf(31); private static final Uint64 DUMMY_PACKET_COUNT = Uint64.valueOf(41); private static final Uint32 DUMMY_FLOW_COUNT = Uint32.valueOf(51); - private static final Long DUMMY_PORT_NO = 154L; + private static final Uint32 DUMMY_PORT_NO = Uint32.valueOf(154); private static final Uint64 DUMMY_RX_BYTES = Uint64.valueOf(155); private static final Uint64 DUMMY_TX_BYTES = Uint64.valueOf(165); private static final Uint64 DUMMY_RX_PACKETS = Uint64.valueOf(175); @@ -79,7 +79,7 @@ public class MultipartReplyTranslatorTest { private static final Uint64 DUMMY_TX_ERRORS = Uint64.valueOf(265); private static final Uint32 DUMMY_DURATION_SEC = Uint32.valueOf(3453); private static final Uint32 DUMMY_DURATION_NSEC = Uint32.valueOf(3343); - private static final GroupId DUMMY_GROUP_ID = new GroupId(55L); + private static final GroupId DUMMY_GROUP_ID = new GroupId(Uint32.valueOf(55)); private static final Uint32 DUMMY_REF_COUNT = Uint32.valueOf(1234); private static final GroupTypes DUMMY_GROUPS_TYPE = GroupTypes.GroupAll; private static final GroupType DUMMY_GROUP_TYPE = GroupType.OFPGTALL; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplParamTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplParamTest.java index 6b18ba9699..9f465c417d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplParamTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplParamTest.java @@ -36,12 +36,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; @RunWith(Parameterized.class) public class StatisticsContextImplParamTest extends StatisticsContextImpMockInitiation { @Mock - private OpenflowProviderConfig config = mock(OpenflowProviderConfig.class); + private final OpenflowProviderConfig config = mock(OpenflowProviderConfig.class); public StatisticsContextImplParamTest(final boolean isTable, final boolean isFlow, final boolean isGroup, final boolean isMeter, @@ -75,8 +76,8 @@ public class StatisticsContextImplParamTest extends StatisticsContextImpMockInit Mockito.when(config.isIsMeterStatisticsPollingOn()).thenReturn(true); Mockito.when(config.isIsPortStatisticsPollingOn()).thenReturn(true); Mockito.when(config.isIsQueueStatisticsPollingOn()).thenReturn(true); - Mockito.when(config.getBasicTimerDelay()).thenReturn(new NonZeroUint32Type(3000L)); - Mockito.when(config.getMaximumTimerDelay()).thenReturn(new NonZeroUint32Type(50000L)); + Mockito.when(config.getBasicTimerDelay()).thenReturn(new NonZeroUint32Type(Uint32.valueOf(3000))); + Mockito.when(config.getMaximumTimerDelay()).thenReturn(new NonZeroUint32Type(Uint32.valueOf(50000))); } @Test diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java index dc4c50a54b..84827e68aa 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java @@ -62,8 +62,8 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio Mockito.when(config.isIsMeterStatisticsPollingOn()).thenReturn(true); Mockito.when(config.isIsPortStatisticsPollingOn()).thenReturn(true); Mockito.when(config.isIsQueueStatisticsPollingOn()).thenReturn(true); - Mockito.when(config.getBasicTimerDelay()).thenReturn(new NonZeroUint32Type(3000L)); - Mockito.when(config.getMaximumTimerDelay()).thenReturn(new NonZeroUint32Type(50000L)); + Mockito.when(config.getBasicTimerDelay()).thenReturn(new NonZeroUint32Type(Uint32.valueOf(3000))); + Mockito.when(config.getMaximumTimerDelay()).thenReturn(new NonZeroUint32Type(Uint32.valueOf(50000))); initStatisticsContext(); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java index 63fb5941d5..2f0a577d44 100755 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java @@ -17,7 +17,6 @@ import com.google.common.collect.Lists; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; -import java.math.BigInteger; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -132,6 +131,7 @@ import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint64; import org.opendaylight.yangtools.yang.common.Uint8; @@ -209,7 +209,7 @@ public class StatisticsGatheringUtilsTest { private static Iterable prepareFlowStatisticsData() { final FlowAndStatisticsMapListBuilder flowAndStatsMapListBld = new FlowAndStatisticsMapListBuilder(); - flowAndStatsMapListBld.setTableId((short) 42); + flowAndStatsMapListBld.setTableId(Uint8.valueOf(42)); flowAndStatsMapListBld.setMatch(new MatchBuilder().build()); final FlowsStatisticsUpdateBuilder flowStatsUpdateBld1 = new FlowsStatisticsUpdateBuilder(); @@ -222,15 +222,15 @@ public class StatisticsGatheringUtilsTest { @Test public void testGatherStatistics_group() throws Exception { final MultipartType type = MultipartType.OFPMPGROUP; - final long groupIdValue = 19L; + final Uint32 groupIdValue = Uint32.valueOf(19); final GroupStatsBuilder groupStatsBld = new GroupStatsBuilder() .setBucketStats(Lists.newArrayList(createBucketStat(21L, 42L))) - .setByteCount(BigInteger.valueOf(84L)) - .setPacketCount(BigInteger.valueOf(63L)) - .setDurationSec(11L) - .setDurationNsec(12L) - .setRefCount(13L) + .setByteCount(Uint64.valueOf(84)) + .setPacketCount(Uint64.valueOf(63)) + .setDurationSec(Uint32.valueOf(11)) + .setDurationNsec(Uint32.valueOf(12)) + .setRefCount(Uint32.valueOf(13)) .setGroupId(new GroupId(groupIdValue)); final MultipartReplyGroupBuilder mpReplyGroupBld = new MultipartReplyGroupBuilder(); mpReplyGroupBld.setGroupStats(Lists.newArrayList(groupStatsBld.build())); @@ -254,10 +254,10 @@ public class StatisticsGatheringUtilsTest { @Test public void testGatherStatistics_groupDesc() throws Exception { final MultipartType type = MultipartType.OFPMPGROUPDESC; - final long groupIdValue = 27L; + final Uint32 groupIdValue = Uint32.valueOf(27); final BucketsListBuilder bucketsListBld = new BucketsListBuilder() - .setWatchPort(new PortNumber(5L)); + .setWatchPort(new PortNumber(Uint32.valueOf(5))); final GroupDescBuilder groupStatsBld = new GroupDescBuilder() .setBucketsList(Lists.newArrayList(bucketsListBld.build())) .setGroupId(new GroupId(groupIdValue)) @@ -287,18 +287,18 @@ public class StatisticsGatheringUtilsTest { @Test public void testGatherStatistics_meter() throws Exception { final MultipartType type = MultipartType.OFPMPMETER; - final long meterIdValue = 19L; + final Uint32 meterIdValue = Uint32.valueOf(19); final MeterBandStatsBuilder meterBandStatsBld = new MeterBandStatsBuilder() - .setByteBandCount(BigInteger.valueOf(91L)) - .setPacketBandCount(BigInteger.valueOf(92L)); + .setByteBandCount(Uint64.valueOf(91)) + .setPacketBandCount(Uint64.valueOf(92)); final MeterStatsBuilder meterStatsBld = new MeterStatsBuilder() .setMeterId(new MeterId(meterIdValue)) - .setByteInCount(BigInteger.valueOf(111L)) - .setDurationSec(112L) - .setDurationNsec(113L) - .setFlowCount(114L) - .setPacketInCount(BigInteger.valueOf(115L)) + .setByteInCount(Uint64.valueOf(111)) + .setDurationSec(Uint32.valueOf(112)) + .setDurationNsec(Uint32.valueOf(113)) + .setFlowCount(Uint32.valueOf(114)) + .setPacketInCount(Uint64.valueOf(115)) .setMeterBandStats(Lists.newArrayList(meterBandStatsBld.build())); final MultipartReplyMeterBuilder mpReplyMeterBld = new MultipartReplyMeterBuilder(); mpReplyMeterBld.setMeterStats(Lists.newArrayList(meterStatsBld.build())); @@ -324,7 +324,7 @@ public class StatisticsGatheringUtilsTest { final MultipartType type = MultipartType.OFPMPPORTSTATS; final PortStatsBuilder portStatsBld = new PortStatsBuilder() - .setPortNo(11L); + .setPortNo(Uint32.valueOf(11)); final MultipartReplyPortStatsBuilder mpReplyMeterBld = new MultipartReplyPortStatsBuilder(); mpReplyMeterBld.setPortStats(Lists.newArrayList(portStatsBld.build())); final MultipartReplyPortStatsCaseBuilder mpReplyMeterCaseBld = new MultipartReplyPortStatsCaseBuilder(); @@ -351,10 +351,10 @@ public class StatisticsGatheringUtilsTest { final MultipartType type = MultipartType.OFPMPTABLE; final TableStatsBuilder tableStatsBld = new TableStatsBuilder() - .setActiveCount(33L) - .setLookupCount(BigInteger.valueOf(34L)) - .setMatchedCount(BigInteger.valueOf(35L)) - .setTableId((short) 0); + .setActiveCount(Uint32.valueOf(33)) + .setLookupCount(Uint64.valueOf(34)) + .setMatchedCount(Uint64.valueOf(35)) + .setTableId(Uint8.ZERO); final MultipartReplyTableBuilder mpReplyTableBld = new MultipartReplyTableBuilder(); mpReplyTableBld.setTableStats(Lists.newArrayList(tableStatsBld.build())); final MultipartReplyTableCaseBuilder mpReplyTableCaseBld = new MultipartReplyTableCaseBuilder(); @@ -367,7 +367,7 @@ public class StatisticsGatheringUtilsTest { final InstanceIdentifier tablePath = dummyNodePath .augmentation(FlowCapableNode.class) - .child(Table.class, new TableKey((short) 0)) + .child(Table.class, new TableKey(Uint8.ZERO)) .augmentation(FlowTableStatisticsData.class) .child(FlowTableStatistics.class); verify(deviceContext).writeToTransaction( @@ -380,14 +380,14 @@ public class StatisticsGatheringUtilsTest { public void testGatherStatistics_queue() throws Exception { final MultipartType type = MultipartType.OFPMPQUEUE; - final long queueIdValue = 4L; + final Uint32 queueIdValue = Uint32.valueOf(4); final QueueStatsBuilder queueStatsBld = new QueueStatsBuilder() - .setPortNo(11L) - .setTxBytes(BigInteger.valueOf(44L)) - .setTxErrors(BigInteger.valueOf(45L)) - .setTxPackets(BigInteger.valueOf(46L)) - .setDurationSec(47L) - .setDurationNsec(48L) + .setPortNo(Uint32.valueOf(11)) + .setTxBytes(Uint64.valueOf(44)) + .setTxErrors(Uint64.valueOf(45)) + .setTxPackets(Uint64.valueOf(46)) + .setDurationSec(Uint32.valueOf(47)) + .setDurationNsec(Uint32.valueOf(48)) .setQueueId(queueIdValue); final MultipartReplyQueueBuilder mpReplyQueueBld = new MultipartReplyQueueBuilder(); @@ -413,13 +413,12 @@ public class StatisticsGatheringUtilsTest { @Test public void testGatherStatistics_flow() throws Exception { - final short tableId = 0; final MultipartType type = MultipartType.OFPMPFLOW; final InstanceIdentifier nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class); final TableBuilder tableDataBld = new TableBuilder(); - tableDataBld.setId(tableId); + tableDataBld.setId(Uint8.ZERO); final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder(); flowNodeBuilder.setTable(Collections.singletonList(tableDataBld.build())); final Optional flowNodeOpt = Optional.of(flowNodeBuilder.build()); @@ -432,11 +431,11 @@ public class StatisticsGatheringUtilsTest { new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder() .setMatchEntry(Collections.emptyList()); final FlowStatsBuilder flowStatsBld = new FlowStatsBuilder() - .setByteCount(BigInteger.valueOf(55L)) - .setPacketCount(BigInteger.valueOf(56L)) - .setDurationSec(57L) - .setDurationNsec(58L) - .setTableId((short) 0) + .setByteCount(Uint64.valueOf(55)) + .setPacketCount(Uint64.valueOf(56)) + .setDurationSec(Uint32.valueOf(57)) + .setDurationNsec(Uint32.valueOf(58L)) + .setTableId(Uint8.ZERO) .setMatch(matchBld.build()) .setFlags(new FlowModFlags(true, false, false, false, true)); @@ -450,10 +449,10 @@ public class StatisticsGatheringUtilsTest { fireAndCheck(type, statsData); final FlowBuilder flowBld = new FlowBuilder() - .setTableId((short) 0) + .setTableId(Uint8.ZERO) .setMatch(new MatchBuilder().build()); final KeyedInstanceIdentifier tablePath = dummyNodePath.augmentation(FlowCapableNode.class) - .child(Table.class, new TableKey((short) 0)); + .child(Table.class, new TableKey(Uint8.ZERO)); final KeyedInstanceIdentifier flowPath = tablePath.child(Flow.class, new FlowKey(flowId)); verify(deviceContext, Mockito.never()).addDeleteToTxChain(eq(LogicalDatastoreType.OPERATIONAL), @@ -468,7 +467,7 @@ public class StatisticsGatheringUtilsTest { @Test public void testGatherStatistics_meterConfig() throws Exception { final MultipartType type = MultipartType.OFPMPMETERCONFIG; - final Long meterIdValue = 55L; + final Uint32 meterIdValue = Uint32.valueOf(55); final MeterConfigBuilder meterConfigBld = new MeterConfigBuilder() .setMeterId(new MeterId(meterIdValue)) @@ -522,22 +521,21 @@ public class StatisticsGatheringUtilsTest { .setMultipartReplyBody(mpReplyGroupCaseBld) .setType(type) .setFlags(new MultipartRequestFlags(false)) - .setXid(42L) + .setXid(Uint32.valueOf(42)) .build(); } private static BucketStats createBucketStat(final long byteCount, final long packetCount) { return new BucketStatsBuilder() - .setByteCount(BigInteger.valueOf(byteCount)).setPacketCount(BigInteger.valueOf(packetCount)).build(); + .setByteCount(Uint64.valueOf(byteCount)).setPacketCount(Uint64.valueOf(packetCount)).build(); } @Test public void testDeleteAllKnownFlows() { - final short tableId = 0; final InstanceIdentifier nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class); final TableBuilder tableDataBld = new TableBuilder(); - tableDataBld.setId(tableId); + tableDataBld.setId(Uint8.ZERO); final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder(); flowNodeBuilder.setTable(Collections.singletonList(tableDataBld.build())); final Optional flowNodeOpt = Optional.of(flowNodeBuilder.build()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImplTest.java index c09f3e23f0..7e731719b1 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImplTest.java @@ -58,6 +58,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -112,13 +113,11 @@ public class StatisticsManagerImplTest { ArgumentMatchers.any())).thenReturn(serviceControlRegistration); final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager(); - final long basicTimerDelay = 3000L; - final long maximumTimerDelay = 900000L; statisticsManager = new StatisticsManagerImpl( new OpenflowProviderConfigBuilder() - .setBasicTimerDelay(new NonZeroUint32Type(basicTimerDelay)) - .setMaximumTimerDelay(new NonZeroUint32Type(maximumTimerDelay)) + .setBasicTimerDelay(new NonZeroUint32Type(Uint32.valueOf(3000))) + .setMaximumTimerDelay(new NonZeroUint32Type(Uint32.valueOf(900000))) .setIsStatisticsPollingOn(false) .build(), rpcProviderRegistry, convertorManager, diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl1Test.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl1Test.java index 24c097c927..e3ddf0cf6e 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl1Test.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl1Test.java @@ -22,7 +22,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.G import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only delegated methods (failing). @@ -54,7 +56,7 @@ public class OpendaylightFlowStatisticsServiceImpl1Test extends AbstractStatsSer GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder() .setNode(createNodeRef("unitProt:123")) - .setTableId(new TableId((short) 1)); + .setTableId(new TableId(Uint8.ONE)); flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build()); } @@ -63,7 +65,7 @@ public class OpendaylightFlowStatisticsServiceImpl1Test extends AbstractStatsSer public void testGetAllFlowStatisticsFromFlowTable() { GetAllFlowStatisticsFromFlowTableInputBuilder input = new GetAllFlowStatisticsFromFlowTableInputBuilder() .setNode(createNodeRef("unitProt:123")) - .setTableId(new TableId((short) 1)); + .setTableId(new TableId(Uint8.ONE)); flowStatisticsService.getAllFlowStatisticsFromFlowTable(input.build()); } @@ -81,7 +83,7 @@ public class OpendaylightFlowStatisticsServiceImpl1Test extends AbstractStatsSer public void testGetFlowStatisticsFromFlowTable() { GetFlowStatisticsFromFlowTableInputBuilder input = new GetFlowStatisticsFromFlowTableInputBuilder() .setNode(createNodeRef("unitProt:123")) - .setPriority(5); + .setPriority(Uint16.valueOf(5)); final Future> resultFuture = flowStatisticsService.getFlowStatisticsFromFlowTable(input.build()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl2Test.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl2Test.java index fab5bb07aa..a533e8c9fd 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl2Test.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl2Test.java @@ -23,7 +23,7 @@ import org.mockito.Captor; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.stubbing.Answer; -import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator; import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager; @@ -38,7 +38,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only not delegated method. @@ -80,7 +82,7 @@ public class OpendaylightFlowStatisticsServiceImpl2Test extends AbstractStatsSer .commitEntry(eq(42L), requestInput.capture(), Mockito.any()); Mockito.doAnswer((Answer) invocation -> { final MultipartReplyMessageBuilder messageBuilder = new MultipartReplyMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3); + .setVersion(EncodeConstants.OF_VERSION_1_3); rqContextMp.setResult(RpcResultBuilder .success(Collections.singletonList(messageBuilder.build())) @@ -94,8 +96,8 @@ public class OpendaylightFlowStatisticsServiceImpl2Test extends AbstractStatsSer GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder input = new GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder() .setNode(createNodeRef("unitProt:123")) - .setPriority(5) - .setTableId((short) 1); + .setPriority(Uint16.valueOf(5)) + .setTableId(Uint8.ONE); final Future> resultFuture = flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForGivenMatch(input.build()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl3Test.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl3Test.java index 9da86fb4a9..3ee63b8acc 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl3Test.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl3Test.java @@ -23,6 +23,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.G import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only delegated methods. @@ -34,6 +36,7 @@ public class OpendaylightFlowStatisticsServiceImpl3Test extends AbstractStatsSer private OpendaylightFlowStatisticsServiceImpl flowStatisticsService; + @Override public void setUp() { final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager(); flowStatisticsService = @@ -46,7 +49,7 @@ public class OpendaylightFlowStatisticsServiceImpl3Test extends AbstractStatsSer GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder() .setNode(createNodeRef("unitProt:123")) - .setTableId(new TableId((short) 1)) + .setTableId(new TableId(Uint8.ONE)) .build(); flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input); @@ -57,7 +60,7 @@ public class OpendaylightFlowStatisticsServiceImpl3Test extends AbstractStatsSer public void testGetAllFlowStatisticsFromFlowTable() { GetAllFlowStatisticsFromFlowTableInput input = new GetAllFlowStatisticsFromFlowTableInputBuilder() .setNode(createNodeRef("unitProt:123")) - .setTableId(new TableId((short) 1)) + .setTableId(new TableId(Uint8.ONE)) .build(); flowStatisticsService.getAllFlowStatisticsFromFlowTable(input); @@ -78,7 +81,7 @@ public class OpendaylightFlowStatisticsServiceImpl3Test extends AbstractStatsSer public void testGetFlowStatisticsFromFlowTable() { GetFlowStatisticsFromFlowTableInput input = new GetFlowStatisticsFromFlowTableInputBuilder() .setNode(createNodeRef("unitProt:123")) - .setPriority(5) + .setPriority(Uint16.valueOf(5)) .build(); flowStatisticsService.getFlowStatisticsFromFlowTable(input); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImplTest.java index 30bde430f5..e46bda3b1a 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImplTest.java @@ -5,14 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.statistics.services; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import com.google.common.util.concurrent.FutureCallback; -import java.math.BigInteger; import java.util.Collections; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicLong; @@ -22,7 +20,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.Captor; import org.mockito.Mockito; -import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput; @@ -37,13 +35,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Test for {@link OpendaylightFlowTableStatisticsServiceImpl}. */ public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractSingleStatsServiceTest { + private static final Uint8 TABLE_ID = Uint8.valueOf(123); - private static final Short TABLE_ID = (short) 123; @Captor private ArgumentCaptor requestInput; @@ -65,17 +65,17 @@ public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractSing rpcResult = RpcResultBuilder.success(Collections.singletonList( new MultipartReplyMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3) + .setVersion(EncodeConstants.OF_VERSION_1_3) .setMultipartReplyBody(new MultipartReplyTableCaseBuilder() .setMultipartReplyTable(new MultipartReplyTableBuilder() .setTableStats(Collections.singletonList(new TableStatsBuilder() - .setActiveCount(31L) - .setLookupCount(BigInteger.valueOf(32L)) - .setMatchedCount(BigInteger.valueOf(33L)) - .setMaxEntries(34L) + .setActiveCount(Uint32.valueOf(31)) + .setLookupCount(Uint64.valueOf(32)) + .setMatchedCount(Uint64.valueOf(33)) + .setMaxEntries(Uint32.valueOf(34)) .setName("test-table") - .setNwDstMask((short) 35) - .setNwSrcMask((short) 36) + .setNwDstMask(Uint8.valueOf(35)) + .setNwSrcMask(Uint8.valueOf(36)) .setTableId(TABLE_ID) .build())) .build()) diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImplTest.java index 9d5792a508..a874d756c4 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImplTest.java @@ -5,14 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.statistics.services; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import com.google.common.util.concurrent.FutureCallback; -import java.math.BigInteger; import java.util.Collections; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicLong; @@ -23,7 +21,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.Captor; import org.mockito.Mockito; -import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder; @@ -55,7 +53,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeaturesBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Test for {@link OpendaylightGroupStatisticsServiceImpl}. @@ -63,8 +63,8 @@ import org.opendaylight.yangtools.yang.common.Uint32; public class OpendaylightGroupStatisticsServiceImplTest extends AbstractSingleStatsServiceTest { private static final org.opendaylight.yang.gen.v1.urn - .opendaylight.openflow.common.types.rev130731.GroupId GROUP_ID = - new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId(123L); + .opendaylight.openflow.common.types.rev130731.GroupId GROUP_ID = new org.opendaylight.yang.gen.v1.urn + .opendaylight.openflow.common.types.rev130731.GroupId(Uint32.valueOf(123)); @Captor private ArgumentCaptor requestInput; @@ -108,15 +108,15 @@ public class OpendaylightGroupStatisticsServiceImplTest extends AbstractSingleSt rpcResult = RpcResultBuilder.success(Collections.singletonList( new MultipartReplyMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3) + .setVersion(EncodeConstants.OF_VERSION_1_3) .setMultipartReplyBody(new MultipartReplyGroupDescCaseBuilder() .setMultipartReplyGroupDesc(new MultipartReplyGroupDescBuilder() .setGroupDesc(Collections.singletonList(new GroupDescBuilder() .setGroupId(GROUP_ID) .setBucketsList(Collections.singletonList(new BucketsListBuilder() - .setWatchGroup(51L) - .setWatchPort(new PortNumber(52L)) - .setWeight(53) + .setWatchGroup(Uint32.valueOf(51)) + .setWatchPort(new PortNumber(Uint32.valueOf(52))) + .setWeight(Uint16.valueOf(53)) .build())) .setType(GroupType.OFPGTALL) .build())) @@ -141,7 +141,7 @@ public class OpendaylightGroupStatisticsServiceImplTest extends AbstractSingleSt rpcResult = RpcResultBuilder.success(Collections.singletonList( new MultipartReplyMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3) + .setVersion(EncodeConstants.OF_VERSION_1_3) .setMultipartReplyBody(new MultipartReplyGroupFeaturesCaseBuilder() .setMultipartReplyGroupFeatures(new MultipartReplyGroupFeaturesBuilder() .setActionsBitmap(Collections.singletonList(new ActionType(true, @@ -168,7 +168,7 @@ public class OpendaylightGroupStatisticsServiceImplTest extends AbstractSingleSt public void testGetGroupStatistics() throws Exception { GetGroupStatisticsInputBuilder input = new GetGroupStatisticsInputBuilder() .setNode(createNodeRef("unitProt:123")) - .setGroupId(new GroupId(21L)); + .setGroupId(new GroupId(Uint32.valueOf(21))); rpcResult = buildGroupStatsResponse(); @@ -184,19 +184,19 @@ public class OpendaylightGroupStatisticsServiceImplTest extends AbstractSingleSt private static RpcResult buildGroupStatsResponse() { return RpcResultBuilder.success(Collections.singletonList( new MultipartReplyMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3) + .setVersion(EncodeConstants.OF_VERSION_1_3) .setMultipartReplyBody(new MultipartReplyGroupCaseBuilder() .setMultipartReplyGroup(new MultipartReplyGroupBuilder() .setGroupStats(Collections.singletonList(new GroupStatsBuilder() - .setByteCount(BigInteger.valueOf(21L)) - .setPacketCount(BigInteger.valueOf(22L)) - .setRefCount(23L) - .setDurationSec(24L) - .setDurationNsec(25L) + .setByteCount(Uint64.valueOf(21)) + .setPacketCount(Uint64.valueOf(22)) + .setRefCount(Uint32.valueOf(23)) + .setDurationSec(Uint32.valueOf(24)) + .setDurationNsec(Uint32.valueOf(25)) .setGroupId(GROUP_ID) .setBucketStats(Collections.singletonList(new BucketStatsBuilder() - .setByteCount(BigInteger.valueOf(26L)) - .setPacketCount(BigInteger.valueOf(27L)) + .setByteCount(Uint64.valueOf(26)) + .setPacketCount(Uint64.valueOf(27)) .build())) .build())) .build()) diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightMeterStatisticsServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightMeterStatisticsServiceImplTest.java index 792ed116c9..7755cc90a3 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightMeterStatisticsServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightMeterStatisticsServiceImplTest.java @@ -5,14 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.statistics.services; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import com.google.common.util.concurrent.FutureCallback; -import java.math.BigInteger; import java.util.Collections; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicLong; @@ -23,7 +21,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.Captor; import org.mockito.Mockito; -import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder; @@ -55,6 +53,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeaturesBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Test for {@link OpendaylightMeterStatisticsServiceImpl}. @@ -62,13 +63,14 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder; public class OpendaylightMeterStatisticsServiceImplTest extends AbstractSingleStatsServiceTest { private static final org.opendaylight.yang.gen.v1.urn - .opendaylight.openflow.common.types.rev130731.MeterId METER_ID = - new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId(123L); + .opendaylight.openflow.common.types.rev130731.MeterId METER_ID = new org.opendaylight.yang.gen.v1.urn + .opendaylight.openflow.common.types.rev130731.MeterId(Uint32.valueOf(123)); @Captor private ArgumentCaptor requestInput; private OpendaylightMeterStatisticsServiceImpl meterStatisticsService; + @Override public void setUp() { final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager(); meterStatisticsService = new OpendaylightMeterStatisticsServiceImpl(rqContextStack, deviceContext, @@ -90,7 +92,7 @@ public class OpendaylightMeterStatisticsServiceImplTest extends AbstractSingleSt rpcResult = RpcResultBuilder.success(Collections.singletonList( new MultipartReplyMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3) + .setVersion(EncodeConstants.OF_VERSION_1_3) .setMultipartReplyBody(new MultipartReplyMeterConfigCaseBuilder() .setMultipartReplyMeterConfig(new MultipartReplyMeterConfigBuilder() .setMeterConfig(Collections.singletonList(new MeterConfigBuilder() @@ -99,8 +101,8 @@ public class OpendaylightMeterStatisticsServiceImplTest extends AbstractSingleSt .setBands(Collections.singletonList(new BandsBuilder() .setMeterBand(new MeterBandDropCaseBuilder() .setMeterBandDrop(new MeterBandDropBuilder() - .setBurstSize(61L) - .setRate(62L) + .setBurstSize(Uint32.valueOf(61)) + .setRate(Uint32.valueOf(62)) .setType(MeterBandType.OFPMBTDROP) .build()) .build()) @@ -143,14 +145,14 @@ public class OpendaylightMeterStatisticsServiceImplTest extends AbstractSingleSt rpcResult = RpcResultBuilder.success(Collections.singletonList( new MultipartReplyMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3) + .setVersion(EncodeConstants.OF_VERSION_1_3) .setMultipartReplyBody(new MultipartReplyMeterFeaturesCaseBuilder() .setMultipartReplyMeterFeatures(new MultipartReplyMeterFeaturesBuilder() .setBandTypes(new MeterBandTypeBitmap(true, false)) .setCapabilities(new MeterFlags(true, false, false, false)) - .setMaxBands((short) 71) - .setMaxColor((short) 72) - .setMaxMeter(73L) + .setMaxBands(Uint8.valueOf(71)) + .setMaxColor(Uint8.valueOf(72)) + .setMaxMeter(Uint32.valueOf(73)) .build()) .build()) .build() @@ -169,7 +171,7 @@ public class OpendaylightMeterStatisticsServiceImplTest extends AbstractSingleSt public void testGetMeterStatistics() throws Exception { GetMeterStatisticsInputBuilder input = new GetMeterStatisticsInputBuilder() .setNode(createNodeRef("unitProt:123")) - .setMeterId(new MeterId(21L)); + .setMeterId(new MeterId(Uint32.valueOf(21))); rpcResult = buildMeterStatisticsReply(); @@ -185,19 +187,19 @@ public class OpendaylightMeterStatisticsServiceImplTest extends AbstractSingleSt protected RpcResult buildMeterStatisticsReply() { return RpcResultBuilder.success(Collections.singletonList( new MultipartReplyMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3) + .setVersion(EncodeConstants.OF_VERSION_1_3) .setMultipartReplyBody(new MultipartReplyMeterCaseBuilder() .setMultipartReplyMeter(new MultipartReplyMeterBuilder() .setMeterStats(Collections.singletonList(new MeterStatsBuilder() .setMeterId(METER_ID) - .setByteInCount(BigInteger.valueOf(81L)) - .setDurationSec(82L) - .setDurationNsec(83L) - .setFlowCount(84L) - .setPacketInCount(BigInteger.valueOf(85L)) + .setByteInCount(Uint64.valueOf(81)) + .setDurationSec(Uint32.valueOf(82)) + .setDurationNsec(Uint32.valueOf(83)) + .setFlowCount(Uint32.valueOf(84)) + .setPacketInCount(Uint64.valueOf(85)) .setMeterBandStats(Collections.singletonList(new MeterBandStatsBuilder() - .setByteBandCount(BigInteger.valueOf(86L)) - .setPacketBandCount(BigInteger.valueOf(87L)) + .setByteBandCount(Uint64.valueOf(86)) + .setPacketBandCount(Uint64.valueOf(87)) .build())) .build())) .build()) diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightPortStatisticsServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightPortStatisticsServiceImplTest.java index 428f0d387e..d29a35b7fb 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightPortStatisticsServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightPortStatisticsServiceImplTest.java @@ -12,7 +12,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import com.google.common.util.concurrent.FutureCallback; -import java.math.BigInteger; import java.util.Collections; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicLong; @@ -23,7 +22,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.Captor; import org.mockito.Mockito; -import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; @@ -37,6 +36,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.G import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Test for {@link OpendaylightPortStatisticsServiceImpl}. @@ -48,6 +49,7 @@ public class OpendaylightPortStatisticsServiceImplTest extends AbstractSingleSta private OpendaylightPortStatisticsServiceImpl portStatisticsService; + @Override public void setUp() { portStatisticsService = new OpendaylightPortStatisticsServiceImpl(rqContextStack, deviceContext, new AtomicLong(), notificationPublishService); @@ -80,25 +82,25 @@ public class OpendaylightPortStatisticsServiceImplTest extends AbstractSingleSta private static RpcResult buildPortStatisticsReply() { return RpcResultBuilder.success(Collections.singletonList( new MultipartReplyMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3) + .setVersion(EncodeConstants.OF_VERSION_1_3) .setMultipartReplyBody(new MultipartReplyPortStatsCaseBuilder() .setMultipartReplyPortStats(new MultipartReplyPortStatsBuilder() .setPortStats(Collections.singletonList(new PortStatsBuilder() - .setDurationSec(90L) - .setDurationNsec(91L) - .setCollisions(BigInteger.valueOf(92L)) - .setPortNo(93L) - .setRxBytes(BigInteger.valueOf(94L)) - .setRxCrcErr(BigInteger.valueOf(95L)) - .setRxDropped(BigInteger.valueOf(96L)) - .setRxFrameErr(BigInteger.valueOf(97L)) - .setRxErrors(BigInteger.valueOf(98L)) - .setRxOverErr(BigInteger.valueOf(99L)) - .setRxPackets(BigInteger.valueOf(100L)) - .setTxBytes(BigInteger.valueOf(94L)) - .setTxDropped(BigInteger.valueOf(96L)) - .setTxErrors(BigInteger.valueOf(98L)) - .setTxPackets(BigInteger.valueOf(98L)) + .setDurationSec(Uint32.valueOf(90)) + .setDurationNsec(Uint32.valueOf(91)) + .setCollisions(Uint64.valueOf(92)) + .setPortNo(Uint32.valueOf(93)) + .setRxBytes(Uint64.valueOf(94)) + .setRxCrcErr(Uint64.valueOf(95)) + .setRxDropped(Uint64.valueOf(96)) + .setRxFrameErr(Uint64.valueOf(97)) + .setRxErrors(Uint64.valueOf(98)) + .setRxOverErr(Uint64.valueOf(99)) + .setRxPackets(Uint64.valueOf(100)) + .setTxBytes(Uint64.valueOf(94)) + .setTxDropped(Uint64.valueOf(96)) + .setTxErrors(Uint64.valueOf(98)) + .setTxPackets(Uint64.valueOf(98)) .build())) .build()) .build()) diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightQueueStatisticsServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightQueueStatisticsServiceImplTest.java index f3e60fef2b..bd16251848 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightQueueStatisticsServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightQueueStatisticsServiceImplTest.java @@ -5,14 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.statistics.services; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import com.google.common.util.concurrent.FutureCallback; -import java.math.BigInteger; import java.util.Collections; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicLong; @@ -23,7 +21,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.Captor; import org.mockito.Mockito; -import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; @@ -40,6 +38,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216. import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Test for {@link OpendaylightQueueStatisticsServiceImpl}. @@ -51,6 +51,7 @@ public class OpendaylightQueueStatisticsServiceImplTest extends AbstractSingleSt private OpendaylightQueueStatisticsServiceImpl queueStatisticsService; + @Override public void setUp() { queueStatisticsService = new OpendaylightQueueStatisticsServiceImpl(rqContextStack, deviceContext, new AtomicLong(), notificationPublishService); @@ -83,17 +84,17 @@ public class OpendaylightQueueStatisticsServiceImplTest extends AbstractSingleSt protected RpcResult buildQueueStatsReply() { return RpcResultBuilder.success(Collections.singletonList( new MultipartReplyMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3) + .setVersion(EncodeConstants.OF_VERSION_1_3) .setMultipartReplyBody(new MultipartReplyQueueCaseBuilder() .setMultipartReplyQueue(new MultipartReplyQueueBuilder() .setQueueStats(Collections.singletonList(new QueueStatsBuilder() - .setDurationSec(41L) - .setDurationNsec(42L) - .setTxBytes(BigInteger.valueOf(43L)) - .setTxErrors(BigInteger.valueOf(44L)) - .setTxPackets(BigInteger.valueOf(45L)) - .setPortNo(46L) - .setQueueId(47L) + .setDurationSec(Uint32.valueOf(41)) + .setDurationNsec(Uint32.valueOf(42)) + .setTxBytes(Uint64.valueOf(43)) + .setTxErrors(Uint64.valueOf(44)) + .setTxPackets(Uint64.valueOf(45)) + .setPortNo(Uint32.valueOf(46)) + .setQueueId(Uint32.valueOf(47)) .build())) .build()) .build()) @@ -129,7 +130,7 @@ public class OpendaylightQueueStatisticsServiceImplTest extends AbstractSingleSt GetQueueStatisticsFromGivenPortInputBuilder input = new GetQueueStatisticsFromGivenPortInputBuilder() .setNode(createNodeRef("unitProt:123")) .setNodeConnectorId(new NodeConnectorId("unitProt:123:321")) - .setQueueId(new QueueId(21L)); + .setQueueId(new QueueId(Uint32.valueOf(21))); rpcResult = buildQueueStatsReply(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java index 92423c7896..038e14b7fb 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.statistics.services.compatibility; import static org.mockito.ArgumentMatchers.any; @@ -13,7 +12,6 @@ import static org.mockito.ArgumentMatchers.eq; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.ListenableFuture; -import java.math.BigInteger; import java.util.Collections; import java.util.concurrent.atomic.AtomicLong; import org.junit.Assert; @@ -24,6 +22,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.stubbing.Answer; import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.DeviceState; @@ -53,6 +52,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Table import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; import org.opendaylight.yangtools.yang.common.Uint8; /** @@ -123,26 +123,26 @@ public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder() .setNode(createNodeRef("unitProt:123")) - .setTableId(new TableId((short) 1)) + .setTableId(new TableId(Uint8.ONE)) .build(); rpcResult = RpcResultBuilder.success(Collections.singletonList( new MultipartReplyMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3) + .setVersion(EncodeConstants.OF_VERSION_1_3) .setMultipartReplyBody(new MultipartReplyAggregateCaseBuilder() .setMultipartReplyAggregate(new MultipartReplyAggregateBuilder() - .setByteCount(BigInteger.valueOf(11L)) - .setFlowCount(12L) - .setPacketCount(BigInteger.valueOf(13L)) + .setByteCount(Uint64.valueOf(11)) + .setFlowCount(Uint32.valueOf(12)) + .setPacketCount(Uint64.valueOf(13)) .build()) .build()) .build() )).build(); AggregatedFlowStatistics aggregatedStats = new AggregatedFlowStatisticsBuilder() - .setByteCount(new Counter64(BigInteger.valueOf(11L))) - .setFlowCount(new Counter32(12L)) - .setPacketCount(new Counter64(BigInteger.valueOf(13L))) + .setByteCount(new Counter64(Uint64.valueOf(11))) + .setFlowCount(new Counter32(Uint32.valueOf(12))) + .setPacketCount(new Counter64(Uint64.valueOf(13))) .build(); Mockito.when(translator.translate(any(MultipartReply.class), eq(deviceInfo), any())) .thenReturn(aggregatedStats); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImplTest.java index 83574b6c67..b40e2c27cb 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImplTest.java @@ -11,7 +11,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import com.google.common.util.concurrent.FutureCallback; -import java.math.BigInteger; import java.util.Collections; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicLong; @@ -22,7 +21,7 @@ import org.mockito.ArgumentMatchers; import org.mockito.Captor; import org.mockito.Mock; import org.mockito.Mockito; -import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator; import org.opendaylight.openflowplugin.impl.statistics.services.AbstractSingleStatsServiceTest; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager; @@ -61,6 +60,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Table import org.opendaylight.yangtools.yang.binding.Notification; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; /** * Test for {@link OpendaylightFlowStatisticsServiceDelegateImpl}. @@ -97,24 +100,24 @@ public class OpendaylightFlowStatisticsServiceDelegateImplTest extends AbstractS GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder() .setNode(createNodeRef("unitProt:123")) - .setTableId(new TableId((short) 1)); + .setTableId(new TableId(Uint8.ONE)); Mockito.when(translator.translate(any(MultipartReply.class), eq(deviceInfo),any())) .thenReturn(new AggregatedFlowStatisticsBuilder() - .setByteCount(new Counter64(BigInteger.valueOf(50L))) - .setPacketCount(new Counter64(BigInteger.valueOf(51L))) - .setFlowCount(new Counter32(52L)) + .setByteCount(new Counter64(Uint64.valueOf(50))) + .setPacketCount(new Counter64(Uint64.valueOf(51))) + .setFlowCount(new Counter32(Uint32.valueOf(52))) .build()); rpcResult = RpcResultBuilder.success(Collections.singletonList(new MultipartReplyMessageBuilder() .setType(MultipartType.OFPMPAGGREGATE) - .setVersion(OFConstants.OFP_VERSION_1_3) + .setVersion(EncodeConstants.OF_VERSION_1_3) .setFlags(new MultipartRequestFlags(false)) .setMultipartReplyBody(new MultipartReplyAggregateCaseBuilder() .setMultipartReplyAggregate(new MultipartReplyAggregateBuilder() - .setByteCount(BigInteger.valueOf(50L)) - .setPacketCount(BigInteger.valueOf(51L)) - .setFlowCount(52L) + .setByteCount(Uint64.valueOf(50)) + .setPacketCount(Uint64.valueOf(51)) + .setFlowCount(Uint32.valueOf(52)) .build()) .build()) .build())) @@ -137,7 +140,7 @@ public class OpendaylightFlowStatisticsServiceDelegateImplTest extends AbstractS public void testGetAllFlowStatisticsFromFlowTable() throws Exception { GetAllFlowStatisticsFromFlowTableInputBuilder input = new GetAllFlowStatisticsFromFlowTableInputBuilder() .setNode(createNodeRef("unitProt:123")) - .setTableId(new TableId((short) 1)); + .setTableId(new TableId(Uint8.ONE)); rpcResult = buildFlowStatsReply(); @@ -156,42 +159,39 @@ public class OpendaylightFlowStatisticsServiceDelegateImplTest extends AbstractS private static RpcResult buildFlowStatsReply() { return RpcResultBuilder.success(Collections.singletonList(new MultipartReplyMessageBuilder() .setType(MultipartType.OFPMPFLOW) - .setVersion(OFConstants.OFP_VERSION_1_3) + .setVersion(EncodeConstants.OF_VERSION_1_3) .setFlags(new MultipartRequestFlags(false)) .setMultipartReplyBody(new MultipartReplyFlowCaseBuilder() - .setMultipartReplyFlow(new MultipartReplyFlowBuilder() - .setFlowStats(Collections.singletonList(new FlowStatsBuilder() - .setTableId((short) 123) - .setDurationSec(10L) - .setDurationNsec(11L) - .setByteCount(BigInteger.valueOf(12L)) - .setPacketCount(BigInteger.valueOf(13L)) - .setCookie(BigInteger.ZERO) - .setPriority(14) - .setMatch(new MatchBuilder() - .setMatchEntry(Collections.emptyList()) + .setMultipartReplyFlow(new MultipartReplyFlowBuilder() + .setFlowStats(Collections.singletonList(new FlowStatsBuilder() + .setTableId(Uint8.valueOf(123)) + .setDurationSec(Uint32.TEN) + .setDurationNsec(Uint32.valueOf(11)) + .setByteCount(Uint64.valueOf(12)) + .setPacketCount(Uint64.valueOf(13)) + .setCookie(Uint64.ZERO) + .setPriority(Uint16.valueOf(14)) + .setMatch(new MatchBuilder().setMatchEntry(Collections.emptyList()).build()) + .setHardTimeout(Uint16.valueOf(15)) + .setIdleTimeout(Uint16.valueOf(16)) + .setFlags(new FlowModFlags(true, false, false, false, false)) + .setInstruction(Collections.singletonList(new InstructionBuilder() + .setInstructionChoice(new ApplyActionsCaseBuilder() + .setApplyActions(new ApplyActionsBuilder() + .setAction(Collections.singletonList(new ActionBuilder() + .setActionChoice(new OutputActionCaseBuilder() + .setOutputAction(new OutputActionBuilder() + .setMaxLength(Uint16.valueOf(17)) + .setPort(new PortNumber(Uint32.valueOf(18))) + .build()) .build()) - .setHardTimeout(15) - .setIdleTimeout(16) - .setFlags(new FlowModFlags(true, false, false, false, false)) - .setInstruction(Collections.singletonList(new InstructionBuilder() - .setInstructionChoice(new ApplyActionsCaseBuilder() - .setApplyActions(new ApplyActionsBuilder() - .setAction(Collections.singletonList(new ActionBuilder() - .setActionChoice(new OutputActionCaseBuilder() - .setOutputAction( - new OutputActionBuilder() - .setMaxLength(17) - .setPort(new PortNumber(18L)) - .build()) - .build()) - .build())) - .build()) - .build()) - .build())) - .build())) - .build()) + .build())) + .build()) + .build()) + .build())) + .build())) .build()) + .build()) .build())) .build(); } @@ -220,9 +220,9 @@ public class OpendaylightFlowStatisticsServiceDelegateImplTest extends AbstractS public void testGetFlowStatisticsFromFlowTable() throws Exception { GetFlowStatisticsFromFlowTableInputBuilder input = new GetFlowStatisticsFromFlowTableInputBuilder() .setNode(createNodeRef("unitProt:123")) - .setTableId((short) 1) - .setPriority(123) - .setOutPort(BigInteger.ONE); + .setTableId(Uint8.ONE) + .setPriority(Uint16.valueOf(123)) + .setOutPort(Uint64.ONE); rpcResult = buildFlowStatsReply(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java index abef161477..6d837e7545 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java @@ -15,7 +15,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.math.BigInteger; import java.util.Collections; import java.util.List; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; @@ -40,6 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlow; import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; import org.opendaylight.yangtools.yang.common.Uint8; public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { @@ -78,11 +78,11 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer final MultipartReplyFlowCase flowCase = mock(MultipartReplyFlowCase.class); final MultipartReplyFlow flow = mock(MultipartReplyFlow.class); final FlowStats flowStat = new FlowStatsBuilder() - .setDurationSec(1L) - .setDurationNsec(1L) + .setDurationSec(Uint32.ONE) + .setDurationNsec(Uint32.ONE) .setTableId(TABLE_NO) - .setByteCount(BigInteger.ONE) - .setPacketCount(BigInteger.ONE) + .setByteCount(Uint64.ONE) + .setPacketCount(Uint64.ONE) .setFlags(mock(FlowModFlags.class)) .setMatch(new org.opendaylight.yang.gen.v1.urn .opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder() diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java index bfab2a3667..7a49170985 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java @@ -16,7 +16,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.math.BigInteger; import java.util.Collections; import java.util.List; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; @@ -35,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroup; import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; public class GroupDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { static final Uint32 GROUP_NO = Uint32.ONE; @@ -72,12 +72,12 @@ public class GroupDirectStatisticsServiceTest extends AbstractDirectStatisticsSe final GroupStats groupStat = new GroupStatsBuilder() .setGroupId(new org.opendaylight.yang.gen.v1.urn .opendaylight.openflow.common.types.rev130731.GroupId(GROUP_NO)) - .setByteCount(BigInteger.ONE) - .setPacketCount(BigInteger.ONE) + .setByteCount(Uint64.ONE) + .setPacketCount(Uint64.ONE) .setBucketStats(Collections.emptyList()) - .setDurationSec(1L) - .setDurationNsec(1L) - .setRefCount(0L) + .setDurationSec(Uint32.ONE) + .setDurationNsec(Uint32.ONE) + .setRefCount(Uint32.ZERO) .build(); final List groupStats = Collections.singletonList(groupStat); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java index b793bdfe7f..19723c0f45 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java @@ -15,7 +15,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.math.BigInteger; import java.util.Collections; import java.util.List; import java.util.Map; @@ -36,6 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeter; import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { static final Uint32 METER_NO = Uint32.valueOf(1); @@ -68,8 +68,9 @@ public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsSe final MultipartReplyMeter meter = mock(MultipartReplyMeter.class); final MeterStats meterStat = new MeterStatsBuilder().setMeterId( new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId(METER_NO)) - .setByteInCount(BigInteger.ONE).setPacketInCount(BigInteger.ONE).setDurationSec(1L).setDurationNsec(1L) - .setFlowCount(0L).setMeterBandStats(Collections.emptyList()).build(); + .setByteInCount(Uint64.ONE).setPacketInCount(Uint64.ONE).setDurationSec(Uint32.ONE) + .setDurationNsec(Uint32.ONE).setFlowCount(Uint32.ZERO).setMeterBandStats(Collections.emptyList()) + .build(); final List meterStats = Collections.singletonList(meterStat); final List input = Collections.singletonList(reply); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java index f19e2a537b..39008083ad 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java @@ -15,7 +15,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.math.BigInteger; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -83,12 +82,12 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer public void testBuildReply() { final FlowAndStatisticsMapList flowStat = new FlowAndStatisticsMapListBuilder() .setDuration(new DurationBuilder() - .setSecond(new Counter32(1L)) - .setNanosecond(new Counter32(2L)) + .setSecond(new Counter32(Uint32.ONE)) + .setNanosecond(new Counter32(Uint32.TWO)) .build()) .setTableId(Uint8.valueOf(50)) - .setByteCount(new Counter64(BigInteger.valueOf(7094))) - .setPacketCount(new Counter64(BigInteger.valueOf(63))) + .setByteCount(new Counter64(Uint64.valueOf(7094))) + .setPacketCount(new Counter64(Uint64.valueOf(63))) .setCookie(new FlowCookie(Uint64.valueOf(134419365))) .setFlags(new FlowModFlags(true, false, false, false, false)) .setMatch(new MatchBuilder().setEthernetMatch( @@ -110,12 +109,12 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer final FlowAndStatisticsMapList flowStat1 = new FlowAndStatisticsMapListBuilder() .setDuration(new DurationBuilder() - .setSecond(new Counter32(1L)) - .setNanosecond(new Counter32(2L)) + .setSecond(new Counter32(Uint32.ONE)) + .setNanosecond(new Counter32(Uint32.TWO)) .build()) .setTableId(Uint8.valueOf(51)) - .setByteCount(new Counter64(BigInteger.valueOf(9853))) - .setPacketCount(new Counter64(BigInteger.valueOf(99))) + .setByteCount(new Counter64(Uint64.valueOf(9853))) + .setPacketCount(new Counter64(Uint64.valueOf(99))) .setCookie(new FlowCookie(Uint64.valueOf(134550437))) .setFlags(new FlowModFlags(true, false, false, false, false)) .setMatch(new MatchBuilder().setEthernetMatch( diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java index 5087f4b09a..8db9b35066 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java @@ -70,7 +70,7 @@ public class GroupDirectStatisticsServiceTest extends AbstractDirectStatisticsSe final MultipartReply reply = new MultipartReplyBuilder() .setMultipartReplyBody(new MultipartReplyGroupStatsBuilder() - .setGroupStats(Collections.singletonList(groupStat)) + .setGroupStats(Collections.singletonMap(groupStat.key(), groupStat)) .build()) .build(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java index 4af0163a39..e9806c3a0a 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java @@ -16,7 +16,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.math.BigInteger; import java.util.Collections; import java.util.List; import java.util.Map; @@ -40,6 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.M import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { static final Uint32 METER_NO = Uint32.ONE; @@ -71,19 +71,19 @@ public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsSe public void testBuildReply() { final MeterStats meterStat = new MeterStatsBuilder() .setMeterId(new MeterId(METER_NO)) - .setByteInCount(new Counter64(BigInteger.ONE)) - .setPacketInCount(new Counter64(BigInteger.ONE)) + .setByteInCount(new Counter64(Uint64.ONE)) + .setPacketInCount(new Counter64(Uint64.ONE)) .setDuration(new DurationBuilder() - .setSecond(new Counter32(1L)) - .setNanosecond(new Counter32(1L)) + .setSecond(new Counter32(Uint32.ONE)) + .setNanosecond(new Counter32(Uint32.ONE)) .build()) - .setFlowCount(new Counter32(0L)) + .setFlowCount(new Counter32(Uint32.ZERO)) .setMeterBandStats(new MeterBandStatsBuilder().build()) .build(); final MultipartReply reply = new MultipartReplyBuilder() .setMultipartReplyBody(new MultipartReplyMeterStatsBuilder() - .setMeterStats(Collections.singletonList(meterStat)) + .setMeterStats(Collections.singletonMap(meterStat.key(), meterStat)) .build()) .build(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java index 0ea3df60de..137d78bd66 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java @@ -16,7 +16,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.math.BigInteger; import java.util.Collections; import java.util.List; import java.util.Map; @@ -39,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216. import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapKey; import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { static final Uint32 QUEUE_NO = Uint32.ONE; @@ -73,14 +73,14 @@ public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsSe final QueueIdAndStatisticsMap queueStats = new QueueIdAndStatisticsMapBuilder() .setQueueId(new QueueId(QUEUE_NO)) .setNodeConnectorId(new NodeConnectorId(PORT_NO.toString())) - .setTransmittedBytes(new Counter64(BigInteger.ONE)) - .setTransmissionErrors(new Counter64(BigInteger.ONE)) - .setTransmittedBytes(new Counter64(BigInteger.ONE)) + .setTransmittedBytes(new Counter64(Uint64.ONE)) + .setTransmissionErrors(new Counter64(Uint64.ONE)) + .setTransmittedBytes(new Counter64(Uint64.ONE)) .build(); final MultipartReply reply = new MultipartReplyBuilder() .setMultipartReplyBody(new MultipartReplyQueueStatsBuilder() - .setQueueIdAndStatisticsMap(Collections.singletonList(queueStats)) + .setQueueIdAndStatisticsMap(Collections.singletonMap(queueStats.key(), queueStats)) .build()) .build(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/AggregatedFlowStatisticsTranslatorTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/AggregatedFlowStatisticsTranslatorTest.java index 2d7bf13784..e2e52c32c5 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/AggregatedFlowStatisticsTranslatorTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/AggregatedFlowStatisticsTranslatorTest.java @@ -5,10 +5,8 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.translator; -import java.math.BigInteger; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -20,6 +18,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.g import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Test of {@link AggregatedFlowStatisticsTranslator}. @@ -39,9 +39,9 @@ public class AggregatedFlowStatisticsTranslatorTest { @Test public void testTranslate() { MultipartReplyAggregateBuilder aggregateStatsValueBld = new MultipartReplyAggregateBuilder() - .setByteCount(BigInteger.valueOf(1L)) - .setFlowCount(2L) - .setPacketCount(BigInteger.valueOf(3L)); + .setByteCount(Uint64.ONE) + .setFlowCount(Uint32.TWO) + .setPacketCount(Uint64.valueOf(3)); MultipartReplyAggregateCaseBuilder inputBld = new MultipartReplyAggregateCaseBuilder() .setMultipartReplyAggregate(aggregateStatsValueBld.build()); MultipartReplyMessageBuilder mpInputBld = new MultipartReplyMessageBuilder() diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslatorTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslatorTest.java index 47ec4c15f6..21e8b54d07 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslatorTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslatorTest.java @@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.impl.translator; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; -import java.math.BigInteger; import java.util.Collections; import org.junit.Before; import org.junit.Test; @@ -37,6 +36,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; /** * Test of {@link AggregatedFlowStatisticsTranslator}. @@ -100,15 +102,15 @@ public class FlowRemovedTranslatorTest { private org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved buildMessage(final boolean isV10) { FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder() - .setCookie(BigInteger.ONE) + .setCookie(Uint64.ONE) .setReason(FlowRemovedReason.OFPRRGROUPDELETE) - .setPriority(1); + .setPriority(Uint16.ONE); if (isV10) { builder.setMatchV10(new MatchV10Builder().setWildcards(flowWildcards).build()); } else { builder.setMatch(new MatchBuilder().setMatchEntry(Collections.emptyList()).build()) - .setTableId(new TableId(42L)); + .setTableId(new TableId(Uint32.valueOf(42))); } return builder.build(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslatorTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslatorTest.java index 5ab9c03738..95c083818b 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslatorTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslatorTest.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowplugin.impl.translator; import com.google.common.collect.Lists; -import java.math.BigInteger; import java.util.Collections; import java.util.List; import org.junit.Assert; @@ -19,7 +18,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; @@ -49,6 +48,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived; import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint64; @RunWith(MockitoJUnitRunner.class) @@ -114,12 +114,12 @@ public class PacketReceivedTranslatorTest { .setMatchEntry(Lists.newArrayList(matchEntryBuilder.build())); return new PacketInMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_0) + .setVersion(EncodeConstants.OF_VERSION_1_0) .setData(data).setReason(reason) .setMatch(packetInMatchBld.build()) - .setVersion(OFConstants.OFP_VERSION_1_3) - .setCookie(BigInteger.ZERO) - .setTableId(new TableId(42L)) + .setVersion(EncodeConstants.OF_VERSION_1_3) + .setCookie(Uint64.ZERO) + .setTableId(new TableId(Uint32.valueOf(42))) .build(); } @@ -131,9 +131,9 @@ public class PacketReceivedTranslatorTest { .setMatchEntry(Lists.newArrayList(matchEntryBuilder.build())); PacketInMessageBuilder inputBld = new PacketInMessageBuilder() .setMatch(packetInMatchBld.build()) - .setVersion(OFConstants.OFP_VERSION_1_3); + .setVersion(EncodeConstants.OF_VERSION_1_3); final PacketReceivedTranslator packetReceivedTranslator = new PacketReceivedTranslator(convertorManager); - final Match packetInMatch = packetReceivedTranslator.getPacketInMatch(inputBld.build(), Uint64.valueOf(10)); + final Match packetInMatch = packetReceivedTranslator.getPacketInMatch(inputBld.build(), Uint64.TEN); Assert.assertNotNull(packetInMatch.getInPort()); Assert.assertEquals("openflow:10:" + PORT_NUM_VALUE, packetInMatch.getInPort().getValue()); @@ -141,7 +141,7 @@ public class PacketReceivedTranslatorTest { private static MatchEntryBuilder assembleMatchEntryBld(final long portNumValue) { MatchEntryBuilder matchEntryBuilder = prepareHeader(InPort.class, false); - InPortBuilder inPortBld = new InPortBuilder().setPortNumber(new PortNumber(portNumValue)); + InPortBuilder inPortBld = new InPortBuilder().setPortNumber(new PortNumber(Uint32.valueOf(portNumValue))); InPortCaseBuilder caseBuilder = new InPortCaseBuilder(); caseBuilder.setInPort(inPortBld.build()); matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslatorTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslatorTest.java index 46febc66c9..5e90ff8fb3 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslatorTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslatorTest.java @@ -28,6 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test of {@link PortUpdateTranslator}. @@ -118,7 +119,7 @@ public class PortUpdateTranslatorTest { final PortStateV10 portState10 = PortStateV10.getDefaultInstance("live"); return new PortStatusMessageBuilder() - .setPortNo(portNoValue) + .setPortNo(Uint32.valueOf(portNoValue)) .setReason(PortReason.OFPPRADD) .setAdvertisedFeatures(portFeatures13) .setAdvertisedFeaturesV10(portFeatures10) @@ -132,9 +133,9 @@ public class PortUpdateTranslatorTest { .setStateV10(portState10) .setSupportedFeatures(portFeatures13) .setSupportedFeaturesV10(portFeatures10) - .setCurrSpeed(speed) + .setCurrSpeed(Uint32.valueOf(speed)) .setHwAddr(new MacAddress("01:02:03:04:05:06")) - .setMaxSpeed(2 * speed) + .setMaxSpeed(Uint32.valueOf(2 * speed)) .setName("utPortName:" + portNoValue); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtilTest.java index f01fcebffd..8703573b00 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtilTest.java @@ -43,14 +43,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint8; @RunWith(MockitoJUnitRunner.class) public class DeviceInitializationUtilTest { private static final KeyedInstanceIdentifier NODE_II = DeviceStateUtil .createNodeInstanceIdentifier(new NodeId("openflow:1")); - private static final int PORT = 2017; - private static final InetSocketAddress INET_SOCKET_ADDRESS = new InetSocketAddress("192.168.0.1", PORT); + private static final Uint16 PORT = Uint16.valueOf(2017); + private static final InetSocketAddress INET_SOCKET_ADDRESS = new InetSocketAddress("192.168.0.1", PORT.intValue()); private static final Uint8 TABLES = Uint8.valueOf(25); @Mock diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtilTest.java index d86e757bd5..85ca2fe344 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtilTest.java @@ -216,11 +216,11 @@ public class FlatBatchUtilTest { } } - private Batch createBatch(BatchStepType type) { + private static Batch createBatch(BatchStepType type) { return createBatch(type, 1); } - private Batch createBatch(BatchStepType type, final int size) { + private static Batch createBatch(BatchStepType type, final int size) { final BatchChoice batchCase; switch (type) { case FLOW_ADD: @@ -281,7 +281,7 @@ public class FlatBatchUtilTest { private static List repeatFlatBatchAddGroupIntoList(final int size) { final List list = new ArrayList<>(); for (int i = 0; i < size; i++) { - list.add(new FlatBatchAddGroupBuilder().withKey(new FlatBatchAddGroupKey(i)).build()); + list.add(new FlatBatchAddGroupBuilder().withKey(new FlatBatchAddGroupKey(Uint16.valueOf(i))).build()); } return list; } @@ -289,7 +289,7 @@ public class FlatBatchUtilTest { private static List repeatFlatBatchUpdateGroupIntoList(final int size) { final List list = new ArrayList<>(); for (int i = 0; i < size; i++) { - list.add(new FlatBatchUpdateGroupBuilder().withKey(new FlatBatchUpdateGroupKey(i)).build()); + list.add(new FlatBatchUpdateGroupBuilder().withKey(new FlatBatchUpdateGroupKey(Uint16.valueOf(i))).build()); } return list; } @@ -297,7 +297,7 @@ public class FlatBatchUtilTest { private static List repeatFlatBatchRemoveGroupIntoList(final int size) { final List list = new ArrayList<>(); for (int i = 0; i < size; i++) { - list.add(new FlatBatchRemoveGroupBuilder().withKey(new FlatBatchRemoveGroupKey(i)).build()); + list.add(new FlatBatchRemoveGroupBuilder().withKey(new FlatBatchRemoveGroupKey(Uint16.valueOf(i))).build()); } return list; } @@ -305,7 +305,7 @@ public class FlatBatchUtilTest { private static List repeatFlatBatchAddFlowIntoList(final int size) { final List list = new ArrayList<>(); for (int i = 0; i < size; i++) { - list.add(new FlatBatchAddFlowBuilder().withKey(new FlatBatchAddFlowKey(i)).build()); + list.add(new FlatBatchAddFlowBuilder().withKey(new FlatBatchAddFlowKey(Uint16.valueOf(i))).build()); } return list; } @@ -313,7 +313,7 @@ public class FlatBatchUtilTest { private static List repeatFlatBatchUpdateFlowIntoList(final int size) { final List list = new ArrayList<>(); for (int i = 0; i < size; i++) { - list.add(new FlatBatchUpdateFlowBuilder().withKey(new FlatBatchUpdateFlowKey(i)).build()); + list.add(new FlatBatchUpdateFlowBuilder().withKey(new FlatBatchUpdateFlowKey(Uint16.valueOf(i))).build()); } return list; } @@ -321,7 +321,7 @@ public class FlatBatchUtilTest { private static List repeatFlatBatchRemoveFlowIntoList(final int size) { final List list = new ArrayList<>(); for (int i = 0; i < size; i++) { - list.add(new FlatBatchRemoveFlowBuilder().withKey(new FlatBatchRemoveFlowKey(i)).build()); + list.add(new FlatBatchRemoveFlowBuilder().withKey(new FlatBatchRemoveFlowKey(Uint16.valueOf(i))).build()); } return list; } @@ -329,7 +329,7 @@ public class FlatBatchUtilTest { private static List repeatFlatBatchAddMeterIntoList(final int size) { final List list = new ArrayList<>(); for (int i = 0; i < size; i++) { - list.add(new FlatBatchAddMeterBuilder().withKey(new FlatBatchAddMeterKey(i)).build()); + list.add(new FlatBatchAddMeterBuilder().withKey(new FlatBatchAddMeterKey(Uint16.valueOf(i))).build()); } return list; } @@ -337,7 +337,7 @@ public class FlatBatchUtilTest { private static List repeatFlatBatchUpdateMeterIntoList(final int size) { final List list = new ArrayList<>(); for (int i = 0; i < size; i++) { - list.add(new FlatBatchUpdateMeterBuilder().withKey(new FlatBatchUpdateMeterKey(i)).build()); + list.add(new FlatBatchUpdateMeterBuilder().withKey(new FlatBatchUpdateMeterKey(Uint16.valueOf(i))).build()); } return list; } @@ -345,7 +345,7 @@ public class FlatBatchUtilTest { private static List repeatFlatBatchRemoveMeterIntoList(final int size) { final List list = new ArrayList<>(); for (int i = 0; i < size; i++) { - list.add(new FlatBatchRemoveMeterBuilder().withKey(new FlatBatchRemoveMeterKey(i)).build()); + list.add(new FlatBatchRemoveMeterBuilder().withKey(new FlatBatchRemoveMeterKey(Uint16.valueOf(i))).build()); } return list; } @@ -353,14 +353,14 @@ public class FlatBatchUtilTest { @Test public void testMergeJobsResultsFutures() { final BatchFailure batchFailure = new BatchFailureBuilder() - .setBatchOrder(9) + .setBatchOrder(Uint16.valueOf(9)) .setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder() .setFlowId(new FlowId("11")) .build()) .withKey(new BatchFailureKey(Uint16.ZERO)) .build(); final BatchFailure batchFailure_1 = new BatchFailureBuilder() - .setBatchOrder(9) + .setBatchOrder(Uint16.valueOf(9)) .setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder() .setFlowId(new FlowId("11")) .build()) diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowCreatorUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowCreatorUtilTest.java index 0c93c1cedc..1e7e87d51f 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowCreatorUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowCreatorUtilTest.java @@ -11,7 +11,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import java.math.BigInteger; import org.junit.Test; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; @@ -33,6 +32,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlow; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; public class FlowCreatorUtilTest { @@ -86,15 +88,15 @@ public class FlowCreatorUtilTest { final Short[] versions = {null, of10, of13}; final Boolean[] bools = {null, Boolean.TRUE, Boolean.FALSE}; - final Integer defPri = Integer.valueOf(0x8000); - final Integer defIdle = Integer.valueOf(0); - final Integer defHard = Integer.valueOf(0); + final Uint16 defPri = Uint16.valueOf(0x8000); + final Uint16 defIdle = Uint16.ZERO; + final Uint16 defHard = Uint16.ZERO; final FlowModFlags defFlags = FlowModFlags.getDefaultInstance("sENDFLOWREM"); final FlowModFlags flags = new FlowModFlags(false, true, false, true, false); - final FlowCookie defCookie = new FlowCookie(BigInteger.ZERO); - final FlowCookie cookie = new FlowCookie(BigInteger.valueOf(0x12345L)); - final FlowCookie cookie1 = new FlowCookie(BigInteger.valueOf(0x67890L)); - final FlowCookie cookieMask = new FlowCookie(BigInteger.valueOf(0xffff00L)); + final FlowCookie defCookie = new FlowCookie(Uint64.ZERO); + final FlowCookie cookie = new FlowCookie(Uint64.valueOf(0x12345)); + final FlowCookie cookie1 = new FlowCookie(Uint64.valueOf(0x67890)); + final FlowCookie cookieMask = new FlowCookie(Uint64.valueOf(0xffff00)); for (final Short ver : versions) { final OriginalFlowBuilder originalBuilder = new OriginalFlowBuilder(); @@ -116,9 +118,12 @@ public class FlowCreatorUtilTest { // Set non-default values. canModifyFlowTest(true, originalBuilder.setMatch(createMatch(0x800L)), updatedBuilder.setMatch(createMatch(0x800L)), ver); - canModifyFlowTest(true, originalBuilder.setIdleTimeout(600), updatedBuilder.setIdleTimeout(600), ver); - canModifyFlowTest(true, originalBuilder.setHardTimeout(1200), updatedBuilder.setHardTimeout(1200), ver); - canModifyFlowTest(true, originalBuilder.setPriority(100), updatedBuilder.setPriority(100), ver); + canModifyFlowTest(true, originalBuilder.setIdleTimeout(Uint16.valueOf(600)), + updatedBuilder.setIdleTimeout(Uint16.valueOf(600)), ver); + canModifyFlowTest(true, originalBuilder.setHardTimeout(Uint16.valueOf(1200)), + updatedBuilder.setHardTimeout(Uint16.valueOf(1200)), ver); + canModifyFlowTest(true, originalBuilder.setPriority(Uint16.valueOf(100)), + updatedBuilder.setPriority(Uint16.valueOf(100)), ver); canModifyFlowTest(true, originalBuilder.setFlags(flags), updatedBuilder.setFlags(flags), ver); canModifyFlowTest(true, originalBuilder.setCookie(cookie), updatedBuilder.setCookie(cookie), ver); @@ -136,14 +141,15 @@ public class FlowCreatorUtilTest { // Set different idle-timeout, hard-timeout, priority. final Integer[] integers = {null, Integer.valueOf(3600)}; for (final Integer i : integers) { - canModifyFlowTest(false, originalBuilder, new UpdatedFlowBuilder(upd).setIdleTimeout(i), ver); - canModifyFlowTest(false, new OriginalFlowBuilder(org).setIdleTimeout(i), updatedBuilder, ver); + final Uint16 uint = i == null ? null : Uint16.valueOf(i.intValue()); + canModifyFlowTest(false, originalBuilder, new UpdatedFlowBuilder(upd).setIdleTimeout(uint), ver); + canModifyFlowTest(false, new OriginalFlowBuilder(org).setIdleTimeout(uint), updatedBuilder, ver); - canModifyFlowTest(false, originalBuilder, new UpdatedFlowBuilder(upd).setHardTimeout(i), ver); - canModifyFlowTest(false, new OriginalFlowBuilder(org).setHardTimeout(i), updatedBuilder, ver); + canModifyFlowTest(false, originalBuilder, new UpdatedFlowBuilder(upd).setHardTimeout(uint), ver); + canModifyFlowTest(false, new OriginalFlowBuilder(org).setHardTimeout(uint), updatedBuilder, ver); - canModifyFlowTest(false, originalBuilder, new UpdatedFlowBuilder(upd).setPriority(i), ver); - canModifyFlowTest(false, new OriginalFlowBuilder(org).setPriority(i), updatedBuilder, ver); + canModifyFlowTest(false, originalBuilder, new UpdatedFlowBuilder(upd).setPriority(uint), ver); + canModifyFlowTest(false, new OriginalFlowBuilder(org).setPriority(uint), updatedBuilder, ver); } // Set different FLOW_MOD flags. @@ -154,7 +160,7 @@ public class FlowCreatorUtilTest { } // Set different cookie. - final FlowCookie[] cookies = {null, defCookie, new FlowCookie(BigInteger.valueOf(0x123456L)),}; + final FlowCookie[] cookies = {null, defCookie, new FlowCookie(Uint64.valueOf(0x123456L)),}; for (final FlowCookie c : cookies) { canModifyFlowTest(false, originalBuilder, new UpdatedFlowBuilder(upd).setCookie(c), ver); canModifyFlowTest(false, new OriginalFlowBuilder(org).setCookie(c), updatedBuilder, ver); @@ -171,7 +177,7 @@ public class FlowCreatorUtilTest { canModifyFlowTest(false, originalBuilder, updatedBuilder, ver); updatedBuilder.setCookieMask(cookieMask); - final boolean expected = (of13.equals(ver) && !Boolean.TRUE.equals(strict)); + final boolean expected = of13.equals(ver) && !Boolean.TRUE.equals(strict); canModifyFlowTest(expected, originalBuilder, updatedBuilder, ver); } } @@ -213,11 +219,11 @@ public class FlowCreatorUtilTest { assertEquals(expected, FlowCreatorUtil.equalsFlowModFlags(f, flags)); } - final boolean overlap = (bit == 0); - final boolean noByte = (bit == 1); - final boolean noPacket = (bit == 2); - final boolean reset = (bit == 3); - final boolean flowRem = (bit == 4); + final boolean overlap = bit == 0; + final boolean noByte = bit == 1; + final boolean noPacket = bit == 2; + final boolean reset = bit == 3; + final boolean flowRem = bit == 4; FlowModFlags flowModFlags = new FlowModFlags(overlap, noByte, noPacket, reset, flowRem); assertTrue(FlowCreatorUtil.equalsFlowModFlags(flags, flowModFlags)); assertTrue(FlowCreatorUtil.equalsFlowModFlags(flowModFlags, flags)); @@ -331,7 +337,7 @@ public class FlowCreatorUtilTest { */ private static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match createMatch( final long etherType) { - final EthernetTypeBuilder ethType = new EthernetTypeBuilder().setType(new EtherType(etherType)); + final EthernetTypeBuilder ethType = new EthernetTypeBuilder().setType(new EtherType(Uint32.valueOf(etherType))); final EthernetMatchBuilder ether = new EthernetMatchBuilder().setEthernetType(ethType.build()); return new MatchBuilder().setEthernetMatch(ether.build()).build(); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java index 361c344933..d836ca9498 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java @@ -43,8 +43,8 @@ import org.opendaylight.yangtools.yang.common.Uint32; public class GroupUtilTest { private static final NodeId DUMMY_NODE_ID = new NodeId("dummyNodeId"); - private static final GroupId DUMMY_GROUP_ID = new GroupId(42L); - private static final GroupId DUMMY_GROUP_ID_2 = new GroupId(43L); + private static final GroupId DUMMY_GROUP_ID = new GroupId(Uint32.valueOf(42)); + private static final GroupId DUMMY_GROUP_ID_2 = new GroupId(Uint32.valueOf(43)); private static final long GROUP_ACTION_BITMAP = 0b00000000000000000000000000000000000001111111111111001100000000001L; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MatchNormalizationUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MatchNormalizationUtilTest.java index 49c26c5c7c..e100b66c65 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MatchNormalizationUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MatchNormalizationUtilTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.util; import static org.junit.Assert.assertEquals; @@ -37,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask; +import org.opendaylight.yangtools.yang.common.Uint16; public class MatchNormalizationUtilTest { @Test @@ -70,7 +70,7 @@ public class MatchNormalizationUtilTest { final MatchBuilder matchBuilder = MatchNormalizationUtil.normalizeArpMatch(new MatchBuilder() .setLayer3Match(new ArpMatchBuilder() - .setArpOp(10) + .setArpOp(Uint16.TEN) .setArpSourceTransportAddress(new Ipv4Prefix(source)) .setArpTargetTransportAddress(new Ipv4Prefix(destination)) .setArpTargetHardwareAddress(new ArpTargetHardwareAddressBuilder() diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MatchUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MatchUtilTest.java index 20f92a4f12..49b6155ba2 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MatchUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MatchUtilTest.java @@ -14,6 +14,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint8; public class MatchUtilTest { @@ -28,23 +30,21 @@ public class MatchUtilTest { } private static MatchV10Builder expectedV10Match() { - Short zeroShort = Short.valueOf("0"); - Integer zeroInteger = 0; MatchV10Builder matchV10Builder = new MatchV10Builder(); matchV10Builder.setDlDst(ZERO_MAC_ADDRESS); matchV10Builder.setDlSrc(ZERO_MAC_ADDRESS); - matchV10Builder.setDlType(zeroInteger); - matchV10Builder.setDlVlan(zeroInteger); - matchV10Builder.setDlVlanPcp(zeroShort); - matchV10Builder.setInPort(zeroInteger); + matchV10Builder.setDlType(Uint16.ZERO); + matchV10Builder.setDlVlan(Uint16.ZERO); + matchV10Builder.setDlVlanPcp(Uint8.ZERO); + matchV10Builder.setInPort(Uint16.ZERO); matchV10Builder.setNwDst(ZERO_IPV4_ADDRESS); - matchV10Builder.setNwDstMask(zeroShort); - matchV10Builder.setNwProto(zeroShort); + matchV10Builder.setNwDstMask(Uint8.ZERO); + matchV10Builder.setNwProto(Uint8.ZERO); matchV10Builder.setNwSrc(ZERO_IPV4_ADDRESS); - matchV10Builder.setNwSrcMask(zeroShort); - matchV10Builder.setNwTos(zeroShort); - matchV10Builder.setTpDst(zeroInteger); - matchV10Builder.setTpSrc(zeroInteger); + matchV10Builder.setNwSrcMask(Uint8.ZERO); + matchV10Builder.setNwTos(Uint8.ZERO); + matchV10Builder.setTpDst(Uint16.ZERO); + matchV10Builder.setTpSrc(Uint16.ZERO); FlowWildcardsV10 flowWildcardsV10 = new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true); matchV10Builder.setWildcards(flowWildcardsV10); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MeterUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MeterUtilTest.java index 04f58c05ac..126f5faa0d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MeterUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MeterUtilTest.java @@ -34,6 +34,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Test for {@link MeterUtil}. @@ -41,8 +42,8 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder; public class MeterUtilTest { public static final NodeId DUMMY_NODE_ID = new NodeId("dummyNodeId"); - private static final MeterId DUMMY_METER_ID = new MeterId(42L); - private static final MeterId DUMMY_METER_ID_2 = new MeterId(43L); + private static final MeterId DUMMY_METER_ID = new MeterId(Uint32.valueOf(42)); + private static final MeterId DUMMY_METER_ID_2 = new MeterId(Uint32.valueOf(43)); @Test public void testBuildGroupPath() { diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslatorTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslatorTest.java index fd1a7bc0ad..72cec981fb 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslatorTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslatorTest.java @@ -8,11 +8,11 @@ package org.opendaylight.openflowplugin.impl.util; import com.google.common.collect.Lists; -import java.math.BigInteger; import junit.framework.TestCase; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; @@ -34,9 +34,9 @@ public class NodeConnectorRefToPortTranslatorTest extends TestCase { private static final String PACKET_DATA = "Test_Data"; private static final Uint32 PORT_NO = Uint32.valueOf(5L); - private static final Uint64 DATA_PATH_ID = Uint64.valueOf(10); + private static final Uint64 DATA_PATH_ID = Uint64.TEN; private static final short OF_VERSION = OFConstants.OFP_VERSION_1_3; - private static final Long TABLE_ID = 42L; + private static final Uint32 TABLE_ID = Uint32.valueOf(42); private static PacketIn createPacketIn(final Uint32 portNo) { InPortBuilder inPortBuilder = new InPortBuilder() @@ -55,12 +55,12 @@ public class NodeConnectorRefToPortTranslatorTest extends TestCase { .setMatchEntry(Lists.newArrayList(matchEntryBuilder.build())); return new PacketInMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_0) + .setVersion(EncodeConstants.OF_VERSION_1_0) .setData(PACKET_DATA.getBytes()) .setReason(PacketInReason.OFPRACTION) .setMatch(matchBuilder.build()) - .setVersion(OFConstants.OFP_VERSION_1_3) - .setCookie(BigInteger.ZERO) + .setVersion(EncodeConstants.OF_VERSION_1_3) + .setCookie(Uint64.ZERO) .setTableId(new TableId(TABLE_ID)) .build(); } -- 2.36.6