1
2
3
4
5 package com.jcabi.http.mock;
6
7 import java.io.ByteArrayInputStream;
8 import java.util.Collections;
9 import org.glassfish.grizzly.http.server.Request;
10 import org.hamcrest.MatcherAssert;
11 import org.hamcrest.Matchers;
12 import org.junit.jupiter.api.Test;
13 import org.mockito.Mockito;
14
15
16
17
18
19 final class GrizzlyQueryTest {
20
21
22
23
24
25 @Test
26 void returnsBinaryBody() throws Exception {
27 final Request request = Mockito.mock(Request.class);
28 Mockito.when(request.getRequestURI()).thenReturn("http://fake.com");
29 Mockito.when(request.getHeaderNames()).thenReturn(
30 Collections.<String>emptyList()
31 );
32 final byte[] body = "body".getBytes();
33 Mockito.when(request.getInputStream()).thenReturn(
34 new ByteArrayInputStream(body)
35 );
36 MatcherAssert.assertThat(
37 "should match the body",
38 new GrizzlyQuery(request).binary(),
39 Matchers.is(body)
40 );
41 }
42
43 }