Java Doc for WebTestCase.java in  » Testing » htmlunit » com » gargoylesoftware » htmlunit » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » htmlunit » com.gargoylesoftware.htmlunit 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


com.gargoylesoftware.htmlunit.WebTestCase

All known Subclasses:   com.gargoylesoftware.htmlunit.javascript.host.ScreenTest,  com.gargoylesoftware.htmlunit.libraries.GWT14Test,  com.gargoylesoftware.htmlunit.html.FocusableElementTest,  com.gargoylesoftware.htmlunit.javascript.host.LabelTest,  com.gargoylesoftware.htmlunit.html.HtmlElementTest,  com.gargoylesoftware.htmlunit.javascript.AttributeCaseTest,  com.gargoylesoftware.htmlunit.javascript.host.MimeTypeTest,  com.gargoylesoftware.htmlunit.html.ClickableElementTest,  com.gargoylesoftware.htmlunit.util.WebConnectionWrapperTest,  com.gargoylesoftware.htmlunit.javascript.HTMLCollectionTest,  com.gargoylesoftware.htmlunit.html.HtmlAnchorTest,  com.gargoylesoftware.htmlunit.javascript.host.MouseEventTest,  com.gargoylesoftware.htmlunit.javascript.host.XMLSerializerTest,  com.gargoylesoftware.htmlunit.html.HtmlSubmitInputTest,  com.gargoylesoftware.htmlunit.html.HtmlTableRowTest,  com.gargoylesoftware.htmlunit.DefaultCredentialsProviderTest,  com.gargoylesoftware.htmlunit.javascript.host.UIEventTest,  com.gargoylesoftware.htmlunit.javascript.host.InputTest,  com.gargoylesoftware.htmlunit.javascript.host.DOMParserTest,  com.gargoylesoftware.htmlunit.javascript.host.XMLHttpRequestTest,  com.gargoylesoftware.htmlunit.html.AttributesTest,  com.gargoylesoftware.htmlunit.ScriptExceptionTest,  com.gargoylesoftware.htmlunit.html.DomTextTest,  com.gargoylesoftware.htmlunit.CacheTest,  com.gargoylesoftware.htmlunit.html.HtmlSelectTest,  com.gargoylesoftware.htmlunit.html.HtmlStyleTest,  com.gargoylesoftware.htmlunit.javascript.JavaScriptEngineTest,  com.gargoylesoftware.htmlunit.javascript.host.HTMLElementTest,  com.gargoylesoftware.htmlunit.javascript.host.FormTest,  com.gargoylesoftware.htmlunit.IncorrectnessListenerTest,  com.gargoylesoftware.htmlunit.DefaultPageCreatorTest,  com.gargoylesoftware.htmlunit.html.DisabledElementTest,  com.gargoylesoftware.htmlunit.javascript.host.PopupTest,  com.gargoylesoftware.htmlunit.html.HtmlLabelTest,  com.gargoylesoftware.htmlunit.html.HtmlHeadTest,  com.gargoylesoftware.htmlunit.javascript.host.NodeTest,  com.gargoylesoftware.htmlunit.WaitingRefreshHandlerTest,  com.gargoylesoftware.htmlunit.javascript.host.LocationTest,  com.gargoylesoftware.htmlunit.FailingHttpStatusCodeExceptionTest,  com.gargoylesoftware.htmlunit.libraries.JQueryTestBase,  com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInputTest,  com.gargoylesoftware.htmlunit.html.HTMLParserTest,  com.gargoylesoftware.htmlunit.SanityCheck,  com.gargoylesoftware.htmlunit.html.HtmlResetInputTest,  com.gargoylesoftware.htmlunit.libraries.Prototype150rc1Test,  com.gargoylesoftware.htmlunit.javascript.host.DocumentTest,  com.gargoylesoftware.htmlunit.WebClientTest,  com.gargoylesoftware.htmlunit.html.HtmlTextInputTest,  com.gargoylesoftware.htmlunit.html.HtmlButtonTest,  com.gargoylesoftware.htmlunit.WebResponseImplTest,  com.gargoylesoftware.htmlunit.ThreadManagerTest,  com.gargoylesoftware.htmlunit.html.DomCommentTest,  com.gargoylesoftware.htmlunit.javascript.regexp.HtmlUnitRegExpProxyTest,  com.gargoylesoftware.htmlunit.javascript.host.XMLElementTest,  com.gargoylesoftware.htmlunit.libraries.Dojo090Test,  com.gargoylesoftware.htmlunit.html.HtmlAttrTest,  com.gargoylesoftware.htmlunit.html.HtmlFrameTest,  com.gargoylesoftware.htmlunit.javascript.host.StyleSheetTest,  com.gargoylesoftware.htmlunit.html.HtmlTextAreaTest,  com.gargoylesoftware.htmlunit.javascript.host.AnchorTest,  com.gargoylesoftware.htmlunit.javascript.host.TextareaTest,  com.gargoylesoftware.htmlunit.javascript.host.StyleSheetListTest,  com.gargoylesoftware.htmlunit.html.HtmlImageTest,  com.gargoylesoftware.htmlunit.javascript.host.DOMImplementationTest,  com.gargoylesoftware.htmlunit.html.HtmlIsIndexTest,  com.gargoylesoftware.htmlunit.javascript.host.ActiveXObjectTest,  com.gargoylesoftware.htmlunit.html.HtmlFileInputTest,  com.gargoylesoftware.htmlunit.javascript.host.SelectTest,  com.gargoylesoftware.htmlunit.html.HtmlInputTest,  com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInputTest,  com.gargoylesoftware.htmlunit.TopLevelWindowTest,  com.gargoylesoftware.htmlunit.javascript.IEConditionalCompilationTest,  com.gargoylesoftware.htmlunit.ImmediateRefreshHandlerTest,  com.gargoylesoftware.htmlunit.html.xpath.HtmlUnitXPathTest,  com.gargoylesoftware.htmlunit.javascript.ThreadTest,  com.gargoylesoftware.htmlunit.html.HtmlNoScriptTest,  com.gargoylesoftware.htmlunit.html.HtmlButtonInputTest,  com.gargoylesoftware.htmlunit.util.UrlUtilsTest,  com.gargoylesoftware.htmlunit.javascript.host.FrameSetTest,  com.gargoylesoftware.htmlunit.html.HtmlFrameSetTest,  com.gargoylesoftware.htmlunit.html.HtmlOptionTest,  com.gargoylesoftware.htmlunit.html.HtmlImageInputTest,  com.gargoylesoftware.htmlunit.javascript.host.TableTest,  com.gargoylesoftware.htmlunit.libraries.CurvyCornersTest,  com.gargoylesoftware.htmlunit.html.HtmlPageTest,  com.gargoylesoftware.htmlunit.html.HTMLParserListenerTest,  com.gargoylesoftware.htmlunit.javascript.host.XPathResultTest,  com.gargoylesoftware.htmlunit.html.DefaultElementFactoryTest,  com.gargoylesoftware.htmlunit.html.DomNodeTest,  com.gargoylesoftware.htmlunit.javascript.SimpleScriptableTest,  com.gargoylesoftware.htmlunit.html.HtmlInlineFrameTest,  com.gargoylesoftware.htmlunit.util.DebuggingWebConnectionTest,  com.gargoylesoftware.htmlunit.libraries.Dojo102Test,  com.gargoylesoftware.htmlunit.javascript.host.NamedNodeMapTest,  com.gargoylesoftware.htmlunit.javascript.host.ImageTest,  com.gargoylesoftware.htmlunit.javascript.host.XMLDocumentTest,  com.gargoylesoftware.htmlunit.html.HtmlAreaTest,  com.gargoylesoftware.htmlunit.libraries.Sarissa099Test,  com.gargoylesoftware.htmlunit.TextUtilTest,  com.gargoylesoftware.htmlunit.javascript.host.ScriptTest,  com.gargoylesoftware.htmlunit.html.HtmlScriptTest,  com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfigurationTest,  com.gargoylesoftware.htmlunit.html.HtmlTableCellTest,  com.gargoylesoftware.htmlunit.javascript.host.XSLTProcessorTest,  com.gargoylesoftware.htmlunit.xml.XmlPageTest,  com.gargoylesoftware.htmlunit.javascript.host.IFrameTest,  com.gargoylesoftware.htmlunit.javascript.host.CharacterDataImplTest,  com.gargoylesoftware.htmlunit.html.HtmlTableTest,  com.gargoylesoftware.htmlunit.javascript.host.NavigatorTest,  com.gargoylesoftware.htmlunit.javascript.host.HTMLFrameElementTest,  com.gargoylesoftware.htmlunit.html.xpath.DocumentNavigatorTest,  com.gargoylesoftware.htmlunit.javascript.host.WindowTest,  com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigurationTest,  com.gargoylesoftware.htmlunit.javascript.host.EventTest,  com.gargoylesoftware.htmlunit.libraries.Prototype160Test,  com.gargoylesoftware.htmlunit.html.HtmlHiddenInputTest,  com.gargoylesoftware.htmlunit.javascript.host.StyleTest,  com.gargoylesoftware.htmlunit.html.HtmlFormTest,  com.gargoylesoftware.htmlunit.javascript.host.OptionTest,  com.gargoylesoftware.htmlunit.WebAssertTest,  com.gargoylesoftware.htmlunit.javascript.host.RangeTest,  com.gargoylesoftware.htmlunit.WebResponseDataTest,  com.gargoylesoftware.htmlunit.html.HtmlHtmlTest,  com.gargoylesoftware.htmlunit.libraries.YuiTest,
WebTestCase
abstract public class WebTestCase extends BaseTestCase (Code)
Common superclass for HtmlUnit tests
version:
   $Revision: 2132 $
author:
   Mike Bowler
author:
   David D. Kilzer
author:
   Marc Guillemot
author:
   Chris Erskine
author:
   Michael Ottati
author:
   Daniel Gredler
author:
   Ahmed Ashour


Field Summary
final public static  StringPROPERTY_GENERATE_TESTPAGES
    
final public static  URLURL_FIRST
     Constant for the url http://first which is used in the tests.
final public static  URLURL_GARGOYLE
     Constant for the url http://www.gargoylesoftware.com which is used in the tests.
final public static  URLURL_SECOND
     Constant for the url http://second which is used in the tests.
final public static  URLURL_THIRD
     Constant for the url http://third which is used in the tests.

Constructor Summary
public  WebTestCase(String name)
     Create an instance.

Method Summary
protected  voidassertEquals(URL expectedUrl, URL actualUrl)
     Facility to test external form of urls.
protected  voidassertEquals(String message, URL expectedUrl, URL actualUrl)
     Facility to test external form of urls.
protected  voidassertEquals(String expectedUrl, URL actualUrl)
     Facility to test external form of an url.
protected  voidassertEquals(String[] expected, List actual)
     Facility method to avoid having to create explicitly a list from a String[] (for example when testing received alerts).
protected  voidassertEquals(String message, String[] expected, List actual)
     Facility method to avoid having to create explicitly a list from a String[] (for example when testing received alerts).
protected  voidassertEquals(String message, String expectedUrl, URL actualUrl)
     Facility to test external form of an url.
public static  voidassertNull(Object object)
     Assert that the specified object is null.
protected  voidcreateTestPageForRealBrowserIfNeeded(String content, String[] expectedAlerts)
    
protected  voidcreateTestPageForRealBrowserIfNeeded(String content, List expectedAlerts)
     Generates an instrumented html file in the temporary dir to easily make a manual test in a real browser.
public static  InputStreamgetFileAsStream(String fileName)
     Return an input stream for the specified file name.
public static  FilegetFileObject(String fileName)
     Return a File object for the specified file name.
final protected  LoggetLog()
    
final protected static  MockWebConnectiongetMockConnection(HtmlPage page)
     Convenience method to pull the MockWebConnection out of an HtmlPage created with the loadPage method.
final protected static  HtmlPageloadPage(String html)
     Load a page with the specified html using the default browser version.
Parameters:
  html - The html to use.
final protected static  HtmlPageloadPage(BrowserVersion browserVersion, String html, List collectedAlerts)
     Load a page with the specified html and collect alerts into the list.
Parameters:
  browserVersion - the browser version to use
Parameters:
  html - The HTML to use.
Parameters:
  collectedAlerts - The list to hold the alerts.
final protected static  HtmlPageloadPage(String html, List collectedAlerts)
     User the default browser version to load a page with the specified html and collect alerts into the list.
Parameters:
  html - The HTML to use.
Parameters:
  collectedAlerts - The list to hold the alerts.
final protected static  HtmlPageloadPage(String html, List collectedAlerts, URL url)
     Load a page with the specified html and collect alerts into the list.
final protected static  HtmlPageloadPage(BrowserVersion browserVersion, String html, List collectedAlerts, URL url)
     Load a page with the specified html and collect alerts into the list.
final protected static  HtmlPageloadUrl(String url)
     Loads an external URL, accounting for the fact that the remote server may be down or the machine running the tests may not be connected to the internet.
protected  booleannotYetImplemented()
     Runs the calling JUnit test again and fails only if it already runs.
This is helpful for tests that don't currently work but should work one day, when the tested functionality has been implemented.
The right way to use it is:
 public void testXXX() {
 if (notYetImplemented()) {
 return;
 }
 ...
protected  voidtestHTMLFile(String fileName)
     Load the specified resource for the supported browsers and tests that the generated log corresponds to the expected one for this browser.

Field Detail
PROPERTY_GENERATE_TESTPAGES
final public static String PROPERTY_GENERATE_TESTPAGES(Code)
The name of the system property used to determine if files should be generated or not in WebTestCase.createTestPageForRealBrowserIfNeeded(String,List)



URL_FIRST
final public static URL URL_FIRST(Code)
Constant for the url http://first which is used in the tests.



URL_GARGOYLE
final public static URL URL_GARGOYLE(Code)
Constant for the url http://www.gargoylesoftware.com which is used in the tests.



URL_SECOND
final public static URL URL_SECOND(Code)
Constant for the url http://second which is used in the tests.



URL_THIRD
final public static URL URL_THIRD(Code)
Constant for the url http://third which is used in the tests.




Constructor Detail
WebTestCase
public WebTestCase(String name)(Code)
Create an instance.
Parameters:
  name - The name of the test.




Method Detail
assertEquals
protected void assertEquals(URL expectedUrl, URL actualUrl)(Code)
Facility to test external form of urls. Comparing external form of urls is really faster than URL.equals() as the host doesn't need to be resolved.
Parameters:
  expectedUrl - the expected url
Parameters:
  actualUrl - the url to test



assertEquals
protected void assertEquals(String message, URL expectedUrl, URL actualUrl)(Code)
Facility to test external form of urls. Comparing external form of urls is really faster than URL.equals() as the host doesn't need to be resolved.
Parameters:
  message - the message to display if assertion fails
Parameters:
  expectedUrl - the string representation of the expected url
Parameters:
  actualUrl - the url to test



assertEquals
protected void assertEquals(String expectedUrl, URL actualUrl)(Code)
Facility to test external form of an url.
Parameters:
  expectedUrl - the string representation of the expected url
Parameters:
  actualUrl - the url to test



assertEquals
protected void assertEquals(String[] expected, List actual)(Code)
Facility method to avoid having to create explicitly a list from a String[] (for example when testing received alerts). Transforms the String[] to a List before calling junit.framework.Assert.assertEquals(java.lang.Objectjava.lang.Object) .
Parameters:
  expected - the expected strings
Parameters:
  actual - the collection of strings to test



assertEquals
protected void assertEquals(String message, String[] expected, List actual)(Code)
Facility method to avoid having to create explicitly a list from a String[] (for example when testing received alerts). Transforms the String[] to a List before calling junit.framework.Assert.assertEquals(java.lang.Stringjava.lang.Objectjava.lang.Object) .
Parameters:
  message - the message to display if assertion fails
Parameters:
  expected - the expected strings
Parameters:
  actual - the collection of strings to test



assertEquals
protected void assertEquals(String message, String expectedUrl, URL actualUrl)(Code)
Facility to test external form of an url.
Parameters:
  message - the message to display if assertion fails
Parameters:
  expectedUrl - the string representation of the expected url
Parameters:
  actualUrl - the url to test



assertNull
public static void assertNull(Object object)(Code)
Assert that the specified object is null.
Parameters:
  object - The object to check.



createTestPageForRealBrowserIfNeeded
protected void createTestPageForRealBrowserIfNeeded(String content, String[] expectedAlerts) throws IOException(Code)
Facility method transforming expectedAlerts to a list and calling WebTestCase.createTestPageForRealBrowserIfNeeded(String,List)
Parameters:
  content - the content of the html page
Parameters:
  expectedAlerts - the expected alerts
throws:
  IOException - if writing file fails



createTestPageForRealBrowserIfNeeded
protected void createTestPageForRealBrowserIfNeeded(String content, List expectedAlerts) throws IOException(Code)
Generates an instrumented html file in the temporary dir to easily make a manual test in a real browser. The file is generated only if the system property WebTestCase.PROPERTY_GENERATE_TESTPAGES is set.
Parameters:
  content - the content of the html page
Parameters:
  expectedAlerts - the expected alerts
throws:
  IOException - if writing file fails



getFileAsStream
public static InputStream getFileAsStream(String fileName) throws FileNotFoundException(Code)
Return an input stream for the specified file name. Refer to WebTestCase.getFileObject(String) for details on how the file is located.
Parameters:
  fileName - The base file name. The input stream.
throws:
  FileNotFoundException - If the file cannot be found.



getFileObject
public static File getFileObject(String fileName) throws FileNotFoundException(Code)
Return a File object for the specified file name. This is different from just new File(fileName) because it will adjust the location of the file depending on how the code is being executed.
Parameters:
  fileName - The base filename. The new File object.
throws:
  FileNotFoundException - if !file.exists()



getLog
final protected Log getLog()(Code)
Return the log that is being used for all testing objects The log.



getMockConnection
final protected static MockWebConnection getMockConnection(HtmlPage page)(Code)
Convenience method to pull the MockWebConnection out of an HtmlPage created with the loadPage method.
Parameters:
  page - HtmlPage to get the connection from the MockWebConnection that served this page



loadPage
final protected static HtmlPage loadPage(String html) throws Exception(Code)
Load a page with the specified html using the default browser version.
Parameters:
  html - The html to use. The new page.
throws:
  Exception - if something goes wrong.



loadPage
final protected static HtmlPage loadPage(BrowserVersion browserVersion, String html, List collectedAlerts) throws Exception(Code)
Load a page with the specified html and collect alerts into the list.
Parameters:
  browserVersion - the browser version to use
Parameters:
  html - The HTML to use.
Parameters:
  collectedAlerts - The list to hold the alerts. The new page.
throws:
  Exception - If something goes wrong.



loadPage
final protected static HtmlPage loadPage(String html, List collectedAlerts) throws Exception(Code)
User the default browser version to load a page with the specified html and collect alerts into the list.
Parameters:
  html - The HTML to use.
Parameters:
  collectedAlerts - The list to hold the alerts. The new page.
throws:
  Exception - If something goes wrong.



loadPage
final protected static HtmlPage loadPage(String html, List collectedAlerts, URL url) throws Exception(Code)
Load a page with the specified html and collect alerts into the list.
Parameters:
  html - The HTML to use.
Parameters:
  collectedAlerts - The list to hold the alerts.
Parameters:
  url - The URL that will use as the document host for this page The new page.
throws:
  Exception - If something goes wrong.



loadPage
final protected static HtmlPage loadPage(BrowserVersion browserVersion, String html, List collectedAlerts, URL url) throws Exception(Code)
Load a page with the specified html and collect alerts into the list.
Parameters:
  browserVersion - the browser version to use
Parameters:
  html - The HTML to use.
Parameters:
  collectedAlerts - The list to hold the alerts.
Parameters:
  url - The URL that will use as the document host for this page The new page.
throws:
  Exception - If something goes wrong.



loadUrl
final protected static HtmlPage loadUrl(String url) throws Exception(Code)
Loads an external URL, accounting for the fact that the remote server may be down or the machine running the tests may not be connected to the internet.
Parameters:
  url - the URL to load the loaded page, or null if there were connectivity issues
throws:
  Exception - if an error occurs



notYetImplemented
protected boolean notYetImplemented()(Code)
Runs the calling JUnit test again and fails only if it already runs.
This is helpful for tests that don't currently work but should work one day, when the tested functionality has been implemented.
The right way to use it is:
 public void testXXX() {
 if (notYetImplemented()) {
 return;
 }
 ... the real (now failing) unit test
 }
 
when not itself already in the call stack



testHTMLFile
protected void testHTMLFile(String fileName) throws Exception(Code)
Load the specified resource for the supported browsers and tests that the generated log corresponds to the expected one for this browser.
Parameters:
  fileName - the resource name which resides in /resources folder andbelongs to the same package as the test class.
throws:
  Exception - if the test fails



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.