Package org.opensocial.providers

Examples of org.opensocial.providers.OrkutProvider


    final String url = "http://example.org/test";
    final Map<String, String> headers = new HashMap<String, String>();

    SecurityTokenScheme authScheme = new SecurityTokenScheme(TOKEN);

    HttpMessage message = authScheme.getHttpMessage(new OrkutProvider(), "GET",
        url, headers, null);
    assertEquals(url + "?st=" + TOKEN, message.url.toString());
  }
View Full Code Here


    final String url = "http://example.org/test?arg=value";
    final Map<String, String> headers = new HashMap<String, String>();

    SecurityTokenScheme authScheme = new SecurityTokenScheme(TOKEN);

    HttpMessage message = authScheme.getHttpMessage(new OrkutProvider(), "GET",
        url, headers, null);
    assertEquals(url + "&st=" + TOKEN, message.url.toString());
  }
View Full Code Here

    final Map<String, String> headers = new HashMap<String, String>();

    SecurityTokenScheme authScheme = new SecurityTokenScheme(TOKEN_NAME,
        TOKEN);

    HttpMessage message = authScheme.getHttpMessage(new OrkutProvider(), "GET",
        url, headers, null);
    assertEquals(url + "?" + TOKEN_NAME + "=" + TOKEN, message.url.toString());
  }
View Full Code Here

  private static final String CONSUMER_KEY = "orkut.com:623061448914";
  private static final String CONSUMER_SECRET = "uynAeXiWTisflWX99KU1D2q5";

  @Test(expected = RequestException.class)
  public void testEmptyRequestQueue() throws RequestException, IOException {
    Client client = new Client(new OrkutProvider(), new OAuth2LeggedScheme(
        CONSUMER_KEY, CONSUMER_SECRET, VIEWER_ID));

    Map<String, Request> requests = new HashMap<String, Request>();
    client.send(requests);
  }
View Full Code Here

    IMocksControl mockControl = EasyMock.createControl();

    HttpClient httpClient = mockControl.createMock(HttpClient.class);
    AuthScheme authScheme = mockControl.createMock(AuthScheme.class);

    OrkutProvider provider = new OrkutProvider();

    Client client = new Client(provider, authScheme, httpClient);

    Request request = new Request(null, "service.method", null);
    request.setContentType("test/content-type");

    String rpcEndPoint = provider.getRpcEndpoint();
    rpcEndPoint = rpcEndPoint.substring(0, rpcEndPoint.length() - 1);

    HttpResponseMessage httpResponseMessage = new HttpResponseMessage("GET",
        new URL(provider.getRpcEndpoint()), 200, stringToInputStream("[]"));

    EasyMock.expect(authScheme.getHttpMessage(eq(provider), eq("POST"),
        eq(rpcEndPoint), isA(Map.class), isA(byte[].class)))
        .andAnswer(new IAnswer<HttpMessage>() {
          public HttpMessage answer() throws Throwable {
View Full Code Here

    IMocksControl mockControl = EasyMock.createControl();

    HttpClient httpClient = mockControl.createMock(HttpClient.class);
    AuthScheme authScheme = mockControl.createMock(AuthScheme.class);

    OrkutProvider provider = new OrkutProvider();

    Client client = new Client(provider, authScheme, httpClient);

    Request request = new Request(null, "service.method", null);
    byte[] payload = "testpayload".getBytes();
    request.setCustomPayload(payload);

    String rpcEndPoint = provider.getRpcEndpoint();
    rpcEndPoint = rpcEndPoint.substring(0, rpcEndPoint.length() - 1);

    HttpResponseMessage httpResponseMessage = new HttpResponseMessage("GET",
        new URL(provider.getRpcEndpoint()), 200, stringToInputStream("[]"));

    EasyMock.expect(authScheme.getHttpMessage(eq(provider), eq("POST"),
        eq(rpcEndPoint), isA(Map.class), eq(payload))).andReturn(null);

    EasyMock.expect(httpClient.execute((HttpMessage) eq(null))).andReturn(
View Full Code Here

    IMocksControl mockControl = EasyMock.createControl();

    HttpClient httpClient = mockControl.createMock(HttpClient.class);
    AuthScheme authScheme = mockControl.createMock(AuthScheme.class);

    OrkutProvider provider = new OrkutProvider();

    Client client = new Client(provider, authScheme, httpClient);

    Request request = new Request(null, null, null);
    request.addRpcQueryStringParameter("key1", "value1");
    request.addRpcQueryStringParameter("key2", "value2");

    String rpcUrl = provider.getRpcEndpoint();
    rpcUrl = rpcUrl.substring(0, rpcUrl.length() - 1);
    String rpcUrl1 = rpcUrl + "?key1=value1&key2=value2";
    String rpcUrl2 = rpcUrl + "?key2=value2&key1=value1";

    EasyMock.expect(authScheme.getHttpMessage(eq(provider), eq("POST"),
        or(eq(rpcUrl1), eq(rpcUrl2)), isA(Map.class), isA(byte[].class)))
        .andReturn(null);

    HttpResponseMessage httpResponseMessage = new HttpResponseMessage("GET",
        new URL(provider.getRpcEndpoint()), 200, stringToInputStream("[]"));

    EasyMock.expect(httpClient.execute((HttpMessage) eq(null))).andReturn(
        httpResponseMessage);

    mockControl.replay();
View Full Code Here

    retrieveSelfFromOrkut(true);
  }

  private void retrieveSelfFromOrkut(boolean useRest) {
    try {
      Client client = new Client(new OrkutProvider(useRest),
          new OAuth2LeggedScheme(ORKUT_KEY, ORKUT_SECRET, ORKUT_ID));
      Request request = PeopleService.getViewer();
      Response response = client.send(request);

      Person self = response.getEntry();
View Full Code Here

    retrieveFriendsFromOrkut(true);
  }

  private void retrieveFriendsFromOrkut(boolean useRest) {
    try {
      Client client = new Client(new OrkutProvider(useRest),
          new OAuth2LeggedScheme(ORKUT_KEY, ORKUT_SECRET, ORKUT_ID));
      Request request = PeopleService.getFriends();
      Response response = client.send(request);

      Person self = response.getEntry();
View Full Code Here

*
*/
public class BaseRequestTest extends AbstractRequestTest {
  @BeforeClass
  public static void init() {
    client = new Client(new OrkutProvider(false), new OAuth2LeggedScheme(
        "consumerKey", "consumerSecret"));
  }
View Full Code Here

TOP

Related Classes of org.opensocial.providers.OrkutProvider

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.