FileDocCategorySizeDatePackage
TestResult.javaAPI DocExample3243Mon Jul 23 13:26:26 BST 2007org.apache.struts2

TestResult

public class TestResult extends Object implements com.opensymphony.xwork2.Result
TestResult

Fields Summary
private static final long
serialVersionUID
private static final Log
LOG
private List
expectedValues
private List
propertyNames
Constructors Summary
Methods Summary
public voidexecute(com.opensymphony.xwork2.ActionInvocation invocation)

        LOG.info("executing TestResult.");

        if ((expectedValues != null) && (expectedValues.size() > 0) && (propertyNames != null) && (propertyNames.size() > 0))
        {
            ValueStack stack = ActionContext.getContext().getValueStack();

            for (int i = 0; i < propertyNames.size(); i++) {
                String propertyName = (String) propertyNames.get(i);
                String expectedValue = null;

                if (i < expectedValues.size()) {
                    expectedValue = (String) expectedValues.get(i);
                }

                String value = (String) stack.findValue(propertyName, String.class);
                Assert.assertEquals(expectedValue, value);
            }
        } else {
            LOG.error("One of expectedValues = " + expectedValues + " and propertyNames = " + propertyNames + " was null or empty.");
            Assert.fail();
        }
    
public java.util.ListgetExpectedValues()

        return expectedValues;
    
public java.util.ListgetPropertyNames()

        return propertyNames;
    
public voidsetExpectedValue(int index, java.lang.String value)



          
        expectedValues.set(index, value);
    
public voidsetExpectedValue(java.lang.String value)

        expectedValues.add(value);
    
public voidsetPropertyName(int index, java.lang.String propertyName)

        propertyNames.set(index, propertyName);
    
public voidsetPropertyName(java.lang.String propertyName)

        propertyNames.add(propertyName);