I have a bunch of SOAP request messages in XML format. Is there a way to import them to a SoapUI project?
I want to import them and add as "Test Request" Test Step to an existing Test Case.
An easy and more automatic way to do so is using a groovy script to automatically create the testStep request from a directory where you have you xml request files:
Create a TestCase manually.
Add an empty TestStep request which we will use as a template to create the other requests.
Add a groovy testStep which imports all files using the code below, and execute it in order to create the testSteps.
Your SOAPUI before groovy code execution looks like:
And the necessary groovy code:
import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory
import groovy.io.FileType
// get the current testCase to add testSteps later
def tc = testRunner.testCase
// get the testStep as template to create the other requests
def tsTemplate = tc.getTestStepByName("TestRequest template")
// create the factory to create testSteps
def testStepFactory = new WsdlTestRequestStepFactory()
def requestDir = new File("/your_xml_request_directory/")
// for each xml file in the directory
requestDir.eachFileRecurse (FileType.FILES) { file ->
def newTestStepName = file.getName()
// create the config
def testStepConfig = testStepFactory.createConfig( tsTemplate.getOperation(), newTestStepName )
// add the new testStep to current testCase
def newTestStep = tc.insertTestStep( testStepConfig, -1 )
// set the request which just create with the file content
newTestStep.getTestRequest().setRequestContent(file.getText())
}
Hope this helps,
Copy/paste each into a new request, then right click on each request and add them to your test case.
Or select "Load from..." when opening the context menu in the request view.
Another option is:
Create a soapui project with one request
Open the soapui-project XML file
Search for con:call part
Duplicate it and replace the con:request with your own XML request
Save and reload the project in soapui
Related
For Example:
REST Request
I want to read these REST matrix request using Java or groovy.
What could be the possible solution?
You need to check where they are the properties.
You review the attachment.
Show properties
You follow this steps:
Create a testSuite with the testcase.
Add the activity Groovy script and you add this code.
//Print all properties
log.info testRunner.testCase.getTestStepByName('NAME_TESTSTEP').getPropertyList().name;
log.info testRunner.testCase.getTestStepByName('NAME_TESTSTEP').getPropertyList().value;
//Get value propertie
def value_property = testRunner.testCase.getTestStepByName('NAME_TESTSTEP').getPropertyValue('NAME_PROPERTY');
//Print Get value propertie
log.info value_property
//Set value Property
testRunner.testCase.getTestStepByName('NAME_TESTSTEP').setPropertyValue('NAME_PROPERTY','VALUE');
You need to update the values (NAME_TESTSTEP ,NAME_PROPERTY ,VALUE)
Run the grrovy script.
I am sending a request using SOAPUI and need to add a tab/space at the end of the text/XML message so it is accepted by the server and I get the proper response. I need a Groovy script that will simply add a tab to the end of the text/XML request. Thanks
The way to go as it's said in the comments is to fix your WS to work correctly without the extra tab/space at the end of your request.
Another simple option if you can't fix de WS because it's a third party service, it's simply to add manually a tab in the testStep as part of your request.
Anywise since some times is necessary or util to modify the request for some other reason I will show you an example of how to get the SOAP Request with a Groovy script to manipulate it. You can do it adding a Groovy testStep with the following code:
// get the testStep by name
def testStep = testRunner.testCase.getTestStepByName('Your request name')
// get request content
def originalRequestContent = testStep.getPropertyValue('request')
// perform your modifications...
// in your case simply add a new tab
def newRequestContent = "${originalRequestContent}\t"
// as tab is not showed in the Raw tab of your testStep,
// to show that this code work as expected I add
// and unnecessary extra text
newRequestContent += 'it works'
// set the new modified request
testStep.setPropertyValue('request',newRequestContent)
// and finally you can send the request
testStep.run(testRunner,context)
// if you want to keep the step as orignal uncomment
// the follow line
// testStep.setPropertyValue('request',originalRequestContent)
Hope it helps,
I am trying to get the test instance names from the test set. I am able to get the test id by using the following URL:
"rest/domains/"+domain+"/projects/"+project+"/test-instances?query={cycle-id["+testSetId+"]}" ;
Is there any way I can get the test names also?
I guess you're talking about the ALM Rest API.
If you do, you can try to add in final of your URL the following:
&fields=test-config.name
Then your URL will look like this:
rest/domains/{domain}/projects/{project}/test-instances?query={cycle-id[{testSetId}]}&fields=test-config.name
The name of your Test Instance will be shown into the RelatedEntities tag from your XML.
For more information about ALM REST API you can click here.
I need to return pdf files with the header
X-Robots-Tag: noindex
https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag?hl=de#robots-meta-tag-verwenden
Is there a way to do this using the standard play Assets Controller? Took a look inside the source code and the only thing that seems to be configurable is:
val configuredCacheControl = config(_.getString("\"assets.cache." + name + "\""))
Thanks
I might go with Kris's idea. Something kinda like this should get you part of the way there, basically all I'm doing is leveraging the Play! Controller that serves static resources but adding a header to the result:
object AssetsController extends Controller {
def modifiedAsset(path: String, file: String): Future[Result] = Async.action { implicit request =>
Assets.at(path, file)(request).map { result =>
result.withHeaders(("X-Robots-Tag", "noindex"))
}
}
Then your routes file would need to be modified from controllers.Assets.at(path="/public", file) to controllers.AssetsController.modifiedAsset(path="/public", file)
Looking through Oozie examples and documentation, it looks like you need a workflow file in order to run an oozie job from Java code. Is ther any way to submit a job directly fro Java code, without needing a workflow file? Is there any pre-existing way to dynamically generate these files through java code? Are there any pre-existing tools that will make generating them easier? Or will I have to write the entirety of the code to generate the file?
Current Situation
OozieClient wc = new OozieClient("http://bar:8080/oozie");
Properties conf = wc.createConfiguration();
conf.setProperty(OozieClient.APP_PATH, "workflow file path");
// set other properties
...
// submit and start the workflow job
wc.run(conf);
Ideal situation is something vaguely like this.
OozieAction action = new OozieAction("actionName");
action.setOkDestination("nextAction");
action.setErrorDestination("errorDestination");
//Rest of config for action
OozieWorkflow workflow = new Oozieworkflow();
workfow.setStartAction(action);
workflow.addAction(otherAction);
//rest of conf
OozieClient wc = new OozieClient("http://bar:8080/oozie");
wc.runWorkflow(workflow);
Another situation that would be desirable if the former is impossibble is:
OozieAction action = new OozieAction("actionName");
action.setOkDestination("nextAction");
action.setErrorDestination("errorDestination");
//Rest of config for action
OozieWorkflow workflow = new Oozieworkflow();
workfow.setStartAction(action);
workflow.addAction(otherAction);
//rest of conf
workflow.writeToFile("some localFile")
//load file to HDFS
//This would also work
// workflow.writeToHDFS("someHdfsLocation");
OozieClient wc = new OozieClient("http://bar:8080/oozie");
//run with created workflow
I have been in a similar situation.
What I would suggest is to use the oozie schema definition (xsd) and generating the java equivalent objects through xjc. Given these objects you can probably create the workflow (not trivial though)
There are scala based DSL's you can use
https://github.com/klout/scoozie does something similar with Scala->oozie generation
Oozie 5.1.0 added support for Fluent Job API which makes it possible to write java code instead of workflow XML files (under the hood, Oozie will generate the XML file for you).
Simple example for the java code which creates a workflow similar to the shell action demo of Oozie:
public class MyFirstWorkflowFactory implements WorkflowFactory {
#Override
public Workflow create() {
final ShellAction shellAction = ShellActionBuilder.create()
.withName("shell-action")
.withResourceManager("${resourceManager}")
.withNameNode("${nameNode}")
.withConfigProperty("mapred.job.queue.name", "${queueName}")
.withExecutable("echo")
.withArgument("my_output=Hello Oozie")
.withCaptureOutput(true)
.build();
final Workflow shellWorkflow = new WorkflowBuilder()
.withName("shell-workflow")
.withDagContainingNode(shellAction).build();
return shellWorkflow;
}
}
More detailed documentation can be found here: https://oozie.apache.org/docs/5.1.0/DG_FluentJobAPI.html
There's a graphical tool to generate Oozi workflows via an eclipse plugin. Find it here Eclipse marketplace: https://marketplace.eclipse.org/content/oozie-eclipse-plugin
It looks like this:
have a static oozie workflow in your HDFS which just takes 2 parameters and writes the content of parameter1(say content which user enters) to parameter2(say writing to HDFS). Now call the oozie CLI and specify app.path as the location created by workflow1