KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cobertura > reporting > html > files > CopyFilesTest


1 /*
2  * Cobertura - http://cobertura.sourceforge.net/
3  *
4  * Copyright (C) 2005 Mark Doliner
5  *
6  * Cobertura is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published
8  * by the Free Software Foundation; either version 2 of the License,
9  * or (at your option) any later version.
10  *
11  * Cobertura is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Cobertura; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  */

21
22 package net.sourceforge.cobertura.reporting.html.files;
23
24 import java.io.File JavaDoc;
25 import java.io.IOException JavaDoc;
26
27 import junit.framework.TestCase;
28
29 public class CopyFilesTest extends TestCase
30 {
31     private final static String JavaDoc basedir = (System.getProperty("basedir") != null)
32             ? System.getProperty("basedir")
33             : "./";
34     private final static File JavaDoc tmpDir = new File JavaDoc(basedir, "/build/test/tmp");
35
36     public void setUp()
37     {
38         tmpDir.mkdirs();
39     }
40
41     private final static void removeDir(File JavaDoc dir)
42     {
43         File JavaDoc files[] = dir.listFiles();
44         for (int i = 0; i < files.length; i++)
45         {
46             if (files[i].isDirectory())
47                 removeDir(files[i]);
48             else
49                 files[i].delete();
50         }
51         dir.delete();
52     }
53
54     public void tearDown()
55     {
56         removeDir(tmpDir);
57     }
58
59     public static void testCopy() throws IOException JavaDoc
60     {
61         CopyFiles.copy(tmpDir);
62         assertTrue(new File JavaDoc(tmpDir, "help.html").isFile());
63         assertTrue(new File JavaDoc(tmpDir, "index.html").isFile());
64
65         File JavaDoc cssDir = new File JavaDoc(tmpDir, "css");
66         assertTrue(cssDir.isDirectory());
67         assertTrue(new File JavaDoc(cssDir, "help.css").isFile());
68         assertTrue(new File JavaDoc(cssDir, "main.css").isFile());
69         assertTrue(new File JavaDoc(cssDir, "sortabletable.css").isFile());
70         assertTrue(new File JavaDoc(cssDir, "source-viewer.css").isFile());
71         assertTrue(new File JavaDoc(cssDir, "tooltip.css").isFile());
72
73         File JavaDoc imagesDir = new File JavaDoc(tmpDir, "images");
74         assertTrue(imagesDir.isDirectory());
75         assertTrue(new File JavaDoc(imagesDir, "blank.png").isFile());
76         assertTrue(new File JavaDoc(imagesDir, "downsimple.png").isFile());
77         assertTrue(new File JavaDoc(imagesDir, "upsimple.png").isFile());
78
79         File JavaDoc jsDir = new File JavaDoc(tmpDir, "js");
80         assertTrue(jsDir.isDirectory());
81         assertTrue(new File JavaDoc(jsDir, "customsorttypes.js").isFile());
82         assertTrue(new File JavaDoc(jsDir, "popup.js").isFile());
83         assertTrue(new File JavaDoc(jsDir, "sortabletable.js").isFile());
84         assertTrue(new File JavaDoc(jsDir, "stringbuilder.js").isFile());
85     }
86 }
Popular Tags