11package org .scm4j .vcs .svn ;
22
3+ import static org .junit .Assert .assertEquals ;
4+ import static org .junit .Assert .assertNotNull ;
5+ import static org .junit .Assert .assertNull ;
6+ import static org .junit .Assert .assertTrue ;
7+ import static org .junit .Assert .fail ;
8+ import static org .mockito .Matchers .any ;
9+ import static org .mockito .Matchers .anyBoolean ;
10+ import static org .mockito .Matchers .anyLong ;
11+ import static org .mockito .Matchers .anyString ;
12+ import static org .mockito .Matchers .isNull ;
13+ import static org .mockito .Mockito .doCallRealMethod ;
14+ import static org .mockito .Mockito .doReturn ;
15+ import static org .mockito .Mockito .doThrow ;
16+ import static org .mockito .Mockito .mock ;
17+ import static org .mockito .Mockito .reset ;
18+ import static org .mockito .Mockito .spy ;
19+ import static org .mockito .Mockito .verify ;
20+
21+ import java .io .File ;
22+ import java .io .IOException ;
23+ import java .io .OutputStream ;
24+ import java .lang .reflect .Field ;
25+ import java .lang .reflect .InvocationTargetException ;
26+ import java .lang .reflect .Method ;
27+ import java .lang .reflect .Modifier ;
28+ import java .util .Arrays ;
29+ import java .util .Collection ;
30+ import java .util .List ;
31+
332import org .junit .After ;
4- import org .junit .Ignore ;
533import org .junit .Test ;
634import org .mockito .Matchers ;
735import org .mockito .exceptions .verification .WantedButNotInvoked ;
1139import org .scm4j .vcs .api .abstracttest .VCSAbstractTest ;
1240import org .scm4j .vcs .api .exceptions .EVCSException ;
1341import org .scm4j .vcs .api .workingcopy .IVCSRepositoryWorkspace ;
14- import org .tmatesoft .svn .core .*;
42+ import org .tmatesoft .svn .core .ISVNLogEntryHandler ;
43+ import org .tmatesoft .svn .core .SVNDepth ;
44+ import org .tmatesoft .svn .core .SVNDirEntry ;
45+ import org .tmatesoft .svn .core .SVNErrorCode ;
46+ import org .tmatesoft .svn .core .SVNErrorMessage ;
47+ import org .tmatesoft .svn .core .SVNException ;
48+ import org .tmatesoft .svn .core .SVNNodeKind ;
49+ import org .tmatesoft .svn .core .SVNProperties ;
50+ import org .tmatesoft .svn .core .SVNURL ;
1551import org .tmatesoft .svn .core .auth .ISVNProxyManager ;
1652import org .tmatesoft .svn .core .auth .SVNAuthentication ;
1753import org .tmatesoft .svn .core .auth .SVNPasswordAuthentication ;
1854import org .tmatesoft .svn .core .internal .wc .DefaultSVNOptions ;
1955import org .tmatesoft .svn .core .io .SVNRepository ;
20- import org .tmatesoft .svn .core .wc .*;
21-
22- import java .io .File ;
23- import java .io .IOException ;
24- import java .io .OutputStream ;
25- import java .lang .reflect .Field ;
26- import java .lang .reflect .InvocationTargetException ;
27- import java .lang .reflect .Method ;
28- import java .lang .reflect .Modifier ;
29- import java .util .Arrays ;
30- import java .util .Collection ;
31- import java .util .List ;
32-
33- import static org .junit .Assert .*;
34- import static org .mockito .Matchers .any ;
35- import static org .mockito .Matchers .anyBoolean ;
36- import static org .mockito .Matchers .anyLong ;
37- import static org .mockito .Matchers .anyString ;
38- import static org .mockito .Matchers .isNull ;
39- import static org .mockito .Mockito .*;
56+ import org .tmatesoft .svn .core .wc .SVNClientManager ;
57+ import org .tmatesoft .svn .core .wc .SVNCommitClient ;
58+ import org .tmatesoft .svn .core .wc .SVNStatusClient ;
59+ import org .tmatesoft .svn .core .wc .SVNStatusType ;
60+ import org .tmatesoft .svn .core .wc .SVNWCClient ;
4061
4162public class SVNVCSTest extends VCSAbstractTest {
4263
@@ -350,14 +371,21 @@ public void testGetCommitsRangeExceptions() throws Exception {
350371 public void testGetHeadCommitExceptions () throws Exception {
351372 SVNRepository mockedRepo = spy (svn .getSVNRepository ());
352373 svn .setSVNRepository (mockedRepo );
353- doThrow (testSVNException ).when (mockedRepo ).log (any (String [].class ), anyLong (), anyLong (), anyBoolean (), anyBoolean (),
354- any (Integer .class ), any (ISVNLogEntryHandler .class ));
374+ doThrow (testSVNException ).when (svn ).getDirHeadLogEntry (anyString ());
355375 try {
356376 vcs .getHeadCommit ("" );
357377 fail ();
358378 } catch (EVCSException e ) {
359379 checkEVCSException (e );
360380 }
381+
382+ doThrow (testCommonException ).when (svn ).getDirHeadLogEntry (anyString ());
383+ try {
384+ vcs .getHeadCommit ("" );
385+ fail ();
386+ } catch (RuntimeException e ) {
387+ checkCommonException (e );
388+ }
361389 }
362390
363391 @ Test
@@ -373,30 +401,25 @@ public void testFileExistsExceptions() throws Exception {
373401 }
374402 }
375403
404+ @ SuppressWarnings ("unchecked" )
376405 @ Test
377406 public void testListEntriesSorting () throws Exception {
378407 SVNRepository mockedRepo = spy (svn .getSVNRepository ());
379408 svn .setSVNRepository (mockedRepo );
380409 SVNDirEntry entry1 = new SVNDirEntry (null , null , "entry1" , SVNNodeKind .DIR , 0 , false , 1 , null , null );
381410 SVNDirEntry entry2 = new SVNDirEntry (null , null , "entry2" , SVNNodeKind .DIR , 0 , false , 2 , null , null );
382411
383- doReturn (Arrays .asList (entry1 , entry2 )).when (mockedRepo ).getDir (anyString (), anyLong (), any (SVNProperties . class ),
384- Matchers .< Collection <SVNDirEntry >> any ());
412+ doReturn (Arrays .asList (entry1 , entry2 )).when (mockedRepo ).getDir (anyString (), anyLong (), (SVNProperties ) isNull ( ),
413+ ( Collection <SVNDirEntry >) isNull ());
385414
386415 List <String > entries = svn .listEntries ("" );
387- assertEquals (entries . get ( 0 ), entry1 . getName ( ));
388- assertEquals (entries . get ( 1 ), entry2 . getName ( ));
416+ assertEquals (entry1 . getName ( ), entries . get ( 0 ));
417+ assertEquals (entry2 . getName ( ), entries . get ( 1 ));
389418 doReturn (Arrays .asList (entry1 , entry1 )).when (mockedRepo ).getDir (anyString (), anyLong (), any (SVNProperties .class ),
390419 Matchers .<Collection <SVNDirEntry >>any ());
391420 entries = svn .listEntries ("" );
392- assertEquals (entries .get (0 ), entry1 .getName ());
393- assertEquals (entries .get (1 ), entry1 .getName ());
394- }
395-
396- @ Test
397- public void testGetHeadCommitNull () throws Exception {
398- doReturn (null ).when (svn ).revToSVNEntry (anyString (), any (Long .class ));
399- assertNull (vcs .getHeadCommit ("" ));
421+ assertEquals (entry1 .getName (), entries .get (0 ));
422+ assertEquals (entry1 .getName (), entries .get (1 ));
400423 }
401424
402425 @ Test
@@ -414,12 +437,10 @@ public void testSVNVCSUtilsCreation() {
414437 }
415438
416439 @ Test
417- @ Ignore
418440 public void testListEntriesNone () throws Exception {
419441 SVNRepository mockedRepo = spy (svn .getSVNRepository ());
420442 svn .setSVNRepository (mockedRepo );
421443 doReturn (SVNNodeKind .NONE ).when (mockedRepo ).checkPath (anyString (), anyLong ());
422- assertTrue (svn .listEntries ("" ).isEmpty ());
423444 assertTrue (svn .listEntries (null ).isEmpty ()); // expecting no NPE
424445 }
425446
@@ -431,25 +452,43 @@ public void testGetTagsOnRevisionNoTagsDir() throws SVNException {
431452 assertTrue (vcs .getTagsOnRevision ("0" ).isEmpty ());
432453 }
433454
455+
434456 @ Test
435457 public void testGetTagsOnRevisionExceptions () throws Exception {
436- SVNRepository mockedRepo = spy (svn .getSVNRepository ());
437- svn .setSVNRepository (mockedRepo );
438458 vcs .createTag (null , TAG_NAME_1 , TAG_MESSAGE_1 , null );
439- doThrow (testCommonException ).when (svn ).revToSVNEntry (anyString (), anyLong ());
459+ doThrow (testSVNException ).when (svn ).getTags (anyString ());
440460 try {
441461 vcs .getTagsOnRevision ("" );
442462 fail ();
443- } catch (RuntimeException e ) {
444- checkCommonException (e );
463+ } catch (EVCSException e ) {
464+ checkEVCSException (e );
445465 }
446466
447- doThrow (testSVNException ).when (mockedRepo ). checkPath (anyString (), anyLong ());
467+ doThrow (testCommonException ).when (svn ). getTags (anyString ());
448468 try {
449469 vcs .getTagsOnRevision ("" );
450470 fail ();
471+ } catch (RuntimeException e ) {
472+ checkCommonException (e );
473+ }
474+ }
475+
476+ @ Test
477+ public void testGetTagsExceptions () throws Exception {
478+ doThrow (testSVNException ).when (svn ).getTags ((String ) isNull ());
479+ try {
480+ vcs .getTags ();
481+ fail ();
451482 } catch (EVCSException e ) {
452483 checkEVCSException (e );
453484 }
485+
486+ doThrow (testCommonException ).when (svn ).getTags ((String ) isNull ());
487+ try {
488+ vcs .getTags ();
489+ fail ();
490+ } catch (RuntimeException e ) {
491+ checkCommonException (e );
492+ }
454493 }
455494}
0 commit comments