You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LFSPointerTest.java 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (C) 2016, Christian Halstrick <christian.halstrick@sap.com> and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.lfs.lib;
  11. import static java.nio.charset.StandardCharsets.UTF_8;
  12. import static org.junit.Assert.assertEquals;
  13. import java.io.ByteArrayOutputStream;
  14. import java.io.IOException;
  15. import org.eclipse.jgit.lfs.LfsPointer;
  16. import org.junit.Test;
  17. /*
  18. * Test LfsPointer file abstraction
  19. */
  20. public class LFSPointerTest {
  21. @Test
  22. public void testEncoding() throws IOException {
  23. final String s = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
  24. AnyLongObjectId id = LongObjectId.fromString(s);
  25. LfsPointer ptr = new LfsPointer(id, 4);
  26. try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
  27. ptr.encode(baos);
  28. assertEquals(
  29. "version https://git-lfs.github.com/spec/v1\noid sha256:"
  30. + s + "\nsize 4\n",
  31. baos.toString(UTF_8.name()));
  32. }
  33. }
  34. }