You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2020/10/19 06:21:05 UTC
svn commit: r1882632 -
/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/io/RandomAccessReadMemoryMappedFileTest.java
Author: lehmi
Date: Mon Oct 19 06:21:05 2020
New Revision: 1882632
URL: http://svn.apache.org/viewvc?rev=1882632&view=rev
Log:
PDFBOX-4855: add a test for the unmapping issue limited to windows environments
Modified:
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/io/RandomAccessReadMemoryMappedFileTest.java
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/io/RandomAccessReadMemoryMappedFileTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/io/RandomAccessReadMemoryMappedFileTest.java?rev=1882632&r1=1882631&r2=1882632&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/io/RandomAccessReadMemoryMappedFileTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/io/RandomAccessReadMemoryMappedFileTest.java Mon Oct 19 06:21:05 2020
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 The Apache Software Foundation.
+ * Copyright 2020 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,9 +21,13 @@ import static org.junit.Assert.assertFal
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
import org.junit.Test;
@@ -163,4 +167,22 @@ public class RandomAccessReadMemoryMappe
randomAccessSource.close();
}
+ @Test
+ public void testUnmapping() throws IOException
+ {
+ // This is a special test case for some unmapping issues limited to windows enviroments
+ // see https://bugs.openjdk.java.net/browse/JDK-4724038
+ Path tempFile = Files.createTempFile("PDFBOX", "txt");
+ BufferedWriter bufferedWriter = Files.newBufferedWriter(tempFile, StandardOpenOption.WRITE);
+ bufferedWriter.write("Apache PDFBox test");
+ bufferedWriter.close();
+
+ RandomAccessRead randomAccessSource = new RandomAccessReadMemoryMappedFile(
+ tempFile.toFile());
+ assertEquals(65, randomAccessSource.read());
+ randomAccessSource.close();
+
+ Files.delete(tempFile);
+ }
+
}