use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.
the class OpendaylightFlowStatisticsServiceImpl2Test method setUp.
public void setUp() {
final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
flowStatisticsService = OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext, convertorManager);
rqContextMp = new AbstractRequestContext<List<MultipartReply>>(42L) {
@Override
public void close() {
// NOOP
}
};
Mockito.when(rqContextStack.<List<MultipartReply>>createRequestContext()).thenReturn(rqContextMp);
Mockito.when(translatorLibrary.<MultipartReply, AggregatedFlowStatistics>lookupTranslator(Matchers.any(TranslatorKey.class))).thenReturn(translator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.
the class TransactionChainManagerTest method testDeactivateTransactionChainManagerFailed.
@Test
public void testDeactivateTransactionChainManagerFailed() throws Exception {
Mockito.when(writeTx.submit()).thenReturn(Futures.<Void, TransactionCommitFailedException>immediateFailedCheckedFuture(new TransactionCommitFailedException("mock")));
final Node data = new NodeBuilder().setId(nodeId).build();
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
txChainManager.deactivateTransactionManager();
Mockito.verify(txChain).newReadWriteTransaction();
Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false);
Mockito.verify(writeTx, Mockito.never()).submit();
Mockito.verify(writeTx).cancel();
Mockito.verify(txChain).close();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.
the class SystemNotificationsListenerImplTest method testOnDisconnectEvent2.
/**
* Broken scenario - connection is on but fails to close.
*/
@Test
public void testOnDisconnectEvent2() throws Exception {
Mockito.when(connectionAdapter.isAlive()).thenReturn(true);
Mockito.when(connectionAdapter.disconnect()).thenReturn(Futures.immediateFuture(Boolean.FALSE));
DisconnectEvent disconnectNotification = new DisconnectEventBuilder().setInfo("testing disconnect").build();
systemNotificationsListener.onDisconnectEvent(disconnectNotification);
verifyCommonInvocationsSubSet();
Mockito.verify(connectionContext).onConnectionClosed();
Mockito.verify(connectionContext).getConnectionAdapter();
Mockito.verify(connectionContext, Mockito.atLeastOnce()).getSafeNodeIdForLOG();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.
the class SystemNotificationsListenerImplTest method testOnDisconnectEvent4.
/**
* Broken scenario - connection is on but throws error on close.
*/
@Test
public void testOnDisconnectEvent4() throws Exception {
Mockito.when(connectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.RIP);
Mockito.when(connectionAdapter.isAlive()).thenReturn(false);
DisconnectEvent disconnectNotification = new DisconnectEventBuilder().setInfo("testing disconnect").build();
systemNotificationsListener.onDisconnectEvent(disconnectNotification);
verifyCommonInvocationsSubSet();
Mockito.verify(connectionContext).onConnectionClosed();
Mockito.verify(connectionContext).getConnectionAdapter();
Mockito.verify(connectionContext, Mockito.atLeastOnce()).getSafeNodeIdForLOG();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.
the class MultipartRequestOnTheFlyCallbackTest method testOnSuccessWithValidMultipart1.
/**
* Not the last reply.
*/
@Test
public void testOnSuccessWithValidMultipart1() throws Exception {
final MatchBuilder matchBuilder = new MatchBuilder().setMatchEntry(Collections.<MatchEntry>emptyList());
final FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder().setTableId(tableId).setPriority(2).setCookie(BigInteger.ZERO).setByteCount(BigInteger.TEN).setPacketCount(BigInteger.ONE).setDurationSec(11L).setDurationNsec(12L).setMatch(matchBuilder.build()).setFlags(new FlowModFlags(true, false, false, false, false));
final MultipartReplyFlowBuilder multipartReplyFlowBuilder = new MultipartReplyFlowBuilder().setFlowStats(Collections.singletonList(flowStatsBuilder.build()));
final MultipartReplyFlowCaseBuilder multipartReplyFlowCaseBuilder = new MultipartReplyFlowCaseBuilder().setMultipartReplyFlow(multipartReplyFlowBuilder.build());
final MultipartReplyMessageBuilder mpReplyMessage = new MultipartReplyMessageBuilder().setType(MultipartType.OFPMPFLOW).setFlags(new MultipartRequestFlags(true)).setMultipartReplyBody(multipartReplyFlowCaseBuilder.build()).setXid(21L);
final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
final TableBuilder tableDataBld = new TableBuilder();
tableDataBld.setId(tableId);
flowNodeBuilder.setTable(Collections.singletonList(tableDataBld.build()));
final Optional<FlowCapableNode> flowNodeOpt = Optional.of(flowNodeBuilder.build());
final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowNodeFuture = Futures.immediateCheckedFuture(flowNodeOpt);
when(mockedReadOnlyTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture);
when(mockedDeviceContext.getReadTransaction()).thenReturn(mockedReadOnlyTx);
multipartRequestOnTheFlyCallback.onSuccess(mpReplyMessage.build());
verify(mockedReadOnlyTx, times(0)).read(LogicalDatastoreType.OPERATIONAL, nodePath);
verify(mockedReadOnlyTx, times(0)).close();
verify(mockedDeviceContext, times(1)).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), Matchers.any(), Matchers.any());
}
Aggregations