|
22 | 22 | import org.junit.Before;
|
23 | 23 | import org.junit.Test;
|
24 | 24 |
|
25 |
| - |
26 | 25 | import java.io.File;
|
27 | 26 | import java.io.FileOutputStream;
|
28 | 27 | import java.io.IOException;
|
29 | 28 | import java.io.InputStream;
|
30 |
| - |
| 29 | +import java.nio.file.Files; |
| 30 | +import java.nio.file.Path; |
| 31 | +import java.util.Collections; |
| 32 | +import java.util.HashSet; |
| 33 | +import java.util.List; |
| 34 | +import java.util.Set; |
| 35 | +import java.util.stream.Collectors; |
| 36 | +import java.util.stream.Stream; |
| 37 | + |
| 38 | +import static org.junit.Assert.assertEquals; |
| 39 | +import static org.junit.Assert.assertNotNull; |
31 | 40 | import static org.junit.Assert.assertSame;
|
32 | 41 | import static org.junit.Assert.assertTrue;
|
33 | 42 | import static org.junit.Assert.fail;
|
34 |
| -import static org.junit.Assert.assertNotNull; |
35 | 43 |
|
36 | 44 | public class BoxStoreBuilderTest extends AbstractObjectBoxTest {
|
37 | 45 |
|
@@ -84,6 +92,35 @@ public void testDefaultStoreNull() {
|
84 | 92 | BoxStore.getDefault();
|
85 | 93 | }
|
86 | 94 |
|
| 95 | + @Test |
| 96 | + public void directoryUnicodePath() throws IOException { |
| 97 | + File parentTestDir = new File("unicode-test"); |
| 98 | + File testDir = new File(parentTestDir, "Îñţérñåţîöñåļîžåţîờñ"); |
| 99 | + builder.directory(testDir); |
| 100 | + BoxStore store = builder.build(); |
| 101 | + store.close(); |
| 102 | + |
| 103 | + // Check only expected files and directories exist. |
| 104 | + // Note: can not compare Path objects, does not appear to work on macOS for unknown reason. |
| 105 | + Set<String> expectedPaths = new HashSet<>(); |
| 106 | + expectedPaths.add(parentTestDir.toPath().toString()); |
| 107 | + expectedPaths.add(testDir.toPath().toString()); |
| 108 | + Path testDirPath = testDir.toPath(); |
| 109 | + expectedPaths.add(testDirPath.resolve("data.mdb").toString()); |
| 110 | + expectedPaths.add(testDirPath.resolve("lock.mdb").toString()); |
| 111 | + try (Stream<Path> files = Files.walk(parentTestDir.toPath())) { |
| 112 | + List<Path> unexpectedPaths = files.filter(path -> !expectedPaths.remove(path.toString())).collect(Collectors.toList()); |
| 113 | + if (!unexpectedPaths.isEmpty()) { |
| 114 | + fail("Found unexpected paths: " + unexpectedPaths); |
| 115 | + } |
| 116 | + if (!expectedPaths.isEmpty()) { |
| 117 | + fail("Missing expected paths: " + expectedPaths); |
| 118 | + } |
| 119 | + } |
| 120 | + |
| 121 | + deleteAllFiles(parentTestDir); |
| 122 | + } |
| 123 | + |
87 | 124 | @Test
|
88 | 125 | public void testMaxReaders() {
|
89 | 126 | builder = createBoxStoreBuilder(null);
|
|
0 commit comments