12 years ago
Concurrency with SoapUi
I’m having problems in soapUi with synchronization.
My goal is read a file sequentially. Each thread have to read a line.
To do that I have this script:
def ret = ''
int lineNo = Integer.parseInt(testRunner.testCase.testSuite.project.getPropertyValue( "TmpLastLineIds" )) +1
def path = testRunner.testCase.testSuite.project.getPropertyValue( "Path" )
File f = new File(path + "crear\\Ids.txt")
f.withReader { r ->
lineNo.times {
ret = r.readLine()
}
}
if(ret == null){
log.error "End of file ids"
throw new Exception ("End of file")
}else{
testRunner.testCase.testSuite.project.setPropertyValue("TmpID",ret)
testRunner.testCase.testSuite.project.setPropertyValue("TmpLastLineIds ",lineNo.toString())
}
In the property TmpID I have the line read and in TmpLastLineIds I have the number of the last line read.
The problem become when two threads at the same time executes this code and read the same line.
To solve it I decided to find a way to know the sequence number generated in loadUi and with this number read a line. The thread 1 read the line 1, the thread 2 reads the line 2 … but I couldn’t find a way to do that.
Any one can help me?
My goal is read a file sequentially. Each thread have to read a line.
To do that I have this script:
def ret = ''
int lineNo = Integer.parseInt(testRunner.testCase.testSuite.project.getPropertyValue( "TmpLastLineIds" )) +1
def path = testRunner.testCase.testSuite.project.getPropertyValue( "Path" )
File f = new File(path + "crear\\Ids.txt")
f.withReader { r ->
lineNo.times {
ret = r.readLine()
}
}
if(ret == null){
log.error "End of file ids"
throw new Exception ("End of file")
}else{
testRunner.testCase.testSuite.project.setPropertyValue("TmpID",ret)
testRunner.testCase.testSuite.project.setPropertyValue("TmpLastLineIds ",lineNo.toString())
}
In the property TmpID I have the line read and in TmpLastLineIds I have the number of the last line read.
The problem become when two threads at the same time executes this code and read the same line.
To solve it I decided to find a way to know the sequence number generated in loadUi and with this number read a line. The thread 1 read the line 1, the thread 2 reads the line 2 … but I couldn’t find a way to do that.
Any one can help me?