01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
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: private final TestRunContext context;
23:
24: public GroovyUtils(TestRunContext context) {
25: this .context = context;
26: }
27:
28: public String getProjectPath() {
29: WsdlProject project = (WsdlProject) context.getTestCase()
30: .getTestSuite().getProject();
31: String path = project.getPath();
32: int ix = path.lastIndexOf(File.separatorChar);
33: return ix == -1 ? path : path.substring(0, ix);
34: }
35:
36: public XmlHolder getXmlHolder(String xmlPropertyOrString)
37: throws Exception {
38: Object property = context.getProperty(xmlPropertyOrString);
39: if (property != null)
40: return new XmlHolder(context, xmlPropertyOrString);
41: else
42: return new XmlHolder(xmlPropertyOrString);
43: }
44:
45: public void setPropertyValue(String testStep, String property,
46: String value) throws Exception {
47: TestStep step = context.getTestCase().getTestStepByName(
48: testStep);
49: if (step != null) {
50: step.setPropertyValue(property, value);
51: } else {
52: throw new Exception("Missing TestStep [" + testStep
53: + "] in TestCase");
54: }
55: }
56: }
|