Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to use java in pva project

douglas_siqueira
douglas_siqueira Posts: 3
edited March 2022 in Virtualize

Hello!

I'm new using parasoft but i don't understand very well how i can integrate a java application in the response of one Virtual Asset.

I hava a web server that i want to virtualize which sends a xml with several values, as below:

REQUEST:

< items>
< item id="1">5000< /item>
< item id="2">4000< /item>
< item id="3">3000< /item>
< item id="4">8000< /item>
< item id="5">10000< /item>
< /items>

For each item in the request, the webserver returns the same response, but each value is incremented by 10%, as below:

RESPONSE:

< items>
< item id="1">5500< /item>
< item id="2">4400< /item>
< item id="3">3300< /item>
< item id="4">8800< /item>
< item id="5">11000< /item>
< /items>

The numbers of items may vary.

I thinked to build an java application that received the XML, calculate the taxes and return the response, but i'm not understand very well how i can integrate a java application using the Scripted Response. I've already read all the instructions in parasoft documentation but it don't work. When i set the classe that i want to use, the methods don't appear and i have a blank response.

anyone hava a step by step tutorial to use a java project to receive, process and return the request using parasoft?

Answers

  • williammccusker
    williammccusker Posts: 672 ✭✭✭

    Hi,

    How is the class you wrote being provided to Virtualize? Normally either a jar file or a Java project needs to be added to the System Properties

    For example this is how to add a Java Project from the Eclipse workspace so that it's class files are accessible to Virtualize
    https://docs.parasoft.com/display/SOAVIRT20212/Adding+Projects,+Virtual+Assets,+and+Responder+Suites#AddingProjects,VirtualAssets,andResponderSuites-UsingEclipseJavaProjectsinVirtualize

    Another option might be to consider writing the script in Groovy. It provides the ability to support Java syntax and is pretty easy to pick up if you know Java. It also wouldn't require adding a jar or Project to the preferences to work.

  • douglas_siqueira
    douglas_siqueira Posts: 3
    edited March 2022

    Thanks to reply, William!

    I've tried this once, but parasoft always send blank data with the most part of codes that i built. There are any debugging option to see which errors are happening during code execution?

  • williammccusker
    williammccusker Posts: 672 ✭✭✭

    Hi,

    What are the signatures of the methods? I believe the tool can only provide certain arguments so maybe it could be that the methods have arguments that the tool doesn't accept? Also, it seems from the screenshot it appears the class is in the default package, does it make a difference if the class is put into a package other than the default package?