Exemplo n.º 1
0
 // no handler installed for type
 public void testNoHandler() {
   FaultDistributor dut = new FaultDistributor();
   // We lie a little bit here to get the NODE_FAILURE routed to UNKNOWN
   // but still set the checking bool correctly
   MockFaultHandler unk_handler = new MockFaultHandler(FaultType.NODE_FAILURE);
   dut.registerDefaultHandler(unk_handler);
   dut.reportFault(new VoltFault(FaultType.NODE_FAILURE));
   assertTrue(unk_handler.m_gotFault);
 }
Exemplo n.º 2
0
 // multiple handlers for same type
 public void testMultiHandler() {
   FaultDistributor dut = new FaultDistributor();
   MockFaultHandler node_handler1 = new MockFaultHandler(FaultType.NODE_FAILURE);
   dut.registerFaultHandler(FaultType.NODE_FAILURE, node_handler1, 1);
   MockFaultHandler node_handler2 = new MockFaultHandler(FaultType.NODE_FAILURE);
   dut.registerFaultHandler(FaultType.NODE_FAILURE, node_handler2, 1);
   dut.reportFault(new VoltFault(FaultType.NODE_FAILURE));
   assertTrue(node_handler1.m_gotFault);
   assertTrue(node_handler2.m_gotFault);
 }
Exemplo n.º 3
0
 public void testBasicDispatch() {
   FaultDistributor dut = new FaultDistributor();
   MockFaultHandler unk_handler = new MockFaultHandler(FaultType.UNKNOWN);
   MockFaultHandler node_handler = new MockFaultHandler(FaultType.NODE_FAILURE);
   dut.registerFaultHandler(FaultType.UNKNOWN, unk_handler, 1);
   dut.registerFaultHandler(FaultType.NODE_FAILURE, node_handler, 1);
   dut.reportFault(new VoltFault(FaultType.UNKNOWN));
   assertTrue(unk_handler.m_gotFault);
   assertFalse(node_handler.m_gotFault);
   dut.reportFault(new VoltFault(FaultType.NODE_FAILURE));
   assertTrue(node_handler.m_gotFault);
 }
Exemplo n.º 4
0
 public void testSingleTypeOrder() {
   FaultDistributor dut = new FaultDistributor();
   OrderTracker order_tracker = new OrderTracker(-1);
   MockFaultHandler node_handler1 = new MockFaultHandler(FaultType.NODE_FAILURE, 1, order_tracker);
   MockFaultHandler node_handler2 = new MockFaultHandler(FaultType.NODE_FAILURE, 2, order_tracker);
   MockFaultHandler node_handler2a =
       new MockFaultHandler(FaultType.NODE_FAILURE, 2, order_tracker);
   MockFaultHandler node_handler5 = new MockFaultHandler(FaultType.NODE_FAILURE, 5, order_tracker);
   MockFaultHandler node_handler5a =
       new MockFaultHandler(FaultType.NODE_FAILURE, 5, order_tracker);
   MockFaultHandler node_handler7 = new MockFaultHandler(FaultType.NODE_FAILURE, 7, order_tracker);
   // register handlers in non-sequential order to avoid getting lucky
   // with insertion order
   dut.registerFaultHandler(FaultType.NODE_FAILURE, node_handler7, 7);
   dut.registerFaultHandler(FaultType.NODE_FAILURE, node_handler2a, 2);
   dut.registerFaultHandler(FaultType.NODE_FAILURE, node_handler5, 5);
   dut.registerFaultHandler(FaultType.NODE_FAILURE, node_handler1, 1);
   dut.registerFaultHandler(FaultType.NODE_FAILURE, node_handler5a, 5);
   dut.registerFaultHandler(FaultType.NODE_FAILURE, node_handler2, 2);
   dut.reportFault(new VoltFault(FaultType.NODE_FAILURE));
   assertTrue(node_handler1.m_gotFault);
   assertTrue(node_handler2.m_gotFault);
   assertTrue(node_handler2a.m_gotFault);
   assertTrue(node_handler5.m_gotFault);
   assertTrue(node_handler5a.m_gotFault);
   assertTrue(node_handler7.m_gotFault);
   assertTrue(order_tracker.m_goodOrder);
 }