org.apache.camel.component.platform.http.PlatformHttpComponent Java Examples
The following examples show how to use
org.apache.camel.component.platform.http.PlatformHttpComponent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlatformHttpServiceContextCustomizer.java From camel-k-runtime with Apache License 2.0 | 6 votes |
@Override public void apply(CamelContext camelContext) { try { camelContext.addService(new VertxPlatformHttpServer(this) { @Override protected void doInit() throws Exception { initializeServer(); } @Override protected void doStart() throws Exception { startServer(); } }); } catch (Exception e) { throw new RuntimeException(e); } PlatformHttpComponent component = new PlatformHttpComponent(camelContext); component.setEngine(new VertxPlatformHttpEngine()); camelContext.getRegistry().bind(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME, component); }
Example #2
Source File: PlatformHttpEngineTest.java From camel-quarkus with Apache License 2.0 | 5 votes |
@Test public void registrySetUp() { RestAssured.given() .get("/test/registry/inspect") .then() .statusCode(200) .body( PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME, is(QuarkusPlatformHttpEngine.class.getName()), PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME, is(PlatformHttpComponent.class.getName()), "handlers-size", is(1)); }
Example #3
Source File: PlatformHttpProcessor.java From camel-quarkus with Apache License 2.0 | 5 votes |
@Record(ExecutionTime.RUNTIME_INIT) @BuildStep CamelRuntimeBeanBuildItem platformHttpComponentBean(PlatformHttpRecorder recorder, PlatformHttpEngineBuildItem engine) { return new CamelRuntimeBeanBuildItem( PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME, PlatformHttpComponent.class.getName(), recorder.createComponent(engine.getInstance())); }
Example #4
Source File: PlatformHttpComponentAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Lazy @Bean(name = "platform-http-component") @ConditionalOnMissingBean(PlatformHttpComponent.class) public PlatformHttpComponent configurePlatformHttpComponent() throws Exception { PlatformHttpComponent component = new PlatformHttpComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); CamelPropertiesHelper.setCamelProperties(camelContext, component, parameters, false); if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<PlatformHttpComponent> customizer : customizers) { boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.component.customizer", "camel.component.platform-http.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate( applicationContext.getEnvironment(), "camel.component.customizer", "camel.component.platform-http.customizer"); if (useCustomizer) { LOGGER.debug("Configure component {}, with customizer {}", component, customizer); customizer.customize(component); } } } return component; }
Example #5
Source File: PlatformHttpServiceCustomizerTest.java From camel-k-runtime with Apache License 2.0 | 5 votes |
@ParameterizedTest @ValueSource(strings = { "/", "/test", "/test/nested" }) public void testPlatformHttpComponent(String path) throws Exception { Runtime runtime = Runtime.on(new DefaultCamelContext()); runtime.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { fromF("platform-http:%s", path) .setBody().constant(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME); } }); PlatformHttpServiceContextCustomizer httpService = new PlatformHttpServiceContextCustomizer(); httpService.setBindPort(AvailablePortFinder.getNextAvailable()); httpService.apply(runtime.getCamelContext()); PlatformHttpComponent c = runtime.getCamelContext().getComponent(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME, PlatformHttpComponent.class); assertThat(c).isNotNull(); assertThat(c.getEngine()).isInstanceOf(VertxPlatformHttpEngine.class); try { runtime.getCamelContext().start(); given() .port(httpService.getBindPort()) .when() .get(path) .then() .statusCode(200) .body(equalTo(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME)); } finally { runtime.getCamelContext().stop(); } }
Example #6
Source File: PlatformHttpServiceCustomizerTest.java From camel-k-runtime with Apache License 2.0 | 5 votes |
@ParameterizedTest @ValueSource(strings = { "/", "/test", "/test/nested" }) public void testPlatformHttpComponentPost(String path) throws Exception { Runtime runtime = Runtime.on(new DefaultCamelContext()); runtime.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { fromF("platform-http:%s", path) .transform().body(String.class, b -> b.toUpperCase()); } }); PlatformHttpServiceContextCustomizer httpService = new PlatformHttpServiceContextCustomizer(); httpService.setBindPort(AvailablePortFinder.getNextAvailable()); httpService.apply(runtime.getCamelContext()); PlatformHttpComponent c = runtime.getCamelContext().getComponent(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME, PlatformHttpComponent.class); assertThat(c).isNotNull(); assertThat(c.getEngine()).isInstanceOf(VertxPlatformHttpEngine.class); try { runtime.getCamelContext().start(); given() .port(httpService.getBindPort()) .body("test") .when() .post(path) .then() .statusCode(200) .body(equalTo("TEST")); } finally { runtime.getCamelContext().stop(); } }
Example #7
Source File: PlatformHttpRecorder.java From camel-quarkus with Apache License 2.0 | 4 votes |
public RuntimeValue<PlatformHttpComponent> createComponent(RuntimeValue<PlatformHttpEngine> engine) { PlatformHttpComponent component = new PlatformHttpComponent(); component.setEngine(engine.getValue()); return new RuntimeValue<>(component); }