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:
26: public class IvyInfoTest extends TestCase {
27: private IvyInfo info;
28:
29: protected void setUp() throws Exception {
30: Project project = new Project();
31:
32: info = new IvyInfo();
33: info.setProject(project);
34: }
35:
36: public void testSimple() throws Exception {
37: info.setFile(new File(
38: "test/java/org/apache/ivy/ant/ivy-simple.xml"));
39: info.execute();
40:
41: assertEquals("apache", info.getProject().getProperty(
42: "ivy.organisation"));
43: assertEquals("resolve-simple", info.getProject().getProperty(
44: "ivy.module"));
45: assertEquals("1.0", info.getProject().getProperty(
46: "ivy.revision"));
47: assertEquals("default", info.getProject().getProperty(
48: "ivy.configurations"));
49: assertEquals("default", info.getProject().getProperty(
50: "ivy.public.configurations"));
51: }
52:
53: public void testAll() throws Exception {
54: info.setFile(new File(
55: "test/java/org/apache/ivy/ant/ivy-info-all.xml"));
56: info.execute();
57:
58: assertEquals("apache", info.getProject().getProperty(
59: "ivy.organisation"));
60: assertEquals("info-all", info.getProject().getProperty(
61: "ivy.module"));
62: assertEquals("1.0", info.getProject().getProperty(
63: "ivy.revision"));
64: assertEquals("release", info.getProject().getProperty(
65: "ivy.status"));
66: assertEquals("default, test, private", info.getProject()
67: .getProperty("ivy.configurations"));
68: assertEquals("default, test", info.getProject().getProperty(
69: "ivy.public.configurations"));
70: assertEquals("trunk", info.getProject().getProperty(
71: "ivy.branch"));
72: assertEquals("myvalue", info.getProject().getProperty(
73: "ivy.extra.myextraatt"));
74: }
75:
76: public void testIVY726() throws Exception {
77: info.setFile(new File(
78: "test/java/org/apache/ivy/ant/ivy-info-all.xml"));
79: info.execute();
80:
81: assertTrue(info.getProject().getProperty("ivy.extra.branch") == null);
82: }
83:
84: }
|