소스 검색

import unit tests from 9.4.x

Keiichi Watanabe 9 년 전
부모
커밋
68d6264ba9

+ 217 - 0
src/test/java/org/codelibs/fess/crawler/transformer/FessFileTransformerTest.java

@@ -0,0 +1,217 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.codelibs.fess.crawler.transformer;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.codelibs.fess.Constants;
+import org.codelibs.fess.exception.FessSystemException;
+import org.codelibs.fess.unit.UnitFessTestCase;
+
+public class FessFileTransformerTest extends UnitFessTestCase {
+
+    private String encodeUrl(final String url) {
+        try {
+            return URLEncoder.encode(url, Constants.UTF_8);
+        } catch (final UnsupportedEncodingException e) {
+            throw new FessSystemException("Unsupported encoding.", e);
+        }
+    }
+
+    public void test_decodeUrl_ok() throws Exception {
+        String url, exp;
+        final FessFileTransformer transformer = new FessFileTransformer();
+
+        url = "";
+        exp = "";
+        assertEquals(exp, transformer.decodeUrlAsName(url, true));
+
+        url = "http://example.com/";
+        exp = "http://example.com/";
+        assertEquals(exp, transformer.decodeUrlAsName(url, false));
+
+        url = "http://example.com/index.html";
+        exp = "http://example.com/index.html";
+        assertEquals(exp, transformer.decodeUrlAsName(url, false));
+
+        url = "http://example.com/" + encodeUrl("テスト ") + ".html";
+        exp = "http://example.com/テスト .html";
+        assertEquals(exp, transformer.decodeUrlAsName(url, false));
+
+        url = "file://C++.doc";
+        exp = "file://C++.doc";
+        assertEquals(exp, transformer.decodeUrlAsName(url, true));
+
+        url = "file://C .doc";
+        exp = "file://C .doc";
+        assertEquals(exp, transformer.decodeUrlAsName(url, true));
+    }
+
+    public void test_decodeUrl_null() throws Exception {
+        final FessFileTransformer transformer = new FessFileTransformer();
+        assertNull(transformer.decodeUrlAsName(null, true));
+    }
+
+    public void test_getHost_ok() {
+        String url, exp;
+        final FessFileTransformer transformer = new FessFileTransformer();
+
+        url = "";
+        exp = "";
+        assertEquals(exp, transformer.getHost(url));
+
+        url = "http://server/home/user";
+        exp = "server";
+        assertEquals(exp, transformer.getHost(url));
+
+        url = "file:/home/user";
+        exp = "localhost";
+        assertEquals(exp, transformer.getHost(url));
+
+        url = "file:/c:/home/user";
+        exp = "localhost";
+        assertEquals(exp, transformer.getHost(url));
+
+        url = "file:////server/home/user";
+        exp = "server";
+        assertEquals(exp, transformer.getHost(url));
+
+        url = "file:/" + encodeUrl("ホーム") + "/user";
+        exp = "localhost";
+        assertEquals(exp, transformer.getHost(url));
+
+        url = "file:/c:/" + encodeUrl("ホーム") + "/user";
+        exp = "localhost";
+        assertEquals(exp, transformer.getHost(url));
+
+        url = "file:////" + encodeUrl("サーバー") + "/home/user";
+        exp = "サーバー";
+        assertEquals(exp, transformer.getHost(url));
+
+    }
+
+    public void test_getHost_unexpected() {
+        String url, exp;
+        final FessFileTransformer transformer = new FessFileTransformer();
+
+        url = null;
+        exp = "";
+        assertEquals(exp, transformer.getHost(url));
+
+        url = "example:";
+        exp = "unknown";
+        assertEquals(exp, transformer.getHost(url));
+
+        url = "file:";
+        exp = "localhost";
+        assertEquals(exp, transformer.getHost(url));
+
+        url = "file://";
+        exp = "localhost";
+        assertEquals(exp, transformer.getHost(url));
+
+        url = "file:///";
+        exp = "localhost";
+        assertEquals(exp, transformer.getHost(url));
+
+        url = "file://///";
+        exp = "localhost";
+        assertEquals(exp, transformer.getHost(url));
+
+        url = "file://///example";
+        exp = "localhost";
+        assertEquals(exp, transformer.getHost(url));
+
+        url = "file:/c:";
+        exp = "localhost";
+        assertEquals(exp, transformer.getHost(url));
+
+    }
+
+    public void test_getSite_ok() {
+        String url, exp;
+        final FessFileTransformer transformer = new FessFileTransformer();
+
+        url = "";
+        exp = "";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+
+        url = "http://example.com/";
+        exp = "example.com/";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+
+        url = "http://example.com/index.html";
+        exp = "example.com/index.html";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+
+        url = "file:/home/user";
+        exp = "/home/user";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+
+        url = "file:/c:/home/user";
+        exp = "c:\\home\\user";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+
+        url = "file:/c:/";
+        exp = "c:\\";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+
+        url = "file:////server/user";
+        exp = "\\\\server\\user";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+
+        transformer.maxSiteLength = 10;
+
+        url = "file:/home/user/foo";
+        exp = "/home/u...";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+
+    }
+
+    public void test_getSite_unexpected() {
+        String url, exp;
+        final FessFileTransformer transformer = new FessFileTransformer();
+
+        url = "file:";
+        exp = "";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+
+        url = "file";
+        exp = "file";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+
+        url = "file:/";
+        exp = "/";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+
+        url = "file:/c:";
+        exp = "c:";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+
+        url = "file://";
+        exp = "//";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+
+        url = "file:///";
+        exp = "///";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+
+        url = "file://///";
+        exp = "\\\\\\";
+        assertEquals(exp, transformer.getSite(url, "UTF-8"));
+    }
+}

+ 298 - 0
src/test/java/org/codelibs/fess/crawler/transformer/FessXpathTransformerTest.java

@@ -0,0 +1,298 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.codelibs.fess.crawler.transformer;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.codelibs.fess.crawler.builder.RequestDataBuilder;
+import org.codelibs.fess.crawler.entity.RequestData;
+import org.codelibs.fess.crawler.entity.ResponseData;
+import org.codelibs.fess.crawler.exception.ChildUrlsException;
+import org.codelibs.fess.unit.UnitFessTestCase;
+import org.cyberneko.html.parsers.DOMParser;
+import org.lastaflute.di.core.exception.ComponentNotFoundException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+public class FessXpathTransformerTest extends UnitFessTestCase {
+    public FessXpathTransformer fessXpathTransformer;
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        fessXpathTransformer = new FessXpathTransformer();
+        fessXpathTransformer.convertUrlMap.put("feed:", "http:");
+    }
+
+    public void test_pruneNode() throws Exception {
+        final String data = "<html><body><br/><script>foo</script><noscript>bar</noscript></body></html>";
+        final Document document = getDocument(data);
+
+        final FessXpathTransformer transformer = new FessXpathTransformer();
+
+        final Node pruneNode = transformer.pruneNode(document.cloneNode(true));
+        assertEquals(getXmlString(document), getXmlString(pruneNode));
+    }
+
+    public void test_pruneNode_removeNoScript() throws Exception {
+        final String data = "<html><body><br/><script>foo</script><noscript>bar</noscript></body></html>";
+        final Document document = getDocument(data);
+
+        final FessXpathTransformer transformer = new FessXpathTransformer();
+        transformer.prunedTagList.add("noscript");
+
+        final Node pruneNode = transformer.pruneNode(document.cloneNode(true));
+        final String docString = getXmlString(document);
+        final String pnString = getXmlString(pruneNode);
+        assertTrue(docString.contains("<SCRIPT>"));
+        assertTrue(docString.contains("foo"));
+        assertTrue(docString.contains("<NOSCRIPT>"));
+        assertTrue(docString.contains("bar"));
+        assertTrue(pnString.contains("<SCRIPT>"));
+        assertTrue(pnString.contains("foo"));
+        assertFalse(pnString.contains("<NOSCRIPT>"));
+        assertFalse(pnString.contains("bar"));
+    }
+
+    public void test_pruneNode_removeScriptAndNoscript() throws Exception {
+        final String data = "<html><body><br/><script>foo</script><noscript>bar</noscript></body></html>";
+        final Document document = getDocument(data);
+
+        final FessXpathTransformer transformer = new FessXpathTransformer();
+        transformer.prunedTagList.add("script");
+        transformer.prunedTagList.add("noscript");
+
+        final Node pruneNode = transformer.pruneNode(document.cloneNode(true));
+        final String docString = getXmlString(document);
+        final String pnString = getXmlString(pruneNode);
+        assertTrue(docString.contains("<SCRIPT>"));
+        assertTrue(docString.contains("foo"));
+        assertTrue(docString.contains("<NOSCRIPT>"));
+        assertTrue(docString.contains("bar"));
+        assertFalse(pnString.contains("<SCRIPT>"));
+        assertFalse(pnString.contains("foo"));
+        assertFalse(pnString.contains("<NOSCRIPT>"));
+        assertFalse(pnString.contains("bar"));
+    }
+
+    private Document getDocument(final String data) throws Exception {
+        final DOMParser parser = new DOMParser();
+        final ByteArrayInputStream is = new ByteArrayInputStream(data.getBytes("UTF-8"));
+        parser.parse(new InputSource(is));
+        return parser.getDocument();
+    }
+
+    private String getXmlString(final Node node) throws Exception {
+        final TransformerFactory tf = TransformerFactory.newInstance();
+        final javax.xml.transform.Transformer transformer = tf.newTransformer();
+        transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+        transformer.setOutputProperty(OutputKeys.INDENT, "no");
+        //        transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+
+        final StringWriter writer = new StringWriter();
+        final StreamResult result = new StreamResult(writer);
+
+        final DOMSource source = new DOMSource(node);
+        transformer.transform(source, result);
+
+        return writer.toString();
+
+    }
+
+    public void test_isValidPath_valid() {
+        String value;
+
+        value = "foo.html";
+        assertTrue(fessXpathTransformer.isValidPath(value));
+
+        value = "./foo.html";
+        assertTrue(fessXpathTransformer.isValidPath(value));
+
+        value = "/foo.html";
+        assertTrue(fessXpathTransformer.isValidPath(value));
+
+        value = "http://www.seasar.org/foo.html";
+        assertTrue(fessXpathTransformer.isValidPath(value));
+
+        value = "a javascript:...";
+        assertTrue(fessXpathTransformer.isValidPath(value));
+
+    }
+
+    public void test_isValidPath_invalid() {
+        String value;
+
+        value = "javascript:...";
+        assertFalse(fessXpathTransformer.isValidPath(value));
+
+        value = "mailto:...";
+        assertFalse(fessXpathTransformer.isValidPath(value));
+
+        value = "irc:...";
+        assertFalse(fessXpathTransformer.isValidPath(value));
+
+        value = " javascript:...";
+        assertFalse(fessXpathTransformer.isValidPath(value));
+
+        value = " mailto:...";
+        assertFalse(fessXpathTransformer.isValidPath(value));
+
+        value = " irc:...";
+        assertFalse(fessXpathTransformer.isValidPath(value));
+
+        value = "JAVASCRIPT:...";
+        assertFalse(fessXpathTransformer.isValidPath(value));
+
+        value = "MAILTO:...";
+        assertFalse(fessXpathTransformer.isValidPath(value));
+
+        value = "IRC:...";
+        assertFalse(fessXpathTransformer.isValidPath(value));
+
+        value = "skype:...";
+        assertFalse(fessXpathTransformer.isValidPath(value));
+    }
+
+    public void test_convertChildUrlList() {
+        List<RequestData> urlList = new ArrayList<>();
+
+        urlList = fessXpathTransformer.convertChildUrlList(urlList);
+        assertEquals(0, urlList.size());
+
+        urlList.clear();
+        urlList.add(RequestDataBuilder.newRequestData().get().url("http://www.example.com").build());
+        urlList = fessXpathTransformer.convertChildUrlList(urlList);
+        assertEquals(1, urlList.size());
+        assertEquals("http://www.example.com", urlList.get(0).getUrl());
+
+        urlList.clear();
+        urlList.add(RequestDataBuilder.newRequestData().get().url("http://www.example.com").build());
+        urlList.add(RequestDataBuilder.newRequestData().get().url("http://www.test.com").build());
+        urlList = fessXpathTransformer.convertChildUrlList(urlList);
+        assertEquals(2, urlList.size());
+        assertEquals("http://www.example.com", urlList.get(0).getUrl());
+        assertEquals("http://www.test.com", urlList.get(1).getUrl());
+
+        urlList.clear();
+        urlList.add(RequestDataBuilder.newRequestData().get().url("feed://www.example.com").build());
+        urlList.add(RequestDataBuilder.newRequestData().get().url("http://www.test.com").build());
+        urlList = fessXpathTransformer.convertChildUrlList(urlList);
+        assertEquals(2, urlList.size());
+        assertEquals("http://www.example.com", urlList.get(0).getUrl());
+        assertEquals("http://www.test.com", urlList.get(1).getUrl());
+
+    }
+
+    public void test_normalizeContent() {
+        assertEquals("", fessXpathTransformer.normalizeContent(""));
+        assertEquals(" ", fessXpathTransformer.normalizeContent(" "));
+        assertEquals(" ", fessXpathTransformer.normalizeContent("  "));
+        assertEquals(" ", fessXpathTransformer.normalizeContent("\t"));
+        assertEquals(" ", fessXpathTransformer.normalizeContent("\t\t"));
+        assertEquals(" ", fessXpathTransformer.normalizeContent("\t \t"));
+    }
+
+    public void test_removeCommentTag() {
+        assertEquals("", fessXpathTransformer.removeCommentTag(""));
+        assertEquals(" ", fessXpathTransformer.removeCommentTag("<!-- - -->"));
+        assertEquals("abc", fessXpathTransformer.removeCommentTag("abc"));
+        assertEquals("abc ", fessXpathTransformer.removeCommentTag("abc<!-- foo -->"));
+        assertEquals("abc 123", fessXpathTransformer.removeCommentTag("abc<!-- fo\no -->123"));
+        assertEquals("abc 123", fessXpathTransformer.removeCommentTag("abc<!--\n foo -->123"));
+        assertEquals("abc 123", fessXpathTransformer.removeCommentTag("abc<!-- foo -->123"));
+        assertEquals("abc 123 ", fessXpathTransformer.removeCommentTag("abc<!-- foo1 -->123<!-- foo2 -->"));
+        assertEquals("abc 123 xyz", fessXpathTransformer.removeCommentTag("abc<!-- foo1 -->123<!-- foo2 -->xyz"));
+        assertEquals("abc ", fessXpathTransformer.removeCommentTag("abc<!---->"));
+        assertEquals("abc -->", fessXpathTransformer.removeCommentTag("abc<!-- foo-->-->"));
+        assertEquals("abc<!-- foo", fessXpathTransformer.removeCommentTag("abc<!-- foo"));
+        assertEquals("abc  -->123", fessXpathTransformer.removeCommentTag("abc<!-- <!-- foo --> -->123"));
+    }
+
+    public void test_canonicalXpath() throws Exception {
+        final FessXpathTransformer transformer = new FessXpathTransformer();
+
+        final Map<String, Object> dataMap = new HashMap<String, Object>();
+        final ResponseData responseData = new ResponseData();
+        responseData.setUrl("http://example.com/");
+
+        String data = "<html><body>aaa</body></html>";
+        Document document = getDocument(data);
+        try {
+            transformer.putAdditionalData(dataMap, responseData, document);
+            fail();
+        } catch (final ComponentNotFoundException e) {
+            // ignore
+        }
+
+        data = "<html><head><link rel=\"canonical\" href=\"http://example.com/\"></head><body>aaa</body></html>";
+        document = getDocument(data);
+        try {
+            transformer.putAdditionalData(dataMap, responseData, document);
+            fail();
+        } catch (final ComponentNotFoundException e) {
+            // ignore
+        }
+
+        data = "<html><head><link rel=\"canonical\" href=\"http://example.com/foo\"></head><body>aaa</body></html>";
+        document = getDocument(data);
+        try {
+            transformer.putAdditionalData(dataMap, responseData, document);
+            fail();
+        } catch (final ChildUrlsException e) {
+            final Set<RequestData> childUrlList = e.getChildUrlList();
+            assertEquals(1, childUrlList.size());
+            assertEquals("http://example.com/foo", childUrlList.iterator().next().getUrl());
+        }
+
+        data = "<html><link rel=\"canonical\" href=\"http://example.com/foo\"><body>aaa</body></html>";
+        document = getDocument(data);
+        try {
+            transformer.putAdditionalData(dataMap, responseData, document);
+            fail();
+        } catch (final ChildUrlsException e) {
+            final Set<RequestData> childUrlList = e.getChildUrlList();
+            assertEquals(1, childUrlList.size());
+            assertEquals("http://example.com/foo", childUrlList.iterator().next().getUrl());
+        }
+    }
+
+    public void test_contentXpath() throws Exception {
+        final FessXpathTransformer transformer = new FessXpathTransformer();
+
+        final String data = "<html><head><meta name=\"keywords\" content=\"bbb\"></head><body>aaa</body></html>";
+        final Document document = getDocument(data);
+        String value = transformer.getSingleNodeValue(document, "//BODY", false);
+        assertEquals("aaa", value);
+
+        value = transformer.getSingleNodeValue(document, "//META[@name='keywords']/@content", false);
+        assertEquals("bbb", value);
+
+        value = transformer.getSingleNodeValue(document, "//META[@name='keywords']/@content|//BODY", false);
+        assertEquals("bbb aaa", value);
+    }
+}

+ 60 - 0
src/test/java/org/codelibs/fess/ds/impl/DatabaseDataStoreImplTest.java

@@ -0,0 +1,60 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.codelibs.fess.ds.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.codelibs.fess.unit.UnitFessTestCase;
+
+public class DatabaseDataStoreImplTest extends UnitFessTestCase {
+    public DatabaseDataStoreImpl databaseDataStore;
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        databaseDataStore = new DatabaseDataStoreImpl();
+    }
+
+    public void test_convertValue() {
+        String value;
+        final Map<String, String> paramMap = new HashMap<String, String>();
+        paramMap.put("param1", "PARAM1");
+        paramMap.put("param2", "PARAM2+");
+        paramMap.put("param3", "PARAM3*");
+
+        value = "\"abc\"";
+        assertEquals("abc", databaseDataStore.convertValue(value, paramMap));
+
+        value = "param1";
+        assertEquals("PARAM1", databaseDataStore.convertValue(value, paramMap));
+
+        value = "param2";
+        assertEquals("PARAM2+", databaseDataStore.convertValue(value, paramMap));
+
+        value = "\"123\"+param2+\",\"+param3+\"abc\"";
+        assertEquals("123PARAM2+,PARAM3*abc", databaseDataStore.convertValue(value, paramMap));
+
+        value = null;
+        assertEquals("", databaseDataStore.convertValue(value, paramMap));
+
+        value = "";
+        assertEquals("", databaseDataStore.convertValue(value, paramMap));
+
+        value = " ";
+        assertNull(databaseDataStore.convertValue(value, paramMap));
+    }
+}

+ 134 - 0
src/test/java/org/codelibs/fess/entity/GeoInfoTest.java

@@ -0,0 +1,134 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.codelibs.fess.entity;
+
+import org.codelibs.fess.unit.UnitFessTestCase;
+
+public class GeoInfoTest extends UnitFessTestCase {
+
+    public void test_0_0_10() {
+        final String latitude = "0";
+        final String lonitude = "0";
+        final String distance = "10";
+
+        final GeoInfo geoInfo = create(latitude, lonitude, distance);
+        assertTrue(geoInfo.isAvailable());
+        String result = "{\"geo_distance\":{\"geo_info\":[0.0,0.0],\"distance\":\"10.0km\"}}";
+        assertEquals(result, geoInfo.toQueryBuilder().toString().replaceAll("[ \n]", ""));
+    }
+
+    public void test_90_180_10() {
+        final String latitude = "90";
+        final String lonitude = "180";
+        final String distance = "10";
+
+        final GeoInfo geoInfo = create(latitude, lonitude, distance);
+        assertTrue(geoInfo.isAvailable());
+        String result = "{\"geo_distance\":{\"geo_info\":[180.0,90.0],\"distance\":\"10.0km\"}}";
+        assertEquals(result, geoInfo.toQueryBuilder().toString().replaceAll("[ \n]", ""));
+    }
+
+    public void test_91_181_10() {
+        final String latitude = "91";
+        final String lonitude = "181";
+        final String distance = "10";
+
+        final GeoInfo geoInfo = create(latitude, lonitude, distance);
+        assertTrue(geoInfo.isAvailable());
+        String result = "{\"geo_distance\":{\"geo_info\":[-179.0,90.0],\"distance\":\"10.0km\"}}";
+        assertEquals(result, geoInfo.toQueryBuilder().toString().replaceAll("[ \n]", ""));
+    }
+
+    public void test_91_361_10() {
+        final String latitude = "91";
+        final String lonitude = "361";
+        final String distance = "100";
+
+        final GeoInfo geoInfo = create(latitude, lonitude, distance);
+        assertTrue(geoInfo.isAvailable());
+        String result = "{\"geo_distance\":{\"geo_info\":[1.0,90.0],\"distance\":\"100.0km\"}}";
+        assertEquals(result, geoInfo.toQueryBuilder().toString().replaceAll("[ \n]", ""));
+    }
+
+    public void test__90__180_10() {
+        final String latitude = "-90";
+        final String lonitude = "-180";
+        final String distance = "10";
+
+        final GeoInfo geoInfo = create(latitude, lonitude, distance);
+        assertTrue(geoInfo.isAvailable());
+        String result = "{\"geo_distance\":{\"geo_info\":[-180.0,-90.0],\"distance\":\"10.0km\"}}";
+        assertEquals(result, geoInfo.toQueryBuilder().toString().replaceAll("[ \n]", ""));
+    }
+
+    public void test__91__181_10() {
+        final String latitude = "-91";
+        final String lonitude = "-181";
+        final String distance = "10";
+
+        final GeoInfo geoInfo = create(latitude, lonitude, distance);
+        assertTrue(geoInfo.isAvailable());
+        String result = "{\"geo_distance\":{\"geo_info\":[179.0,-90.0],\"distance\":\"10.0km\"}}";
+        assertEquals(result, geoInfo.toQueryBuilder().toString().replaceAll("[ \n]", ""));
+    }
+
+    public void test__91__361_10() {
+        final String latitude = "-91";
+        final String lonitude = "-361";
+        final String distance = "100";
+
+        final GeoInfo geoInfo = create(latitude, lonitude, distance);
+        assertTrue(geoInfo.isAvailable());
+        String result = "{\"geo_distance\":{\"geo_info\":[-1.0,-90.0],\"distance\":\"100.0km\"}}";
+        assertEquals(result, geoInfo.toQueryBuilder().toString().replaceAll("[ \n]", ""));
+    }
+
+    public void test_0_0_0() {
+        final String latitude = "0";
+        final String lonitude = "0";
+        final String distance = "0";
+
+        final GeoInfo geoInfo = create(latitude, lonitude, distance);
+        assertFalse(geoInfo.isAvailable());
+    }
+
+    public void test_x_0_0() {
+        final String latitude = "x";
+        final String lonitude = "0";
+        final String distance = "10";
+
+        final GeoInfo geoInfo = create(latitude, lonitude, distance);
+        assertFalse(geoInfo.isAvailable());
+    }
+
+    public void test_0_x_0() {
+        final String latitude = "0";
+        final String lonitude = "x";
+        final String distance = "10";
+
+        final GeoInfo geoInfo = create(latitude, lonitude, distance);
+        assertFalse(geoInfo.isAvailable());
+    }
+
+    private GeoInfo create(final String latitude, final String longitude, final String distance) {
+        final GeoInfo geoInfo = new GeoInfo();
+        geoInfo.latitude = latitude;
+        geoInfo.longitude = longitude;
+        geoInfo.distance = distance;
+        return geoInfo;
+    }
+
+}

+ 92 - 0
src/test/java/org/codelibs/fess/filter/EncodingFilterTest.java

@@ -0,0 +1,92 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.codelibs.fess.filter;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.codelibs.fess.unit.UnitFessTestCase;
+
+public class EncodingFilterTest extends UnitFessTestCase {
+    public void test_normal() throws IOException {
+        final EncodingFilter filter = new EncodingFilter();
+        Map<String, String[]> paramMap;
+
+        paramMap = filter.parseQueryString("a=1", "UTF-8");
+        assertEquals(1, paramMap.size());
+        assertEquals("1", paramMap.get("a")[0]);
+
+        paramMap = filter.parseQueryString("a=1&b=2", "UTF-8");
+        assertEquals(2, paramMap.size());
+        assertEquals("1", paramMap.get("a")[0]);
+        assertEquals("2", paramMap.get("b")[0]);
+
+        paramMap = filter.parseQueryString("a=111&b=222&c=333", "UTF-8");
+        assertEquals(3, paramMap.size());
+        assertEquals("111", paramMap.get("a")[0]);
+        assertEquals("222", paramMap.get("b")[0]);
+        assertEquals("333", paramMap.get("c")[0]);
+
+        paramMap = filter.parseQueryString("a=1&b=2&c=3&a=2", "UTF-8");
+        assertEquals(3, paramMap.size());
+        assertEquals("1", paramMap.get("a")[0]);
+        assertEquals("2", paramMap.get("a")[1]);
+        assertEquals("2", paramMap.get("b")[0]);
+        assertEquals("3", paramMap.get("c")[0]);
+
+    }
+
+    public void test_missing() throws IOException {
+        final EncodingFilter filter = new EncodingFilter();
+        Map<String, String[]> paramMap;
+
+        paramMap = filter.parseQueryString("a=", "UTF-8");
+        assertEquals(1, paramMap.size());
+        assertEquals("", paramMap.get("a")[0]);
+
+        paramMap = filter.parseQueryString("a", "UTF-8");
+        assertEquals(1, paramMap.size());
+        assertEquals("", paramMap.get("a")[0]);
+
+        paramMap = filter.parseQueryString("=1", "UTF-8");
+        assertEquals(1, paramMap.size());
+        assertEquals("1", paramMap.get("")[0]);
+
+        paramMap = filter.parseQueryString("=", "UTF-8");
+        assertEquals(1, paramMap.size());
+        assertEquals("", paramMap.get("")[0]);
+
+    }
+
+    public void test_decode() throws IOException {
+        final EncodingFilter filter = new EncodingFilter();
+        Map<String, String[]> paramMap;
+
+        paramMap = filter.parseQueryString("a=%E3%83%86%E3%82%B9%E3%83%88", "UTF-8");
+        assertEquals(1, paramMap.size());
+        assertEquals("テスト", paramMap.get("a")[0]);
+
+        paramMap = filter.parseQueryString("a=%A5%C6%A5%B9%A5%C8", "EUC-JP");
+        assertEquals(1, paramMap.size());
+        assertEquals("テスト", paramMap.get("a")[0]);
+
+        paramMap = filter.parseQueryString("a=%83e%83X%83g", "Shift_JIS");
+        assertEquals(1, paramMap.size());
+        assertEquals("テスト", paramMap.get("a")[0]);
+
+    }
+
+}

+ 92 - 0
src/test/java/org/codelibs/fess/indexer/DocBoostMatcherTest.java

@@ -0,0 +1,92 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.codelibs.fess.indexer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.codelibs.fess.unit.UnitFessTestCase;
+
+public class DocBoostMatcherTest extends UnitFessTestCase {
+    public void test_integer() {
+        final DocBoostMatcher docBoostMatcher = new DocBoostMatcher();
+        docBoostMatcher.setBoostExpression("10");
+        docBoostMatcher.setMatchExpression("data1 > 10");
+
+        final Map<String, Object> map = new HashMap<String, Object>();
+
+        assertTrue(0.0f == docBoostMatcher.getValue(map));
+
+        map.put("data1", 20);
+        assertTrue(docBoostMatcher.match(map));
+
+        map.put("data1", 5);
+        assertFalse(docBoostMatcher.match(map));
+
+        map.remove("data1");
+        assertFalse(docBoostMatcher.match(map));
+
+        map.put("data2", 5);
+        assertFalse(docBoostMatcher.match(map));
+    }
+
+    public void test_string() {
+        final DocBoostMatcher docBoostMatcher = new DocBoostMatcher();
+        docBoostMatcher.setBoostExpression("10");
+        docBoostMatcher.setMatchExpression("data1 != null && data1.matches(\"test\")");
+
+        final Map<String, Object> map = new HashMap<String, Object>();
+
+        map.put("data1", "test");
+        assertTrue(docBoostMatcher.match(map));
+
+        map.put("data1", "aaa test bbb");
+        assertFalse(docBoostMatcher.match(map));
+
+        map.put("data1", "hoge");
+        assertFalse(docBoostMatcher.match(map));
+
+        map.remove("data1");
+        assertFalse(docBoostMatcher.match(map));
+
+        map.put("data2", "hoge");
+        assertFalse(docBoostMatcher.match(map));
+
+        docBoostMatcher.setMatchExpression("data1.matches(\".*test.*\")");
+        map.put("data1", "aaa test bbb");
+        assertTrue(docBoostMatcher.match(map));
+    }
+
+    public void test_boost_params() {
+        final DocBoostMatcher docBoostMatcher = new DocBoostMatcher();
+        docBoostMatcher.setBoostExpression("10 * boost1 + boost2");
+        docBoostMatcher.setMatchExpression("data1 > 10");
+
+        final Map<String, Object> map = new HashMap<String, Object>();
+
+        map.put("boost1", 0);
+        map.put("boost2", 0);
+        assertTrue(0.0f == docBoostMatcher.getValue(map));
+
+        map.put("boost1", 1);
+        map.put("boost2", 0);
+        assertTrue(10.0f == docBoostMatcher.getValue(map));
+
+        map.put("boost1", 1);
+        map.put("boost2", 2);
+        assertTrue(12.0f == docBoostMatcher.getValue(map));
+    }
+}

+ 166 - 0
src/test/java/org/codelibs/fess/util/ParameterUtilTest.java

@@ -0,0 +1,166 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.codelibs.fess.util;
+
+import java.util.Map;
+
+import org.codelibs.fess.unit.UnitFessTestCase;
+
+public class ParameterUtilTest extends UnitFessTestCase {
+    public void test_convertParameterMap() {
+        String parameters;
+        Map<String, String> parameterMap;
+
+        parameters = "";
+        parameterMap = ParameterUtil.parse(parameters);
+        assertEquals(0, parameterMap.size());
+
+        parameters = "domain";
+        parameterMap = ParameterUtil.parse(parameters);
+        assertEquals(1, parameterMap.size());
+        assertEquals("", parameterMap.get("domain"));
+
+        parameters = "domain=";
+        parameterMap = ParameterUtil.parse(parameters);
+        assertEquals(1, parameterMap.size());
+        assertEquals("", parameterMap.get("domain"));
+
+        parameters = "domain=D";
+        parameterMap = ParameterUtil.parse(parameters);
+        assertEquals(1, parameterMap.size());
+        assertEquals("D", parameterMap.get("domain"));
+
+        parameters = "domain=DOMAIN";
+        parameterMap = ParameterUtil.parse(parameters);
+        assertEquals(1, parameterMap.size());
+        assertEquals("DOMAIN", parameterMap.get("domain"));
+
+        parameters = "\n";
+        parameterMap = ParameterUtil.parse(parameters);
+        assertEquals(0, parameterMap.size());
+
+        parameters = "domain\nworkstation";
+        parameterMap = ParameterUtil.parse(parameters);
+        assertEquals(2, parameterMap.size());
+        assertEquals("", parameterMap.get("domain"));
+        assertEquals("", parameterMap.get("workstation"));
+
+        parameters = "domain=\nworkstation=";
+        parameterMap = ParameterUtil.parse(parameters);
+        assertEquals(2, parameterMap.size());
+        assertEquals("", parameterMap.get("domain"));
+        assertEquals("", parameterMap.get("workstation"));
+
+        parameters = "domain=D\nworkstation=W";
+        parameterMap = ParameterUtil.parse(parameters);
+        assertEquals(2, parameterMap.size());
+        assertEquals("D", parameterMap.get("domain"));
+        assertEquals("W", parameterMap.get("workstation"));
+
+        parameters = "domain=DOMAIN\nworkstation=WORKSTATION";
+        parameterMap = ParameterUtil.parse(parameters);
+        assertEquals(2, parameterMap.size());
+        assertEquals("DOMAIN", parameterMap.get("domain"));
+        assertEquals("WORKSTATION", parameterMap.get("workstation"));
+    }
+
+    public void test_parseParameter() {
+        String value;
+        Map<String, String> paramMap;
+
+        value = "a=b";
+        paramMap = ParameterUtil.parse(value);
+        assertEquals(1, paramMap.size());
+        assertEquals("b", paramMap.get("a"));
+
+        value = "a=b\n1=2";
+        paramMap = ParameterUtil.parse(value);
+        assertEquals(2, paramMap.size());
+        assertEquals("b", paramMap.get("a"));
+        assertEquals("2", paramMap.get("1"));
+
+        value = "a=";
+        paramMap = ParameterUtil.parse(value);
+        assertEquals(1, paramMap.size());
+        assertEquals("", paramMap.get("a"));
+
+        value = "a";
+        paramMap = ParameterUtil.parse(value);
+        assertEquals(1, paramMap.size());
+        assertEquals("", paramMap.get("a"));
+
+        value = "a=b=c";
+        paramMap = ParameterUtil.parse(value);
+        assertEquals(1, paramMap.size());
+        assertEquals("b=c", paramMap.get("a"));
+
+        value = null;
+        paramMap = ParameterUtil.parse(value);
+        assertEquals(0, paramMap.size());
+
+        value = "";
+        paramMap = ParameterUtil.parse(value);
+        assertEquals(0, paramMap.size());
+
+        value = " ";
+        paramMap = ParameterUtil.parse(value);
+        assertEquals(0, paramMap.size());
+    }
+
+    public void test_parseScript() {
+        String value;
+        Map<String, String> scriptMap;
+
+        value = "a=b";
+        scriptMap = ParameterUtil.parse(value);
+        assertEquals(1, scriptMap.size());
+        assertEquals("b", scriptMap.get("a"));
+
+        value = "a=b\n1=2";
+        scriptMap = ParameterUtil.parse(value);
+        assertEquals(2, scriptMap.size());
+        assertEquals("b", scriptMap.get("a"));
+        assertEquals("2", scriptMap.get("1"));
+
+        value = "a=";
+        scriptMap = ParameterUtil.parse(value);
+        assertEquals(1, scriptMap.size());
+        assertEquals("", scriptMap.get("a"));
+
+        value = "a";
+        scriptMap = ParameterUtil.parse(value);
+        assertEquals(1, scriptMap.size());
+        assertEquals("", scriptMap.get("a"));
+
+        value = "a=b=c";
+        scriptMap = ParameterUtil.parse(value);
+        assertEquals(1, scriptMap.size());
+        assertEquals("b=c", scriptMap.get("a"));
+
+        value = null;
+        scriptMap = ParameterUtil.parse(value);
+        assertEquals(0, scriptMap.size());
+
+        value = "";
+        scriptMap = ParameterUtil.parse(value);
+        assertEquals(0, scriptMap.size());
+
+        value = " ";
+        scriptMap = ParameterUtil.parse(value);
+        assertEquals(0, scriptMap.size());
+    }
+
+}

+ 222 - 0
src/test/java/org/codelibs/fess/util/QueryResponseListTest.java

@@ -0,0 +1,222 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.codelibs.fess.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.codelibs.fess.unit.UnitFessTestCase;
+
+public class QueryResponseListTest extends UnitFessTestCase {
+    public void test_calculatePageInfo_page0() {
+        QueryResponseList qrList;
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.calculatePageInfo(0, 20);
+        assertEquals(20, qrList.getPageSize());
+        assertEquals(1, qrList.getCurrentPageNumber());
+        assertEquals(0, qrList.getAllRecordCount());
+        assertEquals(1, qrList.getAllPageCount());
+        assertEquals(false, qrList.isExistPrevPage());
+        assertEquals(false, qrList.isExistNextPage());
+        assertEquals(0, qrList.getCurrentStartRecordNumber());
+        assertEquals(0, qrList.getCurrentEndRecordNumber());
+    }
+
+    public void test_calculatePageInfo_page1() {
+        QueryResponseList qrList;
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 10;
+        qrList.calculatePageInfo(0, 20);
+        assertEquals(20, qrList.getPageSize());
+        assertEquals(1, qrList.getCurrentPageNumber());
+        assertEquals(10, qrList.getAllRecordCount());
+        assertEquals(1, qrList.getAllPageCount());
+        assertEquals(false, qrList.isExistPrevPage());
+        assertEquals(false, qrList.isExistNextPage());
+        assertEquals(1, qrList.getCurrentStartRecordNumber());
+        assertEquals(10, qrList.getCurrentEndRecordNumber());
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 20;
+        qrList.calculatePageInfo(0, 20);
+        assertEquals(20, qrList.getPageSize());
+        assertEquals(1, qrList.getCurrentPageNumber());
+        assertEquals(20, qrList.getAllRecordCount());
+        assertEquals(1, qrList.getAllPageCount());
+        assertEquals(false, qrList.isExistPrevPage());
+        assertEquals(false, qrList.isExistNextPage());
+        assertEquals(1, qrList.getCurrentStartRecordNumber());
+        assertEquals(20, qrList.getCurrentEndRecordNumber());
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 21;
+        qrList.calculatePageInfo(0, 20);
+        assertEquals(20, qrList.getPageSize());
+        assertEquals(1, qrList.getCurrentPageNumber());
+        assertEquals(21, qrList.getAllRecordCount());
+        assertEquals(2, qrList.getAllPageCount());
+        assertEquals(false, qrList.isExistPrevPage());
+        assertEquals(true, qrList.isExistNextPage());
+        assertEquals(1, qrList.getCurrentStartRecordNumber());
+        assertEquals(20, qrList.getCurrentEndRecordNumber());
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 40;
+        qrList.calculatePageInfo(0, 20);
+        assertEquals(20, qrList.getPageSize());
+        assertEquals(1, qrList.getCurrentPageNumber());
+        assertEquals(40, qrList.getAllRecordCount());
+        assertEquals(2, qrList.getAllPageCount());
+        assertEquals(false, qrList.isExistPrevPage());
+        assertEquals(true, qrList.isExistNextPage());
+        assertEquals(1, qrList.getCurrentStartRecordNumber());
+        assertEquals(20, qrList.getCurrentEndRecordNumber());
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 41;
+        qrList.calculatePageInfo(0, 20);
+        assertEquals(20, qrList.getPageSize());
+        assertEquals(1, qrList.getCurrentPageNumber());
+        assertEquals(41, qrList.getAllRecordCount());
+        assertEquals(3, qrList.getAllPageCount());
+        assertEquals(false, qrList.isExistPrevPage());
+        assertEquals(true, qrList.isExistNextPage());
+        assertEquals(1, qrList.getCurrentStartRecordNumber());
+        assertEquals(20, qrList.getCurrentEndRecordNumber());
+    }
+
+    public void test_calculatePageInfo_page2() {
+        QueryResponseList qrList;
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 21;
+        qrList.calculatePageInfo(20, 20);
+        assertEquals(20, qrList.getPageSize());
+        assertEquals(2, qrList.getCurrentPageNumber());
+        assertEquals(21, qrList.getAllRecordCount());
+        assertEquals(2, qrList.getAllPageCount());
+        assertEquals(true, qrList.isExistPrevPage());
+        assertEquals(false, qrList.isExistNextPage());
+        assertEquals(21, qrList.getCurrentStartRecordNumber());
+        assertEquals(21, qrList.getCurrentEndRecordNumber());
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 40;
+        qrList.calculatePageInfo(20, 20);
+        assertEquals(20, qrList.getPageSize());
+        assertEquals(2, qrList.getCurrentPageNumber());
+        assertEquals(40, qrList.getAllRecordCount());
+        assertEquals(2, qrList.getAllPageCount());
+        assertEquals(true, qrList.isExistPrevPage());
+        assertEquals(false, qrList.isExistNextPage());
+        assertEquals(21, qrList.getCurrentStartRecordNumber());
+        assertEquals(40, qrList.getCurrentEndRecordNumber());
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 41;
+        qrList.calculatePageInfo(20, 20);
+        assertEquals(20, qrList.getPageSize());
+        assertEquals(2, qrList.getCurrentPageNumber());
+        assertEquals(41, qrList.getAllRecordCount());
+        assertEquals(3, qrList.getAllPageCount());
+        assertEquals(true, qrList.isExistPrevPage());
+        assertEquals(true, qrList.isExistNextPage());
+        assertEquals(21, qrList.getCurrentStartRecordNumber());
+        assertEquals(40, qrList.getCurrentEndRecordNumber());
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 61;
+        qrList.calculatePageInfo(20, 20);
+        assertEquals(20, qrList.getPageSize());
+        assertEquals(2, qrList.getCurrentPageNumber());
+        assertEquals(61, qrList.getAllRecordCount());
+        assertEquals(4, qrList.getAllPageCount());
+        assertEquals(true, qrList.isExistPrevPage());
+        assertEquals(true, qrList.isExistNextPage());
+        assertEquals(21, qrList.getCurrentStartRecordNumber());
+        assertEquals(40, qrList.getCurrentEndRecordNumber());
+    }
+
+    public void test_calculatePageInfo_pageList() {
+        QueryResponseList qrList;
+        List<String> pnList;
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 20;
+        qrList.calculatePageInfo(0, 20);
+        pnList = qrList.getPageNumberList();
+        assertEquals(1, pnList.size());
+        assertEquals("1", pnList.get(0));
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 61;
+        qrList.calculatePageInfo(0, 20);
+        pnList = qrList.getPageNumberList();
+        assertEquals(4, pnList.size());
+        assertEquals("1", pnList.get(0));
+        assertEquals("2", pnList.get(1));
+        assertEquals("3", pnList.get(2));
+        assertEquals("4", pnList.get(3));
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 200;
+        qrList.calculatePageInfo(0, 20);
+        pnList = qrList.getPageNumberList();
+        assertEquals(6, pnList.size());
+        assertEquals("1", pnList.get(0));
+        assertEquals("2", pnList.get(1));
+        assertEquals("3", pnList.get(2));
+        assertEquals("4", pnList.get(3));
+        assertEquals("5", pnList.get(4));
+        assertEquals("6", pnList.get(5));
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 21;
+        qrList.calculatePageInfo(20, 20);
+        pnList = qrList.getPageNumberList();
+        assertEquals(2, pnList.size());
+        assertEquals("1", pnList.get(0));
+        assertEquals("2", pnList.get(1));
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 61;
+        qrList.calculatePageInfo(20, 20);
+        pnList = qrList.getPageNumberList();
+        assertEquals(4, pnList.size());
+        assertEquals("1", pnList.get(0));
+        assertEquals("2", pnList.get(1));
+        assertEquals("3", pnList.get(2));
+        assertEquals("4", pnList.get(3));
+
+        qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
+        qrList.allRecordCount = 200;
+        qrList.calculatePageInfo(20, 20);
+        pnList = qrList.getPageNumberList();
+        assertEquals(7, pnList.size());
+        assertEquals("1", pnList.get(0));
+        assertEquals("2", pnList.get(1));
+        assertEquals("3", pnList.get(2));
+        assertEquals("4", pnList.get(3));
+        assertEquals("5", pnList.get(4));
+        assertEquals("6", pnList.get(5));
+        assertEquals("7", pnList.get(6));
+
+    }
+
+}

+ 83 - 0
src/test/java/org/codelibs/fess/util/ResourceUtilTest.java

@@ -0,0 +1,83 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.codelibs.fess.util;
+
+import org.codelibs.fess.unit.UnitFessTestCase;
+
+public class ResourceUtilTest extends UnitFessTestCase {
+    public void test_resolve() {
+        String value;
+
+        value = null;
+        assertNull(ResourceUtil.resolve(value));
+
+        value = "";
+        assertEquals("", ResourceUtil.resolve(value));
+
+        value = "a";
+        assertEquals(value, ResourceUtil.resolve(value));
+
+        value = "${a}";
+        assertEquals(value, ResourceUtil.resolve(value));
+
+        value = "$a";
+        assertEquals(value, ResourceUtil.resolve(value));
+
+        value = "${a";
+        assertEquals(value, ResourceUtil.resolve(value));
+
+        value = "$a}";
+        assertEquals(value, ResourceUtil.resolve(value));
+
+        value = "${abc}";
+        assertEquals(value, ResourceUtil.resolve(value));
+
+        value = "${abc.xyz}";
+        assertEquals(value, ResourceUtil.resolve(value));
+
+        System.setProperty("abc", "123");
+
+        value = "${abc}";
+        assertEquals("123", ResourceUtil.resolve(value));
+
+        value = "xxx${abc}zzz";
+        assertEquals("xxx123zzz", ResourceUtil.resolve(value));
+
+        value = "${abc.xyz}";
+        assertEquals(value, ResourceUtil.resolve(value));
+
+        System.setProperty("abc.xyz", "789");
+
+        value = "${abc.xyz}";
+        assertEquals("789", ResourceUtil.resolve(value));
+
+        value = "${abc}${abc.xyz}";
+        assertEquals("123789", ResourceUtil.resolve(value));
+
+        value = "xxx${abc.xyz}zzz";
+        assertEquals("xxx789zzz", ResourceUtil.resolve(value));
+
+        value = "${\\$}";
+        assertEquals(value, ResourceUtil.resolve(value));
+
+        System.setProperty("test.dir", "c:\\test1\\test2");
+
+        value = "${test.dir}";
+        assertEquals("c:\\test1\\test2", ResourceUtil.resolve(value));
+
+    }
+
+}

+ 83 - 0
src/test/java/org/codelibs/fess/validator/UriTypeChecksTest.java

@@ -0,0 +1,83 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.codelibs.fess.validator;
+
+import org.codelibs.fess.unit.UnitFessTestCase;
+
+public class UriTypeChecksTest extends UnitFessTestCase {
+    public void test_check_ok() {
+        String protocols;
+        String values;
+
+        protocols = "http:";
+        values = "http://www.foo.com/";
+        assertTrue(UriTypeChecks.check(protocols, values));
+
+        protocols = "http:";
+        values = "http://www.foo.com/\nhttp://www.bar.com/";
+        assertTrue(UriTypeChecks.check(protocols, values));
+
+        protocols = "http:";
+        values = "http://www.foo.com/ \r\nhttp://www.bar.com/";
+        assertTrue(UriTypeChecks.check(protocols, values));
+
+        protocols = "http:";
+        values = "http://www.foo.com/\nhttp://www.bar.com/\n http://www.baz.com/";
+        assertTrue(UriTypeChecks.check(protocols, values));
+
+        protocols = "http:,https:";
+        values = "https://www.foo.com/";
+        assertTrue(UriTypeChecks.check(protocols, values));
+
+        protocols = "http:,https:";
+        values = "http://www.foo.com/\r\nhttp://www.bar.com/";
+        assertTrue(UriTypeChecks.check(protocols, values));
+
+        protocols = "http:,https:";
+        values = "http://www.foo.com/\nhttps://www.bar.com/";
+        assertTrue(UriTypeChecks.check(protocols, values));
+
+        protocols = "http:,https:";
+        values = "http://www.foo.com/\n \nhttps://www.bar.com/";
+        assertTrue(UriTypeChecks.check(protocols, values));
+
+        protocols = "http:, https:";
+        values = "http://www.foo.com/\nhttps://www.bar.com/\n http://www.baz.com/";
+        assertTrue(UriTypeChecks.check(protocols, values));
+    }
+
+    public void test_check_ng() {
+        String protocols;
+        String values;
+
+        protocols = "http:";
+        values = "https://www.foo.com/";
+        assertFalse(UriTypeChecks.check(protocols, values));
+
+        protocols = "http:";
+        values = "https://www.foo.com/\nhttps://www.bar.com/";
+        assertFalse(UriTypeChecks.check(protocols, values));
+
+        protocols = "http:";
+        values = "https://www.foo.com/\n \nhttps://www.bar.com/";
+        assertFalse(UriTypeChecks.check(protocols, values));
+
+        protocols = "http:";
+        values = "https://www.foo.com/\nhttps://www.bar.com/\n https://www.baz.com/";
+        assertFalse(UriTypeChecks.check(protocols, values));
+
+    }
+}