Example usage for java.net URI URI

List of usage examples for java.net URI URI

Introduction

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

Prototype

public URI(String str) throws URISyntaxException 

Source Link

Document

Constructs a URI by parsing the given string.

Usage

From source file:com.ettrema.httpclient.ReportMethod.java

public ReportMethod(String uri) throws URISyntaxException {
    setURI(new URI(uri));
}

From source file:io.cloudslang.content.httpclient.build.RequestBuilderTest.java

@Test
public void testMethods() throws URISyntaxException {
    HttpRequestBase httpRequestBase = new RequestBuilder().setUri(new URI("/")).setMethod("GET").build();
    assertEquals(httpRequestBase.getMethod(), "GET");
    httpRequestBase = new RequestBuilder().setUri(new URI("/")).setMethod("POST").build();
    assertEquals(httpRequestBase.getMethod(), "POST");
    httpRequestBase = new RequestBuilder().setUri(new URI("/")).setMethod("PUT").build();
    assertEquals(httpRequestBase.getMethod(), "PUT");
    httpRequestBase = new RequestBuilder().setUri(new URI("/")).setMethod("DELETE").build();
    assertEquals(httpRequestBase.getMethod(), "DELETE");
    httpRequestBase = new RequestBuilder().setUri(new URI("/")).setMethod("TRACE").build();
    assertEquals(httpRequestBase.getMethod(), "TRACE");
    httpRequestBase = new RequestBuilder().setUri(new URI("/")).setMethod("OPTIONS").build();
    assertEquals(httpRequestBase.getMethod(), "OPTIONS");
    httpRequestBase = new RequestBuilder().setUri(new URI("/")).setMethod("HEAD").build();
    assertEquals(httpRequestBase.getMethod(), "HEAD");

    httpRequestBase = new RequestBuilder().setUri(new URI("/")).setMethod("get").build();
    assertEquals(httpRequestBase.getMethod(), "GET");
    httpRequestBase = new RequestBuilder().setUri(new URI("/")).setMethod("post").build();
    assertEquals(httpRequestBase.getMethod(), "POST");
    httpRequestBase = new RequestBuilder().setUri(new URI("/")).setMethod("put").build();
    assertEquals(httpRequestBase.getMethod(), "PUT");
}

From source file:com.orange.cloud.servicebroker.filter.securitygroups.domain.Destination.java

public Destination(String uriString) {
    try {/*w ww . ja va 2  s. c o m*/
        URI uri = new URI(uriString);
        setHost(uri.getHost());
        if (noPort(uri)) {
            setDefaultPort(uri.getScheme());
        } else {
            setPort(ImmutablePort.of(uri.getPort()));
        }
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException("Cannot create connection info. Invalid URI " + uriString, e);
    }
}

From source file:org.apache.sling.etcd.client.impl.EtcdClientFactoryImplTest.java

@Test
public void testCreate() throws Exception {
    CloseableHttpClient httpClient = Mockito.mock(CloseableHttpClient.class);
    EtcdClientFactory factory = new EtcdClientFactoryImpl();
    EtcdClient client = factory.create(httpClient, new URI("localhost:4001"));
    Assert.assertNotNull(client);/*from  w  w w.  j av  a 2  s.co m*/
}

From source file:com.knowledgecode.cordova.websocket.ConnectionTask.java

/**
 * Complement default port number.//from  w  w w  . ja  va2 s.c  o m
 *
 * @param url
 * @return URI
 * @throws URISyntaxException
 */
private static URI complementPort(String url) throws URISyntaxException {
    URI uri = new URI(url);
    int port = uri.getPort();

    if (port < 0) {
        if ("ws".equals(uri.getScheme())) {
            port = 80;
        } else if ("wss".equals(uri.getScheme())) {
            port = 443;
        }
        uri = new URI(uri.getScheme(), "", uri.getHost(), port, uri.getPath(), uri.getQuery(), "");
    }
    return uri;
}

From source file:com.rusticisoftware.tincan.Activity.java

public Activity(String id) throws URISyntaxException {
    this(new URI(id));
}

From source file:HelloWorld.HelloWorldTest.java

@Test
public void getPeopleNotExist() throws URISyntaxException, IOException {
    URI uri = new URI(baseURI + "api/person/sally");
    HttpGet get = new HttpGet(uri);
    CloseableHttpResponse response = client.execute(get);

    assertEquals(404, response.getStatusLine().getStatusCode());
    assertEquals("No person exists with specified name.", EntityUtils.toString(response.getEntity(), "UTF-8"));
}

From source file:client.ClientBase.java

/**
 * Computes an aboslute URI from a relative path.
 *
 * @param relativePath the relative path
 * @return the absolute URI/* w w w  .j av a  2s  .com*/
 */
protected URI uri(final String relativePath) {
    try {
        return new URI(_baseUrl).resolve(relativePath);
    } catch (final URISyntaxException e) {
        throw Throwables.propagate(e);
    }
}

From source file:bazaar4idea.data.BzrUrl.java

public BzrUrl(String urlString) throws URISyntaxException {
    uri = new URI(urlString).normalize();
    scheme = SCHEMES.get(uri.getScheme());
}

From source file:test.pl.chilldev.web.tags.page.XmlnsTagTest.java

@Test
public void doTag() throws URISyntaxException, JspTagException {
    JspContext context = new MockPageContext();
    XmlnsTag tag = new XmlnsTag();
    tag.setJspContext(context);//from w ww . j av a2 s .  c  om

    // set up context
    String attribute = "foo";
    context.setAttribute(attribute, this.page);

    // set up resolver
    PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute));

    URI namespace = new URI("http://chilldev.pl/");
    String alias = "cdv";

    // run the tag
    tag.setNamespace(namespace);
    tag.setAlias(alias);
    tag.doTag();

    verify(this.page).setXmlNamespace(namespace, alias);
}