Merge pull request #1687 from HasegawaTomofumi/test180605

update testcase
This commit is contained in:
Shinsuke Sugaya 2018-06-07 04:58:40 +09:00 committed by GitHub
commit d14505c4c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 362 additions and 0 deletions

View file

@ -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<Integer> pageNumberList = new ArrayList<Integer>(1);
accesstokenpager.setPageNumberList(pageNumberList);
assertEquals(pageNumberList, accesstokenpager.getPageNumberList());
assertEquals(1, accesstokenpager.getDefaultCurrentPageNumber());
assertEquals(25, accesstokenpager.getDefaultPageSize());
}
}

View file

@ -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<Integer> pageNumberList = new ArrayList<Integer>(1);
badwordpager.setPageNumberList(pageNumberList);
assertEquals(pageNumberList, badwordpager.getPageNumberList());
assertEquals(25, badwordpager.getDefaultPageSize());
}
}

View file

@ -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<Integer> pageNumberList = new ArrayList<Integer>(1);
boostdocpager.setPageNumberList(pageNumberList);
assertEquals(pageNumberList, boostdocpager.getPageNumberList());
assertEquals(1, boostdocpager.getDefaultCurrentPageNumber());
assertEquals(25, boostdocpager.getDefaultPageSize());
}
}

View file

@ -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<Integer> pageNumberList = new ArrayList<Integer>(1);
charmappingpager.setPageNumberList(pageNumberList);
assertEquals(pageNumberList, charmappingpager.getPageNumberList());
}
}

View file

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

View file

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

View file

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