org.htmlparser.tests
Class ParserTest

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.htmlparser.tests.ParserTestCase
              extended byorg.htmlparser.tests.ParserTest
All Implemented Interfaces:
junit.framework.Test

public class ParserTest
extends ParserTestCase


Field Summary
 
Fields inherited from class org.htmlparser.tests.ParserTestCase
mLexer, node, nodeCount, parser
 
Constructor Summary
ParserTest(java.lang.String name)
           
 
Method Summary
 void testDifferentLocale()
          See bug #883664 toUpperCase on tag names and attributes depends on locale
 void testDoubleQuotedCharset()
          Test the case of a double quoted charset directive.
 void testElements()
           
 void testElementsFromWeb()
          This testcase needs you to be online.
 void testEmbeddedQuoteSplit()
          See bug #729368 Embedded quote and split tag
 void testFile()
          Tests the 'from file' Parser constructor.
 void testFileDelete()
          Tests deleting a file held open by the parser.
 void testFixSpaces()
           
 void testHTMLCharset()
          Test with a HTML header with a charset parameter not matching the HTTP header.
 void testHTTPCharset()
          Test with a HTTP header with a valid charset parameter.
 void testImageCollection()
           
 void testLinkCollection()
           
 void testNullUrl()
           
 void testOutOfMemory()
          See bug #728241 OutOfMemory error/ Infinite loop
 void testPOST()
          Test the Parser(URLConnection) constructor.
 void testSetInputHTML()
          See bug #826764 ParserException occurs only when using setInputHTML() instea
 void testSetRemarkText()
          See bug #900128 RemarkNode.setText() does not set Text
 void testSetStringText()
          See bug #900128 RemarkNode.setText() does not set Text
 void testSingleQuotedCharset()
          Test the case of a single quoted charset directive.
 void testSwitchCharset()
          Test the case of a charset directive different than the HTTP header.
 void testURLWithSpaces()
           
 void testXMLTypeToString()
          Test reproducing a java.lang.StackOverflowError.
 
Methods inherited from class org.htmlparser.tests.ParserTestCase
assertHiddenIDTagPresent, assertNodeCount, assertNodeCount, assertSameType, assertStringEquals, assertSuperType, assertTagEquals, assertType, assertXmlEquals, createParser, createParser, createParser, createParser, failWithMessage, getParser, main, parse, parseAndAssertNodeCount, parseNodes, removeEscapeCharacters, setParser
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, name, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParserTest

public ParserTest(java.lang.String name)
Method Detail

testElements

public void testElements()
                  throws java.lang.Exception
Throws:
java.lang.Exception

testElementsFromWeb

public void testElementsFromWeb()
                         throws java.lang.Exception
This testcase needs you to be online.

Throws:
java.lang.Exception

testPOST

public void testPOST()
              throws java.lang.Exception
Test the Parser(URLConnection) constructor. This testcase needs you to be online. Based on the form at Canada Post http://www.canadapost.ca/tools/pcl/bin/default-e.asp:
 <form NAME="SearchQuick" method="POST" action="cp_search_response-e.asp"
  onSubmit="return runSubmit();">

 <!-- begin test hidden field code -->
   <input TYPE="Hidden" NAME="app_language" value="english">

   <input TYPE="Hidden" NAME="app_response_start_row_number" value="1">
   <input TYPE="Hidden" NAME="app_response_rows_max" value="9">

   <input TYPE="Hidden" NAME="app_source" value="quick">
   <input TYPE="Hidden" NAME="query_source" value="q">

   <input TYPE="Hidden" NAME="name" value>
   <input TYPE="Hidden" NAME="postal_code" value>
   <input TYPE="Hidden" NAME="directory_area_name" value>

   <input TYPE="Hidden" NAME="delivery_mode" value>
   <input TYPE="Hidden" NAME="Suffix" value>

   <input TYPE="Hidden" NAME="street_direction" value>
   <input TYPE="Hidden" NAME="installation_type" value>
   <input TYPE="Hidden" NAME="delivery_number" value>
   <input TYPE="Hidden" NAME="installation_name" value>
   <input TYPE="Hidden" NAME="unit_number" value>

   <input TYPE="Hidden" NAME="app_state" value="production">
 <!-- end test hidden field code -->

 <p>
   <table border="0" cellpadding="0" width="90%" cellspacing="0">

     <tr>
       <td  class="tbltitle"> Street Number: </td>
       <td class="tbltitle"> Street Name: </td>
       <td class="tbltitle"> Street Type:</td>
     </tr>
     <tr>

       <td>
         <input type="text" name="street_number" size="10" maxlength="10">
       </td>
       <td>
         <input type="text" name="street_name" size="30" maxlength="40">
         <input type="hidden" name="street_type" size="30">
       </td>
       <td><input type="text" name="test" size="10" maxlength="30"></td>
     </tr>

   </table>
 <p>
   <table border="0" cellpadding="0" width="90%" cellspacing="0">
     <tr>
       <td class="tbltitle">
         Municipality (City, Town, etc.):
       </td>
       <td class="tbltitle">
         Province:
       </td>

     </tr>
     <tr>
       <td>
         <input type="text" name="city" size="30" maxlength="30">
       </td>
       <td>
         <select size="1" name="prov">
           <option selected value="NULL">Select</option><option value="AB">AB - Alberta</option><option value="BC">BC - British Columbia</option><option value="MB">MB - Manitoba</option><option value="NB">NB - New Brunswick</option><option value="NL">NL - Newfoundland and Labrador</option><option value="NS">NS - Nova Scotia</option><option value="NT">NT - Northwest Territories</option><option value="NU">NU - Nunavut</option><option value="ON">ON - Ontario</option><option value="PE">PE - Prince Edward Island</option><option value="QC">QC - Quebec</option><option value="SK">SK - Saskatchewan</option><option value="YT">YT - Yukon</option>

         </select>
       </td>
     </tr>
     <tr>
       <td height="10">&nbsp;</td>
       <td>&nbsp;</td>
     </tr>
     <tr>
       <td colspan="2" align="right" nowrap>
     <input type="image" src="images/bb_submit-e.gif" name="Search" border="0" WIDTH="88" HEIGHT="23">
         &nbsp; <a href="#" onclick="javascript:fClearAllFields();"><img src="images/bb_clear_form-e.gif" name="Clear" border="0" WIDTH="88" HEIGHT="23"></a>
    </td>
     </tr>
   </table>
 <p>
 </form>
 
Sumbits the POST and verifies the returned HTML contains an expected value.

Throws:
java.lang.Exception

testFile

public void testFile()
Tests the 'from file' Parser constructor.


testFileDelete

public void testFileDelete()
Tests deleting a file held open by the parser. See bug #1005409 Input file not free by parser


testHTTPCharset

public void testHTTPCharset()
Test with a HTTP header with a valid charset parameter. Here, ibm.co.jp is an example of a HTTP server that correctly sets the charset in the header to match the content encoding.


testHTMLCharset

public void testHTMLCharset()
Test with a HTML header with a charset parameter not matching the HTTP header. Here, www.sony.co.jp is an example of a HTTP server that does not set the charset in the header to match the content encoding. We check that after the enumeration is created, that the charset has changed to the correct value.


testSwitchCharset

public void testSwitchCharset()
                       throws ParserException
Test the case of a charset directive different than the HTTP header. See bug #707447 META TAG - CHARSET and bug #699886 can't parse website other than iso-8859-1

Throws:
ParserException

testDoubleQuotedCharset

public void testDoubleQuotedCharset()
                             throws ParserException
Test the case of a double quoted charset directive. See bug #694477. Technically, this format does not meet the HTTP/1.1 specification in RFC 2068. In this case that I believe that the quotes are being inproperly generated in the header by a server-side web application. Nonetheless, it would be nice to handle this case.

Throws:
ParserException

testSingleQuotedCharset

public void testSingleQuotedCharset()
                             throws ParserException
Test the case of a single quoted charset directive. See bug #694477. Technically, this format does not meet the HTTP/1.1 specification in RFC 2068. In this case that I believe that the quotes are being inproperly generated in the header by a server-side web application. Nonetheless, it would be nice to handle this case.

Throws:
ParserException

testNullUrl

public void testNullUrl()

testURLWithSpaces

public void testURLWithSpaces()
                       throws ParserException
Throws:
ParserException

testLinkCollection

public void testLinkCollection()
                        throws ParserException
Throws:
ParserException

testImageCollection

public void testImageCollection()
                         throws ParserException
Throws:
ParserException

testOutOfMemory

public void testOutOfMemory()
                     throws java.lang.Exception
See bug #728241 OutOfMemory error/ Infinite loop

Throws:
java.lang.Exception

testEmbeddedQuoteSplit

public void testEmbeddedQuoteSplit()
                            throws java.lang.Exception
See bug #729368 Embedded quote and split tag

Throws:
java.lang.Exception

testSetInputHTML

public void testSetInputHTML()
                      throws java.lang.Exception
See bug #826764 ParserException occurs only when using setInputHTML() instea

Throws:
java.lang.Exception

testXMLTypeToString

public void testXMLTypeToString()
                         throws java.lang.Exception
Test reproducing a java.lang.StackOverflowError.

Throws:
java.lang.Exception

testDifferentLocale

public void testDifferentLocale()
                         throws java.lang.Exception
See bug #883664 toUpperCase on tag names and attributes depends on locale

Throws:
java.lang.Exception

testSetStringText

public void testSetStringText()
                       throws java.lang.Exception
See bug #900128 RemarkNode.setText() does not set Text

Throws:
java.lang.Exception

testSetRemarkText

public void testSetRemarkText()
                       throws java.lang.Exception
See bug #900128 RemarkNode.setText() does not set Text

Throws:
java.lang.Exception

testFixSpaces

public void testFixSpaces()
                   throws ParserException
Throws:
ParserException