KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > jbi > management > autoload > InstallDirectoryScannerTest


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: DirectoryScannerTest.java 14:37:50 ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.jbi.management.autoload;
23
24 import java.io.File JavaDoc;
25 import java.io.IOException JavaDoc;
26
27 import junit.framework.TestCase;
28
29 import org.apache.commons.io.FileUtils;
30
31 /**
32  * Test of the DirectoryScanner
33  *
34  * @author ddesjardins - eBMWebsourcing
35  */

36 public class InstallDirectoryScannerTest extends TestCase {
37
38     private InstallDirectoryScanner directoryScanner;
39
40     private String JavaDoc baseDir;
41
42     private AutoLoaderImplMock autoLoadImplMock;
43
44     public void setUp() throws IOException JavaDoc {
45         autoLoadImplMock = new AutoLoaderImplMock();
46         baseDir = this.getClass().getResource(".").toString();
47         baseDir = baseDir.substring(0, baseDir.indexOf("target"));
48         baseDir = baseDir.substring(baseDir.indexOf(":") + 1);
49         if (new File JavaDoc(baseDir + "target" + File.separator + "install").exists()) {
50             FileUtils.forceDelete(new File JavaDoc(baseDir + "target" + File.separator
51                 + "install"));
52         }
53         new File JavaDoc(baseDir + "target" + File.separator + "install").mkdir();
54         directoryScanner = new InstallDirectoryScanner(autoLoadImplMock,
55             new File JavaDoc(baseDir + "target" + File.separator + "install"));
56     }
57
58     public void testRunInstall() throws IOException JavaDoc {
59         new File JavaDoc(baseDir + "target" + File.separator).mkdir();
60         new File JavaDoc(baseDir + "target" + File.separator + "install").mkdir();
61         FileUtils.copyFileToDirectory(new File JavaDoc(baseDir + "src" + File.separator
62             + "test-data" + File.separator + "packages" + File.separator
63             + "installation01.zip"), new File JavaDoc(baseDir + "target"
64             + File.separator + "install"));
65         directoryScanner.run();
66         assertTrue(autoLoadImplMock.isInstalled());
67     }
68
69     public void testRunNothing() throws IOException JavaDoc {
70         FileUtils.forceDelete(new File JavaDoc(baseDir + "target" + File.separator
71             + "install"));
72         new File JavaDoc(baseDir + "target" + File.separator + "install").mkdir();
73         directoryScanner.run();
74         assertFalse(autoLoadImplMock.isInstalled());
75     }
76
77 }
78
Popular Tags