KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > uitags > util > ArrayUtilsTest


1 /**
2  * May 7, 2006
3  *
4  * Copyright 2004 uitags
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package net.sf.uitags.util;
19
20 import junit.framework.TestCase;
21
22 public class ArrayUtilsTest extends TestCase {
23   public void testToArrayReturnsNullIfGivenNull() {
24     assertNull(ArrayUtils.toArray(null));
25   }
26
27   public void testToArray() {
28     String JavaDoc elementString = "one,two,three";
29     String JavaDoc[] elementArray = new String JavaDoc[] { "one", "two", "three" };
30
31     assertTrue(ArrayUtils.equals(
32         elementArray, ArrayUtils.toArray(elementString)));
33
34     elementString = "one,two, three";
35     assertFalse(ArrayUtils.equals(
36         elementArray, ArrayUtils.toArray(elementString)));
37
38     elementArray = new String JavaDoc[] { "one", "two", " three" };
39     assertTrue(ArrayUtils.equals(
40         elementArray, ArrayUtils.toArray(elementString)));
41   }
42
43   public void testToArrayOfTrimmedReturnsNullIfGivenNull() {
44     assertNull(ArrayUtils.toArrayOfTrimmed(null));
45   }
46
47   public void testToArrayOfTrimmed() {
48     String JavaDoc elementString = "one , two, three ,four";
49     String JavaDoc[] elementArray = new String JavaDoc[] { "one", "two", "three", "four" };
50
51     assertTrue(ArrayUtils.equals(
52         elementArray, ArrayUtils.toArrayOfTrimmed(elementString)));
53   }
54 }
55
Popular Tags