View Javadoc

1   /**
2    * Copyright (c) 2002-2015, JWebUnit team.
3    *
4    * This file is part of JWebUnit.
5    *
6    * JWebUnit is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Lesser General Public License as published by
8    * the Free Software Foundation, either version 3 of the License, or
9    * (at your option) any later version.
10   *
11   * JWebUnit is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public License
17   * along with JWebUnit.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package net.sourceforge.jwebunit.tests;
20  
21  import static net.sourceforge.jwebunit.junit.JWebUnit.assertElementPresent;
22  import static net.sourceforge.jwebunit.junit.JWebUnit.assertFormPresent;
23  import static net.sourceforge.jwebunit.junit.JWebUnit.beginAt;
24  import static net.sourceforge.jwebunit.junit.JWebUnit.setBaseUrl;
25  import static net.sourceforge.jwebunit.junit.JWebUnit.submit;
26  
27  import org.junit.Test;
28  
29  /**
30   * Tests the use of HttpUnit and the types of html documents accepted.
31   */
32  public class HtmlParsingTest extends JWebUnitAPITestCase {
33  
34      public void setUp() throws Exception {
35          super.setUp();
36          setBaseUrl(HOST_PATH + "/HtmlTest/");
37      }
38      
39      @Test public void testSimpleForm() {
40          beginAt("SimpleForm.html");
41          assertFormPresent();
42          submit();
43      }
44  
45      @Test public void testInvalidForm() {
46          beginAt("InvalidForm.html");
47          assertFormPresent();
48          submit();
49      }
50  
51      @Test public void testInvalidFormNoDoctype() {
52          beginAt("InvalidFormNoDoctype.html");
53          assertFormPresent();
54          submit();
55      }    
56  
57      @Test public void testValidComplexForm() {
58          beginAt("ValidComplexForm.html");
59          assertFormPresent();
60          submit();
61      }    
62  
63      @Test public void testValidFormNoDoctype() {
64          beginAt("ValidFormNoDoctype.html");
65          assertFormPresent();
66          submit();
67      }    
68      
69      @Test public void testXhtmlStrict() {
70          beginAt("XhtmlStrict.html");
71          // run a method that gets the DOM
72          assertElementPresent("div1");
73          //TODO This test gives a "org.w3c.dom.DOMException: NOT_SUPPORTED_ERR" with nekohtml 0.9.5 and httpunit
74      }
75  }