KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > tools > coberturareportplugin > CoberturaReportPluginReportTest


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: CoberturaReportPluginReportTest.java 11:31:42 AM ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.tools.coberturareportplugin;
23
24 import java.io.File JavaDoc;
25 import java.io.IOException JavaDoc;
26 import java.util.ArrayList JavaDoc;
27 import java.util.List JavaDoc;
28 import java.util.Locale JavaDoc;
29
30 import org.apache.commons.io.FileUtils;
31 import org.apache.maven.project.MavenProject;
32 import org.apache.maven.reporting.MavenReportException;
33 import org.easymock.classextension.EasyMock;
34
35 import junit.framework.TestCase;
36
37 /**
38  * Tests of CoberturaReportPluginReport
39  *
40  * @author ddesjardins - eBMWebsourcing
41  */

42 public class CoberturaReportPluginReportTest extends TestCase {
43
44     public void testExecuteReport() throws MavenReportException, IOException JavaDoc {
45         CoberturaReportPluginReport pluginReport = new CoberturaReportPluginReport();
46
47         String JavaDoc baseDir = this.getClass().getResource(".").toString();
48         baseDir = baseDir.substring(0, baseDir.indexOf("target"));
49         baseDir = baseDir.substring(baseDir.indexOf(":") + 1);
50
51         MavenProject project = EasyMock.createMock(MavenProject.class);
52         List JavaDoc<String JavaDoc> modules = new ArrayList JavaDoc<String JavaDoc>();
53         modules.add("test");
54
55         EasyMock.expect(project.getModules()).andReturn(modules).anyTimes();
56
57         EasyMock.replay(project);
58
59         new File JavaDoc(baseDir + "target" + File.separator + "test").mkdir();
60         FileUtils.copyFileToDirectory(new File JavaDoc(baseDir + "src" + File.separator
61                 + "test-data" + File.separator + "cobertura.ser"), new File JavaDoc(
62                 baseDir + "target" + File.separator + "test"));
63
64         pluginReport.outputDirectory = new File JavaDoc(baseDir + "target");
65         pluginReport.project = project;
66         pluginReport.baseDir = baseDir + "target";
67         pluginReport.executeReport(Locale.FRANCE);
68
69         assertTrue(new File JavaDoc(baseDir + "target" + File.separator
70                 + "cobertura-sum" + File.separator + "index.html").exists());
71         assertEquals(pluginReport.getProject(), project);
72     }
73
74     public void testGetters() {
75         CoberturaReportPluginReport pluginReport = new CoberturaReportPluginReport();
76
77         String JavaDoc baseDir = this.getClass().getResource(".").toString();
78         baseDir = baseDir.substring(0, baseDir.indexOf("target"));
79         baseDir = baseDir.substring(baseDir.indexOf(":") + 1);
80
81         pluginReport.outputDirectory = new File JavaDoc(baseDir + "target");
82
83         assertEquals(pluginReport.getDescription(Locale.FRANCE),
84                 "Cobertura Summary Report Generator Task");
85         assertEquals(pluginReport.getName(Locale.FRANCE), "CSRG Task");
86         assertEquals(pluginReport.getOutputName(), "CSRG Task");
87         assertEquals(pluginReport.getOutputDirectory(), new File JavaDoc(baseDir
88                 + "target").getAbsolutePath());
89         assertNull(pluginReport.getSiteRenderer());
90     }
91 }
92
Popular Tags