Package org.apache.cxf.jaxrs.model

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


       
        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, path, values,
                                                                    new MessageImpl());
       
        if (resource != null) {
            OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource, null, httpMethod,
                                                   values, requestContentType, acceptContentTypes, true);
            if (ori != null) {
                return ori;
            }
        }
View Full Code Here


            ct += ";charset=" + enc;
        }
        headers.putSingle("Content-Type", ct);
        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",
                     "\u00E4\u00F6\u00FC", params.get(0));
        List<String> list = CastUtils.cast((List)params.get(1));
View Full Code Here

        assertTrue(proxy.get() instanceof UriInfo);
    }
   
    private void invokeCustomerMethod(ClassResourceInfo cri,
        Customer customer, Server server) throws Exception {
        OperationResourceInfo ori = cri.getMethodDispatcher().getOperationResourceInfo(
            Customer.class.getMethod("test", new Class[]{}));
        JAXRSInvoker invoker = new JAXRSInvoker();
        Exchange exc = new ExchangeImpl();
        exc.put(Endpoint.class, server.getEndpoint());
        Message inMessage = new MessageImpl();
View Full Code Here

        String contentTypes = "*/*";
       
        //If acceptContentTypes does not specify a specific Mime type, the 
        //method is declared with a most specific ProduceMime type is selected.
        OperationResourceInfo ori = findTargetResourceClass(resources, null,
             "/bookstore/1/books/123/", "GET", new MetadataMap<String, String>(), contentTypes,
             getTypes("application/json,application/xml"));      
        assertNotNull(ori);
        assertEquals("getBookJSON", ori.getMethodToInvoke().getName());
       
        //test
        ori = findTargetResourceClass(resources, null, "/bookstore/1/books/123",
             "GET", new MetadataMap<String, String>(), contentTypes, getTypes("application/json"));       
        assertNotNull(ori);
        assertEquals("getBookJSON", ori.getMethodToInvoke().getName());
       
        //test
        ori = findTargetResourceClass(resources, null, "/bookstore/1/books/123",
              "GET", new MetadataMap<String, String>(), contentTypes, getTypes("application/xml"));       
        assertNotNull(ori);
        assertEquals("getBook", ori.getMethodToInvoke().getName());
       
        //test
        ori = findTargetResourceClass(resources, null, "/bookstore/1/books",
                      "GET", new MetadataMap<String, String>(), contentTypes,
                      getTypes("application/xml"));       
        assertNotNull(ori);
        assertEquals("getBooks", ori.getMethodToInvoke().getName());
       
        //test find POST
        ori = findTargetResourceClass(resources, null, "/bookstore/1/books",
                 "POST", new MetadataMap<String, String>(), contentTypes, getTypes("application/xml"));      
        assertNotNull(ori);
        assertEquals("addBook", ori.getMethodToInvoke().getName());
       
        //test find PUT
        ori = findTargetResourceClass(resources, null, "/bookstore/1/books",
            "PUT", new MetadataMap<String, String>(), contentTypes, getTypes("application/xml"))
        assertEquals("updateBook", ori.getMethodToInvoke().getName());
       
        //test find DELETE
        ori = findTargetResourceClass(resources, null, "/bookstore/1/books/123",
             "DELETE", new MetadataMap<String, String>(), contentTypes, getTypes("application/xml"));       
        assertNotNull(ori);
        assertEquals("deleteBook", ori.getMethodToInvoke().getName());    
       
    }
View Full Code Here

        String contentTypes = "*/*";
       
        //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>();
        OperationResourceInfo ori = findTargetResourceClass(resources, null, "/1/2/",
             "GET", values, contentTypes, getTypes("*/*"));      
        assertNotNull(ori);
        assertEquals("getBooks", ori.getMethodToInvoke().getName());
        assertEquals("Only id and final match groups should be there", 2, values.size());
        assertEquals("2 {id} values should've been picked up", 2, values.get("id").size());
        assertEquals("FINAL_MATCH_GROUP should've been picked up", 1,
                     values.get(URITemplate.FINAL_MATCH_GROUP).size());
        assertEquals("First {id} is 1", "1", values.getFirst("id"));
        assertEquals("Second id is 2", "2", values.get("id").get(1));
       
        values = new MetadataMap<String, String>();
        ori = findTargetResourceClass(resources, null, "/2",
             "POST", values, contentTypes, getTypes("*/*"));      
        assertNotNull(ori);
        assertEquals("updateBookStoreInfo", ori.getMethodToInvoke().getName());
        assertEquals("Only id and final match groups should be there", 2, values.size());
        assertEquals("Only single {id} should've been picked up", 1, values.get("id").size());
        assertEquals("FINAL_MATCH_GROUP should've been picked up", 1,
                     values.get(URITemplate.FINAL_MATCH_GROUP).size());
        assertEquals("Only the first {id} should've been picked up", "2", values.getFirst("id"));
       
        values = new MetadataMap<String, String>();
        ori = findTargetResourceClass(resources, null, "/3/4",
             "PUT", values, contentTypes, getTypes("*/*"));      
        assertNotNull(ori);
        assertEquals("updateBook", ori.getMethodToInvoke().getName());
        assertEquals("Only the first {id} should've been picked up", 3, values.size());
        assertEquals("Only the first {id} should've been picked up", 1, values.get("id").size());
        assertEquals("Only the first {id} should've been picked up", 1, values.get("bookId").size());
        assertEquals("Only the first {id} should've been picked up", 1,
                     values.get(URITemplate.FINAL_MATCH_GROUP).size());
View Full Code Here

        sf.create();       
        List<ClassResourceInfo> resources = ((JAXRSServiceImpl)sf.getService()).getClassResourceInfos();

        String contentTypes = "*/*";
       
        OperationResourceInfo ori = findTargetResourceClass(resources,
               null, "/bookstore/books/123", "GET", new MetadataMap<String, String>(), contentTypes,
               getTypes("*/*"));      
        assertNotNull(ori);
        assertEquals("getBook", ori.getMethodToInvoke().getName());
       
        ori = findTargetResourceClass(resources, null,
            "/bookstore/books/123/true/chapter/1", "GET", new MetadataMap<String, String>(), contentTypes,
            getTypes("*/*"));      
        assertNotNull(ori);
        assertEquals("getNewBook", ori.getMethodToInvoke().getName());
       
        ori = findTargetResourceClass(resources, null, "/bookstore/books",
            "POST", new MetadataMap<String, String>(), contentTypes, getTypes("*/*"));     
        assertNotNull(ori);
        assertEquals("addBook", ori.getMethodToInvoke().getName());
       
        ori = findTargetResourceClass(resources, null, "/bookstore/books",
             "PUT", new MetadataMap<String, String>(), contentTypes, getTypes("*/*"));       
        assertNotNull(ori);
        assertEquals("updateBook", ori.getMethodToInvoke().getName());
       
        ori = findTargetResourceClass(resources, null, "/bookstore/books/123",
            "DELETE", new MetadataMap<String, String>(), contentTypes, getTypes("*/*"));       
        assertNotNull(ori);
        assertEquals("deleteBook", ori.getMethodToInvoke().getName());
    }
View Full Code Here

        ClassResourceInfo cr = new ClassResourceInfo(Customer.class);
       
        assertTrue("text/xml can not be matched",
                   JAXRSUtils.matchMimeTypes(JAXRSUtils.ALL_TYPES,
                                             new MediaType("text", "xml"),
                                             new OperationResourceInfo(m, cr)));
        assertTrue("text/xml can not be matched",
                   JAXRSUtils.matchMimeTypes(JAXRSUtils.ALL_TYPES,
                                             new MediaType("text", "*"),
                                             new OperationResourceInfo(m, cr)));
        assertTrue("text/xml can not be matched",
                   JAXRSUtils.matchMimeTypes(JAXRSUtils.ALL_TYPES,
                                             new MediaType("*", "*"),
                                             new OperationResourceInfo(m, cr)));
        assertFalse("text/plain was matched",
                   JAXRSUtils.matchMimeTypes(JAXRSUtils.ALL_TYPES,
                                             new MediaType("text", "plain"),
                                             new OperationResourceInfo(m, cr)));
    }
View Full Code Here

        Class[] argType = {String.class, Integer.TYPE, String.class, String.class};
        Method m = Customer.class.getMethod("testQuery", argType);
        MessageImpl messageImpl = new MessageImpl();
       
        messageImpl.put(Message.QUERY_STRING, "query=24&query2");
        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
                                                           null,
                                                           messageImpl);
        assertEquals(4, params.size());
        assertEquals("Query Parameter was not matched correctly", "24", params.get(0));
        assertEquals("Primitive Query Parameter was not matched correctly", 24, params.get(1));
View Full Code Here

        Class<?>[] argType = {Integer[].class};
        Method m = Customer.class.getMethod("testQueryIntegerArray", argType);
        MessageImpl messageImpl = new MessageImpl();
       
        messageImpl.put(Message.QUERY_STRING, "query=1&query=2");
        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
                                                           null,
                                                           messageImpl);
        assertEquals(1, params.size());
        Integer[] intValues = (Integer[])params.get(0);
        assertEquals(1, (int)intValues[0]);
View Full Code Here

        Class<?>[] argType = {int[].class};
        Method m = Customer.class.getMethod("testQueryIntArray", argType);
        MessageImpl messageImpl = new MessageImpl();
       
        messageImpl.put(Message.QUERY_STRING, "query=1&query=2");
        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
                                                           null,
                                                           messageImpl);
        assertEquals(1, params.size());
        int[] intValues = (int[])params.get(0);
        assertEquals(1, intValues[0]);
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.model.OperationResourceInfo

Copyright © 2018 www.massapicom. 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.