Arquillian Deployable Container for Undertow
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.




Undertow is a flexible performant web server written in java, providing both blocking and non-blocking API’s based on NIO.

Undertow has a composition based architecture that allows you to build a web server by combining small single purpose handlers. The gives you the flexibility to choose between a full Java EE servlet 3.1 container, or a low level non-blocking handler, to anything in between.

Undertow is sponsored by JBoss and is the default web server in the Wildfly Application Server.

Writing tests for Undertow

Arquillian-Container-Undertow as every Arquillian Container Extension it take cares of you of starting, stopping and deploying the application. Also provides an Shrinkwrap resolver for creating the Undertow deployment file.

To simplify the development of tests on Undertow we have created two Shrinkwrap resolvers:

  • Embedded Servlet Deployment

  • Non-blocking handler

Embedded Servlet Deployment

When you want to deploy a servlet/s inside Undertow, you must create a DeploymentInfo class and provide all the required information. For this reason Arquillian-Container-Undertow provides a Shrinkwrap resolver named UndertowWebArchive.

@Deployment(testable = false)
public static Archive<WebArchive> createDeployment() {
	return ShrinkWrap.create(UndertowWebArchive.class).from(
					servlet("MessageServlet", MessageServlet.class)
						.addInitParam("message", "Hello World")

And then we can write our test:

public void shouldBeAbleToInvokeServletInDeployedWebApp(
		@ArquillianResource URL url) throws Exception {

	String body = readAllAndClose(new URL(url, "myservlet").openStream());

	assertThat(body, is("Hello World"));

Non-blocking handler

But with Undertow you can also write non-blocking handlers. For creating a non-blocking handler in Undertow you simply must create a class that implements HttpHandler interface and register it. For this reason Arquillian-Container-Undertow provides a Shrinkwrap resolver named UndertowHttpHandlerArchive.

@Deployment(testable = false)
public static Archive<JavaArchive> createDeployment() {
	return ShrinkWrap.create(UndertowHttpHandlerArchive.class).from(new HttpHandler() {
           public void handleRequest(final HttpServerExchange exchange) throws Exception {
               exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
               exchange.getResponseSender().send("Hello World");

And then we can write our test:

public void shouldBeAbleToInvokeHandlers(@ArquillianResource URL url) throws Exception {

	String body = readAllAndClose(url.openStream());

	assertThat(body, is("Hello World"));



You can configure the bind address and port of Undertow. By default Undertow is opened at localhost:8080.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<arquillian xmlns:xsi=""

    <container qualifier="undertow" default="true">

But you can also set the bind address and the listening port.

<container qualifier="undertow" default="true">
		<property name="bindAddress">localhost</property>
		<property name="bindHttpPort">9090</property> <!-- <1> -->
  1. If port is set to -1, a random port between 1024 and 49151 is used.


Arquillian-Container-Undertow is released on JBoss Maven Repositories so you need to set it on your pom file.

        <name>JBoss Public Maven Repository Group</name>

And add dependency as: