当前位置: 首页>>代码示例>>Java>>正文


Java AvailablePortFinder类代码示例

本文整理汇总了Java中org.apache.camel.test.AvailablePortFinder的典型用法代码示例。如果您正苦于以下问题:Java AvailablePortFinder类的具体用法?Java AvailablePortFinder怎么用?Java AvailablePortFinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AvailablePortFinder类属于org.apache.camel.test包,在下文中一共展示了AvailablePortFinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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();
}
 
开发者ID:fabric8io,项目名称:django,代码行数:19,代码来源:CamelCatalogRestTest.java

示例2: createRouteBuilder

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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}"));
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:NettyAsyncRequestReplyTest.java

示例3: createRouteBuilder

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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");
      
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:NettyHttpClientChunkedResponseTest.java

示例4: createRouteBuilder

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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 "));
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:JmsJettyAsyncTest.java

示例5: createRouteBuilder

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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");
                    }
                });
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:JettyVelocityTest.java

示例6: createRouteBuilder

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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"));
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:JettyConstantSetHeaderTest.java

示例7: createRouteBuilder

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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...");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:JettyRestRedirectTest.java

示例8: createRouteBuilder

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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'"));
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:JettyGroovySetHeaderTest.java

示例9: createRouteBuilder

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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");
                    }
                });
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:JettyXsltTest.java

示例10: createRouteBuilder

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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"));
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:JettySimpleSetHeaderTest.java

示例11: createRouteBuilder

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:JettyValidatorTest.java

示例12: testFilterArgumentsSetOnEndpoint

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:CometdCrossOriginConsumerTest.java

示例13: testCustomName

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:HttpCustomComponentNameTest.java

示例14: initPort

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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);
    }

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:BaseNettyTest.java

示例15: createRouteBuilder

import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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);

        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:MllpTcpServerConsumerAcknowledgementTest.java


注:本文中的org.apache.camel.test.AvailablePortFinder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。