Forum Discussion

slg12345's avatar
slg12345
Occasional Contributor
13 years ago

Default loading of properties and update definitions....

I want to run my project from commandline.

When it runs the first things I would want is:

1. Load Project properties from some file(properties have multiple endpoints, path to external data xls used in datasources etc)

2. Update definition of the services(endpoints are parameterized and value is read from project properties)

3. Run all the test suites

It would be good if you can provide some SOAPUI api to do #1 & 2 - specify in Setup script of project.
This would enable a non SOAPUI user to just update properties in the file and run the project for any release, without having to actually work with SOAPUI interface.

Please see if it is doable.

Thanks.

5 Replies

  • bmgriner's avatar
    bmgriner
    Frequent Contributor
    I'm like these ideas too. The UI is good for manual tests started by me, but when I try to automate testing things get a little clunky. These are some great suggestions to help with some of those issues.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    I've added feature request SOAPUI-3531 to our product backlog.

    Thank you!

    Vladimir
    SmartBear Software
  • bmgriner's avatar
    bmgriner
    Frequent Contributor
    The format "SOAPUI-3531" makes it sound like you are using Jira or some other issue tracking system. Do you have that system available for the public to look at?
  • Finan's avatar
    Finan
    Frequent Contributor
    project properties can be loaded as endpoints, by ${#Project#propertyname}
    Enter this as endpoint for a webservice (don't forget to add the property to the project).

    Below is a script to use at the "Load Script" on project level, it loads files from projectpath/settings.
    Syntax for the propertie filename = environment_tst.properties
    Syntax for the properties inside the file: endpoint=http://localhost:8080


    import groovy.io.*;
    import groovy.swing.SwingBuilder;
    import javax.swing.*;

    //determine projectdir by project.getPath, because GroovyUtils.projectpath does not work at startup
    path = project.getPath();
    log.info("path = " + path);
    s= System.getProperty("file.separator");
    settingsPath = path+s;
    //settingsfiles are stored in projecpath\settings
    settingsPath += "settings" + s;

    //only works in versions > 4.0 because of SoapUI.isCommandline()
    if(com.eviware.soapui.SoapUI.SOAPUI_VERSION.toString().substring(0,1).toInteger() >= 4){
    if(com.eviware.soapui.SoapUI.isCommandLine()){
    setProperties("environment_default", settingsPath);
    }else{
    openDialog();
    }
    }

    //Method to set project properties
    void setProperties(name, location){
    try{
    //read properties file
    FileInputStream fstream = new FileInputStream(location + name + ".properties");
    DataInputStream ins = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(ins));
    String strLine;

    //set new properties
    while ((strLine = br.readLine()) != null) {
    attribute = strLine.split("=");
    project.setPropertyValue(attribute[0],attribute[1]);
    }
    ins.close();
    }catch(Exception e){
    log.info("No project-properties were set, could not find file for name: " + name + " and location: " + location);
    }
    }

    //Opens the swing dialog
    void openDialog(){
    def swingBuilder = new SwingBuilder();
    File[] listOfFiles = new File(settingsPath).listFiles();
    int count, count2;
    def options = [];
    def browser = [];
    for (int i = 0; i < listOfFiles.length; i++) {
    if(listOfFiles[i].getName().contains("environment_")){
    name = listOfFiles[i].getName().replace("environment_","").replace(".properties","");
    options[count]=name;
    count++
    }
    if(listOfFiles[i].getName().contains("browser_")){
    name = listOfFiles[i].getName().replace("browser_","").replace(".properties","");
    browser[count2]=name;
    count2++;
    }
    }
    def pane = swingBuilder.optionPane(message:'Environment', selectionValues:options, optionType:JOptionPane.CLOSED_OPTION);
    def dialog = pane.createDialog(null, 'Select an environment (' + project.name + ")");
    dialog.show();
    setProperties("environment_" + pane.getInputValue(), settingsPath);
    }
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    yes we use JIRA, but unfortunately it is not currently publicly exposed.

    Regards,
    Vladimir
    SmartBear Software