public abstract class

AbstractModelAndViewTests

extends TestCase
java.lang.Object
   ↳ junit.framework.Assert
     ↳ junit.framework.TestCase
       ↳ org.springframework.test.web.AbstractModelAndViewTests

This class is deprecated.
as of Spring 3.0, in favor of using the listener-based test context framework (AbstractJUnit38SpringContextTests) or ModelAndViewAssert with JUnit 4 and TestNG.

Class Overview

Convenient JUnit 3.8 base class for tests dealing with Spring Web MVC ModelAndView objects.

All assert*() methods throw AssertionFailedErrors.

Consider the use of ModelAndViewAssert with JUnit 4 and TestNG.

Summary

Public Constructors
AbstractModelAndViewTests()
Protected Methods
<T> T assertAndReturnModelAttributeOfType(ModelAndView mav, String modelName, Class<T> expectedType)
Checks whether the model value under the given modelName exists and checks it type, based on the expectedType.
void assertCompareListModelAttribute(ModelAndView mav, String modelName, List expectedList)
Compare each individual entry in a list, without first sorting the lists.
void assertModelAttributeAvailable(ModelAndView mav, String modelName)
Assert whether or not a model attribute is available.
void assertModelAttributeValue(ModelAndView mav, String modelName, Object expectedValue)
Compare a given expectedValue to the value from the model bound under the given modelName.
void assertModelAttributeValues(ModelAndView mav, Map<StringObject> expectedModel)
Inspect the expectedModel to see if all elements in the model appear and are equal.
void assertSortAndCompareListModelAttribute(ModelAndView mav, String modelName, List expectedList, Comparator comparator)
Compare each individual entry in a list after having sorted both lists (optionally using a comparator).
void assertViewName(ModelAndView mav, String expectedName)
Check to see if the view name in the ModelAndView matches the given expectedName.
[Expand]
Inherited Methods
From class junit.framework.TestCase
From class junit.framework.Assert
From class java.lang.Object
From interface junit.framework.Test

Public Constructors

public AbstractModelAndViewTests ()

Protected Methods

protected T assertAndReturnModelAttributeOfType (ModelAndView mav, String modelName, Class<T> expectedType)

Checks whether the model value under the given modelName exists and checks it type, based on the expectedType. If the model entry exists and the type matches, the model value is returned.

Parameters
mav ModelAndView to test against (never null)
modelName name of the object to add to the model (never null)
expectedType expected type of the model value
Returns
  • the model value

protected void assertCompareListModelAttribute (ModelAndView mav, String modelName, List expectedList)

Compare each individual entry in a list, without first sorting the lists.

Parameters
mav ModelAndView to test against (never null)
modelName name of the object to add to the model (never null)
expectedList the expected list

protected void assertModelAttributeAvailable (ModelAndView mav, String modelName)

Assert whether or not a model attribute is available.

Parameters
mav ModelAndView to test against (never null)
modelName name of the object to add to the model (never null)

protected void assertModelAttributeValue (ModelAndView mav, String modelName, Object expectedValue)

Compare a given expectedValue to the value from the model bound under the given modelName.

Parameters
mav ModelAndView to test against (never null)
modelName name of the object to add to the model (never null)
expectedValue the model value

protected void assertModelAttributeValues (ModelAndView mav, Map<StringObject> expectedModel)

Inspect the expectedModel to see if all elements in the model appear and are equal.

Parameters
mav ModelAndView to test against (never null)
expectedModel the expected model

protected void assertSortAndCompareListModelAttribute (ModelAndView mav, String modelName, List expectedList, Comparator comparator)

Compare each individual entry in a list after having sorted both lists (optionally using a comparator).

Parameters
mav ModelAndView to test against (never null)
modelName name of the object to add to the model (never null)
expectedList the expected list
comparator the comparator to use (may be null). If not specifying the comparator, both lists will be sorted not using any comparator.

protected void assertViewName (ModelAndView mav, String expectedName)

Check to see if the view name in the ModelAndView matches the given expectedName.

Parameters
mav ModelAndView to test against (never null)
expectedName the name of the model value