scolebourne 2002/10/13 15:42:59 Modified: lang/src/test/org/apache/commons/lang LangTestSuite.java Added: lang/src/test/org/apache/commons/lang ArrayUtilsTest.java Log: Initial version of ArrayUtils testing, testing incomplete at present Revision Changes Path 1.5 +2 -1 jakarta-commons/lang/src/test/org/apache/commons/lang/LangTestSuite.java Index: LangTestSuite.java =================================================================== RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/LangTestSuite.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- LangTestSuite.java 12 Sep 2002 22:01:25 -0000 1.4 +++ LangTestSuite.java 13 Oct 2002 22:42:59 -0000 1.5 @@ -86,6 +86,7 @@ public static Test suite() { TestSuite suite = new TestSuite(); suite.setName("Commons-Lang Tests"); + suite.addTest(ArrayUtilsTest.suite()); suite.addTest(CharSetUtilsTest.suite()); suite.addTest(NumberRangeTest.suite()); suite.addTest(NumberUtilsTest.suite()); 1.1 jakarta-commons/lang/src/test/org/apache/commons/lang/ArrayUtilsTest.java Index: ArrayUtilsTest.java =================================================================== package org.apache.commons.lang; /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Commons", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ import java.util.Map; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import junit.textui.TestRunner; /** * Unit tests {@link org.apache.commons.lang.SerializationUtils}. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephen Colebourne</a> * @author Moritz Petersen * @version $Id: ArrayUtilsTest.java,v 1.1 2002/10/13 22:42:59 scolebourne Exp $ */ public class ArrayUtilsTest extends TestCase { public ArrayUtilsTest(String name) { super(name); } public static void main(String[] args) { TestRunner.run(suite()); } public static Test suite() { TestSuite suite = new TestSuite(ArrayUtilsTest.class); suite.setName("ArrayUtils Tests"); return suite; } protected void setUp() throws Exception { super.setUp(); } protected void tearDown() throws Exception { super.tearDown(); } //----------------------------------------------------------------------- public void testToMap() { Map map = ArrayUtils.toMap(new String[][] {{"foo", "bar"}, {"hello", "world"}}); assertEquals("bar", map.get("foo")); assertEquals("world", map.get("hello")); try { ArrayUtils.toMap(null); fail("exception expected"); } catch (IllegalArgumentException e) { // expected. } try { ArrayUtils.toMap(new String[][] {{"foo", "bar"}, {"short"}}); fail("exception expected"); } catch (IllegalArgumentException e) { // expected. } try { ArrayUtils.toMap(new Object[] {new Object[] {"foo", "bar"}, "illegal type"}); fail("exception expected"); } catch (IllegalArgumentException e) { // expected. } try { ArrayUtils.toMap(new Object[] {new Object[] {"foo", "bar"}, null}); fail("exception expected"); } catch (IllegalArgumentException e) { // expected. } map = ArrayUtils.toMap(new Object[] {new Map.Entry() { public Object getKey() { return "foo"; } public Object getValue() { return "bar"; } public Object setValue(Object value) { throw new UnsupportedOperationException(); } public boolean equals(Object o) { throw new UnsupportedOperationException(); } public int hashCode() { throw new UnsupportedOperationException(); } }}); assertEquals("bar", map.get("foo")); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>