Package org.apache.http.message

Examples of org.apache.http.message.BasicNameValuePair


  @Test
  public void apiKeyGetsAddedAndSignatureGenerated() throws ApplicationException, IOException {
    final String method = "test.call";
   
    List<NameValuePair> params = new ArrayList<>();
    params.add(new BasicNameValuePair(PARAM_METHOD, method));

    TestWSPostAuthenticatedClient client = getTestWSClient(params, FAILED_KEY_RESOURCE);
    params = client.getParams();
   
    client.executeWSRequest(params);
View Full Code Here


        PARAM_METHOD + METHOD +
        PARAM_TOKEN + TOKEN + API_SEC;
    final String API_SIG = new String(encodeHex(getInstance("md5").digest(signature.getBytes(UTF8))));

    List<NameValuePair> params = new ArrayList<>();
    params.add(new BasicNameValuePair(PARAM_METHOD, METHOD));
    params.add(new BasicNameValuePair(PARAM_TOKEN, TOKEN));
    params.add(new BasicNameValuePair(PARAM_API_KEY, API_KEY));

    TestWSGetAuthenticatedClient testWSClient = new TestWSGetAuthenticatedClient(params);
    testWSClient.testCall();

    Assert.assertNotNull(params);
View Full Code Here

 
  @Test
  public void validateURIBuilder() throws ApplicationException {
    final String artistName = "Madonna";
    final String trackName = "Holiday";
    NameValuePair artist = new BasicNameValuePair(PARAM_ARTIST, artistName);
    NameValuePair track = new BasicNameValuePair(PARAM_TRACK, trackName);
    NameValuePair api_key = new BasicNameValuePair(PARAM_API_KEY, API_KEY);
    URI uri = new AbstractWSGetClient() {
    }.getURI(Arrays.asList(artist, track, api_key));
    String expected = HTTP + "://" + HOST + PATH
    + "?" + PARAM_ARTIST + "=" + artistName
    + "&" + PARAM_TRACK + "=" + trackName
View Full Code Here

  @Test
  public void validateURIBuilderForSpecialChars() throws ApplicationException, UnsupportedEncodingException {
    final String artistName = "Sonny & Cher";
    final String trackName = "I Got You Babe";
    NameValuePair artist = new BasicNameValuePair(PARAM_ARTIST, artistName);
    NameValuePair track = new BasicNameValuePair(PARAM_TRACK, trackName);
    NameValuePair api_key = new BasicNameValuePair(PARAM_API_KEY, API_KEY);
    URI uri = new AbstractWSGetClient() {
    }.getURI(Arrays.asList(artist, track, api_key));
    String expected = HTTP + "://" + HOST + PATH
    + "?" + PARAM_ARTIST + "=" + URLEncoder.encode(artistName, UTF8)
    + "&" + PARAM_TRACK + "=" + URLEncoder.encode(trackName, UTF8)
View Full Code Here

  public static final String METHOD = "track.updateNowPlaying";

  public WSResponse updateNowPlaying(Scrobble scrobble) throws ApplicationException {
    List<NameValuePair> params = getDefaultParameterList();
    params.add(new BasicNameValuePair(PARAM_METHOD, METHOD));
    params.add(new BasicNameValuePair(PARAM_ARTIST, scrobble.getTrack().getArtist().getName()));
    params.add(new BasicNameValuePair(PARAM_ALBUM, scrobble.getTrack().getMetaData().getAlbum()));
    params.add(new BasicNameValuePair(PARAM_TRACK, scrobble.getTrack().getName()));
    params.add(new BasicNameValuePair(PARAM_DURATION, "" + scrobble.getTrack().getMetaData().getDuration()));
    params.add(new BasicNameValuePair(PARAM_SK, scrobble.getLastFmUser().getSessionKey()));

    return executeWSRequest(params);
  }
View Full Code Here

  public WSResponse getTopTags(Artist artist) throws ApplicationException {
    WebserviceInvocation webserviceInvocation =
      new WebserviceInvocation(ARTIST_GET_TOP_TAGS, artist);

    List<NameValuePair> params = getDefaultParameterList();
    params.add(new BasicNameValuePair(PARAM_METHOD, METHOD));
    params.add(new BasicNameValuePair(PARAM_ARTIST, artist.getName()));
   
    return executeWSRequest(webserviceInvocation, params);
  }
View Full Code Here

  public WSResponse getTopTracks(Artist artist) throws ApplicationException {
    WebserviceInvocation webserviceInvocation =
      new WebserviceInvocation(ARTIST_GET_TOP_TRACKS, artist);

    List<NameValuePair> params = getDefaultParameterList();
    params.add(new BasicNameValuePair(PARAM_METHOD, METHOD));
    params.add(new BasicNameValuePair(PARAM_ARTIST, artist.getName()));
    // tried adding autocorrect=1, but even simple misspellings didn't get corrected
   
    return executeWSRequest(webserviceInvocation, params);
  }
View Full Code Here

  public WSResponse getUserTopArtists(LastFmUser user, Period period) throws ApplicationException {
    WebserviceInvocation webserviceInvocation =
      new WebserviceInvocation(USER_GET_TOP_ARTISTS, user, period.getDays());

    List<NameValuePair> params = getDefaultParameterList();
    params.add(new BasicNameValuePair(PARAM_METHOD, METHOD));
    params.add(new BasicNameValuePair(PARAM_USER, user.getLastFmUsername()));
    params.add(new BasicNameValuePair(PARAM_PERIOD, period.getDescription()));
   
    return executeWSRequest(webserviceInvocation, params);
  }
View Full Code Here

 
  public String get(String artistName, String mbid, int offset) throws ApplicationException {
    WebserviceInvocation invocation = new WebserviceInvocation(
        MB_RELEASE_GROUPS, new Artist(artistName));
    List<NameValuePair> params = new ArrayList<>();
    params.add(new BasicNameValuePair(QUERY, format(PATTERN, mbid)));
    params.add(new BasicNameValuePair(LIMIT, HUNDRED));
    params.add(new BasicNameValuePair(OFFSET, valueOf(offset)));
    return executeWSRequest(invocation, PATH, params);
  }
View Full Code Here

    super(WSConfiguration.AUTHENTICATED_UNLOGGED);
  }
 
  public WSResponse getRadioPlaylist() throws ApplicationException {
    List<NameValuePair> params = getDefaultParameterList();
    params.add(new BasicNameValuePair(PARAM_METHOD, METHOD));
    params.add(new BasicNameValuePair(PARAM_SK, "5cd6b262eed1fcecc8752eb78eb1db78"));
   
    return executeWSRequest(null, params);
  }
View Full Code Here

TOP

Related Classes of org.apache.http.message.BasicNameValuePair

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.