//System.out.println(">>>ContentNegotiationTest.testJSONFeedGet");
RequestOptions opts = new RequestOptions();
opts.setHeader( "Accept", "application/json" );
// JSON feed request
ClientResponse res = client.get(providerURI, opts);
Assert.assertNotNull(res);
try {
// Assert feed provided since no predicates
Assert.assertEquals(200, res.getStatus());
// Abdera 0.4 throws exception on getContentType with application/json.
// System.out.println( "ContentNegotiationTest.testJSONEntryGet contentType=" + res.getContentType());
String contentType = res.getHeader( "Content-Type");
Assert.assertTrue( -1 < contentType.indexOf( "application/json" ));
// Following is a poor man's JSONObject test to avoid dependency on JSON libs.
// JSONObject jsonResp = new JSONObject(res.);
// Assert.assertEquals(12345, jsonResp.getInt("result"));
String responseBody = readResponse( res.getReader() );
Assert.assertTrue( responseBody.startsWith( "{") );
Assert.assertTrue( responseBody.endsWith( "}") );
Assert.assertTrue( -1 < responseBody.indexOf( "\"id\"" ));
Assert.assertTrue( -1 < responseBody.indexOf( "\"title\"" ));
Assert.assertTrue( -1 < responseBody.indexOf( "\"updated\"" ));
Assert.assertTrue( -1 < responseBody.indexOf( "\"entries\"" ));
// AtomTestCaseUtils.printResponseHeaders( "JSON Entry response headers:", " ", res );
// System.out.println( "ContentNegotiationTest.testJSONEntryGet JSON entry body=" + responseBody );
} finally {
res.release();
}
}