aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/util
Commit message (Collapse)AuthorAgeFilesLines
* Deprecate TemporaryBuffer.LocalFile without parent directoryShawn Pearce2014-11-251-12/+12
| | | | | | | | | | | | | Encourage callers to explicitly name a directory to hold any overflow data. Call sites have more information about what is going into the buffer and how it should be protected at the filesystem level than just throwing content to the system wide temporary directory. Callers that still really don't care (or need to care) can pass null for the File argument to have the system directory used. Change-Id: I89009bbee49d3850d42cd82c2c462e51043acda0
* Cache SimpleDateFormat in GitDateParser per localeMatthias Sohn2013-11-232-15/+30
| | | | | | | | | | Otherwise switching to another locale yields wrong results when parsing date strings in GitDateParser. Since the MockSystemReader explicitly uses english locale the tests need to specify the locale to be used when parsing date strings. Bug: 420772 Change-Id: I313ef6b1e9ef3bfb43d929ce34712ebd21f2cd9c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Merge changes ↵Shawn Pearce2013-11-054-15/+63
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | I85470d1d,I43711486,Ie6ade781,Ic9ab2b6e,Iebe50933,Id6fac253,Ia6becf30,I2af8b0ac * changes: Use absolute paths for file:// URIs in tests Use getPath() in FileResolverTest Extract protocol constants to a common class Move repeat() to utility class for tests Remove hardcoded target/trash from test cases Remove dependency on StatusCommandTest Remove dependency on DiffFormatterReflowTest Remove unnecessary import of BaseConnection in MessageWriter
| * Move repeat() to utility class for testsShawn Pearce2013-11-013-12/+59
| | | | | | | | | | | | | | | | Avoid depending on AutoCRLFOutputStreamTest from within another test such as AutoCRLFInputStreamTest. Breaking the dependency up allows the test classes to be built and executed in parallel. Change-Id: Ic9ab2b6ec74ac87ff4adda8a802ae343dd2a6235
| * Remove hardcoded target/trash from test casesShawn Pearce2013-11-011-3/+4
| | | | | | | | | | | | | | | | | | | | | | Buck does not create a target directory for the build output, this is Maven specific and the project unit tests should not rely on it. Instead follow the pattern used by org.eclipse.jgit.test which is to create a temporary directory in the system temporary folder, and configure the Maven surefire plugin to use the target directory. Change-Id: Iebe5093332343a90f51080614e083aac0d29c26d
* | Also use MockSystemReader in GitDateParserBadlyFormattedTestMatthias Sohn2013-11-051-0/+14
|/ | | | | | | | | | | | | All tests should use MockSystemReader to isolate them from the underlying platform specifics. GitDateParserBadlyFormattedTest wasn't using MockSystemReader which induced Bug 420772 as a side effect since GitDateParser caches SimpleDateFormat instances without regarding their locale. This will be fixed in another change Bug: 420772 Change-Id: I798e55d05730a71bb0326f80aea5488541d6c1f2 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Make sure SystemReader is reset after test is runRobin Stocker2013-10-223-0/+18
| | | | | | | | Otherwise the MockSystemReader from the test setup is active for other tests. Change-Id: I7caf693bd692d06936e29efd4dc4aabb48c1c39b Signed-off-by: Robin Stocker <robin@nibor.org>
* Recognize CRLF when parsing the short message of a commit or tagRobin Rosenberg2013-06-141-0/+12
| | | | | Bug: 400707 Change-Id: I9b09bb88528af465018fc0278f5441f7e6b75986
* Make JGit test work with both hamcrest 1.1 (juno) and 1.3 (kepler)Robin Rosenberg2013-06-091-3/+1
| | | | | | | The hamcrest library has moved things around. This problem applies only to the test, not plugin runtime. Change-Id: I5b97f356d8595dbdc9e91d157558e40561a6a30d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix multiple bugs in RawSubStringPattern used by MessageRevFilterRobin Stocker2013-05-281-0/+104
| | | | | | | | | | * Match at end of input was not handled correctly. * When more than one character matched but not all, the next character was not considered as a match start (e.g. pattern "abab" didn't match input "abaabab"). Bug: 409144 Change-Id: Ia44682c618bfbb927f5567c194227421d222a160 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Extend the FS class for Java7Robin Rosenberg2013-05-041-0/+15
| | | | | | | | | | | | | | | | | | | | | The most important difference is that in Java7 we have symbolic links and for most operations in the work tree we want to operate on the link itself rather than the link target, which the old File methods generally do. We also add support for the hidden attribute, which only makes sense on Windows and exists, just since there are claims that Files.exists is faster the File.exists. A new bundle is only activated when run with a Java7 execution environment. It is implemented as a fragment. Tycho currently has no way to conditionally include optional features based on the java version used to run the build, this means with this change the jgit packaging build always needs to be run using java 7. Change-Id: I3d6580d6fa7b22f60d7e54ab236898ed44954ffd Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Abort before delete in FileUtils.delete EMPTY_DIRECTORIES_ONLY|RECURSIVERobin Stocker2013-04-291-1/+116
| | | | | | | | | | | | Depending on the order in which items are traversed for RECURSIVE, an empty directory may come first before detecting that there is a file and aborting. This fixes it by traversing files first. Bug: 405558 Change-Id: I638b7da58e33ffeb0fee172b96f4c823943d29e9 Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Revert "Add tests for FileUtils.delete and EMPTY_DIREECTORIES_ONLY"Shawn Pearce2013-04-191-85/+0
| | | | | | | | | | | | | | This reverts commit 7aa54967a26cb027fe390ad1c624ebb30f9ac6d5. The unit test dependend upon the specific order of names that listFiles() returned members in. The order is completely undefined and may differ even on different versions of Linux based systems. A proper unit test for this code would have considered both cases, where the deletion function was able to remove an empty subdirectory, or fail to remove a subdirectory because a file was still present within. This is not such a test. Change-Id: Ib0a706fea01e4b1ed8c8e859247d247a1279b4bc
* Improve test coverage of AutoCRLF(In|Out)putStreamRobin Stocker2013-04-182-18/+33
| | | | | | Bug: 405672 Change-Id: I3894e98617fcee16dc2ac9853c203c62eb30c3ab Signed-off-by: Chris Aniszczyk <zx@twitter.com>
* Fix boundary conditions in AutoCRLFOutputStreamRobin Rosenberg2013-04-141-1/+25
| | | | | | | | | | This fixes some problems with inputs around the size of the internal buffer in AutoCRLFOutputStream (8000). Tests supplied by Robin Stocker. Bug: 405672 Change-Id: I6147897290392b3bfd4040e8006da39c302a3d49
* Extend FileUtils.rename to common git semanticsRobin Rosenberg2013-03-261-0/+69
| | | | | | | | | | | | | Unlike the OS or Java rename this method will (on *nix) try (on Windows) replace the target with the source provided the target does not exist, the target does exist and is a file, or if it is a directory which only contains directories. In the latter case the directory hierarchy will be deleted. If the initial rename fails and the target is an existing file the the target file will be deleted first and then the rename is retried. Change-Id: Iae75c49c85445ada7795246a02ce02f7c248d956 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
* Add tests for FileUtils.delete and EMPTY_DIREECTORIES_ONLYRobin Rosenberg2013-03-241-0/+85
| | | | Change-Id: I54a46c29df5eafc7739a6ef29e5dc80fa2f6d9ba
* Extend FileUtils.delete with option to delete empty directories onlyRobin Rosenberg2013-03-081-0/+46
| | | | | | | | | | The new option EMPTY_DIRECTORIES_ONLY will make delete() only delete empty directories. Any attempt to delete files will fail. Can be combined with RECURSIVE to wipe out entire tree structures and IGNORE_ERRORS to silently ignore any files or non-empty directories. Change-Id: Icaa9a30e5302ee5c0ba23daad11c7b93e26b7445 Signed-off-by: Robin Stocker <robin@nibor.org>
* Accept Change-Id even if footer contains not well-formed entriesStefan Lay2013-02-201-12/+41
| | | | | | | | | | | | | | Instead of only looking for a Change-Id in the last section if it consists only of well-formed "key: value" lines replace the last occurrence of a valid Change-Id line in the last section. Some tools require footer lines e.g. without a colon. Gerrit doesn't accept Change-Id lines in the footer if the Change-Id line doesn't start at the beginning of the line. Bug: 400818 Change-Id: Icce54872adc8c566994beea848448a2f7ca87085 Signed-off-by: Stefan Lay <stefan.lay@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Only replace the ChangeId in the footer, not in the bodyStefan Lay2013-01-191-4/+82
| | | | | | | | | | Additionally expose methods to find the first footer line and to find the position of the ChangeId footer in the commit message in order to enable reuse of these methods introduced for the fix. Change-Id: I87ecca009ca3bff1ca0de3c436ebd95736bf5a10 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* Declare essentially static methods as staticRobin Rosenberg2012-12-276-6/+7
| | | | Change-Id: I83ca25fb569c0dbc36eb374d5437fcf2b65a6f68
* Suppress resource warnings with Java 7Robin Rosenberg2012-10-253-0/+11
| | | | | | | | | | | For streams that should not be closed, i.e. don't own an underlying stream, and in-memory streams that do not need to be closed we just suppress the warning. This mostly apply to test cases. GC is enough. For streams with external resources (i.e. files) we add the necessary call to close(). Change-Id: I4d883ba2e7d07f199fe57ccb3459ece00441a570
* Introduce "never" as parseable dateRobin Rosenberg2012-09-181-0/+11
| | | | | | | | | | For configuration parameter like "gc.pruneexpire" we need to understand the value "never". Never is handled as a date so far into the future that it will never happen. The actual value currently used is the constant GitDateParser.NEVER. Change-Id: I7744eaee9bf5026da517151c212c88325c348d6c Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* Introduce ParseExceptions for GitDateParserChristian Halstrick2012-09-172-24/+100
| | | | | | | | | Instead of just returning null when something was not parseable we should throw a real ParseException. This allows us to distinguish between specifications which are unparseable and those which represent no date (e.g. "never") Change-Id: Ib3c1aa64b65ed0e0270791a365f2fa72ab78a3f4
* cleanup: use assertArrayEquals for assertion on arraysRobin Rosenberg2012-09-033-26/+26
| | | | Change-Id: I1df945011f8e5f03959b693d3564fe357e707f91
* cleanup: Prefer assertEquals over assertTrue(....equals(...))Robin Rosenberg2012-09-031-1/+1
| | | | | | That is the common style and yields better diagnostics on failure. Change-Id: I831a55615a812734af0912a5d6bbfd1edc75308e
* Create an input stream that transforms LF to CRLFRobin Rosenberg2012-09-011-0/+122
| | | | | | | | | | | | The transformation is the same as AutoCRLFOutputStream does, but the direction is reversed. The tests are reused, but the implementation derives somewhat from the EolCanonicalizingInputStream. This stream will be used to compare blobs with LF line endings with worktree data that has CRLF line endings. Bug: 387501 Change-Id: I80d96e453e7f780dd464a89778de124cf35384e1 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Implement a parser for datesChristian Halstrick2012-08-281-0/+228
| | | | | | | | | | | | | | | | | | | | | | | | | | | In order to parse user specified strings containing date and time info a thread-safe parser is implemented. This is needed for example to interpret configuration parameters (e.g. gc.pruneexpire where need to parse strings like "2 weeks ago"). The parser is thread-safe by caching SimpleDateFormat instances in a ThreadLocal cache. Native git has a parser called approxidate which is able to interpret a huge number of formats ("1 year ago", "tea time", ...). Ideally JGit should be able to parse the same strings as native git but for now this parser understands the following subset: "now" "yesterday" "(x) years|months|weeks|days|hours|minutes|seconds ago" "yyyy-MM-dd HH:mm:ss Z" (ISO) "EEE, dd MMM yyyy HH:mm:ss Z" (RFC) "yyyy-MM-dd" "yyyy.MM.dd" "MM/dd/yyyy" "dd.MM.yyyy" "EEE MMM dd HH:mm:ss yyyy Z" (DEFAULT) "EEE MMM dd HH:mm:ss yyyy" (LOCAL) Change-Id: Iccb66dadb60da13104e73140e53d5e2de068369c
* Fix UnionInputStream.read to be more Java-likeIan Wetherbee2012-06-141-0/+23
| | | | | | | | | Relax the read() method to not block until exactly "len" bytes have been read. Instead, return when one or more bytes have been read, up to "len", so UnionInputStream more closely resembles InputStream's read() method. Change-Id: I3f632be8eb85a4a0baf27c9f067c8d817162de2b
* Allow to write tests with CLI syntaxTomasz Zarna2012-04-181-0/+102
| | | | | | | CQ: 6385 Bug: 365444 Change-Id: I2d5164cd92429673fe3c37e9f5f9bc565192cc12 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Revert "Allow to write tests with CLI syntax"Matthias Sohn2012-03-231-102/+0
| | | | | | | | | This reverts commit bf845c126d53f07de103e03b68ddb7f24014cee5 since this change needs to go through a formal IP review and Chris missed to file a CQ for that. Change-Id: I303515d78116f0591a2911dbfb9f857738f086a9 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Allow to write tests with CLI syntaxTomasz Zarna2012-03-221-0/+102
| | | | | Bug: 365444 Change-Id: I86f382913bc47665c5b9a2827b878e7dbedce7b1 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* EolCanonicalizingInputStream: binary detection should be optionalMarc Strapetz2012-02-211-8/+19
| | | | | | | | | EolCanonicalizingInputStream may also be used in combination with .gitattributes. If .gitattributes states that a file is of type text, line endings have to be canonicalized even if the actual file content seems to be binary. Change-Id: Ie4ccdfc5cb91fbd55e06f51146cf5c7c84b8e18b
* Support more of AutoCRLFRobin Rosenberg2012-01-102-0/+129
| | | | | | | | | | | | | | | | This patch introduces CRLF handling to the DirCacheCheckout and WorkingTreeIterator supporting the AutoCRLF for add, checkout reset and status and hopefully some other places that depende on the underlying logic of the affected API's. The patch includes test cases for the Status command provided by Tomasz Zarna for bug 353867. The core.eol and core.safecrlf options are not yet supported. Bug: 301775 Bug: 353867 Change-Id: I2280a2dc0698829475de6a662a6c6e80b1df7663
* Cosmetic adjustment of relative date format, do not display "0 months"Robin Rosenberg2011-10-261-2/+2
| | | | | | | Though it may seem less precise, "0 months" looks bad and the reference Git implementation also does not display "0 months" Change-Id: I488e9c97656f9941788ae88d7c5c1562ab6c26f0
* Define a utility class for handling Git date formatsRobin Rosenberg2011-10-231-0/+126
| | | | | | | | | Besides the formats known by git-log(1) we also add "locale" and "localelocal" that formats dates according to the user's locale. "locale" does not translate into local timezone, while localelocal does. Change-Id: I1c088dcec992c107e43f6c17be4ac9ed6eb428bf
* Use the SystemReader to get system timeRobin Rosenberg2011-10-201-1/+9
| | | | Change-Id: Ib79c0cc964bfe799b204419e552b9aa6243966ce
* Fix smart HTTP client stream alignment errorsShawn O. Pearce2011-09-141-9/+19
| | | | | | | | | | | | | | | | | | | The client's use of UnionInputStream was broken when combined with a 8192 byte buffer used by PackParser. A smart HTTP client connection always pushes in the execute stateless RPC input stream after the data stream has ended from the remote peer. At the end of the pack, PackParser asked to fill a 8192 byte buffer, but if only e.g. 1000 bytes remained UnionInputStream went to the next stream and asked it for input, which triggered a new RPC, and failed because there was nothing pending in the request buffer. Change UnionInputStream to only return what it consumed from a single InputStream without invoking the next InputStream, just in case that second InputStream happens to be one of these magical ones that generates an RPC invocation. Change-Id: I0e51a8e6fea1647e4d2e08ac9cfc69c2945ce4cb Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* TemporaryBuffer: Fix reading from in-memory InputStreamShawn O. Pearce2011-06-241-0/+15
| | | | | | | | I had the conditions wrong here, causing the in-memory InputStream to always appear to be at EOF. Change-Id: I6811d6187a34eaf1fd6c5002550d631decdfc391 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Formatter for relative datesMatthias Sohn2011-05-091-0/+126
| | | | | Change-Id: I78b307177c68c578e10101a0ee7b6306880a08f7 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Hande latin-1 encodingLeonard Broman2011-04-111-0/+82
| | | | | | Bug: 342259 Change-Id: Ie285b8819b5ea6f9892ebafc4ebbd9c6d091d1fe Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* BlockList: Micro-optimize appending from another BlockListShawn O. Pearce2011-03-181-0/+18
| | | | | | | | | Simple variant of addAll() that knows how to copy large segments quickly using System.arraycopy() rather than looping through with an Iterator object. Change-Id: Icb50a8f87fe9180ea28b6920f473bb9e70c300f1 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* PackWriter: Reduce GC during enumerationShawn O. Pearce2011-03-071-0/+336
| | | | | | | | | | | | | | | | | | | | | Instead of resizing an ArrayList until all objects have been added, append objects into a specialized List type that uses small arrays of 1024 entries for each 1024 objects added. For a large repository like linux-2.6, PackWriter will now allocate 1,758 smaller arrays to hold the object list, without creating any garbage from the intermediate states due to list expansion. 1024 was chosen as the block size (and initial directory size) as this is a reasonable balance for the PackWriter code. Each block uses approximately 4096 bytes in a 32 bit JVM, as does the default top level block directory. The top level directory doesn't expand until 1 million items have been added to the list, which for linux-2.6 won't yet occur as the lists are per-object-type and are thus bounded to about 1/3 of 1.8 million. Change-Id: If9e4092eb502394c5d3d044b58cf49952772f6d6 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* [findbugs] Do not ignore exceptional return value of mkdirMatthias Sohn2011-01-281-6/+6
| | | | | | | | | 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>
* File utility for creating a new empty fileMatthias Sohn2011-01-141-0/+15
| | | | | | | | | | The java.io.File.createNewFile() method for creating new empty files reports failure by returning false. To ease proper checking of return values provide a utility method wrapping createNewFile() throwing IOException on failure. Change-Id: I42a3dc9d8ff70af62e84de396e6a740050afa896 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Convert all JGit unit tests to JUnit 4Robin Rosenberg2010-12-3123-164/+369
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* File utilities for creating directoriesMatthias Sohn2010-12-131-4/+77
| | | | | | | | | | | | | | The java.io.File methods for creating directories report failure by returning false. To ease proper checking of return values provide utility methods wrapping mkdir() and mkdirs() which throw IOException on failure. Also fix the tests to store test data under a trash folder and cleanup after test. Change-Id: I09c7f9909caf7e25feabda9d31e21ce154e7fcd5 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Add option to skip deletion of non-existing filesMatthias Sohn2010-12-101-0/+95
| | | | | | | For convenience provide an option to skip deletion of non-existing files. Also add some tests for deletion methods in FileUtils. Change-Id: I33e355cfcdc19367d50208150ee49a4a06394890 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Add simple unit tests for Base64Shawn O. Pearce2010-11-121-0/+96
| | | | | Change-Id: I22ef1eb63ae8ddb9884526099013979856ab7bd9 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Fix QuotedString.GIT_PATH escaping rulesShawn O. Pearce2010-09-031-1/+6
| | | | | | | | | | | | | | We shouldn't escape non-special ASCII characters such as '@' or '~'. These are valid in a path name on POSIX systems, and may appear as part of a path in a GNU or Git style patch script. Escaping them into octal just obfuscates the user's intent, with no gain. When parsing an escaped octal sequence, we must parse no more than 3 digits. That is, "\1002" is actually "@2", not the Unicode character \u0202. Change-Id: I3a849a0d318e69b654f03fd559f5d7f99dd63e5c Signed-off-by: Shawn O. Pearce <spearce@spearce.org>