Package org.apache.camel.model.rest

Examples of org.apache.camel.model.rest.RestDefinition


import org.apache.camel.model.rest.RestDefinition;

public class XmlRestParseTest extends XmlTestSupport {

    public void testParseSimpleRestXml() throws Exception {
        RestDefinition rest = assertOneRest("simpleRest.xml");
        assertEquals("/users", rest.getPath());

        assertEquals(1, rest.getVerbs().size());
        GetVerbDefinition get = (GetVerbDefinition) rest.getVerbs().get(0);
        assertEquals("/view/{id}", get.getUri());
        assertEquals("direct:getUser", get.getTo().getUri());
    }
View Full Code Here


        assertEquals("direct:getUser", get.getTo().getUri());
    }

    protected RestDefinition assertOneRest(String uri) throws JAXBException {
        RestContainer context = assertParseRestAsJaxb(uri);
        RestDefinition rest = assertOneElement(context.getRests());
        return rest;
    }
View Full Code Here

    public void testFromRestModel() throws Exception {
        assertEquals(getExpectedNumberOfRoutes(), context.getRoutes().size());

        assertEquals(2, context.getRestDefinitions().size());
        RestDefinition rest = context.getRestDefinitions().get(0);
        assertNotNull(rest);
        assertEquals("/say/hello", rest.getPath());
        assertEquals(1, rest.getVerbs().size());
        ToDefinition to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getTo());
        assertEquals("direct:hello", to.getUri());

        rest = context.getRestDefinitions().get(1);
        assertNotNull(rest);
        assertEquals("/say/bye", rest.getPath());
        assertEquals(2, rest.getVerbs().size());
        assertEquals("application/json", rest.getVerbs().get(0).getConsumes());
        to = assertIsInstanceOf(ToDefinition.class, rest.getVerbs().get(0).getRoute().getOutputs().get(1));
        assertEquals("direct:bye", to.getUri());

        // the rest becomes routes and the input is a seda endpoint created by the DummyRestConsumerFactory
        getMockEndpoint("mock:update").expectedMessageCount(1);
        template.sendBody("seda:post-say-bye", "I was here");
View Full Code Here

        };
    }

    @Test
    public void testReaderRead() throws Exception {
        RestDefinition rest = context.getRestDefinitions().get(0);
        assertNotNull(rest);

        SwaggerConfig config = new SwaggerConfig();
        config.setBasePath("http://localhost:8080/api");
        RestSwaggerReader reader = new RestSwaggerReader();
View Full Code Here

     *
     * @return the builder
     */
    public RestDefinition rest() {
        getRestCollection().setCamelContext(getContext());
        RestDefinition answer = getRestCollection().rest();
        configureRest(answer);
        return answer;
    }
View Full Code Here

     * @param path  the base path
     * @return the builder
     */
    public RestDefinition rest(String path) {
        getRestCollection().setCamelContext(getContext());
        RestDefinition answer = getRestCollection().rest(path);
        configureRest(answer);
        return answer;
    }
View Full Code Here

        // the CamelContext - for example property placeholder resolutions etc.
        List<RestDefinition> clones = new ArrayList<RestDefinition>(answer.size());
        try {
            JAXBContext jaxb = getOrCreateJAXBContext();
            for (RestDefinition def : answer) {
                RestDefinition clone = cloneRestDefinition(jaxb, def);
                if (clone != null) {
                    clones.add(clone);
                }
            }
        } catch (Exception e) {
View Full Code Here

        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        Object clone = unmarshaller.unmarshal(bis);

        if (clone != null && clone instanceof RestDefinition) {
            RestDefinition def2 = (RestDefinition) clone;

            Iterator<VerbDefinition> verbit1 = def.getVerbs().iterator();
            Iterator<VerbDefinition> verbit2 = def2.getVerbs().iterator();

            while (verbit1.hasNext() && verbit2.hasNext()) {
                VerbDefinition verb1 = verbit1.next();
                VerbDefinition verb2 = verbit2.next();
View Full Code Here

TOP

Related Classes of org.apache.camel.model.rest.RestDefinition

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.