Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.ObjectStream$SmallStream


      fail("Should have thrown LargeObjectException");
    } catch (LargeObjectException tooBig) {
      assertEquals(id3.name(), tooBig.getMessage());
    }

    ObjectStream in = ol.openStream();
    assertNotNull("have stream", in);
    assertEquals(Constants.OBJ_BLOB, in.getType());
    assertEquals(data3.length, in.getSize());
    byte[] act = new byte[data3.length];
    IO.readFully(in, act, 0, data3.length);
    assertTrue("same content", Arrays.equals(act, data3));
    assertEquals("stream at EOF", -1, in.read());
    in.close();
  }
View Full Code Here


    assertEquals(type, ol.getType());
    assertEquals(data.length, ol.getSize());
    assertFalse("is not large", ol.isLarge());
    assertTrue("same content", Arrays.equals(data, ol.getCachedBytes()));

    ObjectStream in = ol.openStream();
    assertNotNull("have stream", in);
    assertEquals(type, in.getType());
    assertEquals(data.length, in.getSize());
    byte[] data2 = new byte[data.length];
    IO.readFully(in, data2, 0, data.length);
    assertTrue("same content", Arrays.equals(data2, data));
    assertEquals("stream at EOF", -1, in.read());
    in.close();
  }
View Full Code Here

      fail("Should have thrown LargeObjectException");
    } catch (LargeObjectException tooBig) {
      assertEquals(id.name(), tooBig.getMessage());
    }

    ObjectStream in = ol.openStream();
    assertNotNull("have stream", in);
    assertEquals(type, in.getType());
    assertEquals(data.length, in.getSize());
    byte[] data2 = new byte[data.length];
    IO.readFully(in, data2, 0, data.length);
    assertTrue("same content", Arrays.equals(data2, data));
    assertEquals("stream at EOF", -1, in.read());
    in.close();
  }
View Full Code Here

    assertEquals(type, ol.getType());
    assertEquals(data.length, ol.getSize());
    assertFalse("is not large", ol.isLarge());
    assertTrue("same content", Arrays.equals(data, ol.getCachedBytes()));

    ObjectStream in = ol.openStream();
    assertNotNull("have stream", in);
    assertEquals(type, in.getType());
    assertEquals(data.length, in.getSize());
    byte[] data2 = new byte[data.length];
    IO.readFully(in, data2, 0, data.length);
    assertTrue("same content", Arrays.equals(data, ol.getCachedBytes()));
    in.close();
  }
View Full Code Here

      fail("Should have thrown LargeObjectException");
    } catch (LargeObjectException tooBig) {
      assertEquals(id.name(), tooBig.getMessage());
    }

    ObjectStream in = ol.openStream();
    assertNotNull("have stream", in);
    assertEquals(type, in.getType());
    assertEquals(data.length, in.getSize());
    byte[] data2 = new byte[data.length];
    IO.readFully(in, data2, 0, data.length);
    assertTrue("same content", Arrays.equals(data2, data));
    assertEquals("stream at EOF", -1, in.read());
    in.close();
  }
View Full Code Here

    fileSize = size;
  }

  void hash(ObjectLoader obj) throws MissingObjectException, IOException {
    if (obj.isLarge()) {
      ObjectStream in = obj.openStream();
      try {
        setFileSize(in.getSize());
        hash(in, fileSize);
      } finally {
        in.close();
      }
    } else {
      byte[] raw = obj.getCachedBytes();
      setFileSize(raw.length);
      hash(raw, 0, raw.length);
View Full Code Here

      if (info.type != Constants.OBJ_BLOB)
        throw new IOException(MessageFormat.format(
            JGitText.get().unknownObjectType,
            Integer.valueOf(info.type)));

      ObjectStream cur = readCurs.open(obj, info.type).openStream();
      try {
        long sz = info.size;
        if (cur.getSize() != sz)
          throw new IOException(MessageFormat.format(
              JGitText.get().collisionOn, obj.name()));
        InputStream pck = inflate(Source.DATABASE, sz);
        while (0 < sz) {
          int n = (int) Math.min(readBuffer.length, sz);
          IO.readFully(cur, curBuffer, 0, n);
          IO.readFully(pck, readBuffer, 0, n);
          for (int i = 0; i < n; i++) {
            if (curBuffer[i] != readBuffer[i])
              throw new IOException(MessageFormat.format(JGitText
                  .get().collisionOn, obj.name()));
          }
          sz -= n;
        }
        pck.close();
      } finally {
        cur.close();
      }
    }
  }
View Full Code Here

      if (info.type != Constants.OBJ_BLOB)
        throw new IOException(MessageFormat.format(
            JGitText.get().unknownObjectType,
            Integer.valueOf(info.type)));

      ObjectStream cur = readCurs.open(obj, info.type).openStream();
      try {
        long sz = info.size;
        if (cur.getSize() != sz)
          throw new IOException(MessageFormat.format(
              JGitText.get().collisionOn, obj.name()));
        InputStream pck = inflate(Source.DATABASE, sz);
        while (0 < sz) {
          int n = (int) Math.min(readBuffer.length, sz);
          IO.readFully(cur, curBuffer, 0, n);
          IO.readFully(pck, readBuffer, 0, n);
          for (int i = 0; i < n; i++) {
            if (curBuffer[i] != readBuffer[i])
              throw new IOException(MessageFormat.format(JGitText
                  .get().collisionOn, obj.name()));
          }
          sz -= n;
        }
        pck.close();
      } finally {
        cur.close();
      }
    }
  }
View Full Code Here

      if (info.type != Constants.OBJ_BLOB)
        throw new IOException(MessageFormat.format(
            JGitText.get().unknownObjectType,
            Integer.valueOf(info.type)));

      ObjectStream cur = readCurs.open(obj, info.type).openStream();
      try {
        long sz = info.size;
        if (cur.getSize() != sz)
          throw new IOException(MessageFormat.format(
              JGitText.get().collisionOn, obj.name()));
        InputStream pck = inflate(Source.DATABASE, sz);
        while (0 < sz) {
          int n = (int) Math.min(readBuffer.length, sz);
          IO.readFully(cur, curBuffer, 0, n);
          IO.readFully(pck, readBuffer, 0, n);
          for (int i = 0; i < n; i++) {
            if (curBuffer[i] != readBuffer[i])
              throw new IOException(MessageFormat.format(JGitText
                  .get().collisionOn, obj.name()));
          }
          sz -= n;
        }
        pck.close();
      } finally {
        cur.close();
      }
    }
  }
View Full Code Here

      if (info.type != Constants.OBJ_BLOB)
        throw new IOException(MessageFormat.format(
            JGitText.get().unknownObjectType,
            Integer.valueOf(info.type)));

      ObjectStream cur = readCurs.open(obj, info.type).openStream();
      try {
        long sz = info.size;
        if (cur.getSize() != sz)
          throw new IOException(MessageFormat.format(
              JGitText.get().collisionOn, obj.name()));
        InputStream pck = inflate(Source.DATABASE, sz);
        while (0 < sz) {
          int n = (int) Math.min(readBuffer.length, sz);
          IO.readFully(cur, curBuffer, 0, n);
          IO.readFully(pck, readBuffer, 0, n);
          for (int i = 0; i < n; i++) {
            if (curBuffer[i] != readBuffer[i])
              throw new IOException(MessageFormat.format(JGitText
                  .get().collisionOn, obj.name()));
          }
          sz -= n;
        }
        pck.close();
      } finally {
        cur.close();
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.ObjectStream$SmallStream

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.