Package org.apache.cxf.jaxrs.model.wadl

Examples of org.apache.cxf.jaxrs.model.wadl.WadlGenerator


        final Message m = mockMessage("http://localhost:8080/baz", "/bookstore/1", WadlGenerator.WADL_QUERY, cri);
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        headers.put("Accept", Collections.singletonList("application/json"));
        m.put(Message.PROTOCOL_HEADERS, headers);
       
        WadlGenerator wg = new WadlGenerator() {
            public void filter(ContainerRequestContext context) {
                super.doFilter(context, m);
            }
        };
        wg.setUseJaxbContextForQnames(false);
        wg.setIgnoreMessageWriters(false);
        wg.setExternalLinks(Collections.singletonList("json.schema"));
       
        Response r = handleRequest(wg, m);
        assertEquals("application/json",
                r.getMetadata().getFirst("Content-Type").toString());
       
View Full Code Here


        control.makeThreadSafe(true);
    }
   
    @Test
    public void testWadlInJsonFormat() throws Exception {
        WadlGenerator wg = new WadlGenerator();
        wg.setUseJaxbContextForQnames(false);
        wg.setIgnoreMessageWriters(false);
       
        wg.setExternalLinks(Collections.singletonList("json.schema"));
       
        ClassResourceInfo cri =
            ResourceUtils.createClassResourceInfo(BookStore.class, BookStore.class, true, true);
        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        headers.put("Accept", Collections.singletonList("application/json"));
        m.put(Message.PROTOCOL_HEADERS, headers);
        Response r = wg.handleRequest(m, cri);
        assertEquals("application/json",
                r.getMetadata().getFirst("Content-Type").toString());
       
        ByteArrayOutputStream os = new ByteArrayOutputStream();
       
View Full Code Here

        String query = (String)m.get(Message.QUERY_STRING);
        if (query != null && query.contains(WadlGenerator.WADL_QUERY)) {
            String requestURI = (String)m.get(Message.REQUEST_URI);
            String baseAddress = HttpUtils.getBaseAddress(m);
            if (baseAddress.equals(requestURI)) {
                Response r = new WadlGenerator().handleRequest(m, null);
                if (r != null) {
                    m.getExchange().put(Response.class, r);
                }
            }
        }
View Full Code Here

    public void testCustomWadlHandler() {
        ProviderFactory pf = ProviderFactory.getInstance();
        assertEquals(1, pf.getRequestHandlers().size());
        assertTrue(pf.getRequestHandlers().get(0).getProvider() instanceof WadlGenerator);
       
        WadlGenerator wg = new WadlGenerator();
        pf.setUserProviders(Collections.singletonList(wg));
        assertEquals(1, pf.getRequestHandlers().size());
        assertTrue(pf.getRequestHandlers().get(0).getProvider() instanceof WadlGenerator);
        assertSame(wg, pf.getRequestHandlers().get(0).getProvider());
    }
View Full Code Here

        ProviderFactory pf = ProviderFactory.getInstance();
        assertEquals(1, pf.getRequestHandlers().size());
        assertTrue(pf.getRequestHandlers().get(0).getProvider() instanceof WadlGenerator);
       
        List<Object> providers = new ArrayList<Object>();
        WadlGenerator wg = new WadlGenerator();
        providers.add(wg);
        TestHandler th = new TestHandler();
        providers.add(th);
        pf.setUserProviders(providers);
        assertEquals(2, pf.getRequestHandlers().size());
View Full Code Here

       
        List<ProviderInfo<RequestHandler>> shs = ProviderFactory.getInstance(m).getRequestHandlers();
        // this is actually being tested by ProviderFactory unit tests but just in case
        // WadlGenerator, the custom or default one, must be the first one
        if (shs.size() > 0 && shs.get(0).getProvider() instanceof WadlGenerator) {
            WadlGenerator wg = (WadlGenerator)shs.get(0).getProvider();
            wg = new WadlGenerator(wg);
            wg.setAddResourceAndMethodIds(true);
            Response r = wg.handleRequest(m, resourceClass);
            return r == null ? null : (String)r.getEntity();
        }
        return null;
    }
View Full Code Here

    public void testCustomWadlHandler() {
        ProviderFactory pf = ProviderFactory.getInstance();
        assertEquals(1, pf.getRequestHandlers().size());
        assertTrue(pf.getRequestHandlers().get(0).getProvider() instanceof WadlGenerator);
       
        WadlGenerator wg = new WadlGenerator();
        pf.setUserProviders(Collections.singletonList(wg));
        assertEquals(1, pf.getRequestHandlers().size());
        assertTrue(pf.getRequestHandlers().get(0).getProvider() instanceof WadlGenerator);
        assertSame(wg, pf.getRequestHandlers().get(0).getProvider());
    }
View Full Code Here

        ProviderFactory pf = ProviderFactory.getInstance();
        assertEquals(1, pf.getRequestHandlers().size());
        assertTrue(pf.getRequestHandlers().get(0).getProvider() instanceof WadlGenerator);
       
        List<Object> providers = new ArrayList<Object>();
        WadlGenerator wg = new WadlGenerator();
        providers.add(wg);
        TestHandler th = new TestHandler();
        providers.add(th);
        pf.setUserProviders(providers);
        assertEquals(2, pf.getRequestHandlers().size());
View Full Code Here

  
     
    public void execute() throws MojoExecutionException {
       
        getResourcesList();
        WadlGenerator wadlGenernator = new WadlGenerator(getBus());
        DocumentationProvider documentationProvider = null;
        if (docProvider != null) {
            try {
                documentationProvider = (DocumentationProvider)getClassLoader().loadClass(docProvider).
                    getConstructor(new Class[] {String.class}).
                    newInstance(new Object[] {project.getBuild().getDirectory()});
                wadlGenernator.setDocumentationProvider(documentationProvider);
            } catch (Exception e) {
                throw new MojoExecutionException(e.getMessage(), e);
            }
        }
           
        StringBuilder sbMain = wadlGenernator.generateWADL(getBaseURI(), classResourceInfos, useJson, null, null);
        getLog().debug("the wadl is =====> \n" + sbMain.toString());
        generateWadl(sbMain.toString());
    }
View Full Code Here

       
        List<ProviderInfo<RequestHandler>> shs = ProviderFactory.getInstance(m).getRequestHandlers();
        // this is actually being tested by ProviderFactory unit tests but just in case
        // WadlGenerator, the custom or default one, must be the first one
        if (shs.size() > 0 && shs.get(0).getProvider() instanceof WadlGenerator) {
            WadlGenerator wg = (WadlGenerator)shs.get(0).getProvider();
            wg = new WadlGenerator(wg);
            wg.setAddResourceAndMethodIds(true);
            Response r = wg.handleRequest(m, resourceClass);
            return r == null ? null : (String)r.getEntity();
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.model.wadl.WadlGenerator

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.