Commits

Anonymous committed aef1c1f

FileManager refactoring, new test for FileManager and resource files, details http://jira.opensymphony.com/browse/XW-674

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1923e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits 2c82b51

Comments (0)

Files changed (1)

src/test/com/opensymphony/xwork2/util/FileManagerTest.java

+package com.opensymphony.xwork2.util;
+
+import com.opensymphony.xwork2.XWorkTestCase;
+
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * FileManager Tester.
+ *
+ * @author <Lukasz>
+ * @since <pre>02/18/2009</pre>
+ * @version 1.0
+ */
+public class FileManagerTest extends XWorkTestCase {
+
+    public void testGetFileInJar() throws Exception {
+        testLoadFile("xwork-jar.xml");
+        testLoadFile("xwork - jar.xml");
+        testLoadFile("xwork-zip.xml");
+        testLoadFile("xwork - zip.xml");
+        testLoadFile("xwork-jar2.xml");
+        testLoadFile("xwork - jar2.xml");
+        testLoadFile("xwork-zip2.xml");
+        testLoadFile("xwork - zip2.xml");
+    }
+
+    private void testLoadFile(String fileName) {
+        FileManager.setReloadingConfigs(true);
+        URL url = ClassLoaderUtil.getResource(fileName, FileManager.class);
+        InputStream file = FileManager.loadFile(url, true);
+        assertNotNull(file);
+        assertFalse(!FileManager.fileNeedsReloading(fileName));
+    }
+
+}