1 17 package org.apache.servicemix.jbi.installation; 18 19 import org.apache.servicemix.jbi.container.JBIContainer; 20 21 import java.io.File ; 22 import java.net.URL ; 23 24 import junit.framework.TestCase; 25 26 32 public class ExplodedComponentInstallationTest extends TestCase { 33 protected JBIContainer container = new JBIContainer(); 34 35 private File tempRootDir; 36 37 private static final String COMPONENT_NAME = "logger-component-1.0-exploded.jar"; 38 39 42 protected void setUp() throws Exception { 43 super.setUp(); 44 container.setCreateMBeanServer(true); 45 container.setMonitorInstallationDirectory(true); 46 tempRootDir = File.createTempFile("servicemix", "rootDir"); 47 tempRootDir.delete(); 48 File tempTemp = new File (tempRootDir.getAbsolutePath() + "/temp"); 49 if (!tempTemp.mkdirs()) 50 fail("Unable to create temporary working root directory [" 51 + tempTemp.getAbsolutePath() + "]"); 52 53 System.out.println("Using temporary root directory [" 54 + tempRootDir.getAbsolutePath() + "]"); 55 56 container.setRootDir(tempRootDir.getAbsolutePath()); 57 container.init(); 58 container.start(); 59 60 } 61 62 public void testInstallation() throws Exception { 63 try { 64 URL componentResource = getClass().getClassLoader().getResource( 66 COMPONENT_NAME); 67 assertNotNull("Unable to find exploded resource " + COMPONENT_NAME, 68 componentResource); 69 container.installArchive(componentResource.getFile()); 70 71 fail("Component should be invalid"); 72 } catch (Exception e) { 73 } 74 } 75 76 79 protected void tearDown() throws Exception { 80 super.tearDown(); 81 container.shutDown(); 82 } 84 85 public static boolean deleteDir(File dir) { 86 System.out.println("Deleting directory : " + dir.getAbsolutePath()); 87 if (dir.isDirectory()) { 88 String [] children = dir.list(); 89 for (int i = 0; i < children.length; i++) { 90 boolean success = deleteDir(new File (dir, children[i])); 91 if (!success) { 92 return false; 93 } 94 } 95 } 96 97 return dir.delete(); 99 } 100 } 101 | Popular Tags |