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.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
|
import org.junit.rules.TemporaryFolder;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -48,6 +49,9 @@ public class CheckstyleWriterTest {
|
||||||
@org.junit.Rule
|
@org.junit.Rule
|
||||||
public ExpectedException exception = ExpectedException.none();
|
public ExpectedException exception = ExpectedException.none();
|
||||||
|
|
||||||
|
@org.junit.Rule
|
||||||
|
public TemporaryFolder folder = new TemporaryFolder();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
@ -61,10 +65,12 @@ public class CheckstyleWriterTest {
|
||||||
.put(getOutputFile(RuleLevel.COMPLEXITY))
|
.put(getOutputFile(RuleLevel.COMPLEXITY))
|
||||||
.build();
|
.build();
|
||||||
outputProperties.setRulesetFiles(outputFiles);
|
outputProperties.setRulesetFiles(outputFiles);
|
||||||
outputDirectory = Files.createTempDirectory("test");
|
outputDirectory = folder.newFolder()
|
||||||
|
.toPath();
|
||||||
outputProperties.setDirectory(outputDirectory);
|
outputProperties.setDirectory(outputDirectory);
|
||||||
templateProperties = new TemplateProperties();
|
templateProperties = new TemplateProperties();
|
||||||
checkstyleTemplate = Files.createTempFile("checkstyle-template", ".xml");
|
checkstyleTemplate = folder.newFile("checkstyle-template.xml")
|
||||||
|
.toPath();
|
||||||
Files.write(
|
Files.write(
|
||||||
checkstyleTemplate, TEMPLATE.getBytes(StandardCharsets.UTF_8), StandardOpenOption.TRUNCATE_EXISTING);
|
checkstyleTemplate, TEMPLATE.getBytes(StandardCharsets.UTF_8), StandardOpenOption.TRUNCATE_EXISTING);
|
||||||
templateProperties.setCheckstyleXml(checkstyleTemplate);
|
templateProperties.setCheckstyleXml(checkstyleTemplate);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.kemitix.checkstyle.ruleset.builder;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.TemporaryFolder;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
@ -42,13 +43,19 @@ public class ReadmeWriterTest {
|
||||||
|
|
||||||
private Path readme;
|
private Path readme;
|
||||||
|
|
||||||
|
@org.junit.Rule
|
||||||
|
public TemporaryFolder folder = new TemporaryFolder();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
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"));
|
Files.write(template, Arrays.asList("i:%s", "ce:%s", "se:%s", "cd:%s", "sd:%s"));
|
||||||
fragments = Files.createTempDirectory("fragments");
|
fragments = folder.newFolder("fragments")
|
||||||
readme = Files.createTempFile("README", ".md");
|
.toPath();
|
||||||
|
readme = folder.newFile("README.md")
|
||||||
|
.toPath();
|
||||||
templateProperties = new TemplateProperties();
|
templateProperties = new TemplateProperties();
|
||||||
templateProperties.setReadmeTemplate(template);
|
templateProperties.setReadmeTemplate(template);
|
||||||
templateProperties.setReadmeFragments(fragments);
|
templateProperties.setReadmeFragments(fragments);
|
||||||
|
|
Loading…
Reference in a new issue