use of javax.ws.rs.core.GenericType in project jersey by jersey.
the class JsonMoxyTest method testJAXBListRepresentationJSONCollection.
@Test
public void testJAXBListRepresentationJSONCollection() throws Exception {
final WebTarget target = target("JAXBListResourceJSON");
final Collection<JaxbBean> a = target.request().get(new GenericType<Collection<JaxbBean>>() {
});
Collection<JaxbBean> b = target.request().post(Entity.entity(new GenericEntity<Collection<JaxbBean>>(a) {
}, "application/json"), new GenericType<Collection<JaxbBean>>() {
});
assertEquals(a, b);
b = target.path("type").request().post(Entity.entity(new GenericEntity<Collection<JaxbBean>>(a) {
}, "application/json"), new GenericType<Collection<JaxbBean>>() {
});
assertEquals(a, b);
}
use of javax.ws.rs.core.GenericType in project jersey by jersey.
the class JsonMoxyTest method testJAXBListRepresentationJSONStack.
@Test
public void testJAXBListRepresentationJSONStack() throws Exception {
final WebTarget target = target("JAXBListResourceJSON");
final Collection<JaxbBean> a = target.request().get(new GenericType<Collection<JaxbBean>>() {
});
final Collection<JaxbBean> b;
final Stack<JaxbBean> s = new Stack<>();
s.addAll(a);
b = target.path("stack").request().post(Entity.entity(new GenericEntity<Stack<JaxbBean>>(s) {
}, "application/json"), new GenericType<Stack<JaxbBean>>() {
});
assertEquals(s, b);
}
use of javax.ws.rs.core.GenericType in project jersey by jersey.
the class JsonMoxyTest method testJAXBListRepresentationJSONSet.
@Test
public void testJAXBListRepresentationJSONSet() throws Exception {
final WebTarget target = target("JAXBListResourceJSON");
Collection<JaxbBean> a = target.request().get(new GenericType<Collection<JaxbBean>>() {
});
final Collection<JaxbBean> b;
a = new HashSet<>(a);
b = target.path("set").request().post(Entity.entity(new GenericEntity<Set<JaxbBean>>((Set<JaxbBean>) a) {
}, "application/json"), new GenericType<Set<JaxbBean>>() {
});
final Comparator<JaxbBean> c = new Comparator<JaxbBean>() {
@Override
public int compare(final JaxbBean t, final JaxbBean t1) {
return t.value.compareTo(t1.value);
}
};
final TreeSet<JaxbBean> t1 = new TreeSet<>(c);
final TreeSet<JaxbBean> t2 = new TreeSet<>(c);
t1.addAll(a);
t2.addAll(b);
assertEquals(t1, t2);
}
use of javax.ws.rs.core.GenericType in project jersey by jersey.
the class GenericResponseTest method testAsyncPost.
@Test
public void testAsyncPost() throws ExecutionException, InterruptedException {
GenericType<Response> generic = new GenericType<Response>(Response.class);
Entity entity = Entity.entity("entity", MediaType.WILDCARD_TYPE);
WebTarget target = target("resource");
final AsyncInvoker async = target.request().async();
Response response = async.post(entity, generic).get();
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("entity", response.readEntity(String.class));
}
use of javax.ws.rs.core.GenericType in project jersey by jersey.
the class GenericResponseTest method testAsyncGet.
@Test
public void testAsyncGet() throws ExecutionException, InterruptedException {
GenericType<Response> generic = new GenericType<Response>(Response.class);
WebTarget target = target("resource");
final AsyncInvoker async = target.request().async();
Response response = async.get(generic).get();
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("get", response.readEntity(String.class));
}
Aggregations