Service Virtualization

  • 1.  Eclipse test Customer DPH

    Posted Jun 14, 2017 10:07 AM

    please tell me ,how use Eclipse test Customer DPH。

     



  • 2.  Re: Eclipse test Customer DPH
    Best Answer

    Posted Jun 14, 2017 12:01 PM

    I do not believe there is an explicit set of instructions on configuring Eclipse, IntelliJ, or other IDEs since these tools are outside the purview of DevTest.

     

    The major elements to configure in order to resolve references and enable autosense are:

    - Ensure that Eclipse (Eclipse Preferences -> Java -> Installed JREs) is running the version of Java that DevTest requires

       e.g., If running DevTest 9 or above, make sure you have Java 8 installed and set Eclipse to use the Java 1.8 libraries.

     

    - Create a Project if you do not already have one

     

    - Import the Java code for the custom extension 

     

    - For your project, navigate to Project Properties -> Project Build Properties -> Libraries, and add the JAR files found in your LISA_HOME\lib and LISA_HOME\bin, and if necessary, jars found in LISA_HOME\hotdeploy directories. It is unlikely that you need every one of the JARs in LISA_HOME\lib but including them all will not hurt.

     

    If you compile and export the code as a JAR, only export the custom code.  Do not export / include classes found in the DevTest software JARs as part of your custom JAR. The DevTest classes are already available in the environment.

     

    If you want to test a DPH, you need to create some sort of test driver class. In the test driver's main method, you can create the basics to send data to the DPH according to what a sample request looks like for your environment.

     

    Some of the things that can be set up in the main method in order to invoke the DPH are:

     

    - Create an instance of TestExec

    com.itko.lisa.test.TestExec te = com.itko.lisa.test.TestExec.makeSimpleTestExec();

    - Create a VSE Request object

    com.itko.lisa.vse.stateful.model.Request req = new com.itko.lisa.vse.stateful.model.Request();

    - Create an instance of your custom DPH

    YourDph dph = new YourDPH();

    - Create some data to place in your request

    String someData = "abcdefghijklmnopqrstuvwxyz";

    - Set the data into your request body and set any other items in the Request object that need to be there for your DPH

    req.setBody( someData );

    req.setOperation( "optionalOperationNameHereIfNeededByYourDPH" );

    -- set up any other things your DPH needs such as MetaData headers and so on

    - call the update request method on your custom DPH

    dph.updateRequest( req );

    - Alternatively, call the update request method and pass the TestExec and Request objects to the DPH

    dph.updateRequest( te, req );

     

    - Get a string value for value that is set back into the body or look at other things on the request

    String s = req.getBodyAsString();

    Execute the code in the debugger and watch the variables that are important to you



  • 3.  Re: Eclipse test Customer DPH

    Posted Jun 14, 2017 08:43 PM

    ths,i will try it.



  • 4.  Re: Eclipse test Customer DPH

    Posted Jan 03, 2018 03:08 AM

    can you share a source code? I can not make the test class work. Thank you!



  • 5.  Re: Eclipse test Customer DPH

    Posted Jan 03, 2018 08:51 AM
      |   view attached

    Can you provide some screenshots of the errors you are seeing. 

    You will need to ensure that the correct set of libraries are visible to your project and your imports align correctly.

    The attachment shows just one method for sending a request to your DPH for debugging. There are other ways to do this, of course.

    The driver class can be executed in debug mode so you can use the debugging features of your IDE.

     

    Attachment(s)

    zip
    exampleTestDriver.txt.zip   504 B 1 version


  • 6.  Re: Eclipse test Customer DPH

    Posted Jan 04, 2018 01:31 AM

    this is the console output. 

    I am very sure I could get the LISA_HOME in java code.

     

     

    C:\CA\DevTest    ------ this is returned by "String lisa = System.getenv().get("LISA_HOME");"

    Locale: zh_CN

    Setting System.out and System.err to: GBK

    LISA_HOME not specified, so we will assume it based on current directory.

    LISA_HOME set to C:\ECLIPS~1\LISA_D~1\

    DevTest temporary directory is C:\Users\Administrator\lisatmp_10.2.4

    File C:\ECLIPS~1\LISA_D~1\logging.properties does not exist or is not readable!

    log4j:WARN No appenders could be found for logger (com.itko.lisa.test.TestExecHelper).

    log4j:WARN No appenders could be found for logger (System.err).

    log4j:WARN Please initialize the log4j system properly.

    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

    log4j:WARN No appenders could be found for logger (com.itko.lisa.test.TestExecHelper).

    log4j:WARN Please initialize the log4j system properly.

    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

     

    here is a demo java source code for your reference.

     

    /**
    *
    */
    package com.sample.dph;

    //import com.itko.lisa.test.TestExec;
    import com.itko.lisa.vse.stateful.model.Request;
    import com.itko.lisa.vse.stateful.model.Response;


    /**
    * @author demo
    *
    */
    public class TestDHP {

    /**
    *
    */
    public TestDHP() {
    // TODO Auto-generated constructor stub
    }

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub

    String lisa = System.getenv().get("LISA_HOME");
    System.out.println(lisa);

    com.itko.lisa.test.TestExec te = com.itko.lisa.test.TestExec.makeSimpleTestExec();
    Request req = new Request();
    SampleDPH myDPH = new SampleDPH();
    String sampledata = "abcdefghijklmnopqrstuvwxyz";
    req.setBody(sampledata);
    req.setOperation("myoperation");
    myDPH.updateRequest(req);
    myDPH.updateRequest(te,req);

    String s = req.getBodyAsString();

    System.out.println(s);

    }

     

    }



  • 7.  Re: Eclipse test Customer DPH

    Posted Jan 04, 2018 09:29 PM

    I copied logging.properties from the lisa_home directory, then resolved this issue.