use of org.apache.cxf.jaxrs.fortest.ConcreteRestResource in project cxf by apache.
the class SelectMethodCandidatesTest method testFindFromAbstractGenericImpl5.
@Test
public void testFindFromAbstractGenericImpl5() throws Exception {
JAXRSServiceFactoryBean sf = new JAXRSServiceFactoryBean();
sf.setResourceClasses(ConcreteRestController.class);
sf.create();
List<ClassResourceInfo> resources = ((JAXRSServiceImpl) sf.getService()).getClassResourceInfos();
Message m = createMessage();
m.put(Message.CONTENT_TYPE, "text/xml");
MetadataMap<String, String> values = new MetadataMap<String, String>();
OperationResourceInfo ori = findTargetResourceClass(resources, m, "/", "POST", values, "text/xml", sortMediaTypes("*/*"));
assertNotNull(ori);
assertEquals("resourceMethod needs to be selected", "add", ori.getMethodToInvoke().getName());
String value = "<concreteRestResource><name>The Book</name></concreteRestResource>";
m.setContent(InputStream.class, new ByteArrayInputStream(value.getBytes()));
List<Object> params = JAXRSUtils.processParameters(ori, values, m);
assertEquals(1, params.size());
ConcreteRestResource book = (ConcreteRestResource) params.get(0);
assertNotNull(book);
assertEquals("The Book", book.getName());
}
Aggregations