List of usage examples for java.net URI create
public static URI create(String str)
From source file:com.yahoo.gondola.container.LocalTestRoutingServer.java
public LocalTestRoutingServer(Gondola gondola, RoutingHelper routingHelper, ProxyClientProvider proxyClientProvider, Map<String, RoutingService> services, ChangeLogProcessor changeLogProcessor) throws Exception { routingFilter = new RoutingFilter(gondola, routingHelper, proxyClientProvider, services, changeLogProcessor);/*from w w w . j a va 2s .co m*/ routingFilter.start(); localTestServer = new LocalTestServer((request, response, context) -> { try { URI requestUri = URI.create(request.getRequestLine().getUri()); URI baseUri = URI .create(requestUri.getScheme() + "://" + requestUri.getHost() + ":" + requestUri.getPort()); ContainerRequest containerRequest = new ContainerRequest(baseUri, requestUri, request.getRequestLine().getMethod(), null, new MapPropertiesDelegate()); routingFilter.filter(containerRequest); Response abortResponse = containerRequest.getAbortResponse(); Response jaxrsResponse; if (abortResponse != null) { jaxrsResponse = abortResponse; } else { jaxrsResponse = new OutboundJaxrsResponse.Builder(null).status(200).build(); } ContainerResponse containerResponse = new ContainerResponse(containerRequest, jaxrsResponse); routingFilter.filter(containerRequest, containerResponse); response.setStatusCode(containerResponse.getStatus()); response.setEntity(new StringEntity(containerResponse.getEntity().toString())); Set<Map.Entry<String, List<Object>>> entries = containerResponse.getHeaders().entrySet(); for (Map.Entry<String, List<Object>> e : entries) { String headerName = e.getKey(); for (Object o : e.getValue()) { String headerValue = o.toString(); response.setHeader(headerName, headerValue); } } } catch (Exception e) { e.printStackTrace(); throw e; } }); host = localTestServer.start(); }
From source file:no.digipost.api.useragreements.client.Examples.java
public void instantiate_client() { InputStream key = getClass().getResourceAsStream("certificate.p12"); HttpHost proxy = new HttpHost("proxy.example.com", 8080, "http"); final BrokerId brokerId = BrokerId.of(1234L); DigipostUserAgreementsClient client = new DigipostUserAgreementsClient.Builder(brokerId, key, "password") .useProxy(proxy) //optional .setHttpClientBuilder(HttpClientBuilder.create()) //optional .serviceEndpoint(URI.create("https://api.digipost.no")) //optional .build();/*from ww w . j a v a2s . c om*/ }
From source file:com.netflix.iep.http.ClientConfigTest.java
@Before public void before() { clear("foo.niws.client.UseIpAddress"); clear("niws.client.UseIpAddress"); final URI uri = URI.create("/test"); cfg = new ClientConfig(archaius, "foo", "foo:7001", uri, uri); }
From source file:ch.cyberduck.core.dav.DAVClient.java
@Override public <T> T execute(final HttpRequestBase request, final ResponseHandler<T> responseHandler) throws IOException { if (StringUtils.isNotBlank(request.getURI().getRawQuery())) { request.setURI(URI.create( String.format("%s%s?%s", uri, request.getURI().getRawPath(), request.getURI().getRawQuery()))); } else {//from w ww . jav a2 s . c om request.setURI(URI.create(String.format("%s%s", uri, request.getURI().getRawPath()))); } return super.execute(request, responseHandler); }
From source file:cn.com.loopj.android.http.HttpGet.java
/** * @param uri target url as String//from w w w. j a v a2 s .co m * @throws IllegalArgumentException if the uri is invalid. */ public HttpGet(final String uri) { super(); setURI(URI.create(uri)); }
From source file:com.collective.celos.ci.deploy.JScpWorkerTest.java
@Test public void getURIRespectingUsernameDoesntChange1() throws FileSystemException, URISyntaxException { JScpWorker worker = new JScpWorker("uname"); URI uri = worker.getURIRespectingUsername(URI.create("sftp://user@server/path1/path2")); Assert.assertEquals(uri, URI.create("sftp://user@server/path1/path2")); }
From source file:com.ge.predix.acs.commons.web.ResponseEntityBuilder.java
/** * Creates a typed ResponseEntity with HTTP status code 201/204 with a given location. * * @param location//from ww w.ja v a2 s . c o m * The location of the created resource * @param noContent * false means updated resource which returns 204, true means created resource which returns 201 * @return The corresponding ResponseEntity */ public static <T> ResponseEntity<T> created(final String location, final boolean noContent) { HttpStatus status = noContent ? HttpStatus.NO_CONTENT : HttpStatus.CREATED; if (location != null) { HttpHeaders headers = new HttpHeaders(); headers.setLocation(URI.create(location)); return new ResponseEntity<T>(headers, status); } return new ResponseEntity<T>(status); }
From source file:com.thinkbiganalytics.alerts.rest.model.AlertSummaryGrouped.java
public AlertSummaryGrouped(String type, String subtype, String typeDisplayName) { this(URI.create(type), subtype, typeDisplayName); }
From source file:io.syndesis.credential.BaseCredentialProviderTest.java
@Test public void shouldGenerateCallbackUrlWithParameters() { final MultiValueMap<String, String> some = new LinkedMultiValueMap<>(); some.set("param1", "value1"); some.set("param2", "value2"); assertThat(BaseCredentialProvider.callbackUrlFor(URI.create("https://syndesis.io/api/v1/"), some)) .as("The computed callback URL is not as expected") .isEqualTo("https://syndesis.io/api/v1/credentials/callback?param1=value1¶m2=value2"); }
From source file:cn.com.loopj.android.http.HttpDelete.java
/** * @param uri target url as String/*from w w w . ja va 2 s . c o m*/ * @throws IllegalArgumentException if the uri is invalid. */ public HttpDelete(final String uri) { super(); setURI(URI.create(uri)); }