Search in sources :

Example 1 with FileAnalysisCache

use of net.sourceforge.pmd.cache.FileAnalysisCache in project pmd by pmd.

the class ConfigurationTest method testAnalysisCache.

@Test
public void testAnalysisCache() throws IOException {
    final PMDConfiguration configuration = new PMDConfiguration();
    assertNotNull("Default cache is null", configuration.getAnalysisCache());
    assertTrue("Default cache is not a noop", configuration.getAnalysisCache() instanceof NoopAnalysisCache);
    configuration.setAnalysisCache(null);
    assertNotNull("Default cache was set to null", configuration.getAnalysisCache());
    final File cacheFile = File.createTempFile("pmd-", ".cache");
    cacheFile.deleteOnExit();
    final FileAnalysisCache analysisCache = new FileAnalysisCache(cacheFile);
    configuration.setAnalysisCache(analysisCache);
    assertSame("Confgured cache not stored", analysisCache, configuration.getAnalysisCache());
}
Also used : FileAnalysisCache(net.sourceforge.pmd.cache.FileAnalysisCache) NoopAnalysisCache(net.sourceforge.pmd.cache.NoopAnalysisCache) File(java.io.File) Test(org.junit.Test)

Example 2 with FileAnalysisCache

use of net.sourceforge.pmd.cache.FileAnalysisCache in project pmd by pmd.

the class ConfigurationTest method testIgnoreIncrementalAnalysis.

@Test
public void testIgnoreIncrementalAnalysis() throws IOException {
    final PMDConfiguration configuration = new PMDConfiguration();
    // set dummy cache location
    final File cacheFile = File.createTempFile("pmd-", ".cache");
    cacheFile.deleteOnExit();
    final FileAnalysisCache analysisCache = new FileAnalysisCache(cacheFile);
    configuration.setAnalysisCache(analysisCache);
    assertNotNull("Null cache location accepted", configuration.getAnalysisCache());
    assertFalse("Non null cache location, cache should not be noop", configuration.getAnalysisCache() instanceof NoopAnalysisCache);
    configuration.setIgnoreIncrementalAnalysis(true);
    assertTrue("Ignoring incremental analysis should turn the cache into a noop", configuration.getAnalysisCache() instanceof NoopAnalysisCache);
}
Also used : FileAnalysisCache(net.sourceforge.pmd.cache.FileAnalysisCache) NoopAnalysisCache(net.sourceforge.pmd.cache.NoopAnalysisCache) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)2 FileAnalysisCache (net.sourceforge.pmd.cache.FileAnalysisCache)2 NoopAnalysisCache (net.sourceforge.pmd.cache.NoopAnalysisCache)2 Test (org.junit.Test)2