Package org.eclipse.jgit.lib

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


    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


      assertEquals(MessageFormat.format(
          JGitText.get().largeObjectException, 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(data3.length, ol.getSize());
    assertFalse("is large", ol.isLarge());
    assertNotNull(ol.getCachedBytes());
    assertArrayEquals(data3, ol.getCachedBytes());

    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

    walk.setTreeFilter(AndTreeFilter.create(PathFilterGroup.createFromStrings(Collections.singleton(pattern)), TreeFilter.ANY_DIFF));
    RevCommit revCommit = walk.parseCommit(refId);
    walk.dispose();

    Commit commit = new Commit(null /* not needed */, db, revCommit, pattern);
    ObjectStream stream = commit.toObjectStream();
    if (stream == null) {
      String msg = NLS.bind("Commit body for ref {0} not found", ref);
      return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, msg, null));
    }
    IOUtilities.pipe(stream, response.getOutputStream(), true, false);
View Full Code Here

  }

  private boolean handleGet(HttpServletRequest request, HttpServletResponse response, Repository db, String pattern) throws CoreException, IOException,
      ServletException {
    Index index = new Index(null /* not needed */, db, pattern);
    ObjectStream stream = index.toObjectStream();
    if (stream == null) {
      String msg = NLS.bind("{0} not found in index", pattern); //$NON-NLS-1$
      return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.OK, HttpServletResponse.SC_NOT_FOUND, msg, null));
    }
    IOUtilities.pipe(stream, response.getOutputStream(), true, false);
View Full Code Here

        treeWalk.release();
    }
  }

  private boolean getFileContents(HttpServletRequest request, HttpServletResponse response, Repository repo, TreeWalk treeWalk, RevTree tree) {
    ObjectStream stream = null;
    try {
      ObjectId objId = treeWalk.getObjectId(0);
      ObjectLoader loader = repo.open(objId);
      response.setHeader("Cache-Control", "no-cache"); //$NON-NLS-1$
      response.setHeader("ETag", "\"" + tree.getId().getName() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
      response.setContentType("application/octet-stream"); //$NON-NLS-1$
      stream = loader.openStream();
      IOUtilities.pipe(stream, response.getOutputStream(), true, false);
    } catch (MissingObjectException e) {
    } catch (IOException e) {
    } finally {
      try {
        if (stream != null)
          stream.close();
      } catch (IOException e) {
      }
    }
    return true;
  }
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(data3.length, ol.getSize());
    assertFalse("is large", ol.isLarge());
    assertNotNull(ol.getCachedBytes());
    assertTrue(Arrays.equals(data3, ol.getCachedBytes()));

    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

      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

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.