Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Test and Performance Tools Platform (TPTP) » testing tools : java.lang.NumberFormatException: For input string: "p"
testing tools : java.lang.NumberFormatException: For input string: "p" [message #63792] Tue, 04 April 2006 12:47 Go to next message
Eclipse UserFriend
Originally posted by: anthonycrowtheralwyn.hotmail.com

Hey everyone,

Since I've moved from Tomcat 4 to Tomcat 5, I can record but I can't run
my TPTP tests anymore without having a java.lang.NumberFormatException.

Here's my configuration :
Eclipse 3.2 M5
JDK 1.5.0_06
Tomcat 5.5.15

Here's one of the JUnits that fails, it only tries to connect to a page at
the address "/TOK/PAT.do?enter=1"
When debbuging, it stops at line "executeRequest(request);"
in Recording.c1GETLocalhost()
saying java.lang.NumberFormatException: For input string: "p"
The variable causing that is the integer "rc". It's value is -1 instead of
a normal integer... I can't go deeper in the code because it's in
http.runner.jar.

JUnit :
------------------------------------------------------------ ----------------
package test;

import java.util.Random;

import junit.extensions.RepeatedTest;

import junit.framework.Test;

import org.eclipse.hyades.test.common.junit.DefaultTestArbiter;
import org.eclipse.hyades.test.common.junit.HyadesTestCase;
import org.eclipse.hyades.test.common.junit.HyadesTestSuite;

import org.eclipse.hyades.test.http.runner.HttpCookieCache;
import org.eclipse.hyades.test.http.runner.HttpExecutor;
import org.eclipse.hyades.test.http.runner.HttpHeader;
import org.eclipse.hyades.test.http.runner.HttpRequest;
import org.eclipse.hyades.test.http.runner.HttpResponse;

import org.eclipse.hyades.test.http.runner.internal.util.HttpTestUt il;

/**
* Generated code for the test suite <b>recording</b> located at
* <i>/Servers/recording.testsuite</i>.
*/
public class Recording extends HyadesTestCase {
/**
* Constructor for Recording.
* @param name
*/
public Recording(String name) {
super(name);
}

/**
* Returns the JUnit test suite that implements the <b>recording</b>
* definition.
*/
public static Test suite() {
HyadesTestSuite recording = new HyadesTestSuite("recording");
recording.setArbiter(DefaultTestArbiter.INSTANCE).setId(
"DCD296796B927EB81AA5C4A0C3D611DA");

HyadesTestSuite loop1 = new HyadesTestSuite("Loop 1");
recording.addTest(new RepeatedTest(loop1, 1));
loop1.setId("DCD296796B927EB81AA5C4A4C3D611DA");

HyadesTestSuite pageLocalhost_TOK_PAT_do_enter_1 = new HyadesTestSuite(
"Page localhost/TOK/PAT.do?enter=1");
loop1.addTest(new RepeatedTest(pageLocalhost_TOK_PAT_do_enter_1, 1));
pageLocalhost_TOK_PAT_do_enter_1
.setId("DCD296796B927EB81AA835A0C3D611DA");

pageLocalhost_TOK_PAT_do_enter_1
.addTest(new Recording("c1GETLocalhost")
.setId("DCD296796B927EB81AAAA6A0C3D611DA")
.setTestInvocationId("DCD296796B927EB81AAAA6A4C3D611DA"));

return recording;
}

/**
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
}

/**
* @see junit.framework.TestCase#tearDown()
*/
protected void tearDown() throws Exception {
}

/**
* 1 GET localhost
* @throws Exception
*/
public void c1GETLocalhost() throws Exception {
HttpRequest request = new HttpRequest();
request.setMethod("GET");
request.setVersion("1.1");
request.setHost("localhost");
request.setPort(8000);
request.setAbsolutePath("/TOK/PAT.do?enter=1");
request.setPageNumber(1);
request.setPageOrder(HttpRequest.PAGE_START);
request.setSecure(false);

HttpHeader header;
header = new HttpHeader();
header.setName("Accept");
header
.setValue("image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, */*");
request.addHeader(header);

header = new HttpHeader();
header.setName("Accept-Language");
header.setValue("fr");
request.addHeader(header);

header = new HttpHeader();
header.setName("Accept-Encoding");
header.setValue("gzip, deflate");
request.addHeader(header);

header = new HttpHeader();
header.setName("User-Agent");
header
.setValue("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
NET CLR 1.1.4322)");
request.addHeader(header);

header = new HttpHeader();
header.setName("Host");
header.setValue("localhost:8000");
request.addHeader(header);

header = new HttpHeader();
header.setName("Connection");
header.setValue("Keep-Alive");
request.addHeader(header);

executeRequest(request);
}

/*********************
* Member variables *
*********************/
static protected HttpCookieCache[] m_httpCookieCache;

static protected HttpExecutor[] m_httpExecutor;

protected Random rand = new Random();

/*********************
* Extra Methods *
*********************/
public void populateCookieCache(HttpCookieCache cookies) {
//By default, the cookie cache is created empty. To add new cookies,
use the following
//cookies.AddCookie(name, value, domain, path, expires, bSecure);
}

protected void executeRequest(HttpRequest request) throws Exception {
if (m_httpExecutor == null || m_httpCookieCache == null)
initializeTest();

int nUser = HttpTestUtil.getCurrentUser(this);
m_httpCookieCache[nUser].DynamicGetCookie(request);
HttpResponse response = m_httpExecutor[nUser].execute(request);

String text = "rc=" + Integer.toString(response.getCode());
if (response.getDetail() != null)
text = "\n\n" + response.getDetail();

//If (response.getCode() < 0) then there was an error when executing the
request
if (response.getCode() < 0)
throw new Exception(text);

try {
m_httpCookieCache[nUser].DynamicSetCookie(request, response);
} catch (Exception e) {
}

//If (response.getCode() < 400) then the request has failed.
assertTrue(text, response.getCode() < 400 && response.getCode() > 0);
}

synchronized protected void initializeTest() {
int nTotal = HttpTestUtil.getTotalUsers(this);
if (m_httpCookieCache == null) {
m_httpCookieCache = new HttpCookieCache[nTotal];
for (int i = 0; i < nTotal; i++) {
m_httpCookieCache[i] = new HttpCookieCache();
populateCookieCache(m_httpCookieCache[i]);
}

}
if (m_httpExecutor == null) {
m_httpExecutor = new HttpExecutor[nTotal];
for (int i = 0; i < nTotal; i++) {
m_httpExecutor[i] = new HttpExecutor();
}
}
}

protected long calcThinkTime(long think, int var) {
if (var > 0 && var <= 99) {
long delta = think * var / 100;
if (delta <= 0)
delta = 1;
think += (rand.nextInt((int) delta * 2) - delta);
}
return think;
}
}

------------------------------------------------------------ ----------------

Thanks by advance for your help!

Anthony Crowther-Alwyn
Re: testing tools : java.lang.NumberFormatException: For input string: "p" [message #64083 is a reply to message #63792] Tue, 04 April 2006 21:38 Go to previous messageGo to next message
Randy D. Smith is currently offline Randy D. SmithFriend
Messages: 394
Registered: July 2009
Senior Member
Anthony Crowther-Alwyn wrote:
> Hey everyone,
>
> Since I've moved from Tomcat 4 to Tomcat 5, I can record but I can't
> run my TPTP tests anymore without having a java.lang.NumberFormatException.
> Here's my configuration : Eclipse 3.2 M5
> JDK 1.5.0_06
> Tomcat 5.5.15

You did mean Eclipse 3.2 M5*a*, right? And you're using TPTP 4.2M5 with
that? if you're using an earlier TPTP, you'll need to go back to the
Ecilpse that works with that. If you're using this newer TPTP, you'll
need to make sure you have the *a* version of the Eclipse.

--
RDS

Randy D. Smith randy (dot) d (dot) smith (at) intel (dot) com
Eclipse TPTP Committer, Platform Proj (data collection/agent controller)
Re: testing tools : java.lang.NumberFormatException: For input string: "p" [message #64296 is a reply to message #63792] Wed, 05 April 2006 11:22 Go to previous message
Paul Slauenwhite is currently offline Paul SlauenwhiteFriend
Messages: 975
Registered: July 2009
Senior Member
Hi Anthony,
This appears to be a defect. Please open a TPTP Bugzilla for this issue
with Tomcat V5.x. However, if you do not have a lot of custom code in your
JUnit test class, try re-recording the test using Tomcat V5.x.

Paul
"Anthony Crowther-Alwyn" <anthonycrowtheralwyn@hotmail.com> wrote in message
news:9fb2397095c219aeb394ddda92be5404$1@www.eclipse.org...
> Hey everyone,
>
> Since I've moved from Tomcat 4 to Tomcat 5, I can record but I can't run
> my TPTP tests anymore without having a java.lang.NumberFormatException.
>
> Here's my configuration :
> Eclipse 3.2 M5
> JDK 1.5.0_06
> Tomcat 5.5.15
>
> Here's one of the JUnits that fails, it only tries to connect to a page at
> the address "/TOK/PAT.do?enter=1"
> When debbuging, it stops at line "executeRequest(request);"
> in Recording.c1GETLocalhost()
> saying java.lang.NumberFormatException: For input string: "p"
> The variable causing that is the integer "rc". It's value is -1 instead of
> a normal integer... I can't go deeper in the code because it's in
> http.runner.jar.
>
> JUnit :
> ------------------------------------------------------------ --------------
--
> package test;
>
> import java.util.Random;
>
> import junit.extensions.RepeatedTest;
>
> import junit.framework.Test;
>
> import org.eclipse.hyades.test.common.junit.DefaultTestArbiter;
> import org.eclipse.hyades.test.common.junit.HyadesTestCase;
> import org.eclipse.hyades.test.common.junit.HyadesTestSuite;
>
> import org.eclipse.hyades.test.http.runner.HttpCookieCache;
> import org.eclipse.hyades.test.http.runner.HttpExecutor;
> import org.eclipse.hyades.test.http.runner.HttpHeader;
> import org.eclipse.hyades.test.http.runner.HttpRequest;
> import org.eclipse.hyades.test.http.runner.HttpResponse;
>
> import org.eclipse.hyades.test.http.runner.internal.util.HttpTestUt il;
>
> /**
> * Generated code for the test suite <b>recording</b> located at
> * <i>/Servers/recording.testsuite</i>.
> */
> public class Recording extends HyadesTestCase {
> /**
> * Constructor for Recording.
> * @param name
> */
> public Recording(String name) {
> super(name);
> }
>
> /**
> * Returns the JUnit test suite that implements the <b>recording</b>
> * definition.
> */
> public static Test suite() {
> HyadesTestSuite recording = new HyadesTestSuite("recording");
> recording.setArbiter(DefaultTestArbiter.INSTANCE).setId(
> "DCD296796B927EB81AA5C4A0C3D611DA");
>
> HyadesTestSuite loop1 = new HyadesTestSuite("Loop 1");
> recording.addTest(new RepeatedTest(loop1, 1));
> loop1.setId("DCD296796B927EB81AA5C4A4C3D611DA");
>
> HyadesTestSuite pageLocalhost_TOK_PAT_do_enter_1 = new HyadesTestSuite(
> "Page localhost/TOK/PAT.do?enter=1");
> loop1.addTest(new RepeatedTest(pageLocalhost_TOK_PAT_do_enter_1, 1));
> pageLocalhost_TOK_PAT_do_enter_1
> .setId("DCD296796B927EB81AA835A0C3D611DA");
>
> pageLocalhost_TOK_PAT_do_enter_1
> .addTest(new Recording("c1GETLocalhost")
> .setId("DCD296796B927EB81AAAA6A0C3D611DA")
> .setTestInvocationId("DCD296796B927EB81AAAA6A4C3D611DA"));
>
> return recording;
> }
>
> /**
> * @see junit.framework.TestCase#setUp()
> */
> protected void setUp() throws Exception {
> }
>
> /**
> * @see junit.framework.TestCase#tearDown()
> */
> protected void tearDown() throws Exception {
> }
>
> /**
> * 1 GET localhost
> * @throws Exception
> */
> public void c1GETLocalhost() throws Exception {
> HttpRequest request = new HttpRequest();
> request.setMethod("GET");
> request.setVersion("1.1");
> request.setHost("localhost");
> request.setPort(8000);
> request.setAbsolutePath("/TOK/PAT.do?enter=1");
> request.setPageNumber(1);
> request.setPageOrder(HttpRequest.PAGE_START);
> request.setSecure(false);
>
> HttpHeader header;
> header = new HttpHeader();
> header.setName("Accept");
> header
> .setValue("image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
> application/x-shockwave-flash, application/vnd.ms-excel,
> application/vnd.ms-powerpoint, application/msword, */*");
> request.addHeader(header);
>
> header = new HttpHeader();
> header.setName("Accept-Language");
> header.setValue("fr");
> request.addHeader(header);
>
> header = new HttpHeader();
> header.setName("Accept-Encoding");
> header.setValue("gzip, deflate");
> request.addHeader(header);
>
> header = new HttpHeader();
> header.setName("User-Agent");
> header
> .setValue("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
> NET CLR 1.1.4322)");
> request.addHeader(header);
>
> header = new HttpHeader();
> header.setName("Host");
> header.setValue("localhost:8000");
> request.addHeader(header);
>
> header = new HttpHeader();
> header.setName("Connection");
> header.setValue("Keep-Alive");
> request.addHeader(header);
>
> executeRequest(request);
> }
>
> /*********************
> * Member variables *
> *********************/
> static protected HttpCookieCache[] m_httpCookieCache;
>
> static protected HttpExecutor[] m_httpExecutor;
>
> protected Random rand = new Random();
>
> /*********************
> * Extra Methods *
> *********************/
> public void populateCookieCache(HttpCookieCache cookies) {
> //By default, the cookie cache is created empty. To add new cookies,
> use the following
> //cookies.AddCookie(name, value, domain, path, expires, bSecure);
> }
>
> protected void executeRequest(HttpRequest request) throws Exception {
> if (m_httpExecutor == null || m_httpCookieCache == null)
> initializeTest();
>
> int nUser = HttpTestUtil.getCurrentUser(this);
> m_httpCookieCache[nUser].DynamicGetCookie(request);
> HttpResponse response = m_httpExecutor[nUser].execute(request);
>
> String text = "rc=" + Integer.toString(response.getCode());
> if (response.getDetail() != null)
> text = "\n\n" + response.getDetail();
>
> //If (response.getCode() < 0) then there was an error when executing the
> request
> if (response.getCode() < 0)
> throw new Exception(text);
>
> try {
> m_httpCookieCache[nUser].DynamicSetCookie(request, response);
> } catch (Exception e) {
> }
>
> //If (response.getCode() < 400) then the request has failed.
> assertTrue(text, response.getCode() < 400 && response.getCode() > 0);
> }
>
> synchronized protected void initializeTest() {
> int nTotal = HttpTestUtil.getTotalUsers(this);
> if (m_httpCookieCache == null) {
> m_httpCookieCache = new HttpCookieCache[nTotal];
> for (int i = 0; i < nTotal; i++) {
> m_httpCookieCache[i] = new HttpCookieCache();
> populateCookieCache(m_httpCookieCache[i]);
> }
>
> }
> if (m_httpExecutor == null) {
> m_httpExecutor = new HttpExecutor[nTotal];
> for (int i = 0; i < nTotal; i++) {
> m_httpExecutor[i] = new HttpExecutor();
> }
> }
> }
>
> protected long calcThinkTime(long think, int var) {
> if (var > 0 && var <= 99) {
> long delta = think * var / 100;
> if (delta <= 0)
> delta = 1;
> think += (rand.nextInt((int) delta * 2) - delta);
> }
> return think;
> }
> }
>
> ------------------------------------------------------------ --------------
--
>
> Thanks by advance for your help!
>
> Anthony Crowther-Alwyn
>
>
Previous Topic:RAServer failed to start 2
Next Topic:TPTP and 3.2 M6
Goto Forum:
  


Current Time: Thu May 09 19:42:06 GMT 2024

Powered by FUDForum. Page generated in 0.03441 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top