@Test
public void testSubmitRpcContentType() throws RequestException, IOException {
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 {
Map<String, String> requestHeaders =
(Map<String, String>) EasyMock.getCurrentArguments()[3];
assertEquals("test/content-type",
requestHeaders.get(HttpMessage.CONTENT_TYPE));
return null;
}
});
EasyMock.expect(httpClient.execute(
(HttpMessage) eq(null))).andReturn(httpResponseMessage);
mockControl.replay();
client.send(request);