Update of /cvsroot/jwebunit/jWebUnit/fitplugin/test/net/sourceforge/jwebunit/fit
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27741/fitplugin/test/net/sourceforge/jwebunit/fit

Modified Files:
        WebFixtureTest.java 
Added Files:
        RunSite.java 
Log Message:
Added executable class that runs the sample site. Added maven task to run that 
class. Replaced the old bat file so that the classpath can be managed by maven.

Index: WebFixtureTest.java
===================================================================
RCS file: 
/cvsroot/jwebunit/jWebUnit/fitplugin/test/net/sourceforge/jwebunit/fit/WebFixtureTest.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** WebFixtureTest.java 5 Jan 2006 07:23:53 -0000       1.26
--- WebFixtureTest.java 5 Jan 2006 09:05:47 -0000       1.27
***************
*** 69,78 ****
      public void testFixtureStart() throws Exception {
          WebFixture fixture = new WebFixture();
!         fixture.setBaseUrl("http://"; + JETTY_HOST + ":" + getJettyPort());
          WebTester tester = WebFixture.tester;
!         tester.beginAt("index.html");
          tester.assertTitleEquals("Test root");
      }
  
      public void testWebFixture() throws Exception {
          // avoid the need of the system property, always use .fit files for 
input
--- 69,82 ----
      public void testFixtureStart() throws Exception {
          WebFixture fixture = new WebFixture();
!         fixture.setBaseUrl(getApplicationRootUrl());
          WebTester tester = WebFixture.tester;
!         tester.beginAt("readme.html");
          tester.assertTitleEquals("Test root");
      }
  
+     protected String getApplicationRootUrl() {
+         return "http://"; + JETTY_HOST + ":" + getJettyPort();
+     }
+ 
      public void testWebFixture() throws Exception {
          // avoid the need of the system property, always use .fit files for 
input
***************
*** 112,116 ****
          HttpContext context = server.addContext(JETTY_CONTEXT);
          setUpPathToStaticContents(context);
!         if (!context.getResource("index.html").exists()) {
              // allow the test to run from parent project
              testRoot = PLUGIN_FOLDER + testRoot;
--- 116,120 ----
          HttpContext context = server.addContext(JETTY_CONTEXT);
          setUpPathToStaticContents(context);
!         if (!context.getResource("readme.html").exists()) {
              // allow the test to run from parent project
              testRoot = PLUGIN_FOLDER + testRoot;
***************
*** 118,123 ****
          }
          // check that the context root contains the web pages
!         assertTrue("Should find index.html in the configured jetty context: " 
+ context.getResourceBase(),
!                 context.getResource("index.html").exists());
          setUpContextHandlers(context);
      }
--- 122,127 ----
          }
          // check that the context root contains the web pages
!         assertTrue("Should find readme.html in the configured jetty context: 
" + context.getResourceBase(),
!                 context.getResource("readme.html").exists());
          setUpContextHandlers(context);
      }

--- NEW FILE: RunSite.java ---
package net.sourceforge.jwebunit.fit;

/**
 * Application that runs the sample site, useful when developing tests.
 */
public class RunSite {

    static WebFixtureTest test = null;
    
    /**
     * Run the sample web application that the test cases use.
     * @param args
     * @throws Exception 
     */
    public static void main(String[] args) {
        test = new WebFixtureTest("site");
        try {
            test.setUp();
            test.testFixtureStart();
            print("Site started at: " + test.getApplicationRootUrl());
            waitForClose(); 
        } catch (Exception e) {
            e.printStackTrace();
            print("Could not run the site. Error: " + e.getMessage());
        } finally {
            try {
                test.tearDown();
                test = null;
            } catch (Exception e) {
                print("Could not stop the site. Error: " + e.getMessage());
            }
        }
    }

    private static void print(String msg) {
        System.out.println(msg);
    }

    private static void waitForClose() {
        print("Press any key or close window to stop the sample site.");
        try {
            System.in.read();
            print("Key pressed. Shutting down jetty.");
        } catch (java.io.IOException e) {
            e.printStackTrace();
        }
    }

    protected void finalize() throws Throwable {
        if (test != null) {
            test.tearDown();
        }
        super.finalize();
    }

}



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Jwebunit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to