diff --git a/src/test/java/org/codelibs/fess/app/pager/AccessTokenPagerTest.java b/src/test/java/org/codelibs/fess/app/pager/AccessTokenPagerTest.java new file mode 100644 index 000000000..9d2f2c552 --- /dev/null +++ b/src/test/java/org/codelibs/fess/app/pager/AccessTokenPagerTest.java @@ -0,0 +1,64 @@ +/* + * Copyright 2012-2018 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.app.pager; + +import java.util.ArrayList; +import java.util.List; + +import org.codelibs.fess.unit.UnitFessTestCase; + +public class AccessTokenPagerTest extends UnitFessTestCase { + + public void test_AccessTokenPager() { + AccessTokenPager accesstokenpager = new AccessTokenPager(); + + accesstokenpager.clear(); + assertEquals(0, accesstokenpager.getAllRecordCount()); + assertEquals(0, accesstokenpager.getAllPageCount()); + assertEquals(false, accesstokenpager.isExistPrePage()); + assertEquals(false, accesstokenpager.isExistNextPage()); + assertEquals(25, accesstokenpager.getPageSize()); + assertEquals(1, accesstokenpager.getCurrentPageNumber()); + assertNull(accesstokenpager.id); + assertNull(accesstokenpager.name); + assertNull(accesstokenpager.createdBy); + assertNull(accesstokenpager.createdTime); + assertNull(accesstokenpager.versionNo); + + accesstokenpager.setAllRecordCount(999); + assertEquals(999, accesstokenpager.getAllRecordCount()); + accesstokenpager.setAllPageCount(999); + assertEquals(999, accesstokenpager.getAllPageCount()); + accesstokenpager.setExistPrePage(true); + assertTrue(accesstokenpager.isExistPrePage()); + accesstokenpager.setExistNextPage(true); + assertTrue(accesstokenpager.isExistNextPage()); + accesstokenpager.setPageSize(0); + assertEquals(25, accesstokenpager.getPageSize()); + accesstokenpager.setPageSize(999); + assertEquals(999, accesstokenpager.getPageSize()); + accesstokenpager.setCurrentPageNumber(0); + assertEquals(1, accesstokenpager.getCurrentPageNumber()); + accesstokenpager.setCurrentPageNumber(999); + assertEquals(999, accesstokenpager.getCurrentPageNumber()); + List pageNumberList = new ArrayList(1); + accesstokenpager.setPageNumberList(pageNumberList); + assertEquals(pageNumberList, accesstokenpager.getPageNumberList()); + assertEquals(1, accesstokenpager.getDefaultCurrentPageNumber()); + assertEquals(25, accesstokenpager.getDefaultPageSize()); + + } +} \ No newline at end of file diff --git a/src/test/java/org/codelibs/fess/app/pager/BadWordPagerTest.java b/src/test/java/org/codelibs/fess/app/pager/BadWordPagerTest.java new file mode 100644 index 000000000..a29a5a022 --- /dev/null +++ b/src/test/java/org/codelibs/fess/app/pager/BadWordPagerTest.java @@ -0,0 +1,63 @@ +/* + * Copyright 2012-2018 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.app.pager; + +import java.util.ArrayList; +import java.util.List; + +import org.codelibs.fess.unit.UnitFessTestCase; + +public class BadWordPagerTest extends UnitFessTestCase { + + public void test_badWordPager() { + BadWordPager badwordpager = new BadWordPager(); + + badwordpager.clear(); + assertEquals(0, badwordpager.getAllRecordCount()); + assertEquals(0, badwordpager.getAllPageCount()); + assertEquals(false, badwordpager.isExistPrePage()); + assertEquals(false, badwordpager.isExistNextPage()); + assertEquals(25, badwordpager.getPageSize()); + assertEquals(1, badwordpager.getCurrentPageNumber()); + assertNull(badwordpager.id); + assertNull(badwordpager.suggestWord); + assertNull(badwordpager.createdBy); + assertNull(badwordpager.createdTime); + assertNull(badwordpager.versionNo); + + assertEquals(1, badwordpager.getDefaultCurrentPageNumber()); + badwordpager.setAllRecordCount(999); + assertEquals(999, badwordpager.getAllRecordCount()); + badwordpager.setAllPageCount(999); + assertEquals(999, badwordpager.getAllPageCount()); + badwordpager.setExistPrePage(true); + assertTrue(badwordpager.isExistPrePage()); + badwordpager.setExistNextPage(true); + assertTrue(badwordpager.isExistNextPage()); + badwordpager.setPageSize(0); + assertEquals(25, badwordpager.getPageSize()); + badwordpager.setPageSize(999); + assertEquals(999, badwordpager.getPageSize()); + badwordpager.setCurrentPageNumber(0); + assertEquals(1, badwordpager.getCurrentPageNumber()); + badwordpager.setCurrentPageNumber(999); + assertEquals(999, badwordpager.getCurrentPageNumber()); + List pageNumberList = new ArrayList(1); + badwordpager.setPageNumberList(pageNumberList); + assertEquals(pageNumberList, badwordpager.getPageNumberList()); + assertEquals(25, badwordpager.getDefaultPageSize()); + } +} \ No newline at end of file diff --git a/src/test/java/org/codelibs/fess/app/pager/BoostDocPagerTest.java b/src/test/java/org/codelibs/fess/app/pager/BoostDocPagerTest.java new file mode 100644 index 000000000..a8c8281a9 --- /dev/null +++ b/src/test/java/org/codelibs/fess/app/pager/BoostDocPagerTest.java @@ -0,0 +1,66 @@ +/* + * Copyright 2012-2018 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.app.pager; + +import java.util.ArrayList; +import java.util.List; + +import org.codelibs.fess.unit.UnitFessTestCase; + +public class BoostDocPagerTest extends UnitFessTestCase { + + public void test_BoostDocPage() { + BoostDocPager boostdocpager = new BoostDocPager(); + + boostdocpager.clear(); + assertEquals(0, boostdocpager.getAllRecordCount()); + assertEquals(0, boostdocpager.getAllPageCount()); + assertEquals(false, boostdocpager.isExistPrePage()); + assertEquals(false, boostdocpager.isExistNextPage()); + assertEquals(25, boostdocpager.getPageSize()); + assertEquals(1, boostdocpager.getCurrentPageNumber()); + assertNull(boostdocpager.id); + assertNull(boostdocpager.urlExpr); + assertNull(boostdocpager.boostExpr); + assertNull(boostdocpager.sortOrder); + assertNull(boostdocpager.createdBy); + assertNull(boostdocpager.createdTime); + assertNull(boostdocpager.versionNo); + + boostdocpager.setAllRecordCount(999); + assertEquals(999, boostdocpager.getAllRecordCount()); + boostdocpager.setAllPageCount(999); + assertEquals(999, boostdocpager.getAllPageCount()); + boostdocpager.setExistPrePage(true); + assertTrue(boostdocpager.isExistPrePage()); + boostdocpager.setExistNextPage(true); + assertTrue(boostdocpager.isExistNextPage()); + boostdocpager.setPageSize(0); + assertEquals(25, boostdocpager.getPageSize()); + boostdocpager.setPageSize(999); + assertEquals(999, boostdocpager.getPageSize()); + boostdocpager.setCurrentPageNumber(0); + assertEquals(1, boostdocpager.getCurrentPageNumber()); + boostdocpager.setCurrentPageNumber(999); + assertEquals(999, boostdocpager.getCurrentPageNumber()); + List pageNumberList = new ArrayList(1); + boostdocpager.setPageNumberList(pageNumberList); + assertEquals(pageNumberList, boostdocpager.getPageNumberList()); + assertEquals(1, boostdocpager.getDefaultCurrentPageNumber()); + assertEquals(25, boostdocpager.getDefaultPageSize()); + + } +} \ No newline at end of file diff --git a/src/test/java/org/codelibs/fess/app/pager/CharMappingPagerTest.java b/src/test/java/org/codelibs/fess/app/pager/CharMappingPagerTest.java new file mode 100644 index 000000000..1fc7b41e5 --- /dev/null +++ b/src/test/java/org/codelibs/fess/app/pager/CharMappingPagerTest.java @@ -0,0 +1,60 @@ +/* + * Copyright 2012-2018 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.app.pager; + +import java.util.ArrayList; +import java.util.List; + +import org.codelibs.fess.unit.UnitFessTestCase; + +public class CharMappingPagerTest extends UnitFessTestCase { + + public void test_CharMappingPagerTest() { + CharMappingPager charmappingpager = new CharMappingPager(); + + charmappingpager.clear(); + assertEquals(0, charmappingpager.getAllRecordCount()); + assertEquals(0, charmappingpager.getAllPageCount()); + assertEquals(false, charmappingpager.isExistPrePage()); + assertEquals(false, charmappingpager.isExistNextPage()); + assertEquals(25, charmappingpager.getPageSize()); + assertEquals(1, charmappingpager.getCurrentPageNumber()); + assertNull(charmappingpager.id); + + assertEquals(25, charmappingpager.getDefaultPageSize()); + assertEquals(1, charmappingpager.getDefaultCurrentPageNumber()); + + charmappingpager.setAllRecordCount(999); + assertEquals(999, charmappingpager.getAllRecordCount()); + charmappingpager.setAllPageCount(999); + assertEquals(999, charmappingpager.getAllRecordCount()); + charmappingpager.setExistPrePage(true); + assertTrue(charmappingpager.isExistPrePage()); + charmappingpager.setExistNextPage(true); + assertTrue(charmappingpager.isExistNextPage()); + charmappingpager.setPageSize(0); + assertEquals(25, charmappingpager.getPageSize()); + charmappingpager.setPageSize(999); + assertEquals(999, charmappingpager.getPageSize()); + charmappingpager.setCurrentPageNumber(0); + assertEquals(1, charmappingpager.getCurrentPageNumber()); + charmappingpager.setCurrentPageNumber(999); + assertEquals(999, charmappingpager.getCurrentPageNumber()); + List pageNumberList = new ArrayList(1); + charmappingpager.setPageNumberList(pageNumberList); + assertEquals(pageNumberList, charmappingpager.getPageNumberList()); + } +} \ No newline at end of file diff --git a/src/test/java/org/codelibs/fess/util/MemoryUtilTest.java b/src/test/java/org/codelibs/fess/util/MemoryUtilTest.java new file mode 100644 index 000000000..226b4bb2a --- /dev/null +++ b/src/test/java/org/codelibs/fess/util/MemoryUtilTest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2012-2018 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.util; + +import org.codelibs.fess.unit.UnitFessTestCase; + +public class MemoryUtilTest extends UnitFessTestCase { + + public void test_getUsedMemory() { + assertTrue(MemoryUtil.getUsedMemory() >= 0); + } + +} \ No newline at end of file diff --git a/src/test/java/org/codelibs/fess/util/PrunedTagTest.java b/src/test/java/org/codelibs/fess/util/PrunedTagTest.java new file mode 100644 index 000000000..940a5bee6 --- /dev/null +++ b/src/test/java/org/codelibs/fess/util/PrunedTagTest.java @@ -0,0 +1,49 @@ +/* + * Copyright 2012-2018 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.util; + +import org.codelibs.fess.unit.UnitFessTestCase; + +public class PrunedTagTest extends UnitFessTestCase { + + public void test_hashCode() { + PrunedTag prunedtag = new PrunedTag("tag"); + + assertTrue(prunedtag.hashCode() >= 0); + + } + + public void test_equals() { + + PrunedTag prunedtag = new PrunedTag("tag"); + + assertTrue(prunedtag.equals(prunedtag)); + assertEquals(false, prunedtag.equals(null)); + assertEquals(false, prunedtag.equals("")); + + } + + public void test_toString() { + String tag = "tag", id = "id", css = "css", attrName = "attrName", attrValue = "attrValue"; + PrunedTag prunedtag = new PrunedTag(tag); + prunedtag.setAttr(attrName, attrValue); + prunedtag.setId(id); + prunedtag.setCss(css); + assertEquals("PrunedTag [tag=" + tag + ", id=" + id + ", css=" + css + ", attrName=" + attrName + ", attrValue=" + attrValue + "]", + prunedtag.toString()); + + } +} \ No newline at end of file diff --git a/src/test/java/org/codelibs/fess/util/RenderDataUtilTest.java b/src/test/java/org/codelibs/fess/util/RenderDataUtilTest.java new file mode 100644 index 000000000..706bee314 --- /dev/null +++ b/src/test/java/org/codelibs/fess/util/RenderDataUtilTest.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012-2018 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.util; + +import org.codelibs.fess.unit.UnitFessTestCase; +import org.lastaflute.web.response.render.RenderData; + +public class RenderDataUtilTest extends UnitFessTestCase { + + public void test_register() { + RenderData data = new RenderData(); + + RenderDataUtil.register(data, "key1", null); + assertNull(data.getDataMap().get("key1")); + + RenderDataUtil.register(data, "key5", ""); + assertEquals(data.getDataMap().get("key5"), ""); + + } + +}