Forum Discussion

Kronos_Support's avatar
Kronos_Support
Occasional Contributor
14 years ago

Load global properties using a relative path

How to load project level global properties using a relative path in UI?
I would like to load global properties from an external file at the project level in UI using a relative path.. Absolute path works fine.
I am trying to use ${#Project#ProjectDir} option, but I am getting FileNotFoundException as ${#Project#projectDir}is not getting evaluated right.
I have also tried ${#Project#Resource Root}, but got same error.

java.io.FileNotFoundException: ${#Project#projectDir}\..\properties\Shifts.properties (The system cannot find the path specified)

Please let me know how to fix this?
PJ
  • Hi!

    Try using this in a Groovy Script to get the current project's path:
    testRunner.testCase.testSuite.project.path


    You can assign this to a project property as follows:
    testRunner.testCase.testSuite.project.setPropertyValue( "MyProperty", testRunner.testCase.testSuite.project.path) 


    ...and then use it like this:

    ${#Project#MyProperty}



    Hope this helps!

    Henrik
    eviware support
  • Kronos_Support's avatar
    Kronos_Support
    Occasional Contributor
    Hi,
    I try to add the code you provided at "Load Script" of the Project level.. and I am getting "groovy.lang.MissingPropertyException: No such property: testRunner for class: Script7" error.

    Do I need to add any imports to the script? or do I need any libraries? I just installed SoapUIPro.

    thanks
    PJ
  • Kronos_Support's avatar
    Kronos_Support
    Occasional Contributor
    Hi,
    I am able to create groovy using following code at test case level and set the property for the path file name to be loaded.

    def path = testRunner.testCase.testSuite.project.getPath();
    int pathIdx = path.lastIndexOf("\\");
    String pathS = path.substring(0, pathIdx);
    log.info("pathS is: " + pathS);
    String propFilePath = pathS.concat("\\Global.properties");
    log.info("propFilePath is: " + propFilePath)
    testRunner.testCase.testSuite.project.setPropertyValue( "propFilePath", propFilePath)

    The output log shows:
    Wed Jul 06 16:32:53 EDT 2011:INFO:pathS is: Z:\LoadOpenShift
    Wed Jul 06 16:32:53 EDT 2011:INFO:propFilePath is: Z:\LoadOpenShift\Global.properties

    The property "propFilePath" and it's value is set at the project level successfully. Now I am trying to load this external property file at project level giving "${#Project#propFilePath}" value but, I am still getting following error:

    Wed Jul 06 16:34:05 EDT 2011:ERROR:An error occured [${#Project#propFilePath} (The system cannot find the file specified)], see error log for details

    All I want is I want to load external global property file at project level so, that I can give user option of changing the endpoint server names to apply for the project.

    Please help me solve this as I am blocked by this.
    thank you
    PJ
  • Kronos_Support's avatar
    Kronos_Support
    Occasional Contributor
    Henrik,
    I am trying to load this property-file using "Loads Property valies from an external file" option of "Properties" at Project level. (Not fromt the test case level).
    When we select "Loads Property valies from an external file", SoapUI pops a dialog box to provide File to load..here I am giving "${#Project#propFilePath}".. I can see that "propFilePath" got set from the groovy script below. But the path is not getting evaluated at load time.
    The topic you provided below is a simple load at the test case level..But I am loading at project level with project properties in the path..

    Here is the error.log
    Wed Jul 06 17:05:31 EDT 2011:ERROR:java.io.FileNotFoundException: ${#Project#propFilePath} (The system cannot find the file specified)
    java.io.FileNotFoundException: ${#Project#propFilePath} (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileReader.<init>(Unknown Source)
    at com.eviware.soapui.impl.wsdl.panels.teststeps.support.PropertyHolderTable$LoadPropertiesAction.actionPerformed(PropertyHolderTable.java:433)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$2.run(Unknown Source)
    at java.awt.EventQueue$2.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    thanks
    PJ
  • Hi PJ,

    this dialog does not accept property expansions as you specify, and anyhow it only loads from the specified file only once.

    Could you perhaps put the loading of these properties into the Projects' onLoad script?

    regards,

    /Ole
    eviware.com