info.magnolia.testframework.htmlunit
Class AbstractMagnoliaHtmlUnitTest

java.lang.Object
  extended by info.magnolia.testframework.AbstractMagnoliaIntegrationTest
      extended by info.magnolia.testframework.htmlunit.AbstractMagnoliaHtmlUnitTest

public abstract class AbstractMagnoliaHtmlUnitTest
extends AbstractMagnoliaIntegrationTest

A base class for Magnolia integration tests. Might be split into util class/methods; since we use JUnit4, inheritance isn't really mandatory.


Nested Class Summary
 
Nested classes/interfaces inherited from class info.magnolia.testframework.AbstractMagnoliaIntegrationTest
AbstractMagnoliaIntegrationTest.Instance, AbstractMagnoliaIntegrationTest.User
 
Field Summary
protected static Map<String,String> DEFAULT_HEADERS
           
protected static String SESSION_ID_REGEXP
          Session id's can consist of any digit and letter (lower or upper case).
 
Fields inherited from class info.magnolia.testframework.AbstractMagnoliaIntegrationTest
AUTHOR_CONTEXT_PATH_PROPERTY, DEFAULT_DOMAIN, DOMAIN_PROPERTY, PUBLIC_CONTEXT_PATH_PROPERTY
 
Constructor Summary
AbstractMagnoliaHtmlUnitTest()
           
 
Method Summary
protected
<P extends com.gargoylesoftware.htmlunit.Page>
P
assertRedirected(String reason, String expectedTargetURLPattern, com.gargoylesoftware.htmlunit.Page page, AbstractMagnoliaIntegrationTest.User user)
           
protected  HttpURLConnection openConnection(AbstractMagnoliaIntegrationTest.Instance instance, String path, AbstractMagnoliaIntegrationTest.User user)
           
protected  HttpURLConnection openConnection(AbstractMagnoliaIntegrationTest.Instance instance, String path, AbstractMagnoliaIntegrationTest.User user, Map<String,String> headers)
          Use this method when you need low-level access to the connection headers and content.
protected  com.gargoylesoftware.htmlunit.html.HtmlPage openHtmlPage(AbstractMagnoliaIntegrationTest.Instance instance, String path, AbstractMagnoliaIntegrationTest.User user)
          Deprecated. openPage now uses generics, so use that instead.
protected  com.gargoylesoftware.htmlunit.html.HtmlPage openHtmlPage(AbstractMagnoliaIntegrationTest.Instance instance, String path, AbstractMagnoliaIntegrationTest.User user, boolean followRedirects)
          Deprecated. openPage now uses generics, so use that instead.
protected  com.gargoylesoftware.htmlunit.Page openPage(AbstractMagnoliaIntegrationTest.Instance instance, String path, AbstractMagnoliaIntegrationTest.User user)
          Deprecated. use #openPage(String, AbstractMagnoliaHtmlUnitTest.User, boolean) with AbstractMagnoliaHtmlUnitTest.Instance.AUTHOR.getURL()
protected
<P extends com.gargoylesoftware.htmlunit.Page>
P
openPage(AbstractMagnoliaIntegrationTest.Instance instance, String path, AbstractMagnoliaIntegrationTest.User user, boolean followRedirects)
          Deprecated. use #openPage(String, AbstractMagnoliaHtmlUnitTest.User, boolean) with AbstractMagnoliaIntegrationTest.Instance.AUTHOR.getURL()
protected
<P extends com.gargoylesoftware.htmlunit.Page>
P
openPage(String url, AbstractMagnoliaIntegrationTest.User user)
           
protected
<P extends com.gargoylesoftware.htmlunit.Page>
P
openPage(String url, AbstractMagnoliaIntegrationTest.User user, boolean followRedirects)
           
protected
<P extends com.gargoylesoftware.htmlunit.Page>
P
openPage(String url, AbstractMagnoliaIntegrationTest.User user, boolean followRedirects, boolean enableJavascript)
           
protected
<P extends com.gargoylesoftware.htmlunit.Page>
P
openPage(String url, AbstractMagnoliaIntegrationTest.User user, boolean followRedirects, boolean enableJavascript, Map<String,String> headers)
          This uses htmlunit, simulates a browser and does all kind of fancy stuff for you.
protected  void saveToFile(com.gargoylesoftware.htmlunit.Page page, StackTraceElement stackTraceElement)
          Need to pass a StackTraceElement to determine the current method, because we can't safely guess at what depth of the stack this method was called.
protected  void saveToFile(com.gargoylesoftware.htmlunit.Page page, Throwable fakeException)
          Passing a fake exception might be simpler for some cases.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SESSION_ID_REGEXP

protected static final String SESSION_ID_REGEXP
Session id's can consist of any digit and letter (lower or upper case).

See Also:
Constant Field Values

DEFAULT_HEADERS

protected static final Map<String,String> DEFAULT_HEADERS
Constructor Detail

AbstractMagnoliaHtmlUnitTest

public AbstractMagnoliaHtmlUnitTest()
Method Detail

openConnection

protected HttpURLConnection openConnection(AbstractMagnoliaIntegrationTest.Instance instance,
                                           String path,
                                           AbstractMagnoliaIntegrationTest.User user)
                                    throws IOException
Throws:
IOException
See Also:
#openConnection(AbstractMagnoliaHtmlUnitTest.Instance, String, AbstractMagnoliaHtmlUnitTest.User, java.util.Map)

openConnection

protected HttpURLConnection openConnection(AbstractMagnoliaIntegrationTest.Instance instance,
                                           String path,
                                           AbstractMagnoliaIntegrationTest.User user,
                                           Map<String,String> headers)
                                    throws IOException
Use this method when you need low-level access to the connection headers and content.

Throws:
IOException

openHtmlPage

@Deprecated
protected com.gargoylesoftware.htmlunit.html.HtmlPage openHtmlPage(AbstractMagnoliaIntegrationTest.Instance instance,
                                                                              String path,
                                                                              AbstractMagnoliaIntegrationTest.User user)
                                                            throws IOException
Deprecated. openPage now uses generics, so use that instead.

Just a shortcut method to avoid a cast to HtmlPage.

Throws:
IOException
See Also:
#openPage(AbstractMagnoliaHtmlUnitTest.Instance, String, AbstractMagnoliaHtmlUnitTest.User, boolean)

openHtmlPage

@Deprecated
protected com.gargoylesoftware.htmlunit.html.HtmlPage openHtmlPage(AbstractMagnoliaIntegrationTest.Instance instance,
                                                                              String path,
                                                                              AbstractMagnoliaIntegrationTest.User user,
                                                                              boolean followRedirects)
                                                            throws IOException
Deprecated. openPage now uses generics, so use that instead.

Throws:
IOException

openPage

@Deprecated
protected com.gargoylesoftware.htmlunit.Page openPage(AbstractMagnoliaIntegrationTest.Instance instance,
                                                                 String path,
                                                                 AbstractMagnoliaIntegrationTest.User user)
                                               throws IOException
Deprecated. use #openPage(String, AbstractMagnoliaHtmlUnitTest.User, boolean) with AbstractMagnoliaHtmlUnitTest.Instance.AUTHOR.getURL()

Throws:
IOException

openPage

@Deprecated
protected <P extends com.gargoylesoftware.htmlunit.Page> P openPage(AbstractMagnoliaIntegrationTest.Instance instance,
                                                                               String path,
                                                                               AbstractMagnoliaIntegrationTest.User user,
                                                                               boolean followRedirects)
                                                         throws IOException
Deprecated. use #openPage(String, AbstractMagnoliaHtmlUnitTest.User, boolean) with AbstractMagnoliaIntegrationTest.Instance.AUTHOR.getURL()

Throws:
IOException

openPage

protected <P extends com.gargoylesoftware.htmlunit.Page> P openPage(String url,
                                                                    AbstractMagnoliaIntegrationTest.User user)
                                                         throws IOException
Throws:
IOException

openPage

protected <P extends com.gargoylesoftware.htmlunit.Page> P openPage(String url,
                                                                    AbstractMagnoliaIntegrationTest.User user,
                                                                    boolean followRedirects)
                                                         throws IOException
Throws:
IOException

openPage

protected <P extends com.gargoylesoftware.htmlunit.Page> P openPage(String url,
                                                                    AbstractMagnoliaIntegrationTest.User user,
                                                                    boolean followRedirects,
                                                                    boolean enableJavascript)
                                                         throws IOException
Throws:
IOException

openPage

protected <P extends com.gargoylesoftware.htmlunit.Page> P openPage(String url,
                                                                    AbstractMagnoliaIntegrationTest.User user,
                                                                    boolean followRedirects,
                                                                    boolean enableJavascript,
                                                                    Map<String,String> headers)
                                                         throws IOException
This uses htmlunit, simulates a browser and does all kind of fancy stuff for you.

Throws:
IOException

assertRedirected

protected <P extends com.gargoylesoftware.htmlunit.Page> P assertRedirected(String reason,
                                                                            String expectedTargetURLPattern,
                                                                            com.gargoylesoftware.htmlunit.Page page,
                                                                            AbstractMagnoliaIntegrationTest.User user)
                                                                 throws IOException
Throws:
IOException

saveToFile

protected void saveToFile(com.gargoylesoftware.htmlunit.Page page,
                          Throwable fakeException)
                   throws IOException
Passing a fake exception might be simpler for some cases.

Throws:
IOException
See Also:
saveToFile(com.gargoylesoftware.htmlunit.Page, StackTraceElement)

saveToFile

protected void saveToFile(com.gargoylesoftware.htmlunit.Page page,
                          StackTraceElement stackTraceElement)
                   throws IOException
Need to pass a StackTraceElement to determine the current method, because we can't safely guess at what depth of the stack this method was called. We're keeping this method separate from openPage() for the same reason: if a test/util method calls the openPage method instead of the actual test, the stack won't reflect the "current test method" properly.

Throws:
IOException


Copyright © 2003-2014 Magnolia International Ltd.. All Rights Reserved.