Examples of OperationResourceInfo


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

        }
       
        @SuppressWarnings("unchecked")
        public void handleMessage(Message outMessage) throws Fault {
           
            OperationResourceInfo ori = outMessage.getContent(OperationResourceInfo.class);
            OutputStream os = outMessage.getContent(OutputStream.class);
            if ((os == null && outMessage.getContent(XMLStreamWriter.class) == null)
                || ori == null) {
                return;
            }
            MessageContentsList objs = MessageContentsList.getContentsList(outMessage);
            if (objs == null || objs.size() == 0) {
                return;
            }
            MultivaluedMap<String, String> headers =
                (MultivaluedMap)outMessage.get(Message.PROTOCOL_HEADERS);
            Method method = ori.getMethodToInvoke();
            int bodyIndex = (Integer)outMessage.get("BODY_INDEX");
            Method aMethod = ori.getAnnotatedMethod();
            Annotation[] anns = aMethod == null || bodyIndex == -1 ? new Annotation[0]
                                                  : aMethod.getParameterAnnotations()[bodyIndex];
            Object body = objs.get(0);
            try {
                if (bodyIndex != -1) {
View Full Code Here

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

        ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(resources, ur, true, true);
        assertNotNull(cri);
        assertEquals("/hashmap", cri.getURITemplate().getValue());
        Method method =
            HashMap.class.getMethod("get", new Class[]{Object.class});
        OperationResourceInfo ori = cri.getMethodDispatcher().getOperationResourceInfo(method);
        assertNotNull(ori);
        assertEquals("/key/{id}", ori.getURITemplate().getValue());
        List<Parameter> params = ori.getParameters();
        assertNotNull(params);
        Parameter p = params.get(0);
        assertEquals("id", p.getName());
    }
View Full Code Here

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

    private void verifyParametersBean(Method m,
                                      MultivaluedMap<String, String> simpleValues,
                                      MessageImpl simpleMessageImpl,
                                      MultivaluedMap<String, String> complexValues,
                                      MessageImpl complexMessageImpl) throws Exception {
        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
                                                           simpleValues,
                                                           simpleMessageImpl);
        assertEquals("Bean should be created", 1, params.size());
        Customer.CustomerBean cb = (Customer.CustomerBean)params.get(0);
        assertNotNull(cb);
       
        assertEquals("aValue", cb.getA());
        assertEquals(new Long(123), cb.getB());

        params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
                                                       complexValues,
                                                       complexMessageImpl);
        assertEquals("Bean should be created", 1, params.size());
        Customer.CustomerBean cb1 = (Customer.CustomerBean)params.get(0);
        assertNotNull(cb1);
View Full Code Here

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

        Method m = Customer.class.getMethod("testMultipleQuery", argType);
        MessageImpl messageImpl = new MessageImpl();
       
        messageImpl.put(Message.QUERY_STRING,
                        "query=first&query2=second&query3=3&query4=true&query5");
        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
                                                           null, messageImpl);
        assertEquals("First Query Parameter of multiple was not matched correctly", "first",
                     params.get(0));
        assertEquals("Second Query Parameter of multiple was not matched correctly",
                     "second", params.get(1));
View Full Code Here

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

        Class[] argType = {String.class, String.class, String.class, String.class, List.class, String.class};
        Method m = Customer.class.getMethod("testMatrixParam", argType);
        MessageImpl messageImpl = new MessageImpl();
       
        messageImpl.put(Message.REQUEST_URI, "/foo;p4=0;p3=3/bar;p1=1;p2/baz;p4=4;p4=5;p5");
        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
                                                           null, messageImpl);
        assertEquals("5 Matrix params should've been identified", 6, params.size());
       
        assertEquals("First Matrix Parameter not matched correctly",
                     "1", params.get(0));
View Full Code Here

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

        Method m = Customer.class.getMethod("testPathSegment", argType);
        MessageImpl messageImpl = new MessageImpl();
        messageImpl.put(Message.REQUEST_URI, "/bar%20foo;p4=0%201");
        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
        values.add("ps", "bar%20foo;p4=0%201");
        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
                                                           values,
                                                           messageImpl);
        assertEquals("2 params should've been identified", 2, params.size());
       
        PathSegment ps = (PathSegment)params.get(0);
View Full Code Here

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

        if (useMediaType) {
            headers.putSingle("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
        }
        messageImpl.put(Message.PROTOCOL_HEADERS, headers);
        messageImpl.setContent(InputStream.class, new ByteArrayInputStream(body.getBytes()));
        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
                                                           null, messageImpl);
        assertEquals("2 form params should've been identified", 2, params.size());
       
        assertEquals("First Form Parameter not matched correctly",
                     "1", params.get(0));
View Full Code Here

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

                protected void persistParamsOnMessage(MultivaluedMap<String, String> params) {
                    messageImpl.put(FormUtils.FORM_PARAM_MAP, params);   
                }
            });
       
        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
                                                           new MetadataMap<String, String>(), messageImpl);
        assertEquals("3 params should've been identified", 3, params.size());
       
        MultivaluedMap<String, String> map = (MultivaluedMap<String, String>)params.get(0);
        assertEquals(2, map.size());
View Full Code Here

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

    }
   
    @Test
    public void testSelectResourceMethod() throws Exception {
        ClassResourceInfo cri = new ClassResourceInfo(Customer.class);
        OperationResourceInfo ori1 = new OperationResourceInfo(
                                         Customer.class.getMethod("getItAsXML", new Class[]{}),
                                         cri);
        ori1.setHttpMethod("GET");
        ori1.setURITemplate(new URITemplate("/"));
        OperationResourceInfo ori2 = new OperationResourceInfo(
                                         Customer.class.getMethod("getItPlain", new Class[]{}),
                                         cri);
        ori2.setHttpMethod("GET");
        ori2.setURITemplate(new URITemplate("/"));
        MethodDispatcher md = new MethodDispatcher();
        md.bind(ori1, Customer.class.getMethod("getItAsXML", new Class[]{}));
        md.bind(ori2, Customer.class.getMethod("getItPlain", new Class[]{}));
        cri.setMethodDispatcher(md);
       
        OperationResourceInfo ori = JAXRSUtils.findTargetMethod(cri, null, "GET",
              new MetadataMap<String, String>(), "*/*", getTypes("text/plain"), true);
       
        assertSame(ori, ori2);
       
        ori = JAXRSUtils.findTargetMethod(cri, null, "GET", new MetadataMap<String, String>(),
View Full Code Here

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

    @SuppressWarnings("unchecked")
    @Test
    public void testHttpContextParameters() throws Exception {
       
        ClassResourceInfo cri = new ClassResourceInfo(Customer.class, true);
        OperationResourceInfo ori =
            new OperationResourceInfo(
                Customer.class.getMethod("testParams",
                                         new Class[]{UriInfo.class,
                                                     HttpHeaders.class,
                                                     Request.class,
                                                     SecurityContext.class,
                                                     Providers.class,
                                                     String.class,
                                                     List.class}),
                cri);
        ori.setHttpMethod("GET");
        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
        headers.add("Foo", "bar, baz");
       
        Message m = new MessageImpl();
        m.put("org.apache.cxf.http.header.split", "true");
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.