1 17 package org.apache.servicemix.components.vfs; 18 19 import java.io.File ; 20 21 import org.apache.servicemix.jbi.util.FileUtil; 22 import org.apache.servicemix.tck.TestSupport; 23 import org.springframework.context.support.AbstractXmlApplicationContext; 24 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext; 25 26 import javax.xml.namespace.QName ; 27 28 31 public class FileTest extends TestSupport { 32 33 private static final String SYSTEM_OS_KEY = "os.name"; 34 private static final String WINDOWS = "Windows"; 35 36 protected void setUp() throws Exception { 37 super.setUp(); 38 if (isWindowsOS()) { 39 FileUtil.deleteFile(new File ("c:/tmp/servicemix/vfs/test")); 40 } else { 41 FileUtil.deleteFile(new File ("/tmp/servicemix/vfs/test")); 42 } 43 } 44 45 public void testSendMessagesToFileSystemThenPoollThem() throws Exception { 46 QName service = new QName ("http://servicemix.org/cheese/", "fileSender"); 47 assertSendAndReceiveMessages(service); 48 } 49 50 protected AbstractXmlApplicationContext createBeanFactory() { 51 return new ClassPathXmlApplicationContext(getSystemSupportedXMLConfig()); 52 } 53 54 protected String getSystemSupportedXMLConfig(){ 55 if (isWindowsOS()) { 56 return "org/apache/servicemix/components/vfs/example_win.xml"; 57 } else { 58 return "org/apache/servicemix/components/vfs/example.xml"; 59 } 60 } 61 62 protected boolean isWindowsOS() { 63 String os = System.getProperty(SYSTEM_OS_KEY); 64 boolean isWindows = false; 65 int index = (os==null?-1:os.indexOf(WINDOWS)); 66 if(index > -1 ){ 67 isWindows = true; 68 } 69 return isWindows; 70 } 71 } 72 | Popular Tags |