The Spring Framework

org.springframework.test.web
Class AbstractModelAndViewTests

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.springframework.test.web.AbstractModelAndViewTests
All Implemented Interfaces:
Test

public abstract class AbstractModelAndViewTests
extends TestCase

Convenient base class for tests dealing with Spring web MVC ModelAndView objects.

Since:
2.0
Author:
Alef Arendsen, Bram Smeets
See Also:
ModelAndView

Constructor Summary
AbstractModelAndViewTests()
           
 
Method Summary
protected  Object assertAndReturnModelAttributeOfType(ModelAndView mav, Object key, Class type)
          Checks whether the given model key exists and checks it type, based on the given type.
protected  void assertCompareListModelAttribute(ModelAndView mav, Object key, List assertionList)
          Compare each individual entry in a list, not sorting the lists first.
protected  void assertModelAttributeAvailable(ModelAndView mav, Object key)
          Assert whether or not a model attribute is available.
protected  void assertModelAttributeValue(ModelAndView mav, Object key, Object value)
          Compare a given Object to the value from the model bound under the given key.
protected  void assertModelAttributeValues(ModelAndView mav, Map assertionModel)
          Inspect the given model to see if all elements in the model appear and are equal
protected  void assertSortAndCompareListModelAttribute(ModelAndView mav, Object key, List assertionList, Comparator comp)
          Compare each individual entry in a list after having sorted both lists (optionally using a comparator).
protected  void assertViewName(ModelAndView mav, String name)
          Check to see if the view name in the ModelAndView matches the given String.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, 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

AbstractModelAndViewTests

public AbstractModelAndViewTests()
Method Detail

assertModelAttributeAvailable

protected void assertModelAttributeAvailable(ModelAndView mav,
                                             Object key)
Assert whether or not a model attribute is available.


assertCompareListModelAttribute

protected void assertCompareListModelAttribute(ModelAndView mav,
                                               Object key,
                                               List assertionList)
Compare each individual entry in a list, not sorting the lists first.


assertSortAndCompareListModelAttribute

protected void assertSortAndCompareListModelAttribute(ModelAndView mav,
                                                      Object key,
                                                      List assertionList,
                                                      Comparator comp)
Compare each individual entry in a list after having sorted both lists (optionally using a comparator).

Parameters:
comp - the comparator to use. If not specifying the comparator, both lists will be sorted not using any comparator.

assertAndReturnModelAttributeOfType

protected Object assertAndReturnModelAttributeOfType(ModelAndView mav,
                                                     Object key,
                                                     Class type)
Checks whether the given model key exists and checks it type, based on the given type. If the model entry exists and the type matches, the given model value is returned.


assertViewName

protected void assertViewName(ModelAndView mav,
                              String name)
Check to see if the view name in the ModelAndView matches the given String.


assertModelAttributeValue

protected void assertModelAttributeValue(ModelAndView mav,
                                         Object key,
                                         Object value)
Compare a given Object to the value from the model bound under the given key.


assertModelAttributeValues

protected void assertModelAttributeValues(ModelAndView mav,
                                          Map assertionModel)
Inspect the given model to see if all elements in the model appear and are equal


The Spring Framework

Copyright © 2002-2007 The Spring Framework.