String text = "text";
Form form = new Form();
form.add("key", "value");
client = new Client(Protocol.HTTP);
Request request = new Request(method, "http://localhost:8111/test");
Response response = client.handle(request);
assertTrue(response.getStatus().isSuccess());
response.getEntity().release();
request = new Request(method, "http://localhost:8111/test");
request.getClientInfo().getAcceptedMediaTypes()
.add(new Preference<MediaType>(MediaType.TEXT_HTML));
response = client.handle(request);
assertEquals(MediaType.TEXT_HTML, response.getEntity().getMediaType());
response.getEntity().release();
request = new Request(method, "http://localhost:8111/test");
request.getClientInfo().getAcceptedMediaTypes()
.add(new Preference<MediaType>(MediaType.TEXT_PLAIN));
response = client.handle(request);
assertEquals(MediaType.TEXT_PLAIN, response.getEntity().getMediaType());
response.getEntity().release();
request = new Request(method, "http://localhost:8111/test");
request.setEntity(text, MediaType.TEXT_PLAIN);
request.getClientInfo().getAcceptedMediaTypes()
.add(new Preference<MediaType>(MediaType.TEXT_HTML));
response = client.handle(request);
assertEquals(MediaType.TEXT_PLAIN, response.getEntity().getMediaType());
assertEquals("usi-string+text", response.getEntity().getText());
request = new Request(method, "http://localhost:8111/test");
request.setEntity(form.getWebRepresentation());
request.getClientInfo().getAcceptedMediaTypes()
.add(new Preference<MediaType>(MediaType.TEXT_PLAIN));
response = client.handle(request);
assertEquals(MediaType.TEXT_PLAIN, response.getEntity().getMediaType());
assertEquals("usi-string+form", response.getEntity().getText());
request = new Request(method, "http://localhost:8111/test");
request.setEntity(text, MediaType.TEXT_PLAIN);
request.getClientInfo().getAcceptedMediaTypes()
.add(new Preference<MediaType>(MediaType.TEXT_PLAIN));
response = client.handle(request);
assertEquals(MediaType.TEXT_PLAIN, response.getEntity().getMediaType());
assertEquals("usi-string+text", response.getEntity().getText());
request = new Request(AnnotatedResource9TestCase.USI,
"http://localhost:8111/test");
request.setEntity(form.getWebRepresentation());
request.getClientInfo().getAcceptedMediaTypes()
.add(new Preference<MediaType>(MediaType.TEXT_PLAIN));
response = client.handle(request);
assertEquals(MediaType.TEXT_PLAIN, response.getEntity().getMediaType());
assertEquals("usi-string+form", response.getEntity().getText());
request = new Request(AnnotatedResource9TestCase.USI,
"http://localhost:8111/test");
request.setEntity(form.getWebRepresentation());
request.getClientInfo().getAcceptedMediaTypes()
.add(new Preference<MediaType>(MediaType.TEXT_HTML));
response = client.handle(request);
assertEquals(MediaType.TEXT_PLAIN, response.getEntity().getMediaType());
assertEquals("usi-string+form", response.getEntity().getText());