List of usage examples for java.net URI create
public static URI create(String str)
From source file:com.bt.aloha.batchtest.scenarios.ByeScenario.java
@Override protected void startScenario(String scenarioId) throws Exception { String firstDialogId = outboundCallLegBean.createCallLeg(getFromAddressUri(), getTestEndpointUri()); String secondDialogId = outboundCallLegBean.createCallLeg(getFromAddressUri(), URI.create(this.testEndpoint2)); String callId = null;/* ww w . j a v a2 s . c om*/ synchronized (lock) { callId = manager.selectNextCallBean(this).joinCallLegs(firstDialogId, secondDialogId, AutoTerminateAction.True); callScenarioMap.put(callId, scenarioId); } log.info(String.format("call %s started for scenario %s", callId, scenarioId)); updateScenario(scenarioId, SCENARIO_STARTED); }
From source file:com.arpnetworking.configuration.jackson.JsonNodeUriSourceTest.java
@Test public void test() throws MalformedURLException { final WireMockServer server = new WireMockServer(0); server.start();// www .j a va 2 s . c om final WireMock wireMock = new WireMock(server.port()); wireMock.register(WireMock.get(WireMock.urlEqualTo("/configuration")) .willReturn(WireMock.aResponse().withStatus(200) .withHeader("Content-Type", "application/json; charset=utf-8") .withBody("{\"values\":[\"foo\",\"bar\"]}"))); final JsonNodeUriSource jsonNodeUriSource = new JsonNodeUriSource.Builder() .setUri(URI.create("http://localhost:" + server.port() + "/configuration")).build(); final Optional<JsonNode> jsonNode = jsonNodeUriSource.getJsonNode(); Assert.assertTrue(jsonNode.isPresent()); Assert.assertTrue(jsonNode.get().isObject()); Assert.assertEquals(1, Iterators.size(((ObjectNode) jsonNode.get()).fieldNames())); final Optional<JsonNode> valuesJsonNode = jsonNodeUriSource.getValue("values"); Assert.assertTrue(valuesJsonNode.isPresent()); Assert.assertTrue(valuesJsonNode.get().isArray()); Assert.assertEquals(2, ((ArrayNode) valuesJsonNode.get()).size()); Assert.assertEquals("foo", ((ArrayNode) valuesJsonNode.get()).get(0).textValue()); Assert.assertEquals("bar", ((ArrayNode) valuesJsonNode.get()).get(1).textValue()); server.stop(); }
From source file:com.github.jknack.handlebars.springmvc.HandlebarsViewResolverTest.java
@Test public void configureNoDash() throws Exception { final TemplateLoader templateLoader = createMock(TemplateLoader.class); Template template = createMock(Template.class); final Handlebars handlebars = createMock(Handlebars.class); expect(handlebars.compile(URI.create("home"))).andReturn(template); HandlebarsView view = createMock(HandlebarsView.class); expect(view.getUrl()).andReturn("/home.hbs"); view.setTemplate(template);//from ww w. j av a2s . c om expectLastCall(); view.setValueResolver(MapValueResolver.INSTANCE, JavaBeanValueResolver.INSTANCE); expectLastCall(); replay(handlebars, view, template, templateLoader); HandlebarsViewResolver viewResolver = new HandlebarsViewResolver() { @Override protected Handlebars createHandlebars(final TemplateLoader templateLoader) { return handlebars; } @Override protected void configure(final Handlebars handlebars) { } @Override protected boolean isContextRequired() { return false; } @Override protected TemplateLoader createTemplateLoader(final ApplicationContext context) { return templateLoader; } }; viewResolver.afterPropertiesSet(); viewResolver.configure(view); verify(handlebars, view, template, templateLoader); }
From source file:org.meruvian.yama.webapi.service.RestSocialSignInService.java
@Override public Response socialSignIn(String provider) { String redirectUri = socialServiceLocator.getSocialService(provider).getAuthorizeUrl(); return Response.seeOther(URI.create(redirectUri)).build(); }
From source file:com.griddynamics.jagger.invoker.http.ApacheHttpInvoker.java
@Override protected HttpRequestBase getHttpMethod(HttpRequestBase query, String endpoint) { try {// w w w . j a v a 2s. c o m if (query.getURI() == null) { query.setURI(URI.create(endpoint)); return query; } else { URIBuilder uriBuilder = new URIBuilder(URI.create(endpoint)); uriBuilder.setQuery(query.getURI().getQuery()); uriBuilder.setFragment(query.getURI().getFragment()); uriBuilder.setUserInfo(query.getURI().getUserInfo()); if (!query.getURI().getPath().isEmpty()) { uriBuilder.setPath(query.getURI().getPath()); } query.setURI(uriBuilder.build()); return query; } } catch (Exception e) { throw new RuntimeException(e); } }
From source file:nl.salp.warcraft4j.io.HttpDataReader.java
public HttpDataReader(String url) throws DataParsingException { try {// w w w. j ava2 s.c o m httpClient = HttpClients.createDefault(); response = httpClient.execute(new HttpGet(URI.create(url))); responseStream = getResponseStream(url, response); } catch (Exception e) { try { close(); } catch (IOException ioe) { // Ignore. } throw new DataParsingException(e); } }
From source file:org.zalando.stups.oauth2.spring.server.LeakTokenTest.java
@Test public void testSocketTimeoutException() { ResourceAccessException targetException = null; RestTemplate restTemplate = new TestInternalRestTemplate(new HttpComponentsClientHttpRequestFactory()); try {/* w w w . j a v a2 s. c o m*/ restTemplate.exchange(DefaultTokenInfoRequestExecutor.buildRequestEntity(URI.create(URL), TOKEN), Map.class); } catch (ResourceAccessException e) { targetException = e; } // WE EXPECT NOT TO SEE ANYTHING FROM THE TOKEN Assertions.assertThat(targetException.getMessage()).startsWith(MESSAGE_STARTSWITH); Assertions.assertThat(targetException.getMessage()).doesNotContain(TOKEN); Assertions.assertThat(targetException.getCause().getMessage()).startsWith(JUST_FOR_TESTING); Assertions.assertThat(targetException.getCause().getMessage()).doesNotContain(TOKEN); }
From source file:com.collective.celos.ci.deploy.JScpWorkerTest.java
@Test public void getURIRespectingUsernameDoesntChange2() 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:ch.iterate.openstack.swift.model.Region.java
public URI getStorageUrl(String container, String object, List<NameValuePair> parameters) { return URI.create(String.format("%s?%s", this.getStorageUrl(container, object), URLEncodedUtils.format(parameters, "UTF-8"))); }
From source file:org.jclouds.http.httpnio.util.NioHttpUtilsTest.java
@Test(dataProvider = "gets") public void testConvert(String uri) { HttpEntityEnclosingRequest apacheRequest = NioHttpUtils.convertToApacheRequest( new HttpRequest(HttpMethods.GET, URI.create("https://s3.amazonaws.com:443/" + uri), ImmutableMultimap.of("Host", "s3.amazonaws.com"))); assertEquals(apacheRequest.getHeaders("Host")[0].getValue(), "s3.amazonaws.com"); assertEquals(apacheRequest.getRequestLine().getMethod(), "GET"); assertEquals(apacheRequest.getRequestLine().getUri(), "/" + uri); }