Skip to content

Commit

Permalink
chore: Give access to test context and Citrus in Groovy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
christophd committed Mar 15, 2022
1 parent 920e8e0 commit 79ea604
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void defaultContext() {
@Given("^(?:Default|New) global Camel context$")
public void defaultGlobalContext() {
destroyCamelContext();
citrus.getCitrusContext().getReferenceResolver().bind(contextName, camelContext());
citrus.getCitrusContext().bind(contextName, camelContext());
globalCamelContext = true;
}

Expand All @@ -163,7 +163,7 @@ public void camelContext(String beans) {
@Given("^(?:Default|New) global Spring Camel context$")
public void defaultGlobalContext(String beans) {
destroyCamelContext();
citrus.getCitrusContext().getReferenceResolver().bind(contextName, springCamelContext(beans));
citrus.getCitrusContext().bind(contextName, springCamelContext(beans));
globalCamelContext = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ public Object getProperty(String propertyName) {
try {
return getMetaClass().getProperty(this, propertyName);
} catch (NullPointerException | MissingPropertyException e) {
if (propertyName.equals("citrus")) {
return citrusFramework;
}

if (propertyName.equals("context")) {
return context;
}

if (context != null) {
if (context.getReferenceResolver().isResolvable(propertyName)) {
return context.getReferenceResolver().resolve(propertyName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Feature: Component script

Scenario: Use new component
Given $(echo(foo.text))
And run script: println foo.text

0 comments on commit 79ea604

Please sign in to comment.