How to use Global Property name in my JSON input request using SoapUI? - properties

I have a SoapUI project which contains around 60 plus services. Each service requires some input which will be changed for every execution. So I have created certain Global Properties and assign some values to that properties.
I have to use these properties values in my SoapUI request ( i.e. JSON Format request ).
If it is groovy script means, I will use like this.
String HTiC_Username = com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils.globalProperties['HTiC_Username'].value;
But, how to get the value of the Global Property in the request?
Hope you understand my question. Please provide proper guidance.
Thanks

To dynamically "expand" (i.e. substitute) the value of a property into a test step, the following syntax is used: ${#scope#propertyName}
...where 'scope' refers to the level at which the property has been defined (e.g. Global, Project, TestSuite, TestCase).
So to expand a property named username defined as a Global property, for example, the following code can be used directly within a Request Test Step (e.g within a JSON body, or header value, etc):
${#Global#username}
To access the same property value within a Groovy Test Step, you can use the following syntax:
context.expand('${#scope#propertyName}')
...as in the following example:
context.expand('${#Global#username}')

What we did was the following:
created a test data file to store all the specific input data for the different services (testdata.properties)
Example content of testdata.properties:
Billing_customerID=1234567
OtherService_paymentid=12121212
....
create a SoupUi global parameter (File/Preferences/Global properties): testdata_filepath=C:\...
For specific services we added a Properties test step. You can specify the "Load from" field to our new global parameter: ${#Global#testdata_filepath} Now you can use the Load button to load parameters.
Finally you can reference the parameter in your xml in the following format: ${Properties#Billing_customerID}
Example content of a service with parameter:
...
<BillingCustomerIdentification>
<BillingCustomerID>${#Properties#Billing_customerID}</BillingCustomerID>
</BillingCustomerIdentification>
...
To set up your projects in this manner also helps to automate service tests eg. using Hudson (see my previous SO answer).
If it is too heavy and automation is not a target, you can simply use ${#Global#someinputvariable} format in your xml ;-)

Related

Is there any API in JUnit 5 to test for included or excluded Tags?

I'd like to enable a test if a certain tag is "included", i.e. passed with option --include-tag of the ConsoleLauncher or useJUnitPlatform.includeTags property in Gradle. Is there any API to retrieve the value of this option in the context of test class or method?
I tried the script-based condition #EnabledIf like this:
#EnabledIf("'true' == systemProperty.get('itest.backendSystemPresent') || junitTags.contains('BackendSystemIT') == true")
But junitTags contains the #Tag annotations of the element in question, not the tags included at runtime.
Reading your question again, my answer is "No". You can't use junitTags to achieve your goals. And no, there's no such API at the moment. You would need something like:
#EnabledIf("'true' == evaluateTagExpression('BackendSystemIT') || ...)
Because you need to take care of tag expression here as well: https://junit.org/junit5/docs/current/user-guide/#running-tests-tag-expressions
But, tags are evaluated earlier in the process. Your condition will not get a chance to be executed when the test was already excluded by tag evaluation. So, I guess, you'll have to stick with the single system property switch to control the enabled state of the test method.
Btw. we are improving the tag expression language with any() and none() tokens, soon. https://github.com/junit-team/junit5/issues/1679
Possible solution:
Annotate your test with #Tag("BackendSystemIT")
Before running your tests, check for itest.backendSystemPresent system property and if it is set, pass a --include-tag "BackendSystemIT" to the test run.
Let Jupiter do the job of evaluating tag expressions
Is there any API to retrieve the value (of this option) of all tags that are attached directly or inherited in the context of test class or method?
Yes. Declare and use a org.junit.jupiter.api.TestInfo parameter in your test method.
#Test
#DisplayName("TEST 1")
#Tag("my-tag")
void test1(TestInfo testInfo) {
assertEquals("TEST 1", testInfo.getDisplayName());
assertTrue(testInfo.getTags().contains("my-tag"));
}
For details see https://junit.org/junit5/docs/current/user-guide/#writing-tests-dependency-injection
But junitTags contains the #Tag annotations of the element in question, not the tags included at runtime.
This is the expected behaviour -- the platform (here: console launcher) already applied the filter passed via --include-tag and other configuration parameters. In short: there's no need to manually check for tags in standard Jupiter tests. If there's problem with the built-in filtering, please create an issue here: https://github.com/junit-team/junit5/issues/new/choose

How to pass custom arguments along with standard arguments in a Documentum job method

I configured a job correctly by passing the custom arguments successfully.
Now I want to use the custom as well as standard arguments. But the issue is either standard arguments(job id, user name, docbase name and trace level) are getting passed or the custom arguments only. I am unable to get both types of arguments together.
Could anyone suggest any ways to get that done?
Send standard arguments as custom arguments, i.e. just add it with your custom arguments. Did this before and it work.
In the job properties editor in Documentum Composer select the "Standard Arguments" radio button!
Even if you are using custom attributes, the "Standard Arguments" radio button has to be selected.
I tried to do the same using the custom argument using the Job artifcats and then checking the checkbox "pass standard argument" in DA. But still I was unable to get the custom and standard arguments together.
For resolving this, I first retrieved the job ID from the standard arguments and then fetched the custom arguments using the following code:
IDfId idfJobId = new DfId(stringJobId);
IDfSysObject jobObject = (IDfSysObject) session.getObject(idfJobId);
CustArgument1 = jobObject.getRepeatingString(ATTR_METHOD_ARGS, 0);
if there are multiple arguments we can get it using a for loop by incrementing index i
CustArgument1 = jobObject.getRepeatingString(ATTR_METHOD_ARGS, i);

Using template message body on WCF-SQL adapter in Biztalk to insert promoted properties into SQL database

I need to insert some data from an XML document into an SQL table using a stored procedure. This should be done using the WCF-SQL adapter on a send port in Biztalk. I've set up the connection properties on the adapter, but I am missing the message part.
I'm currently using the below code with some hardcoded values inside a body template:
<SaveDocument xmlns="http://schemas.microsoft.com/Sql/2008/05/Procedures/dbo">
<conversationID>123456</conversationID>
<dataType>OIO</dataType>
<fromID></fromID>
<toID></toID>
<msgInfoExtension><![CDATA[<infoExt><fileInfo fileName="ublinvoice.xml" encoding="utf-8" /></infoExt>]]></msgInfoExtension>
<msgBody>
<bts-msg-body xmlns="http://www.microsoft.com/schemas/bts2007" encoding="string"/>
</msgBody>
<msgBodyBin></msgBodyBin>
</SaveDocument>
Instead of the hardcoded values, I need to grab some of the promoted properties in an XML document, but I'm unsure how to correctly go about doing this.
In the MS documentation I found this page, which describes the structure of the request: https://learn.microsoft.com/en-us/biztalk/adapters-and-accelerators/adapter-sql/message-schemas-for-procedures-and-functions
Distinguish the properties that you want to set in the SaveDocument schema
Create a map that populates the fields, the ones you want to set from the Promoted properties, just fill them with some constants from the map.
In an Orchestration have a Construct Message that contains both the map shape pointing to the above map and a message assignment shape.
In the message assignment shape have some statements like saveSG.conversationID = sourceMSG(PropmotedProperty).
P.S. I think you have manually tried to create the SaveDocument schema. This is probably not correct. The correct way is to create the stored procedure and then use the Generate Instance dialogue in Visual Studio, and to configure that to auto generate the schema for you, and as a bonus, it even generates a binding file containing the settings you need for your send port.
You might be able to use the often overlook Property Demotion feature.
It's basically the reverse of Promotion and is done by the XmlAssembler component.

Dynamically generate url for HTTP source

I'm trying to call a http endpoint. For that I need to specify a url that uses a query string to filter data.
Sample URL: http://example.com?date=2017-10-04T22:18.007Z
I need to use the current system time as a value for date query string.
I created a script and assigned the generated url with the current datetime to a variable. However, when I assigned that variable for the url field in the source HTTP definition, it did not resolve the variable.
Is there a way to solve this issue?
I do this all the time. As long as your script is running properly (you can test that with the test feature on the script), you are writing the URL value to a global variable (something like $URL), and you are writing that global variable out in your target (something like [URL]), it should work.
If you want to show your script (just where you are creating the URL), and your target URL field that could help narrow down the problem.

SOAPUI - SOAPRequest - Expand properties to access name property of current TestStep

SoapUI provides a common syntax to dynamically insert properties in SOAP Request. In their documentation they explain how to access different properties depends on property scope:
#Project# - references a Project property
#TestSuite# - references a TestSuite property in the containing TestSuite
#TestCase# - references a TestCase property in the containing TestCase
#MockService# - references a MockService property in the containing MockService
#Global# - references a global property (optional)
#System# - references a system property
#Env# - references a environment variable
[TestStep name]# - references a TestStep property within the current TestCase
My problem is I want to access the name of the current testStep however documentation says that to access TestStep properties you need the name... There is another way to do so? like for example #TestCase#TestStep#Name. I know how to achieve this with groovy script but in my case I want to put the property directly on SOAP Request.
Thanks in advance
Finally I found the solution in the documentation, with '=' prefix it's possible to specify a groovy script and access to some context variables. In this context request variable is available and also its name property, so It's possible access to the current TestStep name with:
${=request.name}
Example below is grabbing the request from your TestCase and assigning a value to a specific element.
// get XMLHolder for request message def
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
// grabbing the specified request
def holder = groovyUtils.getXmlHolder("Specified#Request")
holder["//*:Password"] = 'password1';
For the example above you need to know the Xpath for your element.
Note, that this can be accomplished in several ways, but you specified doing in through groovy script. It can also be done through a #TestCase# property. Example:
<soapenv:Body>
<tns:AuthenticateUser>
<tns:Credentials>
<tns:IntegrationID>${IntegrationID}</tns:IntegrationID>
<tns:Username>${Username}</tns:Username>
<tns:Password>${Password}</tns:Password>
</tns:Credentials>
</tns:AuthenticateUser>