Skip to content

Commit 3fad9dc

Browse files
committed
PDFBOX-5660: move test to existing class
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1931344 13f79535-47bb-0310-9956-ffa450edef68
1 parent e7bf9ec commit 3fad9dc

File tree

2 files changed

+29
-34
lines changed

2 files changed

+29
-34
lines changed

examples/src/test/java/org/apache/pdfbox/examples/pdmodel/ExtractEmbeddedFilesTest.java

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,11 @@
1515
*/
1616
package org.apache.pdfbox.examples.pdmodel;
1717

18-
import java.io.File;
19-
import java.io.IOException;
20-
import java.nio.charset.StandardCharsets;
21-
import java.nio.file.Files;
22-
import java.nio.file.Paths;
23-
import static org.junit.jupiter.api.Assertions.assertEquals;
24-
import org.junit.jupiter.api.Test;
25-
2618
/**
2719
*
2820
* @author Tilman Hausherr
2921
*/
3022
class ExtractEmbeddedFilesTest
3123
{
32-
/**
33-
* Test that the correct attachments are extracted from a portable collection.
34-
*
35-
* @throws IOException
36-
*/
37-
@Test
38-
void testExtractEmbeddedFiles() throws IOException
39-
{
40-
String dir = "target/test-output";
41-
new File(dir).mkdirs();
42-
String collectionFilename = dir + "/PortableCollection.pdf";
43-
String attachment1Filename = dir + "/Test1.txt";
44-
String attachment2Filename = dir + "/Test2.txt";
45-
String[] args = new String[] { collectionFilename };
46-
CreatePortableCollection.main(args);
47-
ExtractEmbeddedFiles.main(args);
48-
byte[] ba1 = Files.readAllBytes(new File(attachment1Filename).toPath());
49-
byte[] ba2 = Files.readAllBytes(new File(attachment2Filename).toPath());
50-
String s1 = new String(ba1, StandardCharsets.US_ASCII);
51-
String s2 = new String(ba2, StandardCharsets.US_ASCII);
52-
assertEquals("This is the contents of the first embedded file", s1);
53-
assertEquals("This is the contents of the second embedded file", s2);
54-
Files.delete(Paths.get(collectionFilename));
55-
Files.delete(Paths.get(attachment1Filename));
56-
Files.delete(Paths.get(attachment2Filename));
57-
}
24+
5825
}

examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestEmbeddedFiles.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.nio.file.Paths;
2424

2525
import org.junit.jupiter.api.Assertions;
26+
import static org.junit.jupiter.api.Assertions.assertEquals;
2627
import org.junit.jupiter.api.Test;
2728

2829
/**
@@ -54,4 +55,31 @@ void testEmbeddedFiles() throws IOException
5455
new File(embeddedFile).delete();
5556
new File(outputFile).delete();
5657
}
58+
59+
/**
60+
* Test that the correct attachments are extracted from a portable collection.
61+
*
62+
* @throws IOException
63+
*/
64+
@Test
65+
void testExtractEmbeddedFiles() throws IOException
66+
{
67+
String dir = "target/test-output";
68+
new File(dir).mkdirs();
69+
String collectionFilename = dir + "/PortableCollection.pdf";
70+
String attachment1Filename = dir + "/Test1.txt";
71+
String attachment2Filename = dir + "/Test2.txt";
72+
String[] args = new String[] { collectionFilename };
73+
CreatePortableCollection.main(args);
74+
ExtractEmbeddedFiles.main(args);
75+
byte[] ba1 = Files.readAllBytes(new File(attachment1Filename).toPath());
76+
byte[] ba2 = Files.readAllBytes(new File(attachment2Filename).toPath());
77+
String s1 = new String(ba1, StandardCharsets.US_ASCII);
78+
String s2 = new String(ba2, StandardCharsets.US_ASCII);
79+
assertEquals("This is the contents of the first embedded file", s1);
80+
assertEquals("This is the contents of the second embedded file", s2);
81+
Files.delete(Paths.get(collectionFilename));
82+
Files.delete(Paths.get(attachment1Filename));
83+
Files.delete(Paths.get(attachment2Filename));
84+
}
5785
}

0 commit comments

Comments
 (0)