瀏覽代碼

update test cases

Shinsuke Sugaya 7 年之前
父節點
當前提交
60da70ca83

+ 6 - 0
src/main/java/org/codelibs/fess/helper/PathMappingHelper.java

@@ -31,6 +31,7 @@ import org.codelibs.fess.es.config.exentity.PathMapping;
 import org.codelibs.fess.util.ComponentUtil;
 import org.codelibs.fess.util.DocumentUtil;
 import org.codelibs.fess.util.GroovyUtil;
+import org.lastaflute.di.core.exception.ComponentNotFoundException;
 import org.lastaflute.di.core.factory.SingletonLaContainerFactory;
 import org.lastaflute.web.util.LaRequestUtil;
 import org.slf4j.Logger;
@@ -66,6 +67,11 @@ public class PathMappingHelper {
                 cb.fetchFirst(ComponentUtil.getFessConfig().getPagePathMappingMaxFetchSizeAsInteger());
             });
             return cachedPathMappingList.size();
+        } catch (final ComponentNotFoundException e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Failed to load path mappings.", e);
+            }
+            cachedPathMappingList = new ArrayList<>();
         } catch (final Exception e) {
             logger.warn("Failed to load path mappings.", e);
         }

+ 5 - 4
src/test/java/org/codelibs/fess/helper/ViewHelperTest.java

@@ -17,7 +17,6 @@ package org.codelibs.fess.helper;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -37,21 +36,24 @@ public class ViewHelperTest extends UnitFessTestCase {
 
     private File propertiesFile;
 
+    @Override
     public void setUp() throws Exception {
         super.setUp();
         propertiesFile = File.createTempFile("test", ".properties");
+        FileUtil.writeBytes(propertiesFile.getAbsolutePath(), new byte[0]);
         propertiesFile.deleteOnExit();
         DynamicProperties systemProps = new DynamicProperties(propertiesFile);
         ComponentUtil.register(systemProps, "systemProperties");
         userAgentHelper = new UserAgentHelper();
         ComponentUtil.register(userAgentHelper, "userAgentHelper");
         pathMappingHelper = new PathMappingHelper();
-        pathMappingHelper.cachedPathMappingList = new ArrayList<>();
+        pathMappingHelper.init();
         ComponentUtil.register(pathMappingHelper, "pathMappingHelper");
         viewHelper = new ViewHelper();
         viewHelper.init();
     }
 
+    @Override
     public void tearDown() throws Exception {
         propertiesFile.delete();
         super.tearDown();
@@ -135,8 +137,7 @@ public class ViewHelperTest extends UnitFessTestCase {
         PathMapping pathMapping = new PathMapping();
         pathMapping.setRegex("ftp:");
         pathMapping.setReplacement("file:");
-        pathMappingHelper.cachedPathMappingList = new ArrayList<>();
-        pathMappingHelper.cachedPathMappingList.add(pathMapping);
+        ComponentUtil.getPathMappingHelper().cachedPathMappingList.add(pathMapping);
         // ftp->file
         assertUrlLink("ftp:/home/taro/test.txt", //
                 "file://home/taro/test.txt");