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>tags/v0.11.1
@@ -8,7 +8,6 @@ Bundle-Localization: plugin | |||
Bundle-RequiredExecutionEnvironment: J2SE-1.5 | |||
Import-Package: javax.servlet;version="[2.5.0,3.0.0)", | |||
javax.servlet.http;version="[2.5.0,3.0.0)", | |||
junit.framework;version="[4.0.0,5.0.0)", | |||
org.eclipse.jetty.continuation;version="[7.1.0,8.0.0)", | |||
org.eclipse.jetty.http;version="[7.1.0,8.0.0)", | |||
org.eclipse.jetty.http.security;version="[7.1.0,8.0.0)", |
@@ -9,7 +9,7 @@ | |||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.jgit.http.test"/> | |||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> | |||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> | |||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/> | |||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> | |||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/> | |||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.jgit.http.test"/> | |||
</launchConfiguration> |
@@ -43,6 +43,9 @@ | |||
package org.eclipse.jgit.http.test; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.fail; | |||
import java.util.Collections; | |||
import javax.servlet.http.HttpServletRequest; | |||
@@ -70,13 +73,16 @@ import org.eclipse.jgit.transport.ReceivePack; | |||
import org.eclipse.jgit.transport.RemoteRefUpdate; | |||
import org.eclipse.jgit.transport.Transport; | |||
import org.eclipse.jgit.transport.URIish; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class AdvertiseErrorTest extends HttpTestCase { | |||
private FileRepository remoteRepository; | |||
private URIish remoteURI; | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
final TestRepository<FileRepository> src = createTestRepository(); | |||
@@ -120,6 +126,7 @@ public class AdvertiseErrorTest extends HttpTestCase { | |||
cfg.save(); | |||
} | |||
@Test | |||
public void testPush_CreateBranch() throws Exception { | |||
final TestRepository src = createTestRepository(); | |||
final RevBlob Q_txt = src.blob("new text"); |
@@ -43,6 +43,8 @@ | |||
package org.eclipse.jgit.http.test; | |||
import static org.junit.Assert.fail; | |||
import java.io.IOException; | |||
import javax.servlet.http.HttpServletRequestWrapper; | |||
@@ -54,19 +56,23 @@ import org.eclipse.jgit.http.server.resolver.ServiceNotEnabledException; | |||
import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase; | |||
import org.eclipse.jgit.lib.Repository; | |||
import org.eclipse.jgit.lib.StoredConfig; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class AsIsServiceTest extends LocalDiskRepositoryTestCase { | |||
private Repository db; | |||
private AsIsFileService service; | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
db = createBareRepository(); | |||
service = new AsIsFileService(); | |||
} | |||
@Test | |||
public void testDisabledSingleton() throws ServiceNotAuthorizedException { | |||
service = AsIsFileService.DISABLED; | |||
try { | |||
@@ -84,12 +90,14 @@ public class AsIsServiceTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCreate_Default() throws ServiceNotEnabledException, | |||
ServiceNotAuthorizedException { | |||
service.access(new R(null, "1.2.3.4"), db); | |||
service.access(new R("bob", "1.2.3.4"), db); | |||
} | |||
@Test | |||
public void testCreate_Disabled() throws ServiceNotAuthorizedException, | |||
IOException { | |||
final StoredConfig cfg = db.getConfig(); | |||
@@ -111,6 +119,7 @@ public class AsIsServiceTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCreate_Enabled() throws ServiceNotEnabledException, | |||
ServiceNotAuthorizedException { | |||
db.getConfig().setBoolean("http", null, "getanyfile", true); |
@@ -43,6 +43,11 @@ | |||
package org.eclipse.jgit.http.test; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.fail; | |||
import java.io.IOException; | |||
import javax.servlet.http.HttpServletRequestWrapper; | |||
@@ -57,19 +62,23 @@ import org.eclipse.jgit.lib.PersonIdent; | |||
import org.eclipse.jgit.lib.Repository; | |||
import org.eclipse.jgit.lib.StoredConfig; | |||
import org.eclipse.jgit.transport.ReceivePack; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class DefaultReceivePackFactoryTest extends LocalDiskRepositoryTestCase { | |||
private Repository db; | |||
private ReceivePackFactory factory; | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
db = createBareRepository(); | |||
factory = new DefaultReceivePackFactory(); | |||
} | |||
@Test | |||
public void testDisabledSingleton() throws ServiceNotAuthorizedException { | |||
factory = ReceivePackFactory.DISABLED; | |||
@@ -95,6 +104,7 @@ public class DefaultReceivePackFactoryTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCreate_NullUser() throws ServiceNotEnabledException { | |||
try { | |||
factory.create(new R(null, "localhost"), db); | |||
@@ -104,6 +114,7 @@ public class DefaultReceivePackFactoryTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCreate_EmptyStringUser() throws ServiceNotEnabledException { | |||
try { | |||
factory.create(new R("", "localhost"), db); | |||
@@ -113,6 +124,7 @@ public class DefaultReceivePackFactoryTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCreate_AuthUser() throws ServiceNotEnabledException, | |||
ServiceNotAuthorizedException { | |||
ReceivePack rp; | |||
@@ -130,6 +142,7 @@ public class DefaultReceivePackFactoryTest extends LocalDiskRepositoryTestCase { | |||
assertEquals(author.getWhen(), id.getWhen()); | |||
} | |||
@Test | |||
public void testCreate_Disabled() throws ServiceNotAuthorizedException, | |||
IOException { | |||
final StoredConfig cfg = db.getConfig(); | |||
@@ -158,6 +171,7 @@ public class DefaultReceivePackFactoryTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCreate_Enabled() throws ServiceNotEnabledException, | |||
ServiceNotAuthorizedException, IOException { | |||
final StoredConfig cfg = db.getConfig(); |
@@ -43,6 +43,10 @@ | |||
package org.eclipse.jgit.http.test; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.fail; | |||
import java.io.IOException; | |||
import javax.servlet.http.HttpServletRequestWrapper; | |||
@@ -56,19 +60,23 @@ import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase; | |||
import org.eclipse.jgit.lib.Repository; | |||
import org.eclipse.jgit.lib.StoredConfig; | |||
import org.eclipse.jgit.transport.UploadPack; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class DefaultUploadPackFactoryTest extends LocalDiskRepositoryTestCase { | |||
private Repository db; | |||
private UploadPackFactory factory; | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
db = createBareRepository(); | |||
factory = new DefaultUploadPackFactory(); | |||
} | |||
@Test | |||
public void testDisabledSingleton() throws ServiceNotAuthorizedException { | |||
factory = UploadPackFactory.DISABLED; | |||
@@ -94,6 +102,7 @@ public class DefaultUploadPackFactoryTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCreate_Default() throws ServiceNotEnabledException, | |||
ServiceNotAuthorizedException { | |||
UploadPack up; | |||
@@ -107,6 +116,7 @@ public class DefaultUploadPackFactoryTest extends LocalDiskRepositoryTestCase { | |||
assertSame(db, up.getRepository()); | |||
} | |||
@Test | |||
public void testCreate_Disabled() throws ServiceNotAuthorizedException, | |||
IOException { | |||
final StoredConfig cfg = db.getConfig(); | |||
@@ -128,6 +138,7 @@ public class DefaultUploadPackFactoryTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCreate_Enabled() throws ServiceNotEnabledException, | |||
ServiceNotAuthorizedException { | |||
db.getConfig().setBoolean("http", null, "uploadpack", true); |
@@ -46,6 +46,11 @@ package org.eclipse.jgit.http.test; | |||
import static org.eclipse.jgit.util.HttpSupport.HDR_ACCEPT; | |||
import static org.eclipse.jgit.util.HttpSupport.HDR_PRAGMA; | |||
import static org.eclipse.jgit.util.HttpSupport.HDR_USER_AGENT; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.io.IOException; | |||
@@ -70,6 +75,8 @@ import org.eclipse.jgit.transport.HttpTransport; | |||
import org.eclipse.jgit.transport.Transport; | |||
import org.eclipse.jgit.transport.TransportHttp; | |||
import org.eclipse.jgit.transport.URIish; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class DumbClientDumbServerTest extends HttpTestCase { | |||
private Repository remoteRepository; | |||
@@ -80,7 +87,8 @@ public class DumbClientDumbServerTest extends HttpTestCase { | |||
private RevCommit A, B; | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
final TestRepository src = createTestRepository(); | |||
@@ -102,6 +110,7 @@ public class DumbClientDumbServerTest extends HttpTestCase { | |||
src.update(master, B); | |||
} | |||
@Test | |||
public void testListRemote() throws IOException { | |||
Repository dst = createBareRepository(); | |||
@@ -164,6 +173,7 @@ public class DumbClientDumbServerTest extends HttpTestCase { | |||
assertEquals(200, head.getStatus()); | |||
} | |||
@Test | |||
public void testInitialClone_Loose() throws Exception { | |||
Repository dst = createBareRepository(); | |||
assertFalse(dst.hasObject(A_txt)); | |||
@@ -186,6 +196,7 @@ public class DumbClientDumbServerTest extends HttpTestCase { | |||
assertEquals(200, loose.get(0).getStatus()); | |||
} | |||
@Test | |||
public void testInitialClone_Packed() throws Exception { | |||
new TestRepository(remoteRepository).packAndPrune(); | |||
@@ -225,6 +236,7 @@ public class DumbClientDumbServerTest extends HttpTestCase { | |||
assertEquals(200, event.getStatus()); | |||
} | |||
@Test | |||
public void testPushNotSupported() throws Exception { | |||
final TestRepository src = createTestRepository(); | |||
final RevCommit Q = src.commit().create(); |
@@ -47,6 +47,12 @@ import static org.eclipse.jgit.util.HttpSupport.HDR_ACCEPT; | |||
import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_TYPE; | |||
import static org.eclipse.jgit.util.HttpSupport.HDR_PRAGMA; | |||
import static org.eclipse.jgit.util.HttpSupport.HDR_USER_AGENT; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.IOException; | |||
import java.util.List; | |||
@@ -75,6 +81,8 @@ import org.eclipse.jgit.transport.HttpTransport; | |||
import org.eclipse.jgit.transport.Transport; | |||
import org.eclipse.jgit.transport.TransportHttp; | |||
import org.eclipse.jgit.transport.URIish; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class DumbClientSmartServerTest extends HttpTestCase { | |||
private Repository remoteRepository; | |||
@@ -85,7 +93,8 @@ public class DumbClientSmartServerTest extends HttpTestCase { | |||
private RevCommit A, B; | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
final TestRepository src = createTestRepository(); | |||
@@ -118,6 +127,7 @@ public class DumbClientSmartServerTest extends HttpTestCase { | |||
src.update(master, B); | |||
} | |||
@Test | |||
public void testListRemote() throws IOException { | |||
Repository dst = createBareRepository(); | |||
@@ -179,6 +189,7 @@ public class DumbClientSmartServerTest extends HttpTestCase { | |||
assertEquals("text/plain", head.getResponseHeader(HDR_CONTENT_TYPE)); | |||
} | |||
@Test | |||
public void testInitialClone_Small() throws Exception { | |||
Repository dst = createBareRepository(); | |||
assertFalse(dst.hasObject(A_txt)); | |||
@@ -204,6 +215,7 @@ public class DumbClientSmartServerTest extends HttpTestCase { | |||
.getResponseHeader(HDR_CONTENT_TYPE)); | |||
} | |||
@Test | |||
public void testInitialClone_Packed() throws Exception { | |||
new TestRepository(remoteRepository).packAndPrune(); | |||
@@ -239,6 +251,7 @@ public class DumbClientSmartServerTest extends HttpTestCase { | |||
HDR_CONTENT_TYPE)); | |||
} | |||
@Test | |||
public void testPushNotSupported() throws Exception { | |||
final TestRepository src = createTestRepository(); | |||
final RevCommit Q = src.commit().create(); |
@@ -43,21 +43,24 @@ | |||
package org.eclipse.jgit.http.test; | |||
import static org.junit.Assert.assertEquals; | |||
import java.net.HttpURLConnection; | |||
import java.net.URI; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jetty.servlet.ServletContextHandler; | |||
import org.eclipse.jetty.servlet.ServletHolder; | |||
import org.eclipse.jgit.http.server.glue.ErrorServlet; | |||
import org.eclipse.jgit.junit.http.AppServer; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class ErrorServletTest extends TestCase { | |||
public class ErrorServletTest { | |||
private AppServer server; | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
@Before | |||
public void setUp() throws Exception { | |||
server = new AppServer(); | |||
@@ -68,13 +71,14 @@ public class ErrorServletTest extends TestCase { | |||
server.setUp(); | |||
} | |||
protected void tearDown() throws Exception { | |||
@After | |||
public void tearDown() throws Exception { | |||
if (server != null) { | |||
server.tearDown(); | |||
} | |||
super.tearDown(); | |||
} | |||
@Test | |||
public void testHandler() throws Exception { | |||
final URI uri = server.getURI(); | |||
assertEquals(404, ((HttpURLConnection) uri.resolve("/404").toURL() |
@@ -43,6 +43,13 @@ | |||
package org.eclipse.jgit.http.test; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.io.IOException; | |||
@@ -51,8 +58,10 @@ import org.eclipse.jgit.http.server.resolver.FileResolver; | |||
import org.eclipse.jgit.http.server.resolver.ServiceNotEnabledException; | |||
import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase; | |||
import org.eclipse.jgit.lib.Repository; | |||
import org.junit.Test; | |||
public class FileResolverTest extends LocalDiskRepositoryTestCase { | |||
@Test | |||
public void testUnreasonableNames() throws ServiceNotEnabledException { | |||
assertUnreasonable(""); | |||
assertUnreasonable("a\\b"); | |||
@@ -83,6 +92,7 @@ public class FileResolverTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testExportOk() throws IOException { | |||
final Repository a = createBareRepository(); | |||
final String name = a.getDirectory().getName(); | |||
@@ -116,6 +126,7 @@ public class FileResolverTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testNotAGitRepository() throws IOException, | |||
ServiceNotEnabledException { | |||
final Repository a = createBareRepository(); |
@@ -43,30 +43,35 @@ | |||
package org.eclipse.jgit.http.test; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.util.List; | |||
import javax.servlet.ServletException; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jetty.servlet.ServletContextHandler; | |||
import org.eclipse.jetty.servlet.ServletHolder; | |||
import org.eclipse.jgit.http.server.GitServlet; | |||
import org.eclipse.jgit.junit.http.AppServer; | |||
import org.eclipse.jgit.junit.http.MockServletConfig; | |||
import org.eclipse.jgit.junit.http.RecordingLogger; | |||
import org.junit.After; | |||
import org.junit.Test; | |||
public class GitServletInitTest extends TestCase { | |||
public class GitServletInitTest { | |||
private AppServer server; | |||
protected void tearDown() throws Exception { | |||
@After | |||
public void tearDown() throws Exception { | |||
if (server != null) { | |||
server.tearDown(); | |||
server = null; | |||
} | |||
super.tearDown(); | |||
} | |||
@Test | |||
public void testDefaultConstructor_NoBasePath() throws Exception { | |||
GitServlet s = new GitServlet(); | |||
try { | |||
@@ -77,6 +82,7 @@ public class GitServletInitTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testDefaultConstructor_WithBasePath() throws Exception { | |||
MockServletConfig c = new MockServletConfig(); | |||
c.setInitParameter("base-path", "."); | |||
@@ -87,6 +93,7 @@ public class GitServletInitTest extends TestCase { | |||
s.destroy(); | |||
} | |||
@Test | |||
public void testInitUnderContainer_NoBasePath() throws Exception { | |||
server = new AppServer(); | |||
@@ -104,6 +111,7 @@ public class GitServletInitTest extends TestCase { | |||
assertTrue("Wanted base-path", why.getMessage().contains("base-path")); | |||
} | |||
@Test | |||
public void testInitUnderContainer_WithBasePath() throws Exception { | |||
server = new AppServer(); | |||
@@ -43,6 +43,10 @@ | |||
package org.eclipse.jgit.http.test; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertTrue; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.List; | |||
@@ -75,13 +79,16 @@ import org.eclipse.jgit.transport.ReceivePack; | |||
import org.eclipse.jgit.transport.RemoteRefUpdate; | |||
import org.eclipse.jgit.transport.Transport; | |||
import org.eclipse.jgit.transport.URIish; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class HookMessageTest extends HttpTestCase { | |||
private FileRepository remoteRepository; | |||
private URIish remoteURI; | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
final TestRepository<FileRepository> src = createTestRepository(); | |||
@@ -130,6 +137,7 @@ public class HookMessageTest extends HttpTestCase { | |||
cfg.save(); | |||
} | |||
@Test | |||
public void testPush_CreateBranch() throws Exception { | |||
final TestRepository src = createTestRepository(); | |||
final RevBlob Q_txt = src.blob("new text"); |
@@ -43,6 +43,13 @@ | |||
package org.eclipse.jgit.http.test; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.net.URI; | |||
import java.util.List; | |||
@@ -86,7 +93,7 @@ public class HttpClientTests extends HttpTestCase { | |||
private URIish smartAuthBasicURI; | |||
protected void setUp() throws Exception { | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
remoteRepository = createTestRepository(); |
@@ -46,6 +46,12 @@ package org.eclipse.jgit.http.test; | |||
import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_ENCODING; | |||
import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_LENGTH; | |||
import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_TYPE; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.IOException; | |||
import java.io.PrintWriter; | |||
@@ -92,6 +98,8 @@ import org.eclipse.jgit.transport.RemoteRefUpdate; | |||
import org.eclipse.jgit.transport.Transport; | |||
import org.eclipse.jgit.transport.TransportHttp; | |||
import org.eclipse.jgit.transport.URIish; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class SmartClientSmartServerTest extends HttpTestCase { | |||
private static final String HDR_TRANSFER_ENCODING = "Transfer-Encoding"; | |||
@@ -106,7 +114,8 @@ public class SmartClientSmartServerTest extends HttpTestCase { | |||
private RevCommit A, B; | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
final TestRepository<FileRepository> src = createTestRepository(); | |||
@@ -165,6 +174,7 @@ public class SmartClientSmartServerTest extends HttpTestCase { | |||
src.update("refs/garbage/a/very/long/ref/name/to/compress", B); | |||
} | |||
@Test | |||
public void testListRemote() throws IOException { | |||
Repository dst = createBareRepository(); | |||
@@ -213,6 +223,7 @@ public class SmartClientSmartServerTest extends HttpTestCase { | |||
assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING)); | |||
} | |||
@Test | |||
public void testInitialClone_Small() throws Exception { | |||
Repository dst = createBareRepository(); | |||
assertFalse(dst.hasObject(A_txt)); | |||
@@ -257,6 +268,7 @@ public class SmartClientSmartServerTest extends HttpTestCase { | |||
.getResponseHeader(HDR_CONTENT_TYPE)); | |||
} | |||
@Test | |||
public void testFetchUpdateExisting() throws Exception { | |||
// Bootstrap by doing the clone. | |||
// | |||
@@ -336,6 +348,7 @@ public class SmartClientSmartServerTest extends HttpTestCase { | |||
.getResponseHeader(HDR_CONTENT_TYPE)); | |||
} | |||
@Test | |||
public void testInitialClone_BrokenServer() throws Exception { | |||
Repository dst = createBareRepository(); | |||
assertFalse(dst.hasObject(A_txt)); | |||
@@ -376,6 +389,7 @@ public class SmartClientSmartServerTest extends HttpTestCase { | |||
.getResponseHeader(HDR_CONTENT_TYPE)); | |||
} | |||
@Test | |||
public void testPush_NotAuthorized() throws Exception { | |||
final TestRepository src = createTestRepository(); | |||
final RevBlob Q_txt = src.blob("new text"); | |||
@@ -418,6 +432,7 @@ public class SmartClientSmartServerTest extends HttpTestCase { | |||
assertEquals(401, info.getStatus()); | |||
} | |||
@Test | |||
public void testPush_CreateBranch() throws Exception { | |||
final TestRepository src = createTestRepository(); | |||
final RevBlob Q_txt = src.blob("new text"); | |||
@@ -490,6 +505,7 @@ public class SmartClientSmartServerTest extends HttpTestCase { | |||
.getResponseHeader(HDR_CONTENT_TYPE)); | |||
} | |||
@Test | |||
public void testPush_ChunkedEncoding() throws Exception { | |||
final TestRepository<FileRepository> src = createTestRepository(); | |||
final RevBlob Q_bin = src.blob(new TestRng("Q").nextBytes(128 * 1024)); |
@@ -9,7 +9,6 @@ Bundle-ActivationPolicy: lazy | |||
Bundle-RequiredExecutionEnvironment: J2SE-1.5 | |||
Import-Package: javax.servlet;version="[2.5.0,3.0.0)", | |||
javax.servlet.http;version="[2.5.0,3.0.0)", | |||
junit.framework;version="[3.8.2,4.0.0)", | |||
org.eclipse.jetty.continuation;version="[7.1.0,8.0.0)", | |||
org.eclipse.jetty.http;version="[7.1.0,8.0.0)", | |||
org.eclipse.jetty.http.security;version="[7.1.0,8.0.0)", | |||
@@ -30,5 +29,6 @@ Import-Package: javax.servlet;version="[2.5.0,3.0.0)", | |||
org.eclipse.jgit.lib;version="[0.11.0,0.12.0)", | |||
org.eclipse.jgit.revwalk;version="[0.11.0,0.12.0)", | |||
org.eclipse.jgit.storage.file;version="[0.11.0,0.12.0)", | |||
org.eclipse.jgit.transport;version="[0.11.0,0.12.0)" | |||
org.eclipse.jgit.transport;version="[0.11.0,0.12.0)", | |||
org.junit;version="[4.0.0,5.0.0)" | |||
Export-Package: org.eclipse.jgit.junit.http;version="0.11.0" |
@@ -43,6 +43,9 @@ | |||
package org.eclipse.jgit.junit.http; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.IOException; | |||
import java.net.InetAddress; | |||
import java.net.URI; | |||
@@ -51,8 +54,6 @@ import java.net.UnknownHostException; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import junit.framework.Assert; | |||
import org.eclipse.jetty.http.security.Constraint; | |||
import org.eclipse.jetty.http.security.Password; | |||
import org.eclipse.jetty.security.Authenticator; | |||
@@ -282,10 +283,10 @@ public class AppServer { | |||
} | |||
private void assertNotYetSetUp() { | |||
Assert.assertFalse("server is not running", server.isRunning()); | |||
assertFalse("server is not running", server.isRunning()); | |||
} | |||
private void assertAlreadySetUp() { | |||
Assert.assertTrue("server is running", server.isRunning()); | |||
assertTrue("server is running", server.isRunning()); | |||
} | |||
} |
@@ -43,6 +43,8 @@ | |||
package org.eclipse.jgit.junit.http; | |||
import static org.junit.Assert.fail; | |||
import java.io.IOException; | |||
import java.net.URI; | |||
import java.net.URISyntaxException; | |||
@@ -73,12 +75,12 @@ public abstract class HttpTestCase extends LocalDiskRepositoryTestCase { | |||
/** In-memory application server; subclass must start. */ | |||
protected AppServer server; | |||
protected void setUp() throws Exception { | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
server = new AppServer(); | |||
} | |||
protected void tearDown() throws Exception { | |||
public void tearDown() throws Exception { | |||
server.tearDown(); | |||
super.tearDown(); | |||
} |
@@ -43,11 +43,6 @@ | |||
package org.eclipse.jgit.junit.http; | |||
import org.eclipse.jetty.server.DispatcherType; | |||
import org.eclipse.jetty.server.Request; | |||
import org.eclipse.jetty.server.Response; | |||
import org.eclipse.jetty.server.handler.HandlerWrapper; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
@@ -57,6 +52,11 @@ import javax.servlet.ServletException; | |||
import javax.servlet.http.HttpServletRequest; | |||
import javax.servlet.http.HttpServletResponse; | |||
import org.eclipse.jetty.server.DispatcherType; | |||
import org.eclipse.jetty.server.Request; | |||
import org.eclipse.jetty.server.Response; | |||
import org.eclipse.jetty.server.handler.HandlerWrapper; | |||
/** Logs request made through {@link AppServer}. */ | |||
class TestRequestLog extends HandlerWrapper { | |||
private static final int MAX = 16; |
@@ -7,8 +7,7 @@ Bundle-Localization: plugin | |||
Bundle-Vendor: %provider_name | |||
Bundle-ActivationPolicy: lazy | |||
Bundle-RequiredExecutionEnvironment: J2SE-1.5 | |||
Import-Package: junit.framework;version="[4.0.0,5.0.0)", | |||
org.eclipse.jgit.diff;version="[0.11.0,0.12.0)", | |||
Import-Package: org.eclipse.jgit.diff;version="[0.11.0,0.12.0)", | |||
org.eclipse.jgit.dircache;version="[0.11.0,0.12.0)", | |||
org.eclipse.jgit.errors;version="[0.11.0,0.12.0)", | |||
org.eclipse.jgit.fnmatch;version="[0.11.0,0.12.0)", | |||
@@ -24,6 +23,7 @@ Import-Package: junit.framework;version="[4.0.0,5.0.0)", | |||
org.eclipse.jgit.treewalk;version="[0.11.0,0.12.0)", | |||
org.eclipse.jgit.treewalk.filter;version="[0.11.0,0.12.0)", | |||
org.eclipse.jgit.util;version="[0.11.0,0.12.0)", | |||
org.eclipse.jgit.util.io;version="[0.11.0,0.12.0)" | |||
org.eclipse.jgit.util.io;version="[0.11.0,0.12.0)", | |||
org.junit;version="[4.0.0,5.0.0)" | |||
Export-Package: org.eclipse.jgit.junit;version="0.11.0" | |||
Require-Bundle: com.jcraft.jsch;bundle-version="[0.1.37,0.2.0)" |
@@ -43,12 +43,17 @@ | |||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
*/ | |||
package org.eclipse.jgit.util; | |||
package org.eclipse.jgit.junit; | |||
import java.io.File; | |||
import java.lang.reflect.Method; | |||
import java.net.URISyntaxException; | |||
import java.net.URL; | |||
import org.eclipse.jgit.util.RawParseUtils; | |||
import org.junit.Assert; | |||
import org.junit.Test; | |||
public abstract class JGitTestUtil { | |||
public static final String CLASSPATH_TO_RESOURCES = "org/eclipse/jgit/test/resources/"; | |||
@@ -56,6 +61,52 @@ public abstract class JGitTestUtil { | |||
throw new UnsupportedOperationException(); | |||
} | |||
public static String getName() { | |||
GatherStackTrace stack; | |||
try { | |||
throw new GatherStackTrace(); | |||
} catch (GatherStackTrace wanted) { | |||
stack = wanted; | |||
} | |||
try { | |||
for (StackTraceElement stackTrace : stack.getStackTrace()) { | |||
String className = stackTrace.getClassName(); | |||
String methodName = stackTrace.getMethodName(); | |||
Method method; | |||
try { | |||
method = Class.forName(className) // | |||
.getMethod(methodName, (Class[]) null); | |||
} catch (NoSuchMethodException e) { | |||
// could be private, i.e. not a test method | |||
// could have arguments, not handled | |||
continue; | |||
} | |||
Test annotation = method.getAnnotation(Test.class); | |||
if (annotation != null) | |||
return methodName; | |||
} | |||
} catch (ClassNotFoundException shouldNeverOccur) { | |||
// Fall through and crash. | |||
} | |||
throw new AssertionError("Cannot determine name of current test"); | |||
} | |||
@SuppressWarnings("serial") | |||
private static class GatherStackTrace extends Exception { | |||
// Thrown above to collect the stack frame. | |||
} | |||
public static void assertEquals(byte[] exp, byte[] act) { | |||
Assert.assertEquals(s(exp), s(act)); | |||
} | |||
private static String s(byte[] raw) { | |||
return RawParseUtils.decode(raw); | |||
} | |||
public static File getTestResourceFile(final String fileName) { | |||
if (fileName == null || fileName.length() <= 0) { | |||
return null; |
@@ -45,6 +45,9 @@ | |||
package org.eclipse.jgit.junit; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.io.FileOutputStream; | |||
import java.io.IOException; | |||
@@ -57,10 +60,6 @@ import java.util.List; | |||
import java.util.Map; | |||
import java.util.concurrent.TimeUnit; | |||
import junit.framework.Assert; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jgit.lib.AnyObjectId; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.eclipse.jgit.lib.PersonIdent; | |||
import org.eclipse.jgit.lib.Repository; | |||
@@ -72,6 +71,8 @@ import org.eclipse.jgit.storage.file.WindowCacheConfig; | |||
import org.eclipse.jgit.util.FS; | |||
import org.eclipse.jgit.util.IO; | |||
import org.eclipse.jgit.util.SystemReader; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
/** | |||
* JUnit TestCase with specialized support for temporary local repository. | |||
@@ -90,7 +91,7 @@ import org.eclipse.jgit.util.SystemReader; | |||
* a test, or tests may fail altogether if there is insufficient file | |||
* descriptors or address space for the test process. | |||
*/ | |||
public abstract class LocalDiskRepositoryTestCase extends TestCase { | |||
public abstract class LocalDiskRepositoryTestCase { | |||
private static Thread shutdownHook; | |||
private static int testCount; | |||
@@ -110,9 +111,8 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { | |||
private MockSystemReader mockSystemReader; | |||
@Override | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
@Before | |||
public void setUp() throws Exception { | |||
synchronized(this) { | |||
if (shutdownHook == null) { | |||
@@ -131,7 +131,7 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { | |||
Runtime.getRuntime().addShutdownHook(shutdownHook); | |||
} | |||
} | |||
recursiveDelete(testName(), trash, true, false); | |||
recursiveDelete(testId(), trash, true, false); | |||
mockSystemReader = new MockSystemReader(); | |||
mockSystemReader.userGitConfig = new FileBasedConfig(new File(trash, | |||
@@ -174,8 +174,8 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { | |||
return stringBuilder.toString(); | |||
} | |||
@Override | |||
protected void tearDown() throws Exception { | |||
@After | |||
public void tearDown() throws Exception { | |||
RepositoryCache.clear(); | |||
for (Repository r : toClose) | |||
r.close(); | |||
@@ -188,8 +188,7 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { | |||
if (useMMAP) | |||
System.gc(); | |||
recursiveDelete(testName(), trash, false, true); | |||
super.tearDown(); | |||
recursiveDelete(testId(), trash, false, true); | |||
} | |||
/** Increment the {@link #author} and {@link #committer} times. */ | |||
@@ -210,7 +209,7 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { | |||
* the recursively directory to delete, if present. | |||
*/ | |||
protected void recursiveDelete(final File dir) { | |||
recursiveDelete(testName(), dir, false, true); | |||
recursiveDelete(testId(), dir, false, true); | |||
} | |||
private static boolean recursiveDelete(final String testName, | |||
@@ -414,10 +413,6 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { | |||
return new String(body, 0, body.length, "UTF-8"); | |||
} | |||
protected static void assertEquals(AnyObjectId exp, AnyObjectId act) { | |||
Assert.assertEquals(exp, act); | |||
} | |||
private static String[] toEnvArray(final Map<String, String> env) { | |||
final String[] envp = new String[env.size()]; | |||
int i = 0; | |||
@@ -431,7 +426,7 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { | |||
return new HashMap<String, String>(System.getenv()); | |||
} | |||
private String testName() { | |||
return getClass().getName() + "." + getName(); | |||
private String testId() { | |||
return getClass().getName() + "." + testCount; | |||
} | |||
} |
@@ -43,6 +43,8 @@ | |||
package org.eclipse.jgit.junit; | |||
import static org.junit.Assert.*; | |||
import java.io.BufferedOutputStream; | |||
import java.io.File; | |||
import java.io.FileOutputStream; | |||
@@ -56,9 +58,6 @@ import java.util.HashSet; | |||
import java.util.List; | |||
import java.util.Set; | |||
import junit.framework.Assert; | |||
import junit.framework.AssertionFailedError; | |||
import org.eclipse.jgit.dircache.DirCache; | |||
import org.eclipse.jgit.dircache.DirCacheBuilder; | |||
import org.eclipse.jgit.dircache.DirCacheEditor; | |||
@@ -277,12 +276,10 @@ public class TestRepository<R extends Repository> { | |||
* @param path | |||
* the path to find the entry of. | |||
* @return the parsed object entry at this path, never null. | |||
* @throws AssertionFailedError | |||
* if the path does not exist in the given tree. | |||
* @throws Exception | |||
*/ | |||
public RevObject get(final RevTree tree, final String path) | |||
throws AssertionFailedError, Exception { | |||
throws Exception { | |||
final TreeWalk tw = new TreeWalk(pool.getObjectReader()); | |||
tw.setFilter(PathFilterGroup.createFromStrings(Collections | |||
.singleton(path))); | |||
@@ -296,7 +293,7 @@ public class TestRepository<R extends Repository> { | |||
final FileMode entmode = tw.getFileMode(0); | |||
return pool.lookupAny(entid, entmode.getObjectType()); | |||
} | |||
Assert.fail("Can't find " + path + " in tree " + tree.name()); | |||
fail("Can't find " + path + " in tree " + tree.name()); | |||
return null; // never reached. | |||
} | |||
@@ -598,7 +595,7 @@ public class TestRepository<R extends Repository> { | |||
md.update(Constants.encodeASCII(bin.length)); | |||
md.update((byte) 0); | |||
md.update(bin); | |||
Assert.assertEquals(id, ObjectId.fromRaw(md.digest())); | |||
assertEquals(id, ObjectId.fromRaw(md.digest())); | |||
} | |||
/** |
@@ -7,8 +7,7 @@ Bundle-Localization: plugin | |||
Bundle-Vendor: %provider_name | |||
Bundle-ActivationPolicy: lazy | |||
Bundle-RequiredExecutionEnvironment: J2SE-1.5 | |||
Import-Package: junit.framework;version="[4.0.0,5.0.0)", | |||
org.eclipse.jgit;version="[0.11.0,0.12.0)", | |||
Import-Package: org.eclipse.jgit;version="[0.11.0,0.12.0)", | |||
org.eclipse.jgit.api;version="[0.11.0,0.12.0)", | |||
org.eclipse.jgit.api.errors;version="[0.11.0,0.12.0)", | |||
org.eclipse.jgit.awtui;version="[0.11.0,0.12.0)", |
@@ -44,6 +44,11 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
@@ -53,6 +58,8 @@ import java.lang.reflect.Method; | |||
import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase; | |||
import org.eclipse.jgit.lib.GitIndex.Entry; | |||
import org.eclipse.jgit.util.FS; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { | |||
@@ -113,12 +120,14 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { | |||
private File trash; | |||
@Override | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
db = createWorkRepository(); | |||
trash = db.getWorkTree(); | |||
} | |||
@Test | |||
public void testCreateEmptyIndex() throws Exception { | |||
GitIndex index = new GitIndex(db); | |||
index.write(); | |||
@@ -130,12 +139,14 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { | |||
assertEquals(0, indexr.getMembers().length); | |||
} | |||
@Test | |||
public void testReadWithNoIndex() throws Exception { | |||
GitIndex index = new GitIndex(db); | |||
index.read(); | |||
assertEquals(0, index.getMembers().length); | |||
} | |||
@Test | |||
public void testCreateSimpleSortTestIndex() throws Exception { | |||
GitIndex index = new GitIndex(db); | |||
writeTrashFile("a/b", "data:a/b"); | |||
@@ -163,6 +174,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { | |||
assertEquals(0, system(trash, "git status")); | |||
} | |||
@Test | |||
public void testUpdateSimpleSortTestIndex() throws Exception { | |||
GitIndex index = new GitIndex(db); | |||
writeTrashFile("a/b", "data:a/b"); | |||
@@ -178,6 +190,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { | |||
assertEquals(0, system(trash, "git status")); | |||
} | |||
@Test | |||
public void testWriteTree() throws Exception { | |||
GitIndex index = new GitIndex(db); | |||
writeTrashFile("a/b", "data:a/b"); | |||
@@ -198,6 +211,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { | |||
assertEquals(0, system(trash, "git status")); | |||
} | |||
@Test | |||
public void testReadTree() throws Exception { | |||
// Prepare tree | |||
GitIndex index = new GitIndex(db); | |||
@@ -236,6 +250,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { | |||
assertEquals(0, system(trash, "git status")); | |||
} | |||
@Test | |||
public void testReadTree2() throws Exception { | |||
// Prepare a larger tree to test some odd cases in tree writing | |||
GitIndex index = new GitIndex(db); | |||
@@ -281,6 +296,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { | |||
assertEquals("a:b", membersr[5].getName()); | |||
} | |||
@Test | |||
public void testDelete() throws Exception { | |||
GitIndex index = new GitIndex(db); | |||
writeTrashFile("a/b", "data:a/b"); | |||
@@ -305,6 +321,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { | |||
assertEquals(0, system(trash, "git status")); | |||
} | |||
@Test | |||
public void testCheckout() throws Exception { | |||
// Prepare tree, remote it and checkout | |||
GitIndex index = new GitIndex(db); | |||
@@ -336,6 +353,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { | |||
assertEquals(0, system(trash, "git status")); | |||
} | |||
@Test | |||
public void test030_executeBit_coreModeTrue() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, Error, Exception { | |||
if (!FS.DETECTED.supportsExecute()) { | |||
System.err.println("Test ignored since platform FS does not support the execute permission"); | |||
@@ -391,6 +409,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void test031_executeBit_coreModeFalse() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, Error, Exception { | |||
if (!FS.DETECTED.supportsExecute()) { | |||
System.err.println("Test ignored since platform FS does not support the execute permission"); |
@@ -43,6 +43,11 @@ | |||
package org.eclipse.jgit.patch; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.BufferedReader; | |||
import java.io.IOException; | |||
import java.io.InputStreamReader; | |||
@@ -50,14 +55,14 @@ import java.io.UnsupportedEncodingException; | |||
import java.util.HashMap; | |||
import java.util.HashSet; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.eclipse.jgit.util.MutableInteger; | |||
import org.eclipse.jgit.util.RawParseUtils; | |||
import org.eclipse.jgit.util.TemporaryBuffer; | |||
import org.junit.Test; | |||
public class EGitPatchHistoryTest extends TestCase { | |||
public class EGitPatchHistoryTest { | |||
@Test | |||
public void testParseHistory() throws Exception { | |||
final NumStatReader numstat = new NumStatReader(); | |||
numstat.read(); |
@@ -129,8 +129,6 @@ | |||
<argLine>-Xmx256m -Dfile.encoding=UTF-8</argLine> | |||
<includes> | |||
<include>**/*Test.java</include> | |||
<include>**/*TestCase.java</include> | |||
<include>**/T000*.java</include> | |||
</includes> | |||
</configuration> | |||
</plugin> |
@@ -43,6 +43,9 @@ | |||
*/ | |||
package org.eclipse.jgit.api; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.IOException; | |||
@@ -58,9 +61,11 @@ import org.eclipse.jgit.lib.ObjectId; | |||
import org.eclipse.jgit.lib.ObjectInserter; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.eclipse.jgit.util.FileUtils; | |||
import org.junit.Test; | |||
public class AddCommandTest extends RepositoryTestCase { | |||
@Test | |||
public void testAddNothing() { | |||
Git git = new Git(db); | |||
@@ -73,6 +78,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
} | |||
@Test | |||
public void testAddNonExistingSingleFile() throws NoFilepatternException { | |||
Git git = new Git(db); | |||
@@ -81,6 +87,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
} | |||
@Test | |||
public void testAddExistingSingleFile() throws IOException, NoFilepatternException { | |||
File file = new File(db.getWorkTree(), "a.txt"); | |||
file.createNewFile(); | |||
@@ -97,6 +104,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
indexState(CONTENT)); | |||
} | |||
@Test | |||
public void testAddExistingSingleFileInSubDir() throws IOException, NoFilepatternException { | |||
new File(db.getWorkTree(), "sub").mkdir(); | |||
File file = new File(db.getWorkTree(), "sub/a.txt"); | |||
@@ -114,6 +122,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
indexState(CONTENT)); | |||
} | |||
@Test | |||
public void testAddExistingSingleFileTwice() throws IOException, NoFilepatternException { | |||
File file = new File(db.getWorkTree(), "a.txt"); | |||
file.createNewFile(); | |||
@@ -137,6 +146,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
indexState(CONTENT)); | |||
} | |||
@Test | |||
public void testAddExistingSingleFileTwiceWithCommit() throws Exception { | |||
File file = new File(db.getWorkTree(), "a.txt"); | |||
file.createNewFile(); | |||
@@ -162,6 +172,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
indexState(CONTENT)); | |||
} | |||
@Test | |||
public void testAddRemovedFile() throws Exception { | |||
File file = new File(db.getWorkTree(), "a.txt"); | |||
file.createNewFile(); | |||
@@ -183,6 +194,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
indexState(CONTENT)); | |||
} | |||
@Test | |||
public void testAddRemovedCommittedFile() throws Exception { | |||
File file = new File(db.getWorkTree(), "a.txt"); | |||
file.createNewFile(); | |||
@@ -206,6 +218,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
indexState(CONTENT)); | |||
} | |||
@Test | |||
public void testAddWithConflicts() throws Exception { | |||
// prepare conflict | |||
@@ -259,6 +272,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
indexState(CONTENT)); | |||
} | |||
@Test | |||
public void testAddTwoFiles() throws Exception { | |||
File file = new File(db.getWorkTree(), "a.txt"); | |||
file.createNewFile(); | |||
@@ -280,6 +294,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
indexState(CONTENT)); | |||
} | |||
@Test | |||
public void testAddFolder() throws Exception { | |||
new File(db.getWorkTree(), "sub").mkdir(); | |||
File file = new File(db.getWorkTree(), "sub/a.txt"); | |||
@@ -302,6 +317,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
indexState(CONTENT)); | |||
} | |||
@Test | |||
public void testAddIgnoredFile() throws Exception { | |||
new File(db.getWorkTree(), "sub").mkdir(); | |||
File file = new File(db.getWorkTree(), "sub/a.txt"); | |||
@@ -330,6 +346,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
indexState(CONTENT)); | |||
} | |||
@Test | |||
public void testAddWholeRepo() throws Exception { | |||
new File(db.getWorkTree(), "sub").mkdir(); | |||
File file = new File(db.getWorkTree(), "sub/a.txt"); | |||
@@ -356,6 +373,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
// file a exists in workdir and in index -> added | |||
// file b exists not in workdir but in index -> unchanged | |||
// file c exists in workdir but not in index -> added | |||
@Test | |||
public void testAddWithoutParameterUpdate() throws Exception { | |||
new File(db.getWorkTree(), "sub").mkdir(); | |||
File file = new File(db.getWorkTree(), "sub/a.txt"); | |||
@@ -409,6 +427,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
// file a exists in workdir and in index -> added | |||
// file b exists not in workdir but in index -> deleted | |||
// file c exists in workdir but not in index -> unchanged | |||
@Test | |||
public void testAddWithParameterUpdate() throws Exception { | |||
new File(db.getWorkTree(), "sub").mkdir(); | |||
File file = new File(db.getWorkTree(), "sub/a.txt"); | |||
@@ -457,6 +476,7 @@ public class AddCommandTest extends RepositoryTestCase { | |||
indexState(CONTENT)); | |||
} | |||
@Test | |||
public void testAssumeUnchanged() throws Exception { | |||
Git git = new Git(db); | |||
String path = "a.txt"; |
@@ -42,6 +42,11 @@ | |||
*/ | |||
package org.eclipse.jgit.api; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.fail; | |||
import java.util.List; | |||
import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode; | |||
@@ -65,6 +70,8 @@ import org.eclipse.jgit.transport.FetchResult; | |||
import org.eclipse.jgit.transport.RefSpec; | |||
import org.eclipse.jgit.transport.RemoteConfig; | |||
import org.eclipse.jgit.transport.URIish; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class BranchCommandTest extends RepositoryTestCase { | |||
private Git git; | |||
@@ -74,7 +81,8 @@ public class BranchCommandTest extends RepositoryTestCase { | |||
RevCommit secondCommit; | |||
@Override | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
git = new Git(db); | |||
// checkout master | |||
@@ -128,6 +136,7 @@ public class BranchCommandTest extends RepositoryTestCase { | |||
return localGit; | |||
} | |||
@Test | |||
public void testCreateAndList() throws Exception { | |||
int localBefore; | |||
int remoteBefore; | |||
@@ -180,6 +189,7 @@ public class BranchCommandTest extends RepositoryTestCase { | |||
- allBefore); | |||
} | |||
@Test | |||
public void testCreateFromCommit() throws Exception { | |||
Ref branch = git.branchCreate().setName("FromInitial").setStartPoint( | |||
initialCommit).call(); | |||
@@ -198,6 +208,7 @@ public class BranchCommandTest extends RepositoryTestCase { | |||
assertEquals(secondCommit.getId(), branch.getObjectId()); | |||
} | |||
@Test | |||
public void testCreateForce() throws Exception { | |||
// using commits | |||
Ref newBranch = createBranch(git, "NewForce", false, secondCommit | |||
@@ -230,6 +241,7 @@ public class BranchCommandTest extends RepositoryTestCase { | |||
assertEquals(newBranch.getTarget().getObjectId(), initialCommit.getId()); | |||
} | |||
@Test | |||
public void testDelete() throws Exception { | |||
createBranch(git, "ForDelete", false, "master", null); | |||
git.branchDelete().setBranchNames("ForDelete").call(); | |||
@@ -274,6 +286,7 @@ public class BranchCommandTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testPullConfigRemoteBranch() throws Exception { | |||
Git localGit = setUpRepoWithRemote(); | |||
Ref remote = localGit.branchList().setListMode(ListMode.REMOTE).call() | |||
@@ -305,6 +318,7 @@ public class BranchCommandTest extends RepositoryTestCase { | |||
localGit.branchDelete().setBranchNames("newFromRemote").call(); | |||
} | |||
@Test | |||
public void testPullConfigLocalBranch() throws Exception { | |||
Git localGit = setUpRepoWithRemote(); | |||
// by default, we should not create pull configuration | |||
@@ -324,6 +338,7 @@ public class BranchCommandTest extends RepositoryTestCase { | |||
"newFromRemote", "remote")); | |||
} | |||
@Test | |||
public void testPullConfigRenameLocalBranch() throws Exception { | |||
Git localGit = setUpRepoWithRemote(); | |||
// by default, we should not create pull configuration | |||
@@ -348,6 +363,7 @@ public class BranchCommandTest extends RepositoryTestCase { | |||
"newFromRemote", "remote")); | |||
} | |||
@Test | |||
public void testRenameLocalBranch() throws Exception { | |||
// null newName not allowed | |||
try { | |||
@@ -402,6 +418,7 @@ public class BranchCommandTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testRenameRemoteTrackingBranch() throws Exception { | |||
Git localGit = setUpRepoWithRemote(); | |||
Ref remoteBranch = localGit.branchList().setListMode(ListMode.REMOTE) | |||
@@ -412,6 +429,7 @@ public class BranchCommandTest extends RepositoryTestCase { | |||
assertEquals(Constants.R_REMOTES + "newRemote", renamed.getName()); | |||
} | |||
@Test | |||
public void testCreationImplicitStart() throws JGitInternalException, | |||
GitAPIException { | |||
git.branchCreate().setName("topic").call(); |
@@ -42,6 +42,13 @@ | |||
*/ | |||
package org.eclipse.jgit.api; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.IOException; | |||
@@ -57,6 +64,8 @@ import org.eclipse.jgit.lib.RefUpdate; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.eclipse.jgit.revwalk.RevCommit; | |||
import org.eclipse.jgit.util.FileUtils; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class CheckoutCommandTest extends RepositoryTestCase { | |||
private Git git; | |||
@@ -66,7 +75,8 @@ public class CheckoutCommandTest extends RepositoryTestCase { | |||
RevCommit secondCommit; | |||
@Override | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
git = new Git(db); | |||
// commit something | |||
@@ -85,6 +95,7 @@ public class CheckoutCommandTest extends RepositoryTestCase { | |||
secondCommit = git.commit().setMessage("Second commit").call(); | |||
} | |||
@Test | |||
public void testSimpleCheckout() { | |||
try { | |||
git.checkout().setName("test").call(); | |||
@@ -93,6 +104,7 @@ public class CheckoutCommandTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCheckout() { | |||
try { | |||
git.checkout().setName("test").call(); | |||
@@ -109,6 +121,7 @@ public class CheckoutCommandTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCreateBranchOnCheckout() throws IOException { | |||
try { | |||
git.checkout().setCreateBranch(true).setName("test2").call(); | |||
@@ -118,6 +131,7 @@ public class CheckoutCommandTest extends RepositoryTestCase { | |||
assertNotNull(db.getRef("test2")); | |||
} | |||
@Test | |||
public void testCheckoutToNonExistingBranch() throws JGitInternalException, | |||
RefAlreadyExistsException, InvalidRefNameException { | |||
try { | |||
@@ -128,6 +142,7 @@ public class CheckoutCommandTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCheckoutWithConflict() { | |||
CheckoutCommand co = git.checkout(); | |||
try { | |||
@@ -141,6 +156,7 @@ public class CheckoutCommandTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCheckoutWithNonDeletedFiles() throws Exception { | |||
File testFile = writeTrashFile("temp", ""); | |||
FileInputStream fis = new FileInputStream(testFile); | |||
@@ -176,6 +192,7 @@ public class CheckoutCommandTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCheckoutCommit() { | |||
try { | |||
Ref result = git.checkout().setName(initialCommit.name()).call(); |
@@ -42,22 +42,28 @@ | |||
*/ | |||
package org.eclipse.jgit.api; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Iterator; | |||
import org.eclipse.jgit.api.errors.*; | |||
import org.eclipse.jgit.api.errors.GitAPIException; | |||
import org.eclipse.jgit.api.errors.JGitInternalException; | |||
import org.eclipse.jgit.dircache.DirCacheCheckout; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.eclipse.jgit.lib.RefUpdate; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.eclipse.jgit.revwalk.RevCommit; | |||
import org.eclipse.jgit.revwalk.RevWalk; | |||
import org.junit.Test; | |||
/** | |||
* Test cherry-pick command | |||
*/ | |||
public class CherryPickCommandTest extends RepositoryTestCase { | |||
@Test | |||
public void testCherryPick() throws IOException, JGitInternalException, | |||
GitAPIException { | |||
Git git = new Git(db); |
@@ -42,6 +42,10 @@ | |||
*/ | |||
package org.eclipse.jgit.api; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.PrintWriter; |
@@ -42,6 +42,8 @@ | |||
*/ | |||
package org.eclipse.jgit.api; | |||
import static org.junit.Assert.assertEquals; | |||
import java.io.IOException; | |||
import java.net.URISyntaxException; | |||
@@ -55,9 +57,11 @@ import org.eclipse.jgit.revwalk.RevTag; | |||
import org.eclipse.jgit.transport.RefSpec; | |||
import org.eclipse.jgit.transport.RemoteConfig; | |||
import org.eclipse.jgit.transport.URIish; | |||
import org.junit.Test; | |||
public class FetchCommandTest extends RepositoryTestCase { | |||
@Test | |||
public void testFetch() throws JGitInternalException, IOException, | |||
GitAPIException, URISyntaxException { | |||
@@ -42,19 +42,27 @@ | |||
*/ | |||
package org.eclipse.jgit.api; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import org.eclipse.jgit.lib.Repository; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class InitCommandTest extends RepositoryTestCase { | |||
@Override | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
} | |||
@Test | |||
public void testInitRepository() { | |||
try { | |||
File directory = createTempDirectory("testInitRepository"); | |||
@@ -67,6 +75,7 @@ public class InitCommandTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testInitBareRepository() { | |||
try { | |||
File directory = createTempDirectory("testInitBareRepository"); |
@@ -43,6 +43,11 @@ | |||
*/ | |||
package org.eclipse.jgit.api; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Iterator; | |||
@@ -58,8 +63,10 @@ import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.eclipse.jgit.merge.MergeStrategy; | |||
import org.eclipse.jgit.revwalk.RevCommit; | |||
import org.eclipse.jgit.revwalk.RevWalk; | |||
import org.junit.Test; | |||
public class MergeCommandTest extends RepositoryTestCase { | |||
@Test | |||
public void testMergeInItself() throws Exception { | |||
Git git = new Git(db); | |||
git.commit().setMessage("initial commit").call(); | |||
@@ -68,6 +75,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
assertEquals(MergeResult.MergeStatus.ALREADY_UP_TO_DATE, result.getMergeStatus()); | |||
} | |||
@Test | |||
public void testAlreadyUpToDate() throws Exception { | |||
Git git = new Git(db); | |||
RevCommit first = git.commit().setMessage("initial commit").call(); | |||
@@ -80,6 +88,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
} | |||
@Test | |||
public void testFastForward() throws Exception { | |||
Git git = new Git(db); | |||
RevCommit first = git.commit().setMessage("initial commit").call(); | |||
@@ -95,6 +104,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
assertEquals(second, result.getNewHead()); | |||
} | |||
@Test | |||
public void testFastForwardWithFiles() throws Exception { | |||
Git git = new Git(db); | |||
@@ -121,6 +131,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
assertEquals(second, result.getNewHead()); | |||
} | |||
@Test | |||
public void testMultipleHeads() throws Exception { | |||
Git git = new Git(db); | |||
@@ -153,6 +164,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
} | |||
@Test | |||
public void testContentMerge() throws Exception { | |||
Git git = new Git(db); | |||
@@ -197,6 +209,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
assertEquals(RepositoryState.MERGING, db.getRepositoryState()); | |||
} | |||
@Test | |||
public void testMergeNonVersionedPaths() throws Exception { | |||
Git git = new Git(db); | |||
@@ -247,6 +260,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
assertEquals(RepositoryState.MERGING, db.getRepositoryState()); | |||
} | |||
@Test | |||
public void testMultipleCreations() throws Exception { | |||
Git git = new Git(db); | |||
@@ -272,6 +286,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
assertEquals(MergeStatus.CONFLICTING, result.getMergeStatus()); | |||
} | |||
@Test | |||
public void testMultipleCreationsSameContent() throws Exception { | |||
Git git = new Git(db); | |||
@@ -298,6 +313,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
assertEquals("1\nb(1)\n3\n", read(new File(db.getWorkTree(), "b"))); | |||
} | |||
@Test | |||
public void testSuccessfulContentMerge() throws Exception { | |||
Git git = new Git(db); | |||
@@ -355,6 +371,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
// test index state | |||
} | |||
@Test | |||
public void testSuccessfulContentMergeAndDirtyworkingTree() | |||
throws Exception { | |||
Git git = new Git(db); | |||
@@ -414,6 +431,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
assertEquals(RepositoryState.SAFE, db.getRepositoryState()); | |||
} | |||
@Test | |||
public void testSingleDeletion() throws Exception { | |||
Git git = new Git(db); | |||
@@ -466,6 +484,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
read(new File(db.getWorkTree(), "c/c/c"))); | |||
} | |||
@Test | |||
public void testMultipleDeletions() throws Exception { | |||
Git git = new Git(db); | |||
@@ -494,6 +513,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
assertEquals(MergeStatus.MERGED, result.getMergeStatus()); | |||
} | |||
@Test | |||
public void testDeletionAndConflict() throws Exception { | |||
Git git = new Git(db); | |||
@@ -536,6 +556,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
read(new File(db.getWorkTree(), "c/c/c"))); | |||
} | |||
@Test | |||
public void testMergeFailingWithDirtyWorkingTree() throws Exception { | |||
Git git = new Git(db); | |||
@@ -574,6 +595,7 @@ public class MergeCommandTest extends RepositoryTestCase { | |||
assertEquals(RepositoryState.SAFE, db.getRepositoryState()); | |||
} | |||
@Test | |||
public void testMergeConflictFileFolder() throws Exception { | |||
Git git = new Git(db); | |||
@@ -42,6 +42,11 @@ | |||
*/ | |||
package org.eclipse.jgit.api; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.ByteArrayOutputStream; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
@@ -59,6 +64,8 @@ import org.eclipse.jgit.storage.file.FileRepository; | |||
import org.eclipse.jgit.transport.RefSpec; | |||
import org.eclipse.jgit.transport.RemoteConfig; | |||
import org.eclipse.jgit.transport.URIish; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class PullCommandTest extends RepositoryTestCase { | |||
/** Second Test repository */ | |||
@@ -72,6 +79,7 @@ public class PullCommandTest extends RepositoryTestCase { | |||
private File targetFile; | |||
@Test | |||
public void testPullFastForward() throws Exception { | |||
PullResult res = target.pull().call(); | |||
// nothing to update since we don't have different data yet | |||
@@ -94,6 +102,7 @@ public class PullCommandTest extends RepositoryTestCase { | |||
assertFileContentsEqual(targetFile, "Another change"); | |||
} | |||
@Test | |||
public void testPullConflict() throws Exception { | |||
PullResult res = target.pull().call(); | |||
// nothing to update since we don't have different data yet | |||
@@ -127,6 +136,7 @@ public class PullCommandTest extends RepositoryTestCase { | |||
assertFileContentsEqual(targetFile, result); | |||
} | |||
@Test | |||
public void testPullLocalConflict() throws Exception { | |||
target.branchCreate().setName("basedOnMaster").setStartPoint( | |||
"refs/heads/master").setUpstreamMode(SetupUpstreamMode.TRACK) | |||
@@ -168,7 +178,8 @@ public class PullCommandTest extends RepositoryTestCase { | |||
} | |||
@Override | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
dbTarget = createWorkRepository(); | |||
source = new Git(db); |
@@ -42,6 +42,9 @@ | |||
*/ | |||
package org.eclipse.jgit.api; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.fail; | |||
import java.io.IOException; | |||
import java.net.URISyntaxException; | |||
@@ -56,9 +59,11 @@ import org.eclipse.jgit.revwalk.RevTag; | |||
import org.eclipse.jgit.transport.RefSpec; | |||
import org.eclipse.jgit.transport.RemoteConfig; | |||
import org.eclipse.jgit.transport.URIish; | |||
import org.junit.Test; | |||
public class PushCommandTest extends RepositoryTestCase { | |||
@Test | |||
public void testPush() throws JGitInternalException, IOException, | |||
GitAPIException, URISyntaxException { | |||
@@ -42,6 +42,12 @@ | |||
*/ | |||
package org.eclipse.jgit.api; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.BufferedReader; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
@@ -63,6 +69,8 @@ import org.eclipse.jgit.lib.RepositoryState; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.eclipse.jgit.revwalk.RevCommit; | |||
import org.eclipse.jgit.revwalk.RevWalk; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class RebaseCommandTest extends RepositoryTestCase { | |||
private static final String FILE1 = "file1"; | |||
@@ -70,7 +78,8 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
protected Git git; | |||
@Override | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
this.git = new Git(db); | |||
} | |||
@@ -112,6 +121,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
refUpdate.forceUpdate(); | |||
} | |||
@Test | |||
public void testFastForwardWithNewFile() throws Exception { | |||
// create file1 on master | |||
writeTrashFile(FILE1, FILE1); | |||
@@ -134,6 +144,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
assertEquals(Status.UP_TO_DATE, res.getStatus()); | |||
} | |||
@Test | |||
public void testUpToDate() throws Exception { | |||
// create file1 on master | |||
writeTrashFile(FILE1, FILE1); | |||
@@ -146,6 +157,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
assertEquals(Status.UP_TO_DATE, res.getStatus()); | |||
} | |||
@Test | |||
public void testUnknownUpstream() throws Exception { | |||
// create file1 on master | |||
writeTrashFile(FILE1, FILE1); | |||
@@ -162,6 +174,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testConflictFreeWithSingleFile() throws Exception { | |||
// create file1 on master | |||
File theFile = writeTrashFile(FILE1, "1\n2\n3\n"); | |||
@@ -196,6 +209,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
db.resolve(Constants.HEAD)).getParent(0)); | |||
} | |||
@Test | |||
public void testDetachedHead() throws Exception { | |||
// create file1 on master | |||
File theFile = writeTrashFile(FILE1, "1\n2\n3\n"); | |||
@@ -233,6 +247,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
} | |||
@Test | |||
public void testFilesAddedFromTwoBranches() throws Exception { | |||
// create file1 on master | |||
writeTrashFile(FILE1, FILE1); | |||
@@ -277,6 +292,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
assertFalse(new File(db.getWorkTree(), "file3").exists()); | |||
} | |||
@Test | |||
public void testStopOnConflict() throws Exception { | |||
// create file1 on master | |||
RevCommit firstInMaster = writeFileAndCommit(FILE1, "Add file1", "1", | |||
@@ -336,6 +352,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
assertFalse(new File(db.getDirectory(), "rebase-merge").exists()); | |||
} | |||
@Test | |||
public void testStopOnConflictAndContinue() throws Exception { | |||
// create file1 on master | |||
RevCommit firstInMaster = writeFileAndCommit(FILE1, "Add file1", "1", | |||
@@ -390,6 +407,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
.getFullMessage()); | |||
} | |||
@Test | |||
public void testStopOnConflictAndFailContinueIfFileIsDirty() | |||
throws Exception { | |||
// create file1 on master | |||
@@ -430,6 +448,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
checkFile(trashFile, "Some local change"); | |||
} | |||
@Test | |||
public void testStopOnLastConflictAndContinue() throws Exception { | |||
// create file1 on master | |||
RevCommit firstInMaster = writeFileAndCommit(FILE1, "Add file1", "1", | |||
@@ -465,6 +484,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
assertEquals(RepositoryState.SAFE, db.getRepositoryState()); | |||
} | |||
@Test | |||
public void testStopOnLastConflictAndSkip() throws Exception { | |||
// create file1 on master | |||
RevCommit firstInMaster = writeFileAndCommit(FILE1, "Add file1", "1", | |||
@@ -500,6 +520,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
assertEquals(RepositoryState.SAFE, db.getRepositoryState()); | |||
} | |||
@Test | |||
public void testMergeFirstStopOnLastConflictAndSkip() throws Exception { | |||
// create file1 on master | |||
RevCommit firstInMaster = writeFileAndCommit(FILE1, "Add file1", "1", | |||
@@ -538,6 +559,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
checkFile(FILE1, "merged"); | |||
} | |||
@Test | |||
public void testStopOnConflictAndSkipNoConflict() throws Exception { | |||
// create file1 on master | |||
RevCommit firstInMaster = writeFileAndCommit(FILE1, "Add file1", "1", | |||
@@ -574,6 +596,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
assertEquals(Status.OK, res.getStatus()); | |||
} | |||
@Test | |||
public void testStopOnConflictAndSkipWithConflict() throws Exception { | |||
// create file1 on master | |||
RevCommit firstInMaster = writeFileAndCommit(FILE1, "Add file1", "1", | |||
@@ -612,6 +635,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
assertEquals(Status.STOPPED, res.getStatus()); | |||
} | |||
@Test | |||
public void testStopOnConflictCommitAndContinue() throws Exception { | |||
// create file1 on master | |||
RevCommit firstInMaster = writeFileAndCommit(FILE1, "Add file1", "1", | |||
@@ -699,6 +723,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
checkFile(file, sb.toString()); | |||
} | |||
@Test | |||
public void testStopOnConflictFileCreationAndDeletion() throws Exception { | |||
// create file1 on master | |||
writeTrashFile(FILE1, "Hello World"); | |||
@@ -786,6 +811,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
} | |||
@Test | |||
public void testAuthorScriptConverter() throws Exception { | |||
// -1 h timezone offset | |||
PersonIdent ident = new PersonIdent("Author name", "a.mail@some.com", | |||
@@ -821,6 +847,7 @@ public class RebaseCommandTest extends RepositoryTestCase { | |||
assertEquals(ident.getTimeZoneOffset(), parsedIdent.getTimeZoneOffset()); | |||
} | |||
@Test | |||
public void testRepositoryStateChecks() throws Exception { | |||
try { | |||
git.rebase().setOperation(Operation.ABORT).call(); |
@@ -42,11 +42,15 @@ | |||
*/ | |||
package org.eclipse.jgit.api; | |||
import static org.junit.Assert.assertEquals; | |||
import java.io.IOException; | |||
import org.eclipse.jgit.api.errors.JGitInternalException; | |||
import org.eclipse.jgit.api.errors.NoFilepatternException; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class RmCommandTest extends RepositoryTestCase { | |||
@@ -55,7 +59,8 @@ public class RmCommandTest extends RepositoryTestCase { | |||
private static final String FILE = "test.txt"; | |||
@Override | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
git = new Git(db); | |||
// commit something | |||
@@ -64,6 +69,7 @@ public class RmCommandTest extends RepositoryTestCase { | |||
git.commit().setMessage("Initial commit").call(); | |||
} | |||
@Test | |||
public void testRemove() throws JGitInternalException, | |||
NoFilepatternException, IllegalStateException, IOException { | |||
assertEquals("[test.txt, mode:100644, content:Hello world]", |
@@ -42,6 +42,9 @@ | |||
*/ | |||
package org.eclipse.jgit.api; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.fail; | |||
import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; | |||
import org.eclipse.jgit.api.errors.InvalidTagNameException; | |||
import org.eclipse.jgit.api.errors.JGitInternalException; | |||
@@ -52,9 +55,11 @@ import org.eclipse.jgit.errors.UnmergedPathException; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.eclipse.jgit.revwalk.RevCommit; | |||
import org.eclipse.jgit.revwalk.RevTag; | |||
import org.junit.Test; | |||
public class TagCommandTest extends RepositoryTestCase { | |||
@Test | |||
public void testTaggingOnHead() throws NoHeadException, NoMessageException, | |||
UnmergedPathException, ConcurrentRefUpdateException, | |||
JGitInternalException, WrongRepositoryStateException, | |||
@@ -65,6 +70,7 @@ public class TagCommandTest extends RepositoryTestCase { | |||
assertEquals(commit.getId(), tag.getObject().getId()); | |||
} | |||
@Test | |||
public void testTagging() throws NoHeadException, NoMessageException, | |||
UnmergedPathException, ConcurrentRefUpdateException, | |||
JGitInternalException, WrongRepositoryStateException, | |||
@@ -77,6 +83,7 @@ public class TagCommandTest extends RepositoryTestCase { | |||
assertEquals(commit.getId(), tag.getObject().getId()); | |||
} | |||
@Test | |||
public void testEmptyTagName() throws NoHeadException, NoMessageException, | |||
UnmergedPathException, ConcurrentRefUpdateException, | |||
JGitInternalException, WrongRepositoryStateException { | |||
@@ -91,6 +98,7 @@ public class TagCommandTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTagName() throws NoHeadException, | |||
NoMessageException, UnmergedPathException, | |||
ConcurrentRefUpdateException, JGitInternalException, | |||
@@ -105,6 +113,7 @@ public class TagCommandTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testFailureOnSignedTags() throws NoHeadException, | |||
NoMessageException, UnmergedPathException, | |||
ConcurrentRefUpdateException, JGitInternalException, |
@@ -43,76 +43,91 @@ | |||
package org.eclipse.jgit.diff; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.UnsupportedEncodingException; | |||
import junit.framework.TestCase; | |||
import org.junit.Test; | |||
public abstract class AbstractDiffTestCase extends TestCase { | |||
public abstract class AbstractDiffTestCase { | |||
@Test | |||
public void testEmptyInputs() { | |||
EditList r = diff(t(""), t("")); | |||
assertTrue("is empty", r.isEmpty()); | |||
} | |||
@Test | |||
public void testCreateFile() { | |||
EditList r = diff(t(""), t("AB")); | |||
assertEquals(1, r.size()); | |||
assertEquals(new Edit(0, 0, 0, 2), r.get(0)); | |||
} | |||
@Test | |||
public void testDeleteFile() { | |||
EditList r = diff(t("AB"), t("")); | |||
assertEquals(1, r.size()); | |||
assertEquals(new Edit(0, 2, 0, 0), r.get(0)); | |||
} | |||
@Test | |||
public void testDegenerate_InsertMiddle() { | |||
EditList r = diff(t("ac"), t("aBc")); | |||
assertEquals(1, r.size()); | |||
assertEquals(new Edit(1, 1, 1, 2), r.get(0)); | |||
} | |||
@Test | |||
public void testDegenerate_DeleteMiddle() { | |||
EditList r = diff(t("aBc"), t("ac")); | |||
assertEquals(1, r.size()); | |||
assertEquals(new Edit(1, 2, 1, 1), r.get(0)); | |||
} | |||
@Test | |||
public void testDegenerate_ReplaceMiddle() { | |||
EditList r = diff(t("bCd"), t("bEd")); | |||
assertEquals(1, r.size()); | |||
assertEquals(new Edit(1, 2, 1, 2), r.get(0)); | |||
} | |||
@Test | |||
public void testDegenerate_InsertsIntoMidPosition() { | |||
EditList r = diff(t("aaaa"), t("aaXaa")); | |||
assertEquals(1, r.size()); | |||
assertEquals(new Edit(2, 2, 2, 3), r.get(0)); | |||
} | |||
@Test | |||
public void testDegenerate_InsertStart() { | |||
EditList r = diff(t("bc"), t("Abc")); | |||
assertEquals(1, r.size()); | |||
assertEquals(new Edit(0, 0, 0, 1), r.get(0)); | |||
} | |||
@Test | |||
public void testDegenerate_DeleteStart() { | |||
EditList r = diff(t("Abc"), t("bc")); | |||
assertEquals(1, r.size()); | |||
assertEquals(new Edit(0, 1, 0, 0), r.get(0)); | |||
} | |||
@Test | |||
public void testDegenerate_InsertEnd() { | |||
EditList r = diff(t("bc"), t("bcD")); | |||
assertEquals(1, r.size()); | |||
assertEquals(new Edit(2, 2, 2, 3), r.get(0)); | |||
} | |||
@Test | |||
public void testDegenerate_DeleteEnd() { | |||
EditList r = diff(t("bcD"), t("bc")); | |||
assertEquals(1, r.size()); | |||
assertEquals(new Edit(2, 3, 2, 2), r.get(0)); | |||
} | |||
@Test | |||
public void testEdit_ReplaceCommonDelete() { | |||
EditList r = diff(t("RbC"), t("Sb")); | |||
assertEquals(2, r.size()); | |||
@@ -120,6 +135,7 @@ public abstract class AbstractDiffTestCase extends TestCase { | |||
assertEquals(new Edit(2, 3, 2, 2), r.get(1)); | |||
} | |||
@Test | |||
public void testEdit_CommonReplaceCommonDeleteCommon() { | |||
EditList r = diff(t("aRbCd"), t("aSbd")); | |||
assertEquals(2, r.size()); | |||
@@ -127,6 +143,7 @@ public abstract class AbstractDiffTestCase extends TestCase { | |||
assertEquals(new Edit(3, 4, 3, 3), r.get(1)); | |||
} | |||
@Test | |||
public void testEdit_MoveBlock() { | |||
EditList r = diff(t("aYYbcdz"), t("abcdYYz")); | |||
assertEquals(2, r.size()); | |||
@@ -134,6 +151,7 @@ public abstract class AbstractDiffTestCase extends TestCase { | |||
assertEquals(new Edit(6, 6, 4, 6), r.get(1)); | |||
} | |||
@Test | |||
public void testEdit_InvertBlocks() { | |||
EditList r = diff(t("aYYbcdXXz"), t("aXXbcdYYz")); | |||
assertEquals(2, r.size()); | |||
@@ -141,6 +159,7 @@ public abstract class AbstractDiffTestCase extends TestCase { | |||
assertEquals(new Edit(6, 8, 6, 8), r.get(1)); | |||
} | |||
@Test | |||
public void testEdit_UniqueCommonLargerThanMatchPoint() { | |||
// We are testing 3 unique common matches, but two of | |||
// them are consumed as part of the 1st's LCS region. | |||
@@ -150,6 +169,7 @@ public abstract class AbstractDiffTestCase extends TestCase { | |||
assertEquals(new Edit(4, 5, 4, 6), r.get(1)); | |||
} | |||
@Test | |||
public void testEdit_CommonGrowsPrefixAndSuffix() { | |||
// Here there is only one common unique point, but we can grow it | |||
// in both directions to find the LCS in the middle. | |||
@@ -159,6 +179,7 @@ public abstract class AbstractDiffTestCase extends TestCase { | |||
assertEquals(new Edit(6, 7, 6, 7), r.get(1)); | |||
} | |||
@Test | |||
public void testEdit_DuplicateAButCommonUniqueInB() { | |||
EditList r = diff(t("AbbcR"), t("CbcS")); | |||
assertEquals(2, r.size()); | |||
@@ -166,6 +187,7 @@ public abstract class AbstractDiffTestCase extends TestCase { | |||
assertEquals(new Edit(4, 5, 3, 4), r.get(1)); | |||
} | |||
@Test | |||
public void testEdit_InsertNearCommonTail() { | |||
EditList r = diff(t("aq}nb"), t("aCq}nD}nb")); | |||
assertEquals(new Edit(1, 1, 1, 2), r.get(0)); |
@@ -44,17 +44,21 @@ | |||
package org.eclipse.jgit.diff; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.fail; | |||
import java.io.ByteArrayOutputStream; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jgit.junit.JGitTestUtil; | |||
import org.eclipse.jgit.patch.FileHeader; | |||
import org.eclipse.jgit.patch.Patch; | |||
import org.eclipse.jgit.util.RawParseUtils; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class DiffFormatterReflowTest extends TestCase { | |||
public class DiffFormatterReflowTest { | |||
private RawText a; | |||
private RawText b; | |||
@@ -65,12 +69,13 @@ public class DiffFormatterReflowTest extends TestCase { | |||
private DiffFormatter fmt; | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
@Before | |||
public void setUp() throws Exception { | |||
out = new ByteArrayOutputStream(); | |||
fmt = new DiffFormatter(out); | |||
} | |||
@Test | |||
public void testNegativeContextFails() throws IOException { | |||
init("X"); | |||
try { | |||
@@ -81,52 +86,61 @@ public class DiffFormatterReflowTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testContext0() throws IOException { | |||
init("X"); | |||
fmt.setContext(0); | |||
assertFormatted(); | |||
} | |||
@Test | |||
public void testContext1() throws IOException { | |||
init("X"); | |||
fmt.setContext(1); | |||
assertFormatted(); | |||
} | |||
@Test | |||
public void testContext3() throws IOException { | |||
init("X"); | |||
fmt.setContext(3); | |||
assertFormatted(); | |||
} | |||
@Test | |||
public void testContext5() throws IOException { | |||
init("X"); | |||
fmt.setContext(5); | |||
assertFormatted(); | |||
} | |||
@Test | |||
public void testContext10() throws IOException { | |||
init("X"); | |||
fmt.setContext(10); | |||
assertFormatted(); | |||
} | |||
@Test | |||
public void testContext100() throws IOException { | |||
init("X"); | |||
fmt.setContext(100); | |||
assertFormatted(); | |||
} | |||
@Test | |||
public void testEmpty1() throws IOException { | |||
init("E"); | |||
assertFormatted("E.patch"); | |||
} | |||
@Test | |||
public void testNoNewLine1() throws IOException { | |||
init("Y"); | |||
assertFormatted("Y.patch"); | |||
} | |||
@Test | |||
public void testNoNewLine2() throws IOException { | |||
init("Z"); | |||
assertFormatted("Z.patch"); | |||
@@ -139,7 +153,7 @@ public class DiffFormatterReflowTest extends TestCase { | |||
} | |||
private void assertFormatted() throws IOException { | |||
assertFormatted(getName() + ".out"); | |||
assertFormatted(JGitTestUtil.getName() + ".out"); | |||
} | |||
private void assertFormatted(final String name) throws IOException { |
@@ -43,6 +43,8 @@ | |||
package org.eclipse.jgit.diff; | |||
import static org.junit.Assert.assertEquals; | |||
import org.eclipse.jgit.diff.DiffEntry.ChangeType; | |||
import org.eclipse.jgit.junit.TestRepository; | |||
import org.eclipse.jgit.lib.FileMode; | |||
@@ -52,6 +54,9 @@ import org.eclipse.jgit.patch.FileHeader; | |||
import org.eclipse.jgit.patch.HunkHeader; | |||
import org.eclipse.jgit.util.RawParseUtils; | |||
import org.eclipse.jgit.util.io.DisabledOutputStream; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class DiffFormatterTest extends RepositoryTestCase { | |||
private static final String DIFF = "diff --git "; | |||
@@ -69,6 +74,7 @@ public class DiffFormatterTest extends RepositoryTestCase { | |||
private TestRepository testDb; | |||
@Override | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
testDb = new TestRepository(db); | |||
@@ -78,12 +84,14 @@ public class DiffFormatterTest extends RepositoryTestCase { | |||
} | |||
@Override | |||
@After | |||
public void tearDown() throws Exception { | |||
if (df != null) | |||
df.release(); | |||
super.tearDown(); | |||
} | |||
@Test | |||
public void testCreateFileHeader_Add() throws Exception { | |||
ObjectId adId = blob("a\nd\n"); | |||
DiffEntry ent = DiffEntry.add("FOO", adId); | |||
@@ -119,6 +127,7 @@ public class DiffFormatterTest extends RepositoryTestCase { | |||
assertEquals(Edit.Type.INSERT, e.getType()); | |||
} | |||
@Test | |||
public void testCreateFileHeader_Delete() throws Exception { | |||
ObjectId adId = blob("a\nd\n"); | |||
DiffEntry ent = DiffEntry.delete("FOO", adId); | |||
@@ -154,6 +163,7 @@ public class DiffFormatterTest extends RepositoryTestCase { | |||
assertEquals(Edit.Type.DELETE, e.getType()); | |||
} | |||
@Test | |||
public void testCreateFileHeader_Modify() throws Exception { | |||
ObjectId adId = blob("a\nd\n"); | |||
ObjectId abcdId = blob("a\nb\nc\nd\n"); | |||
@@ -188,6 +198,7 @@ public class DiffFormatterTest extends RepositoryTestCase { | |||
assertEquals(Edit.Type.INSERT, e.getType()); | |||
} | |||
@Test | |||
public void testCreateFileHeader_Binary() throws Exception { | |||
ObjectId adId = blob("a\nd\n"); | |||
ObjectId binId = blob("a\nb\nc\n\0\0\0\0d\n"); | |||
@@ -211,6 +222,7 @@ public class DiffFormatterTest extends RepositoryTestCase { | |||
assertEquals(0, hh.toEditList().size()); | |||
} | |||
@Test | |||
public void testCreateFileHeader_GitLink() throws Exception { | |||
ObjectId aId = blob("a\n"); | |||
ObjectId bId = blob("b\n"); |
@@ -43,11 +43,17 @@ | |||
package org.eclipse.jgit.diff; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
import java.util.Iterator; | |||
import junit.framework.TestCase; | |||
import org.junit.Test; | |||
public class EditListTest extends TestCase { | |||
public class EditListTest { | |||
@Test | |||
public void testEmpty() { | |||
final EditList l = new EditList(); | |||
assertEquals(0, l.size()); | |||
@@ -60,6 +66,7 @@ public class EditListTest extends TestCase { | |||
assertEquals(l.hashCode(), new EditList().hashCode()); | |||
} | |||
@Test | |||
public void testAddOne() { | |||
final Edit e = new Edit(1, 2, 1, 1); | |||
final EditList l = new EditList(); | |||
@@ -79,6 +86,7 @@ public class EditListTest extends TestCase { | |||
assertEquals(l.hashCode(), l2.hashCode()); | |||
} | |||
@Test | |||
public void testAddTwo() { | |||
final Edit e1 = new Edit(1, 2, 1, 1); | |||
final Edit e2 = new Edit(8, 8, 8, 12); | |||
@@ -104,6 +112,7 @@ public class EditListTest extends TestCase { | |||
assertEquals(l.hashCode(), l2.hashCode()); | |||
} | |||
@Test | |||
public void testSet() { | |||
final Edit e1 = new Edit(1, 2, 1, 1); | |||
final Edit e2 = new Edit(3, 4, 3, 3); | |||
@@ -114,6 +123,7 @@ public class EditListTest extends TestCase { | |||
assertSame(e2, l.get(0)); | |||
} | |||
@Test | |||
public void testRemove() { | |||
final Edit e1 = new Edit(1, 2, 1, 1); | |||
final Edit e2 = new Edit(8, 8, 8, 12); |
@@ -44,9 +44,15 @@ | |||
package org.eclipse.jgit.diff; | |||
import junit.framework.TestCase; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
public class EditTest extends TestCase { | |||
import org.junit.Test; | |||
public class EditTest { | |||
@Test | |||
public void testCreate() { | |||
final Edit e = new Edit(1, 2, 3, 4); | |||
assertEquals(1, e.getBeginA()); | |||
@@ -55,6 +61,7 @@ public class EditTest extends TestCase { | |||
assertEquals(4, e.getEndB()); | |||
} | |||
@Test | |||
public void testCreateEmpty() { | |||
final Edit e = new Edit(1, 3); | |||
assertEquals(1, e.getBeginA()); | |||
@@ -65,6 +72,7 @@ public class EditTest extends TestCase { | |||
assertSame(Edit.Type.EMPTY, e.getType()); | |||
} | |||
@Test | |||
public void testSwap() { | |||
final Edit e = new Edit(1, 2, 3, 4); | |||
e.swap(); | |||
@@ -74,6 +82,7 @@ public class EditTest extends TestCase { | |||
assertEquals(2, e.getEndB()); | |||
} | |||
@Test | |||
public void testType_Insert() { | |||
final Edit e = new Edit(1, 1, 1, 2); | |||
assertSame(Edit.Type.INSERT, e.getType()); | |||
@@ -82,6 +91,7 @@ public class EditTest extends TestCase { | |||
assertEquals(1, e.getLengthB()); | |||
} | |||
@Test | |||
public void testType_Delete() { | |||
final Edit e = new Edit(1, 2, 1, 1); | |||
assertSame(Edit.Type.DELETE, e.getType()); | |||
@@ -90,6 +100,7 @@ public class EditTest extends TestCase { | |||
assertEquals(0, e.getLengthB()); | |||
} | |||
@Test | |||
public void testType_Replace() { | |||
final Edit e = new Edit(1, 2, 1, 4); | |||
assertSame(Edit.Type.REPLACE, e.getType()); | |||
@@ -98,6 +109,7 @@ public class EditTest extends TestCase { | |||
assertEquals(3, e.getLengthB()); | |||
} | |||
@Test | |||
public void testType_Empty() { | |||
final Edit e = new Edit(1, 1, 2, 2); | |||
assertSame(Edit.Type.EMPTY, e.getType()); | |||
@@ -107,11 +119,13 @@ public class EditTest extends TestCase { | |||
assertEquals(0, e.getLengthB()); | |||
} | |||
@Test | |||
public void testToString() { | |||
final Edit e = new Edit(1, 2, 1, 4); | |||
assertEquals("REPLACE(1-2,1-4)", e.toString()); | |||
} | |||
@Test | |||
public void testEquals1() { | |||
final Edit e1 = new Edit(1, 2, 3, 4); | |||
final Edit e2 = new Edit(1, 2, 3, 4); | |||
@@ -123,22 +137,27 @@ public class EditTest extends TestCase { | |||
assertFalse(e1.equals("")); | |||
} | |||
@Test | |||
public void testNotEquals1() { | |||
assertFalse(new Edit(1, 2, 3, 4).equals(new Edit(0, 2, 3, 4))); | |||
} | |||
@Test | |||
public void testNotEquals2() { | |||
assertFalse(new Edit(1, 2, 3, 4).equals(new Edit(1, 0, 3, 4))); | |||
} | |||
@Test | |||
public void testNotEquals3() { | |||
assertFalse(new Edit(1, 2, 3, 4).equals(new Edit(1, 2, 0, 4))); | |||
} | |||
@Test | |||
public void testNotEquals4() { | |||
assertFalse(new Edit(1, 2, 3, 4).equals(new Edit(1, 2, 3, 0))); | |||
} | |||
@Test | |||
public void testExtendA() { | |||
final Edit e = new Edit(1, 2, 1, 1); | |||
@@ -149,6 +168,7 @@ public class EditTest extends TestCase { | |||
assertEquals(new Edit(1, 4, 1, 1), e); | |||
} | |||
@Test | |||
public void testExtendB() { | |||
final Edit e = new Edit(1, 2, 1, 1); | |||
@@ -159,6 +179,7 @@ public class EditTest extends TestCase { | |||
assertEquals(new Edit(1, 2, 1, 3), e); | |||
} | |||
@Test | |||
public void testBeforeAfterCuts() { | |||
final Edit whole = new Edit(1, 8, 2, 9); | |||
final Edit mid = new Edit(4, 5, 3, 6); |
@@ -43,6 +43,10 @@ | |||
package org.eclipse.jgit.diff; | |||
import static org.junit.Assert.assertEquals; | |||
import org.junit.Test; | |||
public class HistogramDiffTest extends AbstractDiffTestCase { | |||
@Override | |||
@@ -52,6 +56,7 @@ public class HistogramDiffTest extends AbstractDiffTestCase { | |||
return hd; | |||
} | |||
@Test | |||
public void testEdit_NoUniqueMiddleSide_FlipBlocks() { | |||
EditList r = diff(t("aRRSSz"), t("aSSRRz")); | |||
assertEquals(2, r.size()); | |||
@@ -59,12 +64,14 @@ public class HistogramDiffTest extends AbstractDiffTestCase { | |||
assertEquals(new Edit(5, 5, 3, 5), r.get(1)); // INSERT "RR | |||
} | |||
@Test | |||
public void testEdit_NoUniqueMiddleSide_Insert2() { | |||
EditList r = diff(t("aRSz"), t("aRRSSz")); | |||
assertEquals(1, r.size()); | |||
assertEquals(new Edit(2, 2, 2, 4), r.get(0)); | |||
} | |||
@Test | |||
public void testEdit_NoUniqueMiddleSide_FlipAndExpand() { | |||
EditList r = diff(t("aRSz"), t("aSSRRz")); | |||
assertEquals(2, r.size()); | |||
@@ -72,6 +79,7 @@ public class HistogramDiffTest extends AbstractDiffTestCase { | |||
assertEquals(new Edit(3, 3, 2, 5), r.get(1)); // INSERT "SRR" | |||
} | |||
@Test | |||
public void testEdit_LcsContainsUnique() { | |||
EditList r = diff(t("nqnjrnjsnm"), t("AnqnjrnjsnjTnmZ")); | |||
assertEquals(new Edit(0, 0, 0, 1), r.get(0)); // INSERT "A"; | |||
@@ -80,6 +88,7 @@ public class HistogramDiffTest extends AbstractDiffTestCase { | |||
assertEquals(3, r.size()); | |||
} | |||
@Test | |||
public void testExceedsChainLength_DuringScanOfA() { | |||
HistogramDiff hd = new HistogramDiff(); | |||
hd.setFallbackAlgorithm(null); | |||
@@ -102,6 +111,7 @@ public class HistogramDiffTest extends AbstractDiffTestCase { | |||
assertEquals(new Edit(0, 4, 0, 4), r.get(0)); | |||
} | |||
@Test | |||
public void testExceedsChainLength_DuringScanOfB() { | |||
HistogramDiff hd = new HistogramDiff(); | |||
hd.setFallbackAlgorithm(null); | |||
@@ -112,6 +122,7 @@ public class HistogramDiffTest extends AbstractDiffTestCase { | |||
assertEquals(new Edit(0, 4, 0, 4), r.get(0)); | |||
} | |||
@Test | |||
public void testFallbackToMyersDiff() { | |||
HistogramDiff hd = new HistogramDiff(); | |||
hd.setMaxChainLength(4); |
@@ -44,13 +44,17 @@ | |||
package org.eclipse.jgit.diff; | |||
import org.eclipse.jgit.lib.Constants; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.junit.Test; | |||
public class RawTextIgnoreAllWhitespaceTest extends TestCase { | |||
public class RawTextIgnoreAllWhitespaceTest { | |||
private final RawTextComparator cmp = RawTextComparator.WS_IGNORE_ALL; | |||
@Test | |||
public void testEqualsWithoutWhitespace() { | |||
final RawText a = new RawText(Constants | |||
.encodeASCII("foo-a\nfoo-b\nfoo\n")); | |||
@@ -73,6 +77,7 @@ public class RawTextIgnoreAllWhitespaceTest extends TestCase { | |||
assertFalse(cmp.equals(b, 2, a, 2)); | |||
} | |||
@Test | |||
public void testEqualsWithWhitespace() { | |||
final RawText a = new RawText(Constants | |||
.encodeASCII("foo-a\n \n a b c\na \n")); |
@@ -44,13 +44,17 @@ | |||
package org.eclipse.jgit.diff; | |||
import org.eclipse.jgit.lib.Constants; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.junit.Test; | |||
public class RawTextIgnoreLeadingWhitespaceTest extends TestCase { | |||
public class RawTextIgnoreLeadingWhitespaceTest { | |||
private final RawTextComparator cmp = RawTextComparator.WS_IGNORE_LEADING; | |||
@Test | |||
public void testEqualsWithoutWhitespace() { | |||
final RawText a = new RawText(Constants | |||
.encodeASCII("foo-a\nfoo-b\nfoo\n")); | |||
@@ -73,6 +77,7 @@ public class RawTextIgnoreLeadingWhitespaceTest extends TestCase { | |||
assertFalse(cmp.equals(b, 2, a, 2)); | |||
} | |||
@Test | |||
public void testEqualsWithWhitespace() { | |||
final RawText a = new RawText(Constants | |||
.encodeASCII("foo-a\n \n a b c\n a\nb \n")); |
@@ -44,13 +44,17 @@ | |||
package org.eclipse.jgit.diff; | |||
import org.eclipse.jgit.lib.Constants; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.junit.Test; | |||
public class RawTextIgnoreTrailingWhitespaceTest extends TestCase { | |||
public class RawTextIgnoreTrailingWhitespaceTest { | |||
private final RawTextComparator cmp = RawTextComparator.WS_IGNORE_TRAILING; | |||
@Test | |||
public void testEqualsWithoutWhitespace() { | |||
final RawText a = new RawText(Constants | |||
.encodeASCII("foo-a\nfoo-b\nfoo\n")); | |||
@@ -73,6 +77,7 @@ public class RawTextIgnoreTrailingWhitespaceTest extends TestCase { | |||
assertFalse(cmp.equals(b, 2, a, 2)); | |||
} | |||
@Test | |||
public void testEqualsWithWhitespace() { | |||
final RawText a = new RawText(Constants | |||
.encodeASCII("foo-a\n \n a b c\na \n b\n")); |
@@ -44,13 +44,17 @@ | |||
package org.eclipse.jgit.diff; | |||
import org.eclipse.jgit.lib.Constants; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.junit.Test; | |||
public class RawTextIgnoreWhitespaceChangeTest extends TestCase { | |||
public class RawTextIgnoreWhitespaceChangeTest { | |||
private final RawTextComparator cmp = RawTextComparator.WS_IGNORE_CHANGE; | |||
@Test | |||
public void testEqualsWithoutWhitespace() { | |||
final RawText a = new RawText(Constants | |||
.encodeASCII("foo-a\nfoo-b\nfoo\n")); | |||
@@ -73,6 +77,7 @@ public class RawTextIgnoreWhitespaceChangeTest extends TestCase { | |||
assertFalse(cmp.equals(b, 2, a, 2)); | |||
} | |||
@Test | |||
public void testEqualsWithWhitespace() { | |||
final RawText a = new RawText(Constants | |||
.encodeASCII("foo-a\n \n a b c\na \n foo\na b c\n")); |
@@ -44,21 +44,26 @@ | |||
package org.eclipse.jgit.diff; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.ByteArrayOutputStream; | |||
import java.io.IOException; | |||
import java.io.UnsupportedEncodingException; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.eclipse.jgit.util.RawParseUtils; | |||
import org.junit.Test; | |||
public class RawTextTest extends TestCase { | |||
public class RawTextTest { | |||
@Test | |||
public void testEmpty() { | |||
final RawText r = new RawText(new byte[0]); | |||
assertEquals(0, r.size()); | |||
} | |||
@Test | |||
public void testEquals() { | |||
final RawText a = new RawText(Constants.encodeASCII("foo-a\nfoo-b\n")); | |||
final RawText b = new RawText(Constants.encodeASCII("foo-b\nfoo-c\n")); | |||
@@ -76,6 +81,7 @@ public class RawTextTest extends TestCase { | |||
assertTrue(cmp.equals(b, 0, a, 1)); | |||
} | |||
@Test | |||
public void testWriteLine1() throws IOException { | |||
final RawText a = new RawText(Constants.encodeASCII("foo-a\nfoo-b\n")); | |||
final ByteArrayOutputStream o = new ByteArrayOutputStream(); | |||
@@ -84,6 +90,7 @@ public class RawTextTest extends TestCase { | |||
assertEquals("foo-a", RawParseUtils.decode(r)); | |||
} | |||
@Test | |||
public void testWriteLine2() throws IOException { | |||
final RawText a = new RawText(Constants.encodeASCII("foo-a\nfoo-b")); | |||
final ByteArrayOutputStream o = new ByteArrayOutputStream(); | |||
@@ -92,6 +99,7 @@ public class RawTextTest extends TestCase { | |||
assertEquals("foo-b", RawParseUtils.decode(r)); | |||
} | |||
@Test | |||
public void testWriteLine3() throws IOException { | |||
final RawText a = new RawText(Constants.encodeASCII("a\n\nb\n")); | |||
final ByteArrayOutputStream o = new ByteArrayOutputStream(); | |||
@@ -100,6 +108,7 @@ public class RawTextTest extends TestCase { | |||
assertEquals("", RawParseUtils.decode(r)); | |||
} | |||
@Test | |||
public void testComparatorReduceCommonStartEnd() | |||
throws UnsupportedEncodingException { | |||
final RawTextComparator c = RawTextComparator.DEFAULT; | |||
@@ -134,6 +143,7 @@ public class RawTextTest extends TestCase { | |||
assertEquals(new Edit(2, 3, 2, 3), e); | |||
} | |||
@Test | |||
public void testComparatorReduceCommonStartEnd_EmptyLine() | |||
throws UnsupportedEncodingException { | |||
RawText a; |
@@ -43,6 +43,11 @@ | |||
package org.eclipse.jgit.diff; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.util.List; | |||
import org.eclipse.jgit.diff.DiffEntry.ChangeType; | |||
@@ -51,6 +56,8 @@ import org.eclipse.jgit.lib.AbbreviatedObjectId; | |||
import org.eclipse.jgit.lib.FileMode; | |||
import org.eclipse.jgit.lib.ObjectId; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class RenameDetectorTest extends RepositoryTestCase { | |||
private static final String PATH_A = "src/A"; | |||
@@ -63,12 +70,14 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
private TestRepository testDb; | |||
@Override | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
testDb = new TestRepository(db); | |||
rd = new RenameDetector(db); | |||
} | |||
@Test | |||
public void testExactRename_OneRename() throws Exception { | |||
ObjectId foo = blob("foo"); | |||
@@ -83,6 +92,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertRename(b, a, 100, entries.get(0)); | |||
} | |||
@Test | |||
public void testExactRename_DifferentObjects() throws Exception { | |||
ObjectId foo = blob("foo"); | |||
ObjectId bar = blob("bar"); | |||
@@ -102,6 +112,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertSame(q, entries.get(2)); | |||
} | |||
@Test | |||
public void testExactRename_OneRenameOneModify() throws Exception { | |||
ObjectId foo = blob("foo"); | |||
ObjectId bar = blob("bar"); | |||
@@ -122,6 +133,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertSame(c, entries.get(1)); | |||
} | |||
@Test | |||
public void testExactRename_ManyRenames() throws Exception { | |||
ObjectId foo = blob("foo"); | |||
ObjectId bar = blob("bar"); | |||
@@ -143,6 +155,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertRename(d, c, 100, entries.get(1)); | |||
} | |||
@Test | |||
public void testExactRename_MultipleIdenticalDeletes() throws Exception { | |||
ObjectId foo = blob("foo"); | |||
@@ -165,6 +178,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertRename(a, d, 100, entries.get(2)); | |||
} | |||
@Test | |||
public void testExactRename_PathBreaksTie() throws Exception { | |||
ObjectId foo = blob("foo"); | |||
@@ -189,6 +203,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertCopy(d, e, 100, entries.get(2)); | |||
} | |||
@Test | |||
public void testExactRename_OneDeleteManyAdds() throws Exception { | |||
ObjectId foo = blob("foo"); | |||
@@ -210,6 +225,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertCopy(d, b, 100, entries.get(2)); | |||
} | |||
@Test | |||
public void testInexactRename_OnePair() throws Exception { | |||
ObjectId aId = blob("foo\nbar\nbaz\nblarg\n"); | |||
ObjectId bId = blob("foo\nbar\nbaz\nblah\n"); | |||
@@ -225,6 +241,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertRename(b, a, 66, entries.get(0)); | |||
} | |||
@Test | |||
public void testInexactRename_OneRenameTwoUnrelatedFiles() throws Exception { | |||
ObjectId aId = blob("foo\nbar\nbaz\nblarg\n"); | |||
ObjectId bId = blob("foo\nbar\nbaz\nblah\n"); | |||
@@ -248,6 +265,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertSame(d, entries.get(2)); | |||
} | |||
@Test | |||
public void testInexactRename_LastByteDifferent() throws Exception { | |||
ObjectId aId = blob("foo\nbar\na"); | |||
ObjectId bId = blob("foo\nbar\nb"); | |||
@@ -263,6 +281,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertRename(b, a, 88, entries.get(0)); | |||
} | |||
@Test | |||
public void testInexactRename_NewlinesOnly() throws Exception { | |||
ObjectId aId = blob("\n\n\n"); | |||
ObjectId bId = blob("\n\n\n\n"); | |||
@@ -278,6 +297,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertRename(b, a, 74, entries.get(0)); | |||
} | |||
@Test | |||
public void testInexactRename_SameContentMultipleTimes() throws Exception { | |||
ObjectId aId = blob("a\na\na\na\n"); | |||
ObjectId bId = blob("a\na\na\n"); | |||
@@ -293,6 +313,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertRename(b, a, 74, entries.get(0)); | |||
} | |||
@Test | |||
public void testInexactRenames_OnePair2() throws Exception { | |||
ObjectId aId = blob("ab\nab\nab\nac\nad\nae\n"); | |||
ObjectId bId = blob("ac\nab\nab\nab\naa\na0\na1\n"); | |||
@@ -309,6 +330,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertRename(b, a, 57, entries.get(0)); | |||
} | |||
@Test | |||
public void testNoRenames_SingleByteFiles() throws Exception { | |||
ObjectId aId = blob("a"); | |||
ObjectId bId = blob("b"); | |||
@@ -325,6 +347,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertSame(b, entries.get(1)); | |||
} | |||
@Test | |||
public void testNoRenames_EmptyFile1() throws Exception { | |||
ObjectId aId = blob(""); | |||
DiffEntry a = DiffEntry.add(PATH_A, aId); | |||
@@ -336,6 +359,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertSame(a, entries.get(0)); | |||
} | |||
@Test | |||
public void testNoRenames_EmptyFile2() throws Exception { | |||
ObjectId aId = blob(""); | |||
ObjectId bId = blob("blah"); | |||
@@ -352,6 +376,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertSame(b, entries.get(1)); | |||
} | |||
@Test | |||
public void testNoRenames_SymlinkAndFile() throws Exception { | |||
ObjectId aId = blob("src/dest"); | |||
@@ -368,6 +393,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertSame(b, entries.get(1)); | |||
} | |||
@Test | |||
public void testNoRenames_GitlinkAndFile() throws Exception { | |||
ObjectId aId = blob("src/dest"); | |||
@@ -384,6 +410,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertSame(b, entries.get(1)); | |||
} | |||
@Test | |||
public void testNoRenames_SymlinkAndFileSamePath() throws Exception { | |||
ObjectId aId = blob("src/dest"); | |||
@@ -401,6 +428,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertSame(b, entries.get(1)); | |||
} | |||
@Test | |||
public void testBreakModify_BreakAll() throws Exception { | |||
ObjectId aId = blob("foo"); | |||
ObjectId bId = blob("bar"); | |||
@@ -422,6 +450,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertRename(DiffEntry.breakModify(m).get(0), a, 100, entries.get(1)); | |||
} | |||
@Test | |||
public void testBreakModify_BreakNone() throws Exception { | |||
ObjectId aId = blob("foo"); | |||
ObjectId bId = blob("bar"); | |||
@@ -443,6 +472,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertSame(a, entries.get(1)); | |||
} | |||
@Test | |||
public void testBreakModify_BreakBelowScore() throws Exception { | |||
ObjectId aId = blob("foo"); | |||
ObjectId bId = blob("bar"); | |||
@@ -464,6 +494,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertRename(DiffEntry.breakModify(m).get(0), a, 100, entries.get(1)); | |||
} | |||
@Test | |||
public void testBreakModify_DontBreakAboveScore() throws Exception { | |||
ObjectId aId = blob("blah\nblah\nfoo"); | |||
ObjectId bId = blob("blah\nblah\nbar"); | |||
@@ -485,6 +516,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertSame(a, entries.get(1)); | |||
} | |||
@Test | |||
public void testBreakModify_RejoinIfUnpaired() throws Exception { | |||
ObjectId aId = blob("foo"); | |||
ObjectId bId = blob("bar"); | |||
@@ -511,6 +543,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
assertEquals(0, modify.score); | |||
} | |||
@Test | |||
public void testSetRenameScore_IllegalArgs() throws Exception { | |||
try { | |||
rd.setRenameScore(-1); | |||
@@ -527,6 +560,7 @@ public class RenameDetectorTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testRenameLimit() throws Exception { | |||
ObjectId aId = blob("foo\nbar\nbaz\nblarg\n"); | |||
ObjectId bId = blob("foo\nbar\nbaz\nblah\n"); |
@@ -43,15 +43,18 @@ | |||
package org.eclipse.jgit.diff; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.ByteArrayInputStream; | |||
import java.io.IOException; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jgit.diff.SimilarityIndex.TableFullException; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.junit.Test; | |||
public class SimilarityIndexTest extends TestCase { | |||
public class SimilarityIndexTest { | |||
@Test | |||
public void testIndexingSmallObject() throws TableFullException { | |||
SimilarityIndex si = hash("" // | |||
+ "A\n" // | |||
@@ -71,6 +74,7 @@ public class SimilarityIndexTest extends TestCase { | |||
assertEquals(2, si.count(si.findIndex(key_D))); | |||
} | |||
@Test | |||
public void testIndexingLargeObject() throws IOException, | |||
TableFullException { | |||
byte[] in = ("" // | |||
@@ -83,6 +87,7 @@ public class SimilarityIndexTest extends TestCase { | |||
assertEquals(2, si.size()); | |||
} | |||
@Test | |||
public void testCommonScore_SameFiles() throws TableFullException { | |||
String text = "" // | |||
+ "A\n" // | |||
@@ -98,6 +103,7 @@ public class SimilarityIndexTest extends TestCase { | |||
assertEquals(100, dst.score(src, 100)); | |||
} | |||
@Test | |||
public void testCommonScore_EmptyFiles() throws TableFullException { | |||
SimilarityIndex src = hash(""); | |||
SimilarityIndex dst = hash(""); | |||
@@ -105,6 +111,7 @@ public class SimilarityIndexTest extends TestCase { | |||
assertEquals(0, dst.common(src)); | |||
} | |||
@Test | |||
public void testCommonScore_TotallyDifferentFiles() | |||
throws TableFullException { | |||
SimilarityIndex src = hash("A\n"); | |||
@@ -113,6 +120,7 @@ public class SimilarityIndexTest extends TestCase { | |||
assertEquals(0, dst.common(src)); | |||
} | |||
@Test | |||
public void testCommonScore_SimiliarBy75() throws TableFullException { | |||
SimilarityIndex src = hash("A\nB\nC\nD\n"); | |||
SimilarityIndex dst = hash("A\nB\nC\nQ\n"); |
@@ -43,13 +43,20 @@ | |||
package org.eclipse.jgit.dircache; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.File; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.eclipse.jgit.lib.FileMode; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.junit.Test; | |||
public class DirCacheBasicTest extends RepositoryTestCase { | |||
@Test | |||
public void testReadMissing_RealIndex() throws Exception { | |||
final File idx = new File(db.getDirectory(), "index"); | |||
assertFalse(idx.exists()); | |||
@@ -59,6 +66,7 @@ public class DirCacheBasicTest extends RepositoryTestCase { | |||
assertEquals(0, dc.getEntryCount()); | |||
} | |||
@Test | |||
public void testReadMissing_TempIndex() throws Exception { | |||
final File idx = new File(db.getDirectory(), "tmp_index"); | |||
assertFalse(idx.exists()); | |||
@@ -68,6 +76,7 @@ public class DirCacheBasicTest extends RepositoryTestCase { | |||
assertEquals(0, dc.getEntryCount()); | |||
} | |||
@Test | |||
public void testLockMissing_RealIndex() throws Exception { | |||
final File idx = new File(db.getDirectory(), "index"); | |||
final File lck = new File(db.getDirectory(), "index.lock"); | |||
@@ -85,6 +94,7 @@ public class DirCacheBasicTest extends RepositoryTestCase { | |||
assertFalse(lck.exists()); | |||
} | |||
@Test | |||
public void testLockMissing_TempIndex() throws Exception { | |||
final File idx = new File(db.getDirectory(), "tmp_index"); | |||
final File lck = new File(db.getDirectory(), "tmp_index.lock"); | |||
@@ -102,6 +112,7 @@ public class DirCacheBasicTest extends RepositoryTestCase { | |||
assertFalse(lck.exists()); | |||
} | |||
@Test | |||
public void testWriteEmptyUnlock_RealIndex() throws Exception { | |||
final File idx = new File(db.getDirectory(), "index"); | |||
final File lck = new File(db.getDirectory(), "index.lock"); | |||
@@ -118,6 +129,7 @@ public class DirCacheBasicTest extends RepositoryTestCase { | |||
assertFalse(lck.exists()); | |||
} | |||
@Test | |||
public void testWriteEmptyCommit_RealIndex() throws Exception { | |||
final File idx = new File(db.getDirectory(), "index"); | |||
final File lck = new File(db.getDirectory(), "index.lock"); | |||
@@ -135,6 +147,7 @@ public class DirCacheBasicTest extends RepositoryTestCase { | |||
assertEquals(12 + 20, idx.length()); | |||
} | |||
@Test | |||
public void testWriteEmptyReadEmpty_RealIndex() throws Exception { | |||
final File idx = new File(db.getDirectory(), "index"); | |||
final File lck = new File(db.getDirectory(), "index.lock"); | |||
@@ -152,6 +165,7 @@ public class DirCacheBasicTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testWriteEmptyLockEmpty_RealIndex() throws Exception { | |||
final File idx = new File(db.getDirectory(), "index"); | |||
final File lck = new File(db.getDirectory(), "index.lock"); | |||
@@ -172,6 +186,7 @@ public class DirCacheBasicTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testBuildThenClear() throws Exception { | |||
final DirCache dc = db.readDirCache(); | |||
@@ -194,6 +209,7 @@ public class DirCacheBasicTest extends RepositoryTestCase { | |||
assertFalse(dc.hasUnmergedPaths()); | |||
} | |||
@Test | |||
public void testDetectUnmergedPaths() throws Exception { | |||
final DirCache dc = db.readDirCache(); | |||
final DirCacheEntry[] ents = new DirCacheEntry[3]; | |||
@@ -212,6 +228,7 @@ public class DirCacheBasicTest extends RepositoryTestCase { | |||
assertTrue(dc.hasUnmergedPaths()); | |||
} | |||
@Test | |||
public void testFindOnEmpty() throws Exception { | |||
final DirCache dc = DirCache.newInCore(); | |||
final byte[] path = Constants.encode("a"); |
@@ -43,14 +43,22 @@ | |||
package org.eclipse.jgit.dircache; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
import java.util.Collections; | |||
import org.eclipse.jgit.lib.FileMode; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.eclipse.jgit.treewalk.TreeWalk; | |||
import org.eclipse.jgit.treewalk.filter.PathFilterGroup; | |||
import org.junit.Test; | |||
public class DirCacheBuilderIteratorTest extends RepositoryTestCase { | |||
@Test | |||
public void testPathFilterGroup_DoesNotSkipTail() throws Exception { | |||
final DirCache dc = db.readDirCache(); | |||
@@ -43,13 +43,22 @@ | |||
package org.eclipse.jgit.dircache; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertNotSame; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.File; | |||
import org.eclipse.jgit.lib.FileMode; | |||
import org.eclipse.jgit.lib.ObjectId; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.junit.Test; | |||
public class DirCacheBuilderTest extends RepositoryTestCase { | |||
@Test | |||
public void testBuildEmpty() throws Exception { | |||
{ | |||
final DirCache dc = db.lockDirCache(); | |||
@@ -65,6 +74,7 @@ public class DirCacheBuilderTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testBuildRejectsUnsetFileMode() throws Exception { | |||
final DirCache dc = DirCache.newInCore(); | |||
final DirCacheBuilder b = dc.builder(); | |||
@@ -79,6 +89,7 @@ public class DirCacheBuilderTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testBuildOneFile_FinishWriteCommit() throws Exception { | |||
final String path = "a-file-path"; | |||
final FileMode mode = FileMode.REGULAR_FILE; | |||
@@ -128,6 +139,7 @@ public class DirCacheBuilderTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testBuildOneFile_Commit() throws Exception { | |||
final String path = "a-file-path"; | |||
final FileMode mode = FileMode.REGULAR_FILE; | |||
@@ -175,6 +187,7 @@ public class DirCacheBuilderTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testFindSingleFile() throws Exception { | |||
final String path = "a-file-path"; | |||
final DirCache dc = db.readDirCache(); | |||
@@ -201,6 +214,7 @@ public class DirCacheBuilderTest extends RepositoryTestCase { | |||
assertSame(entOrig, dc.getEntry(path)); | |||
} | |||
@Test | |||
public void testAdd_InGitSortOrder() throws Exception { | |||
final DirCache dc = db.readDirCache(); | |||
@@ -225,6 +239,7 @@ public class DirCacheBuilderTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testAdd_ReverseGitSortOrder() throws Exception { | |||
final DirCache dc = db.readDirCache(); | |||
@@ -249,6 +264,7 @@ public class DirCacheBuilderTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testBuilderClear() throws Exception { | |||
final DirCache dc = db.readDirCache(); | |||
@@ -43,6 +43,11 @@ | |||
package org.eclipse.jgit.dircache; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.BufferedReader; | |||
import java.io.ByteArrayOutputStream; | |||
import java.io.File; | |||
@@ -55,6 +60,7 @@ import java.util.LinkedHashMap; | |||
import java.util.Map; | |||
import org.eclipse.jgit.errors.CorruptObjectException; | |||
import org.eclipse.jgit.junit.JGitTestUtil; | |||
import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase; | |||
import org.eclipse.jgit.lib.FileMode; | |||
import org.eclipse.jgit.lib.ObjectId; | |||
@@ -62,11 +68,12 @@ import org.eclipse.jgit.lib.Repository; | |||
import org.eclipse.jgit.treewalk.TreeWalk; | |||
import org.eclipse.jgit.util.FS; | |||
import org.eclipse.jgit.util.IO; | |||
import org.eclipse.jgit.util.JGitTestUtil; | |||
import org.junit.Test; | |||
public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase { | |||
private final File index = pathOf("gitgit.index"); | |||
@Test | |||
public void testReadIndex_LsFiles() throws Exception { | |||
final Map<String, CGitIndexRecord> ls = readLsFiles(); | |||
final DirCache dc = new DirCache(index, FS.DETECTED); | |||
@@ -80,6 +87,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testTreeWalk_LsFiles() throws Exception { | |||
final Repository db = createBareRepository(); | |||
final Map<String, CGitIndexRecord> ls = readLsFiles(); | |||
@@ -104,6 +112,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testUnsupportedOptionalExtension() throws Exception { | |||
final DirCache dc = new DirCache(pathOf("gitgit.index.ZZZZ"), | |||
FS.DETECTED); | |||
@@ -112,6 +121,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase { | |||
assertEquals("A", dc.getEntry(0).getPathString()); | |||
} | |||
@Test | |||
public void testUnsupportedRequiredExtension() throws Exception { | |||
final DirCache dc = new DirCache(pathOf("gitgit.index.aaaa"), | |||
FS.DETECTED); | |||
@@ -124,6 +134,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCorruptChecksumAtFooter() throws Exception { | |||
final DirCache dc = new DirCache(pathOf("gitgit.index.badchecksum"), | |||
FS.DETECTED); | |||
@@ -146,6 +157,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase { | |||
assertEquals(c.stage, j.getStage()); | |||
} | |||
@Test | |||
public void testReadIndex_DirCacheTree() throws Exception { | |||
final Map<String, CGitIndexRecord> cList = readLsFiles(); | |||
final Map<String, CGitLsTreeRecord> cTree = readLsTree(); | |||
@@ -181,6 +193,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testReadWriteV3() throws Exception { | |||
final File file = pathOf("gitgit.index.v3"); | |||
final DirCache dc = new DirCache(file, FS.DETECTED); |
@@ -43,12 +43,18 @@ | |||
package org.eclipse.jgit.dircache; | |||
import junit.framework.TestCase; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.eclipse.jgit.lib.FileMode; | |||
import org.junit.Test; | |||
public class DirCacheEntryTest extends TestCase { | |||
public class DirCacheEntryTest { | |||
@Test | |||
public void testIsValidPath() { | |||
assertTrue(isValidPath("a")); | |||
assertTrue(isValidPath("a/b")); | |||
@@ -67,6 +73,7 @@ public class DirCacheEntryTest extends TestCase { | |||
return DirCacheEntry.isValidPath(Constants.encode(path)); | |||
} | |||
@Test | |||
public void testCreate_ByStringPath() { | |||
assertEquals("a", new DirCacheEntry("a").getPathString()); | |||
assertEquals("a/b", new DirCacheEntry("a/b").getPathString()); | |||
@@ -79,6 +86,7 @@ public class DirCacheEntryTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testCreate_ByStringPathAndStage() { | |||
DirCacheEntry e; | |||
@@ -120,6 +128,7 @@ public class DirCacheEntryTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testSetFileMode() { | |||
final DirCacheEntry e = new DirCacheEntry("a"); | |||
@@ -43,10 +43,16 @@ | |||
package org.eclipse.jgit.dircache; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertSame; | |||
import org.eclipse.jgit.lib.FileMode; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.junit.Test; | |||
public class DirCacheFindTest extends RepositoryTestCase { | |||
@Test | |||
public void testEntriesWithin() throws Exception { | |||
final DirCache dc = db.readDirCache(); | |||
@@ -43,17 +43,25 @@ | |||
package org.eclipse.jgit.dircache; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.File; | |||
import java.util.Collections; | |||
import org.eclipse.jgit.junit.JGitTestUtil; | |||
import org.eclipse.jgit.lib.FileMode; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.eclipse.jgit.treewalk.TreeWalk; | |||
import org.eclipse.jgit.treewalk.filter.PathFilterGroup; | |||
import org.eclipse.jgit.util.FS; | |||
import org.eclipse.jgit.util.JGitTestUtil; | |||
import org.junit.Test; | |||
public class DirCacheIteratorTest extends RepositoryTestCase { | |||
@Test | |||
public void testEmptyTree_NoTreeWalk() throws Exception { | |||
final DirCache dc = DirCache.newInCore(); | |||
assertEquals(0, dc.getEntryCount()); | |||
@@ -62,6 +70,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase { | |||
assertTrue(i.eof()); | |||
} | |||
@Test | |||
public void testEmptyTree_WithTreeWalk() throws Exception { | |||
final DirCache dc = DirCache.newInCore(); | |||
assertEquals(0, dc.getEntryCount()); | |||
@@ -71,6 +80,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase { | |||
assertFalse(tw.next()); | |||
} | |||
@Test | |||
public void testNoSubtree_NoTreeWalk() throws Exception { | |||
final DirCache dc = DirCache.newInCore(); | |||
@@ -96,6 +106,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase { | |||
assertEquals(paths.length, pathIdx); | |||
} | |||
@Test | |||
public void testNoSubtree_WithTreeWalk() throws Exception { | |||
final DirCache dc = DirCache.newInCore(); | |||
@@ -128,6 +139,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase { | |||
assertEquals(paths.length, pathIdx); | |||
} | |||
@Test | |||
public void testSingleSubtree_NoRecursion() throws Exception { | |||
final DirCache dc = DirCache.newInCore(); | |||
@@ -171,6 +183,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase { | |||
assertEquals(expPaths.length, pathIdx); | |||
} | |||
@Test | |||
public void testSingleSubtree_Recursive() throws Exception { | |||
final DirCache dc = DirCache.newInCore(); | |||
@@ -205,6 +218,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase { | |||
assertEquals(paths.length, pathIdx); | |||
} | |||
@Test | |||
public void testTwoLevelSubtree_Recursive() throws Exception { | |||
final DirCache dc = DirCache.newInCore(); | |||
@@ -238,6 +252,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase { | |||
assertEquals(paths.length, pathIdx); | |||
} | |||
@Test | |||
public void testTwoLevelSubtree_FilterPath() throws Exception { | |||
final DirCache dc = DirCache.newInCore(); | |||
@@ -273,6 +288,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testRemovedSubtree() throws Exception { | |||
final File path = JGitTestUtil | |||
.getTestResourceFile("dircache.testRemovedSubtree"); |
@@ -43,29 +43,40 @@ | |||
package org.eclipse.jgit.dircache; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertNotSame; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.IOException; | |||
import org.eclipse.jgit.errors.CorruptObjectException; | |||
import org.eclipse.jgit.lib.FileMode; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.junit.Test; | |||
public class DirCacheLargePathTest extends RepositoryTestCase { | |||
@Test | |||
public void testPath_4090() throws Exception { | |||
testLongPath(4090); | |||
} | |||
@Test | |||
public void testPath_4094() throws Exception { | |||
testLongPath(4094); | |||
} | |||
@Test | |||
public void testPath_4095() throws Exception { | |||
testLongPath(4095); | |||
} | |||
@Test | |||
public void testPath_4096() throws Exception { | |||
testLongPath(4096); | |||
} | |||
@Test | |||
public void testPath_16384() throws Exception { | |||
testLongPath(16384); | |||
} |
@@ -43,18 +43,28 @@ | |||
package org.eclipse.jgit.dircache; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertNotSame; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertSame; | |||
import java.io.IOException; | |||
import org.eclipse.jgit.errors.CorruptObjectException; | |||
import org.eclipse.jgit.lib.FileMode; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.junit.Test; | |||
public class DirCacheTreeTest extends RepositoryTestCase { | |||
@Test | |||
public void testEmptyCache_NoCacheTree() throws Exception { | |||
final DirCache dc = db.readDirCache(); | |||
assertNull(dc.getCacheTree(false)); | |||
} | |||
@Test | |||
public void testEmptyCache_CreateEmptyCacheTree() throws Exception { | |||
final DirCache dc = db.readDirCache(); | |||
final DirCacheTree tree = dc.getCacheTree(true); | |||
@@ -68,6 +78,7 @@ public class DirCacheTreeTest extends RepositoryTestCase { | |||
assertFalse(tree.isValid()); | |||
} | |||
@Test | |||
public void testEmptyCache_Clear_NoCacheTree() throws Exception { | |||
final DirCache dc = db.readDirCache(); | |||
final DirCacheTree tree = dc.getCacheTree(true); | |||
@@ -77,6 +88,7 @@ public class DirCacheTreeTest extends RepositoryTestCase { | |||
assertNotSame(tree, dc.getCacheTree(true)); | |||
} | |||
@Test | |||
public void testSingleSubtree() throws Exception { | |||
final DirCache dc = db.readDirCache(); | |||
@@ -114,6 +126,7 @@ public class DirCacheTreeTest extends RepositoryTestCase { | |||
assertFalse(aTree.isValid()); | |||
} | |||
@Test | |||
public void testTwoLevelSubtree() throws Exception { | |||
final DirCache dc = db.readDirCache(); | |||
@@ -171,6 +184,7 @@ public class DirCacheTreeTest extends RepositoryTestCase { | |||
* @throws CorruptObjectException | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testWriteReadTree() throws CorruptObjectException, IOException { | |||
final DirCache dc = db.lockDirCache(); | |||
@@ -42,10 +42,16 @@ | |||
*/ | |||
package org.eclipse.jgit.events; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertNull; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.eclipse.jgit.storage.file.FileBasedConfig; | |||
import org.junit.Test; | |||
public class ConfigChangeEventTest extends RepositoryTestCase { | |||
@Test | |||
public void testFileRepository_ChangeEventsOnlyOnSave() throws Exception { | |||
final ConfigChangedEvent[] events = new ConfigChangedEvent[1]; | |||
db.getListenerList().addConfigChangedListener( |
@@ -44,12 +44,14 @@ | |||
package org.eclipse.jgit.fnmatch; | |||
import org.eclipse.jgit.errors.InvalidPatternException; | |||
import org.eclipse.jgit.fnmatch.FileNameMatcher; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jgit.errors.InvalidPatternException; | |||
import org.junit.Test; | |||
public class FileNameMatcherTest extends TestCase { | |||
public class FileNameMatcherTest { | |||
private void assertMatch(final String pattern, final String input, | |||
final boolean matchExpected, final boolean appendCanMatchExpected) | |||
@@ -71,178 +73,222 @@ public class FileNameMatcherTest extends TestCase { | |||
assertEquals(appendCanMatchExpected, matcher.canAppendMatch()); | |||
} | |||
@Test | |||
public void testVerySimplePatternCase0() throws Exception { | |||
assertMatch("", "", true, false); | |||
} | |||
@Test | |||
public void testVerySimplePatternCase1() throws Exception { | |||
assertMatch("ab", "a", false, true); | |||
} | |||
@Test | |||
public void testVerySimplePatternCase2() throws Exception { | |||
assertMatch("ab", "ab", true, false); | |||
} | |||
@Test | |||
public void testVerySimplePatternCase3() throws Exception { | |||
assertMatch("ab", "ac", false, false); | |||
} | |||
@Test | |||
public void testVerySimplePatternCase4() throws Exception { | |||
assertMatch("ab", "abc", false, false); | |||
} | |||
@Test | |||
public void testVerySimpleWirdcardCase0() throws Exception { | |||
assertMatch("?", "a", true, false); | |||
} | |||
@Test | |||
public void testVerySimpleWildCardCase1() throws Exception { | |||
assertMatch("??", "a", false, true); | |||
} | |||
@Test | |||
public void testVerySimpleWildCardCase2() throws Exception { | |||
assertMatch("??", "ab", true, false); | |||
} | |||
@Test | |||
public void testVerySimpleWildCardCase3() throws Exception { | |||
assertMatch("??", "abc", false, false); | |||
} | |||
@Test | |||
public void testVerySimpleStarCase0() throws Exception { | |||
assertMatch("*", "", true, true); | |||
} | |||
@Test | |||
public void testVerySimpleStarCase1() throws Exception { | |||
assertMatch("*", "a", true, true); | |||
} | |||
@Test | |||
public void testVerySimpleStarCase2() throws Exception { | |||
assertMatch("*", "ab", true, true); | |||
} | |||
@Test | |||
public void testSimpleStarCase0() throws Exception { | |||
assertMatch("a*b", "a", false, true); | |||
} | |||
@Test | |||
public void testSimpleStarCase1() throws Exception { | |||
assertMatch("a*c", "ac", true, true); | |||
} | |||
@Test | |||
public void testSimpleStarCase2() throws Exception { | |||
assertMatch("a*c", "ab", false, true); | |||
} | |||
@Test | |||
public void testSimpleStarCase3() throws Exception { | |||
assertMatch("a*c", "abc", true, true); | |||
} | |||
@Test | |||
public void testManySolutionsCase0() throws Exception { | |||
assertMatch("a*a*a", "aaa", true, true); | |||
} | |||
@Test | |||
public void testManySolutionsCase1() throws Exception { | |||
assertMatch("a*a*a", "aaaa", true, true); | |||
} | |||
@Test | |||
public void testManySolutionsCase2() throws Exception { | |||
assertMatch("a*a*a", "ababa", true, true); | |||
} | |||
@Test | |||
public void testManySolutionsCase3() throws Exception { | |||
assertMatch("a*a*a", "aaaaaaaa", true, true); | |||
} | |||
@Test | |||
public void testManySolutionsCase4() throws Exception { | |||
assertMatch("a*a*a", "aaaaaaab", false, true); | |||
} | |||
@Test | |||
public void testVerySimpleGroupCase0() throws Exception { | |||
assertMatch("[ab]", "a", true, false); | |||
} | |||
@Test | |||
public void testVerySimpleGroupCase1() throws Exception { | |||
assertMatch("[ab]", "b", true, false); | |||
} | |||
@Test | |||
public void testVerySimpleGroupCase2() throws Exception { | |||
assertMatch("[ab]", "ab", false, false); | |||
} | |||
@Test | |||
public void testVerySimpleGroupRangeCase0() throws Exception { | |||
assertMatch("[b-d]", "a", false, false); | |||
} | |||
@Test | |||
public void testVerySimpleGroupRangeCase1() throws Exception { | |||
assertMatch("[b-d]", "b", true, false); | |||
} | |||
@Test | |||
public void testVerySimpleGroupRangeCase2() throws Exception { | |||
assertMatch("[b-d]", "c", true, false); | |||
} | |||
@Test | |||
public void testVerySimpleGroupRangeCase3() throws Exception { | |||
assertMatch("[b-d]", "d", true, false); | |||
} | |||
@Test | |||
public void testVerySimpleGroupRangeCase4() throws Exception { | |||
assertMatch("[b-d]", "e", false, false); | |||
} | |||
@Test | |||
public void testVerySimpleGroupRangeCase5() throws Exception { | |||
assertMatch("[b-d]", "-", false, false); | |||
} | |||
@Test | |||
public void testTwoGroupsCase0() throws Exception { | |||
assertMatch("[b-d][ab]", "bb", true, false); | |||
} | |||
@Test | |||
public void testTwoGroupsCase1() throws Exception { | |||
assertMatch("[b-d][ab]", "ca", true, false); | |||
} | |||
@Test | |||
public void testTwoGroupsCase2() throws Exception { | |||
assertMatch("[b-d][ab]", "fa", false, false); | |||
} | |||
@Test | |||
public void testTwoGroupsCase3() throws Exception { | |||
assertMatch("[b-d][ab]", "bc", false, false); | |||
} | |||
@Test | |||
public void testTwoRangesInOneGroupCase0() throws Exception { | |||
assertMatch("[b-ce-e]", "a", false, false); | |||
} | |||
@Test | |||
public void testTwoRangesInOneGroupCase1() throws Exception { | |||
assertMatch("[b-ce-e]", "b", true, false); | |||
} | |||
@Test | |||
public void testTwoRangesInOneGroupCase2() throws Exception { | |||
assertMatch("[b-ce-e]", "c", true, false); | |||
} | |||
@Test | |||
public void testTwoRangesInOneGroupCase3() throws Exception { | |||
assertMatch("[b-ce-e]", "d", false, false); | |||
} | |||
@Test | |||
public void testTwoRangesInOneGroupCase4() throws Exception { | |||
assertMatch("[b-ce-e]", "e", true, false); | |||
} | |||
@Test | |||
public void testTwoRangesInOneGroupCase5() throws Exception { | |||
assertMatch("[b-ce-e]", "f", false, false); | |||
} | |||
@Test | |||
public void testIncompleteRangesInOneGroupCase0() throws Exception { | |||
assertMatch("a[b-]", "ab", true, false); | |||
} | |||
@Test | |||
public void testIncompleteRangesInOneGroupCase1() throws Exception { | |||
assertMatch("a[b-]", "ac", false, false); | |||
} | |||
@Test | |||
public void testIncompleteRangesInOneGroupCase2() throws Exception { | |||
assertMatch("a[b-]", "a-", true, false); | |||
} | |||
@Test | |||
public void testCombinedRangesInOneGroupCase0() throws Exception { | |||
assertMatch("[a-c-e]", "b", true, false); | |||
} | |||
@@ -254,383 +300,476 @@ public class FileNameMatcherTest extends TestCase { | |||
* @throws Exception | |||
* for some reasons | |||
*/ | |||
@Test | |||
public void testCombinedRangesInOneGroupCase1() throws Exception { | |||
assertMatch("[a-c-e]", "d", false, false); | |||
} | |||
@Test | |||
public void testCombinedRangesInOneGroupCase2() throws Exception { | |||
assertMatch("[a-c-e]", "e", true, false); | |||
} | |||
@Test | |||
public void testInversedGroupCase0() throws Exception { | |||
assertMatch("[!b-c]", "a", true, false); | |||
} | |||
@Test | |||
public void testInversedGroupCase1() throws Exception { | |||
assertMatch("[!b-c]", "b", false, false); | |||
} | |||
@Test | |||
public void testInversedGroupCase2() throws Exception { | |||
assertMatch("[!b-c]", "c", false, false); | |||
} | |||
@Test | |||
public void testInversedGroupCase3() throws Exception { | |||
assertMatch("[!b-c]", "d", true, false); | |||
} | |||
@Test | |||
public void testAlphaGroupCase0() throws Exception { | |||
assertMatch("[[:alpha:]]", "d", true, false); | |||
} | |||
@Test | |||
public void testAlphaGroupCase1() throws Exception { | |||
assertMatch("[[:alpha:]]", ":", false, false); | |||
} | |||
@Test | |||
public void testAlphaGroupCase2() throws Exception { | |||
// \u00f6 = 'o' with dots on it | |||
assertMatch("[[:alpha:]]", "\u00f6", true, false); | |||
} | |||
@Test | |||
public void test2AlphaGroupsCase0() throws Exception { | |||
// \u00f6 = 'o' with dots on it | |||
assertMatch("[[:alpha:]][[:alpha:]]", "a\u00f6", true, false); | |||
assertMatch("[[:alpha:]][[:alpha:]]", "a1", false, false); | |||
} | |||
@Test | |||
public void testAlnumGroupCase0() throws Exception { | |||
assertMatch("[[:alnum:]]", "a", true, false); | |||
} | |||
@Test | |||
public void testAlnumGroupCase1() throws Exception { | |||
assertMatch("[[:alnum:]]", "1", true, false); | |||
} | |||
@Test | |||
public void testAlnumGroupCase2() throws Exception { | |||
assertMatch("[[:alnum:]]", ":", false, false); | |||
} | |||
@Test | |||
public void testBlankGroupCase0() throws Exception { | |||
assertMatch("[[:blank:]]", " ", true, false); | |||
} | |||
@Test | |||
public void testBlankGroupCase1() throws Exception { | |||
assertMatch("[[:blank:]]", "\t", true, false); | |||
} | |||
@Test | |||
public void testBlankGroupCase2() throws Exception { | |||
assertMatch("[[:blank:]]", "\r", false, false); | |||
} | |||
@Test | |||
public void testBlankGroupCase3() throws Exception { | |||
assertMatch("[[:blank:]]", "\n", false, false); | |||
} | |||
@Test | |||
public void testBlankGroupCase4() throws Exception { | |||
assertMatch("[[:blank:]]", "a", false, false); | |||
} | |||
@Test | |||
public void testCntrlGroupCase0() throws Exception { | |||
assertMatch("[[:cntrl:]]", "a", false, false); | |||
} | |||
@Test | |||
public void testCntrlGroupCase1() throws Exception { | |||
assertMatch("[[:cntrl:]]", String.valueOf((char) 7), true, false); | |||
} | |||
@Test | |||
public void testDigitGroupCase0() throws Exception { | |||
assertMatch("[[:digit:]]", "0", true, false); | |||
} | |||
@Test | |||
public void testDigitGroupCase1() throws Exception { | |||
assertMatch("[[:digit:]]", "5", true, false); | |||
} | |||
@Test | |||
public void testDigitGroupCase2() throws Exception { | |||
assertMatch("[[:digit:]]", "9", true, false); | |||
} | |||
@Test | |||
public void testDigitGroupCase3() throws Exception { | |||
// \u06f9 = EXTENDED ARABIC-INDIC DIGIT NINE | |||
assertMatch("[[:digit:]]", "\u06f9", true, false); | |||
} | |||
@Test | |||
public void testDigitGroupCase4() throws Exception { | |||
assertMatch("[[:digit:]]", "a", false, false); | |||
} | |||
@Test | |||
public void testDigitGroupCase5() throws Exception { | |||
assertMatch("[[:digit:]]", "]", false, false); | |||
} | |||
@Test | |||
public void testGraphGroupCase0() throws Exception { | |||
assertMatch("[[:graph:]]", "]", true, false); | |||
} | |||
@Test | |||
public void testGraphGroupCase1() throws Exception { | |||
assertMatch("[[:graph:]]", "a", true, false); | |||
} | |||
@Test | |||
public void testGraphGroupCase2() throws Exception { | |||
assertMatch("[[:graph:]]", ".", true, false); | |||
} | |||
@Test | |||
public void testGraphGroupCase3() throws Exception { | |||
assertMatch("[[:graph:]]", "0", true, false); | |||
} | |||
@Test | |||
public void testGraphGroupCase4() throws Exception { | |||
assertMatch("[[:graph:]]", " ", false, false); | |||
} | |||
@Test | |||
public void testGraphGroupCase5() throws Exception { | |||
// \u00f6 = 'o' with dots on it | |||
assertMatch("[[:graph:]]", "\u00f6", true, false); | |||
} | |||
@Test | |||
public void testLowerGroupCase0() throws Exception { | |||
assertMatch("[[:lower:]]", "a", true, false); | |||
} | |||
@Test | |||
public void testLowerGroupCase1() throws Exception { | |||
assertMatch("[[:lower:]]", "h", true, false); | |||
} | |||
@Test | |||
public void testLowerGroupCase2() throws Exception { | |||
assertMatch("[[:lower:]]", "A", false, false); | |||
} | |||
@Test | |||
public void testLowerGroupCase3() throws Exception { | |||
assertMatch("[[:lower:]]", "H", false, false); | |||
} | |||
@Test | |||
public void testLowerGroupCase4() throws Exception { | |||
// \u00e4 = small 'a' with dots on it | |||
assertMatch("[[:lower:]]", "\u00e4", true, false); | |||
} | |||
@Test | |||
public void testLowerGroupCase5() throws Exception { | |||
assertMatch("[[:lower:]]", ".", false, false); | |||
} | |||
@Test | |||
public void testPrintGroupCase0() throws Exception { | |||
assertMatch("[[:print:]]", "]", true, false); | |||
} | |||
@Test | |||
public void testPrintGroupCase1() throws Exception { | |||
assertMatch("[[:print:]]", "a", true, false); | |||
} | |||
@Test | |||
public void testPrintGroupCase2() throws Exception { | |||
assertMatch("[[:print:]]", ".", true, false); | |||
} | |||
@Test | |||
public void testPrintGroupCase3() throws Exception { | |||
assertMatch("[[:print:]]", "0", true, false); | |||
} | |||
@Test | |||
public void testPrintGroupCase4() throws Exception { | |||
assertMatch("[[:print:]]", " ", true, false); | |||
} | |||
@Test | |||
public void testPrintGroupCase5() throws Exception { | |||
// \u00f6 = 'o' with dots on it | |||
assertMatch("[[:print:]]", "\u00f6", true, false); | |||
} | |||
@Test | |||
public void testPunctGroupCase0() throws Exception { | |||
assertMatch("[[:punct:]]", ".", true, false); | |||
} | |||
@Test | |||
public void testPunctGroupCase1() throws Exception { | |||
assertMatch("[[:punct:]]", "@", true, false); | |||
} | |||
@Test | |||
public void testPunctGroupCase2() throws Exception { | |||
assertMatch("[[:punct:]]", " ", false, false); | |||
} | |||
@Test | |||
public void testPunctGroupCase3() throws Exception { | |||
assertMatch("[[:punct:]]", "a", false, false); | |||
} | |||
@Test | |||
public void testSpaceGroupCase0() throws Exception { | |||
assertMatch("[[:space:]]", " ", true, false); | |||
} | |||
@Test | |||
public void testSpaceGroupCase1() throws Exception { | |||
assertMatch("[[:space:]]", "\t", true, false); | |||
} | |||
@Test | |||
public void testSpaceGroupCase2() throws Exception { | |||
assertMatch("[[:space:]]", "\r", true, false); | |||
} | |||
@Test | |||
public void testSpaceGroupCase3() throws Exception { | |||
assertMatch("[[:space:]]", "\n", true, false); | |||
} | |||
@Test | |||
public void testSpaceGroupCase4() throws Exception { | |||
assertMatch("[[:space:]]", "a", false, false); | |||
} | |||
@Test | |||
public void testUpperGroupCase0() throws Exception { | |||
assertMatch("[[:upper:]]", "a", false, false); | |||
} | |||
@Test | |||
public void testUpperGroupCase1() throws Exception { | |||
assertMatch("[[:upper:]]", "h", false, false); | |||
} | |||
@Test | |||
public void testUpperGroupCase2() throws Exception { | |||
assertMatch("[[:upper:]]", "A", true, false); | |||
} | |||
@Test | |||
public void testUpperGroupCase3() throws Exception { | |||
assertMatch("[[:upper:]]", "H", true, false); | |||
} | |||
@Test | |||
public void testUpperGroupCase4() throws Exception { | |||
// \u00c4 = 'A' with dots on it | |||
assertMatch("[[:upper:]]", "\u00c4", true, false); | |||
} | |||
@Test | |||
public void testUpperGroupCase5() throws Exception { | |||
assertMatch("[[:upper:]]", ".", false, false); | |||
} | |||
@Test | |||
public void testXDigitGroupCase0() throws Exception { | |||
assertMatch("[[:xdigit:]]", "a", true, false); | |||
} | |||
@Test | |||
public void testXDigitGroupCase1() throws Exception { | |||
assertMatch("[[:xdigit:]]", "d", true, false); | |||
} | |||
@Test | |||
public void testXDigitGroupCase2() throws Exception { | |||
assertMatch("[[:xdigit:]]", "f", true, false); | |||
} | |||
@Test | |||
public void testXDigitGroupCase3() throws Exception { | |||
assertMatch("[[:xdigit:]]", "0", true, false); | |||
} | |||
@Test | |||
public void testXDigitGroupCase4() throws Exception { | |||
assertMatch("[[:xdigit:]]", "5", true, false); | |||
} | |||
@Test | |||
public void testXDigitGroupCase5() throws Exception { | |||
assertMatch("[[:xdigit:]]", "9", true, false); | |||
} | |||
@Test | |||
public void testXDigitGroupCase6() throws Exception { | |||
assertMatch("[[:xdigit:]]", "۹", false, false); | |||
} | |||
@Test | |||
public void testXDigitGroupCase7() throws Exception { | |||
assertMatch("[[:xdigit:]]", ".", false, false); | |||
} | |||
@Test | |||
public void testWordroupCase0() throws Exception { | |||
assertMatch("[[:word:]]", "g", true, false); | |||
} | |||
@Test | |||
public void testWordroupCase1() throws Exception { | |||
// \u00f6 = 'o' with dots on it | |||
assertMatch("[[:word:]]", "\u00f6", true, false); | |||
} | |||
@Test | |||
public void testWordroupCase2() throws Exception { | |||
assertMatch("[[:word:]]", "5", true, false); | |||
} | |||
@Test | |||
public void testWordroupCase3() throws Exception { | |||
assertMatch("[[:word:]]", "_", true, false); | |||
} | |||
@Test | |||
public void testWordroupCase4() throws Exception { | |||
assertMatch("[[:word:]]", " ", false, false); | |||
} | |||
@Test | |||
public void testWordroupCase5() throws Exception { | |||
assertMatch("[[:word:]]", ".", false, false); | |||
} | |||
@Test | |||
public void testMixedGroupCase0() throws Exception { | |||
assertMatch("[A[:lower:]C3-5]", "A", true, false); | |||
} | |||
@Test | |||
public void testMixedGroupCase1() throws Exception { | |||
assertMatch("[A[:lower:]C3-5]", "C", true, false); | |||
} | |||
@Test | |||
public void testMixedGroupCase2() throws Exception { | |||
assertMatch("[A[:lower:]C3-5]", "e", true, false); | |||
} | |||
@Test | |||
public void testMixedGroupCase3() throws Exception { | |||
assertMatch("[A[:lower:]C3-5]", "3", true, false); | |||
} | |||
@Test | |||
public void testMixedGroupCase4() throws Exception { | |||
assertMatch("[A[:lower:]C3-5]", "4", true, false); | |||
} | |||
@Test | |||
public void testMixedGroupCase5() throws Exception { | |||
assertMatch("[A[:lower:]C3-5]", "5", true, false); | |||
} | |||
@Test | |||
public void testMixedGroupCase6() throws Exception { | |||
assertMatch("[A[:lower:]C3-5]", "B", false, false); | |||
} | |||
@Test | |||
public void testMixedGroupCase7() throws Exception { | |||
assertMatch("[A[:lower:]C3-5]", "2", false, false); | |||
} | |||
@Test | |||
public void testMixedGroupCase8() throws Exception { | |||
assertMatch("[A[:lower:]C3-5]", "6", false, false); | |||
} | |||
@Test | |||
public void testMixedGroupCase9() throws Exception { | |||
assertMatch("[A[:lower:]C3-5]", ".", false, false); | |||
} | |||
@Test | |||
public void testSpecialGroupCase0() throws Exception { | |||
assertMatch("[[]", "[", true, false); | |||
} | |||
@Test | |||
public void testSpecialGroupCase1() throws Exception { | |||
assertMatch("[]]", "]", true, false); | |||
} | |||
@Test | |||
public void testSpecialGroupCase2() throws Exception { | |||
assertMatch("[]a]", "]", true, false); | |||
} | |||
@Test | |||
public void testSpecialGroupCase3() throws Exception { | |||
assertMatch("[a[]", "[", true, false); | |||
} | |||
@Test | |||
public void testSpecialGroupCase4() throws Exception { | |||
assertMatch("[a[]", "a", true, false); | |||
} | |||
@Test | |||
public void testSpecialGroupCase5() throws Exception { | |||
assertMatch("[!]]", "]", false, false); | |||
} | |||
@Test | |||
public void testSpecialGroupCase6() throws Exception { | |||
assertMatch("[!]]", "x", true, false); | |||
} | |||
@Test | |||
public void testSpecialGroupCase7() throws Exception { | |||
assertMatch("[:]]", ":]", true, false); | |||
} | |||
@Test | |||
public void testSpecialGroupCase8() throws Exception { | |||
assertMatch("[:]]", ":", false, true); | |||
} | |||
@Test | |||
public void testSpecialGroupCase9() throws Exception { | |||
try { | |||
assertMatch("[[:]", ":", true, true); | |||
@@ -640,6 +779,7 @@ public class FileNameMatcherTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testUnsupportedGroupCase0() throws Exception { | |||
try { | |||
assertMatch("[[=a=]]", "b", false, false); | |||
@@ -649,6 +789,7 @@ public class FileNameMatcherTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testUnsupportedGroupCase1() throws Exception { | |||
try { | |||
assertMatch("[[.a.]]", "b", false, false); | |||
@@ -658,26 +799,32 @@ public class FileNameMatcherTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testFilePathSimpleCase() throws Exception { | |||
assertFileNameMatch("a/b", "a/b", '/', true, false); | |||
} | |||
@Test | |||
public void testFilePathCase0() throws Exception { | |||
assertFileNameMatch("a*b", "a/b", '/', false, false); | |||
} | |||
@Test | |||
public void testFilePathCase1() throws Exception { | |||
assertFileNameMatch("a?b", "a/b", '/', false, false); | |||
} | |||
@Test | |||
public void testFilePathCase2() throws Exception { | |||
assertFileNameMatch("a*b", "a\\b", '\\', false, false); | |||
} | |||
@Test | |||
public void testFilePathCase3() throws Exception { | |||
assertFileNameMatch("a?b", "a\\b", '\\', false, false); | |||
} | |||
@Test | |||
public void testReset() throws Exception { | |||
final String pattern = "helloworld"; | |||
final FileNameMatcher matcher = new FileNameMatcher(pattern, null); | |||
@@ -700,6 +847,7 @@ public class FileNameMatcherTest extends TestCase { | |||
assertEquals(false, matcher.canAppendMatch()); | |||
} | |||
@Test | |||
public void testCreateMatcherForSuffix() throws Exception { | |||
final String pattern = "helloworld"; | |||
final FileNameMatcher matcher = new FileNameMatcher(pattern, null); | |||
@@ -731,6 +879,7 @@ public class FileNameMatcherTest extends TestCase { | |||
assertEquals(false, childMatcher.canAppendMatch()); | |||
} | |||
@Test | |||
public void testCopyConstructor() throws Exception { | |||
final String pattern = "helloworld"; | |||
final FileNameMatcher matcher = new FileNameMatcher(pattern, null); |
@@ -42,15 +42,19 @@ | |||
*/ | |||
package org.eclipse.jgit.ignore; | |||
import junit.framework.Assert; | |||
import junit.framework.TestCase; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import org.junit.Test; | |||
/** | |||
* Tests ignore pattern matches | |||
*/ | |||
public class IgnoreMatcherTest extends TestCase{ | |||
public class IgnoreMatcherTest { | |||
@Test | |||
public void testBasic() { | |||
String pattern = "/test.stp"; | |||
assertMatched(pattern, "/test.stp"); | |||
@@ -59,6 +63,7 @@ public class IgnoreMatcherTest extends TestCase{ | |||
assertNotMatched(pattern, "/test.stp"); | |||
} | |||
@Test | |||
public void testFileNameWildcards() { | |||
//Test basic * and ? for any pattern + any character | |||
String pattern = "*.st?"; | |||
@@ -118,6 +123,7 @@ public class IgnoreMatcherTest extends TestCase{ | |||
assertNotMatched(pattern, "/src/new.c"); | |||
} | |||
@Test | |||
public void testTargetWithoutLeadingSlash() { | |||
//Test basic * and ? for any pattern + any character | |||
String pattern = "/*.st?"; | |||
@@ -177,6 +183,7 @@ public class IgnoreMatcherTest extends TestCase{ | |||
assertNotMatched(pattern, "src/new.c"); | |||
} | |||
@Test | |||
public void testParentDirectoryGitIgnores() { | |||
//Contains git ignore patterns such as might be seen in a parent directory | |||
@@ -210,6 +217,7 @@ public class IgnoreMatcherTest extends TestCase{ | |||
assertNotMatched(pattern, "/src/new/a/file.c"); | |||
} | |||
@Test | |||
public void testTrailingSlash() { | |||
String pattern = "/src/"; | |||
assertMatched(pattern, "/src/"); | |||
@@ -220,6 +228,7 @@ public class IgnoreMatcherTest extends TestCase{ | |||
assertNotMatched(pattern, "/srcA/"); | |||
} | |||
@Test | |||
public void testNameOnlyMatches() { | |||
/* | |||
* Name-only matches do not contain any path separators | |||
@@ -270,11 +279,13 @@ public class IgnoreMatcherTest extends TestCase{ | |||
assertNotMatched(pattern, "/cr3"); | |||
} | |||
@Test | |||
public void testNegation() { | |||
String pattern = "!/test.stp"; | |||
assertMatched(pattern, "/test.stp"); | |||
} | |||
@Test | |||
public void testGetters() { | |||
IgnoreRule r = new IgnoreRule("/pattern/"); | |||
assertFalse(r.getNameOnly()); | |||
@@ -329,7 +340,8 @@ public class IgnoreMatcherTest extends TestCase{ | |||
*/ | |||
public void assertMatched(String pattern, String target) { | |||
boolean value = match(pattern, target); | |||
Assert.assertTrue("Expected a match for: " + pattern + " with: " + target, value); | |||
assertTrue("Expected a match for: " + pattern + " with: " + target, | |||
value); | |||
} | |||
/** | |||
@@ -342,7 +354,8 @@ public class IgnoreMatcherTest extends TestCase{ | |||
*/ | |||
public void assertNotMatched(String pattern, String target) { | |||
boolean value = match(pattern, target); | |||
Assert.assertFalse("Expected no match for: " + pattern + " with: " + target, value); | |||
assertFalse("Expected no match for: " + pattern + " with: " + target, | |||
value); | |||
} | |||
/** |
@@ -42,6 +42,10 @@ | |||
*/ | |||
package org.eclipse.jgit.ignore; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.File; | |||
import java.io.IOException; | |||
@@ -52,6 +56,7 @@ import org.eclipse.jgit.treewalk.FileTreeIterator; | |||
import org.eclipse.jgit.treewalk.TreeWalk; | |||
import org.eclipse.jgit.treewalk.WorkingTreeIterator; | |||
import org.eclipse.jgit.util.FileUtils; | |||
import org.junit.Test; | |||
/** | |||
* Tests ignore node behavior on the local filesystem. | |||
@@ -67,6 +72,7 @@ public class IgnoreNodeTest extends RepositoryTestCase { | |||
private TreeWalk walk; | |||
@Test | |||
public void testRules() throws IOException { | |||
writeIgnoreFile(".git/info/exclude", "*~", "/out"); | |||
@@ -105,6 +111,7 @@ public class IgnoreNodeTest extends RepositoryTestCase { | |||
assertEntry(F, ignored, "src/config/old/lex.out"); | |||
} | |||
@Test | |||
public void testNegation() throws IOException { | |||
writeIgnoreFile(".gitignore", "*.o"); | |||
writeIgnoreFile("src/a/b/.gitignore", "!keep.o"); | |||
@@ -121,6 +128,7 @@ public class IgnoreNodeTest extends RepositoryTestCase { | |||
assertEntry(F, ignored, "src/a/b/nothere.o"); | |||
} | |||
@Test | |||
public void testSlashOnlyMatchesDirectory() throws IOException { | |||
writeIgnoreFile(".gitignore", "out/"); | |||
writeTrashFile("out", ""); | |||
@@ -138,6 +146,7 @@ public class IgnoreNodeTest extends RepositoryTestCase { | |||
assertEntry(F, ignored, "out/foo"); | |||
} | |||
@Test | |||
public void testWithSlashDoesNotMatchInSubDirectory() throws IOException { | |||
writeIgnoreFile(".gitignore", "a/b"); | |||
writeTrashFile("a/a", ""); |
@@ -43,9 +43,17 @@ | |||
package org.eclipse.jgit.lib; | |||
import junit.framework.TestCase; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertNotSame; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertTrue; | |||
public class AbbreviatedObjectIdTest extends TestCase { | |||
import org.junit.Test; | |||
public class AbbreviatedObjectIdTest { | |||
@Test | |||
public void testEmpty_FromByteArray() { | |||
final AbbreviatedObjectId i; | |||
i = AbbreviatedObjectId.fromString(new byte[] {}, 0, 0); | |||
@@ -55,6 +63,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertEquals("", i.name()); | |||
} | |||
@Test | |||
public void testEmpty_FromString() { | |||
final AbbreviatedObjectId i = AbbreviatedObjectId.fromString(""); | |||
assertNotNull(i); | |||
@@ -63,6 +72,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertEquals("", i.name()); | |||
} | |||
@Test | |||
public void testFull_FromByteArray() { | |||
final String s = "7b6e8067ec96acef9a4184b43210d583b6d2f99a"; | |||
final byte[] b = Constants.encodeASCII(s); | |||
@@ -79,6 +89,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertEquals(f.hashCode(), i.hashCode()); | |||
} | |||
@Test | |||
public void testFull_FromString() { | |||
final String s = "7b6e8067ec96acef9a4184b43210d583b6d2f99a"; | |||
final AbbreviatedObjectId i = AbbreviatedObjectId.fromString(s); | |||
@@ -93,6 +104,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertEquals(f.hashCode(), i.hashCode()); | |||
} | |||
@Test | |||
public void test1_FromString() { | |||
final String s = "7"; | |||
final AbbreviatedObjectId i = AbbreviatedObjectId.fromString(s); | |||
@@ -103,6 +115,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertNull(i.toObjectId()); | |||
} | |||
@Test | |||
public void test2_FromString() { | |||
final String s = "7b"; | |||
final AbbreviatedObjectId i = AbbreviatedObjectId.fromString(s); | |||
@@ -113,6 +126,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertNull(i.toObjectId()); | |||
} | |||
@Test | |||
public void test3_FromString() { | |||
final String s = "7b6"; | |||
final AbbreviatedObjectId i = AbbreviatedObjectId.fromString(s); | |||
@@ -123,6 +137,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertNull(i.toObjectId()); | |||
} | |||
@Test | |||
public void test4_FromString() { | |||
final String s = "7b6e"; | |||
final AbbreviatedObjectId i = AbbreviatedObjectId.fromString(s); | |||
@@ -133,6 +148,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertNull(i.toObjectId()); | |||
} | |||
@Test | |||
public void test5_FromString() { | |||
final String s = "7b6e8"; | |||
final AbbreviatedObjectId i = AbbreviatedObjectId.fromString(s); | |||
@@ -143,6 +159,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertNull(i.toObjectId()); | |||
} | |||
@Test | |||
public void test6_FromString() { | |||
final String s = "7b6e80"; | |||
final AbbreviatedObjectId i = AbbreviatedObjectId.fromString(s); | |||
@@ -153,6 +170,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertNull(i.toObjectId()); | |||
} | |||
@Test | |||
public void test7_FromString() { | |||
final String s = "7b6e806"; | |||
final AbbreviatedObjectId i = AbbreviatedObjectId.fromString(s); | |||
@@ -163,6 +181,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertNull(i.toObjectId()); | |||
} | |||
@Test | |||
public void test8_FromString() { | |||
final String s = "7b6e8067"; | |||
final AbbreviatedObjectId i = AbbreviatedObjectId.fromString(s); | |||
@@ -173,6 +192,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertNull(i.toObjectId()); | |||
} | |||
@Test | |||
public void test9_FromString() { | |||
final String s = "7b6e8067e"; | |||
final AbbreviatedObjectId i = AbbreviatedObjectId.fromString(s); | |||
@@ -183,6 +203,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertNull(i.toObjectId()); | |||
} | |||
@Test | |||
public void test17_FromString() { | |||
final String s = "7b6e8067ec96acef9"; | |||
final AbbreviatedObjectId i = AbbreviatedObjectId.fromString(s); | |||
@@ -193,6 +214,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertNull(i.toObjectId()); | |||
} | |||
@Test | |||
public void testEquals_Short() { | |||
final String s = "7b6e8067"; | |||
final AbbreviatedObjectId a = AbbreviatedObjectId.fromString(s); | |||
@@ -203,6 +225,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertTrue(b.equals(a)); | |||
} | |||
@Test | |||
public void testEquals_Full() { | |||
final String s = "7b6e8067ec96acef9a4184b43210d583b6d2f99a"; | |||
final AbbreviatedObjectId a = AbbreviatedObjectId.fromString(s); | |||
@@ -213,6 +236,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertTrue(b.equals(a)); | |||
} | |||
@Test | |||
public void testNotEquals_SameLength() { | |||
final String sa = "7b6e8067"; | |||
final String sb = "7b6e806e"; | |||
@@ -222,6 +246,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertFalse(b.equals(a)); | |||
} | |||
@Test | |||
public void testNotEquals_DiffLength() { | |||
final String sa = "7b6e8067abcd"; | |||
final String sb = "7b6e8067"; | |||
@@ -231,6 +256,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertFalse(b.equals(a)); | |||
} | |||
@Test | |||
public void testPrefixCompare_Full() { | |||
final String s1 = "7b6e8067ec96acef9a4184b43210d583b6d2f99a"; | |||
final AbbreviatedObjectId a = AbbreviatedObjectId.fromString(s1); | |||
@@ -249,6 +275,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertFalse(i3.startsWith(a)); | |||
} | |||
@Test | |||
public void testPrefixCompare_1() { | |||
final String sa = "7"; | |||
final AbbreviatedObjectId a = AbbreviatedObjectId.fromString(sa); | |||
@@ -269,6 +296,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertFalse(i3.startsWith(a)); | |||
} | |||
@Test | |||
public void testPrefixCompare_7() { | |||
final String sa = "7b6e806"; | |||
final AbbreviatedObjectId a = AbbreviatedObjectId.fromString(sa); | |||
@@ -289,6 +317,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertFalse(i3.startsWith(a)); | |||
} | |||
@Test | |||
public void testPrefixCompare_8() { | |||
final String sa = "7b6e8067"; | |||
final AbbreviatedObjectId a = AbbreviatedObjectId.fromString(sa); | |||
@@ -309,6 +338,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertFalse(i3.startsWith(a)); | |||
} | |||
@Test | |||
public void testPrefixCompare_9() { | |||
final String sa = "7b6e8067e"; | |||
final AbbreviatedObjectId a = AbbreviatedObjectId.fromString(sa); | |||
@@ -329,6 +359,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertFalse(i3.startsWith(a)); | |||
} | |||
@Test | |||
public void testPrefixCompare_17() { | |||
final String sa = "7b6e8067ec96acef9"; | |||
final AbbreviatedObjectId a = AbbreviatedObjectId.fromString(sa); | |||
@@ -349,6 +380,7 @@ public class AbbreviatedObjectIdTest extends TestCase { | |||
assertFalse(i3.startsWith(a)); | |||
} | |||
@Test | |||
public void testIsId() { | |||
// These are all too short. | |||
assertFalse(AbbreviatedObjectId.isId("")); |
@@ -48,28 +48,37 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.text.MessageFormat; | |||
import java.util.Arrays; | |||
import java.util.LinkedList; | |||
import java.util.Set; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jgit.errors.ConfigInvalidException; | |||
import org.eclipse.jgit.junit.MockSystemReader; | |||
import org.eclipse.jgit.util.FS; | |||
import org.eclipse.jgit.util.SystemReader; | |||
import org.junit.Test; | |||
/** | |||
* Test reading of git config | |||
*/ | |||
public class ConfigTest extends TestCase { | |||
public class ConfigTest { | |||
@Test | |||
public void test001_ReadBareKey() throws ConfigInvalidException { | |||
final Config c = parse("[foo]\nbar\n"); | |||
assertEquals(true, c.getBoolean("foo", null, "bar", false)); | |||
assertEquals("", c.getString("foo", null, "bar")); | |||
} | |||
@Test | |||
public void test002_ReadWithSubsection() throws ConfigInvalidException { | |||
final Config c = parse("[foo \"zip\"]\nbar\n[foo \"zap\"]\nbar=false\nn=3\n"); | |||
assertEquals(true, c.getBoolean("foo", "zip", "bar", false)); | |||
@@ -80,6 +89,7 @@ public class ConfigTest extends TestCase { | |||
assertEquals(4, c.getInt("foo", "zap","m", 4)); | |||
} | |||
@Test | |||
public void test003_PutRemote() { | |||
final Config c = new Config(); | |||
c.setString("sec", "ext", "name", "value"); | |||
@@ -88,6 +98,7 @@ public class ConfigTest extends TestCase { | |||
assertEquals(expText, c.toText()); | |||
} | |||
@Test | |||
public void test004_PutGetSimple() { | |||
Config c = new Config(); | |||
c.setString("my", null, "somename", "false"); | |||
@@ -95,6 +106,7 @@ public class ConfigTest extends TestCase { | |||
assertEquals("[my]\n\tsomename = false\n", c.toText()); | |||
} | |||
@Test | |||
public void test005_PutGetStringList() { | |||
Config c = new Config(); | |||
final LinkedList<String> values = new LinkedList<String>(); | |||
@@ -110,12 +122,14 @@ public class ConfigTest extends TestCase { | |||
assertEquals(expText, c.toText()); | |||
} | |||
@Test | |||
public void test006_readCaseInsensitive() throws ConfigInvalidException { | |||
final Config c = parse("[Foo]\nBar\n"); | |||
assertEquals(true, c.getBoolean("foo", null, "bar", false)); | |||
assertEquals("", c.getString("foo", null, "bar")); | |||
} | |||
@Test | |||
public void test007_readUserConfig() { | |||
final MockSystemReader mockSystemReader = new MockSystemReader(); | |||
SystemReader.setInstance(mockSystemReader); | |||
@@ -176,6 +190,7 @@ public class ConfigTest extends TestCase { | |||
assertEquals("author@localemail", authorEmail); | |||
} | |||
@Test | |||
public void testReadBoolean_TrueFalse1() throws ConfigInvalidException { | |||
final Config c = parse("[s]\na = true\nb = false\n"); | |||
assertEquals("true", c.getString("s", null, "a")); | |||
@@ -185,6 +200,7 @@ public class ConfigTest extends TestCase { | |||
assertFalse(c.getBoolean("s", "b", true)); | |||
} | |||
@Test | |||
public void testReadBoolean_TrueFalse2() throws ConfigInvalidException { | |||
final Config c = parse("[s]\na = TrUe\nb = fAlSe\n"); | |||
assertEquals("TrUe", c.getString("s", null, "a")); | |||
@@ -194,6 +210,7 @@ public class ConfigTest extends TestCase { | |||
assertFalse(c.getBoolean("s", "b", true)); | |||
} | |||
@Test | |||
public void testReadBoolean_YesNo1() throws ConfigInvalidException { | |||
final Config c = parse("[s]\na = yes\nb = no\n"); | |||
assertEquals("yes", c.getString("s", null, "a")); | |||
@@ -203,6 +220,7 @@ public class ConfigTest extends TestCase { | |||
assertFalse(c.getBoolean("s", "b", true)); | |||
} | |||
@Test | |||
public void testReadBoolean_YesNo2() throws ConfigInvalidException { | |||
final Config c = parse("[s]\na = yEs\nb = NO\n"); | |||
assertEquals("yEs", c.getString("s", null, "a")); | |||
@@ -212,6 +230,7 @@ public class ConfigTest extends TestCase { | |||
assertFalse(c.getBoolean("s", "b", true)); | |||
} | |||
@Test | |||
public void testReadBoolean_OnOff1() throws ConfigInvalidException { | |||
final Config c = parse("[s]\na = on\nb = off\n"); | |||
assertEquals("on", c.getString("s", null, "a")); | |||
@@ -221,6 +240,7 @@ public class ConfigTest extends TestCase { | |||
assertFalse(c.getBoolean("s", "b", true)); | |||
} | |||
@Test | |||
public void testReadBoolean_OnOff2() throws ConfigInvalidException { | |||
final Config c = parse("[s]\na = ON\nb = OFF\n"); | |||
assertEquals("ON", c.getString("s", null, "a")); | |||
@@ -234,6 +254,7 @@ public class ConfigTest extends TestCase { | |||
ONE_TWO; | |||
} | |||
@Test | |||
public void testGetEnum() throws ConfigInvalidException { | |||
Config c = parse("[s]\na = ON\nb = input\nc = true\nd = off\n"); | |||
assertSame(CoreConfig.AutoCRLF.TRUE, c.getEnum("s", null, "a", | |||
@@ -256,12 +277,14 @@ public class ConfigTest extends TestCase { | |||
assertSame(TestEnum.ONE_TWO, c.getEnum("s", "b", "c", TestEnum.ONE_TWO)); | |||
} | |||
@Test | |||
public void testSetEnum() { | |||
final Config c = new Config(); | |||
c.setEnum("s", "b", "c", TestEnum.ONE_TWO); | |||
assertEquals("[s \"b\"]\n\tc = one two\n", c.toText()); | |||
} | |||
@Test | |||
public void testReadLong() throws ConfigInvalidException { | |||
assertReadLong(1L); | |||
assertReadLong(-1L); | |||
@@ -279,6 +302,7 @@ public class ConfigTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testBooleanWithNoValue() throws ConfigInvalidException { | |||
Config c = parse("[my]\n\tempty\n"); | |||
assertEquals("", c.getString("my", null, "empty")); | |||
@@ -288,6 +312,7 @@ public class ConfigTest extends TestCase { | |||
assertEquals("[my]\n\tempty\n", c.toText()); | |||
} | |||
@Test | |||
public void testEmptyString() throws ConfigInvalidException { | |||
Config c = parse("[my]\n\tempty =\n"); | |||
assertNull(c.getString("my", null, "empty")); | |||
@@ -308,6 +333,7 @@ public class ConfigTest extends TestCase { | |||
assertEquals("[my]\n\tempty =\n", c.toText()); | |||
} | |||
@Test | |||
public void testUnsetBranchSection() throws ConfigInvalidException { | |||
Config c = parse("" // | |||
+ "[branch \"keep\"]\n" | |||
@@ -329,6 +355,7 @@ public class ConfigTest extends TestCase { | |||
+ " packedGitLimit = 14\n", c.toText()); | |||
} | |||
@Test | |||
public void testUnsetSingleSection() throws ConfigInvalidException { | |||
Config c = parse("" // | |||
+ "[branch \"keep\"]\n" | |||
@@ -349,6 +376,7 @@ public class ConfigTest extends TestCase { | |||
+ " packedGitLimit = 14\n", c.toText()); | |||
} | |||
@Test | |||
public void test008_readSectionNames() throws ConfigInvalidException { | |||
final Config c = parse("[a]\n [B]\n"); | |||
Set<String> sections = c.getSections(); | |||
@@ -356,6 +384,7 @@ public class ConfigTest extends TestCase { | |||
assertTrue("Sections should contain \"b\"", sections.contains("b")); | |||
} | |||
@Test | |||
public void test009_readNamesInSection() throws ConfigInvalidException { | |||
String configString = "[core]\n" + "repositoryformatversion = 0\n" | |||
+ "filemode = false\n" + "logallrefupdates = true\n"; | |||
@@ -366,6 +395,7 @@ public class ConfigTest extends TestCase { | |||
.contains("filemode")); | |||
} | |||
@Test | |||
public void test010_readNamesInSubSection() throws ConfigInvalidException { | |||
String configString = "[a \"sub1\"]\n"// | |||
+ "x = 0\n" // | |||
@@ -386,6 +416,7 @@ public class ConfigTest extends TestCase { | |||
assertTrue("Subsection should contain \"b\"", names.contains("b")); | |||
} | |||
@Test | |||
public void testQuotingForSubSectionNames() { | |||
String resultPattern = "[testsection \"{0}\"]\n\ttestname = testvalue\n"; | |||
String result; |
@@ -43,12 +43,17 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.UnsupportedEncodingException; | |||
import java.util.Arrays; | |||
import junit.framework.TestCase; | |||
import org.junit.Test; | |||
public class ConstantsEncodingTest extends TestCase { | |||
public class ConstantsEncodingTest { | |||
@Test | |||
public void testEncodeASCII_SimpleASCII() | |||
throws UnsupportedEncodingException { | |||
final String src = "abc"; | |||
@@ -58,6 +63,7 @@ public class ConstantsEncodingTest extends TestCase { | |||
assertEquals(src, new String(res, 0, res.length, "UTF-8")); | |||
} | |||
@Test | |||
public void testEncodeASCII_FailOnNonASCII() { | |||
final String src = "Ūnĭcōde̽"; | |||
try { | |||
@@ -68,6 +74,7 @@ public class ConstantsEncodingTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testEncodeASCII_Number13() { | |||
final long src = 13; | |||
final byte[] exp = { '1', '3' }; | |||
@@ -75,6 +82,7 @@ public class ConstantsEncodingTest extends TestCase { | |||
assertTrue(Arrays.equals(exp, res)); | |||
} | |||
@Test | |||
public void testEncode_SimpleASCII() throws UnsupportedEncodingException { | |||
final String src = "abc"; | |||
final byte[] exp = { 'a', 'b', 'c' }; | |||
@@ -83,6 +91,7 @@ public class ConstantsEncodingTest extends TestCase { | |||
assertEquals(src, new String(res, 0, res.length, "UTF-8")); | |||
} | |||
@Test | |||
public void testEncode_Unicode() throws UnsupportedEncodingException { | |||
final String src = "Ūnĭcōde̽"; | |||
final byte[] exp = { (byte) 0xC5, (byte) 0xAA, 0x6E, (byte) 0xC4, |
@@ -37,6 +37,9 @@ | |||
*/ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.List; | |||
@@ -53,6 +56,7 @@ import org.eclipse.jgit.errors.NoWorkTreeException; | |||
import org.eclipse.jgit.lib.RefUpdate.Result; | |||
import org.eclipse.jgit.revwalk.RevCommit; | |||
import org.eclipse.jgit.revwalk.RevWalk; | |||
import org.junit.Test; | |||
public class DirCacheCheckoutTest extends ReadTreeTest { | |||
private DirCacheCheckout dco; | |||
@@ -94,6 +98,7 @@ public class DirCacheCheckoutTest extends ReadTreeTest { | |||
return dco.getConflicts(); | |||
} | |||
@Test | |||
public void testResetHard() throws IOException, NoFilepatternException, | |||
GitAPIException { | |||
Git git = new Git(db); |
@@ -45,6 +45,9 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.File; | |||
import java.io.IOException; | |||
@@ -53,8 +56,10 @@ import org.eclipse.jgit.dircache.DirCache; | |||
import org.eclipse.jgit.dircache.DirCacheEditor; | |||
import org.eclipse.jgit.dircache.DirCacheEntry; | |||
import org.eclipse.jgit.treewalk.FileTreeIterator; | |||
import org.junit.Test; | |||
public class IndexDiffTest extends RepositoryTestCase { | |||
@Test | |||
public void testAdded() throws IOException { | |||
GitIndex index = new GitIndex(db); | |||
writeTrashFile("file1", "file1"); | |||
@@ -76,6 +81,7 @@ public class IndexDiffTest extends RepositoryTestCase { | |||
assertEquals(0, diff.getRemoved().size()); | |||
} | |||
@Test | |||
public void testRemoved() throws IOException { | |||
writeTrashFile("file2", "file2"); | |||
writeTrashFile("dir/file3", "dir/file3"); | |||
@@ -101,6 +107,7 @@ public class IndexDiffTest extends RepositoryTestCase { | |||
assertEquals(0, diff.getAdded().size()); | |||
} | |||
@Test | |||
public void testModified() throws IOException { | |||
GitIndex index = new GitIndex(db); | |||
@@ -132,6 +139,7 @@ public class IndexDiffTest extends RepositoryTestCase { | |||
assertEquals(0, diff.getMissing().size()); | |||
} | |||
@Test | |||
public void testUnchangedSimple() throws IOException { | |||
GitIndex index = new GitIndex(db); | |||
@@ -166,6 +174,7 @@ public class IndexDiffTest extends RepositoryTestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testUnchangedComplex() throws IOException { | |||
GitIndex index = new GitIndex(db); | |||
@@ -221,6 +230,7 @@ public class IndexDiffTest extends RepositoryTestCase { | |||
* | |||
* @throws Exception | |||
*/ | |||
@Test | |||
public void testRemovedUntracked() throws Exception{ | |||
Git git = new Git(db); | |||
String path = "file"; | |||
@@ -235,6 +245,7 @@ public class IndexDiffTest extends RepositoryTestCase { | |||
assertTrue(diff.getUntracked().contains(path)); | |||
} | |||
@Test | |||
public void testAssumeUnchanged() throws Exception { | |||
Git git = new Git(db); | |||
String path = "file"; |
@@ -44,11 +44,16 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import org.eclipse.jgit.lib.GitIndex.Entry; | |||
import org.junit.Test; | |||
public class IndexTreeWalkerTest extends RepositoryTestCase { | |||
private ArrayList<String> treeOnlyEntriesVisited = new ArrayList<String>(); | |||
@@ -74,6 +79,7 @@ public class IndexTreeWalkerTest extends RepositoryTestCase { | |||
* because I already | |||
*/ | |||
@Test | |||
public void testTreeOnlyOneLevel() throws IOException { | |||
GitIndex index = new GitIndex(db); | |||
Tree tree = new Tree(db); | |||
@@ -86,6 +92,7 @@ public class IndexTreeWalkerTest extends RepositoryTestCase { | |||
assertTrue(treeOnlyEntriesVisited.get(1).equals("foo")); | |||
} | |||
@Test | |||
public void testIndexOnlyOneLevel() throws IOException { | |||
GitIndex index = new GitIndex(db); | |||
Tree tree = new Tree(db); | |||
@@ -98,6 +105,7 @@ public class IndexTreeWalkerTest extends RepositoryTestCase { | |||
assertTrue(indexOnlyEntriesVisited.get(1).equals("foo")); | |||
} | |||
@Test | |||
public void testBoth() throws IOException { | |||
GitIndex index = new GitIndex(db); | |||
Tree tree = new Tree(db); | |||
@@ -114,6 +122,7 @@ public class IndexTreeWalkerTest extends RepositoryTestCase { | |||
} | |||
@Test | |||
public void testIndexOnlySubDirs() throws IOException { | |||
GitIndex index = new GitIndex(db); | |||
Tree tree = new Tree(db); | |||
@@ -126,6 +135,7 @@ public class IndexTreeWalkerTest extends RepositoryTestCase { | |||
assertEquals("foo/bar/baz", indexOnlyEntriesVisited.get(1)); | |||
} | |||
@Test | |||
public void testLeavingTree() throws IOException { | |||
GitIndex index = new GitIndex(db); | |||
index.add(trash, writeTrashFile("foo/bar", "foo/bar")); |
@@ -42,17 +42,23 @@ | |||
*/ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import java.io.File; | |||
import java.io.FileOutputStream; | |||
import java.io.IOException; | |||
import java.util.Arrays; | |||
import java.util.Collections; | |||
import org.junit.Test; | |||
public class MergeHeadMsgTest extends RepositoryTestCase { | |||
private static final String mergeMsg = "merge a and b"; | |||
private static final String sampleId = "1c6db447abdbb291b25f07be38ea0b1bf94947c5"; | |||
@Test | |||
public void testReadWriteMergeHeads() throws IOException { | |||
assertEquals(db.readMergeHeads(), null); | |||
db.writeMergeHeads(Arrays.asList(ObjectId.zeroId(), | |||
@@ -86,6 +92,7 @@ public class MergeHeadMsgTest extends RepositoryTestCase { | |||
assertEquals(db.readMergeHeads().get(0), ObjectId.fromString(sampleId)); | |||
} | |||
@Test | |||
public void testReadWriteMergeMsg() throws IOException { | |||
assertEquals(db.readMergeCommitMsg(), null); | |||
assertFalse(new File(db.getDirectory(), "MERGE_MSG").exists()); |
@@ -44,21 +44,25 @@ | |||
package org.eclipse.jgit.lib; | |||
import java.text.MessageFormat; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.fail; | |||
import junit.framework.TestCase; | |||
import java.text.MessageFormat; | |||
import org.eclipse.jgit.JGitText; | |||
import org.eclipse.jgit.errors.CorruptObjectException; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
public class ObjectCheckerTest extends TestCase { | |||
public class ObjectCheckerTest { | |||
private ObjectChecker checker; | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
@Before | |||
public void setUp() throws Exception { | |||
checker = new ObjectChecker(); | |||
} | |||
@Test | |||
public void testInvalidType() { | |||
try { | |||
checker.check(Constants.OBJ_BAD, new byte[0]); | |||
@@ -69,6 +73,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testCheckBlob() throws CorruptObjectException { | |||
// Any blob should pass... | |||
checker.checkBlob(new byte[0]); | |||
@@ -78,6 +83,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.check(Constants.OBJ_BLOB, new byte[1]); | |||
} | |||
@Test | |||
public void testValidCommitNoParent() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -93,6 +99,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.check(Constants.OBJ_COMMIT, data); | |||
} | |||
@Test | |||
public void testValidCommitBlankAuthor() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -108,6 +115,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.check(Constants.OBJ_COMMIT, data); | |||
} | |||
@Test | |||
public void testValidCommit1Parent() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -127,6 +135,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.check(Constants.OBJ_COMMIT, data); | |||
} | |||
@Test | |||
public void testValidCommit2Parent() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -150,6 +159,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.check(Constants.OBJ_COMMIT, data); | |||
} | |||
@Test | |||
public void testValidCommit128Parent() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -171,6 +181,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.check(Constants.OBJ_COMMIT, data); | |||
} | |||
@Test | |||
public void testValidCommitNormalTime() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
final String when = "1222757360 -0730"; | |||
@@ -187,6 +198,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.check(Constants.OBJ_COMMIT, data); | |||
} | |||
@Test | |||
public void testInvalidCommitNoTree1() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -203,6 +215,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitNoTree2() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -219,6 +232,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitNoTree3() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -235,6 +249,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitNoTree4() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -251,6 +266,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidTree1() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -267,6 +283,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidTree2() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -283,6 +300,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidTree3() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -299,6 +317,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidTree4() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -315,6 +334,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidParent1() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -334,6 +354,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidParent2() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -354,6 +375,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidParent3() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -374,6 +396,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidParent4() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -394,6 +417,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidParent5() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -416,6 +440,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitNoAuthor() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -436,6 +461,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitNoCommitter1() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -456,6 +482,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitNoCommitter2() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -477,6 +504,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidAuthor1() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -497,6 +525,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidAuthor2() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -517,6 +546,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidAuthor3() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -537,6 +567,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidAuthor4() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -557,6 +588,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidAuthor5() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -577,6 +609,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidAuthor6() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -597,6 +630,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidAuthor7() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -617,6 +651,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidCommitInvalidCommitter() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -638,6 +673,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testValidTag() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -654,6 +690,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.check(Constants.OBJ_TAG, data); | |||
} | |||
@Test | |||
public void testInvalidTagNoObject1() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -666,6 +703,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTagNoObject2() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -682,6 +720,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTagNoObject3() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -698,6 +737,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTagNoObject4() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -714,6 +754,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTagNoObject5() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -730,6 +771,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTagNoObject6() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -745,6 +787,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTagNoType1() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -761,6 +804,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTagNoType2() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -779,6 +823,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTagNoType3() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -797,6 +842,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTagNoType4() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -815,6 +861,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTagNoTagHeader1() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -833,6 +880,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTagNoTagHeader2() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -852,6 +900,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTagNoTagHeader3() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -871,6 +920,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testValidTagHasNoTaggerHeader() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -884,6 +934,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTag(Constants.encodeASCII(b.toString())); | |||
} | |||
@Test | |||
public void testInvalidTagInvalidTaggerHeader1() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -904,6 +955,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTagInvalidTaggerHeader3() { | |||
final StringBuilder b = new StringBuilder(); | |||
@@ -924,11 +976,13 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testValidEmptyTree() throws CorruptObjectException { | |||
checker.checkTree(new byte[0]); | |||
checker.check(Constants.OBJ_TREE, new byte[0]); | |||
} | |||
@Test | |||
public void testValidTree1() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 regular-file"); | |||
@@ -936,6 +990,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTree(data); | |||
} | |||
@Test | |||
public void testValidTree2() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100755 executable"); | |||
@@ -943,6 +998,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTree(data); | |||
} | |||
@Test | |||
public void testValidTree3() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "40000 tree"); | |||
@@ -950,6 +1006,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTree(data); | |||
} | |||
@Test | |||
public void testValidTree4() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "120000 symlink"); | |||
@@ -957,6 +1014,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTree(data); | |||
} | |||
@Test | |||
public void testValidTree5() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "160000 git link"); | |||
@@ -964,6 +1022,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTree(data); | |||
} | |||
@Test | |||
public void testValidTree6() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 .a"); | |||
@@ -971,6 +1030,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTree(data); | |||
} | |||
@Test | |||
public void testValidTreeSorting1() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 fooaaa"); | |||
@@ -979,6 +1039,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTree(data); | |||
} | |||
@Test | |||
public void testValidTreeSorting2() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100755 fooaaa"); | |||
@@ -987,6 +1048,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTree(data); | |||
} | |||
@Test | |||
public void testValidTreeSorting3() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "40000 a"); | |||
@@ -995,6 +1057,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTree(data); | |||
} | |||
@Test | |||
public void testValidTreeSorting4() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 a"); | |||
@@ -1003,6 +1066,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTree(data); | |||
} | |||
@Test | |||
public void testValidTreeSorting5() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 a.c"); | |||
@@ -1012,6 +1076,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTree(data); | |||
} | |||
@Test | |||
public void testValidTreeSorting6() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "40000 a"); | |||
@@ -1020,6 +1085,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTree(data); | |||
} | |||
@Test | |||
public void testValidTreeSorting7() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "40000 an orang"); | |||
@@ -1028,6 +1094,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTree(data); | |||
} | |||
@Test | |||
public void testValidTreeSorting8() throws CorruptObjectException { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 a"); | |||
@@ -1037,6 +1104,7 @@ public class ObjectCheckerTest extends TestCase { | |||
checker.checkTree(data); | |||
} | |||
@Test | |||
public void testInvalidTreeModeStartsWithZero1() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "0 a"); | |||
@@ -1049,6 +1117,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeModeStartsWithZero2() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "0100644 a"); | |||
@@ -1061,6 +1130,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeModeStartsWithZero3() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "040000 a"); | |||
@@ -1073,6 +1143,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeModeNotOctal1() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "8 a"); | |||
@@ -1085,6 +1156,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeModeNotOctal2() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "Z a"); | |||
@@ -1097,6 +1169,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeModeNotSupportedMode1() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "1 a"); | |||
@@ -1109,6 +1182,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeModeNotSupportedMode2() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "170000 a"); | |||
@@ -1121,6 +1195,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeModeMissingName() { | |||
final StringBuilder b = new StringBuilder(); | |||
b.append("100644"); | |||
@@ -1133,6 +1208,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeNameContainsSlash() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 a/b"); | |||
@@ -1145,6 +1221,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeNameIsEmpty() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 "); | |||
@@ -1157,6 +1234,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeNameIsDot() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 ."); | |||
@@ -1169,6 +1247,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeNameIsDotDot() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 .."); | |||
@@ -1181,6 +1260,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeTruncatedInName() { | |||
final StringBuilder b = new StringBuilder(); | |||
b.append("100644 b"); | |||
@@ -1193,6 +1273,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeTruncatedInObjectId() { | |||
final StringBuilder b = new StringBuilder(); | |||
b.append("100644 b\0\1\2"); | |||
@@ -1205,6 +1286,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeBadSorting1() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 foobar"); | |||
@@ -1218,6 +1300,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeBadSorting2() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "40000 a"); | |||
@@ -1231,6 +1314,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeBadSorting3() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 a0c"); | |||
@@ -1244,6 +1328,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeDuplicateNames1() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 a"); | |||
@@ -1257,6 +1342,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeDuplicateNames2() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 a"); | |||
@@ -1270,6 +1356,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeDuplicateNames3() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 a"); | |||
@@ -1283,6 +1370,7 @@ public class ObjectCheckerTest extends TestCase { | |||
} | |||
} | |||
@Test | |||
public void testInvalidTreeDuplicateNames4() { | |||
final StringBuilder b = new StringBuilder(); | |||
entry(b, "100644 a"); |
@@ -43,9 +43,15 @@ | |||
package org.eclipse.jgit.lib; | |||
import junit.framework.TestCase; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
public class ObjectIdRefTest extends TestCase { | |||
import org.junit.Test; | |||
public class ObjectIdRefTest { | |||
private static final ObjectId ID_A = ObjectId | |||
.fromString("41eb0d88f833b558bddeb269b7ab77399cdf98ed"); | |||
@@ -54,6 +60,7 @@ public class ObjectIdRefTest extends TestCase { | |||
private static final String name = "refs/heads/a.test.ref"; | |||
@Test | |||
public void testConstructor_PeeledStatusNotKnown() { | |||
ObjectIdRef r; | |||
@@ -84,6 +91,7 @@ public class ObjectIdRefTest extends TestCase { | |||
assertFalse("not symbolic", r.isSymbolic()); | |||
} | |||
@Test | |||
public void testConstructor_Peeled() { | |||
ObjectIdRef r; | |||
@@ -106,6 +114,7 @@ public class ObjectIdRefTest extends TestCase { | |||
assertSame(ID_B, r.getPeeledObjectId()); | |||
} | |||
@Test | |||
public void testToString() { | |||
ObjectIdRef r; | |||
@@ -45,21 +45,28 @@ | |||
package org.eclipse.jgit.lib; | |||
import junit.framework.TestCase; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
public class ObjectIdTest extends TestCase { | |||
import org.junit.Test; | |||
public class ObjectIdTest { | |||
@Test | |||
public void test001_toString() { | |||
final String x = "def4c620bc3713bb1bb26b808ec9312548e73946"; | |||
final ObjectId oid = ObjectId.fromString(x); | |||
assertEquals(x, oid.name()); | |||
} | |||
@Test | |||
public void test002_toString() { | |||
final String x = "ff00eedd003713bb1bb26b808ec9312548e73946"; | |||
final ObjectId oid = ObjectId.fromString(x); | |||
assertEquals(x, oid.name()); | |||
} | |||
@Test | |||
public void test003_equals() { | |||
final String x = "def4c620bc3713bb1bb26b808ec9312548e73946"; | |||
final ObjectId a = ObjectId.fromString(x); | |||
@@ -68,47 +75,56 @@ public class ObjectIdTest extends TestCase { | |||
assertTrue("a and b are same", a.equals(b)); | |||
} | |||
@Test | |||
public void test004_isId() { | |||
assertTrue("valid id", ObjectId | |||
.isId("def4c620bc3713bb1bb26b808ec9312548e73946")); | |||
} | |||
@Test | |||
public void test005_notIsId() { | |||
assertFalse("bob is not an id", ObjectId.isId("bob")); | |||
} | |||
@Test | |||
public void test006_notIsId() { | |||
assertFalse("39 digits is not an id", ObjectId | |||
.isId("def4c620bc3713bb1bb26b808ec9312548e7394")); | |||
} | |||
@Test | |||
public void test007_isId() { | |||
assertTrue("uppercase is accepted", ObjectId | |||
.isId("Def4c620bc3713bb1bb26b808ec9312548e73946")); | |||
} | |||
@Test | |||
public void test008_notIsId() { | |||
assertFalse("g is not a valid hex digit", ObjectId | |||
.isId("gef4c620bc3713bb1bb26b808ec9312548e73946")); | |||
} | |||
@Test | |||
public void test009_toString() { | |||
final String x = "ff00eedd003713bb1bb26b808ec9312548e73946"; | |||
final ObjectId oid = ObjectId.fromString(x); | |||
assertEquals(x, ObjectId.toString(oid)); | |||
} | |||
@Test | |||
public void test010_toString() { | |||
final String x = "0000000000000000000000000000000000000000"; | |||
assertEquals(x, ObjectId.toString(null)); | |||
} | |||
@Test | |||
public void test011_toString() { | |||
final String x = "0123456789ABCDEFabcdef1234567890abcdefAB"; | |||
final ObjectId oid = ObjectId.fromString(x); | |||
assertEquals(x.toLowerCase(), oid.name()); | |||
} | |||
@Test | |||
public void testGetByte() { | |||
byte[] raw = new byte[20]; | |||
for (int i = 0; i < 20; i++) | |||
@@ -123,6 +139,7 @@ public class ObjectIdTest extends TestCase { | |||
assertEquals("index " + i, raw[i] & 0xff, id.getByte(i)); | |||
} | |||
@Test | |||
public void testSetByte() { | |||
byte[] exp = new byte[20]; | |||
for (int i = 0; i < 20; i++) |
@@ -44,29 +44,38 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertNotSame; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.ByteArrayInputStream; | |||
import java.io.ByteArrayOutputStream; | |||
import java.io.IOException; | |||
import java.util.Arrays; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jgit.errors.LargeObjectException; | |||
import org.eclipse.jgit.errors.MissingObjectException; | |||
import org.eclipse.jgit.junit.JGitTestUtil; | |||
import org.eclipse.jgit.junit.TestRng; | |||
import org.junit.Test; | |||
public class ObjectLoaderTest extends TestCase { | |||
public class ObjectLoaderTest { | |||
private TestRng rng; | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
rng = new TestRng(getName()); | |||
private TestRng getRng() { | |||
if (rng == null) | |||
rng = new TestRng(JGitTestUtil.getName()); | |||
return rng; | |||
} | |||
@Test | |||
public void testSmallObjectLoader() throws MissingObjectException, | |||
IOException { | |||
final byte[] act = rng.nextBytes(512); | |||
final byte[] act = getRng().nextBytes(512); | |||
final ObjectLoader ldr = new ObjectLoader.SmallObject(OBJ_BLOB, act); | |||
assertEquals(OBJ_BLOB, ldr.getType()); | |||
@@ -106,9 +115,10 @@ public class ObjectLoaderTest extends TestCase { | |||
assertTrue("same content", Arrays.equals(act, tmp.toByteArray())); | |||
} | |||
@Test | |||
public void testLargeObjectLoader() throws MissingObjectException, | |||
IOException { | |||
final byte[] act = rng.nextBytes(512); | |||
final byte[] act = getRng().nextBytes(512); | |||
final ObjectLoader ldr = new ObjectLoader() { | |||
@Override | |||
public byte[] getCachedBytes() throws LargeObjectException { | |||
@@ -179,9 +189,10 @@ public class ObjectLoaderTest extends TestCase { | |||
assertTrue("same content", Arrays.equals(act, tmp.toByteArray())); | |||
} | |||
@Test | |||
public void testLimitedGetCachedBytes() throws LargeObjectException, | |||
MissingObjectException, IOException { | |||
byte[] act = rng.nextBytes(512); | |||
byte[] act = getRng().nextBytes(512); | |||
ObjectLoader ldr = new ObjectLoader.SmallObject(OBJ_BLOB, act) { | |||
@Override | |||
public boolean isLarge() { | |||
@@ -206,6 +217,7 @@ public class ObjectLoaderTest extends TestCase { | |||
assertTrue("same content", Arrays.equals(act, copy)); | |||
} | |||
@Test | |||
public void testLimitedGetCachedBytesExceedsJavaLimits() | |||
throws LargeObjectException, MissingObjectException, IOException { | |||
ObjectLoader ldr = new ObjectLoader() { |
@@ -42,6 +42,9 @@ | |||
*/ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.File; | |||
import java.io.FileOutputStream; | |||
import java.io.IOException; |
@@ -45,6 +45,12 @@ | |||
*/ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.IOException; | |||
@@ -58,6 +64,7 @@ import org.eclipse.jgit.errors.CheckoutConflictException; | |||
import org.eclipse.jgit.errors.CorruptObjectException; | |||
import org.eclipse.jgit.treewalk.FileTreeIterator; | |||
import org.eclipse.jgit.treewalk.TreeWalk; | |||
import org.junit.Test; | |||
public abstract class ReadTreeTest extends RepositoryTestCase { | |||
protected Tree theHead; | |||
@@ -66,6 +73,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
// Each of these rules are from the read-tree manpage | |||
// go there to see what they mean. | |||
// Rule 0 is left out for obvious reasons :) | |||
@Test | |||
public void testRules1thru3_NoIndexEntry() throws IOException { | |||
Tree head = new Tree(db); | |||
head = buildTree(mk("foo")); | |||
@@ -154,6 +162,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
// for these rules, they all have clean yes/no options | |||
// but it doesn't matter if the entry is clean or not | |||
// so we can just ignore the state in the filesystem entirely | |||
@Test | |||
public void testRules4thru13_IndexEntryNotInHead() throws IOException { | |||
// rules 4 and 5 | |||
HashMap<String, String> idxMap; | |||
@@ -251,6 +260,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertTrue(getConflicts().isEmpty()); | |||
} | |||
@Test | |||
public void testDirectoryFileSimple() throws IOException { | |||
Tree treeDF = buildTree(mkmap("DF", "DF")); | |||
Tree treeDFDF = buildTree(mkmap("DF/DF", "DF/DF")); | |||
@@ -300,6 +310,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
*19 D 0 F Update | |||
*/ | |||
@Test | |||
public void testDirectoryFileConflicts_1() throws Exception { | |||
// 1 | |||
doit(mk("DF/DF"), mk("DF"), mk("DF/DF")); | |||
@@ -308,6 +319,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertRemoved("DF/DF"); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_2() throws Exception { | |||
// 2 | |||
setupCase(mk("DF/DF"), mk("DF"), mk("DF/DF")); | |||
@@ -317,6 +329,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_3() throws Exception { | |||
// 3 - the first to break! | |||
doit(mk("DF/DF"), mk("DF/DF"), mk("DF")); | |||
@@ -324,6 +337,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertRemoved("DF"); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_4() throws Exception { | |||
// 4 (basically same as 3, just with H and M different) | |||
doit(mk("DF/DF"), mkmap("DF/DF", "foo"), mk("DF")); | |||
@@ -332,6 +346,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_5() throws Exception { | |||
// 5 | |||
doit(mk("DF/DF"), mk("DF"), mk("DF")); | |||
@@ -339,6 +354,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_6() throws Exception { | |||
// 6 | |||
setupCase(mk("DF/DF"), mk("DF"), mk("DF")); | |||
@@ -347,6 +363,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertRemoved("DF/DF"); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_7() throws Exception { | |||
// 7 | |||
doit(mk("DF"), mk("DF"), mk("DF/DF")); | |||
@@ -375,6 +392,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
// This test would fail in DirCacheCheckoutTests. | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_8() throws Exception { | |||
// 8 | |||
setupCase(mk("DF"), mk("DF"), mk("DF/DF")); | |||
@@ -384,6 +402,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertConflict("DF/DF"); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_9() throws Exception { | |||
// 9 | |||
doit(mk("DF"), mkmap("DF", "QP"), mk("DF/DF")); | |||
@@ -391,6 +410,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertUpdated("DF"); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_10() throws Exception { | |||
// 10 | |||
cleanUpDF(); | |||
@@ -398,12 +418,14 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertNoConflicts(); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_11() throws Exception { | |||
// 11 | |||
doit(mk("DF"), mk("DF/DF"), mkmap("DF/DF", "asdf")); | |||
assertConflict("DF/DF"); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_12() throws Exception { | |||
// 12 | |||
cleanUpDF(); | |||
@@ -412,6 +434,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertUpdated("DF/DF"); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_13() throws Exception { | |||
// 13 | |||
cleanUpDF(); | |||
@@ -422,6 +445,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertUpdated("DF/DF"); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_14() throws Exception { | |||
// 14 | |||
cleanUpDF(); | |||
@@ -430,6 +454,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertUpdated("DF/DF"); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_15() throws Exception { | |||
// 15 | |||
doit(mkmap(), mk("DF/DF"), mk("DF")); | |||
@@ -441,6 +466,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertUpdated("DF/DF"); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_15b() throws Exception { | |||
// 15, take 2, just to check multi-leveled | |||
doit(mkmap(), mk("DF/DF/DF/DF"), mk("DF")); | |||
@@ -453,6 +479,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertUpdated("DF/DF/DF/DF"); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_16() throws Exception { | |||
// 16 | |||
cleanUpDF(); | |||
@@ -461,6 +488,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertUpdated("DF"); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_17() throws Exception { | |||
// 17 | |||
cleanUpDF(); | |||
@@ -476,6 +504,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
// assertUpdated("DF"); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_18() throws Exception { | |||
// 18 | |||
cleanUpDF(); | |||
@@ -484,6 +513,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertUpdated("DF/DF/DF/DF"); | |||
} | |||
@Test | |||
public void testDirectoryFileConflicts_19() throws Exception { | |||
// 19 | |||
cleanUpDF(); | |||
@@ -536,6 +566,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
return map; | |||
} | |||
@Test | |||
public void testUntrackedConflicts() throws IOException { | |||
setupCase(null, mk("foo"), null); | |||
writeTrashFile("foo", "foo"); | |||
@@ -574,6 +605,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertNoConflicts(); | |||
} | |||
@Test | |||
public void testCloseNameConflictsX0() throws IOException { | |||
setupCase(mkmap("a/a", "a/a-c"), mkmap("a/a","a/a", "b.b/b.b","b.b/b.bs"), mkmap("a/a", "a/a-c") ); | |||
checkout(); | |||
@@ -585,6 +617,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertNoConflicts(); | |||
} | |||
@Test | |||
public void testCloseNameConflicts1() throws IOException { | |||
setupCase(mkmap("a/a", "a/a-c"), mkmap("a/a","a/a", "a.a/a.a","a.a/a.a"), mkmap("a/a", "a/a-c") ); | |||
checkout(); | |||
@@ -596,6 +629,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertNoConflicts(); | |||
} | |||
@Test | |||
public void testCheckoutHierarchy() throws IOException { | |||
setupCase( | |||
mkmap("a", "a", "b/c", "b/c", "d", "d", "e/f", "e/f", "e/g", | |||
@@ -613,6 +647,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCheckoutOutChanges() throws IOException { | |||
setupCase(mk("foo"), mk("foo/bar"), mk("foo")); | |||
checkout(); | |||
@@ -648,6 +683,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testCheckoutUncachedChanges() throws IOException { | |||
setupCase(mk("foo"), mk("foo"), mk("foo")); | |||
writeTrashFile("foo", "otherData"); | |||
@@ -657,6 +693,7 @@ public abstract class ReadTreeTest extends RepositoryTestCase { | |||
assertTrue(new File(trash, "foo").isFile()); | |||
} | |||
@Test | |||
public void testDontOverwriteDirtyFile() throws IOException { | |||
setupCase(mk("foo"), mk("other"), mk("foo")); | |||
writeTrashFile("foo", "different"); |
@@ -45,6 +45,14 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.io.FileOutputStream; | |||
import java.io.IOException; | |||
@@ -52,6 +60,7 @@ import java.util.Map; | |||
import org.eclipse.jgit.lib.Ref.Storage; | |||
import org.eclipse.jgit.lib.RefUpdate.Result; | |||
import org.junit.Test; | |||
/** | |||
* Misc tests for refs. A lot of things are tested elsewhere so not having a | |||
@@ -71,6 +80,7 @@ public class RefTest extends SampleDataRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void testReadAllIncludingSymrefs() throws Exception { | |||
ObjectId masterId = db.resolve("refs/heads/master"); | |||
RefUpdate updateRef = db.updateRef("refs/remotes/origin/master"); | |||
@@ -96,6 +106,7 @@ public class RefTest extends SampleDataRepositoryTestCase { | |||
assertNull(refmaster.getPeeledObjectId()); | |||
} | |||
@Test | |||
public void testReadSymRefToPacked() throws IOException { | |||
writeSymref("HEAD", "refs/heads/b"); | |||
Ref ref = db.getRef("HEAD"); | |||
@@ -106,6 +117,7 @@ public class RefTest extends SampleDataRepositoryTestCase { | |||
assertEquals(Ref.Storage.PACKED, ref.getStorage()); | |||
} | |||
@Test | |||
public void testReadSymRefToLoosePacked() throws IOException { | |||
ObjectId pid = db.resolve("refs/heads/master^"); | |||
RefUpdate updateRef = db.updateRef("refs/heads/master"); | |||
@@ -122,6 +134,7 @@ public class RefTest extends SampleDataRepositoryTestCase { | |||
assertEquals(Ref.Storage.LOOSE, ref.getStorage()); | |||
} | |||
@Test | |||
public void testReadLooseRef() throws IOException { | |||
RefUpdate updateRef = db.updateRef("ref/heads/new"); | |||
updateRef.setNewObjectId(db.resolve("refs/heads/master")); | |||
@@ -137,6 +150,7 @@ public class RefTest extends SampleDataRepositoryTestCase { | |||
* @throws IOException | |||
* @throws InterruptedException | |||
*/ | |||
@Test | |||
public void testReadLoosePackedRef() throws IOException, | |||
InterruptedException { | |||
Ref ref = db.getRef("refs/heads/master"); | |||
@@ -157,6 +171,7 @@ public class RefTest extends SampleDataRepositoryTestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testReadSimplePackedRefSameRepo() throws IOException { | |||
Ref ref = db.getRef("refs/heads/master"); | |||
ObjectId pid = db.resolve("refs/heads/master^"); | |||
@@ -171,11 +186,13 @@ public class RefTest extends SampleDataRepositoryTestCase { | |||
assertEquals(Storage.LOOSE, ref.getStorage()); | |||
} | |||
@Test | |||
public void testResolvedNamesBranch() throws IOException { | |||
Ref ref = db.getRef("a"); | |||
assertEquals("refs/heads/a", ref.getName()); | |||
} | |||
@Test | |||
public void testResolvedSymRef() throws IOException { | |||
Ref ref = db.getRef(Constants.HEAD); | |||
assertEquals(Constants.HEAD, ref.getName()); |
@@ -45,11 +45,17 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.IOException; | |||
import org.eclipse.jgit.storage.file.FileBasedConfig; | |||
import org.junit.Test; | |||
public class ReflogConfigTest extends RepositoryTestCase { | |||
@Test | |||
public void testlogAllRefUpdates() throws Exception { | |||
long commitTime = 1154236443000L; | |||
int tz = -4 * 60; |
@@ -43,13 +43,23 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertNotSame; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import org.eclipse.jgit.errors.RepositoryNotFoundException; | |||
import org.eclipse.jgit.lib.RepositoryCache.FileKey; | |||
import org.junit.Test; | |||
public class RepositoryCacheTest extends RepositoryTestCase { | |||
@Test | |||
public void testNonBareFileKey() { | |||
File gitdir = db.getDirectory(); | |||
File parent = gitdir.getParentFile(); | |||
@@ -63,6 +73,7 @@ public class RepositoryCacheTest extends RepositoryTestCase { | |||
assertEquals(other, FileKey.lenient(other, db.getFS()).getFile()); | |||
} | |||
@Test | |||
public void testBareFileKey() throws IOException { | |||
Repository bare = createBareRepository(); | |||
File gitdir = bare.getDirectory(); | |||
@@ -77,6 +88,7 @@ public class RepositoryCacheTest extends RepositoryTestCase { | |||
assertEquals(gitdir, FileKey.lenient(new File(parent, name), db.getFS()).getFile()); | |||
} | |||
@Test | |||
public void testFileKeyOpenExisting() throws IOException { | |||
Repository r; | |||
@@ -91,6 +103,7 @@ public class RepositoryCacheTest extends RepositoryTestCase { | |||
r.close(); | |||
} | |||
@Test | |||
public void testFileKeyOpenNew() throws IOException { | |||
final Repository n = createBareRepository(); | |||
final File gitdir = n.getDirectory(); | |||
@@ -111,6 +124,7 @@ public class RepositoryCacheTest extends RepositoryTestCase { | |||
assertFalse(gitdir.exists()); | |||
} | |||
@Test | |||
public void testCacheRegisterOpen() throws Exception { | |||
final File dir = db.getDirectory(); | |||
RepositoryCache.register(db); | |||
@@ -121,6 +135,7 @@ public class RepositoryCacheTest extends RepositoryTestCase { | |||
assertSame(db, RepositoryCache.open(FileKey.lenient(parent, db.getFS()))); | |||
} | |||
@Test | |||
public void testCacheOpen() throws Exception { | |||
final FileKey loc = FileKey.exact(db.getDirectory(), db.getFS()); | |||
final Repository d2 = RepositoryCache.open(loc); |
@@ -46,38 +46,49 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.fail; | |||
import java.io.IOException; | |||
import org.eclipse.jgit.errors.IncorrectObjectTypeException; | |||
import org.junit.Test; | |||
public class RepositoryResolveTest extends SampleDataRepositoryTestCase { | |||
@Test | |||
public void testObjectId_existing() throws IOException { | |||
assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0").name()); | |||
} | |||
@Test | |||
public void testObjectId_nonexisting() throws IOException { | |||
assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c1",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c1").name()); | |||
} | |||
@Test | |||
public void testObjectId_objectid_implicit_firstparent() throws IOException { | |||
assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^").name()); | |||
assertEquals("1203b03dc816ccbb67773f28b3c19318654b0bc8",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^^").name()); | |||
assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^^^").name()); | |||
} | |||
@Test | |||
public void testObjectId_objectid_self() throws IOException { | |||
assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^0").name()); | |||
assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^0^0").name()); | |||
assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^0^0^0").name()); | |||
} | |||
@Test | |||
public void testObjectId_objectid_explicit_firstparent() throws IOException { | |||
assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^1").name()); | |||
assertEquals("1203b03dc816ccbb67773f28b3c19318654b0bc8",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^1^1").name()); | |||
assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^1^1^1").name()); | |||
} | |||
@Test | |||
public void testObjectId_objectid_explicit_otherparents() throws IOException { | |||
assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^1").name()); | |||
assertEquals("f73b95671f326616d66b2afb3bdfcdbbce110b44",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^2").name()); | |||
@@ -85,12 +96,14 @@ public class RepositoryResolveTest extends SampleDataRepositoryTestCase { | |||
assertEquals("d0114ab8ac326bab30e3a657a0397578c5a1af88",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^03").name()); | |||
} | |||
@Test | |||
public void testRef_refname() throws IOException { | |||
assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db.resolve("master^0").name()); | |||
assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db.resolve("master^").name()); | |||
assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db.resolve("refs/heads/master^1").name()); | |||
} | |||
@Test | |||
public void testDistance() throws IOException { | |||
assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~0").name()); | |||
assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~1").name()); | |||
@@ -99,15 +112,18 @@ public class RepositoryResolveTest extends SampleDataRepositoryTestCase { | |||
assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~03").name()); | |||
} | |||
@Test | |||
public void testTree() throws IOException { | |||
assertEquals("6020a3b8d5d636e549ccbd0c53e2764684bb3125",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^{tree}").name()); | |||
assertEquals("02ba32d3649e510002c21651936b7077aa75ffa9",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^^{tree}").name()); | |||
} | |||
@Test | |||
public void testHEAD() throws IOException { | |||
assertEquals("6020a3b8d5d636e549ccbd0c53e2764684bb3125",db.resolve("HEAD^{tree}").name()); | |||
} | |||
@Test | |||
public void testDerefCommit() throws IOException { | |||
assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^{}").name()); | |||
assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^{commit}").name()); | |||
@@ -115,6 +131,7 @@ public class RepositoryResolveTest extends SampleDataRepositoryTestCase { | |||
assertEquals("6020a3b8d5d636e549ccbd0c53e2764684bb3125",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^{commit}^{tree}").name()); | |||
} | |||
@Test | |||
public void testDerefTag() throws IOException { | |||
assertEquals("17768080a2318cd89bba4c8b87834401e2095703",db.resolve("refs/tags/B").name()); | |||
assertEquals("d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864",db.resolve("refs/tags/B^{commit}").name()); | |||
@@ -129,6 +146,7 @@ public class RepositoryResolveTest extends SampleDataRepositoryTestCase { | |||
assertEquals("2c349335b7f797072cf729c4f3bb0914ecb6dec9",db.resolve("refs/tags/B10th~2").name()); | |||
} | |||
@Test | |||
public void testDerefBlob() throws IOException { | |||
assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db.resolve("spearce-gpg-pub^{}").name()); | |||
assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db.resolve("spearce-gpg-pub^{blob}").name()); | |||
@@ -136,12 +154,14 @@ public class RepositoryResolveTest extends SampleDataRepositoryTestCase { | |||
assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db.resolve("fd608fbe625a2b456d9f15c2b1dc41f252057dd7^{blob}").name()); | |||
} | |||
@Test | |||
public void testDerefTree() throws IOException { | |||
assertEquals("032c063ce34486359e3ee3d4f9e5c225b9e1a4c2",db.resolve("refs/tags/B10th").name()); | |||
assertEquals("856ec208ae6cadac25a6d74f19b12bb27a24fe24",db.resolve("032c063ce34486359e3ee3d4f9e5c225b9e1a4c2^{tree}").name()); | |||
assertEquals("856ec208ae6cadac25a6d74f19b12bb27a24fe24",db.resolve("refs/tags/B10th^{tree}").name()); | |||
} | |||
@Test | |||
public void testParseGitDescribeOutput() throws IOException { | |||
ObjectId exp = db.resolve("b"); | |||
assertEquals(exp, db.resolve("B-g7f82283")); // old style | |||
@@ -161,6 +181,7 @@ public class RepositoryResolveTest extends SampleDataRepositoryTestCase { | |||
assertEquals(db.resolve("b~2"), db.resolve("B-6-g7f82283~2")); | |||
} | |||
@Test | |||
public void testParseLookupPath() throws IOException { | |||
ObjectId b2_txt = id("10da5895682013006950e7da534b705252b03be6"); | |||
ObjectId b3_b2_txt = id("e6bfff5c1d0f0ecd501552b43a1e13d8008abc31"); |
@@ -46,6 +46,8 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.FileNotFoundException; | |||
@@ -63,6 +65,7 @@ import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase; | |||
import org.eclipse.jgit.storage.file.FileRepository; | |||
import org.eclipse.jgit.treewalk.FileTreeIterator; | |||
import org.eclipse.jgit.util.FileUtils; | |||
import org.junit.Before; | |||
/** | |||
* Base class for most JGit unit tests. | |||
@@ -122,7 +125,8 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase { | |||
protected File trash; | |||
@Override | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
db = createWorkRepository(); | |||
trash = db.getWorkTree(); |
@@ -48,12 +48,12 @@ package org.eclipse.jgit.lib; | |||
import java.io.File; | |||
import org.eclipse.jgit.util.JGitTestUtil; | |||
import org.eclipse.jgit.junit.JGitTestUtil; | |||
/** Test case which includes C Git generated pack files for testing. */ | |||
public abstract class SampleDataRepositoryTestCase extends RepositoryTestCase { | |||
@Override | |||
protected void setUp() throws Exception { | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
final String[] packs = { |
@@ -43,9 +43,15 @@ | |||
package org.eclipse.jgit.lib; | |||
import junit.framework.TestCase; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
public class SymbolicRefTest extends TestCase { | |||
import org.junit.Test; | |||
public class SymbolicRefTest { | |||
private static final ObjectId ID_A = ObjectId | |||
.fromString("41eb0d88f833b558bddeb269b7ab77399cdf98ed"); | |||
@@ -56,6 +62,7 @@ public class SymbolicRefTest extends TestCase { | |||
private static final String name = "refs/remotes/origin/HEAD"; | |||
@Test | |||
public void testConstructor() { | |||
Ref t; | |||
SymbolicRef r; | |||
@@ -83,6 +90,7 @@ public class SymbolicRefTest extends TestCase { | |||
assertTrue("is symbolic", r.isSymbolic()); | |||
} | |||
@Test | |||
public void testLeaf() { | |||
Ref a; | |||
SymbolicRef b, c, d; | |||
@@ -114,6 +122,7 @@ public class SymbolicRefTest extends TestCase { | |||
assertSame(ID_B, b.getPeeledObjectId()); | |||
} | |||
@Test | |||
public void testToString() { | |||
Ref a; | |||
SymbolicRef b, c, d; |
@@ -43,12 +43,16 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import java.util.Date; | |||
import java.util.TimeZone; | |||
import junit.framework.TestCase; | |||
import org.junit.Test; | |||
public class T0001_PersonIdentTest { | |||
public class T0001_PersonIdent extends TestCase { | |||
@Test | |||
public void test001_NewIdent() { | |||
final PersonIdent p = new PersonIdent("A U Thor", "author@example.com", | |||
new Date(1142878501000L), TimeZone.getTimeZone("EST")); | |||
@@ -59,6 +63,7 @@ public class T0001_PersonIdent extends TestCase { | |||
p.toExternalString()); | |||
} | |||
@Test | |||
public void test002_NewIdent() { | |||
final PersonIdent p = new PersonIdent("A U Thor", "author@example.com", | |||
new Date(1142878501000L), TimeZone.getTimeZone("GMT+0230")); |
@@ -44,12 +44,20 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertSame; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.IOException; | |||
import java.io.UnsupportedEncodingException; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
public class T0002_Tree extends SampleDataRepositoryTestCase { | |||
import org.junit.Test; | |||
public class T0002_TreeTest extends SampleDataRepositoryTestCase { | |||
private static final ObjectId SOME_FAKE_ID = ObjectId.fromString( | |||
"0123456789abcdef0123456789abcdef01234567"); | |||
@@ -71,13 +79,18 @@ public class T0002_Tree extends SampleDataRepositoryTestCase { | |||
return Tree.compareNames(abytes, bbytes, lasta, lastb); | |||
} | |||
@Test | |||
public void test000_sort_01() throws UnsupportedEncodingException { | |||
assertEquals(0, compareNamesUsingSpecialCompare("a","a")); | |||
} | |||
@Test | |||
public void test000_sort_02() throws UnsupportedEncodingException { | |||
assertEquals(-1, compareNamesUsingSpecialCompare("a","b")); | |||
assertEquals(1, compareNamesUsingSpecialCompare("b","a")); | |||
} | |||
@Test | |||
public void test000_sort_03() throws UnsupportedEncodingException { | |||
assertEquals(1, compareNamesUsingSpecialCompare("a:","a")); | |||
assertEquals(1, compareNamesUsingSpecialCompare("a/","a")); | |||
@@ -86,16 +99,21 @@ public class T0002_Tree extends SampleDataRepositoryTestCase { | |||
assertEquals(1, compareNamesUsingSpecialCompare("a:","a/")); | |||
assertEquals(-1, compareNamesUsingSpecialCompare("a/","a:")); | |||
} | |||
@Test | |||
public void test000_sort_04() throws UnsupportedEncodingException { | |||
assertEquals(-1, compareNamesUsingSpecialCompare("a.a","a/a")); | |||
assertEquals(1, compareNamesUsingSpecialCompare("a/a","a.a")); | |||
} | |||
@Test | |||
public void test000_sort_05() throws UnsupportedEncodingException { | |||
assertEquals(-1, compareNamesUsingSpecialCompare("a.","a/")); | |||
assertEquals(1, compareNamesUsingSpecialCompare("a/","a.")); | |||
} | |||
@Test | |||
public void test001_createEmpty() throws IOException { | |||
final Tree t = new Tree(db); | |||
assertTrue("isLoaded", t.isLoaded()); | |||
@@ -114,6 +132,7 @@ public class T0002_Tree extends SampleDataRepositoryTestCase { | |||
assertTrue("no foo child", t.findBlobMember("foo") == null); | |||
} | |||
@Test | |||
public void test002_addFile() throws IOException { | |||
final Tree t = new Tree(db); | |||
t.setId(SOME_FAKE_ID); | |||
@@ -139,6 +158,7 @@ public class T0002_Tree extends SampleDataRepositoryTestCase { | |||
assertTrue("iterator is empty", i != null && i.length == 1); | |||
} | |||
@Test | |||
public void test004_addTree() throws IOException { | |||
final Tree t = new Tree(db); | |||
t.setId(SOME_FAKE_ID); | |||
@@ -169,6 +189,7 @@ public class T0002_Tree extends SampleDataRepositoryTestCase { | |||
assertTrue("iterator is empty", i.length == 1); | |||
} | |||
@Test | |||
public void test005_addRecursiveFile() throws IOException { | |||
final Tree t = new Tree(db); | |||
final FileTreeEntry f = t.addFile("a/b/c"); | |||
@@ -180,6 +201,7 @@ public class T0002_Tree extends SampleDataRepositoryTestCase { | |||
.getParent()); | |||
} | |||
@Test | |||
public void test005_addRecursiveTree() throws IOException { | |||
final Tree t = new Tree(db); | |||
final Tree f = t.addTree("a/b/c"); | |||
@@ -191,6 +213,7 @@ public class T0002_Tree extends SampleDataRepositoryTestCase { | |||
.getParent()); | |||
} | |||
@Test | |||
public void test006_addDeepTree() throws IOException { | |||
final Tree t = new Tree(db); | |||
@@ -240,6 +263,7 @@ public class T0002_Tree extends SampleDataRepositoryTestCase { | |||
assertTrue("t no id", t.getId() == null); | |||
} | |||
@Test | |||
public void test007_manyFileLookup() throws IOException { | |||
final Tree t = new Tree(db); | |||
final List<FileTreeEntry> files = new ArrayList<FileTreeEntry>(26 * 26); | |||
@@ -262,6 +286,7 @@ public class T0002_Tree extends SampleDataRepositoryTestCase { | |||
} | |||
} | |||
@Test | |||
public void test008_SubtreeInternalSorting() throws IOException { | |||
final Tree t = new Tree(db); | |||
final FileTreeEntry e0 = t.addFile("a-b"); | |||
@@ -278,6 +303,7 @@ public class T0002_Tree extends SampleDataRepositoryTestCase { | |||
assertSame(e2, ents[4]); | |||
} | |||
@Test | |||
public void test009_SymlinkAndGitlink() throws IOException { | |||
final Tree symlinkTree = db.mapTree("symlink"); | |||
assertTrue("Symlink entry exists", symlinkTree.existsBlob("symlink.txt")); |
@@ -43,12 +43,19 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.util.concurrent.CountDownLatch; | |||
import java.util.concurrent.TimeUnit; | |||
import junit.framework.TestCase; | |||
import org.junit.Test; | |||
public class ThreadSafeProgressMonitorTest extends TestCase { | |||
public class ThreadSafeProgressMonitorTest { | |||
@Test | |||
public void testFailsMethodsOnBackgroundThread() | |||
throws InterruptedException { | |||
final MockProgressMonitor mock = new MockProgressMonitor(); | |||
@@ -84,6 +91,7 @@ public class ThreadSafeProgressMonitorTest extends TestCase { | |||
assertEquals(0, mock.value); | |||
} | |||
@Test | |||
public void testMethodsOkOnMainThread() { | |||
final MockProgressMonitor mock = new MockProgressMonitor(); | |||
final ThreadSafeProgressMonitor pm = new ThreadSafeProgressMonitor(mock); | |||
@@ -106,6 +114,7 @@ public class ThreadSafeProgressMonitorTest extends TestCase { | |||
assertEquals(0, mock.value); | |||
} | |||
@Test | |||
public void testUpdateOnBackgroundThreads() throws InterruptedException { | |||
final MockProgressMonitor mock = new MockProgressMonitor(); | |||
final ThreadSafeProgressMonitor pm = new ThreadSafeProgressMonitor(mock); |
@@ -44,11 +44,18 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.IOException; | |||
import org.junit.Test; | |||
public class TreeIteratorLeafOnlyTest extends RepositoryTestCase { | |||
/** Empty tree */ | |||
@Test | |||
public void testEmpty() { | |||
Tree tree = new Tree(db); | |||
TreeIterator i = makeIterator(tree); | |||
@@ -60,6 +67,7 @@ public class TreeIteratorLeafOnlyTest extends RepositoryTestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testSimpleF1() throws IOException { | |||
Tree tree = new Tree(db); | |||
tree.addFile("x"); | |||
@@ -73,6 +81,7 @@ public class TreeIteratorLeafOnlyTest extends RepositoryTestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testSimpleF2() throws IOException { | |||
Tree tree = new Tree(db); | |||
tree.addFile("a"); | |||
@@ -88,6 +97,7 @@ public class TreeIteratorLeafOnlyTest extends RepositoryTestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testSimpleT() throws IOException { | |||
Tree tree = new Tree(db); | |||
tree.addTree("a"); | |||
@@ -95,6 +105,7 @@ public class TreeIteratorLeafOnlyTest extends RepositoryTestCase { | |||
assertFalse(i.hasNext()); | |||
} | |||
@Test | |||
public void testTricky() throws IOException { | |||
Tree tree = new Tree(db); | |||
tree.addFile("a.b"); |
@@ -44,11 +44,18 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.IOException; | |||
import org.junit.Test; | |||
public class TreeIteratorPostOrderTest extends RepositoryTestCase { | |||
/** Empty tree */ | |||
@Test | |||
public void testEmpty() { | |||
Tree tree = new Tree(db); | |||
TreeIterator i = makeIterator(tree); | |||
@@ -62,6 +69,7 @@ public class TreeIteratorPostOrderTest extends RepositoryTestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testSimpleF1() throws IOException { | |||
Tree tree = new Tree(db); | |||
tree.addFile("x"); | |||
@@ -78,6 +86,7 @@ public class TreeIteratorPostOrderTest extends RepositoryTestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testSimpleF2() throws IOException { | |||
Tree tree = new Tree(db); | |||
tree.addFile("a"); | |||
@@ -96,6 +105,7 @@ public class TreeIteratorPostOrderTest extends RepositoryTestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testSimpleT() throws IOException { | |||
Tree tree = new Tree(db); | |||
tree.addTree("a"); | |||
@@ -107,6 +117,7 @@ public class TreeIteratorPostOrderTest extends RepositoryTestCase { | |||
assertFalse(i.hasNext()); | |||
} | |||
@Test | |||
public void testTricky() throws IOException { | |||
Tree tree = new Tree(db); | |||
tree.addFile("a.b"); |
@@ -44,11 +44,18 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.IOException; | |||
import org.junit.Test; | |||
public class TreeIteratorPreOrderTest extends RepositoryTestCase { | |||
/** Empty tree */ | |||
@Test | |||
public void testEmpty() { | |||
Tree tree = new Tree(db); | |||
TreeIterator i = makeIterator(tree); | |||
@@ -62,6 +69,7 @@ public class TreeIteratorPreOrderTest extends RepositoryTestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testSimpleF1() throws IOException { | |||
Tree tree = new Tree(db); | |||
tree.addFile("x"); | |||
@@ -78,6 +86,7 @@ public class TreeIteratorPreOrderTest extends RepositoryTestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testSimpleF2() throws IOException { | |||
Tree tree = new Tree(db); | |||
tree.addFile("a"); | |||
@@ -96,6 +105,7 @@ public class TreeIteratorPreOrderTest extends RepositoryTestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testSimpleT() throws IOException { | |||
Tree tree = new Tree(db); | |||
tree.addTree("a"); | |||
@@ -107,6 +117,7 @@ public class TreeIteratorPreOrderTest extends RepositoryTestCase { | |||
assertFalse(i.hasNext()); | |||
} | |||
@Test | |||
public void testTricky() throws IOException { | |||
Tree tree = new Tree(db); | |||
tree.addFile("a.b"); |
@@ -43,23 +43,28 @@ | |||
package org.eclipse.jgit.lib; | |||
import junit.framework.TestCase; | |||
import static org.junit.Assert.assertEquals; | |||
public class ValidRefNameTest extends TestCase { | |||
import org.junit.Test; | |||
public class ValidRefNameTest { | |||
private static void assertValid(final boolean exp, final String name) { | |||
assertEquals("\"" + name + "\"", exp, Repository.isValidRefName(name)); | |||
} | |||
@Test | |||
public void testEmptyString() { | |||
assertValid(false, ""); | |||
assertValid(false, "/"); | |||
} | |||
@Test | |||
public void testMustHaveTwoComponents() { | |||
assertValid(false, "master"); | |||
assertValid(true, "heads/master"); | |||
} | |||
@Test | |||
public void testValidHead() { | |||
assertValid(true, "refs/heads/master"); | |||
assertValid(true, "refs/heads/pu"); | |||
@@ -67,27 +72,33 @@ public class ValidRefNameTest extends TestCase { | |||
assertValid(true, "refs/heads/FoO"); | |||
} | |||
@Test | |||
public void testValidTag() { | |||
assertValid(true, "refs/tags/v1.0"); | |||
} | |||
@Test | |||
public void testNoLockSuffix() { | |||
assertValid(false, "refs/heads/master.lock"); | |||
} | |||
@Test | |||
public void testNoDirectorySuffix() { | |||
assertValid(false, "refs/heads/master/"); | |||
} | |||
@Test | |||
public void testNoSpace() { | |||
assertValid(false, "refs/heads/i haz space"); | |||
} | |||
@Test | |||
public void testNoAsciiControlCharacters() { | |||
for (char c = '\0'; c < ' '; c++) | |||
assertValid(false, "refs/heads/mast" + c + "er"); | |||
} | |||
@Test | |||
public void testNoBareDot() { | |||
assertValid(false, "refs/heads/."); | |||
assertValid(false, "refs/heads/.."); | |||
@@ -95,6 +106,7 @@ public class ValidRefNameTest extends TestCase { | |||
assertValid(false, "refs/heads/../master"); | |||
} | |||
@Test | |||
public void testNoLeadingOrTrailingDot() { | |||
assertValid(false, "."); | |||
assertValid(false, "refs/heads/.bar"); | |||
@@ -102,11 +114,13 @@ public class ValidRefNameTest extends TestCase { | |||
assertValid(false, "refs/heads/bar."); | |||
} | |||
@Test | |||
public void testContainsDot() { | |||
assertValid(true, "refs/heads/m.a.s.t.e.r"); | |||
assertValid(false, "refs/heads/master..pu"); | |||
} | |||
@Test | |||
public void testNoMagicRefCharacters() { | |||
assertValid(false, "refs/heads/master^"); | |||
assertValid(false, "refs/heads/^master"); | |||
@@ -121,6 +135,7 @@ public class ValidRefNameTest extends TestCase { | |||
assertValid(false, ":refs/heads/master"); | |||
} | |||
@Test | |||
public void testShellGlob() { | |||
assertValid(false, "refs/heads/master?"); | |||
assertValid(false, "refs/heads/?master"); | |||
@@ -135,6 +150,7 @@ public class ValidRefNameTest extends TestCase { | |||
assertValid(false, "*refs/heads/master"); | |||
} | |||
@Test | |||
public void testValidSpecialCharacters() { | |||
assertValid(true, "refs/heads/!"); | |||
assertValid(true, "refs/heads/\""); | |||
@@ -166,10 +182,12 @@ public class ValidRefNameTest extends TestCase { | |||
assertValid(false, "refs/heads/\\"); | |||
} | |||
@Test | |||
public void testUnicodeNames() { | |||
assertValid(true, "refs/heads/\u00e5ngstr\u00f6m"); | |||
} | |||
@Test | |||
public void testRefLogQueryIsValidRef() { | |||
assertValid(false, "refs/heads/master@{1}"); | |||
assertValid(false, "refs/heads/master@{1.hour.ago}"); |
@@ -44,13 +44,21 @@ | |||
package org.eclipse.jgit.lib; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import org.eclipse.jgit.errors.CheckoutConflictException; | |||
import org.junit.Test; | |||
public class WorkDirCheckoutTest extends RepositoryTestCase { | |||
@Test | |||
public void testFindingConflicts() throws IOException { | |||
GitIndex index = new GitIndex(db); | |||
index.add(trash, writeTrashFile("bar", "bar")); | |||
@@ -86,6 +94,7 @@ public class WorkDirCheckoutTest extends RepositoryTestCase { | |||
assertTrue(removedEntries.contains("foo")); | |||
} | |||
@Test | |||
public void testCheckingOutWithConflicts() throws IOException { | |||
GitIndex index = new GitIndex(db); | |||
index.add(trash, writeTrashFile("bar", "bar")); |
@@ -45,6 +45,9 @@ | |||
package org.eclipse.jgit.merge; | |||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import org.eclipse.jgit.dircache.DirCache; | |||
import org.eclipse.jgit.dircache.DirCacheBuilder; | |||
@@ -57,8 +60,10 @@ import org.eclipse.jgit.lib.ObjectInserter; | |||
import org.eclipse.jgit.lib.PersonIdent; | |||
import org.eclipse.jgit.lib.RepositoryTestCase; | |||
import org.eclipse.jgit.treewalk.TreeWalk; | |||
import org.junit.Test; | |||
public class CherryPickTest extends RepositoryTestCase { | |||
@Test | |||
public void testPick() throws Exception { | |||
// B---O | |||
// \----P---T |
@@ -43,16 +43,17 @@ | |||
package org.eclipse.jgit.merge; | |||
import static org.junit.Assert.assertEquals; | |||
import java.io.ByteArrayOutputStream; | |||
import java.io.IOException; | |||
import junit.framework.TestCase; | |||
import org.eclipse.jgit.diff.RawText; | |||
import org.eclipse.jgit.diff.RawTextComparator; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.junit.Test; | |||
public class MergeAlgorithmTest extends TestCase { | |||
public class MergeAlgorithmTest { | |||
MergeFormatter fmt=new MergeFormatter(); | |||
/** | |||
@@ -61,6 +62,7 @@ public class MergeAlgorithmTest extends TestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testTwoConflictingModifications() throws IOException { | |||
assertEquals(t("a<b=Z>Zdefghij"), | |||
merge("abcdefghij", "abZdefghij", "aZZdefghij")); | |||
@@ -73,6 +75,7 @@ public class MergeAlgorithmTest extends TestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testOneAgainstTwoConflictingModifications() throws IOException { | |||
assertEquals(t("aZ<Z=c>Zefghij"), | |||
merge("abcdefghij", "aZZZefghij", "aZcZefghij")); | |||
@@ -84,6 +87,7 @@ public class MergeAlgorithmTest extends TestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testNoAgainstOneModification() throws IOException { | |||
assertEquals(t("aZcZefghij"), | |||
merge("abcdefghij", "abcdefghij", "aZcZefghij")); | |||
@@ -95,6 +99,7 @@ public class MergeAlgorithmTest extends TestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testTwoNonConflictingModifications() throws IOException { | |||
assertEquals(t("YbZdefghij"), | |||
merge("abcdefghij", "abZdefghij", "Ybcdefghij")); | |||
@@ -106,6 +111,7 @@ public class MergeAlgorithmTest extends TestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testTwoComplicatedModifications() throws IOException { | |||
assertEquals(t("a<ZZZZfZhZj=bYdYYYYiY>"), | |||
merge("abcdefghij", "aZZZZfZhZj", "abYdYYYYiY")); | |||
@@ -116,6 +122,7 @@ public class MergeAlgorithmTest extends TestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testConflictAtStart() throws IOException { | |||
assertEquals(t("<Z=Y>bcdefghij"), | |||
merge("abcdefghij", "Zbcdefghij", "Ybcdefghij")); | |||
@@ -126,6 +133,7 @@ public class MergeAlgorithmTest extends TestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testConflictAtEnd() throws IOException { | |||
assertEquals(t("abcdefghi<Z=Y>"), | |||
merge("abcdefghij", "abcdefghiZ", "abcdefghiY")); | |||
@@ -137,6 +145,7 @@ public class MergeAlgorithmTest extends TestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testSameModification() throws IOException { | |||
assertEquals(t("abZdefghij"), | |||
merge("abcdefghij", "abZdefghij", "abZdefghij")); | |||
@@ -148,19 +157,23 @@ public class MergeAlgorithmTest extends TestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testDeleteVsModify() throws IOException { | |||
assertEquals(t("ab<=Z>defghij"), | |||
merge("abcdefghij", "abdefghij", "abZdefghij")); | |||
} | |||
@Test | |||
public void testInsertVsModify() throws IOException { | |||
assertEquals(t("a<bZ=XY>"), merge("ab", "abZ", "aXY")); | |||
} | |||
@Test | |||
public void testAdjacentModifications() throws IOException { | |||
assertEquals(t("a<Zc=bY>d"), merge("abcd", "aZcd", "abYd")); | |||
} | |||
@Test | |||
public void testSeperateModifications() throws IOException { | |||
assertEquals(t("aZcYe"), merge("abcde", "aZcde", "abcYe")); | |||
} | |||
@@ -172,6 +185,7 @@ public class MergeAlgorithmTest extends TestCase { | |||
* | |||
* @throws IOException | |||
*/ | |||
@Test | |||
public void testTwoSimilarModsAndOneInsert() throws IOException { | |||
assertEquals(t("IAAJ"), merge("iA", "IA", "IAAJ")); | |||
assertEquals(t("aBcDde"), merge("abcde", "aBcde", "aBcDde")); |
@@ -42,15 +42,19 @@ | |||
*/ | |||
package org.eclipse.jgit.merge; | |||
import static org.junit.Assert.assertEquals; | |||
import java.io.IOException; | |||
import java.util.Arrays; | |||
import org.eclipse.jgit.lib.ObjectId; | |||
import org.eclipse.jgit.lib.ObjectIdRef; | |||
import org.eclipse.jgit.lib.Ref; | |||
import org.eclipse.jgit.lib.Ref.Storage; | |||
import org.eclipse.jgit.lib.RefUpdate; | |||
import org.eclipse.jgit.lib.SampleDataRepositoryTestCase; | |||
import org.eclipse.jgit.lib.Ref.Storage; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
/** | |||
* Test construction of merge message by {@link MergeMessageFormatter}. | |||
@@ -60,7 +64,8 @@ public class MergeMessageFormatterTest extends SampleDataRepositoryTestCase { | |||
private MergeMessageFormatter formatter; | |||
@Override | |||
protected void setUp() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
RefUpdate createRemoteRefA = db | |||
@@ -76,6 +81,7 @@ public class MergeMessageFormatterTest extends SampleDataRepositoryTestCase { | |||
formatter = new MergeMessageFormatter(); | |||
} | |||
@Test | |||
public void testOneBranch() throws IOException { | |||
Ref a = db.getRef("refs/heads/a"); | |||
Ref master = db.getRef("refs/heads/master"); | |||
@@ -83,6 +89,7 @@ public class MergeMessageFormatterTest extends SampleDataRepositoryTestCase { | |||
assertEquals("Merge branch 'a'", message); | |||
} | |||
@Test | |||
public void testTwoBranches() throws IOException { | |||
Ref a = db.getRef("refs/heads/a"); | |||
Ref b = db.getRef("refs/heads/b"); | |||
@@ -91,6 +98,7 @@ public class MergeMessageFormatterTest extends SampleDataRepositoryTestCase { | |||
assertEquals("Merge branches 'a' and 'b'", message); | |||
} | |||
@Test | |||
public void testThreeBranches() throws IOException { | |||
Ref c = db.getRef("refs/heads/c"); | |||
Ref b = db.getRef("refs/heads/b"); | |||
@@ -100,6 +108,7 @@ public class MergeMessageFormatterTest extends SampleDataRepositoryTestCase { | |||
assertEquals("Merge branches 'c', 'b' and 'a'", message); | |||
} | |||
@Test | |||
public void testRemoteBranch() throws Exception { | |||
Ref remoteA = db.getRef("refs/remotes/origin/remote-a"); | |||
Ref master = db.getRef("refs/heads/master"); | |||
@@ -107,6 +116,7 @@ public class MergeMessageFormatterTest extends SampleDataRepositoryTestCase { | |||
assertEquals("Merge remote branch 'origin/remote-a'", message); | |||
} | |||
@Test | |||
public void testMixed() throws IOException { | |||
Ref c = db.getRef("refs/heads/c"); | |||
Ref remoteA = db.getRef("refs/remotes/origin/remote-a"); | |||
@@ -116,6 +126,7 @@ public class MergeMessageFormatterTest extends SampleDataRepositoryTestCase { | |||
message); | |||
} | |||
@Test | |||
public void testTag() throws IOException { | |||
Ref tagA = db.getRef("refs/tags/A"); | |||
Ref master = db.getRef("refs/heads/master"); | |||
@@ -123,6 +134,7 @@ public class MergeMessageFormatterTest extends SampleDataRepositoryTestCase { | |||
assertEquals("Merge tag 'A'", message); | |||
} | |||
@Test | |||
public void testCommit() throws IOException { | |||
ObjectId objectId = ObjectId | |||
.fromString("6db9c2ebf75590eef973081736730a9ea169a0c4"); | |||
@@ -134,6 +146,7 @@ public class MergeMessageFormatterTest extends SampleDataRepositoryTestCase { | |||
message); | |||
} | |||
@Test | |||
public void testPullWithUri() throws IOException { | |||
String name = "branch 'test' of http://egit.eclipse.org/jgit.git"; | |||
ObjectId objectId = ObjectId | |||
@@ -146,6 +159,7 @@ public class MergeMessageFormatterTest extends SampleDataRepositoryTestCase { | |||
message); | |||
} | |||
@Test | |||
public void testIntoOtherThanMaster() throws IOException { | |||
Ref a = db.getRef("refs/heads/a"); | |||
Ref b = db.getRef("refs/heads/b"); |
@@ -45,6 +45,9 @@ | |||
package org.eclipse.jgit.merge; | |||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import java.io.IOException; | |||
@@ -59,9 +62,11 @@ import org.eclipse.jgit.lib.ObjectInserter; | |||
import org.eclipse.jgit.lib.PersonIdent; | |||
import org.eclipse.jgit.lib.SampleDataRepositoryTestCase; | |||
import org.eclipse.jgit.treewalk.TreeWalk; | |||
import org.junit.Test; | |||
public class SimpleMergeTest extends SampleDataRepositoryTestCase { | |||
@Test | |||
public void testOurs() throws IOException { | |||
Merger ourMerger = MergeStrategy.OURS.newMerger(db); | |||
boolean merge = ourMerger.merge(new ObjectId[] { db.resolve("a"), db.resolve("c") }); | |||
@@ -69,6 +74,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase { | |||
assertEquals(db.mapTree("a").getId(), ourMerger.getResultTreeId()); | |||
} | |||
@Test | |||
public void testTheirs() throws IOException { | |||
Merger ourMerger = MergeStrategy.THEIRS.newMerger(db); | |||
boolean merge = ourMerger.merge(new ObjectId[] { db.resolve("a"), db.resolve("c") }); | |||
@@ -76,6 +82,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase { | |||
assertEquals(db.mapTree("c").getId(), ourMerger.getResultTreeId()); | |||
} | |||
@Test | |||
public void testTrivialTwoWay() throws IOException { | |||
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db); | |||
boolean merge = ourMerger.merge(new ObjectId[] { db.resolve("a"), db.resolve("c") }); | |||
@@ -83,6 +90,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase { | |||
assertEquals("02ba32d3649e510002c21651936b7077aa75ffa9",ourMerger.getResultTreeId().name()); | |||
} | |||
@Test | |||
public void testTrivialTwoWay_disjointhistories() throws IOException { | |||
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db); | |||
boolean merge = ourMerger.merge(new ObjectId[] { db.resolve("a"), db.resolve("c~4") }); | |||
@@ -90,6 +98,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase { | |||
assertEquals("86265c33b19b2be71bdd7b8cb95823f2743d03a8",ourMerger.getResultTreeId().name()); | |||
} | |||
@Test | |||
public void testTrivialTwoWay_ok() throws IOException { | |||
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db); | |||
boolean merge = ourMerger.merge(new ObjectId[] { db.resolve("a^0^0^0"), db.resolve("a^0^0^1") }); | |||
@@ -97,12 +106,14 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase { | |||
assertEquals(db.mapTree("a^0^0").getId(), ourMerger.getResultTreeId()); | |||
} | |||
@Test | |||
public void testTrivialTwoWay_conflict() throws IOException { | |||
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db); | |||
boolean merge = ourMerger.merge(new ObjectId[] { db.resolve("f"), db.resolve("g") }); | |||
assertFalse(merge); | |||
} | |||
@Test | |||
public void testTrivialTwoWay_validSubtreeSort() throws Exception { | |||
final DirCache treeB = db.readDirCache(); | |||
final DirCache treeO = db.readDirCache(); | |||
@@ -155,6 +166,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase { | |||
assertFalse(tw.next()); | |||
} | |||
@Test | |||
public void testTrivialTwoWay_concurrentSubtreeChange() throws Exception { | |||
final DirCache treeB = db.readDirCache(); | |||
final DirCache treeO = db.readDirCache(); | |||
@@ -202,6 +214,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase { | |||
assertFalse(tw.next()); | |||
} | |||
@Test | |||
public void testTrivialTwoWay_conflictSubtreeChange() throws Exception { | |||
final DirCache treeB = db.readDirCache(); | |||
final DirCache treeO = db.readDirCache(); | |||
@@ -235,6 +248,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase { | |||
assertFalse(merge); | |||
} | |||
@Test | |||
public void testTrivialTwoWay_leftDFconflict1() throws Exception { | |||
final DirCache treeB = db.readDirCache(); | |||
final DirCache treeO = db.readDirCache(); | |||
@@ -267,6 +281,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase { | |||
assertFalse(merge); | |||
} | |||
@Test | |||
public void testTrivialTwoWay_rightDFconflict1() throws Exception { | |||
final DirCache treeB = db.readDirCache(); | |||
final DirCache treeO = db.readDirCache(); | |||
@@ -299,6 +314,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase { | |||
assertFalse(merge); | |||
} | |||
@Test | |||
public void testTrivialTwoWay_leftDFconflict2() throws Exception { | |||
final DirCache treeB = db.readDirCache(); | |||
final DirCache treeO = db.readDirCache(); | |||
@@ -329,6 +345,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase { | |||
assertFalse(merge); | |||
} | |||
@Test | |||
public void testTrivialTwoWay_rightDFconflict2() throws Exception { | |||
final DirCache treeB = db.readDirCache(); | |||
final DirCache treeO = db.readDirCache(); |