View Javadoc
1   /*
2    * Copyright (C) 2016, Google Inc. 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.storage.file;
12  
13  import static org.junit.Assert.assertEquals;
14  import static org.junit.Assert.assertNull;
15  
16  import java.io.File;
17  import java.io.IOException;
18  
19  import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
20  import org.eclipse.jgit.lib.Repository;
21  import org.junit.Test;
22  
23  /** Test managing the gitweb description file. */
24  public class DescriptionTest extends LocalDiskRepositoryTestCase {
25  	private static final String UNCONFIGURED = "Unnamed repository; edit this file to name it for gitweb.";
26  
27  	@Test
28  	public void description() throws IOException {
29  		Repository git = createBareRepository();
30  		File path = new File(git.getDirectory(), "description");
31  		assertNull("description", git.getGitwebDescription());
32  
33  		String desc = "a test repo\nfor jgit";
34  		git.setGitwebDescription(desc);
35  		assertEquals(desc + '\n', read(path));
36  		assertEquals(desc, git.getGitwebDescription());
37  
38  		git.setGitwebDescription(null);
39  		assertEquals("", read(path));
40  
41  		desc = "foo";
42  		git.setGitwebDescription(desc);
43  		assertEquals(desc + '\n', read(path));
44  		assertEquals(desc, git.getGitwebDescription());
45  
46  		git.setGitwebDescription("");
47  		assertEquals("", read(path));
48  
49  		git.setGitwebDescription(UNCONFIGURED);
50  		assertEquals(UNCONFIGURED + '\n', read(path));
51  		assertNull("description", git.getGitwebDescription());
52  	}
53  }