4
4
import java .util .*;
5
5
6
6
import org .junit .Assert ;
7
+ import org .junit .BeforeClass ;
8
+ import org .junit .Rule ;
7
9
import org .junit .Test ;
10
+ import org .junit .rules .TemporaryFolder ;
8
11
9
12
import io .ipfs .multiaddr .MultiAddress ;
10
13
11
14
public class RecursiveAddTest {
12
15
13
16
private final IPFS ipfs = new IPFS (new MultiAddress ("/ip4/127.0.0.1/tcp/5001" ));
14
17
15
- static Path TMPDATA = Paths .get ("target/tmpdata" );
18
+ static File TMPDATA = new File ("target/tmpdata" );
19
+
20
+ @ BeforeClass
21
+ public static void createTmpData () {
22
+ TMPDATA .mkdirs ();
23
+ }
24
+
25
+ @ Rule
26
+ public TemporaryFolder tempFolder = new TemporaryFolder (TMPDATA );
16
27
17
28
@ Test
18
29
public void testAdd () throws Exception {
19
30
System .out .println ("ipfs version: " + ipfs .version ());
20
31
21
32
String EXPECTED = "QmX5fZ6aUxNTAS7ZfYc8f4wPoMx6LctuNbMjuJZ9EmUSr6" ;
22
33
23
- Path base = Files . createTempDirectory ( "test" );
34
+ Path base = tempFolder . newFolder (). toPath ( );
24
35
Files .write (base .resolve ("index.html" ), "<html></html>" .getBytes ());
25
36
Path js = base .resolve ("js" );
26
37
js .toFile ().mkdirs ();
@@ -35,7 +46,7 @@ public void testAdd() throws Exception {
35
46
public void binaryRecursiveAdd () throws Exception {
36
47
String EXPECTED = "Qmd1dTx4Z1PHxSHDR9jYoyLJTrYsAau7zLPE3kqo14s84d" ;
37
48
38
- Path base = TMPDATA . resolve ( "bindata" );
49
+ Path base = tempFolder . newFolder (). toPath ( );
39
50
base .toFile ().mkdirs ();
40
51
byte [] bindata = new byte [1024 *1024 ];
41
52
new Random (28 ).nextBytes (bindata );
@@ -53,7 +64,7 @@ public void binaryRecursiveAdd() throws Exception {
53
64
public void largeBinaryRecursiveAdd () throws Exception {
54
65
String EXPECTED = "QmZdfdj7nfxE68fBPUWAGrffGL3sYGx1MDEozMg73uD2wj" ;
55
66
56
- Path base = TMPDATA . resolve ( "largebindata" );
67
+ Path base = tempFolder . newFolder (). toPath ( );
57
68
base .toFile ().mkdirs ();
58
69
byte [] bindata = new byte [100 * 1024 *1024 ];
59
70
new Random (28 ).nextBytes (bindata );
@@ -73,7 +84,7 @@ public void largeBinaryRecursiveAdd() throws Exception {
73
84
public void largeBinaryInSubdirRecursiveAdd () throws Exception {
74
85
String EXPECTED = "QmUYuMwCpgaxJhNxRA5Pmje8EfpEgU3eQSB9t3VngbxYJk" ;
75
86
76
- Path base = TMPDATA . resolve ( "largebininsubdirdata" );
87
+ Path base = tempFolder . newFolder (). toPath ( );
77
88
base .toFile ().mkdirs ();
78
89
Path bindir = base .resolve ("moredata" );
79
90
bindir .toFile ().mkdirs ();
0 commit comments