[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit/applet AppletTest.java,1.1,1.2
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-11-15 05:43:41
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/applet
In directory usw-pr-cvs1:/tmp/cvs-serv27410/test/com/meterware/httpunit/applet
Modified Files:
AppletTest.java
Log Message:
support applet load, find, show-document
Index: AppletTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/applet/AppletTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AppletTest.java 12 Nov 2002 13:41:54 -0000 1.1
+++ AppletTest.java 15 Nov 2002 00:07:33 -0000 1.2
@@ -25,6 +25,8 @@
import com.meterware.httpunit.WebApplet;
import java.applet.Applet;
+import java.util.Enumeration;
+import java.net.URL;
import junit.textui.TestRunner;
import junit.framework.TestSuite;
@@ -94,7 +96,59 @@
public void testAppletLoading() throws Exception {
+ defineWebPage( "start", "<applet code='" + SimpleApplet.class.getName() +
+ ".class' codebase=/classes width=100 height=100></applet>");
+ mapToClasspath( "/classes" );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/start.html" );
+ WebApplet wa = response.getApplets()[0];
+ Applet applet = wa.getApplet();
+ assertNotNull( "Applet was not loaded", applet );
+ assertEquals( "Applet class", SimpleApplet.class.getName(), applet.getClass().getName() );
+ }
+
+
+ public void testAppletFindFromApplet() throws Exception {
+ defineWebPage( "start", "<applet name=first code='" + SimpleApplet.class.getName() +
+ ".class' codebase=/classes width=100 height=100></applet>" +
+ "<applet name=second code='" + SecondApplet.class.getName() +
+ ".class' codebase=/classes width=100 height=100></applet>");
+ mapToClasspath( "/classes" );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/start.html" );
+ Applet applet = response.getApplets()[0].getApplet();
+ Applet applet2 = applet.getAppletContext().getApplet( "second" );
+ assertNotNull( "Applet was not loaded", applet2 );
+ assertEquals( "Applet class", SecondApplet.class.getName(), applet2.getClass().getName() );
+
+ Enumeration applets = applet2.getAppletContext().getApplets();
+ assertNotNull( "No applet enumeration returned", applets );
+ assertTrue( "No applets in enumeration", applets.hasMoreElements() );
+ assertTrue( "First is not an applet", applets.nextElement() instanceof Applet );
+ assertTrue( "Only one applet in enumeration", applets.hasMoreElements() );
+ assertTrue( "Second is not an applet", applets.nextElement() instanceof Applet );
+ assertFalse( "More than two applets enumerated", applets.hasMoreElements() );
+ }
+
+
+ public void testShowDocument() throws Exception {
+ defineResource( "next.html", "You made it!" );
+ defineWebPage( "start", "<applet code='" + SimpleApplet.class.getName() +
+ ".class' codebase=/classes width=100 height=100></applet>");
+ mapToClasspath( "/classes" );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/start.html" );
+ WebApplet wa = response.getApplets()[0];
+ Applet applet = wa.getApplet();
+ applet.getAppletContext().showDocument( new URL( getHostPath() + "/next.html" ) );
+ assertEquals( "current page URL", getHostPath() + "/next.html", wc.getCurrentPage().getURL().toExternalForm() );
+ }
+
+
+ public static class SimpleApplet extends Applet {
+ }
+ public static class SecondApplet extends Applet {
}
}
|