Search in sources :

Example 36 with TestRepository

use of org.opengrok.indexer.util.TestRepository in project OpenGrok by OpenGrok.

the class HistoryGuruTest method setUpClass.

@BeforeAll
public static void setUpClass() throws Exception {
    env = RuntimeEnvironment.getInstance();
    savedNestingMaximum = env.getNestingMaximum();
    repository = new TestRepository();
    repository.create(HistoryGuru.class.getResource("/repositories"));
    RepositoryFactory.initializeIgnoredNames(env);
    FileUtilities.getAllFiles(new File(repository.getSourceRoot()), FILES, true);
    assertNotEquals(0, FILES.size());
    HistoryGuru histGuru = HistoryGuru.getInstance();
    assertNotNull(histGuru);
    assertEquals(0, histGuru.getRepositories().size());
    // Add initial set of repositories to HistoryGuru and RuntimeEnvironment.
    // This is a test in itself. While this makes the structure of the tests
    // a bit incomprehensible, it does not make sense to run the rest of tests
    // if the basic functionality does not work.
    env.setRepositories(repository.getSourceRoot());
    assertTrue(histGuru.getRepositories().size() > 0);
    assertEquals(histGuru.getRepositories().size(), env.getRepositories().size());
    // Create cache with initial set of repositories.
    histGuru.createCache();
}
Also used : TestRepository(org.opengrok.indexer.util.TestRepository) File(java.io.File) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 37 with TestRepository

use of org.opengrok.indexer.util.TestRepository in project OpenGrok by OpenGrok.

the class IgnoredNamesTest method setUpClass.

@BeforeAll
public static void setUpClass() throws Exception {
    repository = new TestRepository();
    repository.create(CAnalyzerFactoryTest.class.getClassLoader().getResource("sources"));
    // Populate ignored lists with repository specific entries.
    RepositoryFactory.initializeIgnoredNames(RuntimeEnvironment.getInstance());
}
Also used : TestRepository(org.opengrok.indexer.util.TestRepository) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 38 with TestRepository

use of org.opengrok.indexer.util.TestRepository in project OpenGrok by OpenGrok.

the class JavaAnalyzerFactoryTest method setUpClass.

@BeforeAll
public static void setUpClass() throws Exception {
    ctags = new Ctags();
    repository = new TestRepository();
    repository.create(JavaAnalyzerFactoryTest.class.getClassLoader().getResource("sources"));
    JavaAnalyzerFactory analFact = new JavaAnalyzerFactory();
    analyzer = analFact.getAnalyzer();
    RuntimeEnvironment env = RuntimeEnvironment.getInstance();
    if (env.validateUniversalCtags()) {
        analyzer.setCtags(new Ctags());
    }
}
Also used : TestRepository(org.opengrok.indexer.util.TestRepository) RuntimeEnvironment(org.opengrok.indexer.configuration.RuntimeEnvironment) Ctags(org.opengrok.indexer.analysis.Ctags) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 39 with TestRepository

use of org.opengrok.indexer.util.TestRepository in project OpenGrok by OpenGrok.

the class TroffAnalyzerTest method setUpBeforeClass.

/**
 * Test method for {@link org.opengrok.indexer.analysis.document
 * .TroffAnalyzer#TroffAnalyzer(org.opengrok.indexer.analysis.FileAnalyzerFactory)}.
 *
 * @throws java.lang.Exception exception
 */
@BeforeAll
public static void setUpBeforeClass() throws Exception {
    factory = new TroffAnalyzerFactory();
    assertNotNull(factory);
    analyzer = new TroffAnalyzer(factory);
    assertNotNull(analyzer);
    repository = new TestRepository();
    repository.create(TroffAnalyzerTest.class.getClassLoader().getResource("sources"));
    String file = System.getProperty("opengrok.test.troff.doc", repository.getSourceRoot() + "/document/foobar.1");
    File f = new File(file);
    assertTrue(f.canRead() && f.isFile(), "troff testfile " + f + " not found");
    CharArrayWriter w = new CharArrayWriter((int) f.length());
    Util.dump(w, f, false);
    content = w.toString();
}
Also used : TestRepository(org.opengrok.indexer.util.TestRepository) File(java.io.File) CharArrayWriter(java.io.CharArrayWriter) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 40 with TestRepository

use of org.opengrok.indexer.util.TestRepository in project OpenGrok by OpenGrok.

the class CxxAnalyzerFactoryTest method setUpClass.

@BeforeAll
public static void setUpClass() throws Exception {
    ctags = new Ctags();
    repository = new TestRepository();
    repository.create(CxxAnalyzerFactoryTest.class.getClassLoader().getResource("sources"));
    CxxAnalyzerFactory analFact = new CxxAnalyzerFactory();
    analyzer = analFact.getAnalyzer();
    RuntimeEnvironment env = RuntimeEnvironment.getInstance();
    if (env.validateUniversalCtags()) {
        analyzer.setCtags(new Ctags());
    }
}
Also used : TestRepository(org.opengrok.indexer.util.TestRepository) RuntimeEnvironment(org.opengrok.indexer.configuration.RuntimeEnvironment) Ctags(org.opengrok.indexer.analysis.Ctags) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

TestRepository (org.opengrok.indexer.util.TestRepository)45 BeforeAll (org.junit.jupiter.api.BeforeAll)26 BeforeEach (org.junit.jupiter.api.BeforeEach)16 HistoryGuru (org.opengrok.indexer.history.HistoryGuru)15 File (java.io.File)14 RuntimeEnvironment (org.opengrok.indexer.configuration.RuntimeEnvironment)10 Ctags (org.opengrok.indexer.analysis.Ctags)6 EnabledForRepository (org.opengrok.indexer.condition.EnabledForRepository)3 Project (org.opengrok.indexer.configuration.Project)3 BufferedWriter (java.io.BufferedWriter)2 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 Test (org.junit.jupiter.api.Test)2 CharArrayWriter (java.io.CharArrayWriter)1 FileReader (java.io.FileReader)1 StringWriter (java.io.StringWriter)1 URL (java.net.URL)1 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1