# Array Generator DPL (Test Scenario, Functional Test)

To run Java code with array arguments in Appvance, use the **Array Generator DPL**. To execute Java code that has a `<span class="editor-theme-code">main</span>` method in Scenario Editor, select the **Array Generator DPL** type and `<span class="editor-theme-code">String[]</span>` from the **Actions** dropdown. Add the argument name and pass a value by clicking the **Add Val** link.

The main method receives the array from the generator.

With the **Array Generator DPL**, you can send an array of values as a single parameter containing multiple entries, for example a String array:

```
[ "string1", "string2", "string3" ]
```

This allows you to provide an input parameter for a method that requires an array-like parameter:

```
public void myMethod(String[] args) {
}
```

You can also use Object arrays. Example:

```
[
  { name: 'Honda', models: [
      { name: 'Accord', features: ['2dr', '4dr'] },
      { name: 'CRV', features: ['2dr', 'Hatchback'] },
      { name: 'Pilot', features: ['base', 'superDuper'] }
  ] },
  { name: 'Toyota', models: [
      { name: 'Prius', features: ['green', 'superGreen'] },
      { name: 'Camry', features: ['sporty', 'square'] },
      { name: 'Corolla', features: ['cheap', 'superFly'] }
  ] }
]
```

Types available for arrays: `<span class="editor-theme-code">Object</span>`, `<span class="editor-theme-code">String</span>`, `<span class="editor-theme-code">Integer</span>`, `<span class="editor-theme-code">int</span>`, `<span class="editor-theme-code">Byte</span>`, `<span class="editor-theme-code">byte</span>`, `<span class="editor-theme-code">Double</span>`, `<span class="editor-theme-code">double</span>`, `<span class="editor-theme-code">Short</span>`, `<span class="editor-theme-code">short</span>`, `<span class="editor-theme-code">Float</span>`, `<span class="editor-theme-code">float</span>`, `<span class="editor-theme-code">Character</span>`, `<span class="editor-theme-code">Boolean</span>`.

## Sample Java Code with an 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 from the Java code above. Go to Scenario Editor and select the **Functional Test** test type. Add a test case using the **Java Test** type and browse to the `<span class="editor-theme-code">.jar</span>` file you created. The code above takes two arguments: the first is a `<span class="editor-theme-code">String</span>`, and the second is an `<span class="editor-theme-code">int</span>` array. Pass the arguments in the same order in Appvance so the scenario runs successfully.

**Two arguments using array generator**

Set the log level to 100% in the Options panel. Save and play the scenario in a Controller window.

**Output:**

```
Two arguments using array generator
```

---

If you have any feedback on this topic, please contact us at <documentation@appvance.ai>

Last updated: October 15, 2026