1 17 package org.apache.servicemix.jbi.installation; 18 19 import org.apache.servicemix.jbi.container.JBIContainer; 20 import org.apache.servicemix.jbi.util.FileUtil; 21 22 import java.io.File ; 23 import java.net.URL ; 24 25 import junit.framework.TestCase; 26 27 35 public class ComponentAssemblyInstallationTest extends TestCase { 36 protected JBIContainer container = new JBIContainer(); 37 38 private File tempRootDir; 39 40 43 protected void setUp() throws Exception { 44 super.setUp(); 45 container.setCreateMBeanServer(false); 46 container.setMonitorInstallationDirectory(false); 47 tempRootDir = File.createTempFile("servicemix", "rootDir"); 48 tempRootDir.delete(); 49 File tempTemp = new File (tempRootDir.getAbsolutePath() + "/temp"); 50 if (!tempTemp.mkdirs()) 51 fail("Unable to create temporary working root directory [" 52 + tempTemp.getAbsolutePath() + "]"); 53 54 System.out.println("Using temporary root directory [" 55 + tempRootDir.getAbsolutePath() + "]"); 56 57 container.setRootDir(tempRootDir.getAbsolutePath()); 58 container.setMonitorDeploymentDirectory(false); 59 container.setMonitorInstallationDirectory(false); 60 container.init(); 61 container.start(); 62 63 } 64 65 public void testInvalidComponentInstallation() throws Exception { 66 try { 67 URL componentResource = getClass().getClassLoader().getResource("logger-component-1.0-jbi-installer.zip"); 69 assertNotNull("The component JAR logger-component-1.0-jbi-installer is missing from the classpath", componentResource); 70 container.installArchive(componentResource.toExternalForm()); 71 fail("Missing bootstrap should have thrown exception?"); 72 } catch (Exception e) { 73 74 } 75 } 76 77 public void testResourceInstallation() throws Exception { 78 try { 79 URL assemblyResource = getClass().getClassLoader().getResource("sample-jbi.zip"); 80 assertNotNull("The assembly JAR sample-jbi.jar is missing from the classpath",assemblyResource); 81 String url = assemblyResource.toExternalForm(); 82 container.installArchive(url); 83 Thread.sleep(10000); 84 } catch (Exception e) { 85 e.printStackTrace(); 86 fail(e.getMessage()); 87 } 88 } 89 90 93 94 protected void tearDown() throws Exception { 95 super.tearDown(); 96 container.shutDown(); 97 FileUtil.deleteFile(tempRootDir); 98 } 99 100 } 101 | Popular Tags |