| 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 String | PROPERTY_GENERATE_TESTPAGES | final public static URL | URL_FIRST Constant for the url http://first which is used in the tests. | final public static URL | URL_GARGOYLE Constant for the url http://www.gargoylesoftware.com which is used in the tests. | final public static URL | URL_SECOND Constant for the url http://second which is used in the tests. | final public static URL | URL_THIRD Constant for the url http://third which is used in the tests. |
Method Summary | |
protected void | assertEquals(URL expectedUrl, URL actualUrl) Facility to test external form of urls. | protected void | assertEquals(String message, URL expectedUrl, URL actualUrl) Facility to test external form of urls. | protected void | assertEquals(String expectedUrl, URL actualUrl) Facility to test external form of an url. | protected void | assertEquals(String[] expected, List actual) Facility method to avoid having to create explicitly a list from
a String[] (for example when testing received alerts). | protected void | assertEquals(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 void | assertEquals(String message, String expectedUrl, URL actualUrl) Facility to test external form of an url. | public static void | assertNull(Object object) Assert that the specified object is null. | protected void | createTestPageForRealBrowserIfNeeded(String content, String[] expectedAlerts) | protected void | createTestPageForRealBrowserIfNeeded(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 InputStream | getFileAsStream(String fileName) Return an input stream for the specified file name. | public static File | getFileObject(String fileName) Return a File object for the specified file name. | final protected Log | getLog() | final protected static MockWebConnection | getMockConnection(HtmlPage page) Convenience method to pull the MockWebConnection out of an HtmlPage created with
the loadPage method. | final protected static HtmlPage | loadPage(String html) Load a page with the specified html using the default browser version.
Parameters: html - The html to use. | final protected static HtmlPage | loadPage(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 HtmlPage | loadPage(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 HtmlPage | loadPage(String html, List collectedAlerts, URL url) Load a page with the specified html and collect alerts into the list. | final protected static HtmlPage | loadPage(BrowserVersion browserVersion, String html, List collectedAlerts, URL url) Load a page with the specified html and collect alerts into the list. | final protected static HtmlPage | loadUrl(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 boolean | notYetImplemented() 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 void | testHTMLFile(String fileName) Load the specified resource for the supported browsers and tests
that the generated log corresponds to the expected one for this browser. |
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.
|
WebTestCase | public WebTestCase(String name)(Code) | | Create an instance.
Parameters: name - The name of the test. |
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, 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 |
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 |
|
|