List of usage examples for org.eclipse.jgit.lib Config fromText
public void fromText(String text) throws ConfigInvalidException
From source file:com.google.gerrit.acceptance.git.SubmoduleSectionParserIT.java
License:Apache License
@Test public void testFollowMasterBranch() throws Exception { Project.NameKey p = createProject("a"); Config cfg = new Config(); cfg.fromText("" + "[submodule \"a\"]\n" + "path = localpath-to-a\n" + "url = ssh://localhost/" + p.get() + "\n" + "branch = master\n"); Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master"); Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch) .parseAllSections();/* ww w . j av a 2 s . c o m*/ Set<SubmoduleSubscription> expected = Sets.newHashSet( new SubmoduleSubscription(targetBranch, new Branch.NameKey(p, "master"), "localpath-to-a")); assertThat(res).containsExactlyElementsIn(expected); }
From source file:com.google.gerrit.acceptance.git.SubmoduleSectionParserIT.java
License:Apache License
@Test public void testFollowMatchingBranch() throws Exception { Project.NameKey p = createProject("a"); Config cfg = new Config(); cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = ssh://localhost/" + p.get() + "\n" + "branch = .\n"); Branch.NameKey targetBranch1 = new Branch.NameKey(new Project.NameKey("project"), "master"); Set<SubmoduleSubscription> res1 = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch1) .parseAllSections();/*from w w w .j a va2 s . c o m*/ Set<SubmoduleSubscription> expected1 = Sets .newHashSet(new SubmoduleSubscription(targetBranch1, new Branch.NameKey(p, "master"), "a")); assertThat(res1).containsExactlyElementsIn(expected1); Branch.NameKey targetBranch2 = new Branch.NameKey(new Project.NameKey("project"), "somebranch"); Set<SubmoduleSubscription> res2 = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch2) .parseAllSections(); Set<SubmoduleSubscription> expected2 = Sets .newHashSet(new SubmoduleSubscription(targetBranch2, new Branch.NameKey(p, "somebranch"), "a")); assertThat(res2).containsExactlyElementsIn(expected2); }
From source file:com.google.gerrit.acceptance.git.SubmoduleSectionParserIT.java
License:Apache License
@Test public void testFollowAnotherBranch() throws Exception { Project.NameKey p = createProject("a"); Config cfg = new Config(); cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = ssh://localhost/" + p.get() + "\n" + "branch = anotherbranch\n"); Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master"); Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch) .parseAllSections();/* www.j a v a2 s. co m*/ Set<SubmoduleSubscription> expected = Sets .newHashSet(new SubmoduleSubscription(targetBranch, new Branch.NameKey(p, "anotherbranch"), "a")); assertThat(res).containsExactlyElementsIn(expected); }
From source file:com.google.gerrit.acceptance.git.SubmoduleSectionParserIT.java
License:Apache License
@Test public void testWithAnotherURI() throws Exception { Project.NameKey p = createProject("a"); Config cfg = new Config(); cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = http://localhost:80/" + p.get() + "\n" + "branch = master\n"); Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master"); Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch) .parseAllSections();/*from w w w . ja va 2 s.c o m*/ Set<SubmoduleSubscription> expected = Sets .newHashSet(new SubmoduleSubscription(targetBranch, new Branch.NameKey(p, "master"), "a")); assertThat(res).containsExactlyElementsIn(expected); }
From source file:com.google.gerrit.acceptance.git.SubmoduleSectionParserIT.java
License:Apache License
@Test public void testWithSlashesInProjectName() throws Exception { Project.NameKey p = createProject("project/with/slashes/a"); Config cfg = new Config(); cfg.fromText("" + "[submodule \"project/with/slashes/a\"]\n" + "path = a\n" + "url = http://localhost:80/" + p.get() + "\n" + "branch = master\n"); Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master"); Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch) .parseAllSections();/* w w w .j a va 2 s . c o m*/ Set<SubmoduleSubscription> expected = Sets .newHashSet(new SubmoduleSubscription(targetBranch, new Branch.NameKey(p, "master"), "a")); assertThat(res).containsExactlyElementsIn(expected); }
From source file:com.google.gerrit.acceptance.git.SubmoduleSectionParserIT.java
License:Apache License
@Test public void testWithSlashesInPath() throws Exception { Project.NameKey p = createProject("a"); Config cfg = new Config(); cfg.fromText("" + "[submodule \"a\"]\n" + "path = a/b/c/d/e\n" + "url = http://localhost:80/" + p.get() + "\n" + "branch = master\n"); Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master"); Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch) .parseAllSections();/*from ww w .ja va 2 s.com*/ Set<SubmoduleSubscription> expected = Sets .newHashSet(new SubmoduleSubscription(targetBranch, new Branch.NameKey(p, "master"), "a/b/c/d/e")); assertThat(res).containsExactlyElementsIn(expected); }
From source file:com.google.gerrit.acceptance.git.SubmoduleSectionParserIT.java
License:Apache License
@Test public void testWithMoreSections() throws Exception { Project.NameKey p1 = createProject("a"); Project.NameKey p2 = createProject("b"); Config cfg = new Config(); cfg.fromText("" + "[submodule \"a\"]\n" + " path = a\n" + " url = ssh://localhost/" + p1.get() + "\n" + " branch = .\n" + "[submodule \"b\"]\n" + " path = b\n" + " url = http://localhost:80/" + p2.get() + "\n" + " branch = master\n"); Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master"); Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch) .parseAllSections();//ww w. ja va 2s . c o m Set<SubmoduleSubscription> expected = Sets.newHashSet( new SubmoduleSubscription(targetBranch, new Branch.NameKey(p1, "master"), "a"), new SubmoduleSubscription(targetBranch, new Branch.NameKey(p2, "master"), "b")); assertThat(res).containsExactlyElementsIn(expected); }
From source file:com.google.gerrit.acceptance.git.SubmoduleSectionParserIT.java
License:Apache License
@Test public void testWithSubProjectFound() throws Exception { Project.NameKey p1 = createProject("a/b"); Project.NameKey p2 = createProject("b"); Config cfg = new Config(); cfg.fromText("\n" + "[submodule \"a/b\"]\n" + "path = a/b\n" + "url = ssh://localhost/" + p1.get() + "\n" + "branch = .\n" + "[submodule \"b\"]\n" + "path = b\n" + "url = http://localhost/" + p2.get() + "\n" + "branch = .\n"); Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master"); Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch) .parseAllSections();/*from w w w. ja va2s .c o m*/ Set<SubmoduleSubscription> expected = Sets.newHashSet( new SubmoduleSubscription(targetBranch, new Branch.NameKey(p2, "master"), "b"), new SubmoduleSubscription(targetBranch, new Branch.NameKey(p1, "master"), "a/b")); assertThat(res).containsExactlyElementsIn(expected); }
From source file:com.google.gerrit.acceptance.git.SubmoduleSectionParserIT.java
License:Apache License
@Test public void testWithAnInvalidSection() throws Exception { Project.NameKey p1 = createProject("a"); Project.NameKey p2 = createProject("b"); Project.NameKey p3 = createProject("d"); Project.NameKey p4 = createProject("e"); Config cfg = new Config(); cfg.fromText("\n" + "[submodule \"a\"]\n" + " path = a\n" + " url = ssh://localhost/" + p1.get() + "\n" + " branch = .\n" + "[submodule \"b\"]\n" // path missing + " url = http://localhost:80/" + p2.get() + "\n" + " branch = master\n" + "[submodule \"c\"]\n" + " path = c\n" // url missing + " branch = .\n" + "[submodule \"d\"]\n" + " path = d-parent/the-d-folder\n" + " url = ssh://localhost/" + p3.get() + "\n" // branch missing + "[submodule \"e\"]\n" + " path = e\n" + " url = ssh://localhost/" + p4.get() + "\n" + " branch = refs/heads/master\n"); Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master"); Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch) .parseAllSections();/*from w ww .j a va2 s .com*/ Set<SubmoduleSubscription> expected = Sets.newHashSet( new SubmoduleSubscription(targetBranch, new Branch.NameKey(p1, "master"), "a"), new SubmoduleSubscription(targetBranch, new Branch.NameKey(p4, "master"), "e")); assertThat(res).containsExactlyElementsIn(expected); }
From source file:com.google.gerrit.acceptance.git.SubmoduleSectionParserIT.java
License:Apache License
@Test public void testWithSectionOfNonexistingProject() throws Exception { Config cfg = new Config(); cfg.fromText("\n" + "[submodule \"a\"]\n" + "path = a\n" + "url = ssh://non-localhost/a\n" // Project "a" doesn't exist + "branch = .\\n"); Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master"); Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch) .parseAllSections();/*from w w w . j a v a 2 s .c o m*/ assertThat(res).isEmpty(); }