Skip to content

Instantly share code, notes, and snippets.

@glennschler
Created June 11, 2012 17:40
Show Gist options
  • Save glennschler/2911496 to your computer and use it in GitHub Desktop.
Save glennschler/2911496 to your computer and use it in GitHub Desktop.
I use this OATS OpenScript technique for several advanced script control needs. This example only shows how to stop the "content length is zero" error, though this can be used as a template for any advanced control of virtual users.
package yourcompanyname.oats.scripting.modules.http.api;
import oracle.oats.scripting.modules.basic.api.exceptions.AbstractScriptException;
import oracle.oats.scripting.modules.http.api.HTTPService;
import oracle.oats.scripting.modules.http.api.HTTPService.EncodeOptions;
public class MyHTTPService extends HTTPService
{
private IteratingVUser m_vu = null;
public MyHTTPService()
{
super();
}
/**
* @see oracle.oats.scripting.modules.basic.api.IVUserProvider#setCurrentVUser(oracle.oats.scripting.modules.basic.api.IteratingVUser)
*/
@Override public void setCurrentVUser(IteratingVUser vu)
{
super.setCurrentVUser(vu);
/* Consider this work around to stop those warning while running in OATS OLT Tester
*/
List<IValidator> httpValidators = this.getValidatorList();
for (int i = 0; i < httpValidators.size(); i++)
{
IValidator httpValidator = httpValidators.get(i);
if (httpValidator != null &&
httpValidator.getClass().getName().contains("ZeroLengthContentValidator"))
{
removeValidator(httpValidator);
break;
}
}
....
@glennschler
Copy link
Author

Use this OATS OpenScript technique for several advanced script control needs. In your script, change this:

@ScriptService oracle.oats.scripting.modules.http.api.HTTPService http; 

To this:

@ScriptService yourcompanyname.oats.scripting.modules.http.api.MyHTTPService http;

Then add the above Gist MyHTTPService.java to your OATS OpenScript project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment