Contributions
Re: Adding assertions to TestRequest dynamically using Groovy
mkliba wrote: Hi: Talking about removing/adding/renaming Assertions, you posted before that to remove assertions we can use: def assertionsList = testRunner.getTestCase().getTestStepByName("Test Request").getAssertionList() for( e in assertionsList){ testRunner.getTestCase().getTestStepByName("Test Request").removeAssertion(e) } Is there any way we can remove the assertion by assertion type and/or assertion name? Ex: Remove all type "XPath Match", or with name "My XPath Match"? Thanks. You could use the instanceof operator. For example, if you want to remove all GroovyScriptAssertions: def assertionsList = ... for (e in assertionsList) { if (e instanceof com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.GroovyScriptAssertion) testRunner.getTestCase().getTestStepByName("Test Request").removeAssertion(e) } Alls types of assertions: CrossSiteScriptAssertion, GroovyScriptAssertion, HttpDownloadAllResourcesAssertion, InvalidHttpStatusCodesAssertion, JdbcStatusAssertion, JdbcTimeoutAssertion, JMSStatusAssertion, JMSTimeoutAssertion, NotSoapFaultAssertion, ResponseSLAAssertion, SchemaComplianceAssertion, SensitiveInfoExposureAssertion, SimpleContainsAssertion, SimpleNotContainsAssertion, SoapFaultAssertion, SoapRequestAssertion, SoapResponseAssertion, ValidHttpStatusCodesAssertion, WSARequestAssertion, WSAResponseAssertion, WsdlMessageAssertion, WSSStatusAssertion, XPathContainsAssertion, XQueryContainsAssertion They all inherit from the TestAssertion interface: http://www.soapui.org/apidocs/com/eviwa ... rtion.html (links to all assertion types can also be found on that webpage) I haven't tried the code I provided, but it should work without any major changes.2.5KViews0likes0CommentsRe: Clone a step with Groovy script
If someone might be interested, here is the complete code of the script. It deletes every JDBC testStep in the current testCase that has not 'eemplate' in its name. Then it creates JDBC steps based on a specified template with the correct queries. The new steps receive the same name as their corresponding SQL filenames (with .sql removed) // Define the path where all SQL queries are stored String ResultSetsPath = "PATH_TO_DIRECTORY_CONTAINING_SQL_FILES" String ResultSetTemplateStepName = "ResultStepTemplate" // Try to get the template JDBC TestStep def ResultSetTemplateStep = testRunner.testCase.getTestStepByName(ResultSetTemplateStepName) // Make sure it's a valid JDBC TestStep assert ResultSetTemplateStep != null assert ResultSetTemplateStep.getClass().name.contains("JdbcRequestTestStep") // Delete every JDBC TestStep in the current TestCase except the template steps int TestStepCount = testRunner.testCase.getTestStepCount() def TestStepsToDelete = [] for (int i = 0; i < TestStepCount; i++) { // Get the current TestStep def curTestStep = testRunner.testCase.getTestStepAt(i) // Only delete JDBC steps if (!curTestStep.getClass().name.contains("JdbcRequestTestStep")) continue // Don't delete template JDBC steps if (curTestStep.name == ResultSetTemplateStepName || curTestStep.name.toLowerCase().contains("template")) continue TestStepsToDelete.add(i) } int TestStepsToDeleteCount = TestStepsToDelete.size for (int i = TestStepsToDeleteCount - 1; i >= 0; i--) testRunner.testCase.removeTestStep(testRunner.testCase.getTestStepAt(TestStepsToDelete[i])) // // For every SQL file in the provided ResultStepsPath, clone the template TestStep with the filename as TestStep name // // Because of a bug in the Clone methods, we have to: // - Create a temporary TestCase // - Clone the original TestStep(s) to the new TestCase // - Change the name of the the cloned TestStep(s) // - Clone the renamed TestStep(s) to the original TestCase // - Remove the temporary TestCase def tmpCloneTestCase = testRunner.testCase.testSuite.addNewTestCase("TemporaryCloneTestCase") new File(ResultSetsPath).eachFile { // Ignore files that do not end in .sql if (it.name.endsWith(".sql")) { // Make sure we can read the file assert it.canRead() // Get the new name for the testStep String newStepName = it.name[0..-5] // Clone the template TestStep def newStep = ResultSetTemplateStep.clone(tmpCloneTestCase, newStepName) newStep.setName(newStepName) // Update the query of the TestStep with the contents of the file newStep.setQuery(it.text) // Now clone the temporary testStep to the original testCase newStep.clone(testRunner.testCase, newStepName) // Remove the temporary testStep tmpCloneTestCase.removeTestStep(newStep) } } testRunner.testCase.testSuite.removeTestCase(tmpCloneTestCase) // Save the project assert testRunner.testCase.testSuite.project.save() == true2.9KViews0likes1CommentRe: Clone a step with Groovy script
When cloning to another TestCase, I even noticed that the cloned TestStep receives the same name as the original TestStep. Its name hasn't been changed! A workaround is to - Create a temporary TestCase - Clone the original TestStep(s) to the new TestCase - Change the name of the the cloned TestStep(s) - Clone the renamed TestStep(s) to the original TestCase - Remove the temporary TestCase The following code creates new JDBC TestSteps for each SQL file in a specified directory (ResultSetsPath) based on a template step (ResultSetTemplateStep) It then updates the query from the new step to the query in the SQL file. // // For every SQL file in the provided ResultStepsPath, clone the template TestStep with the filename as TestStep name def tmpCloneTestCase = testRunner.testCase.testSuite.addNewTestCase("TemporaryCloneTestCase") new File(ResultSetsPath).eachFile { // Ignore files that do not end in .sql if (it.name.endsWith(".sql")) { // Make sure we can read the file assert it.canRead() // Get the new name for the testStep String newStepName = it.name[0..-5] // Clone the template TestStep def newStep = ResultSetTemplateStep.clone(tmpCloneTestCase, newStepName) newStep.setName(newStepName) // Update the query of the TestStep with the contents of the file newStep.setQuery(it.text) // Now clone the temporary testStep to the original testCase newStep.clone(testRunner.testCase, newStepName) // Remove the temporary testStep tmpCloneTestCase.removeTestStep(newStep) } } testRunner.testCase.testSuite.removeTestCase(tmpCloneTestCase) // Save the project assert testRunner.testCase.testSuite.project.save() == true However,it feels kinda nasty we have to do this :-) Tnx!2.9KViews0likes0CommentsClone a step with Groovy script
Hi there. Ive been Groovy-scripting a lot these days and learning a lot. However, when I try to clone a JDBC TestStep, it always asks me (via the rename dialog) to provide a new name, even when I specify a unique name in the method. Is this a bug or am I doing something wrong? Both testCase.cloneStep(step, name) as testStep.clone(case, name) show the same behavior. def newStep = ResultSetTemplateStep.clone(testRunner.testCase, "uniquenewname") def newStep = testRunner.testCase.cloneStep(ResultSetTemplateStep, "uniquenewname")4.4KViews0likes3CommentsRe: SOAP response vs JDBC response
For the following JDBC XML result: <Results> <ResultSet fetchSize="128"> <Row rowNumber="1"> <ID>10021</ID> <NAME>Test</NAME> </Row> <Row rowNumber="2"> <ID>10022</ID> <NAME>Testing</NAME> </Row> <Row rowNumber="3"> <ID>10023</ID> <NAME>Hello World</NAME> </Row> </ResultSet> </Results> using script import com.eviware.soapui.support.XmlHolder def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) def holder2 = groovyUtils.getXmlHolder( "JDBC Request#ResponseAsXml" ) // loop item nodes in response message for( item in holder2.getDomNodes( "//Row" )) log.info groovy.xml.dom.DOMCategory.xpath(item, "//ID") I get the following results: Tue Jan 10 10:57:15 CET 2012:INFO:10021 Tue Jan 10 10:57:15 CET 2012:INFO:10021 Tue Jan 10 10:57:15 CET 2012:INFO:10021 I got the same behavior when trying some XPath assertions. Does anyone have an idea why it returns the correct number of records (3), but always 'selects' the same record? Tnx!1.8KViews0likes0CommentsSOAP response vs JDBC response
Hi there, Because our test data changes quite a lot, I want to make 'dynamic' assertions. In order to test our webservice, we need to make sure the data we receive from it matches the data in the database (an MSSQL server) and results should be in the same order! I've managed to get the connection working properly and all JDBC requests and datasource functions are working fine. But now comes the tricky part (for me :-)): E.g.: I get the following list from the DB (in whatever format): Record1 --ID: 1 --Name: Test Record2 --ID: 3 --Name: Testing The assertion for the following SOAP response should succeed: <Rows> <Row> <ID>1</ID> <Name>Test</ID> </Row> <Row> <ID>3</ID> <Name>Testing</ID> </Row> </Rows> However, for the following responses, the assertion should fail: <Rows> <Row> <ID>1</ID> <Name>Test</ID> </Row> </Rows> <Rows> <Row> <ID>1</ID> <Name>Testing</ID> </Row> <Row> <ID>3</ID> <Name>Test</ID> </Row> </Rows> <Rows> <Row> <ID>3</ID> <Name>Testing</ID> </Row> <Row> <ID>1</ID> <Name>Test</ID> </Row> </Rows> I've tried to use datasources, JDBC requests, xqueries (with for loops, some loops, ...) but haven't managed to find a decent result. I don't think the datasource loop is the correct solution because the webservice should only be called once. Also, if possible, I'd like to do this without Groovy scripting. However, if not possible with xqueries, Groovy scripts are welcome! Thanks in advance :-)2.8KViews0likes2CommentsRe: Unable to connect to SQL Server 2005 - with 'Data Source' using JDBC
Just for future references (been looking online for a few hours!): The MS driver DOES support integrated security (windows authentication). Download the latest driver from http://www.microsoft.com/download/en/de ... n&id=21599 Unpack, copy 'sqljdbc.jar' or 'sqljdbc4.jar' (copying both resulted in a could not connect exception) to <soapui_dir>/bin/ext Then, copy 'sqljdbc_auth.dll' to <soapui_dir>/bin Use following connection string if using named instances: jdbc:sqlserver://<SERVER>;instanceName=<INSTANCE>;databaseName=<DATABASE>;integratedSecurity=true; Use following connection string if using server port: jdbc:sqlserver://<SERVER>:<PORT>;databaseName=<DATABASE>;integratedSecurity=true;1.5KViews0likes0Comments