https://github.com/arteam/embedded-http-server
A light and minimalistic HTTP server for Java with zero dependencies and quick startup time
https://github.com/arteam/embedded-http-server
http java unit-testing
Last synced: 3 months ago
JSON representation
A light and minimalistic HTTP server for Java with zero dependencies and quick startup time
- Host: GitHub
- URL: https://github.com/arteam/embedded-http-server
- Owner: arteam
- License: mit
- Created: 2016-06-06T06:53:45.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-05-13T10:30:21.000Z (5 months ago)
- Last Synced: 2025-05-13T11:33:43.062Z (5 months ago)
- Topics: http, java, unit-testing
- Language: Java
- Size: 172 KB
- Stars: 18
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: readme.adoc
- License: LICENSE
Awesome Lists containing this project
README
# Embedded HTTP server
`embedded-http-server` is a light and minimalistic Java HTTP server with zero dependencies
and quick startup time.## Maven
```xml
com.github.arteam
embedded-http-server
1.2```
## Description
`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.## Application
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.## Advantages
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:* https://openjdk.java.net/groups/net/httpclient/intro.html[Java11 HTTP Client]
* https://hc.apache.org/[Apache HTTP Client],
* https://github.com/square/okhttp[OkHTTP],
* https://jersey.java.net/documentation/latest/client.html[Jersey HTTP Client],
* http://docs.spring.io/spring/docs/4.0.x/javadoc-api/org/springframework/web/client/RestTemplate.html[Spring Rest Template],
* or even with http://docs.oracle.com/javase/8/docs/api/java/net/URLConnection.html[URLConnection].## Alternatives
If you need a real HTTP server for serving a production worload, you should definitely take a look at
* http://www.eclipse.org/jetty/[Jetty],
* https://tomcat.apache.org/[Tomcat],
* http://undertow.io/[Undertow],
* or http://netty.io/[Netty].