Forum Discussion

phil89's avatar
phil89
Occasional Contributor
14 years ago

Change workdir ?

Hi

I have loaded data with an properties, and default directory seems "bin".
Could i load data file from the directory where is stored SOAPUI xml file ?

Regards
Philippe

3 Replies

  • Hi Phil
    Yes you can like this way. It take me more than one hour to figure out so i hope this will help others solve this in a 2 minute.

    1-Firts clik on your project  & see "project properties" below. For the line "resource root" Choose in the list this:${projectDir} for the value.

    In a groovy step script or in the SETUP script of your test(better) you can load a file like this :

    import org.apache.commons.io.FileUtils;

    //get the path of your local soapui project
    def projectroot = context.expand('${projectDir}');

    //read the file
    File file = new File(projectroot+"\\myfile.sql");

    //get the content in a string
    def content = FileUtils.readFileToString(file);

    //display it the 1st time to be sure it is ok
    log.info content

    //send me 10 dollars :)
  • phil89's avatar
    phil89
    Occasional Contributor
    Hi,

    I have resolved problem with

    //read the file
    def properties = new java.util.Properties();
    properties.load( new java.io.FileInputStream("..\\..\\..\\tirablanc\\VAL\\props_patricia_val30.properties" ));
    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) log.info( groovyUtils.projectPath )
    def targetStep = testRunner.testCase.getTestStepByName( "Properties" );
    // assign single property
    targetStep.setPropertyValue( "nom", properties.getProperty( "nom"+context.getProperty( "RunCount")));
    targetStep.setPropertyValue( "prenom", properties.getProperty( "prenom"+context.getProperty( "RunCount") )); targetStep.setPropertyValue( "clef", properties.getProperty( "clef"+context.getProperty( "RunCount") ));
    targetStep.setPropertyValue( "inst", properties.getProperty( "inst"+context.getProperty( "RunCount") ));
    targetStep.setPropertyValue( "nir", properties.getProperty( "nir"+context.getProperty( "RunCount") ));</script>
      </con:config>



    But, Do you know how change log results directory too ?
    Regards
    Philippe
  • But, Do you know how change log results directory too ?

    Open the soapui***.JAR use by your plugin or your gui software and search for the file :soapui-log4j.xml
    This file is a log4 file and it contains a variabl envionnment like this one

    ...value="${soapui.logroot}soapui-errors.log"


    Now you have to define for example for the location of soapui-errors.log the variable soapui.logroot.
    In order to do that please refer to the log4j manual.

    But if you are using the maven plugin you cand do it like this.
    This will resolve PARTIALLY the location of the .log files

    <configuration>
    <soapuiProperties>
    <property>
    <!-- Indicate where are stored Soapui logs
    but not global-groovy.log wich will be generated at the root of the project.
    This things is not documented (understand that it was time consuming to find out that )
    But soapui-3.6.1.jar
    has a log4j configuration name : soapui-log4j.xml which have the following line:
    ...value="${soapui.logroot}soapui-errors.log"..
    -->
    <name>soapui.logroot</name>
    <value>${project.build.directory}/soapui-logs/</value>
    </property>
    </soapuiProperties>


    Some of them have no variable like global-groovy.log. The dirty trick is to edit the .jar with your variable.