Package org.apache.cxf.message

Examples of org.apache.cxf.message.Message


        wg.setSchemaLocations(Collections.singletonList("classpath:/book2.xsd"));
        wg.setUseJaxbContextForQnames(false);
       
        ClassResourceInfo cri =
            ResourceUtils.createClassResourceInfo(BookStore.class, BookStore.class, true, true);
        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
       
        Response r = wg.handleRequest(m, cri);
        checkResponse(r);
        Document doc = StaxUtils.read(new StringReader(r.getEntity().toString()));
        checkGrammars(doc.getDocumentElement(), "book", "book2", "chapter");
View Full Code Here


        WadlGenerator wg = new WadlGenerator();
        wg.setApplicationTitle("My Application");
        wg.setNamespacePrefix("ns");
        ClassResourceInfo cri =
            ResourceUtils.createClassResourceInfo(BookStore.class, BookStore.class, true, true);
        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
       
        Response r = wg.handleRequest(m, cri);
        checkResponse(r);
        Document doc = StaxUtils.read(new StringReader(r.getEntity().toString()));
        checkDocs(doc.getDocumentElement(), "My Application", "", "");
View Full Code Here

        WadlGenerator wg = new WadlGenerator();
        wg.setApplicationTitle("My Application");
        wg.setNamespacePrefix("ns");
        ClassResourceInfo cri =
            ResourceUtils.createClassResourceInfo(TestResource.class, TestResource.class, true, true);
        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
       
        Response r = wg.handleRequest(m, cri);
        checkResponse(r);
        Document doc = StaxUtils.read(new StringReader(r.getEntity().toString()));
        checkDocs(doc.getDocumentElement(), "My Application", "", "");
View Full Code Here

    public void testRootResourceWithSingleSlash() throws Exception {
        WadlGenerator wg = new WadlGenerator();
        ClassResourceInfo cri =
            ResourceUtils.createClassResourceInfo(BookStoreWithSingleSlash.class,
                                                  BookStoreWithSingleSlash.class, true, true);
        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
       
        Response r = wg.handleRequest(m, cri);
        checkResponse(r);
        Document doc = StaxUtils.read(new StringReader(r.getEntity().toString()));
        List<Element> rootEls = getWadlResourcesInfo(doc, "http://localhost:8080/baz", 1);
View Full Code Here

        ClassResourceInfo cri2 =
            ResourceUtils.createClassResourceInfo(Orders.class, Orders.class, true, true);
        List<ClassResourceInfo> cris = new ArrayList<ClassResourceInfo>();
        cris.add(cri1);
        cris.add(cri2);
        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, cris);
        Response r = wg.handleRequest(m, null);
        assertEquals(WadlGenerator.WADL_TYPE.toString(),
                     r.getMetadata().getFirst(HttpHeaders.CONTENT_TYPE));
        String wadl = r.getEntity().toString();
        Document doc = StaxUtils.read(new StringReader(wadl));
View Full Code Here

    }
   
   
    private Message mockMessage(String baseAddress, String pathInfo, String query,
                                List<ClassResourceInfo> cris) throws Exception {
        Message m = new MessageImpl();
        Exchange e = new ExchangeImpl();
        e.put(Service.class, new JAXRSServiceImpl(cris));
        m.setExchange(e);
        control.reset();
        ServletDestination d = control.createMock(ServletDestination.class);
        EndpointInfo epr = new EndpointInfo();
        epr.setAddress(baseAddress);
        d.getEndpointInfo();
        EasyMock.expectLastCall().andReturn(epr).anyTimes();

        Endpoint endpoint = new EndpointImpl(null, null, epr);
        e.put(Endpoint.class, endpoint);

        endpoint.put(ProviderFactory.class.getName(), ProviderFactory.getInstance());

        e.setDestination(d);
        BindingInfo bi = control.createMock(BindingInfo.class);
        epr.setBinding(bi);
        bi.getProperties();
        EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes();
        m.put(Message.REQUEST_URI, pathInfo);
        m.put(Message.QUERY_STRING, query);
        m.put(Message.HTTP_REQUEST_METHOD, "GET");
        control.replay();
        return m;
    }
View Full Code Here

        sf.create();
        List<ClassResourceInfo> resources = ((JAXRSServiceImpl)sf.getService()).getClassResourceInfos();
        String contentTypes = "text/xml";
        String acceptContentTypes = "text/xml";
       
        Message m = new MessageImpl();
        m.put(Message.CONTENT_TYPE, "text/xml");
        Exchange ex = new ExchangeImpl();
        ex.setInMessage(m);
        m.setExchange(ex);
        Endpoint e = EasyMock.createMock(Endpoint.class);
        e.isEmpty();
        EasyMock.expectLastCall().andReturn(true).anyTimes();
        e.size();
        EasyMock.expectLastCall().andReturn(0).anyTimes();
        e.getEndpointInfo();
        EasyMock.expectLastCall().andReturn(null).anyTimes();
        e.get(ProviderFactory.class.getName());
        EasyMock.expectLastCall().andReturn(ProviderFactory.getInstance()).times(2);
        e.get("org.apache.cxf.jaxrs.comparator");
        EasyMock.expectLastCall().andReturn(null);
        EasyMock.replay(e);
        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());
        List<?> books = (List<?>)params.get(0);
        assertEquals(1, books.size());
        Book book = (Book)books.get(0);
View Full Code Here

    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>();
        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());
        ConcreteRestResource book = (ConcreteRestResource)params.get(0);
        assertNotNull(book);
        assertEquals("The Book", book.getName());
View Full Code Here

        sf.create();
        List<ClassResourceInfo> resources = ((JAXRSServiceImpl)sf.getService()).getClassResourceInfos();
        String contentTypes = "text/xml";
        String acceptContentTypes = "text/xml";
       
        Message m = new MessageImpl();
        m.put(Message.CONTENT_TYPE, "text/xml");
        Exchange ex = new ExchangeImpl();
        ex.setInMessage(m);
        m.setExchange(ex);
        Endpoint e = EasyMock.createMock(Endpoint.class);
        e.isEmpty();
        EasyMock.expectLastCall().andReturn(true).anyTimes();
        e.size();
        EasyMock.expectLastCall().andReturn(0).anyTimes();
        e.getEndpointInfo();
        EasyMock.expectLastCall().andReturn(null).anyTimes();
        e.get(ProviderFactory.class.getName());
        EasyMock.expectLastCall().andReturn(ProviderFactory.getInstance()).times(3);
        e.get("org.apache.cxf.jaxrs.comparator");
        EasyMock.expectLastCall().andReturn(null);
        EasyMock.replay(e);
        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());
        Chapter c = (Chapter)params.get(0);
        assertNotNull(c);
        assertEquals(2L, c.getId());
View Full Code Here

        sf.create();
        List<ClassResourceInfo> resources = ((JAXRSServiceImpl)sf.getService()).getClassResourceInfos();
        String contentType = ct == null ? "application/xml" : ct;
        String acceptContentTypes = "*/*";
       
        Message m = new MessageImpl();
        m.put(Message.CONTENT_TYPE, contentType);
        Exchange ex = new ExchangeImpl();
        ex.setInMessage(m);
        m.setExchange(ex);
        Endpoint e = EasyMock.createMock(Endpoint.class);
        e.isEmpty();
        EasyMock.expectLastCall().andReturn(true).anyTimes();
        e.size();
        EasyMock.expectLastCall().andReturn(0).anyTimes();
View Full Code Here

TOP

Related Classes of org.apache.cxf.message.Message

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.