Search in sources :

Example 41 with Project

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

the class ProjectHelperTestBase method createProject.

protected static Project createProject(int index, int number, boolean grouped, boolean allowed, boolean repository, List<RepositoryInfo> rps, List<Project> prjs, Map<Project, List<RepositoryInfo>> map) {
    Project p = new Project();
    p.setName((allowed ? "allowed_" : "") + (grouped ? "grouped_" : "ungrouped_") + (repository ? "repository" : "project") + "_" + index + "_" + number);
    prjs.add(p);
    return p;
}
Also used : Project(org.opensolaris.opengrok.configuration.Project)

Example 42 with Project

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

the class ProjectHelperTest method testSynchronization.

/**
     * Test if projects and groups are always reloaded fully from the env.
     * 
     * This ensures that when the RuntimeEnvironment changes that it also
     * updates the projects in the ui.
     */
@Test
public void testSynchronization() {
    List<Project> oldProjects = new ArrayList<>(env.getProjects());
    List<RepositoryInfo> oldRepositories = new ArrayList<>(env.getRepositories());
    Set<Group> oldGroups = new TreeSet<>(env.getGroups());
    Map<Project, List<RepositoryInfo>> oldMap = new TreeMap<>(getRepositoriesMap());
    invokeRemoveAll();
    cfg = PageConfig.get(getRequest());
    helper = cfg.getProjectHelper();
    // basic setup
    Assert.assertEquals("There should be 40 env projects", 40, env.getProjects().size());
    Assert.assertEquals("There should be 20 env repositories", 20, env.getRepositories().size());
    Assert.assertEquals("There should be 4 env groups", 4, env.getGroups().size());
    Assert.assertEquals("There are 8 ungrouped projects", 8, helper.getAllUngrouped().size());
    Assert.assertEquals("There are 40 projects", 40, helper.getAllProjects().size());
    Assert.assertEquals("There are 4 projects", 4, helper.getRepositories().size());
    Assert.assertEquals("There are 4 groups", 4, helper.getGroups().size());
    // project
    Project p = new Project();
    p.setName("some random name not in any group");
    // group
    Group g = new Group();
    g.setName("some random name of a group");
    // repository
    Project repo = new Project();
    repo.setName("some random name not in any other group");
    RepositoryInfo info = new RepoRepository();
    info.setParent(repo.getName());
    info.setDirectoryName(null);
    List<RepositoryInfo> infos = getRepositoriesMap().get(repo);
    if (infos == null) {
        infos = new ArrayList<>();
    }
    infos.add(info);
    getRepositoriesMap().put(repo, infos);
    env.getRepositories().add(info);
    env.getProjects().add(p);
    env.getProjects().add(repo);
    env.getGroups().add(g);
    env.register();
    Assert.assertEquals(42, env.getProjects().size());
    Assert.assertEquals(21, env.getRepositories().size());
    Assert.assertEquals(5, env.getGroups().size());
    // simulate another request
    cfg = PageConfig.get(getRequest());
    helper = cfg.getProjectHelper();
    // check for updates
    Assert.assertEquals("The helper state should refresh", 10, helper.getAllUngrouped().size());
    Assert.assertEquals("The helper state should refresh", 42, helper.getAllProjects().size());
    Assert.assertEquals("The helper state should refresh", 5, helper.getRepositories().size());
    Assert.assertEquals("The helper state should refresh", 5, helper.getGroups().size());
    setRepositoriesMap(oldMap);
    env.setProjects(oldProjects);
    env.setRepositories(oldRepositories);
    env.setGroups(oldGroups);
    env.register();
}
Also used : Group(org.opensolaris.opengrok.configuration.Group) RepositoryInfo(org.opensolaris.opengrok.history.RepositoryInfo) ArrayList(java.util.ArrayList) RepoRepository(org.opensolaris.opengrok.history.RepoRepository) TreeMap(java.util.TreeMap) Project(org.opensolaris.opengrok.configuration.Project) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 43 with Project

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

the class ProjectHelperTest method testGetAllowedProjects.

/**
     * Test of getProjects method, of class ProjectHelper.
     */
@Test
public void testGetAllowedProjects() {
    Set<Project> result = helper.getProjects();
    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 44 with Project

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

the class IndexerTest method testBug3430.

@Test
public void testBug3430() throws Exception {
    RuntimeEnvironment env = RuntimeEnvironment.getInstance();
    env.setCtags(System.getProperty(ctagsProperty, "ctags"));
    env.setSourceRoot(repository.getSourceRoot());
    env.setDataRoot(repository.getDataRoot());
    if (env.validateExuberantCtags()) {
        Project project = new Project();
        project.setPath("/bug3430");
        IndexDatabase idb = new IndexDatabase(project);
        assertNotNull(idb);
        MyIndexChangeListener listener = new MyIndexChangeListener();
        idb.addIndexChangedListener(listener);
        idb.update();
        assertEquals(1, listener.files.size());
    } else {
        System.out.println("Skipping test. Could not find a ctags I could use in path.");
    }
}
Also used : Project(org.opensolaris.opengrok.configuration.Project) RuntimeEnvironment(org.opensolaris.opengrok.configuration.RuntimeEnvironment) 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