View Javadoc
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  
11  package org.eclipse.jgit.lfs.lib;
12  
13  import static java.nio.charset.StandardCharsets.UTF_8;
14  import static org.junit.Assert.assertEquals;
15  
16  import java.io.ByteArrayOutputStream;
17  import java.io.IOException;
18  
19  import org.eclipse.jgit.lfs.LfsPointer;
20  import org.junit.Test;
21  
22  /*
23   * Test LfsPointer file abstraction
24   */
25  public class LFSPointerTest {
26  	@Test
27  	public void testEncoding() throws IOException {
28  		final String s = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
29  		AnyLongObjectId id = LongObjectId.fromString(s);
30  		LfsPointer ptr = new LfsPointer(id, 4);
31  		try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
32  			ptr.encode(baos);
33  			assertEquals(
34  					"version https://git-lfs.github.com/spec/v1\noid sha256:"
35  							+ s + "\nsize 4\n",
36  					baos.toString(UTF_8.name()));
37  		}
38  	}
39  }