|
53 | 53 | import java.io.InputStream; |
54 | 54 | import java.nio.file.Files; |
55 | 55 | import java.nio.file.Paths; |
| 56 | +import java.nio.file.StandardCopyOption; |
56 | 57 | import java.text.ParseException; |
57 | 58 | import java.text.SimpleDateFormat; |
58 | 59 | import java.util.*; |
@@ -622,7 +623,7 @@ public void run() { |
622 | 623 | log.error("Error in thread", e); |
623 | 624 | } |
624 | 625 | } |
625 | | - }; |
| 626 | + } |
626 | 627 |
|
627 | 628 | Thread t0 = new Thread(new ThreadRunner()); |
628 | 629 | Thread t1 = new Thread(new ThreadRunner()); |
@@ -682,6 +683,32 @@ public void testReadOnlyMode() { |
682 | 683 | deleteDb(fileName); |
683 | 684 | } |
684 | 685 |
|
| 686 | + @Test |
| 687 | + public void testIssue1162() throws IOException { |
| 688 | + |
| 689 | + // setup no2-v4.3.0.db as a temp file |
| 690 | + var databasePath = Files.createTempFile("temp-no2-v4.3.0", ".db"); |
| 691 | + var templateDb = Objects.requireNonNull(NitriteTest.class.getResourceAsStream("/no2-v4.3.0.db")); |
| 692 | + Files.copy(templateDb, databasePath, StandardCopyOption.REPLACE_EXISTING); |
| 693 | + |
| 694 | + var module = MVStoreModule.withConfig() |
| 695 | + .filePath(databasePath.toAbsolutePath().toFile()) |
| 696 | + .build(); |
| 697 | + |
| 698 | + var database = Nitrite.builder() |
| 699 | + .loadModule(module) |
| 700 | + .openOrCreate(); |
| 701 | + |
| 702 | + try (database) { |
| 703 | + var collection = database.getCollection("myCollection"); |
| 704 | + assertEquals(1, collection.size()); |
| 705 | + |
| 706 | + var firstPerson = collection.find().firstOrNull(); |
| 707 | + assertNotNull(firstPerson); |
| 708 | + assertEquals(1970829645337976832L, firstPerson.getId().getIdValue()); |
| 709 | + } |
| 710 | + } |
| 711 | + |
685 | 712 | @Data |
686 | 713 | @AllArgsConstructor |
687 | 714 | @NoArgsConstructor |
|
0 commit comments