/** * @param event * */ public void anticipateNotification(MockNotification mn) { MockUtil.println("Anticipating notification: " + mn); m_anticipated.add(mn); }
@After public void tearDown() throws Exception { MockUtil.println("------------ End Test --------------------------"); // MockLogAppender.assertNoWarningsOrGreater(); }
@Override protected void tearDown() throws Exception { MockUtil.println("------------ End Test "+getName()+" --------------------------"); super.tearDown(); }
@After public void tearDown() throws Exception { MockUtil.println("------------ End Test --------------------------"); // MockLogAppender.assertNoWarningsOrGreater(); }
@After public void runTest() throws Throwable { try { if (!m_allowWarnings) { MockLogAppender.assertNoWarningsOrGreater(); } } finally { MockUtil.println("------------ End Test "+this+" --------------------------"); } }
@After public void tearDown() throws Exception { sleep(200); MockUtil.println("------------ End Test --------------------------"); }
@After public void tearDown() throws Exception { m_eventMgr.finishProcessingEvents(); MockUtil.println("------------ End Test --------------------------"); }
@Override public void run() { try { pNode1.withTreeLock(r, 500); fail("Expected LockUnavailable"); } catch (LockUnavailable e) { MockUtil.println("Received expected exception "+e); } } };
/** * Tears down the test. * * @throws Exception the exception */ @After public void tearDown() throws Exception { MockUtil.println("------------ End Test --------------------------"); MockLogAppender.assertNoWarningsOrGreater(); }
@Override protected void setUp() throws Exception { super.setUp(); MockUtil.println("------------ Begin Test "+getName()+" --------------------------"); MockLogAppender.setupLogging(); MockDatabase m_db = new MockDatabase(); // m_db.populate(m_network); DataSourceFactory.setInstance(m_db); }
@Override public void visitService(MockService svc) { if (anticipatesClose(svc)) { // Decrease the open ones.. leave the total the same m_expectedOpenCount++; for (Outage outage : m_db.getOpenOutages(svc)) { MockUtil.println("Deanticipating outage closed: "+outage); removeFromOutageList(m_pendingCloses, regainService, outage); } } } };
@Override public void visitService(MockService svc) { if (!m_db.hasOpenOutage(svc) || anticipatesClose(svc)) { m_expectedOpenCount++; m_expectedOutageCount++; outageCreatedEvents.add(svc.createOutageCreatedEvent()); Outage outage = new Outage(svc); MockUtil.println("Anticipating outage open: "+outage); addToOutageList(m_pendingOpens, lostService, outage); } } };
public void closeOutage(PollableService pSvc, PollEvent svcRegainEvent) { MockService mSvc = m_mockNetwork.getService(pSvc.getNodeId(), pSvc.getIpAddr(), pSvc.getSvcName()); Timestamp eventTime = new Timestamp(svcRegainEvent.getDate().getTime()); MockUtil.println("Resolving Outage for "+mSvc); m_db.resolveOutage(mSvc, svcRegainEvent.getEventId(), eventTime); }
@After public void tearDown() throws Exception { m_fileAnticipator.deleteExpected(true); m_fileAnticipator.tearDown(); MockUtil.println("------------ End Test " + m_testName.getMethodName() + " --------------------------"); }
private void writeOutage(PollableService pSvc, PollEvent svcLostEvent) { MockService mSvc = m_mockNetwork.getService(pSvc.getNodeId(), pSvc.getIpAddr(), pSvc.getSvcName()); Timestamp eventTime = new Timestamp(svcLostEvent.getDate().getTime()); MockUtil.println("Opening Outage for "+mSvc); m_db.createOutage(mSvc, svcLostEvent.getEventId(), eventTime); } @Override
@Override public void visitService(MockService svc) { if ((m_db.hasOpenOutage(svc) || anticipatesOpen(svc)) && !anticipatesClose(svc)) { // Decrease the open ones.. leave the total the same m_expectedOpenCount--; outageResolvedEvents.add(svc.createOutageResolvedEvent()); for (Outage outage : m_db.getOpenOutages(svc)) { MockUtil.println("Anticipating outage closed: "+outage); addToOutageList(m_pendingCloses, regainService, outage); } } } };
@Test public void testDontPollDuringScheduledOutages() { long start = System.currentTimeMillis(); MockInterface iface = m_network.getInterface(1, "192.168.1.2"); m_pollerConfig.addScheduledOutage(m_pollerConfig.getPackage("TestPackage"), "TestOutage", start, start + 5000, iface.getIpAddr()); MockUtil.println("Begin Outage"); startDaemons(); long now = System.currentTimeMillis(); sleep(3000 - (now - start)); MockUtil.println("End Outage"); assertEquals(0, iface.getPollCount()); sleep(5000); assertTrue(0 < iface.getPollCount()); }
@After public void tearDown() throws Exception { m_eventMgr.finishProcessingEvents(); stopDaemons(); sleep(200); m_db.drop(); MockUtil.println("------------ End Test --------------------------"); }
@After public void tearDown() throws Exception { m_eventMgr.finishProcessingEvents(); stopDaemons(); sleep(200); m_db.drop(); MockUtil.println("------------ End Test --------------------------"); }
@Test public void testFormattedNotificationsXml() throws Exception { MockUtil.println("################# Running Test ################"); MockLogAppender.setupLogging(); MockNotifdConfigManager notifdConfig = new MockNotifdConfigManager(ConfigurationTestUtils.getConfigForResourceWithReplacements(this, "notifd-configuration.xml")); NotificationManager manager = new MockNotificationManager(notifdConfig, null, ConfigurationTestUtils.getConfigForResourceWithReplacements(this, "notifications-config-test.xml")); Notification n = manager.getNotification("crazyTestNotification"); assertTrue(n.getTextMessage().contains("\n")); } }