Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Junit / httpunit questions.

 
Carl Parrish
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Carl Parrish
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmmm httpunit is a unit testing suite ala junit.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But this still doesn't seem to resolve my https problem so if anyone have any advise please share.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you take a look at http://httpunit.sourceforge.net/doc/sslfaq.html ?
 
Carl Parrish
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic