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();