diff --git a/opengrok-web/src/test/java/org/opengrok/web/CookieFilterTest.java b/opengrok-web/src/test/java/org/opengrok/web/CookieFilterTest.java index b3f82c1bb15..7befd83ea4b 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/CookieFilterTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/CookieFilterTest.java @@ -232,7 +232,7 @@ public Locale getLocale() { } @Test - public void testNoHeaders() throws IOException, ServletException { + void testNoHeaders() throws IOException, ServletException { CookieFilter filter = new CookieFilter(); HttpServletRequest request = mock(HttpServletRequest.class); HttpServletResponse response = new DummyHttpServletResponse(); @@ -246,7 +246,7 @@ public void testNoHeaders() throws IOException, ServletException { } @Test - public void doTest() throws IOException, ServletException { + void doTest() throws IOException, ServletException { CookieFilter filter = new CookieFilter(); HttpServletRequest request = mock(HttpServletRequest.class); HttpServletResponse response = new DummyHttpServletResponse(); diff --git a/opengrok-web/src/test/java/org/opengrok/web/CorsFilterTest.java b/opengrok-web/src/test/java/org/opengrok/web/CorsFilterTest.java index 5f90e8a6a81..422a2a44414 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/CorsFilterTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/CorsFilterTest.java @@ -37,14 +37,14 @@ import static org.opengrok.web.api.v1.filter.CorsFilter.ALLOW_CORS_HEADER; import static org.opengrok.web.api.v1.filter.CorsFilter.CORS_REQUEST_HEADER; -public class CorsFilterTest { +class CorsFilterTest { @Test - public void nonCorsTest() { + void nonCorsTest() { testBoth(null, null); } @Test - public void corsTest() { + void corsTest() { testBoth("https://example.org", List.of("*")); } diff --git a/opengrok-web/src/test/java/org/opengrok/web/DirectoryListingTest.java b/opengrok-web/src/test/java/org/opengrok/web/DirectoryListingTest.java index 6d87dfc7c17..7b343f077e2 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/DirectoryListingTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/DirectoryListingTest.java @@ -209,7 +209,7 @@ public int compareTo(FileEntry fe) { * Set up the test environment with repositories. */ @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { repositories = new TestRepository(); repositories.create(getClass().getResource("/repositories")); @@ -233,7 +233,7 @@ public void setUp() throws Exception { * Clean up after the test. Remove the test repositories. */ @AfterEach - public void tearDown() { + void tearDown() { repositories.destroy(); repositories = null; diff --git a/opengrok-web/src/test/java/org/opengrok/web/PageConfigRequestedProjectsTest.java b/opengrok-web/src/test/java/org/opengrok/web/PageConfigRequestedProjectsTest.java index d59bb8c68c4..4e86b5ae937 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/PageConfigRequestedProjectsTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/PageConfigRequestedProjectsTest.java @@ -42,7 +42,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class PageConfigRequestedProjectsTest { +class PageConfigRequestedProjectsTest { final RuntimeEnvironment env = RuntimeEnvironment.getInstance(); @@ -51,7 +51,7 @@ public class PageConfigRequestedProjectsTest { private AuthorizationStack oldPluginStack; @BeforeEach - public void setUp() { + void setUp() { oldProjects = env.getProjects(); oldGroups = env.getGroups(); oldPluginStack = env.getPluginStack(); @@ -88,14 +88,14 @@ public void setUp() { } @AfterEach - public void tearDown() { + void tearDown() { env.setProjects(oldProjects); env.setGroups(oldGroups); env.setPluginStack(oldPluginStack); } @Test - public void testSingleProject() { + void testSingleProject() { final HttpServletRequest request = createRequest(new String[]{"project-1"}, null); final PageConfig cfg = PageConfig.get(request); @@ -103,7 +103,7 @@ public void testSingleProject() { } @Test - public void testMultipleProject() { + void testMultipleProject() { final HttpServletRequest request = createRequest(new String[]{"project-1", "project-3", "project-6"}, null); final PageConfig cfg = PageConfig.get(request); @@ -111,7 +111,7 @@ public void testMultipleProject() { } @Test - public void testNonIndexedProject() { + void testNonIndexedProject() { env.getProjects().get("project-1").setIndexed(false); final HttpServletRequest request = createRequest(new String[]{"project-1"}, null); @@ -122,7 +122,7 @@ public void testNonIndexedProject() { } @Test - public void testMultipleWithNonIndexedProject() { + void testMultipleWithNonIndexedProject() { env.getProjects().get("project-1").setIndexed(false); final HttpServletRequest request = createRequest(new String[]{"project-1", "project-3", "project-6"}, null); @@ -133,7 +133,7 @@ public void testMultipleWithNonIndexedProject() { } @Test - public void testSingleGroup1() { + void testSingleGroup1() { final HttpServletRequest request = createRequest(null, new String[]{"group-1-2-3"}); final PageConfig cfg = PageConfig.get(request); @@ -141,7 +141,7 @@ public void testSingleGroup1() { } @Test - public void testSingleGroup2() { + void testSingleGroup2() { final HttpServletRequest request = createRequest(null, new String[]{"group-7-8-9"}); final PageConfig cfg = PageConfig.get(request); @@ -149,7 +149,7 @@ public void testSingleGroup2() { } @Test - public void testMultipleGroup() { + void testMultipleGroup() { final HttpServletRequest request = createRequest(null, new String[]{"group-1-2-3", "group-7-8-9"}); final PageConfig cfg = PageConfig.get(request); @@ -159,7 +159,7 @@ public void testMultipleGroup() { } @Test - public void testMixedGroupAndProjectAddingNewProjects() { + void testMixedGroupAndProjectAddingNewProjects() { final HttpServletRequest request = createRequest(new String[]{"project-1", "project-6"}, new String[]{"group-7-8-9"}); final PageConfig cfg = PageConfig.get(request); @@ -170,7 +170,7 @@ public void testMixedGroupAndProjectAddingNewProjects() { @Test - public void testMixedGroupNonExistentGroupAndProjectAddingNewProjects() { + void testMixedGroupNonExistentGroupAndProjectAddingNewProjects() { final HttpServletRequest request = createRequest(new String[]{"project-1", "project-6"}, new String[]{"no-group", "group-7-8-9"}); final PageConfig cfg = PageConfig.get(request); @@ -180,7 +180,7 @@ public void testMixedGroupNonExistentGroupAndProjectAddingNewProjects() { } @Test - public void testMixedGroupAndProjectInclusion() { + void testMixedGroupAndProjectInclusion() { final HttpServletRequest request = createRequest(new String[]{"project-1", "project-2"}, new String[]{"group-1-2-3", "group-7-8-9"}); final PageConfig cfg = PageConfig.get(request); @@ -190,7 +190,7 @@ public void testMixedGroupAndProjectInclusion() { } @Test - public void testNonIndexedInGroup() { + void testNonIndexedInGroup() { env.getProjects().get("project-1").setIndexed(false); final HttpServletRequest request = createRequest(null, new String[]{"group-1-2-3"}); @@ -204,7 +204,7 @@ public void testNonIndexedInGroup() { * Assumes that there is no defaultProjects and no cookie set up. */ @Test - public void testNonExistentProject() { + void testNonExistentProject() { final HttpServletRequest request = createRequest(new String[]{"no-project"}, null); final PageConfig cfg = PageConfig.get(request); @@ -215,7 +215,7 @@ public void testNonExistentProject() { * Assumes that there is no defaultProjects and no cookie set up. */ @Test - public void testNonExistentGroup() { + void testNonExistentGroup() { final HttpServletRequest request = createRequest(null, new String[]{"no-group"}); final PageConfig cfg = PageConfig.get(request); @@ -223,7 +223,7 @@ public void testNonExistentGroup() { } @Test - public void testSelectAllProjects() { + void testSelectAllProjects() { final HttpServletRequest request = createRequest(null, null); Mockito.when(request.getParameter(QueryParameters.ALL_PROJECT_SEARCH)).thenReturn("true"); @@ -232,7 +232,7 @@ public void testSelectAllProjects() { } @Test - public void testSelectAllProjectsOverrideProjectParam() { + void testSelectAllProjectsOverrideProjectParam() { final HttpServletRequest request = createRequest(new String[]{"project-1", "project-2"}, null); Mockito.when(request.getParameter(QueryParameters.ALL_PROJECT_SEARCH)).thenReturn("true"); @@ -241,7 +241,7 @@ public void testSelectAllProjectsOverrideProjectParam() { } @Test - public void testSelectAllProjectsOverrideGroupParam() { + void testSelectAllProjectsOverrideGroupParam() { final HttpServletRequest request = createRequest(null, new String[]{"group-1-2-3"}); Mockito.when(request.getParameter(QueryParameters.ALL_PROJECT_SEARCH)).thenReturn("true"); @@ -250,7 +250,7 @@ public void testSelectAllProjectsOverrideGroupParam() { } @Test - public void testSelectAllOverrideNonExistentProject() { + void testSelectAllOverrideNonExistentProject() { final HttpServletRequest request = createRequest(new String[]{"no-project"}, null); Mockito.when(request.getParameter(QueryParameters.ALL_PROJECT_SEARCH)).thenReturn("true"); diff --git a/opengrok-web/src/test/java/org/opengrok/web/PageConfigTest.java b/opengrok-web/src/test/java/org/opengrok/web/PageConfigTest.java index 1699b449dce..90eb74af949 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/PageConfigTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/PageConfigTest.java @@ -69,7 +69,7 @@ /** * Unit tests for the {@code PageConfig} class. */ -public class PageConfigTest { +class PageConfigTest { private static final String HASH_BB74B7E8 = "bb74b7e849170c31dc1b1b5801c83bf0094a3b10"; private static final String HASH_AA35C258 = "aa35c25882b9a60a97758e0ceb276a3f8cb4ae3a"; private static TestRepository repository = new TestRepository(); diff --git a/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperExtendedTest.java b/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperExtendedTest.java index 1d867486c74..e5ff7bb0851 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperExtendedTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperExtendedTest.java @@ -39,7 +39,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public class ProjectHelperExtendedTest extends ProjectHelperTestBase { +class ProjectHelperExtendedTest extends ProjectHelperTestBase { @BeforeAll public static void setUpClass() { @@ -124,7 +124,7 @@ private Group getUnAllowedGroupWithoutSubgroups() { } @Test - public void testGetAllowedGroupSubgroups() { + void testGetAllowedGroupSubgroups() { Set<Group> result = helper.getSubgroups(getAllowedGroupWithSubgroups()); assertEquals(1, result.size()); for (Group p : result) { @@ -133,37 +133,37 @@ public void testGetAllowedGroupSubgroups() { } @Test - public void testGetUnAllowedGroupSubgroups() { + void testGetUnAllowedGroupSubgroups() { Set<Group> result = helper.getSubgroups(getUnAllowedGroupWithSubgroups()); assertEquals(0, result.size()); } @Test - public void testHasAllowedSubgroupAllowedSubgroups() { + void testHasAllowedSubgroupAllowedSubgroups() { Group g = getAllowedGroupWithSubgroups(); assertTrue(helper.hasAllowedSubgroup(g)); } @Test - public void testHasAllowedSubgroupUnAllowedSubgroups() { + void testHasAllowedSubgroupUnAllowedSubgroups() { Group g = getUnAllowedGroupWithSubgroups(); assertFalse(helper.hasAllowedSubgroup(g)); } @Test - public void testHasAllowedSubgroupAllowedNoSubgroups() { + void testHasAllowedSubgroupAllowedNoSubgroups() { Group g = getAllowedGroupWithoutSubgroups(); assertFalse(helper.hasAllowedSubgroup(g)); } @Test - public void testHasAllowedSubgroupUnAllowedNoSubgroups() { + void testHasAllowedSubgroupUnAllowedNoSubgroups() { Group g = getUnAllowedGroupWithoutSubgroups(); assertFalse(helper.hasAllowedSubgroup(g)); } @Test - public void testIsFavourite() { + void testIsFavourite() { setupPageConfigRequest("grouped_project_0_1," + "grouped_repository_2_2," + "allowed_grouped_repository_0_2," @@ -192,7 +192,7 @@ public void testIsFavourite() { } @Test - public void testHasUngroupedFavouritePositive() { + void testHasUngroupedFavouritePositive() { setupPageConfigRequest("grouped_project_0_1," + "grouped_repository_2_2," + "allowed_grouped_repository_0_2," @@ -204,7 +204,7 @@ public void testHasUngroupedFavouritePositive() { } @Test - public void testHasUngroupedFavouriteNegative() { + void testHasUngroupedFavouriteNegative() { setupPageConfigRequest("grouped_project_0_1," + "grouped_repository_2_2," + "allowed_grouped_repository_0_2," @@ -215,7 +215,7 @@ public void testHasUngroupedFavouriteNegative() { } @Test - public void testHasFavourite() { + void testHasFavourite() { String[] cookie = new String[] { "grouped_project_2_1", "allowed_grouped_project_2_1", diff --git a/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperTest.java b/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperTest.java index 7e80d268074..6338ac6c029 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperTest.java @@ -46,13 +46,13 @@ import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; -public class ProjectHelperTest extends ProjectHelperTestBase { +class ProjectHelperTest extends ProjectHelperTestBase { /** * Test of getInstance method, of class ProjectHelper. */ @Test - public void testGetInstance() { + void testGetInstance() { ProjectHelper result = ProjectHelper.getInstance(cfg); assertNotNull(result, "Project helper should not be null"); assertSame(result.getClass(), ProjectHelper.class); @@ -65,7 +65,7 @@ public void testGetInstance() { * updates the projects in the UI. */ @Test - public void testSynchronization() { + void testSynchronization() { HashMap<String, Project> oldProjects = new HashMap<>(env.getProjects()); List<RepositoryInfo> oldRepositories = new ArrayList<>(env.getRepositories()); Set<Group> oldGroups = new TreeSet<>(env.getGroups().values()); @@ -138,7 +138,7 @@ public void testSynchronization() { * Test of getRepositoryInfo method, of class ProjectHelper. */ @Test - public void testUnAllowedGetRepositoryInfo() { + void testUnAllowedGetRepositoryInfo() { Project p = new Project("repository_2_1"); p.setIndexed(true); List<RepositoryInfo> result = helper.getRepositoryInfo(p); @@ -149,7 +149,7 @@ public void testUnAllowedGetRepositoryInfo() { * Test of getRepositoryInfo method, of class ProjectHelper. */ @Test - public void testAllowedGetRepositoryInfo() { + void testAllowedGetRepositoryInfo() { Project p = new Project("allowed_grouped_repository_0_1"); p.setIndexed(true); List<RepositoryInfo> result = helper.getRepositoryInfo(p); @@ -161,7 +161,7 @@ public void testAllowedGetRepositoryInfo() { * Test of getGroups method, of class ProjectHelper. */ @Test - public void testGetAllowedGroups() { + void testGetAllowedGroups() { Set<Group> result = helper.getGroups(); assertEquals(2, result.size()); for (Group g : result) { @@ -173,7 +173,7 @@ public void testGetAllowedGroups() { * Test of getProjects method, of class ProjectHelper. */ @Test - public void testGetAllowedProjects() { + void testGetAllowedProjects() { Set<Project> result = helper.getProjects(); assertEquals(2, result.size()); for (Project p : result) { @@ -185,7 +185,7 @@ public void testGetAllowedProjects() { * Test of getRepositories method, of class ProjectHelper. */ @Test - public void testGetRepositories() { + void testGetRepositories() { Set<Project> result = helper.getRepositories(); assertEquals(2, result.size()); for (Project p : result) { @@ -197,7 +197,7 @@ public void testGetRepositories() { * Test of getProjects method, of class ProjectHelper. */ @Test - public void testGetProjectsAllowedGroup() { + void testGetProjectsAllowedGroup() { for (Group g : RuntimeEnvironment.getInstance().getGroups().values()) { if (g.getName().startsWith("allowed_group_0")) { Set<Project> result = helper.getProjects(g); @@ -214,7 +214,7 @@ public void testGetProjectsAllowedGroup() { * Test of getProjects method, of class ProjectHelper. */ @Test - public void testGetProjectsUnAllowedGroup() { + void testGetProjectsUnAllowedGroup() { for (Group g : RuntimeEnvironment.getInstance().getGroups().values()) { if (g.getName().startsWith("group_0")) { assertEquals(0, helper.getProjects(g).size()); @@ -228,7 +228,7 @@ public void testGetProjectsUnAllowedGroup() { * Test of getRepositories method, of class ProjectHelper. */ @Test - public void testGetRepositoriesAllowedGroup() { + void testGetRepositoriesAllowedGroup() { for (Group g : RuntimeEnvironment.getInstance().getGroups().values()) { if (g.getName().startsWith("allowed_group_0")) { Set<Project> result = helper.getRepositories(g); @@ -245,7 +245,7 @@ public void testGetRepositoriesAllowedGroup() { * Test of getRepositories method, of class ProjectHelper. */ @Test - public void testGetRepositoriesUnAllowedGroup() { + void testGetRepositoriesUnAllowedGroup() { for (Group g : RuntimeEnvironment.getInstance().getGroups().values()) { if (g.getName().startsWith("group_0")) { assertEquals(0, helper.getRepositories(g).size()); @@ -259,7 +259,7 @@ public void testGetRepositoriesUnAllowedGroup() { * Test of getGroupedProjects method, of class ProjectHelper. */ @Test - public void testGetGroupedProjects() { + void testGetGroupedProjects() { Set<Project> result = helper.getGroupedProjects(); assertEquals(4, result.size()); for (Project p : result) { @@ -271,7 +271,7 @@ public void testGetGroupedProjects() { * Test of getGroupedRepositories method, of class ProjectHelper. */ @Test - public void testGetGroupedRepositories() { + void testGetGroupedRepositories() { Set<Project> result = helper.getGroupedRepositories(); assertEquals(4, result.size()); for (Project p : result) { @@ -283,7 +283,7 @@ public void testGetGroupedRepositories() { * Test of getUngroupedProjects method, of class ProjectHelper. */ @Test - public void testGetUngroupedProjects() { + void testGetUngroupedProjects() { Set<Project> result = helper.getUngroupedProjects(); assertEquals(2, result.size()); for (Project p : result) { @@ -295,7 +295,7 @@ public void testGetUngroupedProjects() { * Test of getUngroupedRepositories method, of class ProjectHelper. */ @Test - public void testGetUngroupedRepositories() { + void testGetUngroupedRepositories() { Set<Project> result = helper.getUngroupedRepositories(); assertEquals(2, result.size()); for (Project p : result) { @@ -307,7 +307,7 @@ public void testGetUngroupedRepositories() { * Test of getAllGrouped method, of class ProjectHelper. */ @Test - public void testGetAllGrouped() { + void testGetAllGrouped() { Set<Project> result = helper.getAllGrouped(); assertEquals(8, result.size()); for (Project p : result) { @@ -319,7 +319,7 @@ public void testGetAllGrouped() { * Test of getAllGrouped method, of class ProjectHelper. */ @Test - public void testGetAllGroupedAllowedGroup() { + void testGetAllGroupedAllowedGroup() { for (Group g : RuntimeEnvironment.getInstance().getGroups().values()) { if (g.getName().startsWith("allowed_group_0")) { Set<Project> result = helper.getAllGrouped(g); @@ -333,7 +333,7 @@ public void testGetAllGroupedAllowedGroup() { } @Test - public void testGetAllGroupedUnAllowedGroup() { + void testGetAllGroupedUnAllowedGroup() { for (Group g : RuntimeEnvironment.getInstance().getGroups().values()) { if (g.getName().startsWith("group_0")) { assertEquals(0, helper.getAllGrouped(g).size()); @@ -346,7 +346,7 @@ public void testGetAllGroupedUnAllowedGroup() { * Test of getAllUngrouped method, of class ProjectHelper. */ @Test - public void testGetAllUngrouped() { + void testGetAllUngrouped() { Set<Project> result = helper.getAllUngrouped(); assertEquals(4, result.size()); for (Project p : result) { @@ -358,7 +358,7 @@ public void testGetAllUngrouped() { * Test of getAllProjects method, of class ProjectHelper. */ @Test - public void testGetAllProjects() { + void testGetAllProjects() { Set<Project> result = helper.getAllProjects(); assertEquals(12, result.size()); for (Project p : result) { diff --git a/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperTestBase.java b/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperTestBase.java index a7c9927a332..88e3af4c1b2 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperTestBase.java +++ b/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperTestBase.java @@ -47,7 +47,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class ProjectHelperTestBase { +class ProjectHelperTestBase { protected static Map<String, Group> groups; protected static Map<String, Project> projects; @@ -258,7 +258,7 @@ protected HttpServletRequest getRequest() { } @BeforeEach - public void setUp() { + void setUp() { assertEquals(4, env.getGroups().size(), "Should contain 4 groups"); assertEquals(40, env.getProjects().size(), "Should contain 40 project"); assertEquals(20, env.getRepositories().size(), "Should contain 20 repositories"); @@ -287,7 +287,7 @@ public boolean isAllowed(HttpServletRequest request, Group group) { } @AfterEach - public void tearDown() { + void tearDown() { env.getAuthorizationFramework().removeAll(); } } diff --git a/opengrok-web/src/test/java/org/opengrok/web/ScriptsTest.java b/opengrok-web/src/test/java/org/opengrok/web/ScriptsTest.java index 77c4e27174f..1d487a4af2e 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/ScriptsTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/ScriptsTest.java @@ -38,17 +38,17 @@ * * @author Krystof Tulinger */ -public class ScriptsTest { +class ScriptsTest { private Scripts scripts; @BeforeEach - public void setUp() { + void setUp() { scripts = new Scripts(); } @Test - public void testInstance() { + void testInstance() { scripts.addScript(new Scripts.FileScript("http://example.com/main1.js", 0)); scripts.addScript(new Scripts.FileScript("http://example.com/main2.js", 0)); scripts.addScript(new Scripts.FileScript("http://example.com/main3.js", 0)); @@ -67,7 +67,7 @@ public void testInstance() { } @Test - public void testSorted() { + void testSorted() { scripts.addScript(new Scripts.FileScript("http://example.com/main1.js", 3)); scripts.addScript(new Scripts.FileScript("http://example.com/main2.js", 1)); scripts.addScript(new Scripts.FileScript("http://example.com/main3.js", 2)); @@ -86,7 +86,7 @@ public void testSorted() { } @Test - public void testContent() { + void testContent() { scripts.addScript(new Scripts.FileScript("http://example.com/main1.js", 0)); scripts.addScript(new Scripts.FileScript("http://example.com/main2.js", 0)); scripts.addScript(new Scripts.FileScript("http://example.com/main3.js", 0)); @@ -108,7 +108,7 @@ public void testContent() { } @Test - public void testLookup() { + void testLookup() { scripts.addScript("", "utils", Scripts.Type.MINIFIED); scripts.addScript("", "jquery", Scripts.Type.MINIFIED); scripts.addScript("", "diff", Scripts.Type.MINIFIED); @@ -140,7 +140,7 @@ public void testLookup() { } @Test - public void testLookupWithContextPath() { + void testLookupWithContextPath() { String contextPath = "/source"; scripts.addScript(contextPath, "utils", Scripts.Type.MINIFIED); scripts.addScript(contextPath, "jquery", Scripts.Type.MINIFIED); @@ -173,13 +173,13 @@ public void testLookupWithContextPath() { } @Test - public void testAddMinified() { + void testAddMinified() { scripts.addScript("", "utils", Scripts.Type.MINIFIED); assertTrue(scripts.iterator().next().scriptData.endsWith("min.js")); } @Test - public void testAddDebug() { + void testAddDebug() { scripts.addScript("", "utils", Scripts.Type.DEBUG); assertFalse(scripts.iterator().next().scriptData.endsWith("min.js")); } diff --git a/opengrok-web/src/test/java/org/opengrok/web/api/ApiTaskTest.java b/opengrok-web/src/test/java/org/opengrok/web/api/ApiTaskTest.java index 85b77984c13..d807a050bf6 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/api/ApiTaskTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/api/ApiTaskTest.java @@ -56,7 +56,7 @@ private static class Task { value = 1; } - public void setValue(int value) { + void setValue(int value) { this.value = value; } diff --git a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/AnnotationControllerTest.java b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/AnnotationControllerTest.java index 28f12b6d87b..d2a18913c46 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/AnnotationControllerTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/AnnotationControllerTest.java @@ -50,7 +50,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -public class AnnotationControllerTest extends OGKJerseyTest { +class AnnotationControllerTest extends OGKJerseyTest { private static final String HASH_BB74B7E8 = "bb74b7e849170c31dc1b1b5801c83bf0094a3b10"; private static final String HASH_AA35C258 = "aa35c25882b9a60a97758e0ceb276a3f8cb4ae3a"; @@ -112,7 +112,7 @@ private static int getNumLines(File file) throws IOException { } @Test - public void testAnnotationAPI() throws IOException { + void testAnnotationAPI() throws IOException { final String path = "git/Makefile"; List<AnnotationController.AnnotationDTO> annotations = target("annotation") .queryParam("path", path) @@ -135,7 +135,7 @@ public void testAnnotationAPI() throws IOException { } @Test - public void testAnnotationAPIWithRevision() { + void testAnnotationAPIWithRevision() { final String path = "git/Makefile"; List<AnnotationController.AnnotationDTO> annotations = target("annotation") .queryParam("path", path) diff --git a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/DirectoryListingControllerTest.java b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/DirectoryListingControllerTest.java index 8d58c51e513..890fd91272a 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/DirectoryListingControllerTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/DirectoryListingControllerTest.java @@ -64,7 +64,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.opengrok.web.api.v1.controller.DirectoryListingController.getDirectoryEntriesDTO; -public class DirectoryListingControllerTest extends OGKJerseyTest { +class DirectoryListingControllerTest extends OGKJerseyTest { private final RuntimeEnvironment env = RuntimeEnvironment.getInstance(); private TestRepository repository; diff --git a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/MessagesControllerTest.java b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/MessagesControllerTest.java index 1368b1f15de..8f685a6f071 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/MessagesControllerTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/MessagesControllerTest.java @@ -64,7 +64,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public class MessagesControllerTest extends OGKJerseyTest { +class MessagesControllerTest extends OGKJerseyTest { private static final GenericType<List<AcceptedMessageModel>> messagesType = new GenericType<>() { }; @@ -92,8 +92,8 @@ protected void configureClient(ClientConfig config) { } // Allow entity body for DELETE method on the server side. - public static class CustomGrizzlyTestContainerFactory implements TestContainerFactory { - public CustomGrizzlyTestContainerFactory() { + static class CustomGrizzlyTestContainerFactory implements TestContainerFactory { + CustomGrizzlyTestContainerFactory() { } public TestContainer create(URI baseUri, DeploymentContext context) { @@ -149,13 +149,13 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc } @BeforeEach - public void setupMessageListener() throws Exception { + void setupMessageListener() throws Exception { setMessageContainer(env, new MessagesContainer()); env.startExpirationTimer(); } @AfterEach - public void tearDownMessageListener() { + void tearDownMessageListener() { env.stopExpirationTimer(); } @@ -166,7 +166,7 @@ private void setMessageContainer(RuntimeEnvironment env, MessagesContainer conta } @Test - public void addMessageTest() { + void addMessageTest() { addMessage("test message"); assertFalse(env.getMessages().isEmpty()); @@ -177,7 +177,7 @@ public void addMessageTest() { } @Test - public void addMessageWithInvalidLevel() throws JsonProcessingException { + void addMessageWithInvalidLevel() throws JsonProcessingException { // Construct correct Message object first. Message msg = new Message( "message with broken message level", @@ -217,7 +217,7 @@ private void addMessage(String text, String... tags) { } @Test - public void removeMessageTest() { + void removeMessageTest() { env.addMessage(new Message( "test", Collections.singleton(MessagesContainer.MESSAGES_MAIN_PAGE_TAG), @@ -249,7 +249,7 @@ private void removeMessages(final String tag, final String text) { } @Test - public void addAndRemoveTest() { + void addAndRemoveTest() { addMessage("test", "test"); addMessage("test", "test"); @@ -261,7 +261,7 @@ public void addAndRemoveTest() { } @Test - public void addAndRemoveWithTextTest() { + void addAndRemoveWithTextTest() { final String tag = "foo"; final String text = "text"; @@ -279,7 +279,7 @@ public void addAndRemoveWithTextTest() { } @Test - public void addAndRemoveDifferentTagsTest() { + void addAndRemoveDifferentTagsTest() { addMessage("test", "tag1"); addMessage("test", "tag2"); @@ -297,7 +297,7 @@ public void addAndRemoveDifferentTagsTest() { } @Test - public void addMessageNegativeDurationTest() throws Exception { + void addMessageNegativeDurationTest() throws Exception { Message m = new Message("text", Collections.singleton("test"), Message.MessageLevel.INFO, @@ -318,7 +318,7 @@ private void setDuration(final Message m, final Duration duration) throws Except } @Test - public void addEmptyMessageTest() throws Exception { + void addEmptyMessageTest() throws Exception { Message m = new Message("text", Collections.singleton("test"), Message.MessageLevel.INFO, @@ -339,7 +339,7 @@ private void setText(final Message m, final String text) throws Exception { } @Test - public void getAllMessagesTest() { + void getAllMessagesTest() { addMessage("text1", "info"); addMessage("text2", "main"); @@ -351,7 +351,7 @@ public void getAllMessagesTest() { } @Test - public void getSpecificMessageTest() { + void getSpecificMessageTest() { addMessage("text", "info"); List<AcceptedMessageModel> messages = target("messages") @@ -366,7 +366,7 @@ public void getSpecificMessageTest() { } @Test - public void multipleTagsTest() { + void multipleTagsTest() { addMessage("test", "info", "main"); List<AcceptedMessageModel> allMessages = target("messages") @@ -377,7 +377,7 @@ public void multipleTagsTest() { } @Test - public void multipleMessageAndTagsTest() { + void multipleMessageAndTagsTest() { addMessage("test1", "tag1", "tag2"); addMessage("test2", "tag3", "tag4"); diff --git a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/PortChecker.java b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/PortChecker.java index 846e146226b..9c118dba60c 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/PortChecker.java +++ b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/PortChecker.java @@ -27,7 +27,7 @@ * Represents a helper for checking a network port, borrowed from Apache * Usergrid's AvailablePortFinder.java. */ -public class PortChecker { +class PortChecker { /** The minimum number of server port number. */ public static final int MIN_PORT_NUMBER = 1; diff --git a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/RepositoriesControllerTest.java b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/RepositoriesControllerTest.java index f90a7987d2d..9cc839994e2 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/RepositoriesControllerTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/RepositoriesControllerTest.java @@ -47,7 +47,7 @@ import static org.opengrok.indexer.condition.RepositoryInstalled.Type.MERCURIAL; @EnabledForRepository(MERCURIAL) -public class RepositoriesControllerTest extends OGKJerseyTest { +class RepositoriesControllerTest extends OGKJerseyTest { private final RuntimeEnvironment env = RuntimeEnvironment.getInstance(); @@ -85,12 +85,12 @@ public void tearDown() throws Exception { } @Test - public void testGetRepositoryTypeOfNonExistentRepository() { + void testGetRepositoryTypeOfNonExistentRepository() { assertThrows(NotFoundException.class, () -> getRepoType(Paths.get("/totally-nonexistent-repository").toString())); } @Test - public void testGetRepositoryType() throws Exception { + void testGetRepositoryType() throws Exception { // Create sub-repository. File mercurialRoot = new File(repository.getSourceRoot() + File.separator + "mercurial"); MercurialRepositoryTest.runHgCommand(mercurialRoot, diff --git a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SearchControllerTest.java b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SearchControllerTest.java index 1f74ef5590d..f9a3bd3caa4 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SearchControllerTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SearchControllerTest.java @@ -43,7 +43,7 @@ import static org.opengrok.web.api.v1.filter.CorsFilter.ALLOW_CORS_HEADER; import static org.opengrok.web.api.v1.filter.CorsFilter.CORS_REQUEST_HEADER; -public class SearchControllerTest extends OGKJerseyTest { +class SearchControllerTest extends OGKJerseyTest { private static final RuntimeEnvironment env = RuntimeEnvironment.getInstance(); diff --git a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SuggesterControllerProjectsDisabledTest.java b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SuggesterControllerProjectsDisabledTest.java index 9b244ec698f..a70fcbebc51 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SuggesterControllerProjectsDisabledTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SuggesterControllerProjectsDisabledTest.java @@ -53,7 +53,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; -public class SuggesterControllerProjectsDisabledTest extends OGKJerseyTest { +class SuggesterControllerProjectsDisabledTest extends OGKJerseyTest { private static final RuntimeEnvironment env = RuntimeEnvironment.getInstance(); @@ -91,7 +91,7 @@ public static void tearDownClass() { } @BeforeEach - public void before() { + void before() { await().atMost(15, TimeUnit.SECONDS).until(() -> getSuggesterProjectDataSize() == 1); env.setSuggesterConfig(new SuggesterConfig()); diff --git a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SuggesterControllerTest.java b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SuggesterControllerTest.java index 574af6563d8..afcd82ee817 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SuggesterControllerTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SuggesterControllerTest.java @@ -66,7 +66,7 @@ import static org.opengrok.web.api.v1.filter.CorsFilter.CORS_REQUEST_HEADER; @TestMethodOrder(MethodOrderer.MethodName.class) -public class SuggesterControllerTest extends OGKJerseyTest { +class SuggesterControllerTest extends OGKJerseyTest { public static class Result { public long time; @@ -130,7 +130,7 @@ public static void tearDownClass() { } @BeforeEach - public void before() throws InterruptedException { + void before() throws InterruptedException { SuggesterServiceImpl.getInstance().waitForInit(15, TimeUnit.SECONDS); env.setSuggesterConfig(new SuggesterConfig()); diff --git a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SystemControllerTest.java b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SystemControllerTest.java index 785f9b8a3e8..5691dc075c8 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SystemControllerTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SystemControllerTest.java @@ -74,7 +74,7 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc * @throws IOException on error */ @Test - public void testIncludeReload() throws IOException { + void testIncludeReload() throws IOException { // Set new include root directory. Path includeRootPath = Files.createTempDirectory("systemControllerTest"); File includeRoot = includeRootPath.toFile(); @@ -115,7 +115,7 @@ public void testIncludeReload() throws IOException { } @Test - public void testDtagsEftarReload() throws IOException { + void testDtagsEftarReload() throws IOException { // The output file will be located in a directory under data root so create it first. Path dataRoot = Files.createTempDirectory("api_dtags_test"); env.setDataRoot(dataRoot.toString()); @@ -148,7 +148,7 @@ public void testDtagsEftarReload() throws IOException { } @Test - public void testIndexTime() throws IOException, ParseException { + void testIndexTime() throws IOException, ParseException { Path dataRoot = Files.createTempDirectory("indexTimetest"); env.setDataRoot(dataRoot.toString()); Path indexTimeFile = dataRoot.resolve("timestamp"); diff --git a/opengrok-web/src/test/java/org/opengrok/web/api/v1/filter/IncomingFilterTest.java b/opengrok-web/src/test/java/org/opengrok/web/api/v1/filter/IncomingFilterTest.java index 29137490344..56bc780fa8d 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/api/v1/filter/IncomingFilterTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/api/v1/filter/IncomingFilterTest.java @@ -47,14 +47,14 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class IncomingFilterTest { +class IncomingFilterTest { @BeforeEach - public void beforeTest() { + void beforeTest() { RuntimeEnvironment.getInstance().setAuthenticationTokens(new HashSet<>()); } @Test - public void nonLocalhostTestWithValidToken() throws Exception { + void nonLocalhostTestWithValidToken() throws Exception { String allowedToken = "foo"; Set<String> tokens = new HashSet<>(); @@ -65,7 +65,7 @@ public void nonLocalhostTestWithValidToken() throws Exception { } @Test - public void nonLocalhostTestWithInvalidToken() throws Exception { + void nonLocalhostTestWithInvalidToken() throws Exception { String allowedToken = "bar"; Set<String> tokens = new HashSet<>(); @@ -76,7 +76,7 @@ public void nonLocalhostTestWithInvalidToken() throws Exception { } @Test - public void nonLocalhostTestWithTokenChange() throws Exception { + void nonLocalhostTestWithTokenChange() throws Exception { RuntimeEnvironment env = RuntimeEnvironment.getInstance(); String token = "foobar"; @@ -128,7 +128,7 @@ private void nonLocalhostTestWithToken(boolean allowed, String token) throws Exc } @Test - public void localhostTestWithForwardedHeader() throws Exception { + void localhostTestWithForwardedHeader() throws Exception { Map<String, String> headers = new TreeMap<>(); headers.put("X-Forwarded-For", "192.0.2.43, 2001:db8:cafe::17"); IncomingFilter filter = mockWithRemoteAddress("127.0.0.1", headers, true); @@ -144,7 +144,7 @@ public void localhostTestWithForwardedHeader() throws Exception { } @Test - public void nonLocalhostTestWithoutToken() throws Exception { + void nonLocalhostTestWithoutToken() throws Exception { IncomingFilter filter = mockWithRemoteAddress("192.168.1.1"); ContainerRequestContext context = mockContainerRequestContext("test"); @@ -197,7 +197,7 @@ private ContainerRequestContext mockContainerRequestContext(final String path) { } @Test - public void localhostTest() throws Exception { + void localhostTest() throws Exception { assertFilterDoesNotBlockAddress("127.0.0.1", "test"); } @@ -214,22 +214,22 @@ private void assertFilterDoesNotBlockAddress(final String remoteAddr, final Stri } @Test - public void localhostIPv6Test() throws Exception { + void localhostIPv6Test() throws Exception { assertFilterDoesNotBlockAddress("0:0:0:0:0:0:0:1", "test"); } @Test - public void searchTest() throws Exception { + void searchTest() throws Exception { assertFilterDoesNotBlockAddress("10.0.0.1", "search"); } @Test - public void systemPingRemoteWithoutTokenTest() throws Exception { + void systemPingRemoteWithoutTokenTest() throws Exception { assertFilterDoesNotBlockAddress("10.0.0.1", "system/ping"); } @Test - public void systemPathDescWithoutTokenTest() throws Exception { + void systemPathDescWithoutTokenTest() throws Exception { IncomingFilter filter = mockWithRemoteAddress("192.168.1.1"); diff --git a/plugins/src/test/java/opengrok/auth/plugin/FalsePluginTest.java b/plugins/src/test/java/opengrok/auth/plugin/FalsePluginTest.java index f14d79bd919..cb24e9f8bf8 100644 --- a/plugins/src/test/java/opengrok/auth/plugin/FalsePluginTest.java +++ b/plugins/src/test/java/opengrok/auth/plugin/FalsePluginTest.java @@ -40,7 +40,7 @@ class FalsePluginTest { private FalsePlugin plugin; @BeforeEach - public void setUp() { + void setUp() { plugin = new FalsePlugin(); } diff --git a/plugins/src/test/java/opengrok/auth/plugin/LdapAttrPluginTest.java b/plugins/src/test/java/opengrok/auth/plugin/LdapAttrPluginTest.java index b2d1b1dee48..4203fb0a1fc 100644 --- a/plugins/src/test/java/opengrok/auth/plugin/LdapAttrPluginTest.java +++ b/plugins/src/test/java/opengrok/auth/plugin/LdapAttrPluginTest.java @@ -59,7 +59,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class LdapAttrPluginTest { +class LdapAttrPluginTest { private HttpServletRequest dummyRequest; private LdapAttrPlugin plugin; @@ -67,7 +67,7 @@ public class LdapAttrPluginTest { private static File whitelistFile; @BeforeAll - public static void beforeClass() throws IOException { + static void beforeClass() throws IOException { whitelistFile = Files.createTempFile("opengrok-auth-", "-check.tmp").toFile(); try (Writer w = new OutputStreamWriter(new FileOutputStream(whitelistFile))) { w.append("james@bond.com\n"); @@ -77,12 +77,12 @@ public static void beforeClass() throws IOException { } @AfterAll - public static void afterClass() { + static void afterClass() { whitelistFile.deleteOnExit(); } @BeforeEach - public void setUp() { + void setUp() { plugin = new LdapAttrPlugin(); Map<String, Object> parameters = new TreeMap<>(); diff --git a/plugins/src/test/java/opengrok/auth/plugin/LdapFilterPluginTest.java b/plugins/src/test/java/opengrok/auth/plugin/LdapFilterPluginTest.java index b64765a17cd..5ed094f4803 100644 --- a/plugins/src/test/java/opengrok/auth/plugin/LdapFilterPluginTest.java +++ b/plugins/src/test/java/opengrok/auth/plugin/LdapFilterPluginTest.java @@ -38,7 +38,7 @@ class LdapFilterPluginTest { private LdapFilterPlugin plugin; @BeforeEach - public void setUp() { + void setUp() { plugin = new LdapFilterPlugin(); } diff --git a/plugins/src/test/java/opengrok/auth/plugin/LdapUserPluginTest.java b/plugins/src/test/java/opengrok/auth/plugin/LdapUserPluginTest.java index 31b4340a06c..4cc7cabdc5e 100644 --- a/plugins/src/test/java/opengrok/auth/plugin/LdapUserPluginTest.java +++ b/plugins/src/test/java/opengrok/auth/plugin/LdapUserPluginTest.java @@ -65,7 +65,7 @@ class LdapUserPluginTest { private LdapUserPlugin plugin; @BeforeEach - public void setUp() { + void setUp() { plugin = new LdapUserPlugin(); } diff --git a/plugins/src/test/java/opengrok/auth/plugin/TruePluginTest.java b/plugins/src/test/java/opengrok/auth/plugin/TruePluginTest.java index 221a9beb94a..01d51c329ce 100644 --- a/plugins/src/test/java/opengrok/auth/plugin/TruePluginTest.java +++ b/plugins/src/test/java/opengrok/auth/plugin/TruePluginTest.java @@ -35,27 +35,27 @@ /** * Represents a container for tests of {@link TruePlugin}. */ -public class TruePluginTest { +class TruePluginTest { private TruePlugin plugin; @BeforeEach - public void setUp() { + void setUp() { plugin = new TruePlugin(); } @Test - public void shouldNotThrowOnLoadIfNullArgument() { + void shouldNotThrowOnLoadIfNullArgument() { plugin.load(null); } @Test - public void shouldUnload() { + void shouldUnload() { plugin.unload(); } @Test - public void shouldAllowRandomUserForAnyProject() { + void shouldAllowRandomUserForAnyProject() { DummyHttpServletRequest req = new DummyHttpServletRequest(); req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.randomAlphanumeric(8))); @@ -69,7 +69,7 @@ public void shouldAllowRandomUserForAnyProject() { } @Test - public void shouldAllowRandomUserForAnyGroup() { + void shouldAllowRandomUserForAnyGroup() { DummyHttpServletRequest req = new DummyHttpServletRequest(); req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.randomAlphanumeric(8))); diff --git a/plugins/src/test/java/opengrok/auth/plugin/UserPluginTest.java b/plugins/src/test/java/opengrok/auth/plugin/UserPluginTest.java index 298b2280a4f..3b4d0478057 100644 --- a/plugins/src/test/java/opengrok/auth/plugin/UserPluginTest.java +++ b/plugins/src/test/java/opengrok/auth/plugin/UserPluginTest.java @@ -40,17 +40,17 @@ * * @author Krystof Tulinger */ -public class UserPluginTest { +class UserPluginTest { private UserPlugin plugin; @BeforeEach - public void setUp() { + void setUp() { plugin = new UserPlugin(new OSSOHeaderDecoder()); } @Test - public void testNoUser() { + void testNoUser() { assertFalse(plugin.isAllowed(new DummyHttpServletRequestUser(), new Group())); assertFalse(plugin.isAllowed(new DummyHttpServletRequestUser(), new Project())); assertFalse(plugin.isAllowed(new DummyHttpServletRequestUser(), createGroup("some group"))); @@ -58,7 +58,7 @@ public void testNoUser() { } @Test - public void testUser() { + void testUser() { HttpServletRequest req; assertTrue(plugin.isAllowed(req = createRequest("007"), new Group())); assertEquals("007", ((User) req.getAttribute(UserPlugin.REQUEST_ATTR)).getUsername()); @@ -71,7 +71,7 @@ public void testUser() { } @Test - public void testTimeoutedUser() { + void testTimeoutedUser() { HttpServletRequest req; assertFalse(plugin.isAllowed(req = createRequest("007", true), new Group())); assertNull(req.getAttribute(UserPlugin.REQUEST_ATTR)); @@ -83,11 +83,11 @@ public void testTimeoutedUser() { assertNull(req.getAttribute(UserPlugin.REQUEST_ATTR)); } - protected HttpServletRequest createRequest(String email) { + HttpServletRequest createRequest(String email) { return createRequest(email, false); } - protected HttpServletRequest createRequest(String email, Boolean timeout) { + HttpServletRequest createRequest(String email, Boolean timeout) { return new DummyHttpServletRequestUser() { { setHeader("osso-user-dn", email); @@ -97,13 +97,13 @@ protected HttpServletRequest createRequest(String email, Boolean timeout) { }; } - protected Group createGroup(String name) { + Group createGroup(String name) { Group g = new Group(); g.setName(name); return g; } - protected Project createProject(String name) { + Project createProject(String name) { Project g = new Project(); g.setName(name); return g; diff --git a/plugins/src/test/java/opengrok/auth/plugin/UserWhiteListPluginTest.java b/plugins/src/test/java/opengrok/auth/plugin/UserWhiteListPluginTest.java index d58c663c0cc..50336333901 100644 --- a/plugins/src/test/java/opengrok/auth/plugin/UserWhiteListPluginTest.java +++ b/plugins/src/test/java/opengrok/auth/plugin/UserWhiteListPluginTest.java @@ -58,7 +58,7 @@ /** * Represents a container for tests of {@link UserWhiteListPlugin}. */ -public class UserWhiteListPluginTest { +class UserWhiteListPluginTest { private static final String OK_USER = "user1321"; private static final String OK_ID = "id2178"; @@ -68,12 +68,12 @@ public class UserWhiteListPluginTest { private UserWhiteListPlugin plugin; - public static Collection<String> parameters() { + static Collection<String> parameters() { return Arrays.asList(UserWhiteListPlugin.ID_FIELD, UserWhiteListPlugin.USERNAME_FIELD); } @BeforeAll - public static void beforeClass() throws Exception { + static void beforeClass() throws Exception { tempWhitelistUser = File.createTempFile("UserWhiteListPluginTestUser", "txt"); try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(tempWhitelistUser), StandardCharsets.UTF_8))) { @@ -92,7 +92,7 @@ public static void beforeClass() throws Exception { } @AfterAll - public static void afterClass() { + static void afterClass() { if (tempWhitelistUser != null) { //noinspection ResultOfMethodCallIgnored tempWhitelistUser.delete(); @@ -103,7 +103,7 @@ public static void afterClass() { } } - public void init(String param) { + void init(String param) { plugin = new UserWhiteListPlugin(); validPluginParameters.put(UserWhiteListPlugin.FIELD_PARAM, param); if (param.equals(UserWhiteListPlugin.USERNAME_FIELD)) { @@ -115,7 +115,7 @@ public void init(String param) { @ParameterizedTest @MethodSource("parameters") - public void shouldThrowOnLoadIfNullArgument(String param) { + void shouldThrowOnLoadIfNullArgument(String param) { init(param); assertThrows(IllegalArgumentException.class, () -> { //noinspection ConstantConditions @@ -125,7 +125,7 @@ public void shouldThrowOnLoadIfNullArgument(String param) { @ParameterizedTest @MethodSource("parameters") - public void shouldThrowOnLoadIfInvalidFieldName(String param) { + void shouldThrowOnLoadIfInvalidFieldName(String param) { init(param); assertThrows(IllegalArgumentException.class, () -> { Map<String, Object> map = new HashMap<>(); @@ -137,7 +137,7 @@ public void shouldThrowOnLoadIfInvalidFieldName(String param) { @ParameterizedTest @MethodSource("parameters") - public void shouldThrowOnLoadIfUnreadableFileSpecified(String param) { + void shouldThrowOnLoadIfUnreadableFileSpecified(String param) { init(param); HashMap<String, Object> unreadablePluginParameters = new HashMap<>(); unreadablePluginParameters.put(UserWhiteListPlugin.FILE_PARAM, @@ -157,7 +157,7 @@ public void shouldThrowOnLoadIfUnreadableFileSpecified(String param) { @ParameterizedTest @MethodSource("parameters") - public void shouldThrowOnLoadIfNoFileSpecified(String param) { + void shouldThrowOnLoadIfNoFileSpecified(String param) { init(param); IllegalArgumentException caughtException = null; try { @@ -173,7 +173,7 @@ public void shouldThrowOnLoadIfNoFileSpecified(String param) { @ParameterizedTest @MethodSource("parameters") - public void shouldStripWhitespaceFromWhitelists(String param) throws IOException { + void shouldStripWhitespaceFromWhitelists(String param) throws IOException { plugin = new UserWhiteListPlugin(); HashMap<String, Object> pluginParameters = new HashMap<>(); pluginParameters.put(UserWhiteListPlugin.FIELD_PARAM, param); @@ -202,14 +202,14 @@ public void shouldStripWhitespaceFromWhitelists(String param) throws IOException @ParameterizedTest @MethodSource("parameters") - public void shouldUnload(String param) { + void shouldUnload(String param) { init(param); plugin.unload(); } @ParameterizedTest @MethodSource("parameters") - public void shouldAllowWhitelistedUserForAnyProject(String param) { + void shouldAllowWhitelistedUserForAnyProject(String param) { init(param); plugin.load(validPluginParameters); @@ -233,7 +233,7 @@ public void shouldAllowWhitelistedUserForAnyProject(String param) { @ParameterizedTest @MethodSource("parameters") - public void shouldNotAllowRandomUserForAnyProject(String param) { + void shouldNotAllowRandomUserForAnyProject(String param) { init(param); plugin.load(validPluginParameters); @@ -251,7 +251,7 @@ public void shouldNotAllowRandomUserForAnyProject(String param) { @ParameterizedTest @MethodSource("parameters") - public void shouldAllowWhitelistedUserForAnyGroup(String param) { + void shouldAllowWhitelistedUserForAnyGroup(String param) { init(param); plugin.load(validPluginParameters); @@ -275,7 +275,7 @@ public void shouldAllowWhitelistedUserForAnyGroup(String param) { @ParameterizedTest @MethodSource("parameters") - public void shouldNotAllowRandomUserForAnyGroup(String param) { + void shouldNotAllowRandomUserForAnyGroup(String param) { init(param); plugin.load(validPluginParameters); diff --git a/plugins/src/test/java/opengrok/auth/plugin/decoders/MellonDecoderTest.java b/plugins/src/test/java/opengrok/auth/plugin/decoders/MellonDecoderTest.java index dd0f3d41aa5..facd8d4fbfc 100644 --- a/plugins/src/test/java/opengrok/auth/plugin/decoders/MellonDecoderTest.java +++ b/plugins/src/test/java/opengrok/auth/plugin/decoders/MellonDecoderTest.java @@ -34,18 +34,18 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -public class MellonDecoderTest { +class MellonDecoderTest { DummyHttpServletRequestUser dummyRequest; MellonHeaderDecoder decoder = new MellonHeaderDecoder(); @BeforeEach - public void setUp() { + void setUp() { dummyRequest = new DummyHttpServletRequestUser(); dummyRequest.setHeader(MELLON_EMAIL_HEADER, "foo@bar.cz"); } @Test - public void testId() { + void testId() { User result = decoder.fromRequest(dummyRequest); assertNotNull(result); @@ -55,12 +55,12 @@ public void testId() { } @Test - public void testMissingHeader() { + void testMissingHeader() { assertNull(decoder.fromRequest(new DummyHttpServletRequestUser())); } @Test - public void testUsername() { + void testUsername() { dummyRequest.setHeader(MELLON_USERNAME_HEADER, "foo"); User result = decoder.fromRequest(dummyRequest); diff --git a/plugins/src/test/java/opengrok/auth/plugin/decoders/OSSODecoderTest.java b/plugins/src/test/java/opengrok/auth/plugin/decoders/OSSODecoderTest.java index 67f91d80b6d..512abe9f76a 100644 --- a/plugins/src/test/java/opengrok/auth/plugin/decoders/OSSODecoderTest.java +++ b/plugins/src/test/java/opengrok/auth/plugin/decoders/OSSODecoderTest.java @@ -42,13 +42,13 @@ * Test OSSO header decoder. * @author Krystof Tulinger */ -public class OSSODecoderTest { +class OSSODecoderTest { DummyHttpServletRequestUser dummyRequest; OSSOHeaderDecoder decoder = new OSSOHeaderDecoder(); @BeforeEach - public void setUp() { + void setUp() { dummyRequest = new DummyHttpServletRequestUser(); dummyRequest.setHeader(OSSO_COOKIE_TIMESTAMP_HEADER, "5761172f"); dummyRequest.setHeader(OSSO_TIMEOUT_EXCEEDED_HEADER, ""); @@ -61,7 +61,7 @@ public void setUp() { /** * Test of fromRequest method, of class User. */ - public void testAll() { + void testAll() { dummyRequest.setHeader(OSSO_COOKIE_TIMESTAMP_HEADER, "5761172f"); dummyRequest.setHeader(OSSO_TIMEOUT_EXCEEDED_HEADER, "false"); dummyRequest.setHeader(OSSO_SUBSCRIBER_DN_HEADER, "dn=example.com"); @@ -83,7 +83,7 @@ public void testAll() { * Test of getUserId method, of class User. */ @Test - public void testGetUserId() { + void testGetUserId() { String[] tests = { "123456", "sd45gfgf5sd4g5ffd54g", @@ -102,7 +102,7 @@ public void testGetUserId() { * Test of getUserDn method, of class User. */ @Test - public void testGetUserDn() { + void testGetUserDn() { String[] tests = { "123456", "sd45gfgf5sd4g5ffd54g", @@ -121,7 +121,7 @@ public void testGetUserDn() { * Test of getCookieTimestamp method, of class User. */ @Test - public void testGetCookieTimestamp() { + void testGetCookieTimestamp() { String[] tests = {"123456", "5761172f", "58d137be"}; long[] expected = {1193046000L, 1465980719000L, 1490106302000L}; @@ -137,7 +137,7 @@ public void testGetCookieTimestamp() { * Test of getCookieTimestamp method, of class User. */ @Test - public void testInvalidGetCookieTimestamp() { + void testInvalidGetCookieTimestamp() { String[] tests = { "sd45gfgf5sd4g5ffd54g", "ě5 1g56ew1tč6516re5g1g65d1g65d", @@ -157,7 +157,7 @@ public void testInvalidGetCookieTimestamp() { * Test of getTimeoutExceeded method, of class User. */ @Test - public void testGetTimeouted() { + void testGetTimeouted() { String[] tests = {"false", "true", "FALSE", "TRUE", "abcd"}; boolean[] expected = {false, true, false, true, false}; diff --git a/plugins/src/test/java/opengrok/auth/plugin/decoders/UserPrincipalDecoderTest.java b/plugins/src/test/java/opengrok/auth/plugin/decoders/UserPrincipalDecoderTest.java index 73c07d7b471..9c9ee8a7d0b 100644 --- a/plugins/src/test/java/opengrok/auth/plugin/decoders/UserPrincipalDecoderTest.java +++ b/plugins/src/test/java/opengrok/auth/plugin/decoders/UserPrincipalDecoderTest.java @@ -32,17 +32,17 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -public class UserPrincipalDecoderTest { +class UserPrincipalDecoderTest { DummyHttpServletRequestUser dummyRequest; UserPrincipalDecoder decoder = new UserPrincipalDecoder(); @BeforeEach - public void setUp() { + void setUp() { dummyRequest = new DummyHttpServletRequestUser(); } @Test - public void testHttpBasicDecoding() { + void testHttpBasicDecoding() { dummyRequest.setHeader("authorization", "Basic Zm9vOmJhcg=="); User result = decoder.fromRequest(dummyRequest); @@ -54,7 +54,7 @@ public void testHttpBasicDecoding() { } @Test - public void testMissingHeader() { + void testMissingHeader() { assertNull(decoder.fromRequest(new DummyHttpServletRequestUser())); } } diff --git a/plugins/src/test/java/opengrok/auth/plugin/util/FilterUtilTest.java b/plugins/src/test/java/opengrok/auth/plugin/util/FilterUtilTest.java index e72447c1518..4273b925808 100644 --- a/plugins/src/test/java/opengrok/auth/plugin/util/FilterUtilTest.java +++ b/plugins/src/test/java/opengrok/auth/plugin/util/FilterUtilTest.java @@ -33,16 +33,16 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -public class FilterUtilTest { +class FilterUtilTest { @Test - public void testTransforms() { + void testTransforms() { assertEquals("FOO", doTransform("foo", "toUpperCase")); assertEquals("foo", doTransform("FOO", "toLowerCase")); } @Test - public void testTransformsUTF() throws UnsupportedEncodingException { + void testTransformsUTF() throws UnsupportedEncodingException { assertEquals(new String("ČUČKAŘ".getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8), doTransform(new String("čučkař".getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8), "toUpperCase")); assertEquals(new String("čučkař".getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8), @@ -50,12 +50,12 @@ public void testTransformsUTF() throws UnsupportedEncodingException { } @Test - public void testInvalidTransform() { + void testInvalidTransform() { assertThrows(UnsupportedOperationException.class, () -> doTransform("foo", "bar")); } @Test - public void testReplace() { + void testReplace() { Map<String, String> transforms = new TreeMap<>(); transforms.put("uid", "toUpperCase"); assertEquals("fooUSERbar", @@ -63,7 +63,7 @@ public void testReplace() { } @Test - public void testCheckTransforms() { + void testCheckTransforms() { Map<String, String> transforms = new TreeMap<>(); transforms.put("uid", "xxx"); assertThrows(UnsupportedOperationException.class, () -> FilterUtil.checkTransforms(transforms)); diff --git a/plugins/src/test/java/opengrok/auth/plugin/util/TimestampTest.java b/plugins/src/test/java/opengrok/auth/plugin/util/TimestampTest.java index 25f9e1c3685..9174f2fa73c 100644 --- a/plugins/src/test/java/opengrok/auth/plugin/util/TimestampTest.java +++ b/plugins/src/test/java/opengrok/auth/plugin/util/TimestampTest.java @@ -33,13 +33,13 @@ * * @author ktulinge */ -public class TimestampTest { +class TimestampTest { /** * Test of valid timestamp cookies and their decoded values. */ @Test - public void testDecodeTimestamp() { + void testDecodeTimestamp() { String[] tests = { "123456", "5761172f", @@ -63,7 +63,7 @@ public void testDecodeTimestamp() { * Test of invalid timestamp cookies. */ @Test - public void testInvalidDecodeTimestamp() { + void testInvalidDecodeTimestamp() { String[] tests = { "sd45gfgf5sd4g5ffd54g", "ě5 1g56ew1tč6516re5g1g65d1g65d", @@ -81,7 +81,7 @@ public void testInvalidDecodeTimestamp() { * Test of encoded cookies. */ @Test - public void testEncodeTimestamp() { + void testEncodeTimestamp() { Date[] tests = { new Date(Long.parseLong("1193046000")), new Date(Long.parseLong("1465980719000")), diff --git a/plugins/src/test/java/opengrok/auth/plugin/util/WebHookTest.java b/plugins/src/test/java/opengrok/auth/plugin/util/WebHookTest.java index 8a0df807be3..62ffd370ae4 100644 --- a/plugins/src/test/java/opengrok/auth/plugin/util/WebHookTest.java +++ b/plugins/src/test/java/opengrok/auth/plugin/util/WebHookTest.java @@ -27,8 +27,6 @@ import jakarta.ws.rs.core.Application; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.concurrent.ExecutionException; @@ -49,16 +47,6 @@ public String handlePost() { } } - @BeforeEach - public void setUp() throws Exception { - super.setUp(); - } - - @AfterEach - public void tearDown() throws Exception { - super.tearDown(); - } - @Override protected Application configure() { return new ResourceConfig(Service.class); diff --git a/suggester/src/test/java/org/opengrok/suggest/LookupPriorityQueueTest.java b/suggester/src/test/java/org/opengrok/suggest/LookupPriorityQueueTest.java index 7d9da8610a1..d0a5b79575f 100644 --- a/suggester/src/test/java/org/opengrok/suggest/LookupPriorityQueueTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/LookupPriorityQueueTest.java @@ -31,10 +31,10 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -public class LookupPriorityQueueTest { +class LookupPriorityQueueTest { @Test - public void testOverflow() { + void testOverflow() { LookupPriorityQueue queue = new LookupPriorityQueue(2); queue.insertWithOverflow(new LookupResultItem("1", "test", 1)); @@ -46,7 +46,7 @@ public void testOverflow() { } @Test - public void testCanInsert() { + void testCanInsert() { LookupPriorityQueue queue = new LookupPriorityQueue(2); queue.insertWithOverflow(new LookupResultItem("1", "test", 1)); diff --git a/suggester/src/test/java/org/opengrok/suggest/LookupResultItemTest.java b/suggester/src/test/java/org/opengrok/suggest/LookupResultItemTest.java index f9a0a2a108c..bd13cf1be29 100644 --- a/suggester/src/test/java/org/opengrok/suggest/LookupResultItemTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/LookupResultItemTest.java @@ -29,10 +29,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -public class LookupResultItemTest { +class LookupResultItemTest { @Test - public void combineTest() { + void combineTest() { LookupResultItem item1 = new LookupResultItem("p1", "proj1", 2); LookupResultItem item2 = new LookupResultItem("p1", "proj2", 4); @@ -44,7 +44,7 @@ public void combineTest() { } @Test - public void combineNullTest() { + void combineNullTest() { LookupResultItem item = new LookupResultItem("p1", "proj1", 2); assertThrows(IllegalArgumentException.class, () -> item.combine(null)); diff --git a/suggester/src/test/java/org/opengrok/suggest/SuggesterProjectDataTest.java b/suggester/src/test/java/org/opengrok/suggest/SuggesterProjectDataTest.java index f58ed05bc8a..1cc5224aef5 100644 --- a/suggester/src/test/java/org/opengrok/suggest/SuggesterProjectDataTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/SuggesterProjectDataTest.java @@ -57,7 +57,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -public class SuggesterProjectDataTest { +class SuggesterProjectDataTest { private static final String FIELD = "test"; @@ -68,13 +68,13 @@ public class SuggesterProjectDataTest { private SuggesterProjectData data; @BeforeEach - public void setUp() throws IOException { + void setUp() throws IOException { dir = new ByteBuffersDirectory(); tempDir = Files.createTempDirectory("test"); } @AfterEach - public void tearDown() throws IOException { + void tearDown() throws IOException { if (data != null) { data.close(); } @@ -84,7 +84,7 @@ public void tearDown() throws IOException { } @Test - public void testLookup() throws IOException { + void testLookup() throws IOException { addText(FIELD, "term1 term2"); init(false); @@ -117,7 +117,7 @@ private List<String> getSuggestions(String field, String prefix, int size) { } @Test - public void testMultipleTermsAreFirstByDefault() throws IOException { + void testMultipleTermsAreFirstByDefault() throws IOException { addText(FIELD, "term1 term2 term1"); init(false); @@ -128,7 +128,7 @@ public void testMultipleTermsAreFirstByDefault() throws IOException { } @Test - public void testMostPopularSearch() throws IOException { + void testMostPopularSearch() throws IOException { addText(FIELD, "term1 term2 term1"); init(true); @@ -144,7 +144,7 @@ public void testMostPopularSearch() throws IOException { } @Test - public void testRebuild() throws IOException { + void testRebuild() throws IOException { addText(FIELD, "term1 term2 term1"); init(false); @@ -163,7 +163,7 @@ public void testRebuild() throws IOException { } @Test - public void testDifferentPrefixes() throws IOException { + void testDifferentPrefixes() throws IOException { addText(FIELD, "abc bbc cbc dbc efc gfc"); init(false); @@ -174,7 +174,7 @@ public void testDifferentPrefixes() throws IOException { } @Test - public void testResultSize() throws IOException { + void testResultSize() throws IOException { addText(FIELD, "a1 a2 a3 a4 a5 a6 a7"); init(false); @@ -185,7 +185,7 @@ public void testResultSize() throws IOException { } @Test - public void incrementTest() throws IOException { + void incrementTest() throws IOException { addText(FIELD, "text"); init(true); @@ -196,7 +196,7 @@ public void incrementTest() throws IOException { } @Test - public void incrementByValueTest() throws IOException { + void incrementByValueTest() throws IOException { addText(FIELD, "some text"); init(true); @@ -207,7 +207,7 @@ public void incrementByValueTest() throws IOException { } @Test - public void incrementByNegativeValueTest() throws IOException { + void incrementByNegativeValueTest() throws IOException { addText(FIELD, "another text example"); init(true); @@ -217,7 +217,7 @@ public void incrementByNegativeValueTest() throws IOException { } @Test - public void rebuildRemoveOldTermsTest() throws IOException { + void rebuildRemoveOldTermsTest() throws IOException { addText(FIELD, "term"); init(true); @@ -236,7 +236,7 @@ public void rebuildRemoveOldTermsTest() throws IOException { } @Test - public void initAfterChangingIndexTest() throws IOException { + void initAfterChangingIndexTest() throws IOException { addText(FIELD, "term"); init(false); @@ -248,7 +248,7 @@ public void initAfterChangingIndexTest() throws IOException { } @Test - public void incrementSearchCountNullTest() throws IOException { + void incrementSearchCountNullTest() throws IOException { addText(FIELD, "term"); init(false); @@ -256,7 +256,7 @@ public void incrementSearchCountNullTest() throws IOException { } @Test - public void getSearchCountMapNullTest() throws IOException { + void getSearchCountMapNullTest() throws IOException { addText(FIELD, "term"); init(true); @@ -264,7 +264,7 @@ public void getSearchCountMapNullTest() throws IOException { } @Test - public void testRemove() throws IOException { + void testRemove() throws IOException { Directory dir = new ByteBuffersDirectory(); Path tempDir = Files.createTempDirectory("test"); @@ -283,7 +283,7 @@ public void testRemove() throws IOException { } @Test - public void testUnknownFieldIgnored() throws IOException { + void testUnknownFieldIgnored() throws IOException { addText(FIELD, "term"); data = new SuggesterProjectData(dir, tempDir, false, new HashSet<>(Arrays.asList(FIELD, "unknown"))); data.init(); @@ -295,7 +295,7 @@ public void testUnknownFieldIgnored() throws IOException { @Test @SuppressWarnings("unchecked") // for contains() - public void testGetSearchCountMapSorted() throws IOException { + void testGetSearchCountMapSorted() throws IOException { addText(FIELD, "test1 test2"); init(true); @@ -311,7 +311,7 @@ public void testGetSearchCountMapSorted() throws IOException { } @Test - public void testRebuildPicksUpNewFields() throws IOException { + void testRebuildPicksUpNewFields() throws IOException { // create dummy index try (IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig())) { iw.isOpen(); // dummy operation diff --git a/suggester/src/test/java/org/opengrok/suggest/SuggesterSearcherTest.java b/suggester/src/test/java/org/opengrok/suggest/SuggesterSearcherTest.java index 8ba99197d43..70d1efe2ba7 100644 --- a/suggester/src/test/java/org/opengrok/suggest/SuggesterSearcherTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/SuggesterSearcherTest.java @@ -52,14 +52,14 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; -public class SuggesterSearcherTest { +class SuggesterSearcherTest { private static Directory dir; private static SuggesterSearcher searcher; @BeforeAll - public static void setUpClass() throws IOException { + static void setUpClass() throws IOException { dir = new ByteBuffersDirectory(); try (IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig())) { @@ -79,12 +79,12 @@ public static void setUpClass() throws IOException { } @AfterAll - public static void tearDownClass() throws IOException { + static void tearDownClass() throws IOException { dir.close(); } @Test - public void suggesterPrefixQueryTest() { + void suggesterPrefixQueryTest() { List<LookupResultItem> suggestions = searcher.suggest(new TermQuery(new Term("test", "test")), "test", new SuggesterPrefixQuery(new Term("test", "o")), k -> 0); @@ -94,7 +94,7 @@ public void suggesterPrefixQueryTest() { } @Test - public void suggesterWildcardQueryTest() { + void suggesterWildcardQueryTest() { List<LookupResultItem> suggestions = searcher.suggest(new TermQuery(new Term("test", "test")), "test", new SuggesterWildcardQuery(new Term("test", "?pengrok")), k -> 0); @@ -104,7 +104,7 @@ public void suggesterWildcardQueryTest() { } @Test - public void suggesterRegexpQueryTest() { + void suggesterRegexpQueryTest() { List<LookupResultItem> suggestions = searcher.suggest(new TermQuery(new Term("test", "test")), "test", new SuggesterRegexpQuery(new Term("test", ".pengrok")), k -> 0); @@ -114,7 +114,7 @@ public void suggesterRegexpQueryTest() { } @Test - public void suggesterFuzzyQueryTest() { + void suggesterFuzzyQueryTest() { List<LookupResultItem> suggestions = searcher.suggest(new TermQuery(new Term("test", "test")), "test", new SuggesterFuzzyQuery(new Term("test", "opengroc"), 1, 0), k -> 0); @@ -124,7 +124,7 @@ public void suggesterFuzzyQueryTest() { } @Test - public void suggesterPhraseQueryTest() { + void suggesterPhraseQueryTest() { SuggesterPhraseQuery q = new SuggesterPhraseQuery("test", "abc", Arrays.asList("opengrok", "openabc"), 0); List<LookupResultItem> suggestions = searcher.suggest(q.getPhraseQuery(), "test", @@ -136,7 +136,7 @@ public void suggesterPhraseQueryTest() { } @Test - public void testRangeQueryUpper() { + void testRangeQueryUpper() { SuggesterRangeQuery q = new SuggesterRangeQuery("test", new BytesRef("opengrok"), new BytesRef("t"), true, true, SuggesterRangeQuery.SuggestPosition.UPPER); @@ -148,7 +148,7 @@ public void testRangeQueryUpper() { } @Test - public void testRangeQueryLower() { + void testRangeQueryLower() { SuggesterRangeQuery q = new SuggesterRangeQuery("test", new BytesRef("o"), new BytesRef("test"), true, true, SuggesterRangeQuery.SuggestPosition.LOWER); diff --git a/suggester/src/test/java/org/opengrok/suggest/SuggesterUtilsTest.java b/suggester/src/test/java/org/opengrok/suggest/SuggesterUtilsTest.java index 14032f00579..bbc2bfa0cad 100644 --- a/suggester/src/test/java/org/opengrok/suggest/SuggesterUtilsTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/SuggesterUtilsTest.java @@ -40,10 +40,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -public class SuggesterUtilsTest { +class SuggesterUtilsTest { @Test - public void intoTermsTest() { + void intoTermsTest() { Term t = new Term("test", "test"); Query q = new TermQuery(t); @@ -55,7 +55,7 @@ public void intoTermsTest() { } @Test - public void intoTermsComplexTest() { + void intoTermsComplexTest() { Term t = new Term("test", "term"); BooleanQuery q = new BooleanQuery.Builder() @@ -71,7 +71,7 @@ public void intoTermsComplexTest() { } @Test - public void intoTermExceptPhraseQueryTest() { + void intoTermExceptPhraseQueryTest() { Term t = new Term("test", "term"); BooleanQuery q = new BooleanQuery.Builder() .add(new TermQuery(t), BooleanClause.Occur.MUST) @@ -85,12 +85,12 @@ public void intoTermExceptPhraseQueryTest() { } @Test - public void testIsComplexQuery() { + void testIsComplexQuery() { assertFalse(SuggesterUtils.isComplexQuery(null, new SuggesterPrefixQuery(new Term("test", "t")))); } @Test - public void testCombineResults() { + void testCombineResults() { LookupResultItem item1 = new LookupResultItem("test", "proj1", 10); LookupResultItem item2 = new LookupResultItem("test", "proj2", 10); LookupResultItem item3 = new LookupResultItem("test", "proj3", 10); diff --git a/suggester/src/test/java/org/opengrok/suggest/popular/impl/ChronicleMapAdapterTest.java b/suggester/src/test/java/org/opengrok/suggest/popular/impl/ChronicleMapAdapterTest.java index b6980318382..2a993bef7b9 100644 --- a/suggester/src/test/java/org/opengrok/suggest/popular/impl/ChronicleMapAdapterTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/popular/impl/ChronicleMapAdapterTest.java @@ -39,7 +39,7 @@ import static org.hamcrest.collection.IsIterableContainingInOrder.contains; import static org.junit.jupiter.api.Assertions.assertEquals; -public class ChronicleMapAdapterTest { +class ChronicleMapAdapterTest { private static final String FIELD = "test"; @@ -48,20 +48,20 @@ public class ChronicleMapAdapterTest { private Path tempFile; @BeforeEach - public void setUp() throws IOException { + void setUp() throws IOException { tempFile = Files.createTempFile("opengrok", "test"); map = new ChronicleMapAdapter(FIELD, 3, 10, tempFile.toFile()); } @AfterEach - public void tearDown() throws IOException { + void tearDown() throws IOException { map.close(); Files.delete(tempFile); } @Test - public void dataNotLostAfterResizeTest() throws IOException { + void dataNotLostAfterResizeTest() throws IOException { fillData(0, 10, map); map.resize(20, 20); @@ -82,7 +82,7 @@ private void checkData(int count, ChronicleMapAdapter map) { } @Test - public void testResize() throws IOException { + void testResize() throws IOException { fillData(0, 10, map); map.resize(500, 20); @@ -94,7 +94,7 @@ public void testResize() throws IOException { @Test @SuppressWarnings("unchecked") // for contains() - public void testGetPopularityData() { + void testGetPopularityData() { Entry<BytesRef, Integer> e1 = new SimpleEntry<>(new BytesRef("test"), 1); Entry<BytesRef, Integer> e2 = new SimpleEntry<>(new BytesRef("test2"), 2); @@ -108,7 +108,7 @@ public void testGetPopularityData() { @Test @SuppressWarnings("unchecked") // for contains() - public void testGetPopularityPaging() { + void testGetPopularityPaging() { Entry<BytesRef, Integer> e1 = new SimpleEntry<>(new BytesRef("test"), 1); Entry<BytesRef, Integer> e2 = new SimpleEntry<>(new BytesRef("test2"), 2); Entry<BytesRef, Integer> e3 = new SimpleEntry<>(new BytesRef("test3"), 3); diff --git a/suggester/src/test/java/org/opengrok/suggest/popular/impl/ChronicleMapConfigurationTest.java b/suggester/src/test/java/org/opengrok/suggest/popular/impl/ChronicleMapConfigurationTest.java index 617ac4f6837..ab6b0936d38 100644 --- a/suggester/src/test/java/org/opengrok/suggest/popular/impl/ChronicleMapConfigurationTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/popular/impl/ChronicleMapConfigurationTest.java @@ -31,10 +31,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class ChronicleMapConfigurationTest { +class ChronicleMapConfigurationTest { @Test - public void saveLoadTest() throws IOException { + void saveLoadTest() throws IOException { ChronicleMapConfiguration conf = new ChronicleMapConfiguration(20, 10); Path dir = Files.createTempDirectory("opengrok"); diff --git a/suggester/src/test/java/org/opengrok/suggest/query/SuggesterFuzzyQueryTest.java b/suggester/src/test/java/org/opengrok/suggest/query/SuggesterFuzzyQueryTest.java index 5b6af466339..98ea7873387 100644 --- a/suggester/src/test/java/org/opengrok/suggest/query/SuggesterFuzzyQueryTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/query/SuggesterFuzzyQueryTest.java @@ -27,10 +27,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class SuggesterFuzzyQueryTest { +class SuggesterFuzzyQueryTest { @Test - public void testLength() { + void testLength() { SuggesterFuzzyQuery q = new SuggesterFuzzyQuery(new Term("test", "test"), 2, 0); assertEquals("test".length(), q.length()); } diff --git a/suggester/src/test/java/org/opengrok/suggest/query/SuggesterPhraseQueryTest.java b/suggester/src/test/java/org/opengrok/suggest/query/SuggesterPhraseQueryTest.java index ed249c37721..fe295ec74b1 100644 --- a/suggester/src/test/java/org/opengrok/suggest/query/SuggesterPhraseQueryTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/query/SuggesterPhraseQueryTest.java @@ -32,10 +32,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class SuggesterPhraseQueryTest { +class SuggesterPhraseQueryTest { @Test - public void prefixQueryTest() { + void prefixQueryTest() { SuggesterPhraseQuery q = new SuggesterPhraseQuery("test", "ident", Arrays.asList("one", "two", "tident"), 0); @@ -45,7 +45,7 @@ public void prefixQueryTest() { } @Test - public void phraseQueryTest() throws Exception { + void phraseQueryTest() throws Exception { SuggesterPhraseQuery q = new SuggesterPhraseQuery("test", "ident", Arrays.asList("one", "two", "tident"), 0); diff --git a/suggester/src/test/java/org/opengrok/suggest/query/SuggesterPrefixQueryTest.java b/suggester/src/test/java/org/opengrok/suggest/query/SuggesterPrefixQueryTest.java index 628c9c6d7b8..2c0b06ff09e 100644 --- a/suggester/src/test/java/org/opengrok/suggest/query/SuggesterPrefixQueryTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/query/SuggesterPrefixQueryTest.java @@ -27,10 +27,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class SuggesterPrefixQueryTest { +class SuggesterPrefixQueryTest { @Test - public void testLength() { + void testLength() { SuggesterPrefixQuery q = new SuggesterPrefixQuery(new Term("test", "prefix")); assertEquals("prefix".length(), q.length()); } diff --git a/suggester/src/test/java/org/opengrok/suggest/query/SuggesterRangeQueryTest.java b/suggester/src/test/java/org/opengrok/suggest/query/SuggesterRangeQueryTest.java index a65c73ea53a..72f6e04a108 100644 --- a/suggester/src/test/java/org/opengrok/suggest/query/SuggesterRangeQueryTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/query/SuggesterRangeQueryTest.java @@ -27,17 +27,17 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class SuggesterRangeQueryTest { +class SuggesterRangeQueryTest { @Test - public void testLengthLower() { + void testLengthLower() { SuggesterRangeQuery q = new SuggesterRangeQuery("test", new BytesRef("lowerTerm"), new BytesRef("upper"), true, false, SuggesterRangeQuery.SuggestPosition.LOWER); assertEquals("lowerTerm".length(), q.length()); } @Test - public void testLengthUpper() { + void testLengthUpper() { SuggesterRangeQuery q = new SuggesterRangeQuery("test", new BytesRef("l"), new BytesRef("upper"), true, false, SuggesterRangeQuery.SuggestPosition.UPPER); assertEquals("upper".length(), q.length()); diff --git a/suggester/src/test/java/org/opengrok/suggest/query/SuggesterRegexpQueryTest.java b/suggester/src/test/java/org/opengrok/suggest/query/SuggesterRegexpQueryTest.java index a35eb2ab483..dcc62688247 100644 --- a/suggester/src/test/java/org/opengrok/suggest/query/SuggesterRegexpQueryTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/query/SuggesterRegexpQueryTest.java @@ -27,10 +27,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class SuggesterRegexpQueryTest { +class SuggesterRegexpQueryTest { @Test - public void testLength() { + void testLength() { SuggesterRegexpQuery q = new SuggesterRegexpQuery(new Term("test", ".*test")); assertEquals(".*test".length(), q.length()); } diff --git a/suggester/src/test/java/org/opengrok/suggest/query/SuggesterWildcardQueryTest.java b/suggester/src/test/java/org/opengrok/suggest/query/SuggesterWildcardQueryTest.java index 1ab6788f97b..d89fabe5f4d 100644 --- a/suggester/src/test/java/org/opengrok/suggest/query/SuggesterWildcardQueryTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/query/SuggesterWildcardQueryTest.java @@ -27,10 +27,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class SuggesterWildcardQueryTest { +class SuggesterWildcardQueryTest { @Test - public void testLength() { + void testLength() { SuggesterWildcardQuery q = new SuggesterWildcardQuery(new Term("test", "m?t")); assertEquals("m?t".length(), q.length()); } diff --git a/suggester/src/test/java/org/opengrok/suggest/query/customized/CustomExactPhraseScorerTest.java b/suggester/src/test/java/org/opengrok/suggest/query/customized/CustomExactPhraseScorerTest.java index 4edd6c32940..86d1879f0bd 100644 --- a/suggester/src/test/java/org/opengrok/suggest/query/customized/CustomExactPhraseScorerTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/query/customized/CustomExactPhraseScorerTest.java @@ -26,15 +26,15 @@ import java.io.IOException; -public class CustomExactPhraseScorerTest { +class CustomExactPhraseScorerTest { @Test - public void simpleTestAfter() throws IOException { + void simpleTestAfter() throws IOException { CustomSloppyPhraseScorerTest.test(0, 2, new String[] {"one", "two"}, new Integer[] {3}); } @Test - public void simpleTestBefore() throws IOException { + void simpleTestBefore() throws IOException { CustomSloppyPhraseScorerTest.test(0, -1, new String[] {"one", "two"}, new Integer[] {0}); } diff --git a/suggester/src/test/java/org/opengrok/suggest/query/customized/CustomSloppyPhraseScorerTest.java b/suggester/src/test/java/org/opengrok/suggest/query/customized/CustomSloppyPhraseScorerTest.java index 801f7a67d16..11deb773353 100644 --- a/suggester/src/test/java/org/opengrok/suggest/query/customized/CustomSloppyPhraseScorerTest.java +++ b/suggester/src/test/java/org/opengrok/suggest/query/customized/CustomSloppyPhraseScorerTest.java @@ -50,9 +50,9 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -public class CustomSloppyPhraseScorerTest { +class CustomSloppyPhraseScorerTest { - public static void test( + static void test( final int slop, final int offset, final String[] terms, @@ -107,12 +107,12 @@ private static Set<Integer> toSet(final BitIntsHolder bs) { } @Test - public void simpleTestAfter() throws IOException { + void simpleTestAfter() throws IOException { test(2, 2, new String[] {"five", "six"}, new Integer[] {7, 8, 9}); } @Test - public void simpleTestBefore() throws IOException { + void simpleTestBefore() throws IOException { test(2, -1, new String[] {"five", "six"}, new Integer[] {2, 3, 4}); }