Search in sources :

Example 11 with Project

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

the class ProjectHelperExtendedTest method createProject.

protected static Project createProject(String name) {
    Project p = new Project();
    p.setName(name);
    return p;
}
Also used : Project(org.opensolaris.opengrok.configuration.Project)

Example 12 with Project

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

the class ProjectHelperTest method testGetRepositories.

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

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

the class ProjectHelperTest method testGetRepositoriesAllowedGroup.

/**
     * Test of getRepositories method, of class ProjectHelper.
     */
@Test
public void testGetRepositoriesAllowedGroup() {
    for (Group g : RuntimeEnvironment.getInstance().getGroups()) {
        if (g.getName().startsWith("allowed_group_0")) {
            Set<Project> result = helper.getRepositories(g);
            Assert.assertEquals(2, result.size());
            for (Project p : result) {
                Assert.assertTrue(p.getName().startsWith("allowed_"));
            }
        }
    }
}
Also used : Group(org.opensolaris.opengrok.configuration.Group) Project(org.opensolaris.opengrok.configuration.Project) Test(org.junit.Test)

Example 14 with Project

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

the class IndexerTest method testBug11896.

@Test
public void testBug11896() throws Exception {
    boolean test = true;
    if (FileUtilities.findProgInPath("mkfifo") == null) {
        System.out.println("Error: mkfifo not found in PATH !\n");
        test = false;
    }
    if (test) {
        RuntimeEnvironment env = RuntimeEnvironment.getInstance();
        env.setSourceRoot(repository.getSourceRoot());
        env.setDataRoot(repository.getDataRoot());
        Executor executor;
        executor = new Executor(new String[] { "mkdir", "-p", repository.getSourceRoot() + "/testBug11896" });
        executor.exec(true);
        executor = new Executor(new String[] { "mkfifo", repository.getSourceRoot() + "/testBug11896/FIFO" });
        executor.exec(true);
        if (env.validateExuberantCtags()) {
            Project project = new Project();
            project.setPath("/testBug11896");
            IndexDatabase idb = new IndexDatabase(project);
            assertNotNull(idb);
            MyIndexChangeListener listener = new MyIndexChangeListener();
            idb.addIndexChangedListener(listener);
            System.out.println("Trying to index a special file - FIFO in this case.");
            idb.update();
            assertEquals(0, listener.files.size());
        } else {
            System.out.println("Skipping test. Could not find a ctags I could use in path.");
        }
    } else {
        System.out.println("Skipping test for bug 11896. Could not find a mkfifo in path.");
    }
}
Also used : Project(org.opensolaris.opengrok.configuration.Project) RuntimeEnvironment(org.opensolaris.opengrok.configuration.RuntimeEnvironment) Executor(org.opensolaris.opengrok.util.Executor) Test(org.junit.Test)

Example 15 with Project

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

the class IndexerTest method testRFE2575.

@Test
public void testRFE2575() throws Exception {
    RuntimeEnvironment env = RuntimeEnvironment.getInstance();
    env.setCtags(System.getProperty(ctagsProperty, "ctags"));
    env.setSourceRoot(repository.getSourceRoot());
    env.setDataRoot(repository.getDataRoot());
    HistoryGuru.getInstance().addRepositories(repository.getSourceRoot());
    List<RepositoryInfo> repos = env.getRepositories();
    Repository r = null;
    for (RepositoryInfo ri : repos) {
        if (ri.getDirectoryName().equals(repository.getSourceRoot() + "/rfe2575")) {
            r = RepositoryFactory.getRepository(ri);
            break;
        }
    }
    if (r != null && r.isWorking() && env.validateExuberantCtags()) {
        Project project = new Project();
        project.setPath("/rfe2575");
        IndexDatabase idb = new IndexDatabase(project);
        assertNotNull(idb);
        MyIndexChangeListener listener = new MyIndexChangeListener();
        idb.addIndexChangedListener(listener);
        idb.update();
        assertEquals(2, listener.files.size());
        repository.purgeData();
        RuntimeEnvironment.getInstance().setIndexVersionedFilesOnly(true);
        idb = new IndexDatabase(project);
        listener = new MyIndexChangeListener();
        idb.addIndexChangedListener(listener);
        idb.update();
        assertEquals(1, listener.files.size());
        RuntimeEnvironment.getInstance().setIndexVersionedFilesOnly(false);
    } else {
        System.out.println("Skipping test. Repository for rfe2575 not found or could not find a ctags or an sccs I could use in path.");
    }
}
Also used : Project(org.opensolaris.opengrok.configuration.Project) Repository(org.opensolaris.opengrok.history.Repository) TestRepository(org.opensolaris.opengrok.util.TestRepository) RuntimeEnvironment(org.opensolaris.opengrok.configuration.RuntimeEnvironment) RepositoryInfo(org.opensolaris.opengrok.history.RepositoryInfo) 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