Examples of OperationResourceInfo


Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

        ex.put(Endpoint.class, e);
       
        MetadataMap<String, String> values = new MetadataMap<String, String>();
        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, "/books", values,
                                                                    m);
        OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource,
                                                                m,
                                    "POST", values, contentTypes,
                                    JAXRSUtils.sortMediaTypes(acceptContentTypes, "q"),
                                    true);
        assertNotNull(ori);
        assertEquals("resourceMethod needs to be selected", "postEntity",
                     ori.getMethodToInvoke().getName());
       
        String value = "<Books><Book><name>The Book</name><id>2</id></Book></Books>";
        m.setContent(InputStream.class, new ByteArrayInputStream(value.getBytes()));
        List<Object> params = JAXRSUtils.processParameters(ori, values, m);
        assertEquals(1, params.size());
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

        m.put(Message.CONTENT_TYPE, "text/xml");
       
        MetadataMap<String, String> values = new MetadataMap<String, String>();
        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, "/", values,
                                                                    m);
        OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource,
                                                                m,
                                    "POST", values, "text/xml",
                                    JAXRSUtils.sortMediaTypes("*/*", "q"),
                                    true);
        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());
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

        ex.put(Endpoint.class, e);
       
        MetadataMap<String, String> values = new MetadataMap<String, String>();
        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, "/books", values,
                                                                    m);
        OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource,
                                                                m,
                                    "PUT", values, contentTypes,
                                    JAXRSUtils.sortMediaTypes(acceptContentTypes, "q"),
                                    true);
        assertNotNull(ori);
        assertEquals("resourceMethod needs to be selected", "putEntity",
                     ori.getMethodToInvoke().getName());
       
        String value = "<Chapter><title>The Book</title><id>2</id></Chapter>";
        m.setContent(InputStream.class, new ByteArrayInputStream(value.getBytes()));
        List<Object> params = JAXRSUtils.processParameters(ori, values, m);
        assertEquals(1, params.size());
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

        ex.put(Endpoint.class, e);
       
        MetadataMap<String, String> values = new MetadataMap<String, String>();
        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, "/", values,
                                                                    m);
        OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource,
                                                                m,
                                    "POST", values, contentType,
                                    JAXRSUtils.sortMediaTypes(acceptContentTypes, "q"),
                                    true);
        assertNotNull(ori);
        assertEquals(expectedMethodName,  ori.getMethodToInvoke().getName());
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

       
        MetadataMap<String, String> values = new MetadataMap<String, String>();
        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, path, values,
                                                                    m);
    
        OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource, m, "GET",
                                                values, contentType,
                                                JAXRSUtils.sortMediaTypes(acceptContentTypes, "q"),
                                                true);

        assertNotNull(ori);
        assertEquals(expectedMethodName,  ori.getMethodToInvoke().getName());
        assertEquals(expectedResponseType, m.getExchange().get(Message.CONTENT_TYPE));
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

        ex.put(Endpoint.class, e);
       
        MetadataMap<String, String> values = new MetadataMap<String, String>();
        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, "/books", values,
                                                                    m);
        OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource,
                                                                m,
                                    methodName, values, contentTypes,
                                    JAXRSUtils.sortMediaTypes(acceptContentTypes, "q"),
                                    true);
        assertNotNull(ori);
        assertEquals("resourceMethod needs to be selected", methodName.toLowerCase() + "Entity",
                     ori.getMethodToInvoke().getName());
       
        String value = "<Book><name>The Book</name><id>2</id></Book>";
        m.setContent(InputStream.class, new ByteArrayInputStream(value.getBytes()));
        List<Object> params = JAXRSUtils.processParameters(ori, values, m);
        assertEquals(1, params.size());
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

        String acceptContentTypes = "text/xml,*/*";
       
        MetadataMap<String, String> values = new MetadataMap<String, String>();
        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, path, values,
                                                                    new MessageImpl());
        OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource,
                                    createMessage(),
                                    "GET", values, contentTypes,
                                    JAXRSUtils.sortMediaTypes(acceptContentTypes, "q"),
                                    true);
        assertNotNull(ori);
        assertEquals("resourceMethod needs to be selected", method,
                     ori.getMethodToInvoke().getName());
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

        String acceptContentTypes = "application/xml;q=0.5,application/json";
       
        MetadataMap<String, String> values = new MetadataMap<String, String>();
        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, "/1/2/3/d/resource1", values,
                                                                    new MessageImpl());
        OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource,
                                    createMessage(),
                                    "GET", values, contentTypes,
                                    JAXRSUtils.sortMediaTypes(acceptContentTypes, "q"),
                                    true);
        assertNotNull(ori);
        assertEquals("jsonResource needs to be selected", "jsonResource",
                     ori.getMethodToInvoke().getName());
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

        //If acceptContentTypes does not specify a specific Mime type, the 
        //method is declared with a most specific ProduceMime type is selected.
        MetadataMap<String, String> values = new MetadataMap<String, String>();
        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, "/1/2/3/d", values,
                                                                    new MessageImpl());
        OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource,
                                    createMessage(),
                                    "GET", values, contentTypes,
                                    Collections.singletonList(MediaType.valueOf(acceptContentTypes)), true);
        assertNotNull(ori);
        assertEquals("listMethod needs to be selected", "listMethod",
                     ori.getMethodToInvoke().getName());
       
       
        acceptContentTypes = "application/xml,application/json;q=0.8";
        resource = JAXRSUtils.selectResourceClass(resources, "/1/2/3/d/1", values,
                                                  new MessageImpl());
        ori = JAXRSUtils.findTargetMethod(resource,
                                        createMessage(),
                                        "GET", values, contentTypes,
                                        JAXRSUtils.parseMediaTypes(acceptContentTypes), true);
        assertNotNull(ori);
        assertEquals("readMethod needs to be selected", "readMethod",
                     ori.getMethodToInvoke().getName());
       
       
        contentTypes = "application/xml";
        acceptContentTypes = "application/xml";
        resource = JAXRSUtils.selectResourceClass(resources, "/1/2/3/d/1", values, new MessageImpl());
        ori = JAXRSUtils.findTargetMethod(resource,
                                        createMessage(),
                                        "GET", values, contentTypes,
                                        Collections.singletonList(MediaType.valueOf(acceptContentTypes))
                                        , true);
        assertNotNull(ori);
        assertEquals("readMethod needs to be selected", "readMethod",
                     ori.getMethodToInvoke().getName());
       
        contentTypes = "application/json";
        acceptContentTypes = "application/json";
        resource = JAXRSUtils.selectResourceClass(resources, "/1/2/3/d/1/bar/baz/baz", values,
                                                  new MessageImpl());
        ori = JAXRSUtils.findTargetMethod(resource,
                                        createMessage(),
                                        "GET", values, contentTypes,
                                        Collections.singletonList(MediaType.valueOf(acceptContentTypes)),
                                        true);
        assertNotNull(ori);
        assertEquals("readMethod2 needs to be selected", "readMethod2",
                     ori.getMethodToInvoke().getName());
       
        contentTypes = "application/json";
        acceptContentTypes = "application/json";
        resource = JAXRSUtils.selectResourceClass(resources, "/1/2/3/d/1", values, new MessageImpl());
        ori = JAXRSUtils.findTargetMethod(resource,
                                        createMessage(),
                                        "GET", values, contentTypes,
                                        Collections.singletonList(MediaType.valueOf(acceptContentTypes)),
                                        true);
        assertNotNull(ori);
        assertEquals("unlimitedPath needs to be selected", "unlimitedPath",
                     ori.getMethodToInvoke().getName());
       
        resource = JAXRSUtils.selectResourceClass(resources, "/1/2/3/d/1/2", values, new MessageImpl());
        ori = JAXRSUtils.findTargetMethod(resource,
                                        createMessage(),
                                        "GET", values, contentTypes,
                                        Collections.singletonList(MediaType.valueOf(acceptContentTypes)),
                                        true);
        assertNotNull(ori);
        assertEquals("limitedPath needs to be selected", "limitedPath",
                     ori.getMethodToInvoke().getName());
       
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.OperationResourceInfo

        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, "/1/2/3/d/custom", values,
                                                                    new MessageImpl());
       
        String contentTypes = "*/*";
        String acceptContentTypes = "application/bar,application/foo;q=0.8";
        OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource,
                                    createMessage(),
                                    "GET", values, contentTypes,
                                    JAXRSUtils.sortMediaTypes(acceptContentTypes, "q"),
                                    true);
        assertNotNull(ori);
        assertEquals("readBar", ori.getMethodToInvoke().getName());
        acceptContentTypes = "application/foo,application/bar;q=0.8";
        resource = JAXRSUtils.selectResourceClass(resources, "/1/2/3/d/custom", values, new MessageImpl());
        ori = JAXRSUtils.findTargetMethod(resource,
                                    createMessage(),
                                    "GET", values, contentTypes,
                                    JAXRSUtils.sortMediaTypes(acceptContentTypes, "q"),
                                    true);
        assertNotNull(ori);
        assertEquals("readFoo", ori.getMethodToInvoke().getName());
       
        acceptContentTypes = "application/foo;q=0.5,application/bar";
        resource = JAXRSUtils.selectResourceClass(resources, "/1/2/3/d/custom", values, new MessageImpl());
        ori = JAXRSUtils.findTargetMethod(resource,
                                    createMessage(),
                                    "GET", values, contentTypes,
                                    JAXRSUtils.sortMediaTypes(acceptContentTypes, "q"),
                                    true);
        assertNotNull(ori);
        assertEquals("readBar", ori.getMethodToInvoke().getName());
       
        acceptContentTypes = "application/foo,application/bar;q=0.5";
        resource = JAXRSUtils.selectResourceClass(resources, "/1/2/3/d/custom", values, new MessageImpl());
        ori = JAXRSUtils.findTargetMethod(resource,
                                    createMessage(),
                                    "GET", values, contentTypes,
                                    JAXRSUtils.sortMediaTypes(acceptContentTypes, "q"),
                                    true);
        assertNotNull(ori);
        assertEquals("readFoo", ori.getMethodToInvoke().getName());
       
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.