View Javadoc
1   /*
2    * Copyright (C) 2022, Google LLC. 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.internal.transport.parser;
12  
13  import static org.junit.Assert.assertEquals;
14  import static org.junit.Assert.assertTrue;
15  
16  import java.util.Map;
17  
18  import org.junit.Test;
19  
20  public class FirstCommandTest {
21  	@Test
22  	public void testClientSID() {
23  		String oldStr = "0000000000000000000000000000000000000000";
24  		String newStr = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
25  		String refName = "refs/heads/master";
26  		String command = oldStr + " " + newStr + " " + refName;
27  		String fl = command + "\0"
28  				+ "some capabilities session-id=the-clients-SID and more unknownCap=some-value";
29  		FirstCommand fc = FirstCommand.fromLine(fl);
30  
31  		Map<String, String> options = fc.getCapabilities();
32  
33  		assertEquals("the-clients-SID", options.get("session-id"));
34  		assertEquals(command, fc.getLine());
35  		assertTrue(options.containsKey("unknownCap"));
36  		assertEquals(6, options.size());
37  	}
38  }