ElideServerTest

abstract class ElideServerTest : Test

Base class for Micronaut tests which want to use the enclosed convenience functions.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
@Inject
lateinit var app: EmbeddedServer
Link copied to clipboard
@Inject
lateinit var beanContext: BeanContext
Link copied to clipboard
@Inject
lateinit var client: HttpClient
Link copied to clipboard
@Inject
lateinit var context: ApplicationContext

Functions

Link copied to clipboard
fun exchange(request: MutableHttpRequest<Any>, status: Int? = 200, block: HttpResponse<Any>.() -> Unit? = null): HttpResponse<Any>
fun <P : Any, R : Any> exchange(request: MutableHttpRequest<P>, status: Int? = 200, responseType: Class<R>, block: HttpResponse<R>.() -> Unit? = null): HttpResponse<R>

Exchange a test request with the current server, expecting status as an HTTP return status; after executing the request to obtain the response, block is executed (if provided) to perform additional assertions on the response.

Link copied to clipboard
fun exchangeHTML(request: MutableHttpRequest<Any>, accept: String? = "text/html,*/*", status: Int? = 200, block: HttpResponse<Any>.(Document) -> Unit? = null): HttpResponse<Any>

Syntactic sugar to exchange a request with the active Elide server which is expected to produce HTML; assertions are run against the response (expected status, content-type/encoding/length, etc), and then the page is parsed with Jsoup and handed to block for additional testing.