update test cases

This commit is contained in:
Shinsuke Sugaya 2018-05-19 12:10:49 +09:00
parent 54af75e45e
commit 60da70ca83
2 changed files with 11 additions and 4 deletions

View file

@ -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);
}

View file

@ -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");