01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2005-2006, Geotools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.resources;
17:
18: // J2SE dependencies
19: import java.io.File;
20: import java.io.Serializable;
21:
22: // JUnit dependencies
23: import junit.framework.Test;
24: import junit.framework.TestCase;
25: import junit.framework.TestSuite;
26:
27: /**
28: * Tests the {@link Utilities} static methods.
29: *
30: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/test/java/org/geotools/resources/UtilitiesTest.java $
31: * @version $Id: UtilitiesTest.java 24576 2007-02-24 00:07:40Z desruisseaux $
32: * @author Martin Desruisseaux
33: */
34: public final class UtilitiesTest extends TestCase {
35: /**
36: * Run the test from the command line.
37: */
38: public static void main(String[] args) {
39: junit.textui.TestRunner.run(suite());
40: }
41:
42: /**
43: * Returns the test suite.
44: */
45: public static Test suite() {
46: return new TestSuite(UtilitiesTest.class);
47: }
48:
49: /**
50: * Constructs a test case with the given name.
51: */
52: public UtilitiesTest(String name) {
53: super (name);
54: }
55:
56: /**
57: * Tests {@link Utilities#equals}.
58: */
59: public void testEquals() {
60: assertTrue(Utilities.equals(null, null));
61: assertFalse(Utilities.equals(null, ""));
62: assertFalse(Utilities.equals("", null));
63: assertTrue(Utilities.equals("", ""));
64: assertFalse(Utilities.equals(" ", ""));
65: }
66:
67: /**
68: * Tests {@link Utilities#spaces}.
69: */
70: public void testSpaces() {
71: assertEquals("", Utilities.spaces(0));
72: assertEquals(" ", Utilities.spaces(1));
73: assertEquals(" ", Utilities.spaces(8));
74: }
75:
76: /**
77: * Tests {@link Utilities#sameInterfaces}.
78: */
79: public void testSameInterfaces() {
80: assertTrue(Utilities.sameInterfaces(StringBuffer.class,
81: String.class, CharSequence.class));
82: assertTrue(Utilities.sameInterfaces(StringBuffer.class,
83: String.class, Serializable.class));
84: assertFalse(Utilities.sameInterfaces(File.class, String.class,
85: CharSequence.class));
86: assertTrue(Utilities.sameInterfaces(File.class, String.class,
87: Serializable.class));
88: }
89: }
|