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 IvyFindRevisionTest extends TestCase {
28: private File cache;
29:
30: private IvyFindRevision findRevision;
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: findRevision = new IvyFindRevision();
39: findRevision.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 testProperty() throws Exception {
59: findRevision.setOrganisation("org1");
60: findRevision.setModule("mod1.1");
61: findRevision.setRevision("1.0");
62: findRevision.setProperty("test.revision");
63: findRevision.execute();
64: assertEquals("1.0", findRevision.getProject().getProperty(
65: "test.revision"));
66: }
67:
68: public void testLatest() throws Exception {
69: findRevision.setOrganisation("org1");
70: findRevision.setModule("mod1.1");
71: findRevision.setRevision("latest.integration");
72: findRevision.execute();
73: assertEquals("2.0", findRevision.getProject().getProperty(
74: "ivy.revision"));
75: }
76:
77: public void testLatestSubversion() throws Exception {
78: findRevision.setOrganisation("org1");
79: findRevision.setModule("mod1.1");
80: findRevision.setRevision("1.0+");
81: findRevision.execute();
82: assertEquals("1.0.1", findRevision.getProject().getProperty(
83: "ivy.revision"));
84: }
85:
86: }
|