コード例 #1
0
 @Test
 public void testBarrierFieldSetGet() {
   Timeout mockedTimeout = mock(Timeout.class);
   deviceContext.setCurrentBarrierTimeout(mockedTimeout);
   final Timeout pickedBarrierTimeout = deviceContext.getBarrierTaskTimeout();
   assertEquals(mockedTimeout, pickedBarrierTimeout);
 }
コード例 #2
0
 @Test
 public void testNodeConnector() {
   NodeConnectorRef mockedNodeConnectorRef = mock(NodeConnectorRef.class);
   deviceContext.storeNodeConnectorRef(DUMMY_PORT_NUMBER, mockedNodeConnectorRef);
   final NodeConnectorRef nodeConnectorRef =
       deviceContext.lookupNodeConnectorRef(DUMMY_PORT_NUMBER);
   assertEquals(mockedNodeConnectorRef, nodeConnectorRef);
 }
コード例 #3
0
 @Test
 public void testProcessReply() {
   Error mockedError = mock(Error.class);
   deviceContext.processReply(mockedError);
   verify(messageIntelligenceAgency)
       .spyMessage(any(Class.class), eq(MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE));
   OfHeader mockedOfHeader = mock(OfHeader.class);
   deviceContext.processReply(mockedOfHeader);
   verify(messageIntelligenceAgency)
       .spyMessage(any(Class.class), eq(MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_SUCCESS));
 }
コード例 #4
0
  @Test
  public void testProcessPacketInMessageFutureFailure() {
    PacketInMessage mockedPacketInMessage = mock(PacketInMessage.class);
    NotificationPublishService mockedNotificationPublishService =
        mock(NotificationPublishService.class);
    final ListenableFuture dummyFuture = Futures.immediateFailedFuture(new IllegalStateException());

    when(mockedNotificationPublishService.offerNotification(any(PacketReceived.class)))
        .thenReturn(dummyFuture);
    deviceContext.setNotificationPublishService(mockedNotificationPublishService);
    deviceContext.processPacketInMessage(mockedPacketInMessage);
    verify(messageIntelligenceAgency)
        .spyMessage(
            any(Class.class), eq(MessageSpy.STATISTIC_GROUP.FROM_SWITCH_NOTIFICATION_REJECTED));
  }
コード例 #5
0
  @Test
  public void testProcessPacketInMessageFutureSuccess() {
    PacketInMessage mockedPacketInMessage = mock(PacketInMessage.class);
    NotificationPublishService mockedNotificationPublishService =
        mock(NotificationPublishService.class);
    final ListenableFuture stringListenableFuture =
        Futures.immediateFuture(new String("dummy value"));

    when(mockedNotificationPublishService.offerNotification(any(PacketReceived.class)))
        .thenReturn(stringListenableFuture);
    deviceContext.setNotificationPublishService(mockedNotificationPublishService);
    deviceContext.processPacketInMessage(mockedPacketInMessage);
    verify(messageIntelligenceAgency)
        .spyMessage(any(Class.class), eq(MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_SUCCESS));
  }
コード例 #6
0
 @Test
 public void testAddDeleteToTxChain() {
   InstanceIdentifier<Nodes> dummyII = InstanceIdentifier.create(Nodes.class);
   deviceContext.addDeleteToTxChain(LogicalDatastoreType.CONFIGURATION, dummyII);
   verify(txChainManager)
       .addDeleteOperationTotTxChain(eq(LogicalDatastoreType.CONFIGURATION), eq(dummyII));
 }
コード例 #7
0
 @Test
 public void testAuxiliaryConnectionContext() {
   ConnectionContext mockedConnectionContext = addDummyAuxiliaryConnectionContext();
   final ConnectionContext pickedConnectiobContexts =
       deviceContext.getAuxiliaryConnectiobContexts(DUMMY_COOKIE);
   assertEquals(mockedConnectionContext, pickedConnectiobContexts);
 }
コード例 #8
0
 @Test
 public void testProcessReply2() {
   MultipartReply mockedMultipartReply = mock(MultipartReply.class);
   Xid dummyXid = new Xid(DUMMY_XID);
   deviceContext.processReply(dummyXid, Lists.newArrayList(mockedMultipartReply));
   verify(messageIntelligenceAgency)
       .spyMessage(any(Class.class), eq(MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE));
 }
コード例 #9
0
  @Test
  public void testClose() {
    ConnectionAdapter mockedConnectionAdapter = mock(ConnectionAdapter.class);
    InetSocketAddress mockRemoteAddress = mock(InetSocketAddress.class);
    when(mockedConnectionAdapter.getRemoteAddress()).thenReturn(mockRemoteAddress);
    when(connectionContext.getConnectionAdapter()).thenReturn(mockedConnectionAdapter);

    NodeId dummyNodeId = new NodeId("dummyNodeId");
    when(deviceState.getNodeId()).thenReturn(dummyNodeId);

    ConnectionContext mockedAuxiliaryConnectionContext = prepareConnectionContext();
    deviceContext.addAuxiliaryConenctionContext(mockedAuxiliaryConnectionContext);
    DeviceContextClosedHandler mockedDeviceContextClosedHandler =
        mock(DeviceContextClosedHandler.class);
    deviceContext.addDeviceContextClosedHandler(mockedDeviceContextClosedHandler);
    deviceContext.close();
    verify(connectionContext).closeConnection(eq(false));
    verify(deviceState).setValid(eq(false));
    verify(txChainManager).close();
    verify(mockedAuxiliaryConnectionContext).closeConnection(eq(false));
  }
コード例 #10
0
  @Test
  public void testOnPublished() {
    final ConnectionContext auxiliaryConnectionContext = addDummyAuxiliaryConnectionContext();

    ConnectionAdapter mockedAuxConnectionAdapter = mock(ConnectionAdapter.class);
    when(auxiliaryConnectionContext.getConnectionAdapter()).thenReturn(mockedAuxConnectionAdapter);

    ConnectionAdapter mockedConnectionAdapter = mock(ConnectionAdapter.class);
    when(connectionContext.getConnectionAdapter()).thenReturn(mockedConnectionAdapter);

    deviceContext.onPublished();
    verify(mockedAuxConnectionAdapter).setPacketInFiltering(eq(false));
    verify(mockedConnectionAdapter).setPacketInFiltering(eq(false));
  }
コード例 #11
0
  @Test
  public void testPortStatusMessage() {
    PortStatusMessage mockedPortStatusMessage = mock(PortStatusMessage.class);
    Class dummyClass = Class.class;
    when(mockedPortStatusMessage.getImplementedInterface()).thenReturn(dummyClass);

    GetFeaturesOutput mockedFeature = mock(GetFeaturesOutput.class);
    when(mockedFeature.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
    when(deviceState.getFeatures()).thenReturn(mockedFeature);

    when(mockedPortStatusMessage.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    when(mockedPortStatusMessage.getReason()).thenReturn(PortReason.OFPPRADD);

    OpenflowPortsUtil.init();
    deviceContext.processPortStatusMessage(mockedPortStatusMessage);
    verify(txChainManager)
        .writeToTransaction(
            eq(LogicalDatastoreType.OPERATIONAL),
            any(InstanceIdentifier.class),
            any(DataObject.class));
  }
コード例 #12
0
 @Test
 public void testGetDeviceState() {
   final DeviceState deviceSt = deviceContext.getDeviceState();
   assertNotNull(deviceSt);
   Assert.assertEquals(deviceState, deviceSt);
 }
コード例 #13
0
 private ConnectionContext addDummyAuxiliaryConnectionContext() {
   ConnectionContext mockedConnectionContext = prepareConnectionContext();
   deviceContext.addAuxiliaryConenctionContext(mockedConnectionContext);
   return mockedConnectionContext;
 }
コード例 #14
0
 @Test
 public void testGetReservedXid() {
   deviceContext.getReservedXid();
   verify(outboundQueueProvider).reserveEntry();
 }
コード例 #15
0
 @Test
 public void testSubmitTransaction() {
   deviceContext.submitTransaction();
   verify(txChainManager).submitWriteTransaction();
 }
コード例 #16
0
 @Test
 public void testGetMessageSpy() {
   final MessageSpy pickedMessageSpy = deviceContext.getMessageSpy();
   assertEquals(messageIntelligenceAgency, pickedMessageSpy);
 }
コード例 #17
0
 @Test
 public void testGetPrimaryConnectionContext() {
   final ConnectionContext primaryConnectionContext = deviceContext.getPrimaryConnectionContext();
   assertEquals(connectionContext, primaryConnectionContext);
 }
コード例 #18
0
 @Test
 public void testGetTimer() {
   final HashedWheelTimer pickedTimer = deviceContext.getTimer();
   assertEquals(timer, pickedTimer);
 }
コード例 #19
0
 @Test
 public void testTranslatorLibrary() {
   final TranslatorLibrary pickedTranslatorLibrary = deviceContext.oook();
   assertEquals(translatorLibrary, pickedTranslatorLibrary);
 }
コード例 #20
0
 @Test
 public void testGetDeviceMeterRegistry() {
   final DeviceMeterRegistry deviceMeterRegistry = deviceContext.getDeviceMeterRegistry();
   assertNotNull(deviceMeterRegistry);
 }
コード例 #21
0
 @Test
 public void testGetReadTransaction() {
   final ReadTransaction readTx = deviceContext.getReadTransaction();
   assertNotNull(readTx);
   Assert.assertEquals(rTx, readTx);
 }