KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > components > vfs > FileTest


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.servicemix.components.vfs;
18
19 import java.io.File JavaDoc;
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 JavaDoc;
27
28 /**
29  * @version $Revision: 426415 $
30  */

31 public class FileTest extends TestSupport {
32
33     private static final String JavaDoc SYSTEM_OS_KEY = "os.name";
34     private static final String JavaDoc WINDOWS = "Windows";
35
36     protected void setUp() throws Exception JavaDoc {
37         super.setUp();
38         if (isWindowsOS()) {
39             FileUtil.deleteFile(new File JavaDoc("c:/tmp/servicemix/vfs/test"));
40         } else {
41             FileUtil.deleteFile(new File JavaDoc("/tmp/servicemix/vfs/test"));
42         }
43     }
44     
45     public void testSendMessagesToFileSystemThenPoollThem() throws Exception JavaDoc {
46         QName JavaDoc service = new QName JavaDoc("http://servicemix.org/cheese/", "fileSender");
47         assertSendAndReceiveMessages(service);
48     }
49
50     protected AbstractXmlApplicationContext createBeanFactory() {
51         return new ClassPathXmlApplicationContext(getSystemSupportedXMLConfig());
52     }
53
54     protected String JavaDoc 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 JavaDoc 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