Skip to content

Commit 7252712

Browse files
committed
tests fixed
moved back to normal-hosted svnkit 1.8.14 from attlasian-hosted
1 parent 3f404e8 commit 7252712

File tree

3 files changed

+41
-24
lines changed

3 files changed

+41
-24
lines changed

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jacocoTestReport {
2222
}
2323

2424
repositories {
25-
maven { url "https://maven.atlassian.com/3rdparty/" }
2625
maven { url "https://jitpack.io" }
2726
mavenCentral()
2827
}
@@ -31,7 +30,7 @@ defaultTasks 'build';
3130

3231
dependencies {
3332
compile 'com.github.scm4j:scm4j-vcs-api:master-SNAPSHOT'
34-
compile 'org.tmatesoft.svnkit:svnkit:1.9.0-r10609-atlassian-hosted'
33+
compile 'org.tmatesoft.svnkit:svnkit:1.8.14'
3534
compile 'org.apache.commons:commons-lang3:3.5'
3635

3736
testCompile 'junit:junit:4.12'

src/main/java/org/scm4j/vcs/svn/SVNVCS.java

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.ArrayList;
88
import java.util.Collection;
99
import java.util.Collections;
10+
import java.util.Comparator;
1011
import java.util.HashSet;
1112
import java.util.Iterator;
1213
import java.util.List;
@@ -462,8 +463,9 @@ public List<VCSDiffEntry> getBranchesDiff(final String srcBranchName, final Stri
462463
@Override
463464
public Set<String> getBranches() {
464465
try {
465-
Set<String> res = new HashSet<>();
466-
listEntries(res, SVNVCS.BRANCHES_PATH);
466+
List<String> entries = new ArrayList<>();
467+
listEntries(entries, SVNVCS.BRANCHES_PATH);
468+
Set<String> res = new HashSet<>(entries);
467469
addTrunkIfExists(res);
468470
return res;
469471
} catch (SVNException e) {
@@ -484,12 +486,28 @@ protected void addTrunkIfExists(Set<String> res) {
484486

485487
}
486488

487-
public void listEntries(Set<String> entries, String path) throws Exception {
489+
490+
public void listEntries(List<String> entries, String path) throws Exception {
488491
@SuppressWarnings("unchecked")
489492
Collection<SVNDirEntry> subEntries = repository.getDir(path, -1, null, (Collection<SVNDirEntry>) null);
490-
for (SVNDirEntry entry : subEntries) {
493+
List<SVNDirEntry> list = new ArrayList<>(subEntries);
494+
Collections.sort(list, new Comparator<SVNDirEntry>() {
495+
496+
@Override
497+
public int compare(SVNDirEntry o1, SVNDirEntry o2) {
498+
if (o1.getRevision() < o2.getRevision()) {
499+
return -11;
500+
}
501+
if (o1.getRevision() > o2.getRevision()) {
502+
return 1;
503+
}
504+
return 0;
505+
}
506+
507+
});
508+
for (SVNDirEntry entry : list) {
491509
if (entry.getKind() == SVNNodeKind.DIR) {
492-
entries.add(((path.equals(SVNVCS.BRANCHES_PATH) ? "" : path + "/") + entry.getName())
510+
entries.add(((path.equals(SVNVCS.BRANCHES_PATH) ? "" : path) + entry.getName())
493511
.replace(SVNVCS.BRANCHES_PATH, ""));
494512
}
495513
}
@@ -500,8 +518,8 @@ public List<String> getCommitMessages(String branchName, Integer limit) {
500518
final List<String> res = new ArrayList<>();
501519
try {
502520
repository.log(new String[] { getBranchName(branchName) },
503-
-1 /* start from head descending */,
504-
0, true, true, limit, new ISVNLogEntryHandler() {
521+
-1L /* start from head descending */,
522+
0L, true, true, limit, new ISVNLogEntryHandler() {
505523
@Override
506524
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
507525
res.add(logEntry.getMessage());
@@ -658,9 +676,9 @@ public VCSTag createTag(String branchName, String tagName, String tagMessage) th
658676
}
659677

660678
private SVNLogEntry revToSVNEntry(String branchName, Long rev) throws Exception {
679+
SVNDirEntry info = repository.info(branchName, rev);
661680
@SuppressWarnings("unchecked")
662-
663-
Collection<SVNLogEntry> entries = repository.log(new String[] {branchName}, null, 0, rev, true, true);
681+
Collection<SVNLogEntry> entries = repository.log(new String[] {branchName}, null, info.getRevision(), rev, true, true);
664682
if (entries != null) {
665683
return entries.iterator().next();
666684
}
@@ -669,7 +687,7 @@ private SVNLogEntry revToSVNEntry(String branchName, Long rev) throws Exception
669687

670688
@Override
671689
public List<VCSTag> getTags() {
672-
Set<String> entries = new HashSet<>();
690+
List<String> entries = new ArrayList<>();
673691
try {
674692
listEntries(entries, TAGS_PATH);
675693
List<VCSTag> res = new ArrayList<>();
@@ -697,7 +715,7 @@ public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
697715

698716
SVNDirEntry copyFromEntry = repository.info("", handler.copyFromRevision);
699717

700-
res.add(new VCSTag(Long.toString(entry.getRevision()), entry.getMessage(), entry.getAuthor(), new VCSCommit(Long.toString(copyFromEntry.getRevision()),
718+
res.add(new VCSTag(entryStr.replace(TAGS_PATH, ""), entry.getMessage(), entry.getAuthor(), new VCSCommit(Long.toString(copyFromEntry.getRevision()),
701719
copyFromEntry.getCommitMessage(), copyFromEntry.getAuthor())));
702720
}
703721
return res;

src/test/java/org/scm4j/vcs/svn/SVNVCSTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import static org.junit.Assert.fail;
66
import static org.mockito.Matchers.any;
77
import static org.mockito.Matchers.anyBoolean;
8-
import static org.mockito.Matchers.anyInt;
98
import static org.mockito.Matchers.anyLong;
109
import static org.mockito.Matchers.anyString;
1110
import static org.mockito.Matchers.isNull;
@@ -25,7 +24,7 @@
2524
import java.lang.reflect.Method;
2625
import java.lang.reflect.Modifier;
2726
import java.util.Collection;
28-
import java.util.Set;
27+
import java.util.List;
2928

3029
import org.junit.After;
3130
import org.junit.Test;
@@ -311,14 +310,14 @@ public void setFileContentWCCorruption() throws Exception {
311310

312311
@Test
313312
public void testGetBranchesExceptions() throws Exception {
314-
doThrow(testSVNException).when(svn).listEntries(Matchers.<Set<String>>any(), anyString());
313+
doThrow(testSVNException).when(svn).listEntries(Matchers.<List<String>>any(), anyString());
315314
try {
316315
vcs.getBranches();
317316
fail();
318317
} catch (EVCSException e) {
319318
checkEVCSException(e);
320319
}
321-
doThrow(testCommonException).when(svn).listEntries(Matchers.<Set<String>>any(), anyString());
320+
doThrow(testCommonException).when(svn).listEntries(Matchers.<List<String>>any(), anyString());
322321
try {
323322
vcs.getBranches();
324323
fail();
@@ -345,7 +344,7 @@ public void testGetCommitMessagesExceptions() throws Exception {
345344
SVNRepository mockedRepo = spy(svn.getSVNRepository());
346345
svn.setSVNRepository(mockedRepo);
347346
doThrow(testSVNException).when(mockedRepo).log(any(String[].class), anyLong(), anyLong(), anyBoolean(), anyBoolean(),
348-
anyInt(), any(ISVNLogEntryHandler.class));
347+
any(Integer.class), any(ISVNLogEntryHandler.class));
349348
try {
350349
vcs.getCommitMessages(null, 0);
351350
fail();
@@ -368,7 +367,7 @@ private void checkCommonException(RuntimeException e) {
368367
public void testRemoveFileExceptions() throws Exception {
369368
doThrow(testCommonException).when(svn).getBranchUrl(anyString());
370369
try {
371-
vcs.removeFile(null, "", "");
370+
vcs.removeFile("", "", "");
372371
fail();
373372
} catch (RuntimeException e) {
374373
checkCommonException(e);
@@ -380,10 +379,10 @@ public void testGetCommitsRangeExceptions() throws Exception {
380379
SVNRepository mockedRepo = spy(svn.getSVNRepository());
381380
svn.setSVNRepository(mockedRepo);
382381
doThrow(testSVNException).when(mockedRepo).log(any(String[].class), anyLong(), anyLong(), anyBoolean(), anyBoolean(),
383-
anyInt(), any(ISVNLogEntryHandler.class));
382+
any(Integer.class), any(ISVNLogEntryHandler.class));
384383
doThrow(testCommonException).when(svn).getBranchFirstCommit(anyString());
385384
try {
386-
vcs.getCommitsRange(null, null, null);
385+
vcs.getCommitsRange("", null, null);
387386
fail();
388387
} catch (RuntimeException e) {
389388
checkCommonException(e);
@@ -401,9 +400,10 @@ public void testGetCommitsRangeExceptions() throws Exception {
401400
public void testGetHeadCommitExceptions() throws Exception {
402401
SVNRepository mockedRepo = spy(svn.getSVNRepository());
403402
svn.setSVNRepository(mockedRepo);
404-
doThrow(testSVNException).when(mockedRepo).info(anyString(), anyLong());
403+
doThrow(testSVNException).when(mockedRepo).log(any(String[].class), anyLong(), anyLong(), anyBoolean(), anyBoolean(),
404+
any(Integer.class), any(ISVNLogEntryHandler.class));
405405
try {
406-
vcs.getHeadCommit(null);
406+
vcs.getHeadCommit("");
407407
fail();
408408
} catch (EVCSException e) {
409409
checkEVCSException(e);
@@ -416,7 +416,7 @@ public void testFileExistsExceptions() throws Exception {
416416
svn.setSVNRepository(mockedRepo);
417417
doThrow(testSVNException).when(mockedRepo).checkPath(anyString(), anyLong());
418418
try {
419-
vcs.getHeadCommit(null);
419+
vcs.fileExists("", "");
420420
fail();
421421
} catch (EVCSException e) {
422422
checkEVCSException(e);

0 commit comments

Comments
 (0)