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


Java AvailablePortFinder.getNextAvailable方法代码示例

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


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

示例1: EmbeddedActiveMQBroker

import org.apache.camel.test.AvailablePortFinder; //导入方法依赖的package包/类
public EmbeddedActiveMQBroker(String brokerId) {
    if ((brokerId == null) || (brokerId.isEmpty())) {
        throw new IllegalArgumentException("brokerId is empty");
    }
    this.brokerId = brokerId;
    tcpConnectorUri = "tcp://localhost:" + AvailablePortFinder.getNextAvailable();

    brokerService = new BrokerService();
    brokerService.setBrokerId(brokerId);
    brokerService.setPersistent(false);
    brokerService.setUseJmx(false);
    try {
        brokerService.setPersistenceAdapter(new MemoryPersistenceAdapter());
        brokerService.addConnector(tcpConnectorUri);
    } catch (Exception e) {
        throw new RuntimeException("Problem creating brokerService", e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:EmbeddedActiveMQBroker.java

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: setUp

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

示例8: 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));

    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();
}
 
开发者ID:fabric8io,项目名称:django,代码行数:31,代码来源:CamelCatalogSwaggerTest.java

示例9: setUp

import org.apache.camel.test.AvailablePortFinder; //导入方法依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
    port = AvailablePortFinder.getNextAvailable(16200);
    super.setUp();
    received.clear();
    latch =  new CountDownLatch(1);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:WebsocketProducerRouteExampleTest.java

示例10: 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(8100);
            
           // set up a netty http proxy
            from("netty-http:http://localhost:" + port1 + "/test")
                .transform().simple("Bye ${header.user}.");
      
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:NettyHttpGetWithInvalidMessageTest.java

示例11: setUp

import org.apache.camel.test.AvailablePortFinder; //导入方法依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
    port1 = AvailablePortFinder.getNextAvailable(23500);
    port2 = AvailablePortFinder.getNextAvailable(23510);
    uri1 = "cometd://127.0.0.1:" + port1 + "/service/test?baseResource=file:./target/test-classes/webapp&"
            + "timeout=240000&interval=0&maxInterval=30000&multiFrameInterval=1500&jsonCommented=true&logLevel=2";

    uri2 = "cometd://127.0.0.1:" + port2 + "/service/test?baseResource=file:./target/test-classes/webapp&"
        + "timeout=240000&interval=0&maxInterval=30000&multiFrameInterval=1500&jsonCommented=true&logLevel=2";
    super.setUp();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:MultipCometdProducerConsumerTest.java

示例12: setupFreePort

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

示例13: setUp

import org.apache.camel.test.AvailablePortFinder; //导入方法依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
    port = AvailablePortFinder.getNextAvailable(16300);

    URL trustStoreUrl = this.getClass().getClassLoader().getResource("jsse/localhost.ks");
    setSystemProp("javax.net.ssl.trustStore", trustStoreUrl.toURI().getPath());
    uri = "websocket://" + server + ":" + port + "/test?sslContextParametersRef=#sslContextParameters";

    super.setUp();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:WebsocketSSLContextInUriRouteExampleTest.java

示例14: configure

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

示例15: initPort

import org.apache.camel.test.AvailablePortFinder; //导入方法依赖的package包/类
@BeforeClass
public static void initPort() throws Exception {
    port = AvailablePortFinder.getNextAvailable(21000);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:BaseServerTestSupport.java


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