Java tutorial
/** * PureInfo Ark * @(#)ActionFormUtilTest.java 1.0 Dec 9, 2005 * * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. * All rights reserved, see the license file. * * www.pureinfo.com.cn */ package com.pureinfo.ark.interaction.util; import org.apache.commons.lang.StringUtils; import junit.framework.TestCase; /** * <P> * Created on Dec 9, 2005 11:34:51 PM <BR> * Last modified on Dec 9, 2005 * </P> * ActionFormUtilTest: test for ActionFormUtil. * * @author Why * @version 1.0, Dec 9, 2005 * @since Ark 1.0 */ public class ActionFormUtilTest extends TestCase { public void testCleanEmpty() { class TData { public String[] values; public String[] expect; public TData(String[] _values, String[] _result) { this.values = _values; this.expect = _result; } } TData[] data = { // new TData(new String[] { "1", "2", "3" }, new String[] { "1", "2", "3" }), // new TData(new String[] { "", "2", "3" }, new String[] { "2", "3" }), // new TData(new String[] { "1", "", "3" }, new String[] { "1", "3" }), // new TData(new String[] { "1", " ", "3" }, new String[] { "1", " ", "3" }), // new TData(new String[] { "1", null, "3" }, new String[] { "1", "3" }), // new TData(new String[] { "1", "2", "" }, new String[] { "1", "2" }), // }; for (int i = 0; i < data.length; i++) { System.out.println("[" + i + "]" + StringUtils.join(data[i].values, ",")); String[] result = ActionFormUtil.cleanEmpty(data[i].values); System.out.println( " " + StringUtils.join(data[i].values, ",") + "-->Result:" + StringUtils.join(result, ",")); String[] expect = data[i].expect; assertEquals(StringUtils.join(expect, ","), StringUtils.join(result, ",")); } } public void testStrings2Ints() { String[][] data = { // { "1", "2", "3" }, { "3" }, // { "-1", "2", "3" }, { "3" }, // { "1", "-2", "3" }, { "3" }, // { "1", "", "3" }, { "2" }, // { "-1", "", "", "" }, { "1" }, // { "-1", "ab", "12d" }, { "1" }, // }; for (int i = 0; i < data.length / 2; i++) { int[] ints = ActionFormUtil.Strings2Ints(data[i * 2]); assertEquals(data[i * 2 + 1][0].charAt(0) - '0', ints.length); } } public void testJoin() { } public void testIsPowerOfTwo() { } public void testApplyAppendixMifier() { } }