Skip to content
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

[SWITCHYARD-2580] Make it possible to don't startup service bindings aut... #765

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ protected RouteDefinition createRouteDefinition() {
addTransactionPolicy(route);
addNamespacePolicy(route);

route.setProperty(ExchangeCompletionEvent.GATEWAY_NAME).simple(getBindingModel().getName(), String.class)
route.autoStartup(getBindingModel().isAutoStartup())
.setProperty(ExchangeCompletionEvent.GATEWAY_NAME).simple(getBindingModel().getName(), String.class)
.setProperty(CamelConstants.APPLICATION_NAMESPACE).constant(_serviceName.getNamespaceURI())
.process(new MessageComposerProcessor(getBindingModel()))
.process(new OperationSelectorProcessor(getServiceName(), getBindingModel()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;

import org.junit.Assert;
import org.junit.Test;

/**
Expand Down Expand Up @@ -115,4 +116,16 @@ public void hasTransactionManager() throws Exception {
_camelContext.stop();
}

/**
* Test covering a case when binding camel route does not startup automatically
* @throws Exception If route startup or shutdown fails.
*/
@Test
public void testBindingRouteAutoStartup() throws Exception {
InboundHandler handler = createInboundHandler("direct://autoStartup", false);
_camelContext.start();
Assert.assertEquals(false, _camelContext.getRouteDefinition(handler.getRouteId()).isAutoStartup(_camelContext));
_camelContext.stop();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,27 @@ public void startUp() {
_configuration = mock(Configuration.class);
}

protected InboundHandler<?> createInboundHandler(final String uri, final boolean autoStartup) {
return createInboundHandler(uri, null, autoStartup, null, null, null);
}

protected InboundHandler<?> createInboundHandler(final String uri) {
return createInboundHandler(uri, null, null, null, null);
return createInboundHandler(uri, null, true, null, null, null);
}

protected InboundHandler<?> createInboundHandler(final String uri, final String name, OperationSelectorModel selectorModel) {
return createInboundHandler(uri, name, selectorModel, null, null);
return createInboundHandler(uri, name, true, selectorModel, null, null);
}

protected InboundHandler<?> createInboundHandler(final String uri, final String name, MessageComposerModel composerModel) {
return createInboundHandler(uri, name, null, composerModel, null);
return createInboundHandler(uri, name, true, null, composerModel, null);
}

protected InboundHandler<?> createInboundHandler(final String uri, final String name, ContextMapperModel mapperModel) {
return createInboundHandler(uri, name, null, null, mapperModel);
return createInboundHandler(uri, name, true, null, null, mapperModel);
}

protected InboundHandler<?> createInboundHandler(final String uri, final String name, final OperationSelectorModel selectorModel,
protected InboundHandler<?> createInboundHandler(final String uri, final String name, final boolean autoStartup, final OperationSelectorModel selectorModel,
final MessageComposerModel composerModel, final ContextMapperModel mapperModel) {
V1BaseCamelBindingModel camelBindingModel = new V1BaseCamelBindingModel(_configuration, new Descriptor()) {
@Override
Expand All @@ -103,6 +107,10 @@ public MessageComposerModel getMessageComposer() {
public ContextMapperModel getContextMapper() {
return mapperModel;
}
@Override
public boolean isAutoStartup() {
return autoStartup;
}
};
return new InboundHandler<V1BaseCamelBindingModel>(camelBindingModel, _camelContext, new QName("urn:foo", "dummyService"), null);
}
Expand Down