New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CAMEL-18262 - Fixing the Template issue #7995
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1fc3cf8
CAMEL-18262 - Fixing the Template issue
rhuan080 2d49ab6
CAMEL-18262 - Adding unit test
rhuan080 455ae49
CAMEL-18262 - Removing comments.
rhuan080 e04d1ff
CAMEL-18262 - Fixing the format issue.
rhuan080 26a2c03
CAMEL-18262 - Fixing the template routeDefinition prepare
rhuan080 a9dfcd1
CAMEL-18262 - Fixing the format issue.
rhuan080 9c79b05
CAMEL-18262 - Creating one RoutesDefinition per call
rhuan080 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
89 changes: 89 additions & 0 deletions
89
core/camel-core/src/test/java/org/apache/camel/model/RouteConfigurationOnExceptionTest.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,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); | ||
template.sendBody("direct:start", testMsg); | ||
mockEndpoint.assertIsSatisfied(); | ||
|
||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!