Skip to content

Commit 10c2de9

Browse files
Merge branch 'gh-406-umlaut-directory' into dev
2 parents 4bda9ec + b80e379 commit 10c2de9

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

tests/objectbox-java-test/src/test/java/io/objectbox/BoxStoreBuilderTest.java

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,24 @@
2222
import org.junit.Before;
2323
import org.junit.Test;
2424

25-
2625
import java.io.File;
2726
import java.io.FileOutputStream;
2827
import java.io.IOException;
2928
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;
3140
import static org.junit.Assert.assertSame;
3241
import static org.junit.Assert.assertTrue;
3342
import static org.junit.Assert.fail;
34-
import static org.junit.Assert.assertNotNull;
3543

3644
public class BoxStoreBuilderTest extends AbstractObjectBoxTest {
3745

@@ -84,6 +92,35 @@ public void testDefaultStoreNull() {
8492
BoxStore.getDefault();
8593
}
8694

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+
87124
@Test
88125
public void testMaxReaders() {
89126
builder = createBoxStoreBuilder(null);

0 commit comments

Comments
 (0)