You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/07/10 03:02:15 UTC
[GitHub] [camel] rhuan080 opened a new pull request, #7995: CAMEL-18262 - Fixing the Template issue
rhuan080 opened a new pull request, #7995:
URL: https://github.com/apache/camel/pull/7995
Signed-off-by: Rhuan Rocha <rh...@gmail.com>
- [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line and body.
- [ ] If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
- [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [ ] Run `mvn clean install -Psourcecheck` in your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically.
Below are the contribution guidelines:
https://github.com/apache/camel/blob/main/CONTRIBUTING.md
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] essobedo commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
essobedo commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1183316046
In other words, if you compare how a normal route and a templated route are initialized, you should see that in case of a templated route, this method is never called https://github.com/apache/camel/blob/main/core/camel-core-model/src/main/java/org/apache/camel/model/RoutesDefinition.java#L233
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] github-actions[bot] commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1182587171
There are too many components to be tested in this PR, components were removed or the code needs a rebase: (303 likely to be tested)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] rhuan080 commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
rhuan080 commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1183420978
Hi @essobedo,
I have used your unit test code! Thank you for helping me with this! I sent another commit fixing the template that does not prepare the RouteDefinition. Please, look at this and tell me what you think. The first commit is right, however, it really dons`t solves the issue totally. Now it is solving.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] github-actions[bot] commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1182587702
There are too many components to be tested in this PR, components were removed or the code needs a rebase: (303 likely to be tested)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] essobedo commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
essobedo commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1183308911
I believe that it works with the `AdviceWith.doAdviceWith` because in this case the route is properly prepared but please note that `AdviceWith.doAdviceWith` is only meant for testing purpose, we don't use it in production code so the code proposed in the new version of test case is more what we will do in practice.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] rhuan080 commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
rhuan080 commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1182195258
@zhfeng and @essobedo the unit test is done!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
davsclaus commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1194168765
Thanks for the PR - I would like to prepare the route before adding
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus merged pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
davsclaus merged PR #7995:
URL: https://github.com/apache/camel/pull/7995
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] zhfeng commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
zhfeng commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1181865121
Thanks @rhuan080 and that could be great!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] essobedo commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
essobedo commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1182472420
There are some checkstyle errors to fix:
```
[ERROR] /home/runner/work/camel/camel/core/camel-core/src/test/java/org/apache/camel/model/RouteConfigurationOnExceptionTest.java:1: Line does not match expected header line of '/*'. [Header]
[ERROR] /home/runner/work/camel/camel/core/camel-core/src/test/java/org/apache/camel/model/RouteConfigurationOnExceptionTest.java:13:1: Wrong order for 'java.net.ConnectException' import. [ImportOrder]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] zhfeng commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
zhfeng commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1181467542
@rhuan080 can you add a unit test at https://github.com/apache/camel/tree/main/core/camel-core/src/test/java/org/apache/camel/model
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] github-actions[bot] commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1182342575
There are too many components to be tested in this PR, components were removed or the code needs a rebase: (303 likely to be tested)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] github-actions[bot] commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1183514555
There are too many components to be tested in this PR, components were removed or the code needs a rebase: (303 likely to be tested)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] rhuan080 commented on a diff in pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
rhuan080 commented on code in PR #7995:
URL: https://github.com/apache/camel/pull/7995#discussion_r920290174
##########
core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultModel.java:
##########
@@ -96,6 +97,7 @@ public class DefaultModel implements Model {
private final Map<String, Resilience4jConfigurationDefinition> resilience4jConfigurations = new ConcurrentHashMap<>();
private final Map<String, FaultToleranceConfigurationDefinition> faultToleranceConfigurations = new ConcurrentHashMap<>();
private Function<RouteDefinition, Boolean> routeFilter;
+ private RoutesDefinition routeCollection = new RoutesDefinition();
Review Comment:
Done!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] github-actions[bot] commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1179649695
:no_entry_sign: There are (likely) no components to be tested in this PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] essobedo commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
essobedo commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1180075822
@rhuan080 Thx for the PR, just one remark, as you have a clear reproducer, would you mind adding a test to ensure that the problem is fixed and will not occur anymore?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] essobedo commented on a diff in pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
essobedo commented on code in PR #7995:
URL: https://github.com/apache/camel/pull/7995#discussion_r919313446
##########
core/camel-core/src/test/java/org/apache/camel/model/RouteConfigurationOnExceptionTest.java:
##########
@@ -0,0 +1,89 @@
+package org.apache.camel.model;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.builder.AdviceWith;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.builder.RouteConfigurationBuilder;
+import org.apache.camel.builder.TemplatedRouteBuilder;
+import org.apache.camel.component.direct.DirectConsumerNotAvailableException;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+import java.net.ConnectException;
+
+public class RouteConfigurationOnExceptionTest extends ContextTestSupport {
+
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
+ }
+
+ @Test
+ public void testGlobal() throws Exception {
+ context.addRoutes(new RouteConfigurationBuilder() {
+ @Override
+ public void configuration() throws Exception {
+ routeConfiguration("my-error-handler").onException(Exception.class)
+ .handled(true)
+ .log(LoggingLevel.ERROR, log, "--> Exception: ${exception.message}, Delivery was NOT rolled back");
+ }
+ });
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ routeTemplate("route-template-1")
+ .templateParameter("route_url-1")
+ .templateParameter("route_url-2")
+ .templateParameter("route-id-param-id")
+
+ .from("direct:{{route_url-1}}")
+ .routeConfigurationId("my-error-handler")
+ .end()
+
+ .log(LoggingLevel.INFO, log, "--> Executing")
+ .to("direct:{{route_url-2}}")
+ .id("{{route-id-param-id}}")
+ .log(LoggingLevel.INFO, log, "--> Executed!");
+ }
+ });
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+
+ from("direct:start2")
+ .to("mock:result2");
+ }
+ });
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ final String routeId = TemplatedRouteBuilder.builder(context, "route-template-1")
+ .routeId("my-test-file-route")
+ .parameter("route_url-1", "start")
+ .parameter("route_url-2", "startWrong")
+ .parameter("route-id-param-id", "my-internal-route-id")
+ .add();
+ }
+ });
+
+ MockEndpoint mockEndpoint = getMockEndpoint("mock:endpointMock");
+ AdviceWith.adviceWith(context, "my-test-file-route", routeBuilder -> {
+ routeBuilder.replaceFromWith("direct:start");
+ routeBuilder.weaveAddLast().to(mockEndpoint);
+ routeBuilder.setLogRouteAsXml(false);
+ });
+
+ context.start();
+
+ final String testMsg = "{ test msg }";
+
+ mockEndpoint.expectedMessageCount(0);
+ //mockEndpoint.expectedBodiesReceived(testMsg);
Review Comment:
I guess this can be removed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] zhfeng commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
zhfeng commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1182915651
The stylecheck failure is related to `GoogleSecretManagerPropertiesFunction.java`. So I think this PR looks good.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] rhuan080 commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
rhuan080 commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1183296038
Hi @essobedo,
Actually, the tests work with the new code and doesn`t work with the old code. I think we have two problems here, the copy I have done is correct. However, the test works because it is calling the Advice.adviceWith. This code is passing on tests
```
@Test
void testRouteTemplateCanSupportRouteConfiguration() throws Exception {
AdviceWith.adviceWith(context, "my-test-file-route", routeBuilder -> {
});
getMockEndpoint("mock:result").expectedMessageCount(1);
getMockEndpoint("mock:result").expectedBodiesReceived("Error Received");
template.sendBody("direct:start-template", "foo");
assertMockEndpointsSatisfied();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] github-actions[bot] commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1183508789
There are too many components to be tested in this PR, components were removed or the code needs a rebase: (303 likely to be tested)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] rhuan080 commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
rhuan080 commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1182559161
Done!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] essobedo commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
essobedo commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1182953480
The test case doesn't really prove that the bug is fixed.
Here is a good test case with normal route and route template:
```
class RouteConfigurationOnExceptionTest extends ContextTestSupport {
@Override
protected RouteBuilder[] createRouteBuilders() {
return new RouteBuilder[] {
new RouteBuilder() {
@Override
public void configure() {
routeTemplate("route-template")
.from("direct:start-template")
.routeConfigurationId("my-error-handler")
.throwException(RuntimeException.class, "Expected Error");
}
},
new RouteBuilder() {
@Override
public void configure() {
TemplatedRouteBuilder.builder(context, "route-template")
.routeId("my-test-file-route")
.add();
}
},
new RouteBuilder() {
@Override
public void configure() {
from("direct:start-normal")
.routeConfigurationId("my-error-handler")
.throwException(RuntimeException.class, "Expected Error");
}
},
new RouteConfigurationBuilder() {
@Override
public void configuration() {
routeConfiguration("my-error-handler").onException(Exception.class).handled(true)
.transform(constant("Error Received"))
.to("mock:result");
}
}
};
}
@Test
void testRouteTemplateCanSupportRouteConfiguration() throws Exception {
getMockEndpoint("mock:result").expectedMessageCount(1);
getMockEndpoint("mock:result").expectedBodiesReceived("Error Received");
template.sendBody("direct:start-template", "foo");
assertMockEndpointsSatisfied();
}
@Test
void testNormalRouteCanSupportRouteConfiguration() throws Exception {
getMockEndpoint("mock:result").expectedMessageCount(1);
getMockEndpoint("mock:result").expectedBodiesReceived("Error Received");
template.sendBody("direct:start-normal", "foo");
assertMockEndpointsSatisfied();
}
}
```
You will see that the test with the route template fails and the other passes. After a quick investigation, the main additional problem seems to be the fact that the route is not prepared when registering it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] rhuan080 commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
rhuan080 commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1180461143
Hi @essobedo the camel-model-core does not have a unit test. I have seen the tests are applied to components. Thus, I had doubts about providing unit tests here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] essobedo commented on a diff in pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
essobedo commented on code in PR #7995:
URL: https://github.com/apache/camel/pull/7995#discussion_r920286398
##########
core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultModel.java:
##########
@@ -96,6 +97,7 @@ public class DefaultModel implements Model {
private final Map<String, Resilience4jConfigurationDefinition> resilience4jConfigurations = new ConcurrentHashMap<>();
private final Map<String, FaultToleranceConfigurationDefinition> faultToleranceConfigurations = new ConcurrentHashMap<>();
private Function<RouteDefinition, Boolean> routeFilter;
+ private RoutesDefinition routeCollection = new RoutesDefinition();
Review Comment:
It is not meant to be shared, I rather prefer that you create a new instance at each call instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] github-actions[bot] commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1183494585
There are too many components to be tested in this PR, components were removed or the code needs a rebase: (303 likely to be tested)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] rhuan080 commented on pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
rhuan080 commented on PR #7995:
URL: https://github.com/apache/camel/pull/7995#issuecomment-1181861430
Sure! I`ll send a commit soon.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] rhuan080 commented on a diff in pull request #7995: CAMEL-18262 - Fixing the Template issue
Posted by GitBox <gi...@apache.org>.
rhuan080 commented on code in PR #7995:
URL: https://github.com/apache/camel/pull/7995#discussion_r919478670
##########
core/camel-core/src/test/java/org/apache/camel/model/RouteConfigurationOnExceptionTest.java:
##########
@@ -0,0 +1,89 @@
+package org.apache.camel.model;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.builder.AdviceWith;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.builder.RouteConfigurationBuilder;
+import org.apache.camel.builder.TemplatedRouteBuilder;
+import org.apache.camel.component.direct.DirectConsumerNotAvailableException;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+import java.net.ConnectException;
+
+public class RouteConfigurationOnExceptionTest extends ContextTestSupport {
+
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
+ }
+
+ @Test
+ public void testGlobal() throws Exception {
+ context.addRoutes(new RouteConfigurationBuilder() {
+ @Override
+ public void configuration() throws Exception {
+ routeConfiguration("my-error-handler").onException(Exception.class)
+ .handled(true)
+ .log(LoggingLevel.ERROR, log, "--> Exception: ${exception.message}, Delivery was NOT rolled back");
+ }
+ });
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ routeTemplate("route-template-1")
+ .templateParameter("route_url-1")
+ .templateParameter("route_url-2")
+ .templateParameter("route-id-param-id")
+
+ .from("direct:{{route_url-1}}")
+ .routeConfigurationId("my-error-handler")
+ .end()
+
+ .log(LoggingLevel.INFO, log, "--> Executing")
+ .to("direct:{{route_url-2}}")
+ .id("{{route-id-param-id}}")
+ .log(LoggingLevel.INFO, log, "--> Executed!");
+ }
+ });
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+
+ from("direct:start2")
+ .to("mock:result2");
+ }
+ });
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ final String routeId = TemplatedRouteBuilder.builder(context, "route-template-1")
+ .routeId("my-test-file-route")
+ .parameter("route_url-1", "start")
+ .parameter("route_url-2", "startWrong")
+ .parameter("route-id-param-id", "my-internal-route-id")
+ .add();
+ }
+ });
+
+ MockEndpoint mockEndpoint = getMockEndpoint("mock:endpointMock");
+ AdviceWith.adviceWith(context, "my-test-file-route", routeBuilder -> {
+ routeBuilder.replaceFromWith("direct:start");
+ routeBuilder.weaveAddLast().to(mockEndpoint);
+ routeBuilder.setLogRouteAsXml(false);
+ });
+
+ context.start();
+
+ final String testMsg = "{ test msg }";
+
+ mockEndpoint.expectedMessageCount(0);
+ //mockEndpoint.expectedBodiesReceived(testMsg);
Review Comment:
Done!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org