Source code

Here is the complete source code for the Custom Virtual User example:

Source code for MyJavaVU

package CustomVUExample;

 

import java.util.*;

 

import MyCompany.JavaThickClient;

 

import com.facilita.fc.runtime.*;

import com.facilita.util.*;

import com.facilita.exception.*;

 

public class MyJavaVU extends com.facilita.fc.runtime.VirtualUser

{

private JavaThickClient javaThickClient;

 

public void login(String username, String password)

{

this.javaThickClient = new JavaThickClient(username, password);

this.javaThickClient.login();

}

 

public void doSomething(String parameter)

{

this.javaThickClient.doSomething(parameter);

}

 

@Override

public void pre() throws Exception

{

//do not remove following line

super.pre();

 

// Put any code that needs to execute at the start of the test here

}

 

@Override

public void post() throws Exception

{

// Put any code that needs to execute at the end of the test here

 

//do not remove following line

super.post();

}

 

@Override

protected boolean onError(String id, String info) throws Exception

{

// This method is called whenever an error occurs

// Returning false from this method will suppress the error in question

return super.onError(id, info);

}

 

@Override

protected boolean onWarn(String id, String info) throws Exception

{

// This method is called whenever a warning occurs

// Returning false from this method will suppress the warning in question

return super.onWarn(id, info);

}

 

@Override

protected boolean onException(Exception e)

{

// This method is called whenever an unhandled exception is thrown by one of your scripts

// Returning false from this method will cause the exception to be ignored

return super.onException(e);

}

}

Source code for MyJavaVUScript

package CustomVUExample;

 

import java.util.*;

 

import com.facilita.fc.runtime.*;

import com.facilita.util.*;

import com.facilita.exception.*;

 

public abstract class MyJavaVUScript extends com.facilita.fc.runtime.VirtualUserScript

{

public void login(String username, String password)

{

getVU().login(username, password);

}

 

public void doSomething(String parameter)

{

getVU().doSomething(parameter);

}

 

@Override

public void pre() throws Exception

{

//do not remove following line

super.pre();

 

// Put any code that needs to execute at the start of the test here

}

 

@Override

public MyJavaVU getVU()

{

return (MyJavaVU)super.getVU();

}

}

Source code for Login script

// Script Generator Version - NOT generated (script specification)

 

package JavaThickClient;

 

import java.util.*;

 

import com.facilita.fc.runtime.*;

import com.facilita.util.*;

import com.facilita.exception.*;

 

public class Login extends CustomVUExample.MyJavaVUScript

{

@Override

public void pre() throws Exception

{

//do not remove following line

super.pre();

}

 

@Override

public void script() throws Exception

{

//TODO Place your script variables here.

 

//TODO Place your iterated script code here.

login(getString("username"), getString("password"));

}

}

Source code for DoSomething script

// Script Generator Version - NOT generated (script specification)

 

package JavaThickClient;

 

import java.util.*;

 

import com.facilita.fc.runtime.*;

import com.facilita.util.*;

import com.facilita.exception.*;

 

public class DoSomething extends CustomVUExample.MyJavaVUScript

{

@Override

public void pre() throws Exception

{

//do not remove following line

super.pre();

}

 

@Override

public void script() throws Exception

{

//TODO Place your script variables here.

 

//TODO Place your iterated script code here.

doSomething(getString("parameter"));

}

}

 

This topic was last updated on January 13, 2022, at 02:42:23 PM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2022 Eggplant