Search in sources :

Example 1 with RequestImpl

use of org.jboss.resteasy.specimpl.RequestImpl in project keycloak-protocol-cas by jacekkow.

the class ContentTypeHelperTest method get.

private ContentTypeHelper get(String uri, String acceptHeader) throws Exception {
    MockHttpRequest req = MockHttpRequest.get(uri);
    MockHttpResponse res = new MockHttpResponse();
    RequestImpl restReq = new RequestImpl(req, res);
    if (acceptHeader != null) {
        req = req.header(HttpHeaders.ACCEPT, acceptHeader);
    }
    return new ContentTypeHelper(req, restReq, req.getUri());
}
Also used : MockHttpRequest(org.jboss.resteasy.mock.MockHttpRequest) ContentTypeHelper(org.keycloak.protocol.cas.utils.ContentTypeHelper) RequestImpl(org.jboss.resteasy.specimpl.RequestImpl) MockHttpResponse(org.jboss.resteasy.mock.MockHttpResponse)

Example 2 with RequestImpl

use of org.jboss.resteasy.specimpl.RequestImpl in project resteasy by resteasy.

the class SynchronousDispatcher method pushContextObjects.

@SuppressWarnings("unchecked")
public void pushContextObjects(final HttpRequest request, final HttpResponse response) {
    @SuppressWarnings("rawtypes") Map contextDataMap = ResteasyContext.getContextDataMap();
    contextDataMap.put(HttpRequest.class, request);
    contextDataMap.put(HttpResponse.class, response);
    contextDataMap.put(HttpHeaders.class, request.getHttpHeaders());
    contextDataMap.put(UriInfo.class, request.getUri());
    contextDataMap.put(Request.class, new RequestImpl(request, response));
    contextDataMap.put(ResteasyAsynchronousContext.class, request.getAsyncContext());
    ResourceContext resourceContext = new ResourceContext() {

        @Override
        public <T> T getResource(Class<T> resourceClass) {
            return providerFactory.injectedInstance(resourceClass, request, response);
        }

        @Override
        public <T> T initResource(T resource) {
            providerFactory.injectProperties(resource, request, response);
            return resource;
        }
    };
    contextDataMap.put(ResourceContext.class, resourceContext);
    contextDataMap.putAll(defaultContextObjects);
    contextDataMap.put(Cleanables.class, new Cleanables());
    contextDataMap.put(PostResourceMethodInvokers.class, new PostResourceMethodInvokers());
}
Also used : ResourceContext(jakarta.ws.rs.container.ResourceContext) Cleanables(org.jboss.resteasy.plugins.server.Cleanables) HashMap(java.util.HashMap) Map(java.util.Map) RequestImpl(org.jboss.resteasy.specimpl.RequestImpl)

Aggregations

RequestImpl (org.jboss.resteasy.specimpl.RequestImpl)2 ResourceContext (jakarta.ws.rs.container.ResourceContext)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 MockHttpRequest (org.jboss.resteasy.mock.MockHttpRequest)1 MockHttpResponse (org.jboss.resteasy.mock.MockHttpResponse)1 Cleanables (org.jboss.resteasy.plugins.server.Cleanables)1 ContentTypeHelper (org.keycloak.protocol.cas.utils.ContentTypeHelper)1