remove test classes
This commit is contained in:
parent
af3c69631d
commit
145a6cb876
43 changed files with 0 additions and 5423 deletions
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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;
|
||||
|
||||
public class FessClass {
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
*
|
||||
* 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.boot;
|
||||
|
||||
import org.dbflute.jetty.JettyBoot;
|
||||
|
||||
/**
|
||||
* @author jflute
|
||||
*/
|
||||
public class FessBoot {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new JettyBoot(8090, "/fess").asDevelopment().bootAwait();
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.dict;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.dict.synonym.SynonymLocator;
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
import org.seasar.framework.util.FileUtil;
|
||||
|
||||
public class DictionaryManagerTest extends S2TestCase {
|
||||
|
||||
private File testDir;
|
||||
|
||||
private File synonymFile1;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
testDir = File.createTempFile("synonymtest", "_dir");
|
||||
testDir.delete();
|
||||
testDir.mkdirs();
|
||||
synonymFile1 = new File(testDir, "synonym.txt");
|
||||
FileUtil.write(synonymFile1.getAbsolutePath(), "abc=>123\nxyz,890".getBytes(Constants.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
FileUtils.deleteDirectory(testDir);
|
||||
}
|
||||
|
||||
public void test_getSynonymFiles() throws Exception {
|
||||
final DictionaryManager dictionaryManager = new DictionaryManager();
|
||||
dictionaryManager.keepAlive = 1000;
|
||||
dictionaryManager.watcherTimeout = 1;
|
||||
final SynonymLocator synonymLocator = new SynonymLocator();
|
||||
synonymLocator.excludedSynonymList = new ArrayList<String>();
|
||||
synonymLocator.excludedSynonymList.add("data");
|
||||
synonymLocator.addSearchPath(testDir.getAbsolutePath());
|
||||
dictionaryManager.addLocator(synonymLocator);
|
||||
dictionaryManager.init();
|
||||
final DictionaryFile<? extends DictionaryItem>[] synonymFiles = dictionaryManager.getDictionaryFiles();
|
||||
assertEquals(1, synonymFiles.length);
|
||||
|
||||
assertNotNull(dictionaryManager.dicFileMap);
|
||||
Thread.sleep(2000);
|
||||
assertNull(dictionaryManager.dicFileMap);
|
||||
|
||||
final DictionaryFile<? extends DictionaryItem>[] synonymFiles2 = dictionaryManager.getDictionaryFiles();
|
||||
assertEquals(1, synonymFiles2.length);
|
||||
|
||||
assertNotNull(dictionaryManager.dicFileMap);
|
||||
Thread.sleep(2000);
|
||||
assertNull(dictionaryManager.dicFileMap);
|
||||
}
|
||||
}
|
|
@ -1,180 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.dict.synonym;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.dict.DictionaryFile.PagingList;
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
import org.seasar.framework.util.FileUtil;
|
||||
|
||||
public class SynonymFileTest extends S2TestCase {
|
||||
|
||||
private File file1;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
file1 = File.createTempFile("synonym", ".txt");
|
||||
FileUtil.write(file1.getAbsolutePath(), "a1=>A1\nb1,b2 => B1\nc1 => C1, C2\nx1,X1\ny1, Y1, y2".getBytes(Constants.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
file1.delete();
|
||||
}
|
||||
|
||||
public void test_selectList() {
|
||||
final SynonymFile synonymFile = new SynonymFile(file1);
|
||||
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList1.size());
|
||||
assertEquals(5, itemList1.getAllRecordCount());
|
||||
assertEquals(1, itemList1.getCurrentPageNumber());
|
||||
assertEquals(20, itemList1.getPageSize());
|
||||
|
||||
final PagingList<SynonymItem> itemList2 = synonymFile.selectList(4, 2);
|
||||
assertEquals(1, itemList2.size());
|
||||
assertEquals(5, itemList2.getAllRecordCount());
|
||||
assertEquals(3, itemList2.getCurrentPageNumber());
|
||||
assertEquals(2, itemList2.getPageSize());
|
||||
|
||||
assertEquals(0, synonymFile.selectList(5, 5).size());
|
||||
assertEquals(0, synonymFile.selectList(-1, 5).size());
|
||||
}
|
||||
|
||||
public void test_selectList2() {
|
||||
final SynonymFile synonymFile = new SynonymFile(file1);
|
||||
final PagingList<SynonymItem> itemList = synonymFile.selectList(0, 5);
|
||||
assertEquals(1, itemList.get(0).getInputs().length);
|
||||
assertEquals(1, itemList.get(0).getOutputs().length);
|
||||
assertEquals("a1", itemList.get(0).getInputs()[0]);
|
||||
assertEquals("A1", itemList.get(0).getOutputs()[0]);
|
||||
assertFalse(itemList.get(0).isUpdated());
|
||||
|
||||
assertEquals(2, itemList.get(1).getInputs().length);
|
||||
assertEquals(1, itemList.get(1).getOutputs().length);
|
||||
assertEquals("b1", itemList.get(1).getInputs()[0]);
|
||||
assertEquals("b2", itemList.get(1).getInputs()[1]);
|
||||
assertEquals("B1", itemList.get(1).getOutputs()[0]);
|
||||
assertFalse(itemList.get(1).isUpdated());
|
||||
|
||||
assertEquals(1, itemList.get(2).getInputs().length);
|
||||
assertEquals(2, itemList.get(2).getOutputs().length);
|
||||
assertEquals("c1", itemList.get(2).getInputs()[0]);
|
||||
assertEquals("C1", itemList.get(2).getOutputs()[0]);
|
||||
assertEquals("C2", itemList.get(2).getOutputs()[1]);
|
||||
assertFalse(itemList.get(2).isUpdated());
|
||||
|
||||
assertEquals(2, itemList.get(3).getInputs().length);
|
||||
assertEquals(2, itemList.get(3).getOutputs().length);
|
||||
assertEquals("X1", itemList.get(3).getInputs()[0]);
|
||||
assertEquals("x1", itemList.get(3).getInputs()[1]);
|
||||
assertEquals("X1", itemList.get(3).getOutputs()[0]);
|
||||
assertEquals("x1", itemList.get(3).getOutputs()[1]);
|
||||
assertFalse(itemList.get(3).isUpdated());
|
||||
|
||||
assertEquals(3, itemList.get(4).getInputs().length);
|
||||
assertEquals(3, itemList.get(4).getOutputs().length);
|
||||
assertEquals("Y1", itemList.get(4).getInputs()[0]);
|
||||
assertEquals("y1", itemList.get(4).getInputs()[1]);
|
||||
assertEquals("y2", itemList.get(4).getInputs()[2]);
|
||||
assertEquals("Y1", itemList.get(4).getOutputs()[0]);
|
||||
assertEquals("y1", itemList.get(4).getOutputs()[1]);
|
||||
assertEquals("y2", itemList.get(4).getOutputs()[2]);
|
||||
assertFalse(itemList.get(4).isUpdated());
|
||||
}
|
||||
|
||||
public void test_insert() {
|
||||
final SynonymFile synonymFile = new SynonymFile(file1);
|
||||
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList1.size());
|
||||
|
||||
final SynonymItem synonymItem1 = new SynonymItem(0, new String[] { "z1", "z2" }, new String[] { "Z1", "Z2" });
|
||||
synonymFile.insert(synonymItem1);
|
||||
final PagingList<SynonymItem> itemList2 = synonymFile.selectList(0, 20);
|
||||
assertEquals(6, itemList2.size());
|
||||
assertEquals("z1", itemList2.get(5).getInputs()[0]);
|
||||
assertEquals("z2", itemList2.get(5).getInputs()[1]);
|
||||
assertEquals("Z1", itemList2.get(5).getOutputs()[0]);
|
||||
assertEquals("Z2", itemList2.get(5).getOutputs()[1]);
|
||||
|
||||
final SynonymItem synonymItem2 = new SynonymItem(0, new String[] { "z1", "z2" }, new String[] { "z1", "z2" });
|
||||
synonymFile.insert(synonymItem2);
|
||||
final PagingList<SynonymItem> itemList3 = synonymFile.selectList(0, 20);
|
||||
assertEquals(7, itemList3.size());
|
||||
assertEquals("z1", itemList3.get(6).getInputs()[0]);
|
||||
assertEquals("z2", itemList3.get(6).getInputs()[1]);
|
||||
assertEquals("z1", itemList3.get(6).getOutputs()[0]);
|
||||
assertEquals("z2", itemList3.get(6).getOutputs()[1]);
|
||||
}
|
||||
|
||||
public void test_update() {
|
||||
final SynonymFile synonymFile = new SynonymFile(file1);
|
||||
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList1.size());
|
||||
|
||||
final SynonymItem synonymItem1 = itemList1.get(0);
|
||||
synonymItem1.setNewInputs(new String[] { "a1", "a2" });
|
||||
synonymItem1.setNewOutputs(new String[] { "A1", "A2" });
|
||||
synonymFile.update(synonymItem1);
|
||||
final PagingList<SynonymItem> itemList2 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList2.size());
|
||||
final SynonymItem synonymItem2 = itemList2.get(0);
|
||||
assertEquals(2, synonymItem2.getInputs().length);
|
||||
assertEquals(2, synonymItem2.getOutputs().length);
|
||||
assertEquals("a1", synonymItem2.getInputs()[0]);
|
||||
assertEquals("a2", synonymItem2.getInputs()[1]);
|
||||
assertEquals("A1", synonymItem2.getOutputs()[0]);
|
||||
assertEquals("A2", synonymItem2.getOutputs()[1]);
|
||||
assertFalse(synonymItem2.isUpdated());
|
||||
|
||||
final SynonymItem synonymItem3 = itemList2.get(2);
|
||||
synonymItem3.setNewInputs(new String[] { "c1", "c2" });
|
||||
synonymItem3.setNewOutputs(new String[] { "c1", "c2" });
|
||||
synonymFile.update(synonymItem3);
|
||||
final PagingList<SynonymItem> itemList3 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList3.size());
|
||||
final SynonymItem synonymItem4 = itemList3.get(2);
|
||||
assertEquals(2, synonymItem4.getInputs().length);
|
||||
assertEquals(2, synonymItem4.getOutputs().length);
|
||||
assertEquals("c1", synonymItem4.getInputs()[0]);
|
||||
assertEquals("c2", synonymItem4.getInputs()[1]);
|
||||
assertEquals("c1", synonymItem4.getOutputs()[0]);
|
||||
assertEquals("c2", synonymItem4.getOutputs()[1]);
|
||||
assertFalse(synonymItem2.isUpdated());
|
||||
}
|
||||
|
||||
public void test_delete() throws Exception {
|
||||
final SynonymFile synonymFile = new SynonymFile(file1);
|
||||
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList1.size());
|
||||
|
||||
final SynonymItem synonymItem1 = itemList1.get(0);
|
||||
synonymFile.delete(synonymItem1);
|
||||
final PagingList<SynonymItem> itemList2 = synonymFile.selectList(0, 20);
|
||||
assertEquals(4, itemList2.size());
|
||||
|
||||
final SynonymItem synonymItem2 = itemList2.get(3);
|
||||
synonymFile.delete(synonymItem2);
|
||||
final PagingList<SynonymItem> itemList3 = synonymFile.selectList(0, 20);
|
||||
assertEquals(3, itemList3.size());
|
||||
|
||||
assertEquals("b1,b2=>B1" + Constants.LINE_SEPARATOR + "c1=>C1,C2" + Constants.LINE_SEPARATOR + "X1,x1" + Constants.LINE_SEPARATOR,
|
||||
new String(FileUtil.getBytes(file1), Constants.UTF_8));
|
||||
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.dict.synonym;
|
||||
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class SynonymItemTest extends S2TestCase {
|
||||
|
||||
public void test_new1() {
|
||||
final SynonymItem synonymItem = new SynonymItem(1, new String[] { "a", "A" }, new String[] { "b", "B" });
|
||||
assertEquals(1, synonymItem.getId());
|
||||
assertEquals(2, synonymItem.getInputs().length);
|
||||
assertEquals("A", synonymItem.getInputs()[0]);
|
||||
assertEquals("a", synonymItem.getInputs()[1]);
|
||||
assertEquals(2, synonymItem.getOutputs().length);
|
||||
assertEquals("B", synonymItem.getOutputs()[0]);
|
||||
assertEquals("b", synonymItem.getOutputs()[1]);
|
||||
assertNull(synonymItem.getNewInputs());
|
||||
assertNull(synonymItem.getNewOutputs());
|
||||
assertFalse(synonymItem.isUpdated());
|
||||
assertFalse(synonymItem.isDeleted());
|
||||
|
||||
synonymItem.setNewInputs(new String[] { "1", "2" });
|
||||
synonymItem.setNewOutputs(new String[] { "3", "4" });
|
||||
assertTrue(synonymItem.isUpdated());
|
||||
assertFalse(synonymItem.isDeleted());
|
||||
|
||||
synonymItem.setNewInputs(new String[0]);
|
||||
synonymItem.setNewOutputs(new String[0]);
|
||||
assertTrue(synonymItem.isUpdated());
|
||||
assertTrue(synonymItem.isDeleted());
|
||||
}
|
||||
|
||||
public void test_new2() {
|
||||
final SynonymItem synonymItem = new SynonymItem(1, new String[] { "A", "a" }, new String[] { "B", "b" });
|
||||
assertEquals(1, synonymItem.getId());
|
||||
assertEquals(2, synonymItem.getInputs().length);
|
||||
assertEquals("A", synonymItem.getInputs()[0]);
|
||||
assertEquals("a", synonymItem.getInputs()[1]);
|
||||
assertEquals(2, synonymItem.getOutputs().length);
|
||||
assertEquals("B", synonymItem.getOutputs()[0]);
|
||||
assertEquals("b", synonymItem.getOutputs()[1]);
|
||||
assertNull(synonymItem.getNewInputs());
|
||||
assertNull(synonymItem.getNewOutputs());
|
||||
assertFalse(synonymItem.isUpdated());
|
||||
assertFalse(synonymItem.isDeleted());
|
||||
|
||||
synonymItem.setNewInputs(new String[] { "2", "1" });
|
||||
synonymItem.setNewOutputs(new String[] { "4", "3" });
|
||||
assertTrue(synonymItem.isUpdated());
|
||||
assertFalse(synonymItem.isDeleted());
|
||||
|
||||
synonymItem.setNewInputs(new String[0]);
|
||||
synonymItem.setNewOutputs(new String[0]);
|
||||
assertTrue(synonymItem.isUpdated());
|
||||
assertTrue(synonymItem.isDeleted());
|
||||
}
|
||||
|
||||
public void test_equals1() {
|
||||
final SynonymItem synonymItem1 = new SynonymItem(1, new String[] { "a", "A" }, new String[] { "b", "B" });
|
||||
|
||||
assertTrue(synonymItem1.equals(synonymItem1));
|
||||
assertTrue(synonymItem1.equals(new SynonymItem(1, new String[] { "A", "a" }, new String[] { "B", "b" })));
|
||||
assertTrue(synonymItem1.equals(new SynonymItem(2, new String[] { "A", "a" }, new String[] { "B", "b" })));
|
||||
assertFalse(synonymItem1.equals(new SynonymItem(2, new String[] { "A", "a" }, new String[] { "B", })));
|
||||
assertFalse(synonymItem1.equals(new SynonymItem(2, new String[] { "A" }, new String[] { "B", "b" })));
|
||||
assertFalse(synonymItem1.equals(new SynonymItem(1, new String[] { "A", "a" }, new String[] { "B", "c" })));
|
||||
assertFalse(synonymItem1.equals(new SynonymItem(1, new String[] { "A", "c" }, new String[] { "B", "b" })));
|
||||
}
|
||||
|
||||
public void test_equals2() {
|
||||
final SynonymItem synonymItem1 = new SynonymItem(1, new String[] { "a" }, new String[] { "b" });
|
||||
|
||||
assertTrue(synonymItem1.equals(synonymItem1));
|
||||
assertTrue(synonymItem1.equals(new SynonymItem(1, new String[] { "a" }, new String[] { "b" })));
|
||||
assertFalse(synonymItem1.equals(new SynonymItem(2, new String[] { "a" }, new String[] { "B", })));
|
||||
assertFalse(synonymItem1.equals(new SynonymItem(2, new String[] { "A" }, new String[] { "b" })));
|
||||
}
|
||||
|
||||
public void test_toLineString() {
|
||||
assertEquals("a1,a2,a3=>b1,b2,b3",
|
||||
new SynonymItem(1, new String[] { "a1", "a2", "a3" }, new String[] { "b1", "b2", "b3" }).toLineString());
|
||||
assertEquals("a=>b", new SynonymItem(1, new String[] { "a" }, new String[] { "b" }).toLineString());
|
||||
assertEquals("A,a=>B,b", new SynonymItem(1, new String[] { "a", "A" }, new String[] { "b", "B" }).toLineString());
|
||||
assertEquals("A,a", new SynonymItem(1, new String[] { "a", "A" }, new String[] { "a", "A" }).toLineString());
|
||||
assertEquals("a", new SynonymItem(1, new String[] { "a" }, new String[] { "a" }).toLineString());
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.dict.synonym;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.dict.DictionaryFile;
|
||||
import org.codelibs.fess.dict.DictionaryItem;
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
import org.seasar.framework.util.FileUtil;
|
||||
|
||||
public class SynonymLocatorTest extends S2TestCase {
|
||||
|
||||
private File testDir;
|
||||
|
||||
private File testDataDir;
|
||||
|
||||
private File testCoreDir;
|
||||
|
||||
private File synonymFile1;
|
||||
|
||||
private File synonymFile2;
|
||||
|
||||
private File synonymFile3;
|
||||
|
||||
private File dummyFile1;
|
||||
|
||||
private File dummyFile2;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
testDir = File.createTempFile("synonymtest", "_dir");
|
||||
testDir.delete();
|
||||
testDir.mkdirs();
|
||||
testDataDir = new File(testDir, "data");
|
||||
testDataDir.mkdirs();
|
||||
testCoreDir = new File(testDir, "core");
|
||||
testCoreDir.mkdirs();
|
||||
synonymFile1 = new File(testDir, "synonym.txt");
|
||||
FileUtil.write(synonymFile1.getAbsolutePath(), "abc=>123\nxyz,890".getBytes(Constants.UTF_8));
|
||||
synonymFile2 = new File(testDataDir, "synonym_data.txt");
|
||||
FileUtil.write(synonymFile2.getAbsolutePath(), "abc=>123\nxyz,890".getBytes(Constants.UTF_8));
|
||||
synonymFile3 = new File(testCoreDir, "synonym_core.txt");
|
||||
FileUtil.write(synonymFile3.getAbsolutePath(), "abc=>123\nxyz,890".getBytes(Constants.UTF_8));
|
||||
dummyFile1 = new File(testDir, "dummy.txt");
|
||||
FileUtil.write(dummyFile1.getAbsolutePath(), "dummy 1".getBytes(Constants.UTF_8));
|
||||
dummyFile2 = new File(testCoreDir, "dummy.txt");
|
||||
FileUtil.write(dummyFile2.getAbsolutePath(), "dummy 2".getBytes(Constants.UTF_8));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
FileUtils.deleteDirectory(testDir);
|
||||
}
|
||||
|
||||
public void test_find() {
|
||||
final SynonymLocator synonymLocator = new SynonymLocator();
|
||||
synonymLocator.excludedSynonymList = new ArrayList<String>();
|
||||
synonymLocator.excludedSynonymList.add("data");
|
||||
synonymLocator.addSearchPath(testDir.getAbsolutePath());
|
||||
final List<DictionaryFile<? extends DictionaryItem>> list = synonymLocator.find();
|
||||
assertEquals(2, list.size());
|
||||
final DictionaryFile<? extends DictionaryItem> dicFile1 = list.get(0);
|
||||
final DictionaryFile<? extends DictionaryItem> dicFile2 = list.get(1);
|
||||
assertEquals(synonymFile3.getAbsolutePath(), dicFile1.getName());
|
||||
assertEquals(synonymFile1.getAbsolutePath(), dicFile2.getName());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,152 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.dict.userdict;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.dict.DictionaryFile.PagingList;
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
import org.seasar.framework.util.FileUtil;
|
||||
|
||||
public class UserDictFileTest extends S2TestCase {
|
||||
|
||||
private File file1;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
file1 = File.createTempFile("userdict_", ".txt");
|
||||
FileUtil.write(file1.getAbsolutePath(),
|
||||
"token1,seg1,reading1,pos1\ntoken2,seg2,reading2,pos2\ntoken3,seg3,reading3,pos3".getBytes(Constants.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
file1.delete();
|
||||
}
|
||||
|
||||
public void test_selectList() {
|
||||
final UserDictFile userDictFile = new UserDictFile(file1);
|
||||
final PagingList<UserDictItem> itemList1 = userDictFile.selectList(0, 20);
|
||||
assertEquals(3, itemList1.size());
|
||||
assertEquals(3, itemList1.getAllRecordCount());
|
||||
assertEquals(1, itemList1.getCurrentPageNumber());
|
||||
assertEquals(20, itemList1.getPageSize());
|
||||
|
||||
final PagingList<UserDictItem> itemList2 = userDictFile.selectList(2, 2);
|
||||
assertEquals(1, itemList2.size());
|
||||
assertEquals(3, itemList2.getAllRecordCount());
|
||||
assertEquals(2, itemList2.getCurrentPageNumber());
|
||||
assertEquals(2, itemList2.getPageSize());
|
||||
|
||||
assertEquals(0, userDictFile.selectList(5, 5).size());
|
||||
assertEquals(0, userDictFile.selectList(-1, 5).size());
|
||||
}
|
||||
|
||||
public void test_selectList2() {
|
||||
final UserDictFile userDictFile = new UserDictFile(file1);
|
||||
final PagingList<UserDictItem> itemList = userDictFile.selectList(0, 5);
|
||||
for (int i = 0; i < itemList.size(); i++) {
|
||||
final UserDictItem userDictItem = itemList.get(i);
|
||||
assertEquals("token" + (i + 1), userDictItem.getToken());
|
||||
assertEquals("seg" + (i + 1), userDictItem.getSegmentation());
|
||||
assertEquals("reading" + (i + 1), userDictItem.getReading());
|
||||
assertEquals("pos" + (i + 1), userDictItem.getPos());
|
||||
assertFalse(userDictItem.isUpdated());
|
||||
assertFalse(userDictItem.isUpdated());
|
||||
}
|
||||
}
|
||||
|
||||
public void test_insert() {
|
||||
final UserDictFile userDictFile = new UserDictFile(file1);
|
||||
final PagingList<UserDictItem> itemList1 = userDictFile.selectList(0, 20);
|
||||
assertEquals(3, itemList1.size());
|
||||
|
||||
final UserDictItem userDictItem1 = new UserDictItem(0, "token4", "seg4", "reading4", "pos4");
|
||||
userDictFile.insert(userDictItem1);
|
||||
final PagingList<UserDictItem> itemList2 = userDictFile.selectList(0, 20);
|
||||
assertEquals(4, itemList2.size());
|
||||
assertEquals("token4", itemList2.get(3).getToken());
|
||||
assertEquals("seg4", itemList2.get(3).getSegmentation());
|
||||
assertEquals("reading4", itemList2.get(3).getReading());
|
||||
assertEquals("pos4", itemList2.get(3).getPos());
|
||||
|
||||
final UserDictItem userDictItem2 = new UserDictItem(0, "token5", "seg5", "reading5", "pos5");
|
||||
userDictFile.insert(userDictItem2);
|
||||
final PagingList<UserDictItem> itemList3 = userDictFile.selectList(0, 20);
|
||||
assertEquals(5, itemList3.size());
|
||||
assertEquals("token5", itemList3.get(4).getToken());
|
||||
assertEquals("seg5", itemList3.get(4).getSegmentation());
|
||||
assertEquals("reading5", itemList3.get(4).getReading());
|
||||
assertEquals("pos5", itemList3.get(4).getPos());
|
||||
}
|
||||
|
||||
public void test_update() {
|
||||
final UserDictFile userDictFile = new UserDictFile(file1);
|
||||
final PagingList<UserDictItem> itemList1 = userDictFile.selectList(0, 20);
|
||||
assertEquals(3, itemList1.size());
|
||||
|
||||
final UserDictItem userDictItem1 = itemList1.get(0);
|
||||
userDictItem1.setNewToken("TOKEN1");
|
||||
userDictItem1.setNewSegmentation("SEG1");
|
||||
userDictItem1.setNewReading("READING1");
|
||||
userDictItem1.setNewPos("POS1");
|
||||
userDictFile.update(userDictItem1);
|
||||
final PagingList<UserDictItem> itemList2 = userDictFile.selectList(0, 20);
|
||||
assertEquals(3, itemList2.size());
|
||||
final UserDictItem userDictItem2 = itemList2.get(0);
|
||||
assertEquals("TOKEN1", userDictItem2.getToken());
|
||||
assertEquals("SEG1", userDictItem2.getSegmentation());
|
||||
assertEquals("READING1", userDictItem2.getReading());
|
||||
assertEquals("POS1", userDictItem2.getPos());
|
||||
assertFalse(userDictItem2.isUpdated());
|
||||
|
||||
final UserDictItem userDictItem3 = itemList2.get(2);
|
||||
userDictItem3.setNewToken("TOKEN3");
|
||||
userDictItem3.setNewSegmentation("SEG3");
|
||||
userDictItem3.setNewReading("READING3");
|
||||
userDictItem3.setNewPos("POS3");
|
||||
userDictFile.update(userDictItem3);
|
||||
final PagingList<UserDictItem> itemList3 = userDictFile.selectList(0, 20);
|
||||
assertEquals(3, itemList3.size());
|
||||
final UserDictItem userDictItem4 = itemList3.get(2);
|
||||
assertEquals("TOKEN3", userDictItem4.getToken());
|
||||
assertEquals("SEG3", userDictItem4.getSegmentation());
|
||||
assertEquals("READING3", userDictItem4.getReading());
|
||||
assertEquals("POS3", userDictItem4.getPos());
|
||||
assertFalse(userDictItem4.isUpdated());
|
||||
}
|
||||
|
||||
public void test_delete() throws Exception {
|
||||
final UserDictFile userDictFile = new UserDictFile(file1);
|
||||
final PagingList<UserDictItem> itemList1 = userDictFile.selectList(0, 20);
|
||||
assertEquals(3, itemList1.size());
|
||||
|
||||
final UserDictItem userDictItem1 = itemList1.get(0);
|
||||
userDictFile.delete(userDictItem1);
|
||||
final PagingList<UserDictItem> itemList2 = userDictFile.selectList(0, 20);
|
||||
assertEquals(2, itemList2.size());
|
||||
|
||||
final UserDictItem userDictItem2 = itemList2.get(1);
|
||||
userDictFile.delete(userDictItem2);
|
||||
final PagingList<UserDictItem> itemList3 = userDictFile.selectList(0, 20);
|
||||
assertEquals(1, itemList3.size());
|
||||
|
||||
assertEquals("token2,seg2,reading2,pos2" + Constants.LINE_SEPARATOR, new String(FileUtil.getBytes(file1), Constants.UTF_8));
|
||||
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.dict.userdict;
|
||||
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class UserDictItemTest extends S2TestCase {
|
||||
|
||||
public void test_new1() {
|
||||
final UserDictItem userDictItem = new UserDictItem(1, "t1", "s1", "r1", "p1");
|
||||
assertEquals(1, userDictItem.getId());
|
||||
assertEquals("t1", userDictItem.getToken());
|
||||
assertEquals("s1", userDictItem.getSegmentation());
|
||||
assertEquals("r1", userDictItem.getReading());
|
||||
assertEquals("p1", userDictItem.getPos());
|
||||
assertNull(userDictItem.getNewToken());
|
||||
assertNull(userDictItem.getNewSegmentation());
|
||||
assertNull(userDictItem.getNewReading());
|
||||
assertNull(userDictItem.getNewPos());
|
||||
assertFalse(userDictItem.isUpdated());
|
||||
assertFalse(userDictItem.isDeleted());
|
||||
|
||||
userDictItem.setNewToken("T1");
|
||||
userDictItem.setNewSegmentation("S1");
|
||||
userDictItem.setNewReading("R1");
|
||||
userDictItem.setNewPos("P1");
|
||||
assertTrue(userDictItem.isUpdated());
|
||||
assertFalse(userDictItem.isDeleted());
|
||||
|
||||
userDictItem.setNewToken("");
|
||||
assertTrue(userDictItem.isUpdated());
|
||||
assertTrue(userDictItem.isDeleted());
|
||||
}
|
||||
|
||||
public void test_equals1() {
|
||||
final UserDictItem userDictItem1 = new UserDictItem(1, "t1", "s1", "r1", "p1");
|
||||
|
||||
assertTrue(userDictItem1.equals(userDictItem1));
|
||||
assertTrue(userDictItem1.equals(new UserDictItem(1, "t1", "s1", "r1", "p1")));
|
||||
assertTrue(userDictItem1.equals(new UserDictItem(2, "t1", "s1", "r1", "p1")));
|
||||
assertFalse(userDictItem1.equals(new UserDictItem(1, "T1", "s1", "r1", "p1")));
|
||||
assertFalse(userDictItem1.equals(new UserDictItem(1, "t1", "S1", "r1", "p1")));
|
||||
assertFalse(userDictItem1.equals(new UserDictItem(1, "t1", "s1", "R1", "p1")));
|
||||
assertFalse(userDictItem1.equals(new UserDictItem(1, "t1", "s1", "r1", "P1")));
|
||||
}
|
||||
|
||||
public void test_toLineString() {
|
||||
assertEquals("t1,s1,r1,p1", new UserDictItem(1, "t1", "s1", "r1", "p1").toLineString());
|
||||
assertEquals("t\"\"1,s\"\"1,r\"\"1,p\"\"1", new UserDictItem(1, "t\"1", "s\"1", "r\"1", "p\"1").toLineString());
|
||||
assertEquals("\"t,1\",\"s,1\",\"r,1\",\"p,1\"", new UserDictItem(1, "t,1", "s,1", "r,1", "p,1").toLineString());
|
||||
assertEquals("\"t\"\",1\",\"s\"\",1\",\"r\"\",1\",\"p\"\",1\"",
|
||||
new UserDictItem(1, "t\",1", "s\",1", "r\",1", "p\",1").toLineString());
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.dict.userdict;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.dict.DictionaryFile;
|
||||
import org.codelibs.fess.dict.DictionaryItem;
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
import org.seasar.framework.util.FileUtil;
|
||||
|
||||
public class UserDictLocatorTest extends S2TestCase {
|
||||
|
||||
private File testDir;
|
||||
|
||||
private File testDataDir;
|
||||
|
||||
private File testCoreDir;
|
||||
|
||||
private File userDictFile1;
|
||||
|
||||
private File userDictFile2;
|
||||
|
||||
private File userDictFile3;
|
||||
|
||||
private File dummyFile1;
|
||||
|
||||
private File dummyFile2;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
testDir = File.createTempFile("userdicttest", "_dir");
|
||||
testDir.delete();
|
||||
testDir.mkdirs();
|
||||
testDataDir = new File(testDir, "data");
|
||||
testDataDir.mkdirs();
|
||||
testCoreDir = new File(testDir, "core");
|
||||
testCoreDir.mkdirs();
|
||||
userDictFile1 = new File(testDir, "userdict.txt");
|
||||
FileUtil.write(userDictFile1.getAbsolutePath(), "abc=>123\nxyz,890".getBytes(Constants.UTF_8));
|
||||
userDictFile2 = new File(testDataDir, "userdict_data.txt");
|
||||
FileUtil.write(userDictFile2.getAbsolutePath(), "abc=>123\nxyz,890".getBytes(Constants.UTF_8));
|
||||
userDictFile3 = new File(testCoreDir, "userdict_core.txt");
|
||||
FileUtil.write(userDictFile3.getAbsolutePath(), "abc=>123\nxyz,890".getBytes(Constants.UTF_8));
|
||||
dummyFile1 = new File(testDir, "dummy.txt");
|
||||
FileUtil.write(dummyFile1.getAbsolutePath(), "dummy 1".getBytes(Constants.UTF_8));
|
||||
dummyFile2 = new File(testCoreDir, "dummy.txt");
|
||||
FileUtil.write(dummyFile2.getAbsolutePath(), "dummy 2".getBytes(Constants.UTF_8));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
FileUtils.deleteDirectory(testDir);
|
||||
}
|
||||
|
||||
public void test_find() {
|
||||
final UserDictLocator userDictLocator = new UserDictLocator();
|
||||
userDictLocator.excludedUserDictList = new ArrayList<String>();
|
||||
userDictLocator.excludedUserDictList.add("data");
|
||||
userDictLocator.addSearchPath(testDir.getAbsolutePath());
|
||||
final List<DictionaryFile<? extends DictionaryItem>> list = userDictLocator.find();
|
||||
assertEquals(2, list.size());
|
||||
final DictionaryFile<? extends DictionaryItem> dicFile1 = list.get(0);
|
||||
final DictionaryFile<? extends DictionaryItem> dicFile2 = list.get(1);
|
||||
assertEquals(userDictFile3.getAbsolutePath(), dicFile1.getName());
|
||||
assertEquals(userDictFile1.getAbsolutePath(), dicFile2.getName());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class DatabaseDataStoreImplTest extends S2TestCase {
|
||||
public DatabaseDataStoreImpl databaseDataStore;
|
||||
|
||||
@Override
|
||||
protected String getRootDicon() throws Throwable {
|
||||
return "fess_ds.dicon";
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,211 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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 java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
|
||||
import org.codelibs.fess.taglib.FessFunctions;
|
||||
|
||||
public class Document implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public String id;
|
||||
|
||||
//
|
||||
// public String segment;
|
||||
|
||||
public String digest;
|
||||
|
||||
//
|
||||
// public String boost;
|
||||
|
||||
public String host;
|
||||
|
||||
public String site;
|
||||
|
||||
public String url;
|
||||
|
||||
public String content;
|
||||
|
||||
public String title;
|
||||
|
||||
public String cache;
|
||||
|
||||
public String tstamp;
|
||||
|
||||
public List<String> anchor;
|
||||
|
||||
public List<String> type;
|
||||
|
||||
public Long contentLength;
|
||||
|
||||
public String lastModified;
|
||||
|
||||
//
|
||||
// public String date;
|
||||
|
||||
//
|
||||
// public String lang;
|
||||
|
||||
public String mimetype;
|
||||
|
||||
// public String getContentTitle() {
|
||||
// ViewHelper viewHelper = SingletonLaContainer.getComponent("viewHelper");
|
||||
// if (viewHelper != null) {
|
||||
// return viewHelper.getContentTitle(this);
|
||||
// }
|
||||
// return title;
|
||||
// }
|
||||
//
|
||||
// public String getContentDescription() {
|
||||
// ViewHelper viewHelper = SingletonLaContainer.getComponent("viewHelper");
|
||||
// if (viewHelper != null) {
|
||||
// return viewHelper.getContentDescription(this);
|
||||
// }
|
||||
// return "";
|
||||
// }
|
||||
//
|
||||
// public String getUrlLink() {
|
||||
// ViewHelper viewHelper = SingletonLaContainer.getComponent("viewHelper");
|
||||
// if (viewHelper != null) {
|
||||
// return viewHelper.getUrlLink(this);
|
||||
// }
|
||||
// return url;
|
||||
// }
|
||||
|
||||
public String getDigest() {
|
||||
return digest;
|
||||
}
|
||||
|
||||
public void setDigest(final String digest) {
|
||||
this.digest = digest;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(final String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getSite() {
|
||||
return site;
|
||||
}
|
||||
|
||||
public void setSite(final String site) {
|
||||
this.site = site;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(final String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(final String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(final String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getTstamp() {
|
||||
return tstamp;
|
||||
}
|
||||
|
||||
public void setTstamp(final String tstamp) {
|
||||
this.tstamp = tstamp;
|
||||
}
|
||||
|
||||
public Date getTstampDate() {
|
||||
return FessFunctions.parseDate(tstamp);
|
||||
}
|
||||
|
||||
public List<String> getAnchor() {
|
||||
return anchor;
|
||||
}
|
||||
|
||||
public void setAnchor(final List<String> anchor) {
|
||||
this.anchor = anchor;
|
||||
}
|
||||
|
||||
public String getMimetype() {
|
||||
return mimetype;
|
||||
}
|
||||
|
||||
public void setMimetype(final String type) {
|
||||
mimetype = type;
|
||||
}
|
||||
|
||||
public Long getContentLength() {
|
||||
return contentLength;
|
||||
}
|
||||
|
||||
public void setContentLength(final Long contentLength) {
|
||||
this.contentLength = contentLength;
|
||||
}
|
||||
|
||||
public List<String> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(final List<String> type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getCache() {
|
||||
return cache;
|
||||
}
|
||||
|
||||
public void setCache(final String cache) {
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
public String getLastModified() {
|
||||
return lastModified;
|
||||
}
|
||||
|
||||
public void setLastModified(final String lastModified) {
|
||||
this.lastModified = lastModified;
|
||||
}
|
||||
|
||||
public Date getLastModifiedDate() {
|
||||
return FessFunctions.parseDate(lastModified);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ReflectionToStringBuilder(this).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class GeoInfoTest extends S2TestCase {
|
||||
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());
|
||||
// assertEquals("{!geofilt pt=" + Double.toString(Double.parseDouble(latitude)) + "," + Double.toString(Double.parseDouble(lonitude))
|
||||
// + " sfield=location d=" + distance + ".0}", geoInfo.toGeoQueryString());
|
||||
}
|
||||
|
||||
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());
|
||||
// assertEquals("{!geofilt pt=" + Double.toString(Double.parseDouble(latitude)) + "," + Double.toString(Double.parseDouble(lonitude))
|
||||
// + " sfield=location d=" + distance + ".0}", geoInfo.toGeoQueryString());
|
||||
}
|
||||
|
||||
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());
|
||||
// assertEquals("{!geofilt pt=90.0,-179.0 sfield=location d=10.0}", geoInfo.toGeoQueryString());
|
||||
}
|
||||
|
||||
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());
|
||||
// assertEquals("{!geofilt pt=90.0,1.0 sfield=location d=100.0}", geoInfo.toGeoQueryString());
|
||||
}
|
||||
|
||||
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());
|
||||
// assertEquals("{!geofilt pt=" + Double.toString(Double.parseDouble(latitude)) + "," + Double.toString(Double.parseDouble(lonitude))
|
||||
// + " sfield=location d=" + distance + ".0}", geoInfo.toGeoQueryString());
|
||||
}
|
||||
|
||||
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());
|
||||
// assertEquals("{!geofilt pt=-90.0,179.0 sfield=location d=10.0}", geoInfo.toGeoQueryString());
|
||||
}
|
||||
|
||||
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());
|
||||
// assertEquals("{!geofilt pt=-90.0,-1.0 sfield=location d=100.0}", geoInfo.toGeoQueryString());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class FessEncodingFilterTest extends S2TestCase {
|
||||
public void test_normal() throws IOException {
|
||||
final FessEncodingFilter filter = new FessEncodingFilter();
|
||||
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 FessEncodingFilter filter = new FessEncodingFilter();
|
||||
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 FessEncodingFilter filter = new FessEncodingFilter();
|
||||
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]);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.helper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class CrawlingSessionHelperTest extends S2TestCase {
|
||||
|
||||
public CrawlingSessionHelper crawlingSessionHelper;
|
||||
|
||||
@Override
|
||||
protected String getRootDicon() throws Throwable {
|
||||
return "app.dicon";
|
||||
}
|
||||
|
||||
public void test_generateId() {
|
||||
final Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("url", "http://hoge.com/");
|
||||
|
||||
assertEquals("http://hoge.com/", crawlingSessionHelper.generateId(dataMap));
|
||||
|
||||
final List<String> browserTypeList = new ArrayList<String>();
|
||||
dataMap.put("type", browserTypeList);
|
||||
final List<String> roleTypeList = new ArrayList<String>();
|
||||
dataMap.put("role", roleTypeList);
|
||||
|
||||
assertEquals("http://hoge.com/", crawlingSessionHelper.generateId(dataMap));
|
||||
}
|
||||
|
||||
public void test_generateId_roleType() {
|
||||
final Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
dataMap.put("url", "http://hoge.com/");
|
||||
final List<String> roleTypeList = new ArrayList<String>();
|
||||
roleTypeList.add("admin");
|
||||
dataMap.put("role", roleTypeList);
|
||||
|
||||
assertEquals("http://hoge.com/;role=admin", crawlingSessionHelper.generateId(dataMap));
|
||||
|
||||
roleTypeList.add("guest");
|
||||
|
||||
assertEquals("http://hoge.com/;role=admin,guest", crawlingSessionHelper.generateId(dataMap));
|
||||
|
||||
final List<String> browserTypeList = new ArrayList<String>();
|
||||
dataMap.put("type", browserTypeList);
|
||||
|
||||
assertEquals("http://hoge.com/;role=admin,guest", crawlingSessionHelper.generateId(dataMap));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.helper;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class IntervalControlHelperTest extends S2TestCase {
|
||||
public IntervalControlHelper intervalControlHelper;
|
||||
|
||||
@Override
|
||||
protected String getRootDicon() throws Throwable {
|
||||
return "org/codelibs/fess/helper/intervalControl.dicon";
|
||||
}
|
||||
|
||||
public void test_noRule() throws ParseException {
|
||||
assertEquals(0, intervalControlHelper.getDelay());
|
||||
}
|
||||
|
||||
public void test_0000() throws ParseException {
|
||||
final IntervalControlHelper intervalControlHelper = createHelper("00:00", 1);
|
||||
intervalControlHelper.addIntervalRule("01:30", "15:15", "*", 1000);
|
||||
assertEquals(0, intervalControlHelper.getDelay());
|
||||
|
||||
intervalControlHelper.addIntervalRule("16:30", "0:15", "*", 2000);
|
||||
assertEquals(2000, intervalControlHelper.getDelay());
|
||||
|
||||
intervalControlHelper.ruleList.clear();
|
||||
|
||||
intervalControlHelper.addIntervalRule("22:15", "2:45", "1", 3000);
|
||||
assertEquals(0, intervalControlHelper.getDelay());
|
||||
|
||||
intervalControlHelper.addIntervalRule("22:15", "2:45", "2", 4000);
|
||||
assertEquals(4000, intervalControlHelper.getDelay());
|
||||
}
|
||||
|
||||
public void test_1215() throws ParseException {
|
||||
final IntervalControlHelper intervalControlHelper = createHelper("12:15", 1);
|
||||
intervalControlHelper.addIntervalRule("01:30", "12:05", "*", 1000);
|
||||
assertEquals(0, intervalControlHelper.getDelay());
|
||||
|
||||
intervalControlHelper.addIntervalRule("12:30", "23:15", "*", 1000);
|
||||
assertEquals(0, intervalControlHelper.getDelay());
|
||||
|
||||
intervalControlHelper.addIntervalRule("12:05", "12:15", "*", 2000);
|
||||
assertEquals(2000, intervalControlHelper.getDelay());
|
||||
|
||||
intervalControlHelper.ruleList.clear();
|
||||
|
||||
intervalControlHelper.addIntervalRule("12:15", "12:15", "*", 3000);
|
||||
assertEquals(3000, intervalControlHelper.getDelay());
|
||||
|
||||
intervalControlHelper.ruleList.clear();
|
||||
|
||||
intervalControlHelper.addIntervalRule("12:15", "12:15", "3,5", 4000);
|
||||
assertEquals(0, intervalControlHelper.getDelay());
|
||||
|
||||
intervalControlHelper.addIntervalRule("12:10", "12:20", "1", 5000);
|
||||
assertEquals(5000, intervalControlHelper.getDelay());
|
||||
|
||||
}
|
||||
|
||||
public void test_2250() throws ParseException {
|
||||
final IntervalControlHelper intervalControlHelper = createHelper("22:50", 1);
|
||||
intervalControlHelper.addIntervalRule("01:30", "15:15", "*", 1000);
|
||||
assertEquals(0, intervalControlHelper.getDelay());
|
||||
|
||||
intervalControlHelper.addIntervalRule("16:30", "0:15", "*", 2000);
|
||||
assertEquals(2000, intervalControlHelper.getDelay());
|
||||
|
||||
intervalControlHelper.ruleList.clear();
|
||||
|
||||
intervalControlHelper.addIntervalRule("22:15", "2:45", "2", 3000);
|
||||
assertEquals(0, intervalControlHelper.getDelay());
|
||||
|
||||
intervalControlHelper.addIntervalRule("22:15", "2:45", "1", 4000);
|
||||
assertEquals(4000, intervalControlHelper.getDelay());
|
||||
}
|
||||
|
||||
private IntervalControlHelper createHelper(final String time, final int day) throws ParseException {
|
||||
final Date date = new SimpleDateFormat("HH:mm").parse(time);
|
||||
return new IntervalControlHelper() {
|
||||
@Override
|
||||
protected Calendar getCurrentCal() {
|
||||
final Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(date.getTime());
|
||||
cal.set(Calendar.DAY_OF_WEEK, day);
|
||||
return cal;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.helper;
|
||||
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class OverlappingHostHelperTest extends S2TestCase {
|
||||
public OverlappingHostHelper overlappingHostHelper;
|
||||
|
||||
@Override
|
||||
protected String getRootDicon() throws Throwable {
|
||||
return "org/codelibs/fess/helper/overlappingHost.dicon";
|
||||
}
|
||||
|
||||
public void test_convert() {
|
||||
String url;
|
||||
String result;
|
||||
|
||||
url = "http://hoge.com";
|
||||
result = "http://www.hoge.com";
|
||||
assertEquals(result, overlappingHostHelper.convert(url));
|
||||
|
||||
url = "http://hoge.com/";
|
||||
result = "http://www.hoge.com/";
|
||||
assertEquals(result, overlappingHostHelper.convert(url));
|
||||
|
||||
url = "http://hoge.com:8080/";
|
||||
result = "http://www.hoge.com:8080/";
|
||||
assertEquals(result, overlappingHostHelper.convert(url));
|
||||
|
||||
url = "http://mail.fuga.com/";
|
||||
result = "http://www.fuga.com/";
|
||||
assertEquals(result, overlappingHostHelper.convert(url));
|
||||
|
||||
}
|
||||
|
||||
public void test_convert_skip() {
|
||||
String url;
|
||||
String result;
|
||||
|
||||
url = "http://www.hoge.com";
|
||||
result = "http://www.hoge.com";
|
||||
assertEquals(result, overlappingHostHelper.convert(url));
|
||||
|
||||
url = "http://www.hoge.com/";
|
||||
result = "http://www.hoge.com/";
|
||||
assertEquals(result, overlappingHostHelper.convert(url));
|
||||
|
||||
url = "http://www.hoge.com:8080/";
|
||||
result = "http://www.hoge.com:8080/";
|
||||
assertEquals(result, overlappingHostHelper.convert(url));
|
||||
|
||||
url = "http://www.fuga.com/";
|
||||
result = "http://www.fuga.com/";
|
||||
assertEquals(result, overlappingHostHelper.convert(url));
|
||||
|
||||
url = "http://www.fuga.com:8080/";
|
||||
result = "http://www.fuga.com:8080/";
|
||||
assertEquals(result, overlappingHostHelper.convert(url));
|
||||
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.helper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.codelibs.fess.es.exentity.PathMapping;
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class PathMappingHelperTest extends S2TestCase {
|
||||
|
||||
public PathMappingHelper pathMappingHelper;
|
||||
|
||||
@Override
|
||||
protected String getRootDicon() throws Throwable {
|
||||
return "org/codelibs/fess/helper/pathMapping.dicon";
|
||||
}
|
||||
|
||||
public void test_setPathMappingList() {
|
||||
final String sessionId = "test";
|
||||
final List<PathMapping> pathMappingList = new ArrayList<PathMapping>();
|
||||
|
||||
assertNull(pathMappingHelper.getPathMappingList(sessionId));
|
||||
assertNull(pathMappingHelper.getPathMappingList(sessionId + "1"));
|
||||
pathMappingHelper.setPathMappingList(sessionId, pathMappingList);
|
||||
assertNotNull(pathMappingHelper.getPathMappingList(sessionId));
|
||||
assertNull(pathMappingHelper.getPathMappingList(sessionId + "1"));
|
||||
pathMappingHelper.removePathMappingList(sessionId);
|
||||
assertNull(pathMappingHelper.getPathMappingList(sessionId));
|
||||
assertNull(pathMappingHelper.getPathMappingList(sessionId + "1"));
|
||||
|
||||
}
|
||||
|
||||
public void test_replaceUrl() {
|
||||
final String sessionId = "test";
|
||||
final List<PathMapping> pathMappingList = new ArrayList<PathMapping>();
|
||||
final PathMapping pathMapping = new PathMapping();
|
||||
pathMapping.setRegex("file:///home/");
|
||||
pathMapping.setReplacement("http://localhost/");
|
||||
pathMappingList.add(pathMapping);
|
||||
|
||||
pathMappingHelper.setPathMappingList(sessionId, pathMappingList);
|
||||
|
||||
final String url = "file:///home/taro/";
|
||||
assertEquals("http://localhost/taro/", pathMappingHelper.replaceUrl(sessionId, url));
|
||||
}
|
||||
|
||||
public void test_replaceUrls() {
|
||||
final List<PathMapping> pathMappingList = new ArrayList<PathMapping>();
|
||||
final PathMapping pathMapping = new PathMapping();
|
||||
pathMapping.setRegex("file:///home/");
|
||||
pathMapping.setReplacement("http://localhost/");
|
||||
pathMappingList.add(pathMapping);
|
||||
|
||||
pathMappingHelper.cachedPathMappingList = pathMappingList;
|
||||
|
||||
String text = "\"file:///home/\"";
|
||||
assertEquals("\"http://localhost/\"", pathMappingHelper.replaceUrls(text));
|
||||
|
||||
text = "\"file:///home/taro/\"";
|
||||
assertEquals("\"http://localhost/taro/\"", pathMappingHelper.replaceUrls(text));
|
||||
|
||||
text = "\"aaafile:///home/taro/\"";
|
||||
assertEquals("\"aaahttp://localhost/taro/\"", pathMappingHelper.replaceUrls(text));
|
||||
|
||||
text = "aaa\"file:///home/taro/\"bbb";
|
||||
assertEquals("aaa\"http://localhost/taro/\"bbb", pathMappingHelper.replaceUrls(text));
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.helper;
|
||||
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class SystemHelperTest extends S2TestCase {
|
||||
public SystemHelper systemHelper;
|
||||
|
||||
@Override
|
||||
protected String getRootDicon() throws Throwable {
|
||||
return "org/codelibs/fess/helper/system.dicon";
|
||||
}
|
||||
|
||||
public void test_encodeUrlFilter() {
|
||||
String path = null;
|
||||
assertNull(systemHelper.encodeUrlFilter(path));
|
||||
|
||||
path = "abc";
|
||||
assertEquals(path, systemHelper.encodeUrlFilter(path));
|
||||
|
||||
path = "あいう";
|
||||
assertEquals("%E3%81%82%E3%81%84%E3%81%86", systemHelper.encodeUrlFilter(path));
|
||||
|
||||
path = "[]^$.*+?,{}|%\\";
|
||||
assertEquals(path, systemHelper.encodeUrlFilter(path));
|
||||
}
|
||||
|
||||
public void test_normalizeLang() {
|
||||
String value = null;
|
||||
assertNull(systemHelper.normalizeLang(value));
|
||||
|
||||
value = "";
|
||||
assertNull(systemHelper.normalizeLang(value));
|
||||
|
||||
value = "_ja";
|
||||
assertNull(systemHelper.normalizeLang(value));
|
||||
|
||||
value = "ja";
|
||||
assertEquals("ja", systemHelper.normalizeLang(value));
|
||||
|
||||
value = " ja ";
|
||||
assertEquals("ja", systemHelper.normalizeLang(value));
|
||||
|
||||
value = "ja-JP";
|
||||
assertEquals("ja", systemHelper.normalizeLang(value));
|
||||
|
||||
value = "ja_JP";
|
||||
assertEquals("ja", systemHelper.normalizeLang(value));
|
||||
|
||||
value = "ja_JP_AAA";
|
||||
assertEquals("ja", systemHelper.normalizeLang(value));
|
||||
|
||||
value = "zh";
|
||||
assertEquals("zh", systemHelper.normalizeLang(value));
|
||||
|
||||
value = "zh-cn";
|
||||
assertEquals("zh_CN", systemHelper.normalizeLang(value));
|
||||
|
||||
value = "zh_CN";
|
||||
assertEquals("zh_CN", systemHelper.normalizeLang(value));
|
||||
|
||||
value = "zh-tw";
|
||||
assertEquals("zh_TW", systemHelper.normalizeLang(value));
|
||||
|
||||
value = "zh_TW";
|
||||
assertEquals("zh_TW", systemHelper.normalizeLang(value));
|
||||
}
|
||||
}
|
|
@ -1,136 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.helper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class ViewHelperTest extends S2TestCase {
|
||||
public ViewHelper viewHelper;
|
||||
|
||||
@Override
|
||||
protected String getRootDicon() throws Throwable {
|
||||
return "org/codelibs/fess/helper/view.dicon";
|
||||
}
|
||||
|
||||
public void test_replaceHighlightQueries() {
|
||||
String text;
|
||||
String[] queries;
|
||||
|
||||
text = "<a>123<b>456<c>";
|
||||
queries = new String[] { "123", "456" };
|
||||
assertEquals("<a><em>123</em><b><em>456</em><c>", viewHelper.replaceHighlightQueries(text, queries));
|
||||
|
||||
text = "<123><456>";
|
||||
queries = new String[] { "123", "456" };
|
||||
assertEquals("<123><456>", viewHelper.replaceHighlightQueries(text, queries));
|
||||
|
||||
text = "123<aaa 123>456<bbb 456>123";
|
||||
queries = new String[] { "123", "456" };
|
||||
assertEquals("<em>123</em><aaa 123><em>456</em><bbb 456><em>123</em>", viewHelper.replaceHighlightQueries(text, queries));
|
||||
|
||||
text = "abc";
|
||||
queries = new String[] { "123" };
|
||||
assertEquals("abc", viewHelper.replaceHighlightQueries(text, queries));
|
||||
|
||||
text = "123";
|
||||
queries = new String[] { "123" };
|
||||
assertEquals("<em>123</em>", viewHelper.replaceHighlightQueries(text, queries));
|
||||
|
||||
text = "abc123efg";
|
||||
queries = new String[] { "123" };
|
||||
assertEquals("abc<em>123</em>efg", viewHelper.replaceHighlightQueries(text, queries));
|
||||
|
||||
text = "123";
|
||||
queries = new String[] { "123", "456" };
|
||||
assertEquals("<em>123</em>", viewHelper.replaceHighlightQueries(text, queries));
|
||||
|
||||
text = "123456";
|
||||
queries = new String[] { "123", "456" };
|
||||
assertEquals("<em>123</em><em>456</em>", viewHelper.replaceHighlightQueries(text, queries));
|
||||
|
||||
text = "a123b456c";
|
||||
queries = new String[] { "123", "456" };
|
||||
assertEquals("a<em>123</em>b<em>456</em>c", viewHelper.replaceHighlightQueries(text, queries));
|
||||
|
||||
text = "abc";
|
||||
queries = new String[] { "abc" };
|
||||
assertEquals("<em>abc</em>", viewHelper.replaceHighlightQueries(text, queries));
|
||||
|
||||
text = "1ABC2";
|
||||
queries = new String[] { "abc" };
|
||||
assertEquals("1<em>abc</em>2", viewHelper.replaceHighlightQueries(text, queries));
|
||||
}
|
||||
|
||||
public void test_escapeHighlight() {
|
||||
viewHelper = new ViewHelper();
|
||||
viewHelper.useSolrHighlight = true;
|
||||
viewHelper.init();
|
||||
|
||||
String text = "";
|
||||
assertEquals("", viewHelper.escapeHighlight(text));
|
||||
|
||||
text = "aaa";
|
||||
assertEquals("aaa", viewHelper.escapeHighlight(text));
|
||||
|
||||
text = "<em>aaa</em>";
|
||||
assertEquals("<em>aaa</em>", viewHelper.escapeHighlight(text));
|
||||
|
||||
text = "<em>aaa</em><b>bbb</b>";
|
||||
assertEquals("<em>aaa</em><b>bbb</b>", viewHelper.escapeHighlight(text));
|
||||
|
||||
}
|
||||
|
||||
public void test_getSitePath() {
|
||||
String urlLink;
|
||||
String sitePath;
|
||||
final Map<String, Object> docMap = new HashMap<>();
|
||||
|
||||
urlLink = "http://www.yahoo.co.jp";
|
||||
sitePath = "www.yahoo.co.jp";
|
||||
docMap.put("urlLink", urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "https://www.jp.websecurity.symantec.com/";
|
||||
sitePath = "www.jp.websecurity.symantec.com/";
|
||||
docMap.put("urlLink", urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "http://www.dfasdfaskdfkakdfadfsd.jp";
|
||||
sitePath = "www.dfasdfaskdfkakdfadfsd.jp";
|
||||
docMap.put("urlLink", urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "www.yahoo.co.jp";
|
||||
sitePath = "www.yahoo.co.jp";
|
||||
docMap.put("urlLink", urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "smb://123.45.678.91/kyoyu1";
|
||||
sitePath = "123.45.678.91/kyoyu1";
|
||||
docMap.put("urlLink", urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "file://home/taro/";
|
||||
sitePath = "home/taro/";
|
||||
docMap.put("urlLink", urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,354 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.helper.impl;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
|
||||
import org.codelibs.core.crypto.CachedCipher;
|
||||
import org.codelibs.core.exception.IllegalBlockSizeRuntimeException;
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class RoleQueryHelperImplTest extends S2TestCase {
|
||||
|
||||
public CachedCipher cipher;
|
||||
|
||||
@Override
|
||||
protected String getRootDicon() throws Throwable {
|
||||
return "org/codelibs/fess/helper/query.dicon";
|
||||
}
|
||||
|
||||
public void test_buildByParameter() {
|
||||
final RoleQueryHelperImpl roleQueryHelperImpl = new RoleQueryHelperImpl();
|
||||
|
||||
Set<String> roleSet;
|
||||
|
||||
roleSet = roleQueryHelperImpl.buildByParameter(getRequest());
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
roleQueryHelperImpl.parameterKey = "fess1";
|
||||
|
||||
getRequest().setParameter("aaa", "bbb");
|
||||
roleSet = roleQueryHelperImpl.buildByParameter(getRequest());
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
roleQueryHelperImpl.encryptedParameterValue = false;
|
||||
getRequest().setParameter("fess1", "xxx\nrole1,role2,role3");
|
||||
roleSet = roleQueryHelperImpl.buildByParameter(getRequest());
|
||||
assertEquals(3, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
assertTrue(roleSet.contains("role2"));
|
||||
assertTrue(roleSet.contains("role3"));
|
||||
|
||||
roleQueryHelperImpl.parameterKey = "fess2";
|
||||
|
||||
roleQueryHelperImpl.cipher = cipher;
|
||||
roleQueryHelperImpl.encryptedParameterValue = true;
|
||||
getRequest().setParameter("fess2", cipher.encryptoText("xxx\nrole1,role2,role3"));
|
||||
roleSet = roleQueryHelperImpl.buildByParameter(getRequest());
|
||||
assertEquals(3, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
assertTrue(roleSet.contains("role2"));
|
||||
assertTrue(roleSet.contains("role3"));
|
||||
|
||||
getRequest().setParameter("fess2", "fail");
|
||||
try {
|
||||
roleSet = roleQueryHelperImpl.buildByParameter(getRequest());
|
||||
fail();
|
||||
} catch (final IllegalBlockSizeRuntimeException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
roleQueryHelperImpl.parameterKey = "fess3";
|
||||
|
||||
roleQueryHelperImpl.encryptedParameterValue = false;
|
||||
roleSet = roleQueryHelperImpl.buildByParameter(getRequest());
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
roleQueryHelperImpl.parameterKey = "fess4";
|
||||
|
||||
roleQueryHelperImpl.cipher = cipher;
|
||||
roleQueryHelperImpl.encryptedParameterValue = true;
|
||||
roleSet = roleQueryHelperImpl.buildByParameter(getRequest());
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
}
|
||||
|
||||
public void test_buildByHeader() {
|
||||
final RoleQueryHelperImpl roleQueryHelperImpl = new RoleQueryHelperImpl();
|
||||
|
||||
Set<String> roleSet;
|
||||
|
||||
try {
|
||||
roleSet = roleQueryHelperImpl.buildByHeader(getRequest());
|
||||
fail();
|
||||
} catch (final NullPointerException e) {
|
||||
//ok
|
||||
}
|
||||
|
||||
roleQueryHelperImpl.headerKey = "fess1";
|
||||
|
||||
getRequest().addHeader("aaa", "bbb");
|
||||
roleSet = roleQueryHelperImpl.buildByHeader(getRequest());
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
roleQueryHelperImpl.encryptedHeaderValue = false;
|
||||
getRequest().addHeader("fess1", "xxx\nrole1,role2,role3");
|
||||
roleSet = roleQueryHelperImpl.buildByHeader(getRequest());
|
||||
assertEquals(3, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
assertTrue(roleSet.contains("role2"));
|
||||
assertTrue(roleSet.contains("role3"));
|
||||
|
||||
roleQueryHelperImpl.headerKey = "fess2";
|
||||
|
||||
roleQueryHelperImpl.cipher = cipher;
|
||||
roleQueryHelperImpl.encryptedHeaderValue = true;
|
||||
getRequest().addHeader("fess2", cipher.encryptoText("xxx\nrole1,role2,role3"));
|
||||
roleSet = roleQueryHelperImpl.buildByHeader(getRequest());
|
||||
assertEquals(3, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
assertTrue(roleSet.contains("role2"));
|
||||
assertTrue(roleSet.contains("role3"));
|
||||
|
||||
roleQueryHelperImpl.headerKey = "fess2x";
|
||||
getRequest().addHeader("fess2x", "fail");
|
||||
try {
|
||||
roleSet = roleQueryHelperImpl.buildByHeader(getRequest());
|
||||
fail();
|
||||
} catch (final IllegalBlockSizeRuntimeException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
roleQueryHelperImpl.headerKey = "fess3";
|
||||
|
||||
roleQueryHelperImpl.encryptedHeaderValue = false;
|
||||
roleSet = roleQueryHelperImpl.buildByHeader(getRequest());
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
roleQueryHelperImpl.headerKey = "fess4";
|
||||
|
||||
roleQueryHelperImpl.cipher = cipher;
|
||||
roleQueryHelperImpl.encryptedHeaderValue = true;
|
||||
roleSet = roleQueryHelperImpl.buildByHeader(getRequest());
|
||||
assertEquals(0, roleSet.size());
|
||||
}
|
||||
|
||||
public void test_buildByCookie() {
|
||||
final RoleQueryHelperImpl roleQueryHelperImpl = new RoleQueryHelperImpl();
|
||||
|
||||
Set<String> roleSet;
|
||||
Cookie cookie;
|
||||
|
||||
roleSet = roleQueryHelperImpl.buildByCookie(getRequest());
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
cookie = new Cookie("aaa", "bbb");
|
||||
getRequest().addCookie(cookie);
|
||||
try {
|
||||
roleSet = roleQueryHelperImpl.buildByCookie(getRequest());
|
||||
fail();
|
||||
} catch (final NullPointerException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
roleQueryHelperImpl.cookieKey = "fess1";
|
||||
|
||||
roleSet = roleQueryHelperImpl.buildByCookie(getRequest());
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
roleQueryHelperImpl.encryptedCookieValue = false;
|
||||
cookie = new Cookie("fess1", "xxx\nrole1,role2,role3");
|
||||
getRequest().addCookie(cookie);
|
||||
roleSet = roleQueryHelperImpl.buildByCookie(getRequest());
|
||||
assertEquals(3, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
assertTrue(roleSet.contains("role2"));
|
||||
assertTrue(roleSet.contains("role3"));
|
||||
|
||||
roleQueryHelperImpl.cookieKey = "fess2";
|
||||
|
||||
roleQueryHelperImpl.cipher = cipher;
|
||||
roleQueryHelperImpl.encryptedCookieValue = true;
|
||||
cookie = new Cookie("fess2", cipher.encryptoText("xxx\nrole1,role2,role3"));
|
||||
getRequest().addCookie(cookie);
|
||||
roleSet = roleQueryHelperImpl.buildByCookie(getRequest());
|
||||
assertEquals(3, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
assertTrue(roleSet.contains("role2"));
|
||||
assertTrue(roleSet.contains("role3"));
|
||||
|
||||
roleQueryHelperImpl.cookieKey = "fess2x";
|
||||
|
||||
roleQueryHelperImpl.cipher = cipher;
|
||||
roleQueryHelperImpl.encryptedCookieValue = true;
|
||||
cookie = new Cookie("fess2x", "fail");
|
||||
getRequest().addCookie(cookie);
|
||||
try {
|
||||
roleSet = roleQueryHelperImpl.buildByCookie(getRequest());
|
||||
fail();
|
||||
} catch (final Exception e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
roleQueryHelperImpl.cookieKey = "fess3";
|
||||
|
||||
roleQueryHelperImpl.encryptedCookieValue = false;
|
||||
roleSet = roleQueryHelperImpl.buildByCookie(getRequest());
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
roleQueryHelperImpl.cookieKey = "fess4";
|
||||
|
||||
roleQueryHelperImpl.cipher = cipher;
|
||||
roleQueryHelperImpl.encryptedCookieValue = true;
|
||||
roleSet = roleQueryHelperImpl.buildByCookie(getRequest());
|
||||
assertEquals(0, roleSet.size());
|
||||
}
|
||||
|
||||
public void test_decodedRoleList() {
|
||||
|
||||
final RoleQueryHelperImpl roleQueryHelperImpl = new RoleQueryHelperImpl();
|
||||
|
||||
Set<String> roleSet;
|
||||
boolean encrypted;
|
||||
String value;
|
||||
|
||||
encrypted = false;
|
||||
value = "";
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
encrypted = false;
|
||||
value = "role1";
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
encrypted = false;
|
||||
value = "role1,role2";
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
encrypted = false;
|
||||
value = "xxx\nrole1";
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(1, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
|
||||
encrypted = false;
|
||||
value = "xxx\nrole1,role2";
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(2, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
assertTrue(roleSet.contains("role2"));
|
||||
|
||||
roleQueryHelperImpl.valueSeparator = "";
|
||||
|
||||
encrypted = false;
|
||||
value = "";
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
encrypted = false;
|
||||
value = "role1";
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(1, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
|
||||
encrypted = false;
|
||||
value = "role1,role2";
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(2, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
assertTrue(roleSet.contains("role2"));
|
||||
|
||||
encrypted = false;
|
||||
value = "role1,role2,role3";
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(3, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
assertTrue(roleSet.contains("role2"));
|
||||
assertTrue(roleSet.contains("role3"));
|
||||
}
|
||||
|
||||
public void test_decodedRoleList_withCipher() {
|
||||
|
||||
final RoleQueryHelperImpl roleQueryHelperImpl = new RoleQueryHelperImpl();
|
||||
roleQueryHelperImpl.cipher = cipher;
|
||||
|
||||
Set<String> roleSet;
|
||||
boolean encrypted;
|
||||
String value;
|
||||
|
||||
encrypted = true;
|
||||
value = cipher.encryptoText("");
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
encrypted = true;
|
||||
value = cipher.encryptoText("role1");
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
encrypted = true;
|
||||
value = cipher.encryptoText("role1,role2");
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
encrypted = true;
|
||||
value = cipher.encryptoText("xxx\nrole1");
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(1, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
|
||||
encrypted = true;
|
||||
value = cipher.encryptoText("xxx\nrole1,role2");
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(2, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
assertTrue(roleSet.contains("role2"));
|
||||
|
||||
roleQueryHelperImpl.valueSeparator = "";
|
||||
|
||||
encrypted = true;
|
||||
value = cipher.encryptoText("");
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(0, roleSet.size());
|
||||
|
||||
encrypted = true;
|
||||
value = cipher.encryptoText("role1");
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(1, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
|
||||
encrypted = true;
|
||||
value = cipher.encryptoText("role1,role2");
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(2, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
assertTrue(roleSet.contains("role2"));
|
||||
|
||||
encrypted = true;
|
||||
value = cipher.encryptoText("role1,role2,role3");
|
||||
roleSet = roleQueryHelperImpl.decodedRoleList(value, encrypted);
|
||||
assertEquals(3, roleSet.size());
|
||||
assertTrue(roleSet.contains("role1"));
|
||||
assertTrue(roleSet.contains("role2"));
|
||||
assertTrue(roleSet.contains("role3"));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.lasta;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
import org.codelibs.fess.unit.UnitFessTestCase;
|
||||
|
||||
/**
|
||||
* @author jflute
|
||||
*/
|
||||
public class LastaEnvTest extends UnitFessTestCase {
|
||||
|
||||
@Resource
|
||||
protected FessConfig fessConfig;
|
||||
|
||||
public void test_boot() throws Exception {
|
||||
assertNotNull(fessConfig);
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.solr;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class BoostDocumentRuleTest extends S2TestCase {
|
||||
|
||||
public void test_integer() {
|
||||
final BoostDocumentRule docRule = new BoostDocumentRule();
|
||||
docRule.setBoostExpression("10");
|
||||
docRule.setMatchExpression("data1 > 10");
|
||||
|
||||
final Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
assertTrue(0.0f == docRule.getValue(map));
|
||||
|
||||
map.put("data1", 20);
|
||||
assertTrue(docRule.match(map));
|
||||
|
||||
map.put("data1", 5);
|
||||
assertFalse(docRule.match(map));
|
||||
|
||||
map.remove("data1");
|
||||
assertFalse(docRule.match(map));
|
||||
|
||||
map.put("data2", 5);
|
||||
assertFalse(docRule.match(map));
|
||||
}
|
||||
|
||||
public void test_string() {
|
||||
final BoostDocumentRule docRule = new BoostDocumentRule();
|
||||
docRule.setBoostExpression("10");
|
||||
docRule.setMatchExpression("data1 != null && data1.matches(\"test\")");
|
||||
|
||||
final Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
map.put("data1", "test");
|
||||
assertTrue(docRule.match(map));
|
||||
|
||||
map.put("data1", "aaa test bbb");
|
||||
assertFalse(docRule.match(map));
|
||||
|
||||
map.put("data1", "hoge");
|
||||
assertFalse(docRule.match(map));
|
||||
|
||||
map.remove("data1");
|
||||
assertFalse(docRule.match(map));
|
||||
|
||||
map.put("data2", "hoge");
|
||||
assertFalse(docRule.match(map));
|
||||
|
||||
docRule.setMatchExpression("data1.matches(\".*test.*\")");
|
||||
map.put("data1", "aaa test bbb");
|
||||
assertTrue(docRule.match(map));
|
||||
}
|
||||
|
||||
public void test_boost_params() {
|
||||
final BoostDocumentRule docRule = new BoostDocumentRule();
|
||||
docRule.setBoostExpression("10 * boost1 + boost2");
|
||||
docRule.setMatchExpression("data1 > 10");
|
||||
|
||||
final Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
map.put("boost1", 0);
|
||||
map.put("boost2", 0);
|
||||
assertTrue(0.0f == docRule.getValue(map));
|
||||
|
||||
map.put("boost1", 1);
|
||||
map.put("boost2", 0);
|
||||
assertTrue(10.0f == docRule.getValue(map));
|
||||
|
||||
map.put("boost1", 1);
|
||||
map.put("boost2", 2);
|
||||
assertTrue(12.0f == docRule.getValue(map));
|
||||
}
|
||||
}
|
|
@ -1,217 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.transformer;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.FessSystemException;
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class FessFileTransformerTest extends S2TestCase {
|
||||
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://hoge.com/";
|
||||
exp = "http://hoge.com/";
|
||||
assertEquals(exp, transformer.decodeUrlAsName(url, false));
|
||||
|
||||
url = "http://hoge.com/index.html";
|
||||
exp = "http://hoge.com/index.html";
|
||||
assertEquals(exp, transformer.decodeUrlAsName(url, false));
|
||||
|
||||
url = "http://hoge.com/" + encodeUrl("テスト ") + ".html";
|
||||
exp = "http://hoge.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/taro";
|
||||
exp = "server";
|
||||
assertEquals(exp, transformer.getHost(url));
|
||||
|
||||
url = "file:/home/taro";
|
||||
exp = "localhost";
|
||||
assertEquals(exp, transformer.getHost(url));
|
||||
|
||||
url = "file:/c:/home/taro";
|
||||
exp = "localhost";
|
||||
assertEquals(exp, transformer.getHost(url));
|
||||
|
||||
url = "file:////server/home/taro";
|
||||
exp = "server";
|
||||
assertEquals(exp, transformer.getHost(url));
|
||||
|
||||
url = "file:/" + encodeUrl("ホーム") + "/taro";
|
||||
exp = "localhost";
|
||||
assertEquals(exp, transformer.getHost(url));
|
||||
|
||||
url = "file:/c:/" + encodeUrl("ホーム") + "/taro";
|
||||
exp = "localhost";
|
||||
assertEquals(exp, transformer.getHost(url));
|
||||
|
||||
url = "file:////" + encodeUrl("サーバー") + "/home/taro";
|
||||
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 = "hoge:";
|
||||
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://///hoge";
|
||||
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://hoge.com/";
|
||||
exp = "hoge.com/";
|
||||
assertEquals(exp, transformer.getSite(url, "UTF-8"));
|
||||
|
||||
url = "http://hoge.com/index.html";
|
||||
exp = "hoge.com/index.html";
|
||||
assertEquals(exp, transformer.getSite(url, "UTF-8"));
|
||||
|
||||
url = "file:/home/taro";
|
||||
exp = "/home/taro";
|
||||
assertEquals(exp, transformer.getSite(url, "UTF-8"));
|
||||
|
||||
url = "file:/c:/home/taro";
|
||||
exp = "c:\\home\\taro";
|
||||
assertEquals(exp, transformer.getSite(url, "UTF-8"));
|
||||
|
||||
url = "file:/c:/";
|
||||
exp = "c:\\";
|
||||
assertEquals(exp, transformer.getSite(url, "UTF-8"));
|
||||
|
||||
url = "file:////server/taro";
|
||||
exp = "\\\\server\\taro";
|
||||
assertEquals(exp, transformer.getSite(url, "UTF-8"));
|
||||
|
||||
transformer.maxSiteLength = 10;
|
||||
|
||||
url = "file:/home/taro/hanako";
|
||||
exp = "/home/t...";
|
||||
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"));
|
||||
}
|
||||
}
|
|
@ -1,298 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.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.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.codelibs.robot.builder.RequestDataBuilder;
|
||||
import org.codelibs.robot.client.fs.ChildUrlsException;
|
||||
import org.codelibs.robot.entity.RequestData;
|
||||
import org.codelibs.robot.entity.ResponseData;
|
||||
import org.cyberneko.html.parsers.DOMParser;
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
import org.seasar.framework.container.ComponentNotFoundRuntimeException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
public class FessXpathTransformerTest extends S2TestCase {
|
||||
public FessXpathTransformer fessXpathTransformer;
|
||||
|
||||
@Override
|
||||
protected String getRootDicon() throws Throwable {
|
||||
return "s2robot_transformer.dicon";
|
||||
}
|
||||
|
||||
public void test_pruneNode() throws Exception {
|
||||
final String data = "<html><body><br/><script>hoge</script><noscript>fuga</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>hoge</script><noscript>fuga</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("hoge"));
|
||||
assertTrue(docString.contains("<NOSCRIPT>"));
|
||||
assertTrue(docString.contains("fuga"));
|
||||
assertTrue(pnString.contains("<SCRIPT>"));
|
||||
assertTrue(pnString.contains("hoge"));
|
||||
assertFalse(pnString.contains("<NOSCRIPT>"));
|
||||
assertFalse(pnString.contains("fuga"));
|
||||
}
|
||||
|
||||
public void test_pruneNode_removeScriptAndNoscript() throws Exception {
|
||||
final String data = "<html><body><br/><script>hoge</script><noscript>fuga</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("hoge"));
|
||||
assertTrue(docString.contains("<NOSCRIPT>"));
|
||||
assertTrue(docString.contains("fuga"));
|
||||
assertFalse(pnString.contains("<SCRIPT>"));
|
||||
assertFalse(pnString.contains("hoge"));
|
||||
assertFalse(pnString.contains("<NOSCRIPT>"));
|
||||
assertFalse(pnString.contains("fuga"));
|
||||
}
|
||||
|
||||
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 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 = "hoge.html";
|
||||
assertTrue(fessXpathTransformer.isValidPath(value));
|
||||
|
||||
value = "./hoge.html";
|
||||
assertTrue(fessXpathTransformer.isValidPath(value));
|
||||
|
||||
value = "/hoge.html";
|
||||
assertTrue(fessXpathTransformer.isValidPath(value));
|
||||
|
||||
value = "http://www.seasar.org/hoge.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<!-- hoge -->"));
|
||||
assertEquals("abc 123", fessXpathTransformer.removeCommentTag("abc<!-- ho\nge -->123"));
|
||||
assertEquals("abc 123", fessXpathTransformer.removeCommentTag("abc<!--\n hoge -->123"));
|
||||
assertEquals("abc 123", fessXpathTransformer.removeCommentTag("abc<!-- hoge -->123"));
|
||||
assertEquals("abc 123 ", fessXpathTransformer.removeCommentTag("abc<!-- hoge1 -->123<!-- hoge2 -->"));
|
||||
assertEquals("abc 123 xyz", fessXpathTransformer.removeCommentTag("abc<!-- hoge1 -->123<!-- hoge2 -->xyz"));
|
||||
assertEquals("abc ", fessXpathTransformer.removeCommentTag("abc<!---->"));
|
||||
assertEquals("abc -->", fessXpathTransformer.removeCommentTag("abc<!-- hoge-->-->"));
|
||||
assertEquals("abc<!-- hoge", fessXpathTransformer.removeCommentTag("abc<!-- hoge"));
|
||||
assertEquals("abc -->123", fessXpathTransformer.removeCommentTag("abc<!-- <!-- hoge --> -->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 ComponentNotFoundRuntimeException 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 ComponentNotFoundRuntimeException e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
data = "<html><head><link rel=\"canonical\" href=\"http://example.com/hoge\"></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/hoge", childUrlList.iterator().next().getUrl());
|
||||
}
|
||||
|
||||
data = "<html><link rel=\"canonical\" href=\"http://example.com/hoge\"><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/hoge", 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);
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.unit;
|
||||
|
||||
import org.dbflute.utflute.lastadi.ContainerTestCase;
|
||||
|
||||
/**
|
||||
* Use like this:
|
||||
* <pre>
|
||||
* YourTest extends {@link UnitFessTestCase} {
|
||||
*
|
||||
* public void test_yourMethod() {
|
||||
* <span style="color: #3F7E5E">// ## Arrange ##</span>
|
||||
* YourAction action = new YourAction();
|
||||
* <span style="color: #FD4747">inject</span>(action);
|
||||
*
|
||||
* <span style="color: #3F7E5E">// ## Act ##</span>
|
||||
* action.submit();
|
||||
*
|
||||
* <span style="color: #3F7E5E">// ## Assert ##</span>
|
||||
* assertTrue(action...);
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* @author jflute
|
||||
*/
|
||||
public abstract class UnitFessTestCase extends ContainerTestCase {
|
||||
}
|
|
@ -1,167 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class ParameterUtilTest extends S2TestCase {
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,207 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class QueryResponseListTest extends S2TestCase {
|
||||
public void test_calculatePageInfo_page0() {
|
||||
QueryResponseList qrList;
|
||||
|
||||
qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
|
||||
qrList.calculatePageInfo(0, 20, 0);
|
||||
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.calculatePageInfo(0, 20, 10);
|
||||
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.calculatePageInfo(0, 20, 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.calculatePageInfo(0, 20, 21);
|
||||
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.calculatePageInfo(0, 20, 40);
|
||||
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.calculatePageInfo(0, 20, 41);
|
||||
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.calculatePageInfo(20, 20, 21);
|
||||
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.calculatePageInfo(20, 20, 40);
|
||||
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.calculatePageInfo(20, 20, 41);
|
||||
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.calculatePageInfo(20, 20, 61);
|
||||
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.calculatePageInfo(0, 20, 20);
|
||||
pnList = qrList.getPageNumberList();
|
||||
assertEquals(1, pnList.size());
|
||||
assertEquals("1", pnList.get(0));
|
||||
|
||||
qrList = new QueryResponseList(new ArrayList<Map<String, Object>>());
|
||||
qrList.calculatePageInfo(0, 20, 61);
|
||||
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.calculatePageInfo(0, 20, 200);
|
||||
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.calculatePageInfo(20, 20, 21);
|
||||
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.calculatePageInfo(20, 20, 61);
|
||||
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.calculatePageInfo(20, 20, 200);
|
||||
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));
|
||||
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class ResourceUtilTest extends S2TestCase {
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the 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.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class UriTypeChecksTest extends S2TestCase {
|
||||
public void test_check_ok() {
|
||||
String protocols;
|
||||
String values;
|
||||
|
||||
protocols = "http:";
|
||||
values = "http://www.hoge.com/";
|
||||
assertTrue(UriTypeChecks.check(protocols, values));
|
||||
|
||||
protocols = "http:";
|
||||
values = "http://www.hoge.com/\nhttp://www.fuga.com/";
|
||||
assertTrue(UriTypeChecks.check(protocols, values));
|
||||
|
||||
protocols = "http:";
|
||||
values = "http://www.hoge.com/ \r\nhttp://www.fuga.com/";
|
||||
assertTrue(UriTypeChecks.check(protocols, values));
|
||||
|
||||
protocols = "http:";
|
||||
values = "http://www.hoge.com/\nhttp://www.fuga.com/\n http://www.bar.com/";
|
||||
assertTrue(UriTypeChecks.check(protocols, values));
|
||||
|
||||
protocols = "http:,https:";
|
||||
values = "https://www.hoge.com/";
|
||||
assertTrue(UriTypeChecks.check(protocols, values));
|
||||
|
||||
protocols = "http:,https:";
|
||||
values = "http://www.hoge.com/\r\nhttp://www.fuga.com/";
|
||||
assertTrue(UriTypeChecks.check(protocols, values));
|
||||
|
||||
protocols = "http:,https:";
|
||||
values = "http://www.hoge.com/\nhttps://www.fuga.com/";
|
||||
assertTrue(UriTypeChecks.check(protocols, values));
|
||||
|
||||
protocols = "http:,https:";
|
||||
values = "http://www.hoge.com/\n \nhttps://www.fuga.com/";
|
||||
assertTrue(UriTypeChecks.check(protocols, values));
|
||||
|
||||
protocols = "http:, https:";
|
||||
values = "http://www.hoge.com/\nhttps://www.fuga.com/\n http://www.bar.com/";
|
||||
assertTrue(UriTypeChecks.check(protocols, values));
|
||||
}
|
||||
|
||||
public void test_check_ng() {
|
||||
String protocols;
|
||||
String values;
|
||||
|
||||
protocols = "http:";
|
||||
values = "https://www.hoge.com/";
|
||||
assertFalse(UriTypeChecks.check(protocols, values));
|
||||
|
||||
protocols = "http:";
|
||||
values = "https://www.hoge.com/\nhttps://www.fuga.com/";
|
||||
assertFalse(UriTypeChecks.check(protocols, values));
|
||||
|
||||
protocols = "http:";
|
||||
values = "https://www.hoge.com/\n \nhttps://www.fuga.com/";
|
||||
assertFalse(UriTypeChecks.check(protocols, values));
|
||||
|
||||
protocols = "http:";
|
||||
values = "https://www.hoge.com/\nhttps://www.fuga.com/\n https://www.bar.com/";
|
||||
assertFalse(UriTypeChecks.check(protocols, values));
|
||||
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
|
||||
"http://www.seasar.org/dtd/components24.dtd">
|
||||
<components>
|
||||
<include path="convention.dicon"/>
|
||||
<include path="aop.dicon"/>
|
||||
<include path="saflute.dicon"/>
|
||||
<include path="dbflute.dicon"/>
|
||||
|
||||
<include path="fess.dicon"/>
|
||||
|
||||
<include path="s2robot_db.dicon"/>
|
||||
|
||||
<!-- Web -->
|
||||
<component name="actionMessagesThrowsInterceptor" class="org.codelibs.fess.interceptor.FessActionMessagesThrowsInterceptor"/>
|
||||
|
||||
<component name="authenticationCipher" class="org.codelibs.core.crypto.CachedCipher">
|
||||
<property name="key">"1234567890123456"</property>
|
||||
</component>
|
||||
<component name="queryHelper" class="org.codelibs.fess.helper.QueryHelper">
|
||||
</component>
|
||||
<component name="roleQueryHelper" class="org.codelibs.fess.helper.impl.RoleQueryHelperImpl">
|
||||
<!-- ex. parameter: fessRoles=123%0aadmin -->
|
||||
<!--
|
||||
<property name="parameterKey">"fessRoles"</property>
|
||||
<property name="encryptedParameterValue">false</property>
|
||||
<property name="headerKey">"fessRoles"</property>
|
||||
<property name="encryptedHeaderValue">true</property>
|
||||
<property name="cookieKey">"fessRoles"</property>
|
||||
<property name="encryptedCookieValue">true</property>
|
||||
<property name="fessCipher">
|
||||
<component class="org.codelibs.core.crypto.CachedCipher">
|
||||
<property name="key">"1234567890123456"</property>
|
||||
</component>
|
||||
</property>
|
||||
<property name="defaultRoleList">
|
||||
{"guest"}
|
||||
</property>
|
||||
-->
|
||||
</component>
|
||||
<component name="viewHelper" class="org.codelibs.fess.helper.ViewHelper">
|
||||
<!--
|
||||
<property name="useDigest">true</property>
|
||||
<property name="useHighlightContent">true</property>
|
||||
-->
|
||||
</component>
|
||||
<component name="userAgentHelper" class="org.codelibs.fess.helper.UserAgentHelper">
|
||||
</component>
|
||||
<component name="userAgentName" class="java.lang.String">
|
||||
<arg>"Fess Robot/1.0"</arg>
|
||||
</component>
|
||||
|
||||
<!-- Cmd -->
|
||||
<component name="webFsIndexHelper" class="org.codelibs.fess.helper.WebFsIndexHelper">
|
||||
</component>
|
||||
<component name="crawlingConfigHelper" class="org.codelibs.fess.helper.CrawlingConfigHelper">
|
||||
</component>
|
||||
<component name="pathMappingHelper" class="org.codelibs.fess.helper.PathMappingHelper">
|
||||
</component>
|
||||
<component name="overlappingHostHelper" class="org.codelibs.fess.helper.OverlappingHostHelper">
|
||||
</component>
|
||||
<component name="intervalControlHelper" class="org.codelibs.fess.helper.IntervalControlHelper">
|
||||
</component>
|
||||
<component name="indexUpdater" class="org.codelibs.fess.solr.IndexUpdater" instance="prototype">
|
||||
<!--
|
||||
<property name="maxDocumentCacheSize">10</property>
|
||||
<property name="unprocessedDocumentSize">100</property>
|
||||
-->
|
||||
</component>
|
||||
<component name="fessCrawler" class="org.codelibs.fess.exec.Crawler" instance="prototype">
|
||||
</component>
|
||||
|
||||
</components>
|
Binary file not shown.
|
@ -1 +0,0 @@
|
|||
ut
|
|
@ -1,25 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
|
||||
"http://www.seasar.org/dtd/components24.dtd">
|
||||
<components>
|
||||
<include path="fess_es.dicon"/>
|
||||
|
||||
<component name="crawlerProperties" class="org.codelibs.core.misc.DynamicProperties">
|
||||
<arg>
|
||||
@org.seasar.framework.util.ResourceUtil@getBuildDir(@org.codelibs.fess.FessClass@class).getCanonicalPath()
|
||||
+ "/conf/crawler.properties"
|
||||
</arg>
|
||||
</component>
|
||||
|
||||
<component name="fieldHelper" class="org.codelibs.fess.helper.FieldHelper">
|
||||
</component>
|
||||
<component name="systemHelper" class="org.codelibs.fess.helper.SystemHelper">
|
||||
<!--
|
||||
<property name="adminRole">"fess"</property>
|
||||
<property name="authenticatedRoles">"role1"</property>
|
||||
-->
|
||||
</component>
|
||||
<component name="crawlingSessionHelper" class="org.codelibs.fess.helper.CrawlingSessionHelper">
|
||||
</component>
|
||||
|
||||
</components>
|
|
@ -1,166 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN"
|
||||
"http://www.seasar.org/dtd/components21.dtd">
|
||||
<components namespace="jdbc">
|
||||
<include path="jta.dicon"/>
|
||||
|
||||
<!-- for HSQLDB -->
|
||||
<!--
|
||||
<component name="xaDataSource"
|
||||
class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
|
||||
<property name="driverClassName">
|
||||
"org.hsqldb.jdbcDriver"
|
||||
</property>
|
||||
<property name="URL">
|
||||
"jdbc:hsqldb:file:"
|
||||
+ @org.seasar.framework.util.ResourceUtil@getBuildDir('app.dicon').getCanonicalPath()
|
||||
+ "/data/test"
|
||||
</property>
|
||||
<property name="user">"sa"</property>
|
||||
<property name="password">""</property>
|
||||
</component>
|
||||
-->
|
||||
|
||||
<!-- for H2 -->
|
||||
<component name="xaDataSource"
|
||||
class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
|
||||
<property name="driverClassName">
|
||||
"org.h2.Driver"
|
||||
</property>
|
||||
<property name="URL">
|
||||
"jdbc:h2:file:"
|
||||
+ @org.seasar.framework.util.ResourceUtil@getBuildDir(@org.codelibs.fess.FessClass@class).getCanonicalPath()
|
||||
+ "../../../src/main/h2/webapp/WEB-INF/db/fess;DB_CLOSE_ON_EXIT=FALSE;LOG=2;MVCC=true"
|
||||
</property>
|
||||
<property name="user">"sa"</property>
|
||||
<property name="password"></property>
|
||||
</component>
|
||||
|
||||
<!-- for Oracle -->
|
||||
<!--
|
||||
<component name="xaDataSource"
|
||||
class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
|
||||
<property name="driverClassName">
|
||||
"oracle.jdbc.driver.OracleDriver"
|
||||
</property>
|
||||
<property name="URL">
|
||||
"jdbc:oracle:thin:@xxx:1521:xxx"
|
||||
</property>
|
||||
<property name="user">"xxx"</property>
|
||||
<property name="password">"xxx"</property>
|
||||
</component>
|
||||
-->
|
||||
|
||||
<!-- for DB2 -->
|
||||
<!--
|
||||
<component name="xaDataSource"
|
||||
class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
|
||||
<property name="driverClassName">
|
||||
"com.ibm.db2.jcc.DB2Driver"
|
||||
</property>
|
||||
<property name="URL">
|
||||
"jdbc:db2://foo.bar.com:50000/SAMPLE"
|
||||
</property>
|
||||
<property name="user">"db2user"</property>
|
||||
<property name="password">"db2password"</property>
|
||||
<initMethod name="addProperty">
|
||||
<arg>"currentSchema"</arg>
|
||||
<arg>"SCHEMA"</arg>
|
||||
</initMethod>
|
||||
</component>
|
||||
-->
|
||||
|
||||
<!-- for PostgreSQL -->
|
||||
<!--
|
||||
<component name="xaDataSource"
|
||||
class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
|
||||
<property name="driverClassName">
|
||||
"org.postgresql.Driver"
|
||||
</property>
|
||||
<property name="URL">
|
||||
"jdbc:postgresql://localhost/TEST"
|
||||
</property>
|
||||
<property name="user">"xxxx"</property>
|
||||
<property name="password">"xxxx"</property>
|
||||
</component>
|
||||
-->
|
||||
|
||||
<!-- MySQL
|
||||
- MySQL4.0以下でマルチバイト文字を扱う場合には,URL指定の後に,
|
||||
以下の接続パラメータを追加で指定してください.
|
||||
useUnicode=true
|
||||
characterEncoding=[MySQLのエンコーディングに対応した
|
||||
Javaのエンコーディング名]
|
||||
例:"jdbc:mysql://localhost:3306/test?useUnicode=true" +
|
||||
"&characterEncoding=Windows-31J"
|
||||
|
||||
- MySQL5.0以降で,エンコーディングがeucjpmsの列を扱う場合には,
|
||||
URL指定の後に,以下の接続パラメータを追加で指定してください.
|
||||
characterEncoding=UTF-8またはWindows-31J
|
||||
characterSetResults=UTF-8またはWindows-31J
|
||||
例:"jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8" +
|
||||
"&characterSetResults=UTF-8"
|
||||
この指定をしない場合,Java側でUCS-2⇔EUC_JP_Solarisの変換が
|
||||
行なわれるため,ユーザー定義外字などの一部の文字が化けます.
|
||||
この指定をすることで,MySQL側でeucjpms⇔ucs2⇔utf8(cp932)の
|
||||
変換が行なわれ,Java側でUCS-2⇔UTF-8(Windows-31J)の変換が
|
||||
行なわれるようになります.この結果,文字化けを防げます.
|
||||
なおJIS X 0212(補助漢字)を使用する場合は,Windows-31Jではなく
|
||||
UTF-8を指定する必要があります.
|
||||
|
||||
- 上記以外の場合は,my.cnfでdefault-character-setの設定を適切に
|
||||
(cp932やutf8など.デフォルトのlatin1は不可)行なっていれば,
|
||||
文字化けは防げます.
|
||||
<component name="xaDataSource"
|
||||
class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
|
||||
<property name="driverClassName">
|
||||
"com.mysql.jdbc.Driver"
|
||||
</property>
|
||||
<property name="URL">
|
||||
"jdbc:mysql://localhost:3306/test"
|
||||
</property>
|
||||
<property name="user">"xxx"</property>
|
||||
<property name="password">"xxx"</property>
|
||||
</component>
|
||||
-->
|
||||
|
||||
<!-- for SQLServer -->
|
||||
<!--
|
||||
<component name="xaDataSource"
|
||||
class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
|
||||
<property name="driverClassName">
|
||||
"net.sourceforge.jtds.jdbc.Driver"
|
||||
</property>
|
||||
<property name="URL">
|
||||
"jdbc:jtds:sqlserver://localhost/TEST;instance=SQLEXPRESS"
|
||||
</property>
|
||||
<property name="user">"xxxx"</property>
|
||||
<property name="password">"xxxx"</property>
|
||||
</component>
|
||||
-->
|
||||
|
||||
<component name="connectionPool"
|
||||
class="org.seasar.extension.dbcp.impl.ConnectionPoolImpl">
|
||||
<property name="timeout">600</property>
|
||||
<property name="maxPoolSize">10</property>
|
||||
<property name="allowLocalTx">true</property>
|
||||
<destroyMethod name="close"/>
|
||||
</component>
|
||||
|
||||
<component name="DataSource"
|
||||
class="org.seasar.extension.dbcp.impl.DataSourceImpl"
|
||||
/>
|
||||
|
||||
<!-- from JNDI -->
|
||||
<!--
|
||||
<component name="DataSource"
|
||||
class="javax.sql.DataSource">
|
||||
@org.seasar.extension.j2ee.JndiResourceLocator@lookup("java:comp/env/jdbc/DataSource")
|
||||
</component>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<component name="dataSource"
|
||||
class="org.seasar.extension.datasource.impl.SelectableDataSourceProxy"/>
|
||||
-->
|
||||
</components>
|
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
||||
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
|
||||
<param name="Target" value="System.out"/>
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
<root>
|
||||
<priority value="debug"/>
|
||||
<appender-ref ref="stdout"/>
|
||||
</root>
|
||||
</log4j:configuration>
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
|
||||
"http://www.seasar.org/dtd/components24.dtd">
|
||||
<components>
|
||||
<include path="aop.dicon"/>
|
||||
<include path="dbflute.dicon"/>
|
||||
<component name="intervalControlHelper" class="org.codelibs.fess.helper.IntervalControlHelper">
|
||||
</component>
|
||||
</components>
|
|
@ -1,27 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
|
||||
"http://www.seasar.org/dtd/components24.dtd">
|
||||
<components>
|
||||
<include path="aop.dicon"/>
|
||||
<include path="saflute.dicon"/>
|
||||
<include path="dbflute.dicon"/>
|
||||
<include path="fess_es.dicon"/>
|
||||
<component name="overlappingHostHelper" class="org.codelibs.fess.helper.OverlappingHostHelper">
|
||||
<initMethod name="add">
|
||||
<arg>
|
||||
<component class="org.codelibs.fess.es.exentity.OverlappingHost">
|
||||
<property name="regularName">"www.hoge.com"</property>
|
||||
<property name="overlappingName">"hoge.com"</property>
|
||||
</component>
|
||||
</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>
|
||||
<component class="org.codelibs.fess.es.exentity.OverlappingHost">
|
||||
<property name="regularName">"www.fuga.com"</property>
|
||||
<property name="overlappingName">"mail.fuga.com"</property>
|
||||
</component>
|
||||
</arg>
|
||||
</initMethod>
|
||||
</component>
|
||||
</components>
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
|
||||
"http://www.seasar.org/dtd/components24.dtd">
|
||||
<components>
|
||||
<include path="aop.dicon"/>
|
||||
<include path="dbflute.dicon"/>
|
||||
<component name="pathMappingHelper" class="org.codelibs.fess.helper.PathMappingHelper">
|
||||
</component>
|
||||
</components>
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
|
||||
"http://www.seasar.org/dtd/components24.dtd">
|
||||
<components>
|
||||
<component name="fieldHelper" class="org.codelibs.fess.helper.FieldHelper">
|
||||
</component>
|
||||
<component name="systemHelper" class="org.codelibs.fess.helper.SystemHelper">
|
||||
</component>
|
||||
<component name="queryHelper" class="org.codelibs.fess.helper.QueryHelper">
|
||||
</component>
|
||||
|
||||
<component name="cipher" class="org.codelibs.core.crypto.CachedCipher">
|
||||
<property name="key">"1234567890123456"</property>
|
||||
</component>
|
||||
|
||||
</components>
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
|
||||
"http://www.seasar.org/dtd/components24.dtd">
|
||||
<components>
|
||||
<component name="fieldHelper" class="org.codelibs.fess.helper.FieldHelper">
|
||||
</component>
|
||||
<component name="systemHelper" class="org.codelibs.fess.helper.SystemHelper">
|
||||
</component>
|
||||
|
||||
</components>
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
|
||||
"http://www.seasar.org/dtd/components24.dtd">
|
||||
<components>
|
||||
<component name="viewHelper" class="org.codelibs.fess.helper.ViewHelper">
|
||||
</component>
|
||||
<component name="pathMappingHelper" class="org.codelibs.fess.helper.PathMappingHelper">
|
||||
</component>
|
||||
<component name="userAgentHelper" class="org.codelibs.fess.helper.UserAgentHelper">
|
||||
</component>
|
||||
<component name="crawlerProperties" class="org.codelibs.core.misc.DynamicProperties">
|
||||
<arg>
|
||||
@org.seasar.framework.util.ResourceUtil@getBuildDir(@org.codelibs.fess.FessClass@class).getCanonicalPath()
|
||||
+ "/conf/crawler.properties"
|
||||
</arg>
|
||||
</component>
|
||||
|
||||
</components>
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN"
|
||||
"http://www.seasar.org/dtd/components21.dtd">
|
||||
<components namespace="jdbc">
|
||||
<include path="jta.dicon"/>
|
||||
|
||||
<!-- for H2 -->
|
||||
<component name="xaDataSource"
|
||||
class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
|
||||
<property name="driverClassName">
|
||||
"org.h2.Driver"
|
||||
</property>
|
||||
<property name="URL">
|
||||
"jdbc:h2:file:"
|
||||
+ @org.seasar.framework.util.ResourceUtil@getBuildDir(@org.codelibs.fess.FessClass@class).getCanonicalPath()
|
||||
+ "db/robot;DB_CLOSE_ON_EXIT=FALSE"
|
||||
</property>
|
||||
<property name="user">"sa"</property>
|
||||
<property name="password"></property>
|
||||
</component>
|
||||
|
||||
<component name="connectionPool"
|
||||
class="org.seasar.extension.dbcp.impl.ConnectionPoolImpl">
|
||||
<property name="timeout">600</property>
|
||||
<property name="maxPoolSize">10</property>
|
||||
<property name="allowLocalTx">true</property>
|
||||
<destroyMethod name="close"/>
|
||||
</component>
|
||||
|
||||
<component name="DataSource"
|
||||
class="org.seasar.extension.dbcp.impl.DataSourceImpl"
|
||||
/>
|
||||
|
||||
</components>
|
Loading…
Add table
Reference in a new issue