How to run a Java code using Array Generator DPL

Article below tells how Array Generator DPL is useful in running a Java test type scenario in scenario builder.
Please refer the attached sample jar and scenario file to understand how array generator DPL can be used to pass array of arguments.
To run a java code with array arguments in Appvance use Array generator DPL.

In order to execute Java code with Main method in scenario builder you need to select a Array Generator DPL type and String[] from actions drop down. Add argument name and pass a value by clicking on Add Val link.




UsingArrayGenerator DPL you can send an array of values as a single parameter that has inside many entries String array: [ "string1", "string2", "string3" ].

So now you can provide a input parameter for a method that requires an array like

public void myMethod(String[]) {
}
You can also have Object arrays-Example: 
[ { name: 'Honda', models: [ { name: 'Accord', features: ['2dr', '4dr'] }, 
{ name: 'CRV', features: ['2dr', 'Hatchback'] }, 
{ name: 'Pilot', features: ['base', Appvance_DPL_ArrayGenerator Page 2 'superDuper']},
{ name: 'Toyota', models: [ { name: 'Prius', features: ['green', 'superGreen'] }, 
{ name: 'Camry', features: ['sporty', 'square'] }, { name: 'Corolla', features: ['cheap', 'superFly'] }


Types for arrays available: Object, String, Integer, int, Byte, byte, Double, double, Short, short, Float, float, Character, Boolean, Boolean


Sample Java Code with int array[]:

package com.package1; 
import java.util.Arrays; 
public class Array {
 public static void main(String args[]) throws Exception {} 
 public void printArray(String message, int array[]) 
 { 
   Arrays.sort(array); 
   System.out.println(message+ ": [length: " + array.length + "]");
   for (int i = 0; i<array.length; i++) {
    if(i != 0)
   { 
    System.out.print(", ");
   } 
     System.out.print(array[i]);
   } 
 System.out.println(); 
 int index = Arrays.binarySearch(array, 2); 
 System.out.println("Found 2 @ " + index);
}


}


Create a jar file for above java code. Goto Scenario builder and select a Functional test Test type.

Add a test case with Java Test type and browse the above created jar file.

Above java code consists of two arguments first with String argument and second with int array argument.

You need to pass the argument in same order in Appvance to run scenario successfully.

Please look at the below screen shot.





Enter 100% logs in Options panel. Save and play the scenario in a controller.