Example usage for java.net URI toString

List of usage examples for java.net URI toString

Introduction

In this page you can find the example usage for java.net URI toString.

Prototype

public String toString() 

Source Link

Document

Returns the content of this URI as a string.

Usage

From source file:org.opencredo.couchdb.core.CouchDbDocumentTemplateTest.java

@SuppressWarnings("unchecked")
@Test/* w w w .  j  a  va 2  s .co m*/
public void writeDocumentToUri() throws Exception {
    DummyDocument document = new DummyDocument("hello");
    URI uri = new URI("http://test");
    documentTemplate.writeDocument(uri, document);
    verify(restOperations).put(eq(uri.toString()), argThat(bodyEqual(document)), anyMap());
}

From source file:edu.ncsu.lib.ole.test.JsonValidator.java

JsonSchema loadSchemaByName(String schemaName) {
    if (!schemas.containsKey(schemaName)) {
        String path = "/schemas/" + schemaName + ".json";
        try {// w  w w.  j a v  a 2s . com
            URI theURI = getClass().getResource(path).toURI();
            JsonSchema schema = factory.getJsonSchema(theURI.toString());
            schemas.put(schemaName, schema);
        } catch (ProcessingException e) {
            throw new IllegalStateException("Unable to read schema for " + schemaName, e);
        } catch (NullPointerException | URISyntaxException badx) {
            throw new IllegalStateException("Unable to load " + schemaName + " schema from classpath", badx);
        }
    }
    return schemas.get(schemaName);
}

From source file:at.ac.univie.isc.asio.integration.RequestSpecAssembler.java

private RequestSpecBuilder datasetRequest(final IntegrationDsl dsl, final URI baseUri) {
    final URI authedBaseUri = config.auth.configureUri(baseUri, dsl.getRole());
    RequestSpecBuilder request = new RequestSpecBuilder().setBaseUri(authedBaseUri.toString());
    request = config.auth.configureRequestSpec(request, dsl.getRole());

    final UsernamePasswordCredentials delegated = dsl.getDelegated();
    if (delegated != null) {
        request = config.auth.attachCredentials(delegated.getUserName(), delegated.getPassword(), request);
    }//from   ww  w . j a  v a  2 s.com

    return request;
}

From source file:org.springside.examples.bootservice.functional.TaskRestServiceTest.java

@Test
public void createUpdateAndDeleteTask() {

    // create// w ww . j  a v a  2s  . c  o m
    Task task = randomTask();

    URI createdTaskUri = restTemplate.postForLocation(resourceUrl, task);
    System.out.println(createdTaskUri.toString());
    Task createdTask = restTemplate.getForObject(createdTaskUri, Task.class);
    assertThat(createdTask.title).isEqualTo(task.title);

    // update
    String id = StringUtils.substringAfterLast(createdTaskUri.toString(), "/");
    task.id = new Long(id);
    task.title = RandomData.randomName("Task");

    restTemplate.put(createdTaskUri, task);

    Task updatedTask = restTemplate.getForObject(createdTaskUri, Task.class);
    assertThat(updatedTask.title).isEqualTo(task.title);

    // delete
    restTemplate.delete(createdTaskUri);
    Task deletedTask = restTemplate.getForObject(createdTaskUri, Task.class);
    assertThat(deletedTask).isNull();
}

From source file:com.unboundid.scim2.common.messages.PatchOperation.java

/**
 * Create a new replace patch operation.
 *
 * @param path The path targeted by this patch operation.  The path
 *             must not be {@code null}.
 *             Path string examples:/*from   w  w  w  .  j av a2s . c  o  m*/
 *               "{@code userName eq 'bjensen'}"
 *               "{@code userName}"
 * @param value The value(s) to replace.  The value must not be {@code null}.
 *
 * @return The new replace patch operation.
 * @throws ScimException If the path is invalid.
 */
public static PatchOperation replace(final String path, final URI value) throws ScimException {
    return replace(path, value.toString());
}

From source file:org.openlmis.fulfillment.service.stockmanagement.StockEventStockManagementServiceTest.java

@Test
public void shouldSubmitStockEvent() {
    ResponseEntity response = mock(ResponseEntity.class);
    when(restTemplate.exchange(any(URI.class), eq(HttpMethod.POST), any(HttpEntity.class), eq(UUID.class)))
            .thenReturn(response);/*from www .  j a  va 2s .c  o m*/

    service.submit(new StockEventDto());

    verify(restTemplate).exchange(uriCaptor.capture(), eq(HttpMethod.POST), entityCaptor.capture(),
            eq(UUID.class));

    URI uri = uriCaptor.getValue();
    String url = service.getServiceUrl() + service.getUrl();

    assertThat(uri.toString(), is(equalTo(url)));
    assertThat(entityCaptor.getValue().getBody(), is(new StockEventDto()));
}

From source file:se.vgregion.pubsub.impl.DefaultTopic.java

public DefaultTopic(URI url, PublicationRetryer publicationRetryer) {
    Assert.notNull(url);//ww  w.  j  av a  2 s.c  om

    this.url = url.toString();
    this.publicationRetryer = publicationRetryer;
}

From source file:com.google.appengine.tck.util.GaeAuthClient.java

protected String getCookieUrl(String servletUrl, String authToken) throws URISyntaxException {
    URI servletUri = new URI(servletUrl);
    URI cookieUri = servletUri.resolve("/_ah/login?auth=" + authToken);
    return cookieUri.toString();
}

From source file:org.n52.javaps.InfoEndpoint.java

@Setting(SERVICE_URL)
public void setServiceURL(final URI serviceURL) throws ConfigurationError {
    Validation.notNull("Service URL", serviceURL);
    String url = serviceURL.toString();
    if (url.contains("?")) {
        url = url.split("[?]")[0];
    }/*from w  ww . ja  va 2 s.c  o  m*/
    this.serviceURL = url;
}

From source file:com.electronicpanopticon.spring.web.rest.RestClient.java

/**
 * This method logs into a service by doing an standard http using the
 * configuration in this class.//from  ww  w  .  j a  va 2s  . c  o m
 * 
 * @param username
 *            the username to log into the application with
 * @param password
 *            the password to log into the application with
 * 
 * @return the url that the login redirects to
 */
public String login(String username, String password) {
    MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
    form.add(usernameInputFieldName, username);
    form.add(passwordInputFieldName, password);
    URI location = this.template.postForLocation(loginUrl(), form);
    return location.toString();
}