use of org.opennms.netmgt.provision.server.SimpleServer in project opennms by OpenNMS.
the class Pop3DetectorTest method setUp.
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging();
m_server = new SimpleServer() {
@Override
public void onInit() {
setBanner("+OK");
addResponseHandler(startsWith("QUIT"), shutdownServer("+OK"));
// setExpectedClose("QUIT", "+OK");
}
};
m_server.init();
m_server.startServer();
m_detector = createDetector(m_server.getLocalPort());
}
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 AsyncDetectorFileDescriptorLeakTest method setUpServer.
private void setUpServer(final String banner, final int bannerDelay) throws Exception {
m_server = new SimpleServer() {
@Override
public void onInit() {
if (banner != null) {
setBanner(banner);
setBannerDelay(bannerDelay);
}
}
};
// No timeout
m_server.setTimeout(0);
// m_server.setThreadSleepLength(0);
m_server.init();
m_server.startServer();
}
use of org.opennms.netmgt.provision.server.SimpleServer in project opennms by OpenNMS.
the class ImapDetectorTest method testDetectorFailUnexpectedLogoutResponse.
@Test(timeout = 20000)
public void testDetectorFailUnexpectedLogoutResponse() throws Exception {
m_server = new SimpleServer() {
@Override
public void onInit() {
setBanner("* NOT OK THIS IS A BANNER FOR IMAP");
addResponseHandler(contains("LOGOUT"), singleLineRequest("* NOT OK"));
}
};
m_server.init();
m_server.startServer();
try {
m_detector.setPort(m_server.getLocalPort());
// assertFalse(m_detector.isServiceDetected(m_server.getInetAddress()));
DetectFuture future = m_detector.isServiceDetected(m_server.getInetAddress());
assertNotNull(future);
future.awaitForUninterruptibly();
assertFalse(future.isServiceDetected());
} finally {
m_server.stopServer();
}
}
use of org.opennms.netmgt.provision.server.SimpleServer in project opennms by OpenNMS.
the class ImapDetectorTest method testDetectorFailUnexpectedBanner.
@Test(timeout = 20000)
public void testDetectorFailUnexpectedBanner() throws Exception {
m_server = new SimpleServer() {
@Override
public void onInit() {
setBanner("* NOT OK THIS IS A BANNER FOR IMAP");
}
};
m_server.init();
m_server.startServer();
try {
m_detector.setPort(m_server.getLocalPort());
// assertFalse(m_detector.isServiceDetected(m_server.getInetAddress()));
DetectFuture future = m_detector.isServiceDetected(m_server.getInetAddress());
assertNotNull(future);
future.awaitForUninterruptibly();
assertFalse(future.isServiceDetected());
} finally {
m_server.stopServer();
}
}
Aggregations