26
26
import java .nio .charset .StandardCharsets ;
27
27
import java .nio .file .Files ;
28
28
import java .nio .file .Path ;
29
+ import java .nio .file .Paths ;
29
30
import java .util .HashMap ;
30
31
import java .util .List ;
31
32
import java .util .Map ;
@@ -78,27 +79,37 @@ public class JavadocReportTest extends AbstractMojoTestCase {
78
79
79
80
public static final String OPTIONS_UMLAUT_ENCODING = "Options Umlaut Encoding ö ä ü ß" ;
80
81
81
- /** flag to copy repo only one time */
82
- private static boolean TEST_REPO_CREATED = false ;
83
-
84
82
private Path unit ;
85
83
86
84
private File localRepo ;
87
85
88
86
private static final Logger LOGGER = LoggerFactory .getLogger (JavadocReportTest .class );
89
87
90
- /** {@inheritDoc} */
91
88
@ Override
92
89
protected void setUp () throws Exception {
93
90
super .setUp ();
94
91
92
+ Path tempDirectory = Files .createTempDirectory ("JavadocReportTest" );
93
+ localRepo = tempDirectory .resolve (Paths .get ("target/local-repo/" )).toFile ();
95
94
unit = new File (getBasedir (), "src/test/resources/unit" ).toPath ();
96
95
97
- localRepo = new File (getBasedir (), "target/local-repo/" );
98
-
99
96
createTestRepo ();
100
97
}
101
98
99
+ @ Override
100
+ protected void tearDown () throws Exception {
101
+ try {
102
+ deleteDirectory (localRepo );
103
+ } catch (IOException ex ) {
104
+ // CI servers can have problems deleting files.
105
+ // It will get cleared out eventually, and since
106
+ // temporary directories have unique names,
107
+ // it shouldn't affect subsequent tests.
108
+ }
109
+
110
+ super .tearDown ();
111
+ }
112
+
102
113
private JavadocReport lookupMojo (Path testPom ) throws Exception {
103
114
JavadocReport mojo = (JavadocReport ) lookupMojo ("javadoc" , testPom .toFile ());
104
115
@@ -122,11 +133,7 @@ private JavadocReport lookupMojo(Path testPom) throws Exception {
122
133
* @throws IOException if any
123
134
*/
124
135
private void createTestRepo () throws IOException {
125
- if (TEST_REPO_CREATED ) {
126
- return ;
127
- }
128
-
129
- localRepo .mkdirs ();
136
+ assertTrue (localRepo .mkdirs ());
130
137
131
138
// ----------------------------------------------------------------------
132
139
// UMLGraph
@@ -146,7 +153,7 @@ private void createTestRepo() throws IOException {
146
153
147
154
// ----------------------------------------------------------------------
148
155
// commons-attributes-compiler
149
- // http ://www.tullmann.org/pat/taglets/
156
+ // https ://www.tullmann.org/pat/taglets/
150
157
// ----------------------------------------------------------------------
151
158
152
159
sourceDir = unit .resolve ("taglet-test/artifact-taglet" );
@@ -181,8 +188,6 @@ private void createTestRepo() throws IOException {
181
188
file .delete ();
182
189
}
183
190
}
184
-
185
- TEST_REPO_CREATED = true ;
186
191
}
187
192
188
193
/**
0 commit comments