1 /**
2 * Copyright 2010, CSIRO Australia.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package au.csiro.netcdf.util;
17
18 import java.util.List;
19
20 import junit.framework.TestCase;
21
22 /**
23 * Check the function of the Util class.
24 *
25 * @author James Dempsey on 23/06/2010
26 * @version $Revision: 29 $ $Date: 2010-06-24 10:29:08 +1000 (Thu, 24 Jun 2010) $
27 */
28 public class UtilTest extends TestCase
29 {
30
31 /* (non-Javadoc)
32 * @see junit.framework.TestCase#setUp()
33 */
34 protected void setUp() throws Exception
35 {
36 super.setUp();
37 }
38
39 /**
40 * Test method for {@link au.csiro.netcdf.util.Util#getListOfTargetFiles(java.lang.String, java.lang.String)}.
41 */
42 public final void testGetListOfTargetFiles()
43 {
44 List<String> files = Util.getListOfTargetFiles(".", "*.txt");
45 assertNotNull("Files should be a non-empty list", files);
46 assertTrue("Files should be a non-empty list", files.size()>1);
47 boolean hasUsage = false;
48 for (String string : files)
49 {
50 if (string.endsWith("USAGE.txt"))
51 {
52 hasUsage = true;
53 }
54 }
55 assertTrue("Expected to find USAGE.txt in result set.", hasUsage);
56
57 }
58
59 /**
60 * Test method for {@link au.csiro.netcdf.util.Util#getListOfTargetFiles(java.lang.String, java.lang.String)}.
61 */
62 public final void testGetListOfTargetFilesEscaped()
63 {
64 List<String> files = Util.getListOfTargetFiles(".", "\\*.txt");
65 assertNotNull("Files should be a non-empty list", files);
66 assertTrue("Files should be a non-empty list", files.size()>1);
67 boolean hasUsage = false;
68 for (String string : files)
69 {
70 if (string.endsWith("USAGE.txt"))
71 {
72 hasUsage = true;
73 }
74 }
75 assertTrue("Expected to find USAGE.txt in result set.", hasUsage);
76
77 }
78
79 }