X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fstatistics%2FStatisticsGatheringUtilsTest.java;h=7076e6b8862d7c97994e3abe69e1fac885c39979;hb=d8cc382a8dbdcb7c89b68457b3ae0b6d576ee28f;hp=a5303e23097b8394ad1b861903682001b14d4c42;hpb=3ca48d7b0eebd05566ee5fb72569cc51c4048e03;p=openflowplugin.git 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 a5303e2309..7076e6b886 100644 --- 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 @@ -1,18 +1,16 @@ /* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * - * * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * * - * * This program and the accompanying materials are made available under the - * * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * + * This program and the accompanying materials are made available under the + * 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; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; + import com.google.common.base.Optional; import com.google.common.collect.Lists; import com.google.common.util.concurrent.CheckedFuture; @@ -24,10 +22,8 @@ import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.junit.After; import org.junit.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; @@ -51,6 +47,8 @@ import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRe import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier; import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.StatisticsGatherer; import org.opendaylight.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory; +import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager; +import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory; import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder; @@ -131,7 +129,6 @@ 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.multipart.reply.table.TableStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatistics; -import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -168,12 +165,16 @@ public class StatisticsGatheringUtilsTest { @Mock private TxFacade txFacade; + private SinglePurposeMultipartReplyTranslator singlePurposeMultipartReplyTranslator; + public StatisticsGatheringUtilsTest() { OpenflowPortsUtil.init(); } @Before public void setUp() throws Exception { + final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager(); + singlePurposeMultipartReplyTranslator = new SinglePurposeMultipartReplyTranslator(convertorManager); when(deviceContext.getDeviceState()).thenReturn(deviceState); when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo); when(deviceContext.getDeviceFlowRegistry()).thenReturn(deviceFlowRegistry); @@ -193,11 +194,6 @@ public class StatisticsGatheringUtilsTest { when(deviceInfo.getNodeId()).thenReturn(DUMMY_NODE_ID); } - @After - public void tearDown() throws Exception { - - } - @Test public void testWriteFlowStatistics() throws Exception { final ArgumentCaptor dataStoreType = ArgumentCaptor.forClass(LogicalDatastoreType.class); @@ -417,7 +413,7 @@ public class StatisticsGatheringUtilsTest { public void testGatherStatistics_flow() throws Exception { final short tableId = 0; final MultipartType type = MultipartType.OFPMPFLOW; - when(deviceFlowRegistry.storeIfNecessary(Matchers.any(FlowRegistryKey.class), Matchers.anyShort())) + when(deviceFlowRegistry.storeIfNecessary(Matchers.any(FlowRegistryKey.class))) .thenReturn(new FlowId("openflow:21")); final InstanceIdentifier nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class); @@ -457,7 +453,7 @@ public class StatisticsGatheringUtilsTest { .child(Table.class, new TableKey((short) 0)) .child(Flow.class, new FlowKey(new FlowId("openflow:21"))); verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.>any()); - verify(deviceFlowRegistry).storeIfNecessary(FlowRegistryKeyFactory.create(flowBld.build()), (short) 0); + verify(deviceFlowRegistry).storeIfNecessary(FlowRegistryKeyFactory.create(flowBld.build())); verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(flowPath), Matchers.any(Flow.class)); } @@ -500,7 +496,8 @@ public class StatisticsGatheringUtilsTest { type, txFacade, deviceContext, - deviceState); + false, + singlePurposeMultipartReplyTranslator); Assert.assertTrue(gatherStatisticsResult.get(1, TimeUnit.SECONDS).booleanValue()); verify(txFacade).submitTransaction(); } @@ -518,18 +515,9 @@ public class StatisticsGatheringUtilsTest { return new BucketStatsBuilder().setByteCount(BigInteger.valueOf(byteCount)).setPacketCount(BigInteger.valueOf(packetCount)).build(); } - @Test - public void testDeleteAllKnownFlowsNotSync() throws Exception { - when(deviceState.deviceSynchronized()).thenReturn(false); - StatisticsGatheringUtils.deleteAllKnownFlows(deviceInfo, - deviceContext.getDeviceFlowRegistry(), deviceContext, deviceState); - Mockito.verifyNoMoreInteractions(deviceFlowRegistry); - } - @Test public void testDeleteAllKnownFlows() throws Exception { final short tableId = 0; - when(deviceState.deviceSynchronized()).thenReturn(true); final InstanceIdentifier nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class); final TableBuilder tableDataBld = new TableBuilder(); tableDataBld.setId(tableId); @@ -542,7 +530,7 @@ public class StatisticsGatheringUtilsTest { .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId)); StatisticsGatheringUtils.deleteAllKnownFlows(deviceInfo, - deviceContext.getDeviceFlowRegistry(), txFacade, deviceState); + deviceContext.getDeviceFlowRegistry(), txFacade); verify(txFacade).writeToTransaction( LogicalDatastoreType.OPERATIONAL,