Package org.apache.http.client.utils

Examples of org.apache.http.client.utils.URIBuilder


        ProxyClient proxyClient = new ProxyClient("127.0.0.1", getProxyPort()).reset();

        // when
        httpClient.execute(
                new HttpGet(
                        new URIBuilder()
                                .setScheme("http")
                                .setHost("localhost")
                                .setPort(getServerPort())
                                .setPath("/test_headers_and_body")
                                .build()
                )
        );
        httpClient.execute(
                new HttpGet(
                        new URIBuilder()
                                .setScheme("http")
                                .setHost("localhost")
                                .setPort(getServerPort())
                                .setPath("/test_headers_only")
                                .build()
View Full Code Here


        ProxyClient proxyClient = new ProxyClient("127.0.0.1", getProxyPort()).reset();

        // when
        httpClient.execute(
                new HttpGet(
                        new URIBuilder()
                                .setScheme("http")
                                .setHost("localhost")
                                .setPort(getServerPort())
                                .setPath("/test_headers_and_body")
                                .build()
View Full Code Here

        ProxyClient proxyClient = new ProxyClient("127.0.0.1", getProxyPort()).reset();

        // when
        httpClient.execute(
                new HttpGet(
                        new URIBuilder()
                                .setScheme("http")
                                .setHost("localhost")
                                .setPort(getServerPort())
                                .setPath("/test_headers_and_body")
                                .build()
View Full Code Here

        ProxyClient proxyClient = new ProxyClient("127.0.0.1", getProxyPort()).reset();

        // when
        httpClient.execute(
                new HttpGet(
                        new URIBuilder()
                                .setScheme("http")
                                .setHost("localhost")
                                .setPort(getServerPort())
                                .setPath("/test_headers_and_body")
                                .build()
View Full Code Here

        ProxyClient proxyClient = new ProxyClient("127.0.0.1", getProxyPort()).reset();

        // when
        httpClient.execute(
                new HttpGet(
                        new URIBuilder()
                                .setScheme("http")
                                .setHost("localhost")
                                .setPort(getServerPort())
                                .setPath("/test_headers_and_body")
                                .build()
                )
        );
        httpClient.execute(
                new HttpGet(
                        new URIBuilder()
                                .setScheme("http")
                                .setHost("localhost")
                                .setPort(getServerPort())
                                .setPath("/test_headers_and_body")
                                .build()
View Full Code Here

        ProxyClient proxyClient = new ProxyClient("127.0.0.1", getProxyPort()).reset();

        // when
        httpClient.execute(
                new HttpGet(
                        new URIBuilder()
                                .setScheme("http")
                                .setHost("localhost")
                                .setPort(getServerPort())
                                .setPath("/test_headers_and_body")
                                .build()
                )
        );
        httpClient.execute(
                new HttpGet(
                        new URIBuilder()
                                .setScheme("http")
                                .setHost("localhost")
                                .setPort(getServerPort())
                                .setPath("/test_headers_only")
                                .build()
View Full Code Here

        ProxyClient proxyClient = new ProxyClient("127.0.0.1", getProxyPort()).reset();

        // when
        httpClient.execute(
                new HttpGet(
                        new URIBuilder()
                                .setScheme("http")
                                .setHost("localhost")
                                .setPort(getServerPort())
                                .setPath("/test_headers_and_body")
                                .build()
                )
        );
        httpClient.execute(
                new HttpGet(
                        new URIBuilder()
                                .setScheme("http")
                                .setHost("localhost")
                                .setPort(getServerPort())
                                .setPath("/test_headers_only")
                                .build()
View Full Code Here

  @Override
  public MetricServiceData getMetrics(MetricQuery query) throws RestClientException {
    URI url = metricBaseUrl.resolve("api/metric/").resolve(project + "/");

    URIBuilder uriBuilder = new URIBuilder(url);

    if (query != null) {
      for (String filter : query.filters) {
        int firstEquals = filter.indexOf('=');
        if (firstEquals == -1) {
          uriBuilder.addParameter("has." + filter, "");
        } else {
          String key = filter.substring(0, firstEquals);
          String value = filter.substring(firstEquals + 1);

          uriBuilder.addParameter("filter." + key, value);
        }
      }

      for (String projection : query.projections) {
        int firstEquals = projection.indexOf('=');
        if (firstEquals == -1) {
          uriBuilder.addParameter("select." + projection, "");
        } else {
          throw new IllegalArgumentException();
        }
      }

      if (query.flatten) {
        uriBuilder.addParameter("flatten", "true");
      }
    }

    try {
      url = uriBuilder.build();
    } catch (URISyntaxException e) {
      throw new IllegalArgumentException("Error building URI", e);
    }

    HttpGet request = new HttpGet(url);
View Full Code Here

 
  public String getAmbariServerURI(String path) {
    if(masterProtocol==null || masterHostname==null || masterPort==null)
      return null;
   
    URIBuilder uriBuilder = new URIBuilder();
    uriBuilder.setScheme(masterProtocol);
    uriBuilder.setHost(masterHostname);
    uriBuilder.setPort(masterPort);
    uriBuilder.setPath(path);
   
    return uriBuilder.toString();
  }
View Full Code Here

   
    metricsRegexes.add(FLUME_CHANNEL_CAPACITY_PROPERTY);

    String metricsList = getMetricsRegexes(metricsRegexes, gangliaPropertyIds, "FLUME_SERVER");
   
    URIBuilder expectedUri = new URIBuilder();
   
    expectedUri.setScheme((configuration.isGangliaSSL() ? "https" : "http"));
    expectedUri.setHost("domU-12-31-39-0E-34-E1.compute-1.internal");
    expectedUri.setPath("/cgi-bin/rrd.py");
    expectedUri.setParameter("c", "HDPFlumeServer,HDPSlaves");
    expectedUri.setParameter("h", "ip-10-39-113-33.ec2.internal");
    expectedUri.setParameter("m", metricsList);
    expectedUri.setParameter("s", "10");
    expectedUri.setParameter("e", "20");
    expectedUri.setParameter("r", "1");
   
    URIBuilder actualUri = new URIBuilder(streamProvider.getLastSpec());

    Assert.assertEquals(expectedUri.getScheme(), actualUri.getScheme());
    Assert.assertEquals(expectedUri.getHost(), actualUri.getHost());
    Assert.assertEquals(expectedUri.getPath(), actualUri.getPath());
   
    Assert.assertTrue(isUrlParamsEquals(actualUri, expectedUri));   
   
    Assert.assertEquals(3, PropertyHelper.getProperties(resource).size());
    Assert.assertNotNull(resource.getPropertyValue(FLUME_CHANNEL_CAPACITY_PROPERTY));
View Full Code Here

TOP

Related Classes of org.apache.http.client.utils.URIBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.