Forum Discussion

keczy1992's avatar
keczy1992
New Contributor
12 years ago

Java SoapUI Api, applying outgoing WSS to all test steps

Hi there!

I have a huge problem, because i got quite big project with many test suites (about 50), and every TS got about 10 Test Cases wich have about 6 methods.
As u can see that make my project is having about 3000 methods, and i have to add Outgoing WSS to all of them.

Because its realy hard work to get every test step and manualy set Outgoing WSS to it, i want to write a method in Java to automatize that work.

And here is the problem:

in SoapUI api i got class named: ApplyOutgoingWSSToRequestAction(WsdlRequest request, OutgoingWss outgoing), and i know where i can download only the first parameter "request" (tStep.getProperty("request");)
and i really dont know how can i get the outgoing parameter from Java side.

My method now looks like that:

public void addOutgoingWSSToAllTestSteps(){
List<TestSuite> tsList = testRunner.getTestCase().getTestSuite().getProject().getTestSuiteList();
Project project = testRunner.getTestCase().getTestSuite().getProject();

for(TestSuite tSuite : tsList){
if(!tSuite.isDisabled()){
List<TestCase> tcList = tSuite.getTestCaseList();
for(TestCase tCase : tcList){
List<TestStep> tstList = tCase.getTestStepList();
for(TestStep tStep : tstList){
ApplyOutgoingWSSToRequestAction applyOutgoingWSSToRequestAction = new ApplyOutgoingWSSToRequestAction(tStep.getProperty("request"), <here should be OutgoingWSS item>);
}
}
}
}
}

Than U in advance!
Tomasz Kaczyński

1 Reply

  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    This was a fun one. I did it with just a groovy script step but it should at least help lead you down the correct path

    The following code will build a new project level outgoingWSS and put it into all WSDLTestSteps in the current project:

    def project = testRunner.testCase.testSuite.project;
    def WssC = project.getWssContainer();
    if (!WssC.getOutgoingWssList().contains("testing")) {
    def owss = WssC.addOutgoingWss("testing");
    owss.setActor("blah");
    owss.setPassword("Test");
    owss.setUsername("Test");
    owss.setMustUnderstand(true);
    }

    for (ts in testRunner.testCase.getTestStepList()) {
    if (ts instanceof com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep) {
    trs = ((com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep)ts);
    trs.getTestRequest().setOutgoingWss("testing");
    }
    }




    Change the code as you need but it should lead you down the correct path