long expiration = timeout == -1 ? Long.MAX_VALUE : System.currentTimeMillis() + timeout; Ref dataRef = new Ref (recid, expiration);
@Test public void testRefSerializeThrowsClassCastException() throws Throwable { try { new JDBMSpace.Ref(100L, 1000L).serialize(Integer.valueOf(0)); fail("Expected ClassCastException to be thrown"); } catch (ClassCastException ex) { assertEquals("ex.getClass()", ClassCastException.class, ex.getClass()); } }
Ref dataRef = new Ref (recid, expiration); long dataRefRecId = recman.insert (dataRef, refSerializer);
@Test public void testRefDeserializeThrowsArrayIndexOutOfBoundsException2() throws Throwable { JDBMSpace.Ref ref = new JDBMSpace.Ref(100L, 1000L); byte[] serialized = new byte[2]; try { ref.deserialize(serialized); fail("Expected ArrayIndexOutOfBoundsException to be thrown"); } catch (ArrayIndexOutOfBoundsException ex) { assertEquals("ex.getMessage()", "7", ex.getMessage()); assertEquals("ref.recid", 100L, ref.recid); assertEquals("ref.expires", 1000L, ref.expires); assertEquals("ref.next", -1L, ref.next); } }
@Test public void testRefDeserializeThrowsNullPointerException() throws Throwable { JDBMSpace.Ref ref = new JDBMSpace.Ref(100L, 1000L); try { ref.deserialize(null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertEquals("ref.recid", 100L, ref.recid); assertEquals("ref.expires", 1000L, ref.expires); assertEquals("ref.next", -1L, ref.next); } }
@Test public void testRefToString() throws Throwable { new JDBMSpace.Ref(100L, 1000L).toString(); assertTrue("Test completed without Exception", true); } }
@Test public void testRefSerialize() throws Throwable { JDBMSpace.Ref ref = new JDBMSpace.Ref(100L, 1000L); byte[] result = ref.serialize(new JDBMSpace.Ref(1000L, 0L)); assertEquals("result.length", 24, result.length); assertEquals("result[0]", (byte) 0, result[0]); }
@Test public void testRefConstructor() throws Throwable { JDBMSpace.Ref ref = new JDBMSpace.Ref(100L, 1000L); assertEquals("ref.recid", 100L, ref.recid); assertEquals("ref.next", -1L, ref.next); assertEquals("ref.expires", 1000L, ref.expires); }
@Test public void testGetLong1() throws Throwable { long result = JDBMSpace.getLong(new JDBMSpace.Ref(100L, 1000L).serialize(new JDBMSpace.Ref()), 0); assertEquals("result", 0L, result); }
public Object deserialize (byte[] serialized) throws IOException { Ref d = new Ref (); d.recid = getLong (serialized, 0); d.next = getLong (serialized, 8); d.expires = getLong (serialized, 16); return d; } }
@Test public void testRefIsExpired() throws Throwable { long expirytime = System.currentTimeMillis() + 365 * 24 * 60 * 60 * 1000; boolean result = new JDBMSpace.Ref(100L, expirytime).isExpired(); assertFalse("result", result); }
@Test public void testRefIsExpired1() throws Throwable { boolean result = new JDBMSpace.Ref(100L, 1000L).isExpired(); assertTrue("result", result); }
@Test public void testRefDeserialize() throws Throwable { JDBMSpace.Ref ref = new JDBMSpace.Ref(); byte[] serialized = new byte[26]; JDBMSpace.Ref result = (JDBMSpace.Ref) ref.deserialize(serialized); assertTrue("result.isExpired()", result.isExpired()); assertEquals("ref.recid", 0L, ref.recid); assertEquals("ref.expires", 0L, ref.expires); assertEquals("ref.next", 0L, ref.next); }
@Test public void testRefSerializeThrowsNullPointerException() throws Throwable { try { new JDBMSpace.Ref().serialize(null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
@Test public void testRefConstructor1() throws Throwable { JDBMSpace.Ref ref = new JDBMSpace.Ref(); assertTrue("ref.isExpired()", ref.isExpired()); }