Package org.elasticsearch.test.fixture
Class AbstractHttpFixture
java.lang.Object
org.junit.rules.ExternalResource
org.elasticsearch.test.fixture.AbstractHttpFixture
- All Implemented Interfaces:
org.junit.rules.TestRule
public abstract class AbstractHttpFixture
extends org.junit.rules.ExternalResource
Base class for test fixtures that requires a
HttpServer to work.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classRepresents an HTTP Request.static interfaceprotected static final recordRepresents an HTTP Response. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final byte[] -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractHttpFixture(String workingDir) protectedAbstractHttpFixture(String workingDir, int port) -
Method Summary
Modifier and TypeMethodDescriptioncontentType(String contentType) protected abstract AbstractHttpFixture.Responsehandle(AbstractHttpFixture.Request request) final voidlisten()Opens aHttpServerand start listening on a provided or random port.final voidlisten(InetAddress inetAddress, boolean exposePidAndPort) Opens aHttpServerand start listening on a provided or random port.final voidlisten(InetSocketAddress socketAddress, boolean exposePidAndPort) final voidlistenAndWait(InetSocketAddress socketAddress, boolean exposePidAndPort) protected voidstop()Methods inherited from class org.junit.rules.ExternalResource
after, apply, before
-
Field Details
-
TEXT_PLAIN_CONTENT_TYPE
-
JSON_CONTENT_TYPE
-
EMPTY_BYTE
protected static final byte[] EMPTY_BYTE
-
-
Constructor Details
-
AbstractHttpFixture
-
AbstractHttpFixture
-
AbstractHttpFixture
public AbstractHttpFixture()
-
-
Method Details
-
listen
Opens aHttpServerand start listening on a provided or random port.- Throws:
IOExceptionInterruptedException
-
listen
public final void listen(InetAddress inetAddress, boolean exposePidAndPort) throws IOException, InterruptedException Opens aHttpServerand start listening on a provided or random port.- Throws:
IOExceptionInterruptedException
-
listenAndWait
public final void listenAndWait(InetSocketAddress socketAddress, boolean exposePidAndPort) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
listen
public final void listen(InetSocketAddress socketAddress, boolean exposePidAndPort) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
handle
protected abstract AbstractHttpFixture.Response handle(AbstractHttpFixture.Request request) throws IOException - Throws:
IOException
-
stop
protected void stop() -
getAddress
-
getHostAndPort
-
contentType
-