本文整理汇总了Java中org.glassfish.jersey.server.spi.ContainerResponseWriter类的典型用法代码示例。如果您正苦于以下问题:Java ContainerResponseWriter类的具体用法?Java ContainerResponseWriter怎么用?Java ContainerResponseWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContainerResponseWriter类属于org.glassfish.jersey.server.spi包,在下文中一共展示了ContainerResponseWriter类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createContainerRequest
import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
/**
* Creates a new {@link ContainerRequest} for the given input.
*
* @param request
* @param containerResponseWriter
* @param securityContext
* @return
*/
@Nonnull
protected ContainerRequest createContainerRequest(@Nonnull RequestT request,
@Nonnull ContainerResponseWriter containerResponseWriter, @Nonnull SecurityContext securityContext) {
requireNonNull(request, "request may not be null");
URI baseUri = request.getBaseUri();
URI requestUri = requireNonNull(request.getRequestUri(), "request.getRequestUri() may not be null");
String httpMethod = requireNonNull(request.getHttpMethod(), "request.getHttpMethod() may not be null");
InputStream entityStream = requireNonNull(request.getEntityStream(),
"request.getEntityStream() may not be null");
Map<String, List<String>> headers = requireNonNull(request.getHeaders(),
"request.getHeaderParams() may not be null");
requireNonNull(containerResponseWriter, "containerResponseWriter may not be null");
requireNonNull(securityContext, "securityContext may not be null");
ContainerRequest requestContext = new ContainerRequest(baseUri, requestUri, httpMethod, securityContext,
new MapPropertiesDelegate());
requestContext.setEntityStream(entityStream);
requestContext.getHeaders().putAll(headers);
requestContext.setWriter(containerResponseWriter);
return requestContext;
}
示例2: ByteArrayInputStream
import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
@Test
public void createContainerRequest_RequestAndContainerResponseWriterAndSecurityContextGiven_ShouldCreateContainerRequestUsingValues() {
URI baseUri = URI.create("/");
URI requestUri = URI.create("/entity");
String httpMethod = "POST";
ByteArrayInputStream entityStream = new ByteArrayInputStream(new byte[0]);
MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
headers.add("hk0", "hv0_0");
headers.add("hk0", "hv0_1");
headers.add("hk1", "hv1_0");
JRestlessContainerRequest request = createRequest(baseUri, requestUri, httpMethod, entityStream, headers);
ContainerResponseWriter containerResponseWriter = mock(ContainerResponseWriter.class);
SecurityContext securityContext = mock(SecurityContext.class);
ContainerRequest containerRequest = container.createContainerRequest(request, containerResponseWriter, securityContext);
assertEquals(baseUri, containerRequest.getBaseUri());
assertEquals(requestUri, containerRequest.getRequestUri());
assertEquals(httpMethod, containerRequest.getMethod());
assertSame(entityStream, containerRequest.getEntityStream());
assertEquals(headers, containerRequest.getHeaders());
assertSame(containerResponseWriter, containerRequest.getResponseWriter());
assertSame(securityContext, containerRequest.getSecurityContext());
}
示例3: flushResponse
import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
private void flushResponse(RequestEvent requestEvent) {
try {
ContainerResponseWriter writer = requestEvent.getContainerRequest().getResponseWriter();
writer.writeResponseStatusAndHeaders(0, requestEvent.getContainerResponse()).flush();
} catch (Exception e) {
// no op
}
}
示例4: createContainerRequest_NoRequestGiven_ShouldThrowNpe
import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
@Test
public void createContainerRequest_NoRequestGiven_ShouldThrowNpe() {
assertThrows(NullPointerException.class, () -> container.createContainerRequest(null, mock(ContainerResponseWriter.class), mock(SecurityContext.class)));
}
示例5: createContainerRequest_NoSecurityContext_ShouldThrowNpe
import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
@Test
public void createContainerRequest_NoSecurityContext_ShouldThrowNpe() {
assertThrows(NullPointerException.class, () -> container.createContainerRequest(createAnyRequest(), mock(ContainerResponseWriter.class), null));
}
示例6: createContainerRequest_NoRequestBaseUriGiven_ShouldPass
import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
public void createContainerRequest_NoRequestBaseUriGiven_ShouldPass() {
JRestlessContainerRequest request = createAnyRequest();
when(request.getBaseUri()).thenReturn(null);
container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class));
}
示例7: createContainerRequest_NoRequestRequestUriGiven_ShouldThrowNpe
import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
@Test
public void createContainerRequest_NoRequestRequestUriGiven_ShouldThrowNpe() {
JRestlessContainerRequest request = createAnyRequest();
when(request.getRequestUri()).thenReturn(null);
assertThrows(NullPointerException.class, () -> container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class)));
}
示例8: createContainerRequest_NoRequestHttpMethodGiven_ShouldThrowNpe
import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
@Test
public void createContainerRequest_NoRequestHttpMethodGiven_ShouldThrowNpe() {
JRestlessContainerRequest request = createAnyRequest();
when(request.getHttpMethod()).thenReturn(null);
assertThrows(NullPointerException.class, () -> container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class)));
}
示例9: createContainerRequest_NoRequestEntityStreamGiven_ShouldThrowNpe
import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
@Test
public void createContainerRequest_NoRequestEntityStreamGiven_ShouldThrowNpe() {
JRestlessContainerRequest request = createAnyRequest();
when(request.getEntityStream()).thenReturn(null);
assertThrows(NullPointerException.class, () -> container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class)));
}
示例10: createContainerRequest_NoRequestHeadersGiven_ShouldThrowNpe
import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
@Test
public void createContainerRequest_NoRequestHeadersGiven_ShouldThrowNpe() {
JRestlessContainerRequest request = createAnyRequest();
when(request.getHeaders()).thenReturn(null);
assertThrows(NullPointerException.class, () -> container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class)));
}
示例11: setWriter
import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
/**
* <p>setWriter.</p>
*
* @param responseWriter a {@link org.glassfish.jersey.server.spi.ContainerResponseWriter} object.
*/
public static void setWriter(ContainerResponseWriter responseWriter) {
getRequest().setWriter(responseWriter);
}
示例12: getResponseWriter
import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
/**
* <p>getResponseWriter.</p>
*
* @return a {@link org.glassfish.jersey.server.spi.ContainerResponseWriter} object.
*/
public static ContainerResponseWriter getResponseWriter() {
return getRequest().getResponseWriter();
}