use of org.junit.jupiter.api.io.TempDir in project sonarlint-core by SonarSource.
the class ConnectedIssueExclusionsMediumTests method prepare.
@BeforeAll
static void prepare(@TempDir Path slHome) throws Exception {
var storage = newStorage(SERVER_ID).withJavaPlugin().withProject("test-project").withProject(JAVA_MODULE_KEY, project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule("java:S106", "MAJOR").withActiveRule("java:S1220", "MINOR").withActiveRule("java:S1481", "BLOCKER"))).create(slHome);
projectStorage = storage.getProjectStorages().get(1);
var config = ConnectedGlobalConfiguration.builder().setConnectionId(SERVER_ID).setSonarLintUserHome(slHome).setStorageRoot(storage.getPath()).setLogOutput(createNoOpLogOutput()).addEnabledLanguage(Language.JAVA).build();
sonarlint = new ConnectedSonarLintEngineImpl(config);
}
use of org.junit.jupiter.api.io.TempDir in project janusgraph by JanusGraph.
the class BerkeleyTransactionTest method longRunningTxShouldBeRolledBack.
@Test
void longRunningTxShouldBeRolledBack(@TempDir File dir) throws InterruptedException {
JanusGraph graph = JanusGraphFactory.open("berkeleyje:" + dir.getAbsolutePath());
GraphTraversalSource traversal = graph.traversal();
for (int i = 0; i < 10; i++) {
traversal.addV().property("a", "2").next();
}
traversal.tx().commit();
GraphTraversalSource g = graph.tx().createThreadedTx().traversal();
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
g.V().has("a", "2").sideEffect(ignored -> {
try {
// artificially slow down the traversal execution so that
// this test has a chance to interrupt it before it finishes
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}).toList();
});
Thread.sleep(100);
g.tx().rollback();
graph.close();
assertThrows(ExecutionException.class, future::get);
}
use of org.junit.jupiter.api.io.TempDir in project sonarlint-core by SonarSource.
the class ConnectedStorageProblemsMediumTests method corrupted_plugin_should_not_prevent_startup.
@Test
void corrupted_plugin_should_not_prevent_startup(@TempDir Path slHome, @TempDir Path baseDir) throws Exception {
var storageId = "localhost";
var storage = newStorage(storageId).withJSPlugin().withJavaPlugin().create(slHome);
var cachedJSPlugin = storage.getPluginPaths().get(0);
FileUtils.write(cachedJSPlugin.toFile(), "corrupted jar", StandardCharsets.UTF_8);
List<String> logs = new CopyOnWriteArrayList<>();
var config = ConnectedGlobalConfiguration.builder().setConnectionId(storageId).setSonarLintUserHome(slHome).setStorageRoot(storage.getPath()).setLogOutput((m, l) -> logs.add(m)).addEnabledLanguage(Language.JAVA).addEnabledLanguage(Language.JS).build();
sonarlint = new ConnectedSonarLintEngineImpl(config);
assertThat(logs).contains("Unable to load plugin " + cachedJSPlugin);
var inputFile = prepareJavaInputFile(baseDir);
final List<Issue> issues = new ArrayList<>();
sonarlint.analyze(ConnectedAnalysisConfiguration.builder().setProjectKey(null).setBaseDir(baseDir).addInputFile(inputFile).build(), issues::add, null, null);
assertThat(logs).contains("Execute Sensor: JavaSquidSensor");
}
use of org.junit.jupiter.api.io.TempDir in project sonarlint-core by SonarSource.
the class ConnectedStorageProblemsMediumTests method test_stale_storage.
@Test
void test_stale_storage(@TempDir Path slHome, @TempDir Path baseDir) {
var storageId = "localhost";
newStorage(storageId).stale().create(slHome);
var config = ConnectedGlobalConfiguration.builder().setConnectionId(storageId).setSonarLintUserHome(slHome).setLogOutput((msg, level) -> {
}).build();
sonarlint = new ConnectedSonarLintEngineImpl(config);
assertThat(sonarlint.getGlobalStorageStatus().isStale()).isTrue();
assertThat(sonarlint.getProjectStorageStatus("foo")).isNull();
assertThat(sonarlint.allProjectsByKey()).isEmpty();
var thrown = assertThrows(IllegalStateException.class, () -> sonarlint.getActiveRuleDetails(null, null, "rule", null));
assertThat(thrown).hasMessage("Unable to find rule details for 'rule'");
var analysisConfig = ConnectedAnalysisConfiguration.builder().setBaseDir(baseDir).build();
var thrown2 = assertThrows(StorageException.class, () -> sonarlint.analyze(analysisConfig, i -> {
}, null, null));
assertThat(thrown2).hasMessage("Outdated storage for connection");
}
use of org.junit.jupiter.api.io.TempDir in project sonarlint-core by SonarSource.
the class ConnectedIssueMediumTests method prepare.
@BeforeAll
static void prepare(@TempDir Path slHome) throws Exception {
var storage = newStorage(SERVER_ID).withJSPlugin().withJavaPlugin().withProject("test-project").withProject(JAVA_MODULE_KEY, project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule("java:S106", "MAJOR").withActiveRule("java:S1220", "MINOR").withActiveRule("java:S1481", "BLOCKER"))).withProject("stale_module", ProjectStorageFixture.ProjectStorageBuilder::stale).create(slHome);
var nodeJsHelper = new NodeJsHelper();
nodeJsHelper.detect(null);
var config = ConnectedGlobalConfiguration.builder().setConnectionId(SERVER_ID).setSonarLintUserHome(slHome).setStorageRoot(storage.getPath()).setLogOutput(createNoOpLogOutput()).addEnabledLanguages(Language.JAVA, Language.JS).setNodeJs(nodeJsHelper.getNodeJsPath(), nodeJsHelper.getNodeJsVersion()).setModulesProvider(() -> List.of(new ClientModuleInfo("key", mock(ClientModuleFileSystem.class)))).build();
sonarlint = new ConnectedSonarLintEngineImpl(config);
}
Aggregations