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;
|
---|
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 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 name) {
|
---|
53 | return new Resource(name); // implies lastModified == 0
|
---|
54 | }
|
---|
55 |
|
---|
56 | /* ============ FileNameMapper interface ======================= */
|
---|
57 | public void setFrom(String s) {}
|
---|
58 | public void setTo(String s) {}
|
---|
59 | public String[] mapFileName(String s) {
|
---|
60 | return new String[] {"fred colon", "carrot ironfoundersson"};
|
---|
61 | }
|
---|
62 | }
|
---|