Two Laptop Bag*
The moose likes IDEs, Version Control and other tools and the fly likes Junit / httpunit questions. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Junit / httpunit questions. " Watch "Junit / httpunit questions. " New topic
Author

Junit / httpunit questions.

Carl Parrish
Ranch Hand

Joined: May 03, 2002
Posts: 60
I'm not sure this is the correct group but so far this seems to be the closest to what I'm looking for. I have some httpunit questions. Should I post them here?
Carl Parrish
Ranch Hand

Joined: May 03, 2002
Posts: 60
Here is my code. It shouldn't be passing but it is. any ideas why?
<pre>
public void TestLink()throws Exception {

WebResponse resp = null;
WebLink link = null;
WebRequest req = null;
WebResponse addMember = null;
String linkValue = " ";
try {
resp = wc.getResponse( url );
link = resp.getLinkWith("click here");
linkValue = link.getURLString();

}
catch (java.net.MalformedURLException e) {
System.out.println("Bad url: " + e);
} catch (java.io.IOException e) {
System.out.println("IO Err: " + e);
} catch (org.xml.sax.SAXException e) {
System.out.println("XML Err: " + e);
}
addMember = wc.getResponse(linkValue);

assertEquals(200, addMember.getResponseCode());
}
</pre>

(reformatted by moderator for clarity)
[ May 15, 2002: Message edited by: Junilu Lacar ]
Carl Parrish
Ranch Hand

Joined: May 03, 2002
Posts: 60
Okay addMember should be addMeberPage. And I'm beginning to think that its a ant issue. This is the first time I'm trying to build my test suite from ant. and it doesn't seem to be getting the exceptions.
Carl Parrish
Ranch Hand

Joined: May 03, 2002
Posts: 60
Okay I stopped throwing the Exceptions and wrapped everything in a try catch block. I also renamed the method 'testLink' instead of 'TestLink' but it still says
"variable addMemberPage might not have been initialized"

Any idea why not?
Carl Parrish
Ranch Hand

Joined: May 03, 2002
Posts: 60
Okay I figured it out. I had to set addMemberPage to null at the top first.
So now I have a new question.
do I have to do anything special to create a https link? So for instance if I have this.

And link is of the form "https://myURLhere.com" should that work?? Right now I'm getting a 404 error even though its working on my browser.
Carl Parrish
Ranch Hand

Joined: May 03, 2002
Posts: 60
Okay from the sourceforge site I found that to get https working you have to set the following java system property.
-Djava.protocol.handler.pkgs=com.sun.net.ssl.internal.www.protocol
Which would be fine if I knew how to set a java system property from within ant. If anyone knows please share, else I'll share when I figure it out.
Carl P.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Carl Parrish:
I'm not sure this is the correct group but so far this seems to be the closest to what I'm looking for. I have some httpunit questions. Should I post them here?

The "IDE's and other tools" forum might be more appropriate...
Regards, Ilja


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Carl Parrish
Ranch Hand

Joined: May 03, 2002
Posts: 60
hmmmm httpunit is a unit testing suite ala junit.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Carl Parrish:
hmmmm httpunit is a unit testing suite ala junit.

Yes, I know. There are frequently JUnit questions posted (and answered) in the "IDE's and other tools" forum. After all, it is a testing tool, isn't it?
Carl Parrish
Ranch Hand

Joined: May 03, 2002
Posts: 60
Okay then can a modirator move the discussion over there? For the archives I want to post what I've found about posting java system properties via ant (from a nice javaranch member)
Here is a snip from my build.xml file
[snip]
<!-- =================================================================== -->
<!-- Runs the test code -->
<!-- =================================================================== -->
<target name="test" depends="compile">
<echo message="Starting HTTP Test (in separate VM)" />
<java classname="HTTPTest" fork="yes" >
<classpath>
<path refid="base.classpath" />
<pathelement location="${classes.dir}" />
<pathelement location="${classpath}" />
</classpath>
<jvmarg value="-Djava.protocol.handler.pkgs=com.sun.net.ssl.internal.www.protocol" />
</java>
</target>
[/snip]
Carl Parrish
Ranch Hand

Joined: May 03, 2002
Posts: 60
But this still doesn't seem to resolve my https problem so if anyone have any advise please share.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Did you take a look at http://httpunit.sourceforge.net/doc/sslfaq.html ?
Carl Parrish
Ranch Hand

Joined: May 03, 2002
Posts: 60
thanks, this was helpful but I still can't seem to get it working. My server has a thawte ca so I think I should be fine there (it in some funkcy .pfx format so I can't add it anyways). And I installed jsse. But I still get a 404 error While trying to access the page.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Junit / httpunit questions.