Example usage for org.apache.http.message BasicNameValuePair BasicNameValuePair

List of usage examples for org.apache.http.message BasicNameValuePair BasicNameValuePair

Introduction

In this page you can find the example usage for org.apache.http.message BasicNameValuePair BasicNameValuePair.

Prototype

public BasicNameValuePair(String str, String str2) 

Source Link

Usage

From source file:lh.api.showcase.server.lh.api.opperations.OperationsRequestFactoryImplTest.java

@Test
public void shouldConstructScheduleRequestUri() throws URISyntaxException {

    // e.g., https://api.lufthansa.com/v1/operations/schedules/FRA/KIX/2014-11-01?directFlights=true
    OperationsRequestFactoryImpl reqFact = new OperationsRequestFactoryImpl();

    URI constructedUri = reqFact.getRequestUri((NameValuePair) new BasicNameValuePair("schedules", ""),
            (List<NameValuePair>) Arrays.asList((NameValuePair) new BasicNameValuePair("FRA", ""),
                    (NameValuePair) new BasicNameValuePair("KIX", ""),
                    (NameValuePair) new BasicNameValuePair("2014-11-01", "")),
            Arrays.asList((NameValuePair) new BasicNameValuePair("directFlights", "true")));
    URI referenceUri = new URI(
            "https://api.lufthansa.com/v1/operations/schedules/FRA/KIX/2014-11-01?directFlights=true");

    logger.log(Level.INFO, "constructed: " + constructedUri.toString());
    logger.log(Level.INFO, "reference: " + referenceUri.toString());
    assertTrue(referenceUri.equals(constructedUri));
}

From source file:com.clxcommunications.xms.GroupFilterTest.java

@Test
public void canGenerateMinimal() throws Exception {
    GroupFilter filter = ClxApi.groupFilter().build();

    List<NameValuePair> actual = filter.toQueryParams(4);

    assertThat(actual, containsInAnyOrder((NameValuePair) new BasicNameValuePair("page", "4")));
}

From source file:org.amplafi.flow.strategies.CorruptParamsNameTestingStrategy.java

@Override
public Collection<NameValuePair> generateParameters(String flow, Collection<String> parameterNames) {
    // These elements may cause illegal JSON tokens
    String[] corruptParamElements = new String[] { " ", ".", "%", "{" };
    List<NameValuePair> bogusDataList = new ArrayList<NameValuePair>();
    int idx = 0;/* w  w w . j ava 2 s  .com*/
    for (String parameterName : parameterNames) {
        String badToken = "bad" + corruptParamElements[idx] + "token";
        bogusDataList.add(new BasicNameValuePair(badToken, "bogusData"));
        idx = (idx + 1) % corruptParamElements.length;
    }
    return bogusDataList;
}

From source file:eu.over9000.cathode.data.parameters.SearchChannelOptions.java

@Override
public List<NameValuePair> buildParamPairs() {
    if (query == null) {
        return Collections.emptyList();
    }/*from  ww  w. j a v  a  2s  . c  o  m*/
    return Collections.singletonList(new BasicNameValuePair("query", query));
}

From source file:com.compguide.web.ServerRequest.ServiceRequest.java

public static ProcessedTask requestNextTask(Header header, ProcessedTask processedTask,
        TaskRequest taskRequest) {//from   ww w  .  j a v  a 2 s.c  o  m

    HttpManager http = new HttpManager();
    ArrayList<BasicNameValuePair> valuePairRequest = new ArrayList<BasicNameValuePair>();
    valuePairRequest.add(new BasicNameValuePair("request", taskRequest.toJson()));

    http.setValuePairs(valuePairRequest);

    http.setURL(servicePath + "execution/guideline2/next/");

    return (ProcessedTask) http.sendPostNext2(processedTask, header);
}

From source file:org.lightcouch.Params.java

public Params conflicts() {
    params.add(new BasicNameValuePair("conflicts", "true"));
    return this;
}

From source file:org.opencastproject.remotetest.server.resource.ComposerResources.java

public static HttpResponse image(TrustedHttpClient client, String mediapackage, String time,
        String sourceTrackId, String profileId) throws Exception {
    HttpPost post = new HttpPost(getServiceUrl() + "encode");
    List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
    params.add(new BasicNameValuePair("mediapackage", mediapackage));
    params.add(new BasicNameValuePair("sourceTrackId", sourceTrackId));
    params.add(new BasicNameValuePair("time", time));
    params.add(new BasicNameValuePair("profileId", profileId));
    post.setEntity(new UrlEncodedFormEntity(params));
    return client.execute(post);
}

From source file:com.thoughtworks.go.spark.SparkController.java

default String controllerPath(Map<String, String> params) {
    if (params == null || params.isEmpty()) {
        return controllerBasePath();
    } else {//from  ww  w.j ava  2  s. c om
        List<BasicNameValuePair> queryParams = params.entrySet().stream()
                .map(entry -> new BasicNameValuePair(entry.getKey(), entry.getValue()))
                .collect(Collectors.toList());
        return controllerBasePath() + '?' + URLEncodedUtils.format(queryParams, "utf-8");
    }
}

From source file:org.wildfly.swarm.servlet.jpa.jta.test.ServletJpaJtaTest.java

@Test
@RunAsClient// w w  w.j av a  2s  . c  om
@InSequence(2)
public void create() throws IOException {
    String result = Request.Post("http://localhost:8080/")
            .bodyForm(new BasicNameValuePair("title", "Title"), new BasicNameValuePair("author", "Author"))
            .execute().returnContent().asString().trim();

    assertThat(result).isNotEmpty();
    id = Integer.parseInt(result);
}

From source file:com.google.resting.component.impl.json.JSONRequestParams.java

/**
 * To add input params in the format//from w  w w. j  a  va 2  s.co m
 * &valueArrayKey={valueArray[0],valueArray[1]...}
 * 
 * @param valueArrayKey
 * @param valueArray
 */
public void add(String valueArrayKey, String[] valueArray) {
    JSONArray jsonArray = new JSONArray();
    for (String value : valueArray) {
        jsonArray.put(value);
    }
    queryParams.add(new BasicNameValuePair(valueArrayKey, jsonArray.toString()));
}