Java 类org.apache.camel.test.AvailablePortFinder 实例源码

项目:django    文件:CamelCatalogRestTest.java   
@Before
public void setup() {
    catalog = new CamelCatalogRest();

    port = AvailablePortFinder.getNextAvailable(9000);

    // setup Apache CXF REST server
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(CamelCatalogRest.class);
    sf.setResourceProvider(CamelCatalogRest.class, new SingletonResourceProvider(catalog));
    // to use jackson for json
    sf.setProvider(JacksonJsonProvider.class);
    sf.setAddress("http://localhost:" + port);

    // create and start the CXF server (non blocking)
    server = sf.create();
    server.start();
}
项目:Camel    文件:NettyAsyncRequestReplyTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            port = AvailablePortFinder.getNextAvailable(8000);

            from("netty:tcp://localhost:" + port + "?textline=true&sync=true&reuseAddress=true&synchronous=false")
                .to("activemq:queue:foo")
                .log("Writing reply ${body}");

            from("activemq:queue:foo")
                .transform(simple("Bye ${body}"));
        }
    };
}
项目:Camel    文件:NettyHttpClientChunkedResponseTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            port1 = AvailablePortFinder.getNextAvailable(8000);
            port2 = AvailablePortFinder.getNextAvailable(9000);

            // use jetty as server as it supports sending response as chunked encoding
            from("jetty:http://localhost:" + port1 + "/test")
                .setHeader("Transfer-Encoding", constant("chunked"))
                .transform().simple("Bye ${body}");

            // set up a netty http proxy
            from("netty-http:http://localhost:" + port2 + "/test")
                .to("netty-http:http://localhost:" + port1 + "/test?bridgeEndpoint=true&throwExceptionOnFailure=false");

        }
    };
}
项目:Camel    文件:JmsJettyAsyncTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // enable async consumer to process messages faster
            from("activemq:queue:inbox?asyncConsumer=false")
                .to("jetty:http://0.0.0.0:" + port + "/myapp")
                .to("log:result?groupSize=10", "mock:result");

            from("jetty:http://0.0.0.0:" + port + "/myapp")
                .delay(100)
                .transform(body().prepend("Bye "));
        }
    };
}
项目:Camel    文件:JettyVelocityTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        public void configure() {
            from("jetty:http://localhost:" + port + "/test")
                .process(new Processor() {
                    @Override
                    public void process(Exchange exchange) throws Exception {
                        String name = exchange.getIn().getHeader("name", String.class);
                        ObjectHelper.notNull(name, "name");

                        name = "org/apache/camel/itest/jetty/" + name;
                        InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(exchange.getContext().getClassResolver(), name);
                        String xml = exchange.getContext().getTypeConverter().convertTo(String.class, is);

                        exchange.getOut().setBody(xml);
                        exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "text/plain");
                    }
                });
        }
    };
}
项目:Camel    文件:JettyConstantSetHeaderTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("jetty:http://localhost:" + port + "/beer")
                    .convertBodyTo(String.class)
                    .to("mock:before")
                    .setHeader("beer", constant("Carlsberg"))
                    .to("mock:result")
                    .transform(constant("Bye World"));
        }
    };
}
项目:Camel    文件:JettyRestRedirectTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        public void configure() {
            restConfiguration().component("jetty").host("localhost").scheme("http").port(port);
            rest("/metadata/profile")
                .get("/{id}").to("direct:profileLookup")
                .post("/tag").to("direct:tag");

            from("direct:profileLookup").transform().constant("Mock profile");
            from("direct:tag").log("${headers}").process(new Processor() {
                @Override
                public void process(Exchange ex) throws Exception {
                    ex.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 303);
                    ex.getOut().setHeader("Location", "/metadata/profile/1");
                }
            }).log("${headers}").transform().constant("Redirecting...");
        }
    };
}
项目:Camel    文件:JettyGroovySetHeaderTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("jetty:http://localhost:" + port + "/beer")
                    .convertBodyTo(String.class)
                    .to("mock:before")
                    .setHeader("beer", groovy("'Carlsberg'"))
                    .to("mock:result")
                    .transform(groovy("'Bye World'"));
        }
    };
}
项目:Camel    文件:JettyXsltTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        public void configure() {
            from("jetty:http://localhost:" + port + "/test")
                .process(new Processor() {
                    @Override
                    public void process(Exchange exchange) throws Exception {
                        String name = exchange.getIn().getHeader("name", String.class);
                        ObjectHelper.notNull(name, "name");

                        name = "org/apache/camel/itest/jetty/" + name;
                        InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(exchange.getContext().getClassResolver(), name);
                        String xml = exchange.getContext().getTypeConverter().convertTo(String.class, is);

                        exchange.getOut().setBody(xml);
                        exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "text/xml");
                    }
                });
        }
    };
}
项目:Camel    文件:JettySimpleSetHeaderTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("jetty:http://localhost:" + port + "/beer")
                    .convertBodyTo(String.class)
                    .to("mock:before")
                    .setHeader("beer", simple("Carlsberg"))
                    .to("mock:result")
                    .transform(simple("Bye World"));
        }
    };
}
项目:Camel    文件:JettyValidatorTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        public void configure() {
            from("jetty:http://localhost:" + port + "/test")
                .convertBodyTo(String.class)
                .to("log:in")
                .doTry()
                    .to("validator:OptimizationRequest.xsd")
                    .transform(constant("<ok/>"))
                .doCatch(ValidationException.class)
                    .transform(constant("<error/>"))
                .end()
                .to("log:out");
        }
    };
}
项目:Camel    文件:CometdCrossOriginConsumerTest.java   
@Test
public void testFilterArgumentsSetOnEndpoint() throws Exception {
    // setup
    CometdComponent component = context.getComponent("cometd", CometdComponent.class);
    int port = AvailablePortFinder.getNextAvailable(23500);

    // act
    Endpoint result = component
        .createEndpoint(String.format("cometd://127.0.0.1:%s?crossOriginFilterOn=true&allowedOrigins=%s&filterPath=%s",
             port, ALLOWED_ORIGINS, FILTER_PATH));

    // assert
    assertTrue(result instanceof CometdEndpoint);
    CometdEndpoint cometdEndpoint = (CometdEndpoint)result;
    assertTrue(cometdEndpoint.isCrossOriginFilterOn());
    assertEquals(ALLOWED_ORIGINS, cometdEndpoint.getAllowedOrigins());
    assertEquals(FILTER_PATH, cometdEndpoint.getFilterPath());
}
项目:Camel    文件:HttpCustomComponentNameTest.java   
@Test
public void testCustomName() throws Exception {
    context.start();

    int port = AvailablePortFinder.getNextAvailable(24400);

    Component custom = new HttpComponent();
    context.addComponent("http-foo", custom);
    ServiceHelper.startService(custom);

    String uri = "http-foo://www.somewhere.com:" + port + "?q=Camel";
    Endpoint endpoint = context.getEndpoint(uri);
    assertNotNull(endpoint);
    // the endpoint uri should use the custom component name as scheme
    assertEquals(uri, endpoint.getEndpointUri());

    context.stop();
}
项目:Camel    文件:BaseNettyTest.java   
@BeforeClass
public static void initPort() throws Exception {
    File file = new File("target/nettyport.txt");

    if (!file.exists()) {
        // start from somewhere in the 25xxx range
        port = AvailablePortFinder.getNextAvailable(25000);
    } else {
        // read port number from file
        String s = IOConverter.toString(file, null);
        port = Integer.parseInt(s);
        // use next free port
        port = AvailablePortFinder.getNextAvailable(port + 1);
    }

}
项目:Camel    文件:MllpTcpServerConsumerAcknowledgementTest.java   
@Override
protected RouteBuilder createRouteBuilder() {

    mllpClient.setMllpHost("localhost");
    mllpClient.setMllpPort(AvailablePortFinder.getNextAvailable());

    return new RouteBuilder() {
        int connectTimeout = 500;
        int responseTimeout = 5000;

        @Override
        public void configure() throws Exception {
            String routeId = "mllp-test-receiver-route";

            onCompletion()
                    .toF("log:%s?level=INFO&showAll=true", routeId)
                    .log(LoggingLevel.INFO, routeId, "Test route complete");

            fromF("mllp://%s:%d?autoAck=true&connectTimeout=%d&receiveTimeout=%d",
                    mllpClient.getMllpHost(), mllpClient.getMllpPort(), connectTimeout, responseTimeout)
                    .routeId(routeId)
                    .to(result);

        }
    };
}
项目:Camel    文件:BaseEmbeddedKafkaTest.java   
@BeforeClass
public static void beforeClass() {
    // start from somewhere in the 23xxx range
    zookeeperPort = AvailablePortFinder.getNextAvailable(23000);
    // find another ports for proxy route test
    karfkaPort = AvailablePortFinder.getNextAvailable(24000);

    embeddedZookeeper = new EmbeddedZookeeper(zookeeperPort);
    List<Integer> kafkaPorts = new ArrayList<Integer>();
    // -1 for any available port
    kafkaPorts.add(karfkaPort);
    embeddedKafkaCluster = new EmbeddedKafkaCluster(embeddedZookeeper.getConnection(), new Properties(), kafkaPorts);
    try {
        embeddedZookeeper.startup();
    } catch (IOException e) {
        e.printStackTrace();
    }
    System.out.println("### Embedded Zookeeper connection: " + embeddedZookeeper.getConnection());
    embeddedKafkaCluster.startup();
    System.out.println("### Embedded Kafka cluster broker list: " + embeddedKafkaCluster.getBrokerList());
}
项目:Camel    文件:BaseNettyTest.java   
@BeforeClass
public static void initPort() throws Exception {
    File file = new File("target/nettyport.txt");

    if (!file.exists()) {
        // start from somewhere in the 26xxx range
        port = AvailablePortFinder.getNextAvailable(26000);
    } else {
        // read port number from file
        String s = IOConverter.toString(file, null);
        port = Integer.parseInt(s);
        // use next free port
        port = AvailablePortFinder.getNextAvailable(port + 1);
    }

}
项目:Camel    文件:JettyManual.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        public void configure() throws Exception {
            from("jetty:http://localhost:" + AvailablePortFinder.getNextAvailable() + "/ myapp / myservice")
                .process(new Processor() {
                    public void process(Exchange exchange) throws Exception {
                        String body = exchange.getIn().getBody(String.class);
                        assertNotNull("Body should not be null", body);
                    }
                })
                .transform(constant("OK")).setHeader("Content-Type", constant("text/plain"))
                .to("mock:result");
        }
    };
}
项目:Camel    文件:TestRouteBuilder.java   
@Override
public void configure() throws Exception {

    // get port number dynamically
    int port = AvailablePortFinder.getNextAvailable();

    // START SNIPPET: consumer_route
    from("restlet:http://localhost:" + port + "/securedOrders?restletMethod=post&restletRealm=#realm").process(new Processor() {
        public void process(Exchange exchange) throws Exception {
            exchange.getOut().setBody(
                    "received [" + exchange.getIn().getBody(String.class)
                    + "] as an order id = "
                    + exchange.getIn().getHeader("id"));
        }
    });
    // END SNIPPET: consumer_route

    // START SNIPPET: producer_route
    // Note: restletMethod and restletRealmRef are stripped 
    // from the query before a request is sent as they are 
    // only processed by Camel.
    from("direct:start-auth").to("restlet:http://localhost:" + port + "/securedOrders?restletMethod=post");
    // END SNIPPET: producer_route

}
项目:django    文件:CamelCatalogSwaggerTest.java   
@Before
public void setup() {
    catalog = new CamelCatalogRest();

    port = AvailablePortFinder.getNextAvailable(9000);

    // setup Apache CXF REST server
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(CamelCatalogRest.class);
    sf.setResourceProvider(CamelCatalogRest.class, new SingletonResourceProvider(catalog));

    Swagger2Feature swagger = new Swagger2Feature();
    swagger.setBasePath("/");
    swagger.setScanAllResources(false);
    swagger.setPrettyPrint(true);
    swagger.setSupportSwaggerUi(true);
    swagger.setTitle("Camel Catalog REST Api");
    swagger.setDescription("REST Api for the Camel Catalog");
    swagger.setVersion(catalog.getCatalogVersion());
    swagger.setContact("Apache Camel");
    sf.getFeatures().add(swagger);

    // to use jackson for json
    sf.setProvider(JacksonJsonProvider.class);
    sf.setAddress("http://localhost:" + port);

    // create and start the CXF server (non blocking)
    server = sf.create();
    server.start();
}
项目:Camel    文件:CamelCxfExample.java   
@Override
public void configure() throws Exception {
    // Set system properties for use with Camel property placeholders for running the example tests.
    System.setProperty("routerPort", String.valueOf(AvailablePortFinder.getNextAvailable()));
    System.setProperty("servicePort", String.valueOf(AvailablePortFinder.getNextAvailable()));
    CxfComponent cxfComponent = new CxfComponent(getContext());
    CxfEndpoint serviceEndpoint = new CxfEndpoint(SERVICE_ADDRESS, cxfComponent);
    serviceEndpoint.setServiceClass(Greeter.class); 

    // Here we just pass the exception back, don't need to use errorHandler
    errorHandler(noErrorHandler());
    from(ROUTER_ENDPOINT_URI).to(serviceEndpoint);
}
项目:Camel    文件:CamelTransportClientServerTest.java   
@BeforeClass
public static void startUpServer() throws Exception {
    if (!"true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"))) {
        port = AvailablePortFinder.getNextAvailable();
        System.setProperty("port", String.valueOf(port));
        context = new ClassPathXmlApplicationContext(new String[]{"/META-INF/spring/CamelTransportSpringConfig.xml"});
    } else {
        System.out.println("Skipping starting CamelContext as system property skipStartingCamelContext is set to be true.");
    }
}
项目:Camel    文件:ProviderClientServerTest.java   
@Override
protected AbstractXmlApplicationContext createApplicationContext() {
    port = AvailablePortFinder.getNextAvailable();
    System.setProperty("port", String.valueOf(port));

    return new ClassPathXmlApplicationContext(new String[]{"/META-INF/spring/CamelCXFProviderRouteConfig.xml"});
}
项目:Camel    文件:RmiTest.java   
@BeforeClass
public static void setupFreePort() throws Exception {
    // find a free port number, and write that in the custom.properties file
    // which we will use for the unit tests, to avoid port number in use problems
    port = AvailablePortFinder.getNextAvailable();
    String s = "port=" + port;

    File custom = new File("target/custom.properties");
    FileOutputStream fos = new FileOutputStream(custom);
    fos.write(s.getBytes());
    fos.close();
}
项目:Camel    文件:ReportIncidentRoutesClientTest.java   
@BeforeClass
public static void setupFreePort() throws Exception {
    // find a free port number, and write that in the custom.properties file
    // which we will use for the unit tests, to avoid port number in use problems
    int port = AvailablePortFinder.getNextAvailable();
    String s = "port=" + port;
    File custom = new File("target/custom.properties");
    FileOutputStream fos = new FileOutputStream(custom);
    fos.write(s.getBytes());
    fos.close();
}
项目:Camel    文件:SpringJmsClientServerTest.java   
@BeforeClass
public static void setupFreePort() throws Exception {
    // find a free port number, and write that in the custom.properties file
    // which we will use for the unit tests, to avoid port number in use problems
    int port = AvailablePortFinder.getNextAvailable();
    String bank1 = "tcp.port=" + port;

    File custom = new File("target/custom.properties");
    FileOutputStream fos = new FileOutputStream(custom);
    fos.write(bank1.getBytes());
    fos.close();
}
项目:Camel    文件:SpringJmsClientRemotingServerTest.java   
@BeforeClass
public static void setupFreePort() throws Exception {
    // find a free port number, and write that in the custom.properties file
    // which we will use for the unit tests, to avoid port number in use problems
    int port = AvailablePortFinder.getNextAvailable();
    String bank1 = "tcp.port=" + port;

    File custom = new File("target/custom.properties");
    FileOutputStream fos = new FileOutputStream(custom);
    fos.write(bank1.getBytes());
    fos.close();

    appCtx = new ClassPathXmlApplicationContext("/META-INF/spring/camel-server.xml", "camel-client-remoting.xml");
    appCtx.start();
}
项目:Camel    文件:LoanBrokerWSTest.java   
@BeforeClass
public static void setupFreePort() throws Exception {
    // find a free port number, and write that in the custom.properties file
    // which we will use for the unit tests, to avoid port number in use problems
    int port = AvailablePortFinder.getNextAvailable(); 
    String bank1 = "bank1.port=" + port;
    port = AvailablePortFinder.getNextAvailable();
    String bank2 = "bank2.port=" + port;
    port = AvailablePortFinder.getNextAvailable();
    String bank3 = "bank3.port=" + port;
    port = AvailablePortFinder.getNextAvailable();
    String credit = "credit_agency.port=" + port;
    port = AvailablePortFinder.getNextAvailable();
    String loan = "loan_broker.port=" + port;

    File custom = new File("target/custom.properties");
    FileOutputStream fos = new FileOutputStream(custom);
    fos.write(bank1.getBytes());
    fos.write("\n".getBytes());
    fos.write(bank2.getBytes());
    fos.write("\n".getBytes());
    fos.write(bank3.getBytes());
    fos.write("\n".getBytes());
    fos.write(credit.getBytes());
    fos.write("\n".getBytes());
    fos.write(loan.getBytes());
    fos.write("\n".getBytes());
    fos.close();

    url = "http://localhost:" + port + "/loanBroker";
}
项目:Camel    文件:ReportIncidentRoutesTest.java   
@BeforeClass
public static void setupFreePort() throws Exception {
    // find a free port number, and write that in the custom.properties file
    // which we will use for the unit tests, to avoid port number in use problems
    int port = AvailablePortFinder.getNextAvailable();
    String s = "port=" + port;
    File custom = new File("target/custom.properties");
    FileOutputStream fos = new FileOutputStream(custom);
    fos.write(s.getBytes());
    fos.close();
}
项目:Camel    文件:ReportIncidentRoutesTest.java   
@BeforeClass
public static void setupFreePort() throws Exception {
    // find a free port number, and write that in the custom.properties file
    // which we will use for the unit tests, to avoid port number in use problems
    int port = AvailablePortFinder.getNextAvailable();
    String s = "port=" + port;
    File custom = new File("target/custom.properties");
    FileOutputStream fos = new FileOutputStream(custom);
    fos.write(s.getBytes());
    fos.close();
}
项目:Camel    文件:SslContextParametersCometdProducerConsumerTest.java   
@Override
@Before
public void setUp() throws Exception {
    port = AvailablePortFinder.getNextAvailable(23500);
    uri = "cometds://127.0.0.1:" + port + "/service/test?baseResource=file:./target/test-classes/webapp&"
            + "timeout=240000&interval=0&maxInterval=30000&multiFrameInterval=1500&jsonCommented=true&logLevel=2";

    super.setUp();
}
项目:Camel    文件:JmsToHttpWithRollbackRoute.java   
public void configure() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    // configure a global transacted error handler
    errorHandler(transactionErrorHandler(required));

    from(data)
        // must setup policy for each route due CAMEL-1475 bug
        .policy(required)
        // send a request to http and get the response
        .to("http://localhost:" + port + "/sender")
        // convert the response to String so we can work with it and avoid streams only be readable once
        // as the http component will return data as a stream
        .convertBodyTo(String.class)
        // do a choice if the response is okay or not
        .choice()
            // do a xpath to compare if the status is NOT okay
            .when().xpath("/reply/status != 'ok'")
                // as this is based on an unit test we use mocks to verify how many times we did rollback
                .to("mock:rollback")
                // response is not okay so force a rollback
                .rollback()
            .otherwise()
            // otherwise since its okay, the route ends and the response is sent back
            // to the original caller
        .end();

    // this is our http route that will fail the first 2 attempts
    // before it sends an ok response
    from("jetty:http://localhost:" + port + "/sender").process(new Processor() {
        public void process(Exchange exchange) throws Exception {
            if (counter++ < 2) {
                exchange.getOut().setBody(nok);
            } else {
                exchange.getOut().setBody(ok);
            }
        }
    });
}
项目:Camel    文件:HttpRouteContentLengthTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            port1 = AvailablePortFinder.getNextAvailable(8000);
            port2 = AvailablePortFinder.getNextAvailable(9000);

            // use jetty as server as it supports sending response as chunked encoding
            from("jetty:http://localhost:" + port1 + "/test")
                .process(new Processor() {

                    @Override
                    public void process(Exchange exchange) throws Exception {
                        String contentLength = exchange.getIn().getHeader(Exchange.CONTENT_LENGTH, String.class);
                        String request = exchange.getIn().getBody(String.class);
                        exchange.getOut().setBody(request + ": " + contentLength);
                    }

                })
                .transform().simple("Bye ${body}");

            // set up a netty http proxy
            from("jetty:http://localhost:" + port2 + "/test")
                .to(getHttpEndpointScheme() + port1 + "/test?bridgeEndpoint=true&throwExceptionOnFailure=false");

        }
    };
}
项目:Camel    文件:JmsHttpJmsTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        public void configure() {
            from("jms:in").to("http://localhost:" + port + "/myservice").convertBodyTo(String.class).to("jms:out", "mock:result");

            from("jms:reply").to("http://localhost:" + port + "/myservice");

            from("jetty:http://0.0.0.0:" + port + "/myservice").transform().constant("Bye World");
        }
    };
}
项目:Camel    文件:JmsHttpPostIssueWithMockTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        public void configure() {
            from("jms:queue:in")
                .setBody().simple("name=${body}")
                .setHeader(CONTENT_TYPE).constant("application/x-www-form-urlencoded")
                .setHeader(HTTP_METHOD).constant("POST")
                .to("http://localhost:" + port + "/myservice")
                .to("mock:result");

            from("jetty:http://0.0.0.0:" + port + "/myservice")
                .process(new Processor() {
                    @Override
                    public void process(Exchange exchange) throws Exception {
                        String body = exchange.getIn().getBody(String.class);
                        assertEquals("name=Hello World", body);

                        exchange.getOut().setBody("OK");
                        exchange.getOut().setHeader(CONTENT_TYPE, "text/plain");
                        exchange.getOut().setHeader(HTTP_RESPONSE_CODE, 200);
                    }
                });
        }
    };
}
项目:Camel    文件:JettyXsltHttpTemplateTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("jetty:http://0.0.0.0:" + port + "/myxslt")
                .pollEnrich("file://src/test/resources/org/apache/camel/itest/jetty/?fileName=transform.xsl&noop=true&readLock=none", 2000)
                .convertBodyTo(String.class)
                .to("log:transform");
        }
    };
}
项目:Camel    文件:JettyValidatorStreamTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("jetty:http://localhost:" + port + "/test")
                .to("validator:OptimizationRequest.xsd")
                .transform(constant("<ok/>"));
        }
    };
}
项目:Camel    文件:JettyFreemarkerTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        public void configure() {
            from("jetty:http://localhost:" + port + "/test")
                .process(new Processor() {
                    @Override
                    public void process(Exchange exchange) throws Exception {
                        String name = exchange.getIn().getHeader("name", String.class);
                        ObjectHelper.notNull(name, "name");

                        // strip off the locale
                        name = ObjectHelper.before(name, "_");

                        name = "org/apache/camel/itest/jetty/" + name + ".ftl";
                        InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(exchange.getContext().getClassResolver(), name);
                        String xml = exchange.getContext().getTypeConverter().convertTo(String.class, is);

                        exchange.getOut().setBody(xml);
                        exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "text/plain");
                    }
                });
        }
    };
}
项目:Camel    文件:JettyValidatorStreamWithStreamCachingEnabledTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            context.setStreamCaching(true);

            from("jetty:http://localhost:" + port + "/test")
                .to("validator:OptimizationRequest.xsd")
                .transform(constant("<ok/>"));
        }
    };
}
项目:Camel    文件:NettyHttpGetWithInvalidMessageTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            port1 = AvailablePortFinder.getNextAvailable(8100);

           // set up a netty http proxy
            from("netty-http:http://localhost:" + port1 + "/test")
                .transform().simple("Bye ${header.user}.");

        }
    };
}