@Override protected Request newRequest() { return new Request(loader, URI.create(requestUri)); }
public Request newServerRequest() { return new Request(driver, URI.create("mbus://localhost/")); }
/** * Create a new HTTP request from an URI. * * @param container the current container instance * @param uri the request parameters * @param method GET, POST, etc * @param requestData the associated data stream, may be null * @param properties a set of properties to set in the request in addition to the implicit ones from the URI * @return a new HTTP request */ public static HttpRequest createRequest(CurrentContainer container, URI uri, Method method, InputStream requestData, Map<String, String> properties) { com.yahoo.jdisc.http.HttpRequest clientRequest = com.yahoo.jdisc.http.HttpRequest.newClientRequest(new Request(container, uri), uri, method); setProperties(clientRequest, properties); return new HttpRequest(clientRequest, requestData); }
private static com.yahoo.jdisc.Request createDiscRequest(Request request, CurrentContainer currentContainer) { String scheme = getScheme(request.getUri()); com.yahoo.jdisc.Request discRequest; if ("http".equals(scheme) || "https".equals(scheme)) { com.yahoo.jdisc.http.HttpRequest httpRequest = com.yahoo.jdisc.http.HttpRequest.newServerRequest(currentContainer, URI.create(request.getUri()), com.yahoo.jdisc.http.HttpRequest.Method.valueOf(request.getMethod().name())); request.getUserPrincipal().ifPresent(httpRequest::setUserPrincipal); discRequest = httpRequest; } else { discRequest = new com.yahoo.jdisc.Request(currentContainer, URI.create(request.getUri())); } for (Map.Entry<String, List<String>> entry : request.getHeaders().entrySet()) { discRequest.headers().add(entry.getKey(), entry.getValue()); } discRequest.context().putAll(request.getAttributes()); return discRequest; }
/** * <p>Factory method to create a {@link Request} without an associated {@link Container}. The design of jDISC does * not allow this, so this method internally creates TestDriver, activates a Container, and creates a new Request * from that Container. Before returning, this method {@link Request#release() closes} the Request, and calls {@link * TestDriver#close()} on the TestDriver. This means that you MUST NOT attempt to access any Container features * through the created Request. This factory is only for directed feature tests that require a non-null * Request.</p> * * @param uri The URI string to assign to the Request. * @param guiceModules The guice modules to inject into the {@link Application}. * @return A non-working Request. */ public static Request newInstance(String uri, Module... guiceModules) { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(guiceModules); driver.activateContainer(driver.newContainerBuilder()); Request request = new Request(driver, URI.create(uri)); request.release(); driver.close(); return request; } }