001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018: package org.apache.ivy.ant;
019:
020: import java.io.File;
021: import java.util.Locale;
022:
023: import junit.framework.TestCase;
024:
025: import org.apache.tools.ant.Project;
026: import org.apache.tools.ant.taskdefs.Delete;
027:
028: public class IvyReportTest extends TestCase {
029: private File cache;
030:
031: private IvyReport report;
032:
033: private Project project;
034:
035: protected void setUp() throws Exception {
036: createCache();
037: project = new Project();
038: project.setProperty("ivy.settings.file",
039: "test/repositories/ivysettings.xml");
040:
041: report = new IvyReport();
042: report.setTaskName("report");
043: report.setProject(project);
044: System.setProperty("ivy.cache.dir", cache.getAbsolutePath());
045: }
046:
047: private void createCache() {
048: cache = new File("build/cache");
049: cache.mkdirs();
050: }
051:
052: protected void tearDown() throws Exception {
053: cleanCache();
054: }
055:
056: private void cleanCache() {
057: Delete del = new Delete();
058: del.setProject(new Project());
059: del.setDir(cache);
060: del.execute();
061: }
062:
063: public void testSimple() throws Exception {
064: Locale oldLocale = Locale.getDefault();
065:
066: try {
067: // set the locale to UK as workaround for SUN bug 6240963
068: Locale.setDefault(Locale.UK);
069:
070: IvyResolve res = new IvyResolve();
071: res.setProject(project);
072: res.setFile(new File(
073: "test/java/org/apache/ivy/ant/ivy-simple.xml"));
074: res.execute();
075:
076: report.setTodir(new File(cache, "report"));
077: report.execute();
078:
079: assertTrue(new File(cache,
080: "report/apache-resolve-simple-default.html")
081: .exists());
082: assertTrue(new File(cache,
083: "report/apache-resolve-simple-default.graphml")
084: .exists());
085: } finally {
086: Locale.setDefault(oldLocale);
087: }
088: }
089:
090: public void testMultipleConfigurations() throws Exception {
091: Locale oldLocale = Locale.getDefault();
092:
093: try {
094: // set the locale to UK as workaround for SUN bug 6240963
095: Locale.setDefault(Locale.UK);
096:
097: IvyResolve res = new IvyResolve();
098: res.setProject(project);
099: res.setFile(new File(
100: "test/java/org/apache/ivy/ant/ivy-multiconf.xml"));
101: res.execute();
102:
103: report.setTodir(new File(cache, "report"));
104: report.execute();
105:
106: assertTrue(new File(cache,
107: "report/apache-resolve-simple-default.html")
108: .exists());
109: assertTrue(new File(cache,
110: "report/apache-resolve-simple-default.graphml")
111: .exists());
112: assertTrue(new File(cache,
113: "report/apache-resolve-simple-compile.html")
114: .exists());
115: assertTrue(new File(cache,
116: "report/apache-resolve-simple-compile.graphml")
117: .exists());
118: } finally {
119: Locale.setDefault(oldLocale);
120: }
121: }
122:
123: public void testRegularCircular() throws Exception {
124: project.setProperty("ivy.dep.file",
125: "test/repositories/2/mod11.1/ivy-1.0.xml");
126: IvyResolve res = new IvyResolve();
127: res.setProject(project);
128: res.execute();
129:
130: report.setTodir(new File(cache, "report"));
131: report.setXml(true);
132:
133: // do not test any xsl transformation here, because of problems of build in our continuous
134: // integration server
135: report.setXsl(false);
136: report.setGraph(false);
137:
138: report.execute();
139:
140: assertTrue(new File(cache, "report/org11-mod11.1-compile.xml")
141: .exists());
142: }
143: }
|