Code example for FileChannel

Methods: isOpen, size

0
    keystone = loadKeystone(filename, 0);
    assertEquals(value, keystone.get());
 
  } 
 
 
  @Test 
  public void testRoundtrip4() throws IOException { 
    String filename = method(new Object() { });
    long value = 5;
    Keystone keystone = createKeystone(filename, 0, value);
    value = -9;
    keystone.set(value);
    value = 11;
    keystone.set(value);
    keystone = loadKeystone(filename, 0);
    assertEquals(value, keystone.get());
  } 
 
	@Test 
	public void testOldValue() throws IOException { 
		String filename = method(new Object() { });
		long oldvalue = 5;
		Keystone keystone = createKeystone(filename, 0, oldvalue);
		long newvalue = -9;
		assertEquals(oldvalue, keystone.set(newvalue));
	} 
 
 
  @Test 
  public void testIncrement() throws IOException { 
    String filename = method(new Object() { });
    long value = 5;
    Keystone keystone = createKeystone(filename, 0, value);
    assertEquals(value, keystone.get());
 
    long incr = 10;
    value += incr;
    assertEquals(value, keystone.increment(incr));
    assertEquals(value, keystone.get());
 
    keystone = loadKeystone(filename, 0);
    assertEquals(value, keystone.get());
  } 
 
 
  @Test 
  public void testDecrement() throws IOException { 
    String filename = method(new Object() { });