forked from apache/camel-k-runtime
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kamelets: create a camel-kamelet component apache#375
- Loading branch information
1 parent
75f697d
commit 67e5e96
Showing
4 changed files
with
195 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...let/src/test/java/org/apache/camel/component/kamelet/KameletAddAfterCamelStartedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.camel.component.kamelet; | ||
|
||
import java.util.UUID; | ||
|
||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.builder.RouteBuilder; | ||
import org.apache.camel.impl.DefaultCamelContext; | ||
import org.junit.jupiter.api.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class KameletAddAfterCamelStartedTest { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(KameletAddAfterCamelStartedTest.class); | ||
|
||
@Test | ||
public void test() throws Exception { | ||
String body = UUID.randomUUID().toString(); | ||
|
||
CamelContext context = new DefaultCamelContext(); | ||
context.addRoutes(new RouteBuilder() { | ||
@Override | ||
public void configure() throws Exception { | ||
routeTemplate("setBody") | ||
.templateParameter("bodyValue") | ||
.from("direct:{{routeId}}") | ||
.setBody().constant("{{bodyValue}}"); | ||
} | ||
}); | ||
|
||
/* | ||
context.addRouteFromTemplate("setBody") | ||
.routeId("test") | ||
.parameter("routeId", "test") | ||
.parameter("bodyValue", body) | ||
.build(); | ||
*/ | ||
|
||
// start camel here and add routes with kamelts later | ||
context.start(); | ||
|
||
context.addRoutes(new RouteBuilder() { | ||
@Override | ||
public void configure() throws Exception { | ||
// routes | ||
from("direct:template") | ||
.toF("kamelet:setBody/test?bodyValue=%s", body) | ||
.to("log:1"); | ||
} | ||
}); | ||
|
||
assertThat( | ||
context.createFluentProducerTemplate().to("direct:template").withBody("test").request(String.class) | ||
).isEqualTo(body); | ||
|
||
context.stop(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters