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

Can variables be used in send action.payload() and query action.statement()? #645

Closed
johnshirey opened this issue Apr 25, 2019 · 14 comments
Closed
Labels
good first issue A good point to start from for new contributrs Prio: Low Type: Bug

Comments

@johnshirey
Copy link

johnshirey commented Apr 25, 2019

Citrus Version
2.7.8

Question
Can variables be used in send action.payload() and query action.statement()?

What I've tried so far
In my Citrus Framework test cases it was recommended to me that I should try and read resource file path strings and SQL select statement strings as properties use them in variables instead of hard coding the stings in my test cases.

So I am trying to use a property file to populate Citrus global variables with resource file paths and SQL select statements. The properties (resource file path and SQL select statement strings) get loaded into the Text Context global variables just fine.

However when the file path string gets passed to FileUtils it is the variable name that gets passed instead of the string inside the variable.

Reading file resource: '${0150reqpath}' (encoding is 'windows-1252') => Failed to read payload resource

And when the SQL select string gets passed to validateSqlStatement again it is the variable name that gets passed instead of the string inside the variable.

Missing keyword SELECT in statement: ${stage8sql}

I've tried variable names with ${} around them and without
I've tried no quotes around the stings in the property file and "" around the strings in the property file.

Additional information
citrus-context.xml exerpt

  <context:property-placeholder location="classpath:rfsstest.properties"/>
  
  <citrus:global-variables>
  	<citrus:file path="classpath:rfsstest.properties"/>
  </citrus:global-variables>

rfsstest.properties

0150reqpath="C:\Users\BAEIV5T\git\TSSVCitrus\TSSVCitrus\src\test\resources\ATLAS_HHHKACS_SchM_0150_Req.xml"
stage8sql="select * from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='08'"
stage10sql="select * from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='10'"

RFSStest0150prop.java

package tssv.pipeline.citrus;

import org.testng.annotations.Test;
import org.apache.commons.dbcp2.BasicDataSource;

import com.consol.citrus.annotations.CitrusTest;
import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;
import org.testng.Reporter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;

@Test
public class RFSStest0150prop extends TestNGCitrusTestRunner{
	@Autowired
	private BasicDataSource dataSource;
	
  @CitrusTest (name = "rfss0150dbp")      
  public void rfss0150dbp() {
	  	
		Boolean sent = false;
		int tries = 0;
		while ((sent == false) & (tries <= 5)){
			try  
			{  
				send(action -> action.endpoint("rfss_request11")
						.payload(new FileSystemResource("${0150reqpath}")));
				sent = true;
				tries = 5;
				sleep(5000);
			} catch (Exception e) {  
				e.printStackTrace();
				tries = tries + 1;
				sent = false;
			} 
		}
			
		sequential().actions( 
			repeatOnError().until("i = 5").index("i").autoSleep(1000).actions(
					query(action -> action.dataSource(dataSource)
							.statement("${stage8sql}")
							.validate("INBUND_OTBUND_CD", "F"))
					),
			repeatOnError().until("i = 5").index("i").autoSleep(1000).actions(
					query(action -> action.dataSource(dataSource)
							.statement("${stage10sql}")
							.validate("INBUND_OTBUND_CD", "O"))
					)
			);

		Reporter.log("RFSS Organization detailed response and final found in database");

  }
	

}
09:47:34,757 INFO  BeanDefinitionReader| Loading XML bean definitions from URL [file:/C:/Users/BAEIV5T/git/TSSVCitrus/TSSVCitrus/target/test-classes/citrus-context.xml]
09:47:35,055 DEBUG BeanDefinitionReader| Loaded 19 bean definitions from location pattern [classpath*:citrus-context.xml]
09:47:35.825 [main] DEBUG com.consol.citrus.variable.GlobalVariablesPropertyLoader - Reading property file rfsstest.properties
09:47:35.829 [main] DEBUG com.consol.citrus.variable.GlobalVariablesPropertyLoader - Property line [ 0150reqpath="C:\Users\BAEIV5T\git\TSSVCitrus\TSSVCitrus\src\test\resources\ATLAS_HHHKACS_SchM_0150_Req.xml" ]
09:47:35.831 [main] DEBUG com.consol.citrus.variable.GlobalVariablesPropertyLoader - Property value replace dynamic content [ "C:\Users\BAEIV5T\git\TSSVCitrus\TSSVCitrus\src\test\resources\ATLAS_HHHKACS_SchM_0150_Req.xml" ]
09:47:35.832 [main] DEBUG com.consol.citrus.variable.GlobalVariablesPropertyLoader - Loading property: 0150reqpath="C:\Users\BAEIV5T\git\TSSVCitrus\TSSVCitrus\src\test\resources\ATLAS_HHHKACS_SchM_0150_Req.xml" into default variables
09:47:35.833 [main] DEBUG com.consol.citrus.context.TestContext - Setting variable: 0150reqpath with value: '"C:\Users\BAEIV5T\git\TSSVCitrus\TSSVCitrus\src\test\resources\ATLAS_HHHKACS_SchM_0150_Req.xml"'
09:47:35.833 [main] DEBUG com.consol.citrus.variable.GlobalVariablesPropertyLoader - Property line [ stage8sql="select * from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='08'" ]
09:47:35.833 [main] DEBUG com.consol.citrus.variable.GlobalVariablesPropertyLoader - Property value replace dynamic content [ "select * from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='08'" ]
09:47:35.833 [main] DEBUG com.consol.citrus.variable.GlobalVariablesPropertyLoader - Loading property: stage8sql="select * from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='08'" into default variables
09:47:35.833 [main] DEBUG com.consol.citrus.context.TestContext - Setting variable: stage8sql with value: '"select * from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='08'"'
09:47:35.833 [main] DEBUG com.consol.citrus.variable.GlobalVariablesPropertyLoader - Property line [ stage10sql="select * from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='10'" ]
09:47:35.833 [main] DEBUG com.consol.citrus.variable.GlobalVariablesPropertyLoader - Property value replace dynamic content [ "select * from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='10'" ]
09:47:35.833 [main] DEBUG com.consol.citrus.variable.GlobalVariablesPropertyLoader - Loading property: stage10sql="select * from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='10'" into default variables
09:47:35.833 [main] DEBUG com.consol.citrus.context.TestContext - Setting variable: stage10sql with value: '"select * from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='10'"'
09:47:35.833 [main] INFO com.consol.citrus.variable.GlobalVariablesPropertyLoader - Loaded property file rfsstest.properties

09:47:36.458 [main] DEBUG com.consol.citrus.TestCase - Initializing test case
09:47:36.458 [main] DEBUG com.consol.citrus.TestCase - Global variables:
09:47:36.458 [main] DEBUG com.consol.citrus.TestCase - stage8sql = "select * from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='08'"
09:47:36.458 [main] DEBUG com.consol.citrus.TestCase - stage10sql = "select * from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='10'"
09:47:36.458 [main] DEBUG com.consol.citrus.TestCase - 0150reqpath = "C:\Users\BAEIV5T\git\TSSVCitrus\TSSVCitrus\src\test\resources\ATLAS_HHHKACS_SchM_0150_Req.xml"
09:47:36.458 [main] DEBUG com.consol.citrus.context.TestContext - Setting variable: citrus.test.name with value: 'rfss0150dbp'
09:47:36.458 [main] DEBUG com.consol.citrus.context.TestContext - Setting variable: citrus.test.package with value: 'tssv.pipeline.citrus'
09:47:36.458 [main] DEBUG com.consol.citrus.TestCase - Test variables:
09:47:36.458 [main] DEBUG com.consol.citrus.TestCase - stage8sql = "select * from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='08'"
09:47:36.458 [main] DEBUG com.consol.citrus.TestCase - stage10sql = "select * from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='10'"
09:47:36.458 [main] DEBUG com.consol.citrus.TestCase - citrus.test.package = tssv.pipeline.citrus
09:47:36.458 [main] DEBUG com.consol.citrus.TestCase - 0150reqpath = "C:\Users\BAEIV5T\git\TSSVCitrus\TSSVCitrus\src\test\resources\ATLAS_HHHKACS_SchM_0150_Req.xml"
09:47:36.458 [main] DEBUG com.consol.citrus.TestCase - citrus.test.name = rfss0150dbp
09:47:36.466 [main] DEBUG com.consol.citrus.util.FileUtils - Reading file resource: '${0150reqpath}' (encoding is 'windows-1252')
com.consol.citrus.exceptions.CitrusRuntimeException: Failed to read payload resource
09:47:36.469 [main] DEBUG com.consol.citrus.util.FileUtils - Reading file resource: '${0150reqpath}' (encoding is 'windows-1252')
	at com.consol.citrus.dsl.builder.SendMessageBuilder.payload(SendMessageBuilder.java:197)
	at com.consol.citrus.dsl.builder.SendMessageBuilder.payload(SendMessageBuilder.java:184)
	at tssv.pipeline.citrus.RFSStest0150prop.lambda$0(RFSStest0150prop.java:27)
	at com.consol.citrus.dsl.runner.DefaultTestRunner.send(DefaultTestRunner.java:316)
	at com.consol.citrus.dsl.testng.TestNGCitrusTestRunner.send(TestNGCitrusTestRunner.java:214)
	at tssv.pipeline.citrus.RFSStest0150prop.rfss0150dbp(RFSStest0150prop.java:26)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:223)
	at com.consol.citrus.dsl.testng.TestNGCitrusTest.invokeTestMethod(TestNGCitrusTest.java:128)
	at com.consol.citrus.dsl.testng.TestNGCitrusTest.run(TestNGCitrusTest.java:110)
	at com.consol.citrus.dsl.testng.TestNGCitrusTest.run(TestNGCitrusTest.java:56)
	at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:242)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:576)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
	at org.testng.TestRunner.privateRun(TestRunner.java:648)
	at org.testng.TestRunner.run(TestRunner.java:505)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
	at org.testng.SuiteRunner.run(SuiteRunner.java:364)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
	at org.testng.TestNG.runSuites(TestNG.java:1049)
	at org.testng.TestNG.run(TestNG.java:1017)
	at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
	at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
	at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.io.FileNotFoundException: ${0150reqpath}
	at org.springframework.core.io.FileSystemResource.getInputStream(FileSystemResource.java:129)
	at com.consol.citrus.util.FileUtils.readToString(FileUtils.java:115)
	at com.consol.citrus.dsl.builder.SendMessageBuilder.payload(SendMessageBuilder.java:195)
	... 34 more

09:47:36.491 [main] DEBUG com.consol.citrus.report.LoggingReporter - TEST ACTION CONTAINER with 2 embedded actions
09:47:36.492 [main] DEBUG com.consol.citrus.util.BooleanExpressionParser - Boolean expression 1 = 5 evaluates to false
09:47:36.492 [main] DEBUG com.consol.citrus.context.TestContext - Setting variable: i with value: '1'
09:47:36.492 [main] INFO com.consol.citrus.container.RepeatOnErrorUntilTrue - Caught exception of type com.consol.citrus.exceptions.CitrusRuntimeException 'Missing keyword SELECT in statement: ${stage8sql}' - performing retry #1
09:47:36.492 [main] INFO com.consol.citrus.container.RepeatOnErrorUntilTrue - Sleeping 1000 milliseconds
09:47:37.492 [main] INFO com.consol.citrus.container.RepeatOnErrorUntilTrue - Returning after 1000 milliseconds
09:47:37.492 [main] DEBUG com.consol.citrus.util.BooleanExpressionParser - Boolean expression 2 = 5 evaluates to false
09:47:37.492 [main] DEBUG com.consol.citrus.context.TestContext - Setting variable: i with value: '2'
09:47:37.492 [main] INFO com.consol.citrus.container.RepeatOnErrorUntilTrue - Caught exception of type com.consol.citrus.exceptions.CitrusRuntimeException 'Missing keyword SELECT in statement: ${stage8sql}' - performing retry #2
09:47:37.492 [main] INFO com.consol.citrus.container.RepeatOnErrorUntilTrue - Sleeping 1000 milliseconds
09:47:38.493 [main] INFO com.consol.citrus.container.RepeatOnErrorUntilTrue - Returning after 1000 milliseconds

09:47:40.495 [main] DEBUG com.consol.citrus.util.BooleanExpressionParser - Boolean expression 5 = 5 evaluates to true
09:47:40.495 [main] INFO com.consol.citrus.container.RepeatOnErrorUntilTrue - All retries failed - raising exception com.consol.citrus.exceptions.CitrusRuntimeException
09:47:40.502 [main] INFO com.consol.citrus.report.LoggingReporter - 
09:47:40.511 [main] ERROR com.consol.citrus.report.LoggingReporter - TEST FAILED rfss0150dbp <tssv.pipeline.citrus> Nested exception is: 
com.consol.citrus.exceptions.TestCaseFailedException: Missing keyword SELECT in statement: ${stage8sql}
	at com.consol.citrus.TestCase.executeAction(TestCase.java:227)
	at com.consol.citrus.dsl.runner.DefaultTestRunner.run(DefaultTestRunner.java:188)
	at com.consol.citrus.dsl.builder.AbstractTestContainerBuilder.actions(AbstractTestContainerBuilder.java:94)
	at tssv.pipeline.citrus.RFSStest0150prop.rfss0150dbp(RFSStest0150prop.java:38)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:223)
	at com.consol.citrus.dsl.testng.TestNGCitrusTest.invokeTestMethod(TestNGCitrusTest.java:128)
	at com.consol.citrus.dsl.testng.TestNGCitrusTest.run(TestNGCitrusTest.java:110)
	at com.consol.citrus.dsl.testng.TestNGCitrusTest.run(TestNGCitrusTest.java:56)
	at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:242)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:576)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
	at org.testng.TestRunner.privateRun(TestRunner.java:648)
	at org.testng.TestRunner.run(TestRunner.java:505)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
	at org.testng.SuiteRunner.run(SuiteRunner.java:364)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
	at org.testng.TestNG.runSuites(TestNG.java:1049)
	at org.testng.TestNG.run(TestNG.java:1017)
	at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
	at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
	at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: com.consol.citrus.exceptions.CitrusRuntimeException: Missing keyword SELECT in statement: ${stage8sql}
	at com.consol.citrus.actions.ExecuteSQLQueryAction.validateSqlStatement(ExecuteSQLQueryAction.java:293)
	at com.consol.citrus.actions.ExecuteSQLQueryAction.executeStatements(ExecuteSQLQueryAction.java:120)
	at com.consol.citrus.actions.ExecuteSQLQueryAction.doExecute(ExecuteSQLQueryAction.java:98)
	at com.consol.citrus.actions.AbstractDatabaseConnectingTestAction.execute(AbstractDatabaseConnectingTestAction.java:69)
	at com.consol.citrus.container.AbstractIteratingActionContainer.executeActions(AbstractIteratingActionContainer.java:68)
	at com.consol.citrus.container.RepeatOnErrorUntilTrue.executeIteration(RepeatOnErrorUntilTrue.java:61)
	at com.consol.citrus.container.AbstractIteratingActionContainer.doExecute(AbstractIteratingActionContainer.java:50)
	at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
	at com.consol.citrus.container.Sequence.doExecute(Sequence.java:47)
	at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
	at com.consol.citrus.TestCase.executeAction(TestCase.java:220)
	... 32 common frames omitted
@svettwer
Copy link
Contributor

svettwer commented Apr 28, 2019

Hi!

Thx for the report. 👍
Substituting complete select statements is currently not possible. The processing of SQL select statements performs a validation before variable substitution. The validation consists of a check, whether the SQL statements starts with the select keyword, which causes the error message.

So a workaround should be:

query(action -> action.dataSource(dataSource)
  .statement("SELECT ${stage8sql}")
  .validate("INBUND_OTBUND_CD", "F"))
)

with

stage8sql="* from MSG_MNTR_TRNSACTN_DATA_SGMT, MSG_MNTR_TRNSACTN_HDR where MSG_MNTR_TRNSACTN_DATA_SGMT.NTRNL_TRNSACTN_ID_NBR=MSG_MNTR_TRNSACTN_HDR.NTRNL_TRNSACTN_ID_NBR and CNFRMTN_NBR='TC00420190424R01' and MSG_PRCSG_STG_CD='08'"

I've changed the behavior in a dedicated bugfix branch real quick, but it would be necessary to add some additional test cases etc. Nevertheless, I am confident this change will make it into the next release so that you are able to put the complete select statement into a properties file.

Concerning the file system resource:
FileSystemResource is not owned by Citrus.
Citrus is not able to substitute variables you pass directly to a component Citrus does not own. You would have to resolve the variable with the TestContext before passing it to the FileSystemResource using Test context injection.

I hope that helps you out.

BR,
Sven

@svettwer
Copy link
Contributor

svettwer commented Apr 28, 2019

A little addition to the FileSystemResource issue:

You could use the Citrus FileUtils.getFileResource(String filePath, TestContext context) function to save some boilerplate code.
So you would pass the injected context to the mentioned FileUtils function and the filePath would be your variable.

properties:

payload=file:/path/to/payload.txt

Java code

http()
    .client(todoClient)
    .send()
    .post("/todolist")
    .payload(FileUtils.getFileResource("${payload}", testContext));

I'd also recommend to use classpath references instead of absolute file paths.

BR,
Sven

@svettwer svettwer added Prio: Low READY Type: Bug Type: Question good first issue A good point to start from for new contributrs labels Apr 28, 2019
@johnshirey
Copy link
Author

Thanks for the help

@johnshirey
Copy link
Author

I'm using JMS and MQ but I can adapt your http example above to replace my current .payload() statement.

@svettwer
Copy link
Contributor

svettwer commented May 6, 2019

Hi!

Please have a look at our JMS-Sample.

BR,
Sven

@svettwer
Copy link
Contributor

I assume the questions have been answered so there is just the bug left to be fixed.

BR,
Sven

@johnshirey
Copy link
Author

johnshirey commented May 24, 2019 via email

@johnshirey
Copy link
Author

johnshirey commented May 29, 2019 via email

@johnshirey
Copy link
Author

johnshirey commented May 29, 2019 via email

@svettwer
Copy link
Contributor

svettwer commented Jun 5, 2019

Hi!

It might be the case that you just hit a short downtime of GitHub. This affects the citrus repository as well as the website, because the website ist hosted on GitHub as well.

Concerning your question. As you already mentioned, this is not a Citrus issue but an issue of on of our dependencies, namely org.apache.xerxes.parsers.DOMParserImpl.parse. So please ask the xerxes parser team for help on this one.

BR,
Sven

@johnshirey
Copy link
Author

johnshirey commented Jun 5, 2019 via email

@svettwer
Copy link
Contributor

svettwer commented Jun 6, 2019

Awesome! Thanks for sharing the solution. 👍

@christophd christophd removed the READY label Oct 6, 2021
@akuz0
Copy link
Contributor

akuz0 commented Jul 21, 2022

@bbortt need check this issue. I`m think it solved problem, true?

@bbortt
Copy link
Collaborator

bbortt commented Jul 21, 2022

@akuz0 sounds like it, thanks for the hint.

@bbortt bbortt closed this as completed Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue A good point to start from for new contributrs Prio: Low Type: Bug
Projects
None yet
Development

No branches or pull requests

5 participants