Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does Soap UI look for a file in new File() Groovy Script by default? How do i change this?

Tags:

groovy

soapui

I have a groovy script which reads the text from a file and returns it as a response

i have to read it as follows

text = new File("D:/text.xml")

now the problem is i'd like to use relative paths.. so i was wondering

If i just say

text = new File("text.xml")

Where does Soap UI / Groovy start searching for the file by default? This currently throws a "java.io.FileNotFoundException".

How do i change this so that it uses paths relative to the project.xml file?

This is how i finally solved my requirement

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def projectPath = groovyUtils.projectPath //gets the path of the project root
def response = new File(projectPath, "/test.xml").text;
like image 562
Brijesh Bharadwaj Avatar asked Oct 05 '22 13:10

Brijesh Bharadwaj


1 Answers

Add

System.out.println(System.getProperty("user.dir"));

or

System.out.println(text.getAbsolutePath());

to your script to find out.

like image 185
JB Nizet Avatar answered Oct 10 '22 01:10

JB Nizet