Skip to content
Permalink
Browse files
Troubleshooting
  • Loading branch information
leerho committed Nov 8, 2018
1 parent 1ad5ae5 commit aa54d32e8c31b0b893cd51e2dac559d171b492f8
Showing 4 changed files with 33 additions and 3 deletions.
@@ -255,7 +255,7 @@ static boolean isFileReadOnly(final File file) {
bits |= ((permissions.contains(PosixFilePermission.OTHERS_WRITE)) ? 1 << 1 : 0);
bits |= ((permissions.contains(PosixFilePermission.OTHERS_EXECUTE)) ? 1 : 0);
// Here we are going to ignore the Owner Write & Execute bits to allow root/owner testing.
System.err.println(file.getName() + " : " + Integer.toBinaryString(bits));
//System.err.println(file.getName() + " : " + Integer.toBinaryString(bits));
return ((bits & 0477) == 0444);
}

@@ -11,14 +11,29 @@
import static org.testng.Assert.fail;

import java.io.File;
import java.io.IOException;
import java.nio.ByteOrder;
import java.nio.file.Files;
import java.nio.file.attribute.PosixFilePermissions;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class AllocateDirectMapMemoryTest {
MapHandle hand = null;

@BeforeClass
public void setReadOnly() {
File file =
new File(getClass().getClassLoader().getResource("GettysburgAddress.txt").getFile());
try {
Files.setPosixFilePermissions(file.toPath(), PosixFilePermissions.fromString("rw-r--r--"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}

@Test
public void simpleMap() throws Exception {
File file = new File(getClass().getClassLoader().getResource("GettysburgAddress.txt").getFile());
@@ -37,7 +37,7 @@ public void setReadOnly() {
}
}

//@Test //TODO
@Test
public void simpleMap() throws Exception {
File file =
new File(getClass().getClassLoader().getResource("GettysburgAddress.txt").getFile());
@@ -136,7 +136,7 @@ public void simpleMap2() throws IOException {
}
}

//@Test(expectedExceptions = IllegalArgumentException.class) //TODO
@Test(expectedExceptions = IllegalArgumentException.class)
public void checkOverLength() {
File file =
new File(getClass().getClassLoader().getResource("GettysburgAddress.txt").getFile());
@@ -12,16 +12,31 @@
import static org.testng.Assert.assertTrue;

import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.file.Files;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.List;

import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.testng.collections.Lists;

public class MemoryTest {

@BeforeClass
public void setReadOnly() {
File file =
new File(getClass().getClassLoader().getResource("GettysburgAddress.txt").getFile());
try {
Files.setPosixFilePermissions(file.toPath(), PosixFilePermissions.fromString("rw-r--r--"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}

@Test
public void checkDirectRoundTrip() {
int n = 1024; //longs

0 comments on commit aa54d32

Please sign in to comment.