multithreading - Why Unit test of WebServer project shows strange behaviour? -
i writing unit test of project http threadpooled web server. using junit in maven.
in mean while stuck in 1 place, , doubt follows,
there 1 class named webserver, task start server, makes threadpool, , starts listening on port client request. when make thread same, in test class under annotation
@beforeclass
, expected wait client request , comes out shows test completes.public class webservertest {
@beforeclass public static void webserverstarter() { system.out.println("before class : webserverstarter"); new thread(new webserver()).start(); } @afterclass public static void webservercleanup() { system.out.println("after class : webserverstarter"); }
}
i don't understand why not waits client request. please me in writing unit test testing http threadpooled webserver.
the @before executed before every single test. if want use 1 single webserver, make object!
Comments
Post a Comment