diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2010-12-31 11:44:54 +0100 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-12-31 14:00:05 -0800 |
commit | d9e07a574a946693e491668e0d94619bc5d886a5 (patch) | |
tree | 5bce4e9d47090d6b427986de4db30be17cc99c6d /org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java | |
parent | 7cf8b8812f7baa1636c138113f4ed015eed8cc31 (diff) | |
download | jgit-d9e07a574a946693e491668e0d94619bc5d886a5.tar.gz jgit-d9e07a574a946693e491668e0d94619bc5d886a5.zip |
Convert all JGit unit tests to JUnit 4
Eclipse has some problem re-running single JUnit tests if
the tests are in Junit 3 format, but the JUnit 4 launcher
is used. This was quite unnecessary and the move was not
completed. We still have no JUnit4 test.
This completes the extermination of JUnit3. Most of the
work was global searce/replace using regular expression,
followed by numerous invocarions of quick-fix and organize
imports and verification that we had the same number of
tests before and after.
- Annotations were introduced.
- All references to JUnit3 classes removed
- Half-good replacement for getting the test name. This was
needed to make the TestRngs work. The initialization of
TestRngs was also made lazily since we can not longer find
out the test name in runtime in the @Before methods.
- Renamed test classes to end with Test, with the exception
of TestTranslateBundle, which fails from Maven
- Moved JGitTestUtil to the junit support bundle
Change-Id: Iddcd3da6ca927a7be773a9c63ebf8bb2147e2d13
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java index f66e2fd33e..966cd98127 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java @@ -43,6 +43,10 @@ package org.eclipse.jgit.transport; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -50,6 +54,8 @@ import java.io.OutputStreamWriter; import org.eclipse.jgit.lib.RepositoryTestCase; import org.eclipse.jgit.transport.OpenSshConfig.Host; +import org.junit.Before; +import org.junit.Test; public class OpenSshConfigTest extends RepositoryTestCase { private File home; @@ -58,6 +64,7 @@ public class OpenSshConfigTest extends RepositoryTestCase { private OpenSshConfig osc; + @Before public void setUp() throws Exception { super.setUp(); @@ -78,6 +85,7 @@ public class OpenSshConfigTest extends RepositoryTestCase { fw.close(); } + @Test public void testNoConfig() { final Host h = osc.lookup("repo.or.cz"); assertNotNull(h); @@ -87,6 +95,7 @@ public class OpenSshConfigTest extends RepositoryTestCase { assertNull(h.getIdentityFile()); } + @Test public void testSeparatorParsing() throws Exception { config("Host\tfirst\n" + "\tHostName\tfirst.tld\n" + @@ -111,6 +120,7 @@ public class OpenSshConfigTest extends RepositoryTestCase { assertEquals("last.tld", osc.lookup("last").getHostName()); } + @Test public void testQuoteParsing() throws Exception { config("Host \"good\"\n" + " HostName=\"good.tld\"\n" + @@ -137,6 +147,7 @@ public class OpenSshConfigTest extends RepositoryTestCase { assertEquals("bad.tld\"", osc.lookup("bad").getHostName()); } + @Test public void testAlias_DoesNotMatch() throws Exception { config("Host orcz\n" + "\tHostName repo.or.cz\n"); final Host h = osc.lookup("repo.or.cz"); @@ -147,6 +158,7 @@ public class OpenSshConfigTest extends RepositoryTestCase { assertNull(h.getIdentityFile()); } + @Test public void testAlias_OptionsSet() throws Exception { config("Host orcz\n" + "\tHostName repo.or.cz\n" + "\tPort 2222\n" + "\tUser jex\n" + "\tIdentityFile .ssh/id_jex\n" @@ -159,6 +171,7 @@ public class OpenSshConfigTest extends RepositoryTestCase { assertEquals(new File(home, ".ssh/id_jex"), h.getIdentityFile()); } + @Test public void testAlias_OptionsKeywordCaseInsensitive() throws Exception { config("hOsT orcz\n" + "\thOsTnAmE repo.or.cz\n" + "\tPORT 2222\n" + "\tuser jex\n" + "\tidentityfile .ssh/id_jex\n" @@ -171,6 +184,7 @@ public class OpenSshConfigTest extends RepositoryTestCase { assertEquals(new File(home, ".ssh/id_jex"), h.getIdentityFile()); } + @Test public void testAlias_OptionsInherit() throws Exception { config("Host orcz\n" + "\tHostName repo.or.cz\n" + "\n" + "Host *\n" + "\tHostName not.a.host.example.com\n" + "\tPort 2222\n" @@ -184,12 +198,14 @@ public class OpenSshConfigTest extends RepositoryTestCase { assertEquals(new File(home, ".ssh/id_jex"), h.getIdentityFile()); } + @Test public void testAlias_PreferredAuthenticationsDefault() throws Exception { final Host h = osc.lookup("orcz"); assertNotNull(h); assertNull(h.getPreferredAuthentications()); } + @Test public void testAlias_PreferredAuthentications() throws Exception { config("Host orcz\n" + "\tPreferredAuthentications publickey\n"); final Host h = osc.lookup("orcz"); @@ -197,6 +213,7 @@ public class OpenSshConfigTest extends RepositoryTestCase { assertEquals("publickey", h.getPreferredAuthentications()); } + @Test public void testAlias_InheritPreferredAuthentications() throws Exception { config("Host orcz\n" + "\tHostName repo.or.cz\n" + "\n" + "Host *\n" + "\tPreferredAuthentications publickey, hostbased\n"); @@ -205,12 +222,14 @@ public class OpenSshConfigTest extends RepositoryTestCase { assertEquals("publickey,hostbased", h.getPreferredAuthentications()); } + @Test public void testAlias_BatchModeDefault() throws Exception { final Host h = osc.lookup("orcz"); assertNotNull(h); assertEquals(false, h.isBatchMode()); } + @Test public void testAlias_BatchModeYes() throws Exception { config("Host orcz\n" + "\tBatchMode yes\n"); final Host h = osc.lookup("orcz"); @@ -218,6 +237,7 @@ public class OpenSshConfigTest extends RepositoryTestCase { assertEquals(true, h.isBatchMode()); } + @Test public void testAlias_InheritBatchMode() throws Exception { config("Host orcz\n" + "\tHostName repo.or.cz\n" + "\n" + "Host *\n" + "\tBatchMode yes\n"); |