01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.ivy.ant;
19:
20: import java.io.File;
21:
22: import junit.framework.TestCase;
23:
24: import org.apache.tools.ant.Project;
25: import org.apache.tools.ant.taskdefs.Delete;
26:
27: public class IvyListModulesTest extends TestCase {
28: private File cache;
29:
30: private IvyListModules findModules;
31:
32: protected void setUp() throws Exception {
33: createCache();
34: Project project = new Project();
35: project.setProperty("ivy.settings.file",
36: "test/repositories/ivysettings.xml");
37:
38: findModules = new IvyListModules();
39: findModules.setProject(project);
40: }
41:
42: private void createCache() {
43: cache = new File("build/cache");
44: cache.mkdirs();
45: }
46:
47: protected void tearDown() throws Exception {
48: cleanCache();
49: }
50:
51: private void cleanCache() {
52: Delete del = new Delete();
53: del.setProject(new Project());
54: del.setDir(cache);
55: del.execute();
56: }
57:
58: public void testExact() throws Exception {
59: findModules.setOrganisation("org1");
60: findModules.setModule("mod1.1");
61: findModules.setRevision("1.0");
62: findModules.setProperty("found");
63: findModules.setValue("[organisation]/[module]/[revision]");
64: findModules.execute();
65: assertEquals("org1/mod1.1/1.0", findModules.getProject()
66: .getProperty("found"));
67: }
68:
69: public void testAllRevs() throws Exception {
70: findModules.setOrganisation("org1");
71: findModules.setModule("mod1.1");
72: findModules.setRevision("*");
73: findModules.setProperty("found.[revision]");
74: findModules.setValue("true");
75: findModules.execute();
76: assertEquals("true", findModules.getProject().getProperty(
77: "found.1.0"));
78: assertEquals("true", findModules.getProject().getProperty(
79: "found.1.1"));
80: assertEquals("true", findModules.getProject().getProperty(
81: "found.2.0"));
82: }
83:
84: }
|