use of org.opennms.netmgt.provision.server.SimpleServer in project opennms by OpenNMS.
the class SmtpDetectorTest method testDetectorFailIncompleteMultilineResponseFromServer.
@Test(timeout = 20000)
public void testDetectorFailIncompleteMultilineResponseFromServer() throws Exception {
SimpleServer tempServer = new SimpleServer() {
@Override
public void onInit() {
String[] multiLine = { "250-First line", "400-Bogus second line" };
setBanner("220 ewhserver279.edgewebhosting.net");
addResponseHandler(matches("HELO LOCALHOST"), multilineLineRequest(multiLine));
addResponseHandler(matches("QUIT"), shutdownServer("221 Service closing transmission channel"));
}
};
tempServer.init();
tempServer.startServer();
m_detector.setPort(tempServer.getLocalPort());
assertFalse(doCheck(m_detector.isServiceDetected(tempServer.getInetAddress())));
}
use of org.opennms.netmgt.provision.server.SimpleServer in project opennms by OpenNMS.
the class TcpDetectorTest method testFailureConnectionTimesOutWhenExpectingABanner.
@Test(timeout = 20000)
public void testFailureConnectionTimesOutWhenExpectingABanner() throws Exception {
initializeDefaultDetector();
m_server = new SimpleServer() {
@Override
public void onInit() {
setTimeout(500);
}
};
m_server.init();
m_server.startServer();
m_detector.setPort(m_server.getLocalPort());
DetectFuture future = m_detector.isServiceDetected(m_server.getInetAddress());
assertNotNull(future);
future.awaitForUninterruptibly();
assertFalse("Test should fail because no banner was sent when expecting a banner to be sent", future.isServiceDetected());
}
use of org.opennms.netmgt.provision.server.SimpleServer in project opennms by OpenNMS.
the class TcpDetectorTest method testFailureNoBannerSentWhenExpectingABanner.
@Test(timeout = 20000)
public void testFailureNoBannerSentWhenExpectingABanner() throws Exception {
initializeDefaultDetector();
m_server = new SimpleServer() {
@Override
public void onInit() {
}
};
m_server.init();
m_server.startServer();
m_detector.setPort(m_server.getLocalPort());
DetectFuture future = m_detector.isServiceDetected(m_server.getInetAddress());
assertNotNull(future);
future.awaitForUninterruptibly();
assertFalse("Test should fail because no banner was sent when expecting a banner to be sent", future.isServiceDetected());
}
use of org.opennms.netmgt.provision.server.SimpleServer in project opennms by OpenNMS.
the class TcpDetectorTest method testServerCloses.
/**
* I think that this test is redundant with {@link #testFailureClosedPort()} since neither
* server is actually started. The detector just times out on both connections.
*/
@Test(timeout = 20000)
public void testServerCloses() throws Exception {
initializeDefaultDetector();
m_server = new SimpleServer() {
@Override
public void onInit() {
shutdownServer("Closing");
}
};
m_server.init();
//m_server.startServer();
m_detector.setPort(m_server.getLocalPort());
//assertFalse("Test should fail because the server closes before detection takes place", m_detector.isServiceDetected(m_server.getInetAddress()));
DetectFuture future = m_detector.isServiceDetected(m_server.getInetAddress());
assertNotNull(future);
future.awaitForUninterruptibly();
assertFalse(future.isServiceDetected());
}
use of org.opennms.netmgt.provision.server.SimpleServer in project opennms by OpenNMS.
the class MSExchangeDetectorTest method setUp.
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging();
m_pop3Server = new SimpleServer() {
@Override
public void onInit() {
setBanner(TEST_BANNER);
}
};
m_pop3Server.init();
m_pop3Server.startServer();
m_imapServer = new SimpleServer() {
@Override
public void onInit() {
setBanner(TEST_BANNER);
}
};
m_imapServer.init();
m_imapServer.startServer();
m_detector = m_detectorFactory.createDetector();
m_detector.setPop3Port(110);
m_detector.setImapPort(143);
m_detector.setTimeout(500);
}
Aggregations