Search in sources :

Example 1 with ConcreteRestResource

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());
}
Also used : Message(org.apache.cxf.message.Message) ClassResourceInfo(org.apache.cxf.jaxrs.model.ClassResourceInfo) MetadataMap(org.apache.cxf.jaxrs.impl.MetadataMap) ByteArrayInputStream(java.io.ByteArrayInputStream) OperationResourceInfo(org.apache.cxf.jaxrs.model.OperationResourceInfo) ConcreteRestResource(org.apache.cxf.jaxrs.fortest.ConcreteRestResource) Test(org.junit.Test)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 ConcreteRestResource (org.apache.cxf.jaxrs.fortest.ConcreteRestResource)1 MetadataMap (org.apache.cxf.jaxrs.impl.MetadataMap)1 ClassResourceInfo (org.apache.cxf.jaxrs.model.ClassResourceInfo)1 OperationResourceInfo (org.apache.cxf.jaxrs.model.OperationResourceInfo)1 Message (org.apache.cxf.message.Message)1 Test (org.junit.Test)1