1 22 package org.objectweb.petals.jbi.management.autoload; 23 24 import java.io.File ; 25 import java.io.IOException ; 26 27 import junit.framework.TestCase; 28 29 import org.apache.commons.io.FileUtils; 30 31 36 public class InstallDirectoryScannerTest extends TestCase { 37 38 private InstallDirectoryScanner directoryScanner; 39 40 private String baseDir; 41 42 private AutoLoaderImplMock autoLoadImplMock; 43 44 public void setUp() throws IOException { 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 (baseDir + "target" + File.separator + "install").exists()) { 50 FileUtils.forceDelete(new File (baseDir + "target" + File.separator 51 + "install")); 52 } 53 new File (baseDir + "target" + File.separator + "install").mkdir(); 54 directoryScanner = new InstallDirectoryScanner(autoLoadImplMock, 55 new File (baseDir + "target" + File.separator + "install")); 56 } 57 58 public void testRunInstall() throws IOException { 59 new File (baseDir + "target" + File.separator).mkdir(); 60 new File (baseDir + "target" + File.separator + "install").mkdir(); 61 FileUtils.copyFileToDirectory(new File (baseDir + "src" + File.separator 62 + "test-data" + File.separator + "packages" + File.separator 63 + "installation01.zip"), new File (baseDir + "target" 64 + File.separator + "install")); 65 directoryScanner.run(); 66 assertTrue(autoLoadImplMock.isInstalled()); 67 } 68 69 public void testRunNothing() throws IOException { 70 FileUtils.forceDelete(new File (baseDir + "target" + File.separator 71 + "install")); 72 new File (baseDir + "target" + File.separator + "install").mkdir(); 73 directoryScanner.run(); 74 assertFalse(autoLoadImplMock.isInstalled()); 75 } 76 77 } 78 | Popular Tags |