@@ -66,19 +66,15 @@ public class BorderTest extends ExtendedITextTest {
66
66
public static final String destinationFolder = TestUtil .getOutputPath () + "/layout/BorderTest/" ;
67
67
public static final String cmpPrefix = "cmp_" ;
68
68
69
- String fileName ;
70
- String outFileName ;
71
- String cmpFileName ;
72
-
73
69
@ BeforeAll
74
70
public static void beforeClass () {
75
71
createDestinationFolder (destinationFolder );
76
72
}
77
73
78
74
@ Test
79
75
public void simpleBordersTest () throws IOException , InterruptedException {
80
- fileName = "simpleBordersTest.pdf" ;
81
- Document doc = createDocument ();
76
+ String fileName = "simpleBordersTest.pdf" ;
77
+ Document doc = createDocument (fileName );
82
78
83
79
List list = new List ();
84
80
@@ -109,7 +105,7 @@ public void simpleBordersTest() throws IOException, InterruptedException {
109
105
110
106
doc .add (list );
111
107
112
- closeDocumentAndCompareOutputs (doc );
108
+ closeDocumentAndCompareOutputs (doc , fileName );
113
109
}
114
110
115
111
@ Test
@@ -137,8 +133,8 @@ public void drawBordersByRectangleTest() throws IOException, InterruptedExceptio
137
133
138
134
@ Test
139
135
public void borders3DTest () throws IOException , InterruptedException {
140
- fileName = "borders3DTest.pdf" ;
141
- Document doc = createDocument ();
136
+ String fileName = "borders3DTest.pdf" ;
137
+ Document doc = createDocument (fileName );
142
138
143
139
List list = new List ();
144
140
@@ -213,13 +209,13 @@ public void borders3DTest() throws IOException, InterruptedException {
213
209
214
210
doc .add (list );
215
211
216
- closeDocumentAndCompareOutputs (doc );
212
+ closeDocumentAndCompareOutputs (doc , fileName );
217
213
}
218
214
219
215
@ Test
220
216
public void borderSidesTest () throws IOException , InterruptedException {
221
- fileName = "borderSidesTest.pdf" ;
222
- Document doc = createDocument ();
217
+ String fileName = "borderSidesTest.pdf" ;
218
+ Document doc = createDocument (fileName );
223
219
224
220
String text =
225
221
"<p class=\" none\" >No border.</p>\n " +
@@ -247,13 +243,13 @@ public void borderSidesTest() throws IOException, InterruptedException {
247
243
doc .add (new Paragraph (text ).setBorderLeft (new DashedBorder (DeviceGray .BLACK , 5 )));
248
244
doc .add (new Paragraph (text ).setBorder (new DottedBorder (DeviceGray .BLACK , 1 )));
249
245
250
- closeDocumentAndCompareOutputs (doc );
246
+ closeDocumentAndCompareOutputs (doc , fileName );
251
247
}
252
248
253
249
@ Test
254
250
public void borderBoxTest () throws IOException , InterruptedException {
255
- fileName = "borderBoxTest.pdf" ;
256
- Document doc = createDocument ();
251
+ String fileName = "borderBoxTest.pdf" ;
252
+ Document doc = createDocument (fileName );
257
253
258
254
String textBefore = "At the mid-oceanic ridges, two tectonic plates diverge from one another as new oceanic crust is formed by the cooling and " +
259
255
"solidifying of hot molten rock. Because the crust is very thin at these ridges due to the pull of the tectonic plates, the release of " +
@@ -288,13 +284,13 @@ public void borderBoxTest() throws IOException, InterruptedException {
288
284
289
285
doc .add (new Paragraph (textAfter ).setBorder (new DottedBorder (ColorConstants .BLACK , 3 )).setBorderRight (new DottedBorder (ColorConstants .BLACK , 12 )));
290
286
291
- closeDocumentAndCompareOutputs (doc );
287
+ closeDocumentAndCompareOutputs (doc , fileName );
292
288
}
293
289
294
290
@ Test
295
291
public void borderOutlineTest () throws IOException , InterruptedException {
296
- fileName = "borderOutlineTest.pdf" ;
297
- Document doc = createDocument ();
292
+ String fileName = "borderOutlineTest.pdf" ;
293
+ Document doc = createDocument (fileName );
298
294
299
295
String textBefore = "At the mid-oceanic ridges, two tectonic plates diverge from one another as new oceanic crust is formed by the cooling and " +
300
296
"solidifying of hot molten rock. Because the crust is very thin at these ridges due to the pull of the tectonic plates, the release of " +
@@ -320,15 +316,15 @@ public void borderOutlineTest() throws IOException, InterruptedException {
320
316
p .setProperty (Property .OUTLINE , new DoubleBorder (ColorConstants .RED , 25 ));
321
317
doc .add (p );
322
318
323
- closeDocumentAndCompareOutputs (doc );
319
+ closeDocumentAndCompareOutputs (doc , fileName );
324
320
}
325
321
@ Test
326
322
@ LogMessages (messages = {
327
323
@ LogMessage (messageTemplate = LayoutLogMessageConstant .ELEMENT_DOES_NOT_FIT_AREA , count = 1 )
328
324
})
329
325
public void rotatedBordersTest () throws IOException , InterruptedException {
330
- fileName = "rotatedBordersTest.pdf" ;
331
- Document doc = createDocument ();
326
+ String fileName = "rotatedBordersTest.pdf" ;
327
+ Document doc = createDocument (fileName );
332
328
doc .setMargins (0 , 0 , 0 , 0 );
333
329
334
330
Paragraph p = new Paragraph ("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.\n " +
@@ -343,19 +339,19 @@ public void rotatedBordersTest() throws IOException, InterruptedException {
343
339
doc .add (img );
344
340
doc .close ();
345
341
346
- closeDocumentAndCompareOutputs (doc );
342
+ closeDocumentAndCompareOutputs (doc , fileName );
347
343
}
348
344
349
- private Document createDocument () throws IOException {
350
- outFileName = destinationFolder + fileName ;
351
- cmpFileName = sourceFolder + cmpPrefix + fileName ;
352
-
345
+ private static Document createDocument (String fileName ) throws IOException {
346
+ String outFileName = destinationFolder + fileName ;
353
347
PdfDocument pdfDocument = new PdfDocument (new PdfWriter (outFileName ));
354
348
355
349
return new Document (pdfDocument );
356
350
}
357
351
358
- private void closeDocumentAndCompareOutputs (Document document ) throws IOException , InterruptedException {
352
+ private static void closeDocumentAndCompareOutputs (Document document , String fileName ) throws IOException , InterruptedException {
353
+ String cmpFileName = sourceFolder + cmpPrefix + fileName ;
354
+ String outFileName = destinationFolder + fileName ;
359
355
document .close ();
360
356
String compareResult = new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , "diff" );
361
357
if (compareResult != null ) {
0 commit comments