tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: Testing woes - please help!!
Date Thu, 16 Nov 2000 18:44:29 GMT
Mike La Budde wrote:

> I'm trying to slice up the GTest.java ant task that comes with the tomcat
> distribution. Since we are using struts and placing some things in the
> session (tho' we try to minimize that) any of my actions/pages I request
> that rely on stuff being in the session error out.
>
> What I was hoping to do was create a new ant task(def), let's call this
> testcase, and the gtest task becomes a nested subtask. This way I could
> open the socket/connection in the testcase and just reuse it in the gtest
> subtask. Good thought, but it doesn't work. The first gtest task works, but
> all subsequent ones fail (the response is always null). Naturally, socket
> programming is not something I've done before and I was hoping there would
> be an easier way.
>

You are probably running into the fact that HTTP/1.0 is a request-response
protocol.  If you want to reuse an existing socket, you need to set the
appropriate HTTP headers for persistent connections, and the server needs to
support them.

>
> So, where to from here?
>
> 1) Can somebody offer pointers on socket programming?
>
> 2) Is there a better way? (What are others doing to test their webapps?)
>

You might want to look at using a URLConnection instead.  In particular, since
you will be talking to an "http:" type URL, you can cast the URLConnection
object you get back to HttpURLConnection so that you can do things like set the
request type to POST (for example).  There's some simple examples of using
URLConnection in the Networking Trail of the Java Language Tutorial
<http://java.sun.com/docs/books/tutorial>, or you can do searches for
URLConnection in the archives (or various search engines) to find out more.

>
> 3) Is there documentation on using the JUnit ant task? And documentation on
> JUnit itself?
>
> Thanks in advance,
>
> Mike

Craig McClanahan



Mime
View raw message