Contributions
Problem in iterating inside WsdlInterface Table
Hi, I have linked my Readi Api jar file whithin my Eclipse IDE. Then, I'm able to write code use any native features from my ReadyApi which has been already implemented. Today, I'm struggle with the importWsdl Method which come fromWsdlImporter class. The issue appears just after adding several wsdl to my project. Apparently, each time a wdsl is added to my project, index 0 of WsdlInterface table issystematically replaced by last wsdl. Therefore, I am able to add several interfaces inside project but I am not able to use it to do some stuff with. The only wsdl where we can iterate is placed at index 0, so in consequences, it is obvious that we could only use API features on last imported wsdl. For instance, if I try to iterate onan integer greater than 0, I will catch anArrayIndexOutOfBoundsException. Well, I definitely don't understand what I did wrong in my code, and why I can not use other value of WsdlInterface table except 0. Here I share my code for a better understanding : package soapUiTreatments; import com.eviware.soapui.SoapUI; import com.eviware.soapui.StandaloneSoapUICore; import com.eviware.soapui.impl.wsdl.WsdlInterface; import com.eviware.soapui.impl.wsdl.WsdlOperation; import com.eviware.soapui.impl.wsdl.WsdlProject; import com.eviware.soapui.impl.wsdl.WsdlRequest; import com.eviware.soapui.impl.wsdl.WsdlTestSuite; import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlImporter; import com.eviware.soapui.model.iface.Operation; import com.eviware.soapui.model.testsuite.TestSuite; import java.util.*; import java.io.File; public class CreateSoapUiProject { public static void main(String[] args) { try { String virtuLabel = "fr-virtu-label"; String projectVersion = "v1"; String projectLabel = "-soapui-project"; String extension = ".xml"; int countOperationsInInterface = 0; int countTestSuiteInProject = 0; File projectFile =new File(virtuLabel + projectLabel + extension + projectVersion); SoapUI.setSoapUICore(new StandaloneSoapUICore(true)); WsdlProject project = new WsdlProject(virtuLabel); //define project label /*-----------------Define WSDL Urls-------------------------*/ ArrayList<String> allWsdlUrls = new ArrayList<String>(); String IWsConsultationCISSOAP11Binding = "http://eip-mediator-wsint-tstenv-sedc.applications.services.axa-tech.intraxa/ws/fr-cis-infocontrat-v1-vs?wsdl"; String EndpointRecupererSDM = "http://eip-med-tst-sesd.applications.services.axa-tech.intraxa/ws/fr-fca-sdm-cst-v2-vs?wsdl"; String IdentityCstServiceEndpoint = "http://eip-mediator-wsint-tstenv-sedc.applications.services.axa-tech.intraxa/ws/fr-acon-cst-enduseridentity-v1-vs?wsdl"; String BasicHttpBinding_IRoutageService = "http://eip-med-tst-sesd.applications.services.axa-tech.intraxa/ws/fr-bow-mng-soclederoutage-v1-vs?wsdl"; /*-----------------Import WSDL Interfaces in Project-------------------------*/ WsdlInterface[] wsdls; wsdls = WsdlImporter.importWsdl(project, IWsConsultationCISSOAP11Binding); wsdls = WsdlImporter.importWsdl(project, IdentityCstServiceEndpoint); wsdls = WsdlImporter.importWsdl(project, EndpointRecupererSDM); wsdls = WsdlImporter.importWsdl(project, BasicHttpBinding_IRoutageService); System.out.println("----------INTERFACE COUNT------------------"+project.getInterfaceCount()); System.out.println("---------------------------------------WSDL COUNT--------------------" + wsdls.length); //To get the number of wsdl interfaces always return 1, why? for (int wsdlCount = 0; wsdlCount < project.getInterfaceCount(); wsdlCount++){ WsdlInterface wsdl = wsdls[wsdlCount]; //HERE IS MY CAUGHT EXCEPTION ArrayIndexOutOfBoundsException String soapVersion = wsdl.getSoapVersion().toString(); List<WsdlOperation> operations = wsdl.getAllOperations(); while (operations.size() > countOperationsInInterface){ wsdl.getProject().addNewTestSuite(operations.get(countOperationsInInterface) .getName()+"TestSuite"); countOperationsInInterface++; } List<WsdlTestSuite> testSuiteList = wsdl.getProject().getTestSuiteList(); while (testSuiteList.size() > countTestSuiteInProject){ wsdl.getProject().getTestSuiteAt(countTestSuiteInProject) .addNewTestCase(operations.get(countTestSuiteInProject) .getName()+"-TestCase-"+"1"); countTestSuiteInProject++; } int countBindingOperations = wsdl.getOperationCount(); String reqContent=""; String result=""; for(int index = 0; index < countBindingOperations; index++){ WsdlOperation operationAtIndex = wsdl.getOperationAt(index); String operationName = operationAtIndex.getName(); reqContent = operationAtIndex.createRequest(true); WsdlRequest req = operationAtIndex.addNewRequest("Req_" + soapVersion + "_" + operationName); req.setRequestContent(reqContent); } } project.saveIn(projectFile); } catch (Exception e) { e.printStackTrace(); } } } My aim is to create a single testsuiteand a testcase for each binding operation found after loading an interface. As all operations name, contained in all interfaces, are different, there should not occur any problem with this automatic process. Regarding my issue, this automatic process is done only one time for the last imported wsdl whereas what I want is doing these for all imported wsdls. I know it's a bit complicated and I am not so clear explaing the issue, but if you have any understanding problems, I could may be express that in a better way. Thanks for your help Harold7 years agoPlace ReadyAPI QuestionsReadyAPI Questions619Views0likes0Comments- 7 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.6KViews0likes0Comments
Iterate throw global properties entries from Groovy script
Hello all, I have filled some global properties with associated values inside global Propeties section in preferences panel of Ready Api! (Cf attachment) Now, I would like to know how could I define a list container to iterate through all elements. I would be able to retrieve keys and values from the global properties list in order to do some stuff with each element. Any idea of how to do this?Solved7 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.6KViews0likes2CommentsRe: Populate string inside Excel Data Sink fields from groovy script
Hellogroovyguy, That'it, thaks you. Here, I share my script aaccording to my need : def dataSink = context.testCase.testSteps["ExcelDataSink"]; def excel = dataSink.getDataSink(); def environmentName = testRunner.testCase.testSuite.project.activeEnvironment.name; if (environmentName == "Integration"){ excel.setFileName("E:\\SoapUi_Workspaces\\ProjectsToDeliver\\fr-cevia-v2-vs\\TestCaseResult\\fr-cevia-v2-vs_GenericTable.xls"); excel.setOutFileName("E:\\SoapUi_Workspaces\\ProjectsToDeliver\\fr-cevia-v2-vs\\TestCaseResult\\INT\\CheckSdcAuthorisationTestSuite\\CheckSdcAuthorisationTestCaseResult[INT].xls"); excel.setWorksheet("CEVIA_V2"); excel.setEvaluateFormulas(false); dataSink.setPropertyValue("CheckSdcAuthorisationTestCaseResult", '${#TestCase#Status}'); excel.setStartCell("K2"); } else if (environmentName == "Recette"){ excel.setFileName("E:\\SoapUi_Workspaces\\ProjectsToDeliver\\fr-cevia-v2-vs\\TestCaseResult\\fr-cevia-v2-vs_GenericTable.xls"); excel.setOutFileName("E:\\SoapUi_Workspaces\\ProjectsToDeliver\\fr-cevia-v2-vs\\TestCaseResult\\REC\\CheckSdcAuthorisationTestSuite\\CheckSdcAuthorisationTestCaseResult[REC].xls"); excel.setWorksheet("CEVIA_V2"); excel.setEvaluateFormulas(false); dataSink.setPropertyValue("CheckSdcAuthorisationTestCaseResult", '${#TestCase#Status}'); excel.setStartCell("K2"); } else if (environmentName == "PreProd"){ excel.setFileName("E:\\SoapUi_Workspaces\\ProjectsToDeliver\\fr-cevia-v2-vs\\TestCaseResult\\fr-cevia-v2-vs_GenericTable.xls"); excel.setOutFileName("E:\\SoapUi_Workspaces\\ProjectsToDeliver\\fr-cevia-v2-vs\\TestCaseResult\\PP\\CheckSdcAuthorisationTestSuite\\CheckSdcAuthorisationTestCaseResult[PP].xls"); excel.setWorksheet("CEVIA_V2"); excel.setEvaluateFormulas(false); dataSink.setPropertyValue("CheckSdcAuthorisationTestCaseResult", '${#TestCase#Status}'); excel.setStartCell("K2"); } else if (environmentName == "Prod"){ excel.setFileName("E:\\SoapUi_Workspaces\\ProjectsToDeliver\\fr-cevia-v2-vs\\TestCaseResult\\fr-cevia-v2-vs_GenericTable.xls"); excel.setOutFileName("E:\\SoapUi_Workspaces\\ProjectsToDeliver\\fr-cevia-v2-vs\\TestCaseResult\\PROD\\CheckSdcAuthorisationTestSuite\\CheckSdcAuthorisationTestCaseResult[PROD].xls"); excel.setWorksheet("CEVIA_V2"); excel.setEvaluateFormulas(false); dataSink.setPropertyValue("CheckSdcAuthorisationTestCaseResult", '${#TestCase#Status}'); excel.setStartCell("K2"); } else { log.info("Default Environment"); }7 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.9KViews1like0CommentsPopulate string inside Excel Data Sink fields from groovy script
Hey, Context : Let's say that I have appended a DataSink Teststep manually which I have named "DataSink", feature which is provide naturally in the UI of ReadyAPI. Now, I would like to get this object instance and feed it regarding my environment execution. I have already known how to get the environment settings so the issue is only how /what are the statements to set DataSink parameters from a groovy script Teststep. On SoapUiPro documentation, I have found this : http://www.soapui.org/apidocs/pro/com/eviware/soapui/impl/wsdl/teststeps/datasink/ExcelDataSink.html#setFileName-java.lang.String- First, I would like to be able to use these metods setFileName(path), setOutFileName(path), setWorksheet(worksheet), setStartCell(startCell) in order to provide the parameters to the DataSink instance. I also would like loading properties from my first row of the ExcelFile and keep only those I want but in the class documentation, I do not see any metod to add properties to the DataSink. Does anyone have an idea of how to achieve both purposes? Regards, HaroldSolved7 years agoPlace ReadyAPI QuestionsReadyAPI Questions2KViews0likes2CommentsRe: Get Autocompletion for imported libraries inside groovy scripts teststep
Hello Steven, Thanks for your reply and for accepting this new feature. Please, let me know when this will be available in a new version of the tool. Regards, Harold7 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.5KViews0likes0CommentsGet Autocompletion for imported libraries inside groovy scripts teststep
Hello@all, Inside my groovy scripts, I always deal with external jar libraries, for instance, java.util, jxl, odbc...etc As I am not familiar with these libraries, the only way I have found to know which class should I use to suit my needis to load the concerned library inside a java project from my Eclipse IDE. In Eclipse, I have installed a java decompiler, thanks to this plugin, I am able to access code within the loaded libraries. The native Autocompletion plugin in my IDE works well. Thus, when I explore files hierarchy, I am able to use what ever I wantamong class or methods that I want to use. I would like to find a way to do this inside my groovy scripts teststeps. So, when I import jar libraries inside groovy scripts, Ready Api does not provide any autocompletion plugin to look inside native implementations. Is there a way to get an autocompletion tool on imported jar libraries, which would permit me to access code libraries, to see which metods and which class could be available for use. Best Regards Harold7 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.5KViews0likes2CommentsRe: Change teststep request status from groovy script
Thanks for the reply, The thing is, as I have a loop in my testcase, if the script failed at least once, the execution of the testcase will stop. That's why I was looking for a way to directly set an assertion to Failed and to pursue remaining executions even if one had failed before. So,do you get an idea of how could I change the statut of any assertion which is set in the teststep request? Regards, H.R7 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.5KViews0likes0CommentsChange teststep request status from groovy script
Hello all the community, I try to change the status and the colour of my teststep request, but the status of the request is not updated. Here is my code : import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus; import java.util.regex.Pattern; import java.util.regex.Matcher; Pattern myRegularExpression = ~'\\w{10}'; //Create regular expression to compare to testcase property String myProperty = testRunner.testCase.getPropertyValue("MyProperty"); // get testcaseproperty myTestStepResult = testRunner.runTestStepByName("CheckSdcAuthorisation[8.2]"); //allow testRunner object to run teststep myStatus = myTestStepResult.status; // def teststep status boolean result = myProperty.matches(myRegularExpression); //assert that string property contain the regular expression if(result == true) { statusOK = myStatus.OK; //change test step status to OK } else { statusFAILED = myStatus.FAILED; //change test step status to failed } log.info(result) But when the execution flow cross the if statement, the status is not updated. Anyone get an idea of how to do the trick?7 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.6KViews0likes2CommentsRe: Create Add Auth Manager Profiles, set credentials, populate inherit method from Groovy Script
Hi Nastya, Your message is really helpful, thanks you!!! Also , I was wondering : Regarding the code you provided in the first frame, if I am about to use the method to set the authentication at the project level, will all childs descending nodes inherit from the authentication profile. In other words, will the inherit from parent method be spread to all containing nodes whithout using the code of the second frame? Is it the same behaviour if we decide to set the authentication at testsuite level? Regards, Harold7 years agoPlace ReadyAPI QuestionsReadyAPI Questions5.7KViews0likes1Comment