alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Struts example source code file (GetPropertiesTest.java)

This example Struts source code file (GetPropertiesTest.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Struts tags/keywords

arraylist, foo, foo, getpropertiestest, hashset, integer, integer, util, valuestack, valuestack, xworktestcase, xworktestcase

The Struts GetPropertiesTest.java source code

/*
 * Created on Jan 23, 2006
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.opensymphony.xwork2.util;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.XWorkTestCase;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

/**
 * @author Gabe
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class GetPropertiesTest extends XWorkTestCase {

    public void testGetCollectionProperties()  {
        doGetCollectionPropertiesTest(new ArrayList());
        doGetCollectionPropertiesTest(new HashSet());
        
    }
    
    public void doGetCollectionPropertiesTest(Collection c) {
        ValueStack vs = ActionContext.getContext().getValueStack();
        Foo foo = new Foo();
        foo.setBarCollection(c);
        vs.push(foo);
        assertEquals(Boolean.TRUE, vs.findValue("barCollection.isEmpty"));
        assertEquals(Boolean.TRUE, vs.findValue("barCollection.empty"));
        assertEquals(new Integer(0), vs.findValue("barCollection.size"));
        assertTrue(vs.findValue("barCollection.iterator") instanceof java.util.Iterator);
    }
}

Other Struts examples (source code examples)

Here is a short list of links related to this Struts GetPropertiesTest.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.