/** * Asserts if the the endpoint view correctly returns the total number of child endpoints included in the * endpoint associated with the view. * * @throws Exception if an error occurs while accessing child endpoints */ public void testGetTotalChildren() throws Exception { EndpointView endpointView = createMockEndPointView(3); Assert.assertEquals("Incorrect child count", 3, endpointView.getTotalChildren()); endpointView = createMockEndPointView(0); Assert.assertEquals("Incorrect child count", 0, endpointView.getTotalChildren()); }
/** * Tests if the receiving faults table is correctly updated when a receiving fault with an error code is reported. */ public void testReportReceivingFault() { EndpointView endpointView = createMockEndPointView(0); endpointView.reportReceivingFault(100); Assert.assertEquals("Receiving fault table not updated with new entry", 1, endpointView.getReceivingFaultTable().get(100).longValue()); endpointView.reportReceivingFault(100); Assert.assertEquals("Receiving fault table not updated", 2, endpointView.getReceivingFaultTable().get(100).longValue()); }
/** * Tests if the receiving faults table is correctly updated when a sending fault with an error code is reported. */ public void testReportSendingFault() { EndpointView endpointView = createMockEndPointView(0); endpointView.reportSendingFault(100); Assert.assertEquals("Sending fault table not updated with new entry", 1, endpointView.getSendingFaultTable().get(100).longValue()); endpointView.reportSendingFault(100); Assert.assertEquals("Receiving fault table not updated", 2, endpointView.getSendingFaultTable().get(100).longValue()); }
/** * Tests if the suspention counts are correctly updated when 'incrementSuspensions' is called. */ public void testIncrementSuspensions() { EndpointView endpointView = createMockEndPointView(0); endpointView.incrementSuspensions(); Assert.assertEquals("Consecutive endpoint suspension count not incremented", 1, endpointView.getConsecutiveEndpointSuspensions()); Assert.assertEquals("Total endpoint suspension count not incremented", 1, endpointView.getTotalEndpointSuspensions()); }
/** * Tests if the timeout counts are correctly updated when 'incrementTimeouts' is called. */ public void testIncrementTimeouts() { EndpointView endpointView = createMockEndPointView(0); endpointView.incrementTimeouts(); Assert.assertEquals("Consecutive endpoint timeout count not incremented", 1, endpointView.getConsecutiveEndpointTimeouts()); Assert.assertEquals("Total endpoint suspension count not incremented", 1, endpointView.getTotalEndpointTimeouts()); }
/** * Tests if the consecutive suspension count is correctly updated when 'incrementSuspensions' is called. */ public void testResetConsecutiveSuspensions() { EndpointView endpointView = createMockEndPointView(0); endpointView.incrementSuspensions(); endpointView.resetConsecutiveSuspensions(); Assert.assertEquals("Consecutive endpoint suspension count not reset", 0, endpointView.getConsecutiveEndpointSuspensions()); }
/** * Tests if the sending faults table and the sending fault counts are correctly updated when * 'incrementFaultsSending' is called. */ public void testIncrementFaultsSending() { EndpointView endpointView = createMockEndPointView(0); endpointView.incrementFaultsSending(100); Assert.assertEquals("Sending fault count not incremented", 1, endpointView.getFaultsSending()); Assert.assertEquals("Sending fault table not updated", 1, endpointView.getSendingFaultTable().get(100).longValue()); endpointView.incrementFaultsSending(100); Assert.assertEquals("Sending fault count not incremented", 2, endpointView.getFaultsSending()); Assert.assertEquals("Sending fault table not updated", 2, endpointView.getSendingFaultTable().get(100).longValue()); }
/** * Tests if the receiving faults table and the fault receiving counts are correctly updated when * 'incrementFaultsReceiving' is called. */ public void testIncrementFaultsReceiving() { EndpointView endpointView = createMockEndPointView(0); endpointView.incrementFaultsReceiving(100); Assert.assertEquals("Receiving fault count not incremented", 1, endpointView.getFaultsReceiving()); Assert.assertEquals("Receiving fault table not updated", 1, endpointView.getReceivingFaultTable().get(100).longValue()); endpointView.incrementFaultsReceiving(100); Assert.assertEquals("Receiving fault count not incremented", 2, endpointView.getFaultsReceiving()); Assert.assertEquals("Receiving fault table not updated", 2, endpointView.getReceivingFaultTable().get(100).longValue()); }
/** * Asserts if the the endpoint view correctly returns the number of child endpoints in the ready state. * * @throws Exception if an error occurs while accessing child endpoints */ public void testGetReadyChildren() throws Exception { AbstractEndpoint endpoint = createMockEndPoint(3); EndpointView endpointView = new EndpointView("endpoint", endpoint); Mockito.when(endpoint.getChildren().get(0).getContext().readyToSend()).thenReturn(true); Assert.assertEquals("Incorrect ready children count", 1, endpointView.getReadyChildren()); endpointView = createMockEndPointView(0); Assert.assertEquals("Ready children count should be empty", 0, endpointView.getReadyChildren()); }
/** * Asserts if the the endpoint view correctly returns the number of active child endpoints included in the * endpoint associated with the view. * * @throws Exception if an error occurs while accessing child endpoints */ public void testGetActiveChildren() throws Exception { //Assert with children AbstractEndpoint endpoint = createMockEndPoint(5); Mockito.when(endpoint.getChildren().get(0).getContext().isState(EndpointContext.ST_ACTIVE)).thenReturn(true); Mockito.when(endpoint.getChildren().get(1).getContext().isState(EndpointContext.ST_ACTIVE)).thenReturn(false); Mockito.when(endpoint.getChildren().get(2).getContext().isState(EndpointContext.ST_ACTIVE)).thenReturn(true); Mockito.when(endpoint.getChildren().get(3).getContext().isState(EndpointContext.ST_ACTIVE)).thenReturn(false); Mockito.when(endpoint.getChildren().get(4).getContext().isState(EndpointContext.ST_ACTIVE)).thenReturn(true); EndpointView endpointView = new EndpointView("endpoint", endpoint); Assert.assertEquals("Incorrect active children count", 3, endpointView.getActiveChildren()); //Assert when endpoint has no children EndpointView endpointViewWithoutChildren = createMockEndPointView(0); Assert.assertEquals("Incorrect active children count", 0, endpointViewWithoutChildren.getActiveChildren()); }