Exemplo n.º 1
0
  public void testSimpleRoundWithEntriesTrip(
      int baseOffsetSize, int indexSize, int lengthSize, int offsetSize) throws IOException {
    ItemLocationBox ilocOrig = new ItemLocationBox();
    ilocOrig.setVersion(1);
    ilocOrig.setBaseOffsetSize(baseOffsetSize);
    ilocOrig.setIndexSize(indexSize);
    ilocOrig.setLengthSize(lengthSize);
    ilocOrig.setOffsetSize(offsetSize);
    ItemLocationBox.Item item =
        ilocOrig.createItem(12, 0, 13, 123, Collections.<ItemLocationBox.Extent>emptyList());
    ilocOrig.setItems(Collections.singletonList(item));
    ByteBuffer bb = ByteBuffer.allocate(l2i(ilocOrig.getSize()));
    ilocOrig.getBox(new ByteBufferByteChannel(bb));

    bb.rewind();

    IsoFile isoFile = new IsoFile(new ByteBufferByteChannel(bb));

    ItemLocationBox iloc = (ItemLocationBox) isoFile.getBoxes().get(0);

    Assert.assertEquals(ilocOrig.getBaseOffsetSize(), iloc.getBaseOffsetSize());
    Assert.assertEquals(ilocOrig.getContentSize(), iloc.getContentSize());
    Assert.assertEquals(ilocOrig.getIndexSize(), iloc.getIndexSize());
    Assert.assertEquals(ilocOrig.getLengthSize(), iloc.getLengthSize());
    Assert.assertEquals(ilocOrig.getOffsetSize(), iloc.getOffsetSize());
    Assert.assertEquals(ilocOrig.getItems(), iloc.getItems());
  }
Exemplo n.º 2
0
  public void testExtent(int a, int b, int c, int d) throws IOException {
    ItemLocationBox iloc = new ItemLocationBox();
    iloc.setVersion(1);
    iloc.setBaseOffsetSize(a);
    iloc.setIndexSize(b);
    iloc.setLengthSize(c);
    iloc.setOffsetSize(d);
    ItemLocationBox.Extent e1 = iloc.createExtent(123, 124, 125);
    ByteBuffer bb = ByteBuffer.allocate(e1.getSize());
    e1.getContent(bb);
    Assert.assertTrue(bb.remaining() == 0);
    bb.rewind();
    ItemLocationBox.Extent e2 = iloc.createExtent(bb);

    Assert.assertEquals(e1, e2);
  }
Exemplo n.º 3
0
  public void testItemVersionZero(int a, int b, int c, int d) throws IOException {
    ItemLocationBox iloc = new ItemLocationBox();
    iloc.setVersion(0);
    iloc.setBaseOffsetSize(a);
    iloc.setIndexSize(b);
    iloc.setLengthSize(c);
    iloc.setOffsetSize(d);
    ItemLocationBox.Item e1 =
        iloc.createItem(65, 0, 1, 66, Collections.<ItemLocationBox.Extent>emptyList());
    ByteBuffer bb = ByteBuffer.allocate(e1.getSize());
    e1.getContent(bb);
    Assert.assertTrue(bb.remaining() == 0);
    bb.rewind();
    ItemLocationBox.Item e2 = iloc.createItem(bb);

    Assert.assertEquals(e1, e2);
  }
Exemplo n.º 4
0
  public void testSimpleRoundTrip(int baseOffsetSize, int indexSize, int lengthSize, int offsetSize)
      throws IOException {
    ItemLocationBox ilocOrig = new ItemLocationBox();
    ilocOrig.setVersion(1);
    ilocOrig.setBaseOffsetSize(baseOffsetSize);
    ilocOrig.setIndexSize(indexSize);
    ilocOrig.setLengthSize(lengthSize);
    ilocOrig.setOffsetSize(offsetSize);
    ByteBuffer bb = ByteBuffer.allocate(l2i(ilocOrig.getSize()));
    ilocOrig.getBox(new ByteBufferByteChannel(bb));
    Assert.assertTrue(bb.remaining() == 0);
    bb.rewind();

    IsoFile isoFile = new IsoFile(new ByteBufferByteChannel(bb));

    ItemLocationBox iloc = (ItemLocationBox) isoFile.getBoxes().get(0);

    Assert.assertEquals(ilocOrig.getBaseOffsetSize(), iloc.getBaseOffsetSize());
    Assert.assertEquals(ilocOrig.getContentSize(), iloc.getContentSize());
    Assert.assertEquals(ilocOrig.getIndexSize(), iloc.getIndexSize());
    Assert.assertEquals(ilocOrig.getLengthSize(), iloc.getLengthSize());
    Assert.assertEquals(ilocOrig.getOffsetSize(), iloc.getOffsetSize());
    Assert.assertEquals(ilocOrig.getItems(), iloc.getItems());
  }