本文整理汇总了Java中org.apache.camel.test.AvailablePortFinder类的典型用法代码示例。如果您正苦于以下问题:Java AvailablePortFinder类的具体用法?Java AvailablePortFinder怎么用?Java AvailablePortFinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AvailablePortFinder类属于org.apache.camel.test包,在下文中一共展示了AvailablePortFinder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: beforeClass
import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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());
}
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:BaseEmbeddedKafkaTest.java
示例17: 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 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);
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:BaseNettyTest.java
示例18: createRouteBuilder
import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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");
}
};
}
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:JettyManual.java
示例19: configure
import org.apache.camel.test.AvailablePortFinder; //导入依赖的package包/类
@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
}
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:TestRouteBuilder.java
示例20: 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
注:本文中的org.apache.camel.test.AvailablePortFinder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论