Search in sources :

Example 16 with Project

use of org.opensolaris.opengrok.configuration.Project in project OpenGrok by OpenGrok.

the class IndexerTest method testRescanProjects.

/**
     * Test that rescanning for projects does not erase customization of
     * existing projects. Bug #16006.
     * @throws java.lang.Exception*/
@Test
public void testRescanProjects() throws Exception {
    // Generate one project that will be found in source.zip, and set
    // some properties that we can verify after the rescan.
    Project p1 = new Project();
    p1.setPath("/java");
    p1.setName("Project 1");
    p1.setTabSize(3);
    // Generate one project that will not be found in source.zip, and that
    // should not be in the list of projects after the rescan.
    Project p2 = new Project();
    p2.setPath("/this_path_does_not_exist");
    p2.setName("Project 2");
    // Make the runtime environment aware of these two projects.
    List<Project> projects = new ArrayList<>();
    projects.add(p1);
    projects.add(p2);
    RuntimeEnvironment env = RuntimeEnvironment.getInstance();
    env.setProjects(projects);
    // Do a rescan of the projects, and only that (we don't care about
    // the other aspects of indexing in this test case).
    Indexer.getInstance().prepareIndexer(env, // don't search for repositories
    false, // scan and add projects
    true, // no default project
    null, // don't write config file
    null, // don't refresh history
    false, // don't list files
    false, // don't create dictionary
    false, // subFiles - not needed since we don't list files
    null, // repositories - not needed when not refreshing history
    null, // don't zap cache
    new ArrayList<>(), // don't list repos
    false);
    List<Project> newProjects = env.getProjects();
    // p2 should not be in the project list anymore
    for (Project p : newProjects) {
        assertFalse("p2 not removed", p.getPath().equals(p2.getPath()));
    }
    // p1 should be there
    Project newP1 = null;
    for (Project p : newProjects) {
        if (p.getPath().equals(p1.getPath())) {
            newP1 = p;
            break;
        }
    }
    assertNotNull("p1 not in list", newP1);
    // The properties of p1 should be preserved
    assertEquals("project path", p1.getPath(), newP1.getPath());
    assertEquals("project description", p1.getName(), newP1.getName());
    assertEquals("project tabsize", p1.getTabSize(), newP1.getTabSize());
}
Also used : Project(org.opensolaris.opengrok.configuration.Project) RuntimeEnvironment(org.opensolaris.opengrok.configuration.RuntimeEnvironment) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 17 with Project

use of org.opensolaris.opengrok.configuration.Project in project OpenGrok by OpenGrok.

the class ProjectHelperTest method testGetUngroupedRepositories.

/**
     * Test of getUngroupedRepositories method, of class ProjectHelper.
     */
@Test
public void testGetUngroupedRepositories() {
    Set<Project> result = helper.getUngroupedRepositories();
    Assert.assertEquals(2, result.size());
    for (Project p : result) {
        Assert.assertTrue(p.getName().startsWith("allowed_"));
    }
}
Also used : Project(org.opensolaris.opengrok.configuration.Project) Test(org.junit.Test)

Example 18 with Project

use of org.opensolaris.opengrok.configuration.Project in project OpenGrok by OpenGrok.

the class ProjectHelperTest method testAllowedGetRepositoryInfo.

/**
     * Test of getRepositoryInfo method, of class ProjectHelper.
     */
@Test
public void testAllowedGetRepositoryInfo() {
    Project p = new Project();
    p.setName("allowed_grouped_repository_0_1");
    List<RepositoryInfo> result = helper.getRepositoryInfo(p);
    Assert.assertEquals(1, result.size());
    Assert.assertEquals("allowed_grouped_repository_0_1_" + 0, result.get(0).getParent());
}
Also used : Project(org.opensolaris.opengrok.configuration.Project) RepositoryInfo(org.opensolaris.opengrok.history.RepositoryInfo) Test(org.junit.Test)

Example 19 with Project

use of org.opensolaris.opengrok.configuration.Project in project OpenGrok by OpenGrok.

the class ProjectHelperTest method testGetGroupedRepositories.

/**
     * Test of getGroupedRepositories method, of class ProjectHelper.
     */
@Test
public void testGetGroupedRepositories() {
    Set<Project> result = helper.getGroupedRepositories();
    Assert.assertEquals(4, result.size());
    for (Project p : result) {
        Assert.assertTrue(p.getName().startsWith("allowed_"));
    }
}
Also used : Project(org.opensolaris.opengrok.configuration.Project) Test(org.junit.Test)

Example 20 with Project

use of org.opensolaris.opengrok.configuration.Project in project OpenGrok by OpenGrok.

the class ProjectHelperTest method testGetAllUngrouped.

/**
     * Test of getAllUngrouped method, of class ProjectHelper.
     */
@Test
public void testGetAllUngrouped() {
    Set<Project> result = helper.getAllUngrouped();
    Assert.assertEquals(4, result.size());
    for (Project p : result) {
        Assert.assertTrue(p.getName().startsWith("allowed_"));
    }
}
Also used : Project(org.opensolaris.opengrok.configuration.Project) Test(org.junit.Test)

Aggregations

Project (org.opensolaris.opengrok.configuration.Project)44 Test (org.junit.Test)22 RuntimeEnvironment (org.opensolaris.opengrok.configuration.RuntimeEnvironment)12 Group (org.opensolaris.opengrok.configuration.Group)9 ArrayList (java.util.ArrayList)8 RepositoryInfo (org.opensolaris.opengrok.history.RepositoryInfo)6 File (java.io.File)4 TreeSet (java.util.TreeSet)4 IOException (java.io.IOException)3 HistoryException (org.opensolaris.opengrok.history.HistoryException)3 FileNotFoundException (java.io.FileNotFoundException)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 Document (org.apache.lucene.document.Document)2 Genre (org.opensolaris.opengrok.analysis.FileAnalyzer.Genre)2 RepoRepository (org.opensolaris.opengrok.history.RepoRepository)2 DummyHttpServletRequest (org.opensolaris.opengrok.web.DummyHttpServletRequest)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1