Skip to content

Commit

Permalink
replace TemporaryFolder rule
Browse files Browse the repository at this point in the history
  • Loading branch information
signed committed Dec 30, 2018
1 parent 6dcfb6e commit 7a3d8cb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
4 changes: 4 additions & 0 deletions javaparser-symbol-solver-testing/pom.xml
Expand Up @@ -121,6 +121,10 @@
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
</dependency>
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
</dependency>
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-symbol-solver-logic</artifactId>
Expand Down
Expand Up @@ -6,22 +6,21 @@
import com.github.javaparser.symbolsolver.model.resolution.SymbolReference;
import com.github.javaparser.symbolsolver.utils.LeanParserConfiguration;
import com.github.javaparser.utils.CodeGenerationUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junitpioneer.jupiter.TempDirectory;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class JavaParserTypeSolverTest {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
class JavaParserTypeSolverTest {

@Test
public void containsLocationInStorage() {
void containsLocationInStorage() {
JavaParserTypeSolver typeSolver = new JavaParserTypeSolver(CodeGenerationUtils.mavenModuleRoot(JavaParserTypeSolver.class).resolve("src/main/java"), new LeanParserConfiguration());

SymbolReference<ResolvedReferenceTypeDeclaration> x = typeSolver.tryToSolveType("com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver");
Expand All @@ -32,15 +31,13 @@ public void containsLocationInStorage() {
}

@Test
public void folderTraversalDoesNotKeepFolderHandlesHostage() throws IOException {
File folder = new File(temporaryFolder.getRoot(), "folder");
@ExtendWith(TempDirectory.class)
void folderTraversalDoesNotKeepFolderHandlesHostage(@TempDirectory.TempDir Path tempDir) throws IOException {
File folder = tempDir.resolve("folder").toFile();
assertTrue(folder.mkdirs());
File testJava = new File(folder, "Test.java");
assertTrue(testJava.createNewFile());
JavaParserTypeSolver typeSolver = new JavaParserTypeSolver(folder.getParentFile());
typeSolver.tryToSolveType("folder.Test");
assertTrue(testJava.delete());
assertTrue(folder.delete());
assertTrue(folder.getParentFile().delete());
}
}
6 changes: 6 additions & 0 deletions pom.xml
Expand Up @@ -334,6 +334,12 @@
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
<version>0.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down

0 comments on commit 7a3d8cb

Please sign in to comment.