Example usage for java.net URI create

List of usage examples for java.net URI create

Introduction

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

Prototype

public static URI create(String str) 

Source Link

Document

Creates a URI by parsing the given string.

Usage

From source file:org.apache.taverna.gis.GisActivityFactoryTest.java

@Test
public void testGetActivityURI() {
    assertEquals(URI.create(GisActivity.ACTIVITY_TYPE), activityFactory.getActivityType());
}

From source file:com.almende.eve.test.TestAgents.java

/**
 * Test agents.//  w w  w. j av a  2 s. co  m
 *
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws InterruptedException
 *             the interrupted exception
 */
@Test
public void testAgent() throws IOException, InterruptedException {

    final InstantiationServiceConfig isconfig = new InstantiationServiceConfig();
    final FileStateConfig state = new FileStateConfig();
    state.setPath(".wakeservices");
    state.setId("testAgents");
    isconfig.setState(state);

    final HttpTransportConfig transportConfig = new HttpTransportConfig();
    transportConfig.setServletUrl("http://localhost:8080/agents/");

    transportConfig.setServletLauncher("JettyLauncher");
    final ObjectNode jettyParms = JOM.createObjectNode();
    jettyParms.put("port", 8080);
    transportConfig.set("jetty", jettyParms);

    final AgentConfig config = new AgentConfig("example");
    config.addTransport(transportConfig);
    config.setInstantiationService(isconfig);

    ExampleAgent agent = new ExampleAgent();
    agent.setConfig(config);

    final Params callParams = new Params();
    callParams.add("message", "Hello world!");
    agent.pubSend(URI.create("http://localhost:8080/agents/example"), "helloWorld", callParams,
            new AsyncCallback<String>() {

                @Override
                public void onSuccess(final String result) {
                    LOG.warning("Received:'" + result + "'");
                }

                @Override
                public void onFailure(final Exception exception) {
                    LOG.log(Level.SEVERE, "", exception);
                    fail();
                }

            });

    LOG.warning("Sync received:'" + agent.pubSendSync(URI.create("http://localhost:8080/agents/example"),
            "helloWorld", callParams, new TypeUtil<String>() {
            }) + "'");

    // Try to get rid of the agent instance from memory
    agent = null;
    System.gc();
    System.gc();

    final AgentConfig ac = new AgentConfig("tester");
    ac.addTransport(transportConfig);
    final ExampleAgent tester = new ExampleAgent() {
    };
    tester.setConfig(ac);

    LOG.warning("Sync received:'"
            + tester.pubSendSync(URI.create("http://localhost:8080/agents/example"), "helloWorld",
                    callParams.deepCopy().put("message", "Hello world after sleep!"), new TypeUtil<String>() {
                    })
            + "'");

    tester.runComplexTypeTest(URI.create("http://localhost:8080/agents/example"));
}

From source file:com.gopivotal.cla.github.RateLimitingClientHttpRequestInterceptorTest.java

@Test
public void block() throws InterruptedException, IOException {
    CountDownLatch latch = new CountDownLatch(1);

    MockClientHttpRequest request = new MockClientHttpRequest();
    MockClientHttpResponse response = new MockClientHttpResponse(new byte[0], HttpStatus.OK);
    ClientHttpRequestExecution execution = mock(ClientHttpRequestExecution.class);

    request.setMethod(HttpMethod.GET);/*from   w  w w  .j  a va 2 s  . c o  m*/
    request.setURI(URI.create("http://localhost"));

    when(execution.execute(request, new byte[0])).thenReturn(response);

    new Thread(new Trigger(this.interceptor, latch)).start();
    latch.await();

    this.interceptor.intercept(request, new byte[0], execution);
}

From source file:org.fcrepo.http.api.repository.FedoraRepositoryNodeTypesTest.java

@Before
public void setUp() throws Exception {
    initMocks(this);
    testObj = new FedoraRepositoryNodeTypes();
    setField(testObj, "nodeService", mockNodes);
    setField(testObj, "uriInfo", getUriInfoImpl());
    mockSession = mockSession(testObj);/* w  ww  .j a v  a2  s  .com*/
    setField(testObj, "session", mockSession);
    when(mockUriInfo.getBaseUriBuilder()).thenReturn(mockUriBuilder);
    when(mockUriBuilder.path(any(Class.class))).thenReturn(mockUriBuilder);
    when(mockUriBuilder.build(any(String.class))).thenReturn(URI.create("mock:uri"));
}

From source file:com.sap.core.odata.fit.basic.issues.TestIssue105.java

@Test
public void checkContextForDifferentHostNamesRequests()
        throws ClientProtocolException, IOException, ODataException, URISyntaxException {
    URI uri1 = URI.create(getEndpoint().toString() + "$metadata");

    HttpGet get1 = new HttpGet(uri1);
    HttpResponse response1 = getHttpClient().execute(get1);
    assertNotNull(response1);//from ww w.j  a v a2s  . c o m

    URI serviceRoot1 = getService().getProcessor().getContext().getPathInfo().getServiceRoot();
    assertEquals(uri1.getHost(), serviceRoot1.getHost());

    get1.reset();

    URI uri2 = new URI(uri1.getScheme(), uri1.getUserInfo(), "127.0.0.1", uri1.getPort(), uri1.getPath(),
            uri1.getQuery(), uri1.getFragment());

    HttpGet get2 = new HttpGet(uri2);
    HttpResponse response2 = getHttpClient().execute(get2);
    assertNotNull(response2);

    URI serviceRoot2 = getService().getProcessor().getContext().getPathInfo().getServiceRoot();
    assertEquals(uri2.getHost(), serviceRoot2.getHost());
}

From source file:io.pravega.segmentstore.storage.impl.extendeds3.S3ProxyImpl.java

public S3ProxyImpl(String endpoint, S3Config s3Config) {
    URI uri = URI.create(endpoint);

    Properties properties = new Properties();
    properties.setProperty("s3proxy.authorization", "none");
    properties.setProperty("s3proxy.endpoint", endpoint);
    properties.setProperty("jclouds.provider", "filesystem");
    properties.setProperty("jclouds.filesystem.basedir", "/tmp/s3proxy");

    ContextBuilder builder = ContextBuilder.newBuilder("filesystem").credentials("x", "x")
            .modules(ImmutableList.<Module>of(new SLF4JLoggingModule())).overrides(properties);
    BlobStoreContext context = builder.build(BlobStoreContext.class);
    BlobStore blobStore = context.getBlobStore();
    s3Proxy = S3Proxy.builder().awsAuthentication(AuthenticationType.AWS_V2_OR_V4, "x", "x").endpoint(uri)
            .keyStore("", "").blobStore(blobStore).ignoreUnknownHeaders(true).build();
    client = new S3JerseyCopyPartClient(s3Config);
}

From source file:base.tina.external.http.HttpTask.java

@Override
public final void run() throws Exception {
    if (httpPlugin == null || httpPlugin.url == null)
        return;//w w w.  j  a v a  2s.c o  m
    //#debug 
    base.tina.core.log.LogPrinter.d(null, "-----------" + httpPlugin.url + "-----------");
    httpClient = new DefaultHttpClient();
    httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 60000);
    httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 60000);
    HttpResponse response;

    if (httpPlugin.requestData == null && httpPlugin.requestDataInputStream == null) {
        HttpGet getRequest = new HttpGet(URI.create(httpPlugin.url));
        request = getRequest;
        response = httpClient.execute(getRequest);
    } else {
        HttpPost requestPost = new HttpPost(URI.create(httpPlugin.url));

        request = requestPost;

        // request.setHeader("Connention", "close");

        if (httpPlugin.requestDataInputStream != null) {
            InputStream instream = httpPlugin.requestDataInputStream;
            InputStreamEntity inputStreamEntity = new InputStreamEntity(instream, httpPlugin.dataLength);
            requestPost.setEntity(inputStreamEntity);
        } else {
            InputStream instream = new ByteArrayInputStream(httpPlugin.requestData);
            InputStreamEntity inputStreamEntity = new InputStreamEntity(instream,
                    httpPlugin.requestData.length);
            requestPost.setEntity(inputStreamEntity);
        }
        response = httpClient.execute(requestPost);
    }
    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
        httpPlugin.parseData(EntityUtils.toByteArray(response.getEntity()));
        commitResult(httpPlugin, CommitAction.WAKE_UP);
    } else {
        //#debug error
        base.tina.core.log.LogPrinter.e(null,
                "Http error : " + new String(EntityUtils.toByteArray(response.getEntity())));
        throw new Exception("Http response code is : " + response.getStatusLine().getStatusCode());
    }
}

From source file:org.apache.taverna.robundle.manifest.PathAnnotation.java

private URI relativizePath(Path path) {
    return URI.create("/.ro/").relativize(URI.create(path.toUri().getRawPath()));
}

From source file:net.oneandone.shared.artifactory.SearchByGavTest.java

/**
 * Test of buildSearchURI method, of class SearchByGav.
 *//*from w  w w .  j  a va2  s  . com*/
@Test
public void testBuildSearchURI() {
    URI expResult = URI.create("http://localhost/api/search/gavc?repos=repo1&g=junit&a=junit&v=4.11");
    URI result = sut.buildSearchURI(repositoryName, gav);
    assertEquals(expResult, result);
}