@Override protected void setUp() throws Exception { setVersion(SnmpAgentConfig.VERSION2C); SnmpPeerFactory.setInstance( new SnmpPeerFactory(new ByteArrayResource(getSnmpConfig().getBytes()))); MockLogAppender.setupLogging(true); }
@Before public void setUp() throws Exception { // Use the mock.logLevel system property to control the log level MockLogAppender.setupLogging(true); // Set the operation delay to 1 second so that queued operations execute immediately m_adapter.setDelay(1); m_adapter.setTimeUnit(TimeUnit.SECONDS); Assert.notNull(m_nodeDao, "Autowiring failed, NodeDao is null"); Assert.notNull(m_mockEventIpcManager, "Autowiring failed, IPC manager is null"); Assert.notNull(m_populator, "Autowiring failed, DB populator is null"); Assert.notNull(m_adapter, "Autowiring failed, adapter is null"); // Make sure that the localhost SNMP connection config factory has overridden // the normal config factory assertTrue(m_adapter.getSnmpPeerFactory() instanceof ProxySnmpAgentConfigFactory); m_populator.populateDatabase(); OnmsNode node = m_nodeDao.get(NODE_ID); assertNotNull(node); node.setSysObjectId(".1.3"); m_nodeDao.saveOrUpdate(node); }
@Before public void setUp() throws InterruptedException { MockLogAppender.setupLogging(); m_detector.setArrayNumber("0.0"); // the default m_detector.setRetries(2); m_detector.setTimeout(500); }
@Before public void setUp() throws InterruptedException { MockLogAppender.setupLogging(); m_detector.setRetries(2); m_detector.setTimeout(5000); m_detector.setVirtualDiskNumber("1"); }
@Before public void setUp() throws Exception { Properties props = new Properties(); props.setProperty("log4j.logger.org.hibernate", "INFO"); props.setProperty("log4j.logger.org.springframework", "INFO"); props.setProperty("log4j.logger.org.hibernate.SQL", "DEBUG"); MockLogAppender.setupLogging(props); }
@Before public void setUp() throws InterruptedException { MockLogAppender.setupLogging(); m_detector.setRetries(2); m_detector.setTimeout(500); m_detector.setAdminTag("to_detect"); }
@Before public void setUp() { MockLogAppender.setupLogging(true); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setIgnoreComments(true); XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true); XMLUnit.setNormalize(true); }
@BeforeClass public static void setupLogging() { Properties props = new Properties(); props.setProperty("log4j.logger.org.hibernate", "INFO"); props.setProperty("log4j.logger.org.springframework", "INFO"); props.setProperty("log4j.logger.org.hibernate.SQL", "DEBUG"); MockLogAppender.setupLogging(props); }
@Before public void setUp() throws Exception { MockLogAppender.setupLogging(); m_detector = getDetector(ImapDetector.class); m_detector.setServiceName("Imap"); m_detector.setTimeout(500); m_detector.init(); }
@Before public void setUp() throws Exception { Properties p = new Properties(); p.setProperty("log4j.logger.org.hibernate.SQL", "WARN"); MockLogAppender.setupLogging(p); assertTrue("Capsd must not be null", m_capsd != null); // assertTrue("Linkd must not be null", m_linkd != null); }
@Before public void setUp() throws SocketException { MockLogAppender.setupLogging(); m_detector = new DnsDetector(); m_detector.setTimeout(500); // m_socket = new DatagramSocket(4445); // m_serverThread = createThread(); // m_serverThread.start(); }
@After public void tearDown() throws Exception { m_eventMgr.finishProcessingEvents(); stopDaemons(); sleep(200); if (m_assertLevel != null) { MockLogAppender.assertNotGreaterOrEqual(m_assertLevel); } m_db.drop(); MockUtil.println("------------ End Test --------------------------"); }
@Before public void setUp() throws IOException { MockLogAppender.setupLogging(); assertNotNull(m_detector); JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9123/server"); m_connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, m_beanServer); m_connectorServer.start(); }
@Before public void setUp() throws Exception { MockLogAppender.setupLogging(); MockDatabase db = new MockDatabase(); DataSourceFactory.setInstance(db); RrdUtils.setStrategy(m_strategy); m_provisioner = new OpenNMSProvisioner(); m_eventManager = new MockEventIpcManager(); m_provisioner.setEventManager(m_eventManager); m_capsdConfig = new TestCapsdConfigManager(CAPSD_CONFIG); CapsdConfigFactory.setInstance(m_capsdConfig); m_pollerConfig = new TestPollerConfigManager(POLLER_CONFIG, "localhost", false); PollerConfigFactory.setInstance(m_pollerConfig); m_provisioner.setCapsdConfig(m_capsdConfig); m_provisioner.setPollerConfig(m_pollerConfig); InputStream configStream = ConfigurationTestUtils.getInputStreamForConfigFile("opennms-server.xml"); OpennmsServerConfigFactory onmsSvrConfig = new OpennmsServerConfigFactory(configStream); configStream.close(); OpennmsServerConfigFactory.setInstance(onmsSvrConfig); configStream = ConfigurationTestUtils.getInputStreamForConfigFile("database-schema.xml"); DatabaseSchemaConfigFactory.setInstance(new DatabaseSchemaConfigFactory(configStream)); configStream.close(); configStream = ConfigurationTestUtils.getInputStreamForResource( this, "/org/opennms/netmgt/capsd/collectd-configuration.xml"); CollectdConfigFactory.setInstance( new CollectdConfigFactory( configStream, onmsSvrConfig.getServerName(), onmsSvrConfig.verifyServer())); configStream.close(); JdbcTemplate jdbcTemplate = new JdbcTemplate(db); m_syncer = new JdbcCapsdDbSyncer(); m_syncer.setJdbcTemplate(jdbcTemplate); m_syncer.setOpennmsServerConfig(OpennmsServerConfigFactory.getInstance()); m_syncer.setCapsdConfig(m_capsdConfig); m_syncer.setPollerConfig(m_pollerConfig); m_syncer.setCollectdConfig(CollectdConfigFactory.getInstance()); m_syncer.setNextSvcIdSql(db.getNextServiceIdStatement()); m_syncer.afterPropertiesSet(); m_syncer.syncServices(); m_provisioner.setCapsdDbSyncer(m_syncer); }
@Before public void setUp() throws Exception { Properties p = new Properties(); p.setProperty("log4j.logger.org.hibernate.SQL", "WARN"); p.setProperty("log4j.logger.org.hibernate.cfg", "WARN"); p.setProperty("log4j.logger.org.springframework", "WARN"); p.setProperty("log4j.logger.com.mchange.v2.resourcepool", "WARN"); MockLogAppender.setupLogging(p); super.setNodeDao(m_nodeDao); super.setSnmpInterfaceDao(m_snmpInterfaceDao); }
public void testUnmarshalReaderQuietly() throws MarshalException, ValidationException, FileNotFoundException, IOException { CastorUtils.unmarshal( Userinfo.class, ConfigurationTestUtils.getInputStreamForConfigFile("users.xml")); /* * Ensure that nothing was logged. * In particular, we want to make sure that we don't see this message: * 2008-07-28 16:04:53,260 DEBUG [main] org.exolab.castor.xml.Unmarshaller: *static* unmarshal method called, this will ignore any mapping files or changes made to an Unmarshaller instance. */ MockLogAppender.assertNoLogging(); }
// // Tests // @Test public void testIsRemotePackage() { Properties p = new Properties(); p.setProperty("org.opennms.netmgt.ConfigFileConstants", "ERROR"); MockLogAppender.setupLogging(p); Package pkg = new Package(); pkg.setName("SFO"); pkg.setRemote(true); Poller poller = new Poller(); assertFalse(poller.pollableServiceInPackage(null, null, pkg)); poller = null; }
@Before public void setUp() throws InterruptedException, UnknownHostException { MockLogAppender.setupLogging(); m_testIpAddress = InetAddressUtils.addr(TEST_IP_ADDRESS); if (m_detector == null) { m_detector = getDetector(SnmpDetector.class); m_detector.setRetries(2); m_detector.setTimeout(500); } }
@Before public void setUp() throws Exception { MockLogAppender.setupLogging(); // m_strategy = RrdUtils.getStrategy(); TcpRrdStrategy strategy = new TcpRrdStrategy(); strategy.setHost("127.0.0.1"); strategy.setPort(m_listenPort); m_strategy = new QueuingTcpRrdStrategy(strategy, 44444); // Don't initialize by default since not all tests need it. m_fileAnticipator = new FileAnticipator(false); }
@Before public void setUp() throws Exception { Properties p = new Properties(); p.setProperty("log4j.logger.org.hibernate.SQL", "WARN"); p.setProperty("log4j.logger.org.hibernate.cfg", "WARN"); p.setProperty("log4j.logger.org.hibernate.impl", "WARN"); p.setProperty("log4j.logger.org.hibernate.hql", "WARN"); p.setProperty("log4j.logger.org.opennms.mock.snmp", "WARN"); p.setProperty("log4j.logger.org.opennms.netmgt.snmp", "WARN"); p.setProperty("log4j.logger.org.opennms.netmgt.filter", "WARN"); p.setProperty("log4j.logger.org.hibernate", "WARN"); p.setProperty("log4j.logger.org.springframework", "WARN"); p.setProperty("log4j.logger.com.mchange.v2.resourcepool", "WARN"); MockLogAppender.setupLogging(p); }
@Before public void setUp() throws IOException { final Properties props = new Properties(); props.put("log4j.logger.org.opennms.core.xml.SimpleNamespaceFilter", "WARN"); props.put("log4j.logger.org.opennms.netmgt.provision.persist.RequisitionFileUtils", "TRACE"); MockLogAppender.setupLogging(props); System.err.println("setUp()"); m_pending.clear(); m_active.clear(); FileUtils.deleteDirectory(new File("target/opennms-home/etc/imports/pending")); m_pending.flush(); m_active.flush(); }
@Before public void setUp() throws Exception { Properties p = new Properties(); p.setProperty("log4j.logger.org.hibernate.SQL", "WARN"); p.setProperty("log4j.logger.org.hibernate.cfg", "WARN"); p.setProperty("log4j.logger.org.springframework", "WARN"); p.setProperty("log4j.logger.com.mchange.v2.resourcepool", "WARN"); MockLogAppender.setupLogging(p); super.setNodeDao(m_nodeDao); super.setSnmpInterfaceDao(m_snmpInterfaceDao); for (Package pkg : Collections.list(m_linkdConfig.enumeratePackage())) { pkg.setForceIpRouteDiscoveryOnEthernet(true); } }
/** * Sets the up. * * @throws Exception the exception */ @BeforeTransaction public void setUp() throws Exception { MockLogAppender.setupLogging(true); NetworkBuilder nb = new NetworkBuilder(); nb.addNode("R1") .setForeignSource("Cisco") .setForeignId("1") .setSysObjectId(".1.3.6.1.4.1.9.1.222"); nb.addInterface("192.168.0.1").setIsSnmpPrimary("P").setIsManaged("P"); m_nodeDao.save(nb.getCurrentNode()); nb.addNode("R2") .setForeignSource("Cisco") .setForeignId("2") .setSysObjectId(".1.3.6.1.4.1.9.1.222"); nb.addInterface("192.168.0.2").setIsSnmpPrimary("P").setIsManaged("P"); m_nodeDao.save(nb.getCurrentNode()); nb.addNode("R3") .setForeignSource("Cisco") .setForeignId("3") .setSysObjectId(".1.3.6.1.4.1.9.1.222"); nb.addInterface("192.168.0.3").setIsSnmpPrimary("P").setIsManaged("P"); m_nodeDao.save(nb.getCurrentNode()); nb.addNode("R4") .setForeignSource("Cisco") .setForeignId("4") .setSysObjectId(".1.3.6.1.4.1.9.1.222"); nb.addInterface("192.168.0.4").setIsSnmpPrimary("P").setIsManaged("P"); m_nodeDao.save(nb.getCurrentNode()); m_nodeDao.flush(); m_adapter.afterPropertiesSet(); for (int i = 1; i <= 4; i++) { Integer nodeId = m_nodeDao.findByForeignId("Cisco", Integer.toString(i)).getId(); AdapterOperationSchedule ops = new AdapterOperationSchedule(0, 1, 1, TimeUnit.SECONDS); AdapterOperation op = m_adapter.new AdapterOperation(nodeId, AdapterOperationType.ADD, ops); m_operations.add(new TestOperation(nodeId, op)); } }
@Test public void testDuplicateNodes() throws Exception { MockLogAppender.setupLogging(true, "DEBUG"); String req = "<model-import xmlns=\"http://xmlns.opennms.org/xsd/config/model-import\" date-stamp=\"2006-03-09T00:03:09\" foreign-source=\"test\">" + "<node node-label=\"a\" foreign-id=\"a\" />" + "<node node-label=\"b\" foreign-id=\"c\" />" + "<node node-label=\"c\" foreign-id=\"c\" />" + "</model-import>"; final MockHttpServletResponse response = sendPost("/requisitions", req, 400, null); assertTrue( "response should say 'c' has duplicates", response .getContentAsString() .contains("Duplicate nodes found on foreign source test: c (2 found)")); }
/** * Sets the up. * * @throws Exception the exception */ @Before public void setUp() throws Exception { MockLogAppender.setupLogging(); initializeRrdStrategy(); initializeDocumentBuilder(); m_collectionAgent = EasyMock.createMock(CollectionAgent.class); EasyMock.expect(m_collectionAgent.getNodeId()).andReturn(1).anyTimes(); EasyMock.expect(m_collectionAgent.getHostAddress()).andReturn("127.0.0.1").anyTimes(); EasyMock.expect(m_collectionAgent.getStorageDir()).andReturn(new File("1")).anyTimes(); m_eventProxy = EasyMock.createMock(EventProxy.class); m_xmlCollectionDao = new XmlDataCollectionConfigDaoJaxb(); Resource resource = new FileSystemResource(getConfigFileName()); m_xmlCollectionDao.setConfigResource(resource); m_xmlCollectionDao.afterPropertiesSet(); EasyMock.replay(m_collectionAgent, m_eventProxy); }
/** * Sets the up. * * @throws Exception the exception */ @Before public void setUp() throws Exception { FileUtils.deleteDirectory(new File(TEST_SNMP_DIRECTORY)); MockLogAppender.setupLogging(); System.setProperty("org.opennms.rrd.usetcp", "false"); System.setProperty("org.opennms.rrd.usequeue", "false"); RrdUtils.setStrategy(new JRobinRrdStrategy()); m_collectionAgent = EasyMock.createMock(CollectionAgent.class); EasyMock.expect(m_collectionAgent.getNodeId()).andReturn(1).anyTimes(); EasyMock.expect(m_collectionAgent.getHostAddress()).andReturn("127.0.0.1").anyTimes(); EasyMock.expect(m_collectionAgent.getStorageDir()).andReturn(new File("1")).anyTimes(); m_eventProxy = EasyMock.createMock(EventProxy.class); m_xmlCollectionDao = new XmlDataCollectionConfigDaoJaxb(); Resource resource = new FileSystemResource(getXmlConfigFileName()); m_xmlCollectionDao.setConfigResource(resource); m_xmlCollectionDao.afterPropertiesSet(); MockDocumentBuilder.setXmlFileName(getXmlSampleFileName()); EasyMock.replay(m_collectionAgent, m_eventProxy); }
@Before public void setUp() { MockLogAppender.setupLogging(); }
@Before public void setUp() throws Exception { m_assertLevel = Level.WARN; // System.setProperty("mock.logLevel", "DEBUG"); // System.setProperty("mock.debug", "true"); MockUtil.println("------------ Begin Test --------------------------"); MockLogAppender.setupLogging(); m_network = new MockNetwork(); m_network.setCriticalService("ICMP"); m_network.addNode(1, "Router"); m_network.addInterface("192.168.1.1"); m_network.addService("ICMP"); m_network.addService("SMTP"); m_network.addService("SNMP"); m_network.addInterface("192.168.1.2"); m_network.addService("ICMP"); m_network.addService("SMTP"); m_network.addNode(2, "Server"); m_network.addInterface("192.168.1.3"); m_network.addService("ICMP"); m_network.addService("HTTP"); m_network.addService("SMTP"); m_network.addService("SNMP"); m_network.addNode(3, "Firewall"); m_network.addInterface("192.168.1.4"); m_network.addService("SMTP"); m_network.addService("HTTP"); m_network.addInterface("192.168.1.5"); m_network.addService("SMTP"); m_network.addService("HTTP"); m_network.addNode(4, "DownNode"); m_network.addInterface("192.168.1.6"); m_network.addService("SNMP"); // m_network.addInterface("fe80:0000:0000:0000:0231:f982:0123:4567"); // m_network.addService("SNMP"); m_db = new MockDatabase(); m_db.populate(m_network); DataSourceFactory.setInstance(m_db); // DemandPollDao demandPollDao = new DemandPollDaoHibernate(m_db); // demandPollDao.setAllocateIdStmt(m_db // .getNextSequenceValStatement("demandPollNxtId")); // m_demandPollDao = demandPollDao; m_pollerConfig = new MockPollerConfig(m_network); m_pollerConfig.setNextOutageIdSql(m_db.getNextOutageIdStatement()); m_pollerConfig.setNodeOutageProcessingEnabled(true); m_pollerConfig.setCriticalService("ICMP"); m_pollerConfig.addPackage("TestPackage"); m_pollerConfig.addDowntime(1000L, 0L, -1L, false); m_pollerConfig.setDefaultPollInterval(1000L); m_pollerConfig.populatePackage(m_network); m_pollerConfig.addPackage("TestPkg2"); m_pollerConfig.addDowntime(1000L, 0L, -1L, false); m_pollerConfig.setDefaultPollInterval(2000L); m_pollerConfig.addService(m_network.getService(2, "192.168.1.3", "HTTP")); m_anticipator = new EventAnticipator(); m_outageAnticipator = new OutageAnticipator(m_db); m_eventMgr = new MockEventIpcManager(); m_eventMgr.setEventWriter(m_db); m_eventMgr.setEventAnticipator(m_anticipator); m_eventMgr.addEventListener(m_outageAnticipator); m_eventMgr.setSynchronous(false); QueryManager queryManager = new DefaultQueryManager(); queryManager.setDataSource(m_db); DefaultPollContext pollContext = new DefaultPollContext(); pollContext.setEventManager(m_eventMgr); pollContext.setLocalHostName("localhost"); pollContext.setName("Test.DefaultPollContext"); pollContext.setPollerConfig(m_pollerConfig); pollContext.setQueryManager(queryManager); PollableNetwork network = new PollableNetwork(pollContext); m_poller = new Poller(); m_poller.setDataSource(m_db); m_poller.setEventManager(m_eventMgr); m_poller.setNetwork(network); m_poller.setQueryManager(queryManager); m_poller.setPollerConfig(m_pollerConfig); m_poller.setPollOutagesConfig(m_pollerConfig); MockOutageConfig config = new MockOutageConfig(); config.setGetNextOutageID(m_db.getNextOutageIdStatement()); RrdUtils.setStrategy(new NullRrdStrategy()); // m_outageMgr = new OutageManager(); // m_outageMgr.setEventMgr(m_eventMgr); // m_outageMgr.setOutageMgrConfig(config); // m_outageMgr.setDbConnectionFactory(m_db); }
@Override protected void setUp() throws Exception { EventIpcManager m_eventIpcManager; NodeDao m_nodeDao; MockLogAppender.setupLogging(); Resource threshdResource = new ClassPathResource("/etc/thresholds.xml"); File homeDir = threshdResource.getFile().getParentFile().getParentFile(); System.setProperty("opennms.home", homeDir.getAbsolutePath()); // Test setup m_eventIpcManager = m_easyMockUtils.createMock(EventIpcManager.class); EventIpcManagerFactory.setIpcManager(m_eventIpcManager); m_nodeDao = m_easyMockUtils.createMock(NodeDao.class); m_ipIfDao = m_easyMockUtils.createMock(IpInterfaceDao.class); m_scheduler = new MockScheduler(); m_eventIpcManager.addEventListener(isA(EventListener.class)); expectLastCall().anyTimes(); m_eventIpcManager.addEventListener(isA(EventListener.class), isACollection(String.class)); expectLastCall().anyTimes(); m_eventIpcManager.addEventListener(isA(EventListener.class), isA(String.class)); expectLastCall().anyTimes(); m_eventIpcManager.removeEventListener(isA(EventListener.class)); expectLastCall().anyTimes(); // MockNetwork m_network = new MockNetwork(); // m_network.setCriticalService("ICMP"); // m_network.addNode(1, "Router"); // m_network.addInterface("192.168.1.1"); // m_network.addService("ICMP"); // m_network.addService("SMTP"); // m_network.addInterface("192.168.1.2"); // m_network.addService("ICMP"); // m_network.addService("SMTP"); // m_network.addNode(2, "Server"); // m_network.addInterface("192.168.1.3"); // m_network.addService("ICMP"); // m_network.addService("HTTP"); // m_network.addNode(3, "Firewall"); // m_network.addInterface("192.168.1.4"); // m_network.addService("SMTP"); // m_network.addService("HTTP"); // m_network.addInterface("192.168.1.5"); // m_network.addService("SMTP"); // m_network.addService("HTTP"); // // MockDatabase m_db = new MockDatabase(); // m_db.populate(m_network); // // DataSourceFactory.setInstance(m_db); // Mock the FilterDao without using EasyMockUtils so that it can be verified separately m_filterDao = EasyMock.createMock(FilterDao.class); List<InetAddress> allIps = new ArrayList<InetAddress>(); allIps.add(addr("192.168.1.1")); allIps.add(addr("192.168.1.2")); allIps.add(addr("192.168.1.3")); allIps.add(addr("192.168.1.4")); allIps.add(addr("192.168.1.5")); expect(m_filterDao.getActiveIPAddressList("IPADDR IPLIKE *.*.*.*")) .andReturn(allIps) .anyTimes(); expect(m_filterDao.getActiveIPAddressList("IPADDR IPLIKE 1.1.1.1")) .andReturn(new ArrayList<InetAddress>(0)) .anyTimes(); EasyMock.replay(m_filterDao); FilterDaoFactory.setInstance(m_filterDao); // This call will also ensure that the poll-outages.xml file can parse IPv4 // and IPv6 addresses. Resource resource = new ClassPathResource("etc/poll-outages.xml"); PollOutagesConfigFactory factory = new PollOutagesConfigFactory(resource); factory.afterPropertiesSet(); PollOutagesConfigFactory.setInstance(factory); final MockTransactionTemplate transTemplate = new MockTransactionTemplate(); transTemplate.afterPropertiesSet(); m_collectd = new Collectd(); m_collectd.setEventIpcManager(m_eventIpcManager); // m_collectd.setCollectdConfigFactory(m_collectdConfigFactory); m_collectd.setNodeDao(m_nodeDao); m_collectd.setIpInterfaceDao(m_ipIfDao); m_collectd.setFilterDao(m_filterDao); m_collectd.setScheduler(m_scheduler); m_collectd.setTransactionTemplate(transTemplate); // m_collectd.afterPropertiesSet(); ThresholdingConfigFactory.setInstance( new ThresholdingConfigFactory( ConfigurationTestUtils.getInputStreamForConfigFile("thresholds.xml"))); }
/** * Tear down. * * @throws Exception the exception */ @AfterTransaction public void tearDown() throws Exception { MockLogAppender.assertNoWarningsOrGreater(); }