Passage de paramètres à la méthode callScript

Cette rubrique décrit comment utiliser les différentes signatures de la méthode callScript pour passer des données d'un script à un autre. L'exemple sur lequel elle s'appuie utilise deux scripts Functional Tester distincts :

callScript("TheCalled");

String[] dataToPass = new String[4];
...

callScript("TheCalled",dataToPass);

Object[] objdataToPass = new Object[4];
...

callScript("TheCalled",objdataToPass);

Le script TheCaller a été enregistré comme suit :

import resources TheCallerHelper;

/**
* Description : Functional Test Script
* @author Administrator
*/

public class TheCaller extends TheCallerHelper
{
/**
* Script Name : <b>TheCaller</b>
* Generated : <b>Dec 17, 2002 8:47:45 PM</b>
* Modified : <b>Dec 17, 2002 8:47:45 PM</b>
* Description : Functional Test Script
* Original Host : WinNT Version 5.0 Build 2195 (Service Pack 2)
*
* @since 2002/12/17
* @author Administrator
*/
public void testMain (Object[] args)
{

callScript("TheCalled");

String[] dataToPass = new String[4];
dataToPass[0] = "this";
dataToPass[1] = "is";
dataToPass[2] = "really";
dataToPass[3] = "cool";

callScript("TheCalled",dataToPass);

Object[] objdataToPass = new Object[4];
objdataToPass[0] = new String("Thought the previous was cool?");
objdataToPass[1] = "Take this one!";
objdataToPass[2] = new Float(0.02);
objdataToPass[3] = new Integer(4711);

callScript("TheCalled",objdataToPass);
}
}

Le script TheCalled utilise une boucle simple pour imprimer les paramètres reçus sur le flux System.out :

import resources.TheCalledHelper;

/**
* Description : Functional Test Script
* @author Administrator
*/

public class TheCalled extends TheCalledHelper
{
/**
* Script Name : <b>TheCalled</b>
* Generated : <b>Dec 17, 2002 8:48:12 PM</b>
* Modified : <b>Dec 17, 2002 8:48:12 PM</b>
* Description : Functional Test Script
* Original Host : WinNT Version 5.0 Build 2195 (Service Pack 2)
*
* @since 2002/12/17
* @author Administrator
*/
public void testMain (Object[] args)
{
if (args.length < 1)
{
System.out.println( "Expected at least 1 arg, but I got: "+args.length);
return;
}
else
{
System.out.println( "Got: "+args.length+" args");
};

for (int i = 0; i < args.length; ++i)
{
System.out.println( " arg["+i+"] = "+args[i]);
}
}
}

 

Conditions d'utilisation | Appréciations en retour
(C) Copyright IBM Corporation 2002, 2004. All Rights Reserved.