Tech-Today
How to set Authorization header in all SoapUI test cases via Script
To set the Authorization header in each test case of a testSuite, we run the script below.
import com.eviware.soapui.impl.wsdl.teststeps.*
import com.eviware.soapui.support.types.*;
StringToStringMap headers = new StringToStringMap();
StringToStringMap headersForSuper = new StringToStringMap();
String userPass = testCase.testSuite.project.getPropertyValue("username")+":"+testCase.testSuite.project.getPropertyValue("password");
log.info("userPass=" + userPass);
headers.put("Authorization","Basic "+userPass.getBytes().encodeBase64());
for(testSuiteItem in testCase.testSuite.project.getTestSuiteList()){
for( testCaseItem in testSuiteItem.getTestCaseList() ) {
log.info("Setting basic auth for all WSDL test requests in test case ["+testCaseItem.getName()+"]")
for( testStep in testCaseItem.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep) ) {
testStep.getTestRequest().setPreemptive(true);
testStep.getTestRequest().setRequestHeaders(headers);
}
}
}
-
How To Call A Javaee Rest Web Service With Basic Authentication Using Jquery Ajax
I don't really remember when I coded it, nor where I got it but I'm writing it here for future use :-) Below is the code I use to test CORS, http://en.wikipedia.org/wiki/Cross-origin_resource_sharing. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>...
-
How To Call Java Rest Web Service In Soapui
The following code is an explanation of how you can call a rest web service in java. Below you can find the actual java code and soapUI configuration. We enumerate 3 type of methods namely: POST, PUT and DELETE. How to call rest web service using soapUI...
-
Jax-rs 2.0 Security Tutorial In Javaee And Jboss
This tutorial will summarize how the author was able to call a secured rest webservice using resteasy. We will not go into detail on how we build the entire project since the code is already pushed at github. Basically we will just note down the most...
-
Creating And Testing A Web Service Using Soap Ui
I just want to share a simple example on how to create and test a web service on java. Download and install the following: 1.) eclipse java (client) 2.) eclipse jee (web service) 3.) jboss 5.1 AS 4.) soap ui, get the stand alone (http://www.soapui.org/)...
-
Junit 4.7 Expected Exception Failed
I recently downloaded the new version of JUnit which is 4.7 and linked it to my project. Then all the test cases that should be ok if an exception is encountered failed. My immediate solution was to remove the extends TestCase to each test classes. With...
Tech-Today