1 22 package org.objectweb.petals.tools.coberturareportplugin; 23 24 import java.io.File ; 25 import java.io.IOException ; 26 import java.util.ArrayList ; 27 import java.util.List ; 28 import java.util.Locale ; 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 42 public class CoberturaReportPluginReportTest extends TestCase { 43 44 public void testExecuteReport() throws MavenReportException, IOException { 45 CoberturaReportPluginReport pluginReport = new CoberturaReportPluginReport(); 46 47 String 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 <String > modules = new ArrayList <String >(); 53 modules.add("test"); 54 55 EasyMock.expect(project.getModules()).andReturn(modules).anyTimes(); 56 57 EasyMock.replay(project); 58 59 new File (baseDir + "target" + File.separator + "test").mkdir(); 60 FileUtils.copyFileToDirectory(new File (baseDir + "src" + File.separator 61 + "test-data" + File.separator + "cobertura.ser"), new File ( 62 baseDir + "target" + File.separator + "test")); 63 64 pluginReport.outputDirectory = new File (baseDir + "target"); 65 pluginReport.project = project; 66 pluginReport.baseDir = baseDir + "target"; 67 pluginReport.executeReport(Locale.FRANCE); 68 69 assertTrue(new File (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 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 (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 (baseDir 88 + "target").getAbsolutePath()); 89 assertNull(pluginReport.getSiteRenderer()); 90 } 91 } 92 | Popular Tags |