@AfterClass(alwaysRun = true) public void tearDownOnceAgain() throws Exception { m_agentContext.stop(); verifyTestMocks(); clearTestMocks(); }
@BeforeClass(alwaysRun = true) public void setUpOnceAgain() throws Exception { m_agentContext = mockAgentContext(); BundleContext bc = mockBundleContext(); m_eventsHandler = new EventsHandlerImpl(bc); m_agentContext.setHandler(EventsHandler.class, m_eventsHandler); m_agentContext.setHandler(ConfigurationHandler.class, new ConfigurationHandlerImpl(bc)); m_agentContext.setHandler(FeedbackHandler.class, new TestFeedbackHandler()); replayTestMocks(); m_agentContext.start(); }
@SuppressWarnings("deprecation") @Test public void testExcludeEvent() throws Exception { ConfigurationHandler configurationHandler = m_agentContext.getHandler(ConfigurationHandler.class); configureAgent(configurationHandler, AgentConstants.CONFIG_LOGGING_EXCLUDE_EVENTS, "1001,1002"); FrameworkEvent event = new FrameworkEvent(32, new Object()); FeedbackHandler feedbackHandler = m_agentContext.getHandler(FeedbackHandler.class); TestFeedbackChannel channel = (TestFeedbackChannel) feedbackHandler.getChannel("auditlog"); // make sure the configuration is written to the channel assertEquals(channel.getLastTtype(), 2000); m_eventLogger.frameworkEvent(event); // make sure nothing is written to the channel assertEquals(channel.getLastTtype(), 2000); } }
@BeforeMethod(alwaysRun = true) public void reset() throws Exception { // create a new eventlogger for every test m_eventLogger = new EventLoggerImpl(mockBundleContext()); m_eventLogger.init(m_agentContext); m_eventsHandler.addListener(m_eventLogger); m_eventLogger.start(m_agentContext); // reset the previously logged data in our mock feedbackchannel. No need to create a new one here FeedbackHandler feedbackHandler = m_agentContext.getHandler(FeedbackHandler.class); TestFeedbackChannel channel = (TestFeedbackChannel) feedbackHandler.getChannel("auditlog"); channel.reset(); }