builder:{Checkstyle,Readme}WriterTest: use @Rule TemporaryFolder
This commit is contained in:
parent
8696fb10cd
commit
d342495fbd
2 changed files with 18 additions and 5 deletions
|
@ -5,6 +5,7 @@ import me.andrz.builder.map.MapBuilder;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -48,6 +49,9 @@ public class CheckstyleWriterTest {
|
|||
@org.junit.Rule
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@org.junit.Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
@ -61,10 +65,12 @@ public class CheckstyleWriterTest {
|
|||
.put(getOutputFile(RuleLevel.COMPLEXITY))
|
||||
.build();
|
||||
outputProperties.setRulesetFiles(outputFiles);
|
||||
outputDirectory = Files.createTempDirectory("test");
|
||||
outputDirectory = folder.newFolder()
|
||||
.toPath();
|
||||
outputProperties.setDirectory(outputDirectory);
|
||||
templateProperties = new TemplateProperties();
|
||||
checkstyleTemplate = Files.createTempFile("checkstyle-template", ".xml");
|
||||
checkstyleTemplate = folder.newFile("checkstyle-template.xml")
|
||||
.toPath();
|
||||
Files.write(
|
||||
checkstyleTemplate, TEMPLATE.getBytes(StandardCharsets.UTF_8), StandardOpenOption.TRUNCATE_EXISTING);
|
||||
templateProperties.setCheckstyleXml(checkstyleTemplate);
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.kemitix.checkstyle.ruleset.builder;
|
|||
import lombok.val;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
|
@ -42,13 +43,19 @@ public class ReadmeWriterTest {
|
|||
|
||||
private Path readme;
|
||||
|
||||
@org.junit.Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
template = Files.createTempFile("README", ".md");
|
||||
template = folder.newFile("README-template.md")
|
||||
.toPath();
|
||||
Files.write(template, Arrays.asList("i:%s", "ce:%s", "se:%s", "cd:%s", "sd:%s"));
|
||||
fragments = Files.createTempDirectory("fragments");
|
||||
readme = Files.createTempFile("README", ".md");
|
||||
fragments = folder.newFolder("fragments")
|
||||
.toPath();
|
||||
readme = folder.newFile("README.md")
|
||||
.toPath();
|
||||
templateProperties = new TemplateProperties();
|
||||
templateProperties.setReadmeTemplate(template);
|
||||
templateProperties.setReadmeFragments(fragments);
|
||||
|
|
Loading…
Reference in a new issue