embedded-http-server
is a light and minimalistic Java HTTP server with zero dependencies
and quick startup time.
<dependency>
<groupId>com.github.arteam</groupId>
<artifactId>embedded-http-server</artifactId>
<version>1.2</version>
</dependency>
embedded-http-server
is a thin wrapper around com.sun.net.HttpServer
. The internal Sun server is
quite fast, provides a Java API for accessing requests/responses and already shipped in
the JDK. Unfortunately, the API is quite confusing, not documented and the server lacks
error reporting. This library tries to solve these issues by providing a nice and functional
API for scripting an HTTP server without a long startup time.
The primary use case is integration testing of HTTP clients. You often need to fire up an HTTP server in tests to create a test double for a remote HTTP server. That test double should ideally be rather fast, otherwise you lose the advantage of the quick turnaround time and eventually switch to testing on a "live" system. Some people are also opionated about including huge projects as external dependencies without a specific need and want to avoid bloating the classpath.
The project is not tied to any external API and can be used with any HTTP client or framework. You can use it with any HTTP client you like: