1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.support;
14
15 import java.io.File;
16
17 import com.eviware.soapui.impl.wsdl.WsdlProject;
18 import com.eviware.soapui.model.testsuite.TestRunContext;
19 import com.eviware.soapui.model.testsuite.TestStep;
20
21 public final class GroovyUtils
22 {
23 private final TestRunContext context;
24
25 public GroovyUtils( TestRunContext context )
26 {
27 this.context = context;
28 }
29
30 public String getProjectPath()
31 {
32 WsdlProject project = ( WsdlProject ) context.getTestCase().getTestSuite().getProject();
33 String path = project.getPath();
34 int ix = path.lastIndexOf( File.separatorChar );
35 return ix == -1 ? path : path.substring( 0, ix );
36 }
37
38 public XmlHolder getXmlHolder( String xmlPropertyOrString ) throws Exception
39 {
40 Object property = context.getProperty( xmlPropertyOrString );
41 if( property != null )
42 return new XmlHolder( context, xmlPropertyOrString );
43 else
44 return new XmlHolder( xmlPropertyOrString );
45 }
46
47 public void setPropertyValue( String testStep, String property, String value ) throws Exception
48 {
49 TestStep step = context.getTestCase().getTestStepByName( testStep );
50 if( step != null )
51 {
52 step.setPropertyValue( property, value );
53 }
54 else
55 {
56 throw new Exception( "Missing TestStep [" + testStep + "] in TestCase" );
57 }
58 }
59 }