org.apache.tapestry
Class BaseComponentTestCase

java.lang.Object
  extended by org.testng.Assert
      extended by org.apache.tapestry.TestBase
          extended by org.apache.tapestry.BaseComponentTestCase

public class BaseComponentTestCase
extends TestBase

Base class for testing components, or testing classes that operate on components. Simplifies creating much of the infrastructure around the components.


Field Summary
protected  CharArrayWriter _charArrayWriter
           
 
Constructor Summary
BaseComponentTestCase()
           
 
Method Summary
protected  void assertBuffer(String expected)
           
protected  void assertExceptionSubstring(Throwable t, String msg)
           
static boolean assertListEquals(Object[] expected, List actual)
           
static boolean assertListEquals(Object[] expected, Object[] actual)
           
protected  Registry buildFrameworkRegistry(ModuleDescriptorProvider customProvider)
          Builds a registry, containing only the modules delivered by the specified ModuleDescriptorProvider, plus the master module descriptor (i.e., those visible on the classpath).
protected  Registry buildFrameworkRegistry(String file)
          Convienience method for invoking buildFrameworkRegistry(String[]) with only a single file.
protected  Registry buildFrameworkRegistry(String[] files)
          Builds a minimal registry, containing only the specified files, plus the master module descriptor (i.e., those visible on the classpath).
protected  Registry buildMinimalRegistry(Resource l)
          Builds a registry from exactly the provided resource; this registry will not include the hivemind module.
protected  Location fabricateLocation(int line)
           
protected  ClassResolver getClassResolver()
           
protected  org.apache.tapestry.test.Creator getCreator()
           
protected  Resource getResource(String file)
          Returns the given file as a Resource from the classpath.
protected  org.apache.tapestry.IAsset newAsset()
           
protected  org.apache.tapestry.IBinding newBinding()
           
protected  org.apache.tapestry.IBinding newBinding(Location location)
           
protected  org.apache.tapestry.IBinding newBinding(Object value)
           
protected  org.apache.tapestry.IRender newBody()
           
protected  org.apache.tapestry.json.IJSONWriter newBufferJSONWriter()
           
protected  org.apache.tapestry.IMarkupWriter newBufferWriter()
           
protected  org.apache.tapestry.IComponent newComponent()
           
protected  org.apache.tapestry.IComponent newComponent(String extendedId, Location location)
           
protected  org.apache.tapestry.IRequestCycle newCycle()
           
protected  org.apache.tapestry.IRequestCycle newCycle(boolean rewinding)
           
protected  org.apache.tapestry.IRequestCycle newCycle(boolean rewinding, boolean trainWriter)
           
protected  org.apache.tapestry.IRequestCycle newCycle(boolean rewinding, org.apache.tapestry.IMarkupWriter writer)
           
protected  org.apache.tapestry.IRequestCycle newCycle(org.apache.tapestry.IMarkupWriter writer)
           
protected  org.apache.tapestry.IRequestCycle newCycleGetPage(String pageName, org.apache.tapestry.IPage page)
           
protected  org.apache.tapestry.IRequestCycle newCycleGetParameter(String name, String value)
           
protected  org.apache.tapestry.IRequestCycle newCycleGetUniqueId(String id, String uniqueId)
           
protected  org.apache.tapestry.IEngine newEngine(ClassResolver resolver)
           
protected  org.apache.tapestry.engine.IEngineService newEngineService()
           
protected  org.apache.tapestry.IForm newForm()
           
protected  Object newInstance(Class componentClass)
           
protected  Object newInstance(Class componentClass, String propertyName, Object propertyValue)
           
protected  org.apache.tapestry.engine.ILink newLink()
           
protected  Location newLocation()
           
protected  Log newLog()
           
protected  org.apache.tapestry.NestedMarkupWriter newNestedWriter()
           
protected  org.apache.tapestry.IPage newPage()
           
protected  org.apache.tapestry.IPage newPage(String name)
           
protected  org.apache.tapestry.IPage newPage(String name, int count)
           
protected  org.apache.tapestry.PageRenderSupport newPageRenderSupport()
           
protected  org.apache.tapestry.IRender newRender()
           
protected  org.apache.tapestry.web.WebRequest newRequest()
           
protected  Resource newResource()
           
protected  org.apache.tapestry.spec.IComponentSpecification newSpec()
           
protected  org.apache.tapestry.spec.IComponentSpecification newSpec(String parameterName, org.apache.tapestry.spec.IParameterSpecification pspec)
           
protected  org.apache.tapestry.IMarkupWriter newWriter()
           
static void notEquals(Object expected, Object actual)
           
protected  void trainBuildURL(org.apache.tapestry.IAsset asset, org.apache.tapestry.IRequestCycle cycle, String URL)
           
protected  void trainEncodeURL(org.apache.tapestry.IRequestCycle rc, String URL, String encodedURL)
           
protected  void trainExtractBrowserEvent(org.apache.tapestry.IRequestCycle cycle)
           
protected  void trainGetAttribute(org.apache.tapestry.IRequestCycle cycle, String attributeName, Object attribute)
           
protected  void trainGetBinding(org.apache.tapestry.IComponent component, String name, org.apache.tapestry.IBinding binding)
           
protected  void trainGetComponent(org.apache.tapestry.IComponent container, String componentId, org.apache.tapestry.IComponent containee)
           
protected  void trainGetEngine(org.apache.tapestry.IPage page, org.apache.tapestry.IEngine engine)
           
protected  void trainGetEngine(org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.IEngine engine)
           
protected  void trainGetExtendedId(org.apache.tapestry.IComponent component, String extendedId)
           
protected  void trainGetId(org.apache.tapestry.IComponent component, String id)
           
protected  void trainGetIdPath(org.apache.tapestry.IComponent component, String idPath)
           
protected  void trainGetLink(org.apache.tapestry.engine.IEngineService service, org.apache.tapestry.IRequestCycle cycle, boolean post, Object parameter, org.apache.tapestry.engine.ILink link)
           
protected  void trainGetLink(org.apache.tapestry.components.ILinkComponent component, org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.engine.ILink link)
           
protected  void trainGetLinkCheckIgnoreParameter(org.apache.tapestry.engine.IEngineService service, org.apache.tapestry.IRequestCycle cycle, boolean post, Object parameter, org.apache.tapestry.engine.ILink link)
           
protected  void trainGetLocation(Locatable locatable, Location location)
           
protected  void trainGetNestedWriter(org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.NestedMarkupWriter nested)
           
protected  void trainGetPage(org.apache.tapestry.IComponent component, org.apache.tapestry.IPage page)
           
protected  void trainGetPageName(org.apache.tapestry.IPage page, String pageName)
           
protected  void trainGetPageRenderSupport(org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.PageRenderSupport support)
           
protected  void trainGetParameter(org.apache.tapestry.IRequestCycle cycle, String name, String value)
           
protected  void trainGetParameterNames(org.apache.tapestry.engine.ILink link, String[] names)
           
protected  void trainGetParameterValues(org.apache.tapestry.engine.ILink link, String parameterName, String[] values)
           
protected  void trainGetScheme(org.apache.tapestry.web.WebRequest request, String scheme)
           
protected  void trainGetServerName(org.apache.tapestry.web.WebRequest request, String serverName)
           
protected  void trainGetServerPort(org.apache.tapestry.web.WebRequest request, int port)
           
protected  void trainGetSpecification(org.apache.tapestry.IComponent component, org.apache.tapestry.spec.IComponentSpecification spec)
           
protected  void trainGetSupport(org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.PageRenderSupport support)
           
protected  void trainGetUniqueId(org.apache.tapestry.IRequestCycle cycle, String id, String uniqueId)
           
protected  void trainGetURL(org.apache.tapestry.engine.ILink link, String URL)
           
protected  void trainGetURL(org.apache.tapestry.engine.ILink link, String scheme, String anchor, String URL)
           
protected  void trainGetURL(org.apache.tapestry.engine.ILink link, String scheme, String anchor, String URL, int port)
           
protected  void trainIsRewinding(org.apache.tapestry.IRequestCycle cycle, boolean rewinding)
           
protected  void trainResponseBuilder(org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.IMarkupWriter writer)
           
 
Methods inherited from class org.apache.tapestry.TestBase
cleanupControlSource, getMocksControl, newInstance, newMarkupWriter, newMock, newRequestCycle, replay, setReturnValue, setThrowable, unreachable, verify
 
Methods inherited from class org.testng.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEqualsNoOrder, assertEqualsNoOrder, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_charArrayWriter

protected CharArrayWriter _charArrayWriter
Constructor Detail

BaseComponentTestCase

public BaseComponentTestCase()
Method Detail

getCreator

protected org.apache.tapestry.test.Creator getCreator()

getClassResolver

protected ClassResolver getClassResolver()

newBufferWriter

protected org.apache.tapestry.IMarkupWriter newBufferWriter()

newBufferJSONWriter

protected org.apache.tapestry.json.IJSONWriter newBufferJSONWriter()

assertBuffer

protected void assertBuffer(String expected)

assertExceptionSubstring

protected void assertExceptionSubstring(Throwable t,
                                        String msg)

newInstance

protected Object newInstance(Class componentClass)

newInstance

protected Object newInstance(Class componentClass,
                             String propertyName,
                             Object propertyValue)

newCycle

protected org.apache.tapestry.IRequestCycle newCycle()

newCycle

protected org.apache.tapestry.IRequestCycle newCycle(org.apache.tapestry.IMarkupWriter writer)

newCycle

protected org.apache.tapestry.IRequestCycle newCycle(boolean rewinding)

newCycle

protected org.apache.tapestry.IRequestCycle newCycle(boolean rewinding,
                                                     boolean trainWriter)

newCycle

protected org.apache.tapestry.IRequestCycle newCycle(boolean rewinding,
                                                     org.apache.tapestry.IMarkupWriter writer)

trainResponseBuilder

protected void trainResponseBuilder(org.apache.tapestry.IRequestCycle cycle,
                                    org.apache.tapestry.IMarkupWriter writer)

trainIsRewinding

protected void trainIsRewinding(org.apache.tapestry.IRequestCycle cycle,
                                boolean rewinding)

newCycleGetPage

protected org.apache.tapestry.IRequestCycle newCycleGetPage(String pageName,
                                                            org.apache.tapestry.IPage page)

newCycleGetUniqueId

protected org.apache.tapestry.IRequestCycle newCycleGetUniqueId(String id,
                                                                String uniqueId)

newCycleGetParameter

protected org.apache.tapestry.IRequestCycle newCycleGetParameter(String name,
                                                                 String value)

newWriter

protected org.apache.tapestry.IMarkupWriter newWriter()

newBinding

protected org.apache.tapestry.IBinding newBinding(Object value)

newBinding

protected org.apache.tapestry.IBinding newBinding(Location location)

newComponent

protected org.apache.tapestry.IComponent newComponent(String extendedId,
                                                      Location location)

newSpec

protected org.apache.tapestry.spec.IComponentSpecification newSpec(String parameterName,
                                                                   org.apache.tapestry.spec.IParameterSpecification pspec)

newRender

protected org.apache.tapestry.IRender newRender()

newPage

protected org.apache.tapestry.IPage newPage()

newPage

protected org.apache.tapestry.IPage newPage(String name)

newPage

protected org.apache.tapestry.IPage newPage(String name,
                                            int count)

newForm

protected org.apache.tapestry.IForm newForm()

newBody

protected org.apache.tapestry.IRender newBody()

newPageRenderSupport

protected org.apache.tapestry.PageRenderSupport newPageRenderSupport()

trainGetSupport

protected void trainGetSupport(org.apache.tapestry.IRequestCycle cycle,
                               org.apache.tapestry.PageRenderSupport support)

trainGetAttribute

protected void trainGetAttribute(org.apache.tapestry.IRequestCycle cycle,
                                 String attributeName,
                                 Object attribute)

trainGetUniqueId

protected void trainGetUniqueId(org.apache.tapestry.IRequestCycle cycle,
                                String id,
                                String uniqueId)

trainGetIdPath

protected void trainGetIdPath(org.apache.tapestry.IComponent component,
                              String idPath)

trainGetParameter

protected void trainGetParameter(org.apache.tapestry.IRequestCycle cycle,
                                 String name,
                                 String value)

trainGetPageName

protected void trainGetPageName(org.apache.tapestry.IPage page,
                                String pageName)

trainBuildURL

protected void trainBuildURL(org.apache.tapestry.IAsset asset,
                             org.apache.tapestry.IRequestCycle cycle,
                             String URL)

newAsset

protected org.apache.tapestry.IAsset newAsset()

newEngine

protected org.apache.tapestry.IEngine newEngine(ClassResolver resolver)

trainGetEngine

protected void trainGetEngine(org.apache.tapestry.IPage page,
                              org.apache.tapestry.IEngine engine)

newComponent

protected org.apache.tapestry.IComponent newComponent()

trainGetPage

protected void trainGetPage(org.apache.tapestry.IComponent component,
                            org.apache.tapestry.IPage page)

trainGetExtendedId

protected void trainGetExtendedId(org.apache.tapestry.IComponent component,
                                  String extendedId)

trainGetLocation

protected void trainGetLocation(Locatable locatable,
                                Location location)

newBinding

protected org.apache.tapestry.IBinding newBinding()

trainGetComponent

protected void trainGetComponent(org.apache.tapestry.IComponent container,
                                 String componentId,
                                 org.apache.tapestry.IComponent containee)

newEngineService

protected org.apache.tapestry.engine.IEngineService newEngineService()

trainGetLink

protected void trainGetLink(org.apache.tapestry.engine.IEngineService service,
                            org.apache.tapestry.IRequestCycle cycle,
                            boolean post,
                            Object parameter,
                            org.apache.tapestry.engine.ILink link)

trainGetLinkCheckIgnoreParameter

protected void trainGetLinkCheckIgnoreParameter(org.apache.tapestry.engine.IEngineService service,
                                                org.apache.tapestry.IRequestCycle cycle,
                                                boolean post,
                                                Object parameter,
                                                org.apache.tapestry.engine.ILink link)

trainGetURL

protected void trainGetURL(org.apache.tapestry.engine.ILink link,
                           String URL)

trainGetPageRenderSupport

protected void trainGetPageRenderSupport(org.apache.tapestry.IRequestCycle cycle,
                                         org.apache.tapestry.PageRenderSupport support)

newSpec

protected org.apache.tapestry.spec.IComponentSpecification newSpec()

newResource

protected Resource newResource()

newRequest

protected org.apache.tapestry.web.WebRequest newRequest()

newLocation

protected Location newLocation()

fabricateLocation

protected Location fabricateLocation(int line)

trainEncodeURL

protected void trainEncodeURL(org.apache.tapestry.IRequestCycle rc,
                              String URL,
                              String encodedURL)

trainGetServerPort

protected void trainGetServerPort(org.apache.tapestry.web.WebRequest request,
                                  int port)

trainGetServerName

protected void trainGetServerName(org.apache.tapestry.web.WebRequest request,
                                  String serverName)

trainGetScheme

protected void trainGetScheme(org.apache.tapestry.web.WebRequest request,
                              String scheme)

newNestedWriter

protected org.apache.tapestry.NestedMarkupWriter newNestedWriter()

trainGetNestedWriter

protected void trainGetNestedWriter(org.apache.tapestry.IMarkupWriter writer,
                                    org.apache.tapestry.NestedMarkupWriter nested)

trainGetURL

protected void trainGetURL(org.apache.tapestry.engine.ILink link,
                           String scheme,
                           String anchor,
                           String URL)

trainGetURL

protected void trainGetURL(org.apache.tapestry.engine.ILink link,
                           String scheme,
                           String anchor,
                           String URL,
                           int port)

newLink

protected org.apache.tapestry.engine.ILink newLink()

trainGetLink

protected void trainGetLink(org.apache.tapestry.components.ILinkComponent component,
                            org.apache.tapestry.IRequestCycle cycle,
                            org.apache.tapestry.engine.ILink link)

trainGetEngine

protected void trainGetEngine(org.apache.tapestry.IRequestCycle cycle,
                              org.apache.tapestry.IEngine engine)

trainGetParameterValues

protected void trainGetParameterValues(org.apache.tapestry.engine.ILink link,
                                       String parameterName,
                                       String[] values)

trainGetParameterNames

protected void trainGetParameterNames(org.apache.tapestry.engine.ILink link,
                                      String[] names)

trainGetSpecification

protected void trainGetSpecification(org.apache.tapestry.IComponent component,
                                     org.apache.tapestry.spec.IComponentSpecification spec)

trainGetBinding

protected void trainGetBinding(org.apache.tapestry.IComponent component,
                               String name,
                               org.apache.tapestry.IBinding binding)

newLog

protected Log newLog()

trainGetId

protected void trainGetId(org.apache.tapestry.IComponent component,
                          String id)

trainExtractBrowserEvent

protected void trainExtractBrowserEvent(org.apache.tapestry.IRequestCycle cycle)

buildFrameworkRegistry

protected Registry buildFrameworkRegistry(String file)
                                   throws Exception
Convienience method for invoking buildFrameworkRegistry(String[]) with only a single file.

Parameters:
file - The path to the hivemind xml configuration file.
Returns:
The constructed registry.
Throws:
Exception - When file can't be found or parsed.

buildFrameworkRegistry

protected Registry buildFrameworkRegistry(String[] files)
                                   throws Exception
Builds a minimal registry, containing only the specified files, plus the master module descriptor (i.e., those visible on the classpath).

Parameters:
files - The path to the hivemind xml configuration files to parse.
Returns:
The constructed registry.
Throws:
Exception - When file can't be found or parsed.

buildFrameworkRegistry

protected Registry buildFrameworkRegistry(ModuleDescriptorProvider customProvider)
Builds a registry, containing only the modules delivered by the specified ModuleDescriptorProvider, plus the master module descriptor (i.e., those visible on the classpath).

Parameters:
customProvider - The custom module provider that should be added to the configuration.
Returns:
A constructed Registry.

buildMinimalRegistry

protected Registry buildMinimalRegistry(Resource l)
                                 throws Exception
Builds a registry from exactly the provided resource; this registry will not include the hivemind module.

Parameters:
l - The resource to build the registry from.
Returns:
A constructed Registry instance.
Throws:
Exception - If error building registry.

getResource

protected Resource getResource(String file)
Returns the given file as a Resource from the classpath. Typically, this is to find files in the same folder as the invoking class.

Parameters:
file - Gets a resource object for the file representing the path specified.
Returns:
A Resource object.

assertListEquals

public static boolean assertListEquals(Object[] expected,
                                       Object[] actual)

assertListEquals

public static boolean assertListEquals(Object[] expected,
                                       List actual)

notEquals

public static void notEquals(Object expected,
                             Object actual)


Copyright © 2006-2007 Apache Software Foundation. All Rights Reserved.