summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit/src
Commit message (Collapse)AuthorAgeFilesLines
* Move base test classes to the junit bundle for reuse for Java 7 testsRobin Rosenberg2013-02-042-0/+574
| | | | Change-Id: Iedb54eb9d8396bc3ae66d8754c1527fd9ca655f9
* Remove packIndex field from FileObjDatabase openPack method.Colby Ranger2013-01-101-1/+1
| | | | | | | | | | | Previously, the FileObjDatabase required both the pack file path and index file path to be passed to openPack(). A future change to add a bitmap index will add a .bitmap file parallel to the pack file (similar to the .idx file). Update the PackFile to support automatically loading pack index extensions based on the pack file path. Change-Id: Ifc8fc3e57f4afa177ba5a88df87334dbfa799f01
* Declare essentially static methods as staticRobin Rosenberg2012-12-272-3/+3
| | | | Change-Id: I83ca25fb569c0dbc36eb374d5437fcf2b65a6f68
* Provide a convenient read() in RepositoryTestCaseRobin Stocker2012-09-252-13/+23
| | | | | | | For reading a file by its repository-relative path, analogous to writeTrashFile. Change-Id: I112de0d57c2ee1bd425de6cbf561a57fea7147f0
* Suppress boxing warnings where we know they are okRobin Rosenberg2012-09-221-0/+58
| | | | | | | | | Invoke the wrapper types' valueOf via static imports. For booleans used in asserts, add a new assert in the JUnit utility package since out current version of JUnit does not have the assert(boolean, boolean) method. Change-Id: I9099bd8efbc8c133479344d51ce7dabed8958a2b
* Additional unit tests for the GCSasa Zivkov2012-09-161-1/+28
| | | | | Change-Id: Id5b578f7040c6c896ab9386a6b5ed62b0f495ed5 Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Ensure a directory exists before trying to create/merge a file into it.Jevgeni Zelenkov2012-08-061-0/+8
| | | | | | | | | | Since git doesn't keep track of empty directories, they should be created first. Test case included demonstrates that using StashApplyCommand(). Bugfix is applied to the DirCacheCheckout class, because StashApplyCommand() uses it internally to apply a stash. Change-Id: Iac259229ef919f9e92e7e51a671d877172bb88a8 Signed-off-by: Jevgeni Zelenkov <jevgeni.zelenkov@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Add a CommitBuilder method to edit arbitrary DirCacheEntrysDave Borowitz2012-06-151-2/+6
| | | | Change-Id: Ic2f5ec28621219a8ff1272674e2bf2c8d36eb107
* Get rid of warnings about empty statmentsRobin Rosenberg2012-06-061-0/+6
| | | | | | | | In HtttpAuthMethod there were comments, but not in a style that Eclipse recognizes. Change-Id: I64f55b27143f8badcefbb419d3951f2a26b87d5f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Validate paths during DirCheckoutRobin Rosenberg2012-04-231-0/+1
| | | | | | | | | | | | | | | | | | | DirCacheCheckout and CanonicalTreeParser cooperate. CanonicalTreeParser can detect malformed, potentially malicious tree entries and sets a flag, while DirCacheCheckout refuses to work with such paths. Malicious tree entries are ".", "..", ".git" (case insensitive), any name containing '/' and (on Windows '\') and also (on Windows) any paths ending in a combination of '.' or space or containing a ':'. We also forbid all special names like "con" etc on Windows. Some of the test can execute on any platform by enabling partial platform emulation. A new runtime exception, InvalidPathException, is introduced. For backwards compatibility it extends InvalidArgumentException. Change-Id: I86199105814b63d4340e5de0e471d0da6b579ead Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Let the date formatter pick the locale.Daniel Megert2012-02-251-0/+13
| | | | | | | | | Instead of using the locale from the SystemReader we let the SystemReader create the date formats without passing the locale. Bug 368756 Change-Id: I6be9e07af804a08f3f3ac2d2d526ef594eed19e3 Signed-off-by: Daniel Megert <daniel_megert@ch.ibm.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Move writeTrashFile and deleteFile into JGitTestUtilDariusz Luksza2012-01-252-10/+46
| | | | | | | | | Moves RepositoryTestCase.writeThashFile, RepositoryTestCase.deleteFile and dependencies into JGitTestUtil for further reuse. Required-by-EGit: If8dfa0251797aca56ddc825619500dc21885ba26 Change-Id: I6fc62c8e6626f907e544b5bbe5d64e864a2c323f Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
* Make sure all bytes are written to files on close, or get an error.Robin Rosenberg2012-01-151-5/+6
| | | | | | | | | | Java's BufferedOutputStream swallows any errors that occur when flushing the buffer in close(). This class overrides close to make sure an error during the final flush is reported back to the caller. Change-Id: I74a82b31505fadf8378069c5f6554f1033c28f9b Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Add methods for configuring platform emulationRobin Rosenberg2011-12-071-0/+30
| | | | | | | Specifically we support setting system properties for Windows, generic Unix and current test platform. Change-Id: Ib02be417c4915350dfec64fda3face1138552871
* Add locale to the properties manageable by SystemReaderRobin Rosenberg2011-10-201-0/+6
| | | | Change-Id: I5e9af40d38bb671cb9fcdb0fa3b4eb3af5f36f6c
* Add a method to SystemReader to get the time zoneRobin Rosenberg2011-10-201-1/+5
| | | | Change-Id: Ifd31f408ed2c5b7869694b715fea3219e74963ef
* Cleanup directories leftover by test.Adrian Goerler2011-07-071-5/+27
| | | | | | | Use the temporary file management from superclass. Change-Id: I3042951dc21860b4b85dd72a6bf41ee7cfe2aba4 Signed-off-by: Adrian Goerler <adrian.goerler@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Cleanup curly bracesAdrian Goerler2011-07-061-16/+9
| | | | | Change-Id: I2de6439a3ad951a99d89e4aee02006c745d16510 Signed-off-by: Adrian Goerler <adrian.goerler@sap.com>
* Make sure test repositories are closedChristian Halstrick2011-05-311-0/+11
| | | | | | | | | | | | | Some repositories created during tests are not added to the 'toClose' list in LocalDiskRepositoryTestCase. Therefore when the tests end we may have open FileHandles and on Windows this may cause the tests to fail because we can't delete those files. This is fixed by adding the possibility to explicitly add repositories to the list of repos which are closed automatically. Change-Id: I1261baeef4c7d9aaedd7c34b546393bfa005bbcc Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
* Add GitCloneTaskTestKetan Padegaonkar2011-05-191-0/+5
| | | | | Change-Id: Iec8cd032d8d659a896d909f9094f76b7d35147e6 Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Create all test data in trash folderMatthias Sohn2011-04-101-4/+18
| | | | | | | | | This ensures that all test data is separated from project sources and cleaned up after the test. Previously the cloned bare test repository was created in org.eclipse.jgit.test/ and not deleted after the test run. Change-Id: I55110442e365fc8fe610f1c372f72a71ee6e1412 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* [findbugs] Do not ignore exceptional return value of mkdirMatthias Sohn2011-01-281-1/+2
| | | | | | | | | java.io.File.mkdir() and mkdirs() report failure as an exceptional return value false. Fix the code which silently ignored this exceptional return value. Change-Id: I41244f4b9d66176e68e2c07e2329cf08492f8619 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Convert all JGit unit tests to JUnit 4Robin Rosenberg2010-12-313-28/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add support for getting the system wide configurationRobin Rosenberg2010-12-311-12/+31
| | | | | | | | | | | | | These settings are stored in <prefix>/etc/gitconfig. The C Git binary is installed in <prefix>/bin, so we look for the C Git executable to find this location, first by looking at the PATH environment variable and then by attemting to launch bash as a login shell to find out. Bug: 333216 Change-Id: I1bbee9fb123a81714a34a9cc242b92beacfbb4a8 Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* [findbugs] Do not ignore exceptional return valueMatthias Sohn2010-12-071-2/+3
| | | | | | | | | | java.io.File.delete() reports failure as an exceptional return value false. Fix the code which silently ignored this exceptional return value. Also remove some duplicate deletion helper methods. Change-Id: I80ed20ca1f07a2bc6e779957a4ad0c713789c5be Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Allow writing a NoteMap back to the repositoryShawn O. Pearce2010-11-121-2/+12
| | | | | | | | This is necessary to allow applications to wrap the note tree in a commit and update the note branch with the new state. Change-Id: Idbd7ead4a1b16ae2b64a30a4a01a29cfed548cdf Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Comment the use of System.gc in LocalDiskRepositoryTestCaseRobin Rosenberg2010-09-281-0/+5
| | | | | Change-Id: Ic5e9bda4275006ef3bf6ea6255ddf1c0eecc3770 Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* Shut up findbugs/protect the shutdownHook in LocalDiskRepositoryTestcaseRobin Rosenberg2010-09-281-10/+11
| | | | | | | | | Singleton references should be protected from multiple threads. As far as we know this cannot happen as JUnit is used today since we currently don't run tests in parallel, but now this code will not prevent anyone. Change-Id: I29109344d2e8025fa2a3ccaf7c2c16469544ce05 Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* Move commit and tag formatting to CommitBuilder, TagBuilderShawn O. Pearce2010-08-231-4/+3
| | | | | | | | | | | | These objects should be responsible for their own formatting, rather than delegating it to some obtuse type called ObjectInserter. While we are at it, simplify the way we insert these into a database. Passing in the type and calling format in application code turned out to be a huge mistake in terms of ease-of-use of the insert API. Change-Id: Id5bb95ee56aa2a002243e9b7853b84ec8df1d7bf Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Rename Commit, Tag to CommitBuilder, TagBuilderShawn O. Pearce2010-08-231-5/+8
| | | | | | | | | Since these types no longer support reading, calling them a Builder is a better description of what they do. They help the caller to build a commit or a tag object. Change-Id: I53cae5a800a66ea1721b0fe5e702599df31da05d Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Make Tag class only for writingShawn O. Pearce2010-08-201-3/+2
| | | | | | | | | | The Tag class now only supports the creation of an annotated tag object. To read an annotated tag, applictions should use RevTag. This permits us to have exactly one implementation, and RevTag's is faster and more bug-free. Change-Id: Ib573f7e15f36855112815269385c21dea532e2cf Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Make Commit class only for writingShawn O. Pearce2010-08-201-3/+3
| | | | | | | | | | The Commit class now only supports the creation of a commit object. To read a commit, applictions should use RevCommit. This permits us to have exactly one implementation, and RevCommit's is faster and more bug-free. Change-Id: Ib573f7e15f36855112815269385c21dea532e2cf Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Remove unnecessary ObjectId.copy() callsShawn O. Pearce2010-08-192-5/+1
| | | | | | | | | | | | | | | | | | | | When RevObject overrode equals() to provide only reference equality we used to need to convert a RevObject into an ObjectId by copy() just to use standard Java tools like JUnit assertEquals(), or to use contains() or get() on standard java.util collection types. Now that we have removed this override and made ObjectId's equals() final (preventing any of this mess in the future), some copy() calls are unnecessary. Anytime the value is being used as an input to a lookup routine, or to an equals, we can avoid the copy(). However we still want to use copy() anytime we are given an ObjectId that may exist long-term, where we don't want the high cost of the additional storage from a RevCommit extension. So we can't remove all uses of copy(), just some of them. Change-Id: Ief275dace435c0ddfa362ac8e5d93558bc7e9fc3 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Fix concurrent read / write issue in LockFile on WindowsJens Baumgart2010-07-273-3/+4
| | | | | | | | | | LockFile.commit fails if another thread concurrently reads the base file. The problem is fixed by retrying the rename operation if it fails. Change-Id: I6bb76ea7f2e6e90e3ddc45f9dd4d69bd1b6fa1eb Bug: 308506 Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
* Use ObjectReader in DirCacheBuilder.addTreeShawn O. Pearce2010-06-291-1/+2
| | | | | | | Rather than building a custom reader, have the caller supply us one. Change-Id: Ief2b5a6b1b75f05c8a6bc732a60d4d1041dd8254 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Use ObjectReader in RevWalk, TreeWalkShawn O. Pearce2010-06-281-1/+1
| | | | | | | | | | | | | We don't actually need a Repository object here, just an ObjectReader that can load content for us. So change the API to depend on that. However, this breaks the asCommit and asTag legacy translation methods on RevCommit and RevTag, so we still have to keep the Repository inside of RevWalk for those two types. Hopefully we can drop those in the future, and then drop the Repository off the RevWalk. Change-Id: Iba983e48b663790061c43ae9ffbb77dfe6f4818e Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Refactor Repository.openObject to be Repository.openShawn O. Pearce2010-06-281-2/+2
| | | | | | | | | | | We drop the "Object" suffix, because its pretty clear here that we want to open an object, given that we pass in AnyObjectId as the main parameter. We also fix the calling convention to throw a MissingObjectException or IncorrectObjectTypeException, so that callers don't have to do this error checking themselves. Change-Id: I72c43353cea8372278b032f5086d52082c1eee39 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Move PackWriter progress monitors onto the operationsShawn O. Pearce2010-06-281-3/+4
| | | | | | | | | Rather than taking the ProgressMonitor objects in our constructor and carrying them around as instance fields, take them as arguments to the actual time consuming operations we need to run. Change-Id: I2b230d07e277de029b1061c807e67de5428cc1c4 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Ensure ObjectReader used by PackWriter is releasedShawn O. Pearce2010-06-281-21/+26
| | | | | | | | | | | | | | The ObjectReader API demands that we release the reader when we are done with it. PackWriter contains a reader, which it uses for the entire packing session. Expose the release of the reader through a release method on the writer. This still doesn't address the RevWalk and TreeWalk users, who don't correctly release their reader. But its a small step in the right direction. Change-Id: I5cb0b5c1b432434a799fceb21b86479e09b84a0a Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Move PackWriter over to storage.pack.PackWriterShawn O. Pearce2010-06-261-1/+1
| | | | | | | | | Similar to what we did with the file code, move the pack writer into its own package so the related classes and their package private methods are hidden from the rest of the library. Change-Id: Ic1b5c7c8c8d266e90c910d8d68dfc8e93586854f Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Move FileRepository to storage.file.FileRepositoryShawn O. Pearce2010-06-263-10/+10
| | | | | | | | | | | | This move isolates all of the local file specific implementation code into a single package, where their package-private methods and support classes are properly hidden away from the rest of the core library. Because of the sheer number of files impacted, I have limited this change to only the renames and the updated imports. Change-Id: Icca4884e1a418f83f8b617d0c4c78b73d8a4bd17 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Rename Repository getWorkDir to getWorkTreeShawn O. Pearce2010-06-251-1/+1
| | | | | | | | | | | | | | This better matches with the name used in the environment (GIT_WORK_TREE), in the configuration file (core.worktree), and in our builder object. Since we are already breaking a good chunk of other code related to repository access, and this fairly easy to fix in an application's code base, I'm not going to offer the wrapper getWorkDir() method. Change-Id: Ib698ba4bbc213c48114f342378cecfe377e37bb7 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Start using ObjectInserter instead of ObjectWriterShawn O. Pearce2010-06-251-9/+45
| | | | | | | | | | | | Some newer style APIs are updated to use the newer ObjectInserter interface instead of the now deprecated ObjectWriter. In many of the unit tests we don't bother to release the inserter, these are typically using the file backend which doesn't need a release, but in the future should use an in-memory HashMap based store, which really wouldn't need it either. Change-Id: I91a15e1dc42da68e6715397814e30fbd87fa2e73 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Use FileRepository where we assume other file semanticsShawn O. Pearce2010-06-252-51/+59
| | | | | | | | | | | When the surrounding code is already heavily based upon the assumption that we have a FileRepository (e.g. because it created that type of repository) keep the type around and use it directly. This permits us to continue to do things like save the configuration file. Change-Id: Ib783f0f6a11acd6aa305c16d61ccc368b46beecc Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Make lib.Repository abstract and lib.FileRepository its implementationShawn O. Pearce2010-06-251-1/+2
| | | | | | | | | | | | | | | | | | | | To support other storage models other than just the local filesystem, we split the Repository class into a nearly abstract interface and then create a concrete subclass called FileRepository with the file based IO implementation. We are using an abstract class for Repository rather than the much more generic interface, as implementers will want to inherit a large array of utility functions, such as resolve(String). Having these in a base class makes it easy to inherit them. This isn't the final home for lib.FileRepository. Future changes will rename it into storage.file.FileRepository, but to do that we need to also move a number of other related class, which we aren't quite ready to do. Change-Id: I1bd54ea0500337799a8e792874c272eb14d555f7 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Repository can be configured with FSMarc Strapetz2010-06-041-1/+2
| | | | | | | | | | | | | On Windows, FS_Win32_Cygwin has been used if a Cygwin Git installation is present in the PATH. Assuming that the user works with the Cygwin Git installation may result in unnecessary overhead if he actually does not. Applications built on top of jgit may have more knowledge on the actually used Git client (Cygwin or not) and hence should be able to configure which FS to use accordingly. Change-Id: Ifc4278078b298781d55cf5421e9647a21fa5db24
* Fix unit tests using MockSystemReader with user configuationShawn O. Pearce2010-04-141-1/+7
| | | | | | | | | | | | | | Since cc905e7d4be "Make Repository.getConfig aware of changed config" its invalid to have a null result from FileBasedConfig.getFile(), as the path is used to stat the location on disk before returning the Config object from Repository.getConfig(). Mock out the isOutdated() method to return false all of the time in the mock test environment, so we don't crash with an NPE when this mock user configuration is being called. Change-Id: I0b4d9cbd346d5dc225ec12674da905c35457fa7c Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Reduce multi-level buffered streams in transport codeShawn O. Pearce2010-03-121-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Some transports actually provide stream buffering on their own, without needing to be wrapped up inside of a BufferedInputStream in order to smooth out system calls to read or write. A great example of this is the JSch SSH client, or the Apache MINA SSHD server. Both use custom buffering to packetize the streams into the encrypted SSH channel, and wrapping them up inside of a BufferedInputStream or BufferedOutputStream is relatively pointless. Our SideBandOutputStream implementation also provides some fairly large buffering, equal to one complete side-band packet on the main data channel. Wrapping that inside of a BufferedOutputStream just to smooth out small writes from PackWriter causes extra data copies, and provides no advantage. We can save some memory and some CPU cycles by letting PackWriter dump directly into the SideBandOutputStream's internal buffer array. Instead we push the buffering streams down to be as close to the network socket (or operating system pipe) as possible. This allows us to smooth out the smaller reads/writes from pkt-line messages during advertisement and negotation, but avoid copying altogether when the stream switches to larger writes over a side band channel. Change-Id: I2f6f16caee64783c77d3dd1b2a41b3cc0c64c159 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Introduce a named constant for the .git directory.Robin Rosenberg2010-01-151-1/+1
| | | | | | | | | | | Not all occurrences of ".git" are replaced by this constant, only those where it actually refers to the directory with that name, i.e not the ".git" directory suffix. Asserts and comment are also excluded from replacement. Change-Id: I65a9da89aedd53817f2ea3eaab4f9c2bed35d7ee Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* Add JUnit tests for HTTP transportShawn O. Pearce2010-01-122-13/+161
| | | | | | | | No Eclipse support for this project is provided, because the Jetty project does not publish a complete P2 repository. Change-Id: Ic5fe2e79bb216e36920fd4a70ec15dd6ccfd1468 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>