List of usage examples for org.apache.cassandra.io.util RandomAccessReader getPath
public String getPath()
From source file:com.fullcontact.cassandra.io.util.BufferedRandomAccessFileTest.java
License:Apache License
@Test public void testBytesPastMark() throws IOException { File tmpFile = File.createTempFile("overflowtest", "bin"); tmpFile.deleteOnExit();/*from w w w . j a v a 2 s. c om*/ // Create the BRAF by filename instead of by file. final RandomAccessReader r = RandomAccessReader.open(new Path(new File(tmpFile.getPath()).getPath()), fs); assert tmpFile.getPath().equals(r.getPath()); // Create a mark and move the rw there. final FileMark mark = r.mark(); r.reset(mark); // Expect this call to succeed. r.bytesPastMark(mark); }
From source file:com.fullcontact.cassandra.io.util.BufferedRandomAccessFileTest.java
License:Apache License
@Test public void testClose() throws IOException { final SequentialWriter w = createTempFile("brafClose"); byte[] data = generateByteArray(RandomAccessReader.DEFAULT_BUFFER_SIZE + 20); w.write(data);/*w w w . j a va2 s .co m*/ w.close(); // will flush final RandomAccessReader r = RandomAccessReader.open(new Path(new File(w.getPath()).getPath()), fs); r.close(); // closing to test read after close expectException(new Callable<Object>() { public Object call() { return r.read(); } }, AssertionError.class); expectException(new Callable<Object>() { public Object call() throws IOException { w.write(generateByteArray(1)); return null; } }, ClosedChannelException.class); RandomAccessReader copy = RandomAccessReader.open(new Path(new File(r.getPath()).getPath()), fs); ByteBuffer contents = copy.readBytes((int) copy.length()); assertEquals(contents.limit(), data.length); assertEquals(ByteBufferUtil.compare(contents, data), 0); }