KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > util > ResourceUtilsTest


1 /*
2  * Copyright 2003-2004 The Apache Software Foundation
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  */

17
18 package org.apache.tools.ant.util;
19
20 import org.apache.tools.ant.Project;
21 import org.apache.tools.ant.taskdefs.Echo;
22 import org.apache.tools.ant.types.Resource;
23 import org.apache.tools.ant.types.ResourceFactory;
24
25 import java.io.File JavaDoc;
26
27 import junit.framework.TestCase;
28
29 /**
30  * Tests for org.apache.tools.ant.util.ResourceUtils.
31  */

32 public class ResourceUtilsTest extends TestCase
33     implements ResourceFactory, FileNameMapper {
34
35     private Echo taskINeedForLogging = new Echo();
36
37     public ResourceUtilsTest(String JavaDoc name) {
38         super(name);
39         taskINeedForLogging.setProject(new Project());
40     }
41
42     public void testNoDuplicates() {
43         Resource r = new Resource("samual vimes", true, 1, false);
44         Resource[] toNew =
45             ResourceUtils.selectOutOfDateSources(taskINeedForLogging,
46                                                  new Resource[] {r},
47                                                  this, this);
48         assertEquals(1, toNew.length);
49     }
50
51     /* ============ ResourceFactory interface ====================== */
52     public Resource getResource(String JavaDoc name) {
53         return new Resource(name); // implies lastModified == 0
54
}
55
56     /* ============ FileNameMapper interface ======================= */
57     public void setFrom(String JavaDoc s) {}
58     public void setTo(String JavaDoc s) {}
59     public String JavaDoc[] mapFileName(String JavaDoc s) {
60         return new String JavaDoc[] {"fred colon", "carrot ironfoundersson"};
61     }
62 }
63
Popular Tags