Service Virtualization

  • 1.  How to change config file dynamically

    Posted Jun 02, 2016 03:31 AM

    Hi ,

     

    I am not able to change the config file dynamically, below is the code i am using.

     

    import com.itko.lisa.test.Configuration;

    //Configuration cnf = new Configuration()

     

     

    List L1 = testExec.getTestCase().getConfigurations();

    int i = L1.size();

    //L1.get(10);

    Configuration cnf = L1.get(10);

    testExec.getTestCase().setRealTimeConfig(cnf);



  • 2.  Re: How to change config file dynamically

    Posted Jun 06, 2016 02:40 PM

    I don't see this in the TestExec documentation. RalphParker, caujo01 do you guys know?



  • 3.  Re: How to change config file dynamically
    Best Answer

    Posted Jun 06, 2016 03:45 PM

    The above code does change the instance variable holding the Configuration, but it doesn't apply the content of the Configuration.  That is, the state properties in the TestExec don't get updated when setRealTimeConfig is called.

     

    You can try adding a call to

    Configuration.setConfiguration ( TestCase ts, String configSpec )

     

    (its a static method),  where configSpec can be a known configuration in the project ( 'default.config', 'localhost.config' etc. ).

     

    Does this help?  Am I following what you're trying to accomplish?



  • 4.  Re: How to change config file dynamically

    Posted Mar 27, 2018 04:04 PM

    I am using this method to change the config file, and it is working in DevTest when running an ITR.

     

    However, running within a suite the path it is looking to get and load the config file is changing. For example:

    import com.itko.lisa.test.Configuration;
    String Current_Environment = String.valueOf(ENV_NAME);
    //If the project config set to XQA environment then
            if (Current_Environment.equals("PQA")){
            Configuration.setConfiguration(testExec.getTestCase(), "PQA.config");
            }else if (Current_Environment.equals("XQA")){
            Configuration.setConfiguration(testExec.getTestCase(), "XQA.config");
            }
            return;

    works when executed as an ITR. However when executed in suite, the path it is looking to load the config file from becomes the DevTest install dir, or 'C:\Program Files\CA\DevTest951' and it errors showing failure to load the config file from that path.

     

    Updated the code above to include the relative path to the config file, using the LISA_RELATIVE_PROJ_ROOT parameter, which also works within a DevTest ITR, but now when executed via suite the error message tells me the path it's seeking the config file is 'C:/Users/e664vv/lisatmp_9.5.1/lads/*.

     

    Very unusual behavior considering the variables given aren't being updated.

     

    Any ideas anyone?