Package org.entityfs.util.io

Examples of org.entityfs.util.io.ByteArrayRandomAccess


  @Test
  public void testReadLong()
  {
    byte[] barr = LongSerializer.INSTANCE.serialize(0L);
    assertEquals(0L, LongSerializer.INSTANCE.readLong(new ByteArrayInputStream(barr)).longValue());
    assertEquals(0L, LongSerializer.INSTANCE.readLong(new ByteArrayRandomAccess(barr)).longValue());
    barr = LongSerializer.INSTANCE.serialize(1L);
    assertEquals(1L, LongSerializer.INSTANCE.readLong(new ByteArrayInputStream(barr)).longValue());
    assertEquals(1L, LongSerializer.INSTANCE.readLong(new ByteArrayRandomAccess(barr)).longValue());
    barr = LongSerializer.INSTANCE.serialize(-1L);
    assertEquals(-1L, LongSerializer.INSTANCE.readLong(new ByteArrayInputStream(barr)).longValue());
    assertEquals(-1L, LongSerializer.INSTANCE.readLong(new ByteArrayRandomAccess(barr)).longValue());
    barr = LongSerializer.INSTANCE.serialize(Long.MAX_VALUE);
    assertEquals(Long.MAX_VALUE, LongSerializer.INSTANCE.readLong(new ByteArrayInputStream(barr)).longValue());
    assertEquals(Long.MAX_VALUE, LongSerializer.INSTANCE.readLong(new ByteArrayRandomAccess(barr)).longValue());
    barr = LongSerializer.INSTANCE.serialize(Long.MIN_VALUE);
    assertEquals(Long.MIN_VALUE, LongSerializer.INSTANCE.readLong(new ByteArrayInputStream(barr)).longValue());
    assertEquals(Long.MIN_VALUE, LongSerializer.INSTANCE.readLong(new ByteArrayRandomAccess(barr)).longValue());
  }
View Full Code Here


  public void testReadBigInteger()
  {
    FixedSizeBigIntegerSerializer s = new FixedSizeBigIntegerSerializer(2);
    byte[] barr = s.serialize(BigInteger.ZERO);
    assertEquals(0, s.readBigInteger(new ByteArrayInputStream(barr)).intValue());
    assertEquals(0, s.readBigInteger(new ByteArrayRandomAccess(barr)).intValue());
    barr = s.serialize(BigInteger.ONE);
    assertEquals(1, s.readBigInteger(new ByteArrayInputStream(barr)).intValue());
    assertEquals(1, s.readBigInteger(new ByteArrayRandomAccess(barr)).intValue());
    barr = s.serialize(BigInteger.valueOf(127));
    assertEquals(127, s.readBigInteger(new ByteArrayInputStream(barr)).intValue());
    assertEquals(127, s.readBigInteger(new ByteArrayRandomAccess(barr)).intValue());
    barr = s.serialize(BigInteger.valueOf(-128));
    assertEquals(-128, s.readBigInteger(new ByteArrayInputStream(barr)).intValue());
    assertEquals(-128, s.readBigInteger(new ByteArrayRandomAccess(barr)).intValue());
  }
View Full Code Here

  public void testReadInteger()
  {
    ConfigurableLengthIntegerSerializer s = new ConfigurableLengthIntegerSerializer(1);
    byte[] barr = s.serialize(0);
    assertEquals(0, s.readInteger(new ByteArrayInputStream(barr)).intValue());
    assertEquals(0, s.readInteger(new ByteArrayRandomAccess(barr)).intValue());
    barr = s.serialize(1);
    assertEquals(1, s.readInteger(new ByteArrayInputStream(barr)).intValue());
    assertEquals(1, s.readInteger(new ByteArrayRandomAccess(barr)).intValue());
    barr = s.serialize(255);
    assertEquals(255, s.readInteger(new ByteArrayInputStream(barr)).intValue());
    assertEquals(255, s.readInteger(new ByteArrayRandomAccess(barr)).intValue());
  }
View Full Code Here

  @Test
  public void testReadInteger()
  {
    byte[] barr = IntegerNullSerializer.INSTANCE.serialize(null);
    assertNull(IntegerNullSerializer.INSTANCE.readInteger(new ByteArrayInputStream(barr)));
    assertNull(IntegerNullSerializer.INSTANCE.readInteger(new ByteArrayRandomAccess(barr)));
    barr = IntegerNullSerializer.INSTANCE.serialize(0);
    assertEquals(0, IntegerNullSerializer.INSTANCE.readInteger(new ByteArrayInputStream(barr)).intValue());
    assertEquals(0, IntegerNullSerializer.INSTANCE.readInteger(new ByteArrayRandomAccess(barr)).intValue());
    barr = IntegerNullSerializer.INSTANCE.serialize(1);
    assertEquals(1, IntegerNullSerializer.INSTANCE.readInteger(new ByteArrayInputStream(barr)).intValue());
    assertEquals(1, IntegerNullSerializer.INSTANCE.readInteger(new ByteArrayRandomAccess(barr)).intValue());
    barr = IntegerNullSerializer.INSTANCE.serialize(-1);
    assertEquals(-1, IntegerNullSerializer.INSTANCE.readInteger(new ByteArrayInputStream(barr)).intValue());
    assertEquals(-1, IntegerNullSerializer.INSTANCE.readInteger(new ByteArrayRandomAccess(barr)).intValue());
    barr = IntegerNullSerializer.INSTANCE.serialize(Integer.MAX_VALUE);
    assertEquals(Integer.MAX_VALUE, IntegerNullSerializer.INSTANCE.readInteger(new ByteArrayInputStream(barr)).intValue());
    assertEquals(Integer.MAX_VALUE, IntegerNullSerializer.INSTANCE.readInteger(new ByteArrayRandomAccess(barr)).intValue());
    barr = IntegerNullSerializer.INSTANCE.serialize(Integer.MIN_VALUE + 1);
    assertEquals(Integer.MIN_VALUE + 1, IntegerNullSerializer.INSTANCE.readInteger(new ByteArrayInputStream(barr)).intValue());
    assertEquals(Integer.MIN_VALUE + 1, IntegerNullSerializer.INSTANCE.readInteger(new ByteArrayRandomAccess(barr)).intValue());
  }
View Full Code Here

  @Test
  public void testReadShort()
  {
    byte[] barr = ShortNullSerializer.INSTANCE.serialize(null);
    assertNull(ShortNullSerializer.INSTANCE.readShort(new ByteArrayInputStream(barr)));
    assertNull(ShortNullSerializer.INSTANCE.readShort(new ByteArrayRandomAccess(barr)));
    barr = ShortNullSerializer.INSTANCE.serialize((short) 0);
    assertEquals(0, ShortNullSerializer.INSTANCE.readShort(new ByteArrayInputStream(barr)).shortValue());
    assertEquals(0, ShortNullSerializer.INSTANCE.readShort(new ByteArrayRandomAccess(barr)).shortValue());
    barr = ShortNullSerializer.INSTANCE.serialize((short) 1);
    assertEquals(1, ShortNullSerializer.INSTANCE.readShort(new ByteArrayInputStream(barr)).shortValue());
    assertEquals(1, ShortNullSerializer.INSTANCE.readShort(new ByteArrayRandomAccess(barr)).shortValue());
    barr = ShortNullSerializer.INSTANCE.serialize((short) -1);
    assertEquals(-1, ShortNullSerializer.INSTANCE.readShort(new ByteArrayInputStream(barr)).shortValue());
    assertEquals(-1, ShortNullSerializer.INSTANCE.readShort(new ByteArrayRandomAccess(barr)).shortValue());
    barr = ShortNullSerializer.INSTANCE.serialize(Short.MAX_VALUE);
    assertEquals(Short.MAX_VALUE, ShortNullSerializer.INSTANCE.readShort(new ByteArrayInputStream(barr)).shortValue());
    assertEquals(Short.MAX_VALUE, ShortNullSerializer.INSTANCE.readShort(new ByteArrayRandomAccess(barr)).shortValue());
    barr = ShortNullSerializer.INSTANCE.serialize((short) (Short.MIN_VALUE + 1));
    assertEquals(Short.MIN_VALUE + 1, ShortNullSerializer.INSTANCE.readShort(new ByteArrayInputStream(barr)).shortValue());
    assertEquals(Short.MIN_VALUE + 1, ShortNullSerializer.INSTANCE.readShort(new ByteArrayRandomAccess(barr)).shortValue());
  }
View Full Code Here

  @Test
  public void testReadFloat()
  {
    byte[] barr = FloatSerializer.INSTANCE.serialize(0.0f);
    assertEquals(0.0f, FloatSerializer.INSTANCE.readFloat(new ByteArrayInputStream(barr)).floatValue(), 0.00001f);
    assertEquals(0.0f, FloatSerializer.INSTANCE.readFloat(new ByteArrayRandomAccess(barr)).floatValue(), 0.00001f);
    barr = FloatSerializer.INSTANCE.serialize(1.0f);
    assertEquals(1.0f, FloatSerializer.INSTANCE.readFloat(new ByteArrayInputStream(barr)).floatValue(), 0.00001f);
    assertEquals(1.0f, FloatSerializer.INSTANCE.readFloat(new ByteArrayRandomAccess(barr)).floatValue(), 0.00001f);
    barr = FloatSerializer.INSTANCE.serialize(-1.2034f);
    assertEquals(-1.2034f, FloatSerializer.INSTANCE.readFloat(new ByteArrayInputStream(barr)).floatValue(), 0.00001f);
    assertEquals(-1.2034f, FloatSerializer.INSTANCE.readFloat(new ByteArrayRandomAccess(barr)).floatValue(), 0.00001f);
    barr = FloatSerializer.INSTANCE.serialize(Float.MAX_VALUE);
    assertEquals(Float.MAX_VALUE, FloatSerializer.INSTANCE.readFloat(new ByteArrayInputStream(barr)).floatValue(), 0.00001f);
    assertEquals(Float.MAX_VALUE, FloatSerializer.INSTANCE.readFloat(new ByteArrayRandomAccess(barr)).floatValue(), 0.00001f);
    barr = FloatSerializer.INSTANCE.serialize(Float.MIN_VALUE);
    assertEquals(Float.MIN_VALUE, FloatSerializer.INSTANCE.readFloat(new ByteArrayInputStream(barr)).floatValue(), 0.00001f);
    assertEquals(Float.MIN_VALUE, FloatSerializer.INSTANCE.readFloat(new ByteArrayRandomAccess(barr)).floatValue(), 0.00001f);
  }
View Full Code Here

  @Test
  public void testReadCharacter()
  {
    byte[] barr = CharacterNullSerializer.INSTANCE.serialize(null);
    assertNull(CharacterNullSerializer.INSTANCE.readCharacter(new ByteArrayInputStream(barr)));
    assertNull(CharacterNullSerializer.INSTANCE.readCharacter(new ByteArrayRandomAccess(barr)));
    barr = CharacterNullSerializer.INSTANCE.serialize('a');
    assertEquals('a', CharacterNullSerializer.INSTANCE.readCharacter(new ByteArrayInputStream(barr)).charValue());
    assertEquals('a', CharacterNullSerializer.INSTANCE.readCharacter(new ByteArrayRandomAccess(barr)).charValue());
    barr = CharacterNullSerializer.INSTANCE.serialize('ä');
    assertEquals('ä', CharacterNullSerializer.INSTANCE.readCharacter(new ByteArrayInputStream(barr)).charValue());
    assertEquals('ä', CharacterNullSerializer.INSTANCE.readCharacter(new ByteArrayRandomAccess(barr)).charValue());
  }
View Full Code Here

  @Test
  public void testReadShort()
  {
    byte[] barr = ShortSerializer.INSTANCE.serialize((short) 0);
    assertEquals(0, ShortSerializer.INSTANCE.readShort(new ByteArrayInputStream(barr)).shortValue());
    assertEquals(0, ShortSerializer.INSTANCE.readShort(new ByteArrayRandomAccess(barr)).shortValue());
    barr = ShortSerializer.INSTANCE.serialize((short) 1);
    assertEquals(1, ShortSerializer.INSTANCE.readShort(new ByteArrayInputStream(barr)).shortValue());
    assertEquals(1, ShortSerializer.INSTANCE.readShort(new ByteArrayRandomAccess(barr)).shortValue());
    barr = ShortSerializer.INSTANCE.serialize((short) -1);
    assertEquals(-1, ShortSerializer.INSTANCE.readShort(new ByteArrayInputStream(barr)).shortValue());
    assertEquals(-1, ShortSerializer.INSTANCE.readShort(new ByteArrayRandomAccess(barr)).shortValue());
    barr = ShortSerializer.INSTANCE.serialize(Short.MAX_VALUE);
    assertEquals(Short.MAX_VALUE, ShortSerializer.INSTANCE.readShort(new ByteArrayInputStream(barr)).shortValue());
    assertEquals(Short.MAX_VALUE, ShortSerializer.INSTANCE.readShort(new ByteArrayRandomAccess(barr)).shortValue());
    barr = ShortSerializer.INSTANCE.serialize(Short.MIN_VALUE);
    assertEquals(Short.MIN_VALUE, ShortSerializer.INSTANCE.readShort(new ByteArrayInputStream(barr)).shortValue());
    assertEquals(Short.MIN_VALUE, ShortSerializer.INSTANCE.readShort(new ByteArrayRandomAccess(barr)).shortValue());
  }
View Full Code Here

  @Test
  public void testReadLong()
  {
    byte[] barr = LongNullSerializer.INSTANCE.serialize(null);
    assertNull(LongNullSerializer.INSTANCE.readLong(new ByteArrayInputStream(barr)));
    assertNull(LongNullSerializer.INSTANCE.readLong(new ByteArrayRandomAccess(barr)));
    barr = LongNullSerializer.INSTANCE.serialize(0L);
    assertEquals(0L, LongNullSerializer.INSTANCE.readLong(new ByteArrayInputStream(barr)).longValue());
    assertEquals(0L, LongNullSerializer.INSTANCE.readLong(new ByteArrayRandomAccess(barr)).longValue());
    barr = LongNullSerializer.INSTANCE.serialize(1L);
    assertEquals(1L, LongNullSerializer.INSTANCE.readLong(new ByteArrayInputStream(barr)).longValue());
    assertEquals(1L, LongNullSerializer.INSTANCE.readLong(new ByteArrayRandomAccess(barr)).longValue());
    barr = LongNullSerializer.INSTANCE.serialize(-1L);
    assertEquals(-1L, LongNullSerializer.INSTANCE.readLong(new ByteArrayInputStream(barr)).longValue());
    assertEquals(-1L, LongNullSerializer.INSTANCE.readLong(new ByteArrayRandomAccess(barr)).longValue());
    barr = LongNullSerializer.INSTANCE.serialize(Long.MAX_VALUE);
    assertEquals(Long.MAX_VALUE, LongNullSerializer.INSTANCE.readLong(new ByteArrayInputStream(barr)).longValue());
    assertEquals(Long.MAX_VALUE, LongNullSerializer.INSTANCE.readLong(new ByteArrayRandomAccess(barr)).longValue());
    barr = LongNullSerializer.INSTANCE.serialize(Long.MIN_VALUE + 1);
    assertEquals(Long.MIN_VALUE + 1, LongNullSerializer.INSTANCE.readLong(new ByteArrayInputStream(barr)).longValue());
    assertEquals(Long.MIN_VALUE + 1, LongNullSerializer.INSTANCE.readLong(new ByteArrayRandomAccess(barr)).longValue());
  }
View Full Code Here

  @Test
  public void testReadCharacter()
  {
    byte[] barr = CharacterSerializer.INSTANCE.serialize('\0');
    assertEquals('\0', CharacterSerializer.INSTANCE.readCharacter(new ByteArrayInputStream(barr)).charValue());
    assertEquals('\0', CharacterSerializer.INSTANCE.readCharacter(new ByteArrayRandomAccess(barr)).charValue());
    barr = CharacterSerializer.INSTANCE.serialize('A');
    assertEquals('A', CharacterSerializer.INSTANCE.readCharacter(new ByteArrayInputStream(barr)).charValue());
    assertEquals('A', CharacterSerializer.INSTANCE.readCharacter(new ByteArrayRandomAccess(barr)).charValue());
    barr = CharacterSerializer.INSTANCE.serialize('ö');
    assertEquals('ö', CharacterSerializer.INSTANCE.readCharacter(new ByteArrayInputStream(barr)).charValue());
    assertEquals('ö', CharacterSerializer.INSTANCE.readCharacter(new ByteArrayRandomAccess(barr)).charValue());
  }
View Full Code Here

TOP

Related Classes of org.entityfs.util.io.ByteArrayRandomAccess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.