Search in sources :

Example 1 with ResponseMatcher

use of com.artipie.http.hm.ResponseMatcher in project artipie by artipie.

the class ResponseMetricsSliceTest method shouldForwardRequestUnmodified.

@Test
void shouldForwardRequestUnmodified() {
    final Header header = new Header("header1", "value1");
    final byte[] body = "some code".getBytes();
    final RsStatus status = RsStatus.CREATED;
    MatcherAssert.assertThat(new ResponseMetricsSlice((rsline, rsheaders, rsbody) -> new RsFull(status, rsheaders, rsbody), this.metrics).response(new RequestLine(RqMethod.POST, "/some_upload.war").toString(), new Headers.From(header), Flowable.just(ByteBuffer.wrap(body))), new ResponseMatcher(status, body, header));
}
Also used : RequestLine(com.artipie.http.rq.RequestLine) ResponseMatcher(com.artipie.http.hm.ResponseMatcher) RsFull(com.artipie.http.rs.RsFull) Header(com.artipie.http.headers.Header) RsStatus(com.artipie.http.rs.RsStatus) Test(org.junit.jupiter.api.Test)

Example 2 with ResponseMatcher

use of com.artipie.http.hm.ResponseMatcher in project artipie by artipie.

the class ResponseMetricsSliceTest method shouldForwardResponseUnmodified.

@Test
void shouldForwardResponseUnmodified() {
    final Header rsheader = new Header("header2", "value2");
    final byte[] body = "piece of code".getBytes();
    final RsStatus rsstatus = RsStatus.CREATED;
    final Response response = new ResponseMetricsSlice((rsline, rsheaders, rsbody) -> new RsFull(rsstatus, new Headers.From(rsheader), Flowable.just(ByteBuffer.wrap(body))), this.metrics).response(new RequestLine(RqMethod.PUT, "/").toString(), Headers.EMPTY, Flowable.empty());
    MatcherAssert.assertThat(response, new ResponseMatcher(rsstatus, body, rsheader));
}
Also used : Response(com.artipie.http.Response) RqMethod(com.artipie.http.rq.RqMethod) BeforeEach(org.junit.jupiter.api.BeforeEach) RsWithStatus(com.artipie.http.rs.RsWithStatus) Headers(com.artipie.http.Headers) Header(com.artipie.http.headers.Header) InMemoryMetrics(com.artipie.metrics.memory.InMemoryMetrics) ResponseMatcher(com.artipie.http.hm.ResponseMatcher) Response(com.artipie.http.Response) RsStatus(com.artipie.http.rs.RsStatus) CompletableFuture(java.util.concurrent.CompletableFuture) ByteBuffer(java.nio.ByteBuffer) RsFull(com.artipie.http.rs.RsFull) Test(org.junit.jupiter.api.Test) Authorization(com.artipie.http.headers.Authorization) RequestLine(com.artipie.http.rq.RequestLine) MatcherAssert(org.hamcrest.MatcherAssert) Flowable(io.reactivex.Flowable) IsEqual(org.hamcrest.core.IsEqual) RequestLine(com.artipie.http.rq.RequestLine) ResponseMatcher(com.artipie.http.hm.ResponseMatcher) RsFull(com.artipie.http.rs.RsFull) Header(com.artipie.http.headers.Header) Headers(com.artipie.http.Headers) RsStatus(com.artipie.http.rs.RsStatus) Test(org.junit.jupiter.api.Test)

Aggregations

Header (com.artipie.http.headers.Header)2 ResponseMatcher (com.artipie.http.hm.ResponseMatcher)2 RequestLine (com.artipie.http.rq.RequestLine)2 RsFull (com.artipie.http.rs.RsFull)2 RsStatus (com.artipie.http.rs.RsStatus)2 Test (org.junit.jupiter.api.Test)2 Headers (com.artipie.http.Headers)1 Response (com.artipie.http.Response)1 Authorization (com.artipie.http.headers.Authorization)1 RqMethod (com.artipie.http.rq.RqMethod)1 RsWithStatus (com.artipie.http.rs.RsWithStatus)1 InMemoryMetrics (com.artipie.metrics.memory.InMemoryMetrics)1 Flowable (io.reactivex.Flowable)1 ByteBuffer (java.nio.ByteBuffer)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 MatcherAssert (org.hamcrest.MatcherAssert)1 IsEqual (org.hamcrest.core.IsEqual)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1