1 17 package org.apache.servicemix.jbi.management.task; 18 19 import java.io.File ; 20 import java.net.URL ; 21 22 import org.apache.servicemix.jbi.util.FileUtil; 23 import org.apache.tools.ant.Project; 24 25 29 public class DeployAndListServiceAssemblyTasksTest extends JbiTaskSupport { 30 31 private static final String XML_OUTPUT_PROPERTY = "test.xml.output"; 32 33 private DeployServiceAssemblyTask deployServiceAssembliesTask; 34 35 private File rootDir = new File ("target/testWDIR"); 36 37 private ListServiceAssembliesTask listServiceAssembliesTask; 38 39 private Project project = new Project(); 40 41 44 protected void setUp() throws Exception { 45 FileUtil.deleteFile(rootDir); 46 this.container.setRootDir(rootDir.getPath()); 47 super.setUp(); 48 deployServiceAssembliesTask = new DeployServiceAssemblyTask() { 49 }; 50 deployServiceAssembliesTask.setProject(new Project()); 51 deployServiceAssembliesTask.init(); 52 53 listServiceAssembliesTask = new ListServiceAssembliesTask(); 54 listServiceAssembliesTask.setProject(project); 55 listServiceAssembliesTask.init(); 56 } 57 58 61 protected void tearDown() throws Exception { 62 deployServiceAssembliesTask.close(); 63 super.tearDown(); 64 } 65 66 public void testInstallationAndList() throws Exception { 67 URL url = getClass().getClassLoader().getResource( 68 "org/apache/servicemix/jbi/installation/testassembly.jar"); 69 70 listServiceAssembliesTask.setServiceAssemblyName("sa"); 71 listServiceAssembliesTask.setXmlOutput(XML_OUTPUT_PROPERTY); 72 listServiceAssembliesTask.execute(); 73 74 System.out.println(project.getProperty(XML_OUTPUT_PROPERTY)); 75 76 if (url != null) { 77 String file = url.getFile(); 78 deployServiceAssembliesTask.setFile(file); 79 deployServiceAssembliesTask.init(); 80 deployServiceAssembliesTask.execute(); 81 File testFile = new File (rootDir, "service-assemblies" 82 + File.separator + "sa"); 83 assertTrue(testFile.exists()); 84 } 85 86 listServiceAssembliesTask.setServiceAssemblyName("sa"); 87 listServiceAssembliesTask.setXmlOutput(XML_OUTPUT_PROPERTY); 88 listServiceAssembliesTask.execute(); 89 90 System.out.println(project.getProperty(XML_OUTPUT_PROPERTY)); 91 92 FileUtil.deleteFile(rootDir); 93 94 } 95 } 96 | Popular Tags |