1818
1919package pl .project13 .maven .git ;
2020
21- import static org .junit .Assert .assertEquals ;
21+ import static org .junit .jupiter . api . Assertions .assertEquals ;
2222
2323import java .io .File ;
24+ import java .nio .file .Path ;
2425import org .eclipse .jgit .api .Git ;
2526import org .eclipse .jgit .lib .ConfigConstants ;
2627import org .eclipse .jgit .lib .StoredConfig ;
27- import org .junit .After ;
28- import org .junit .Before ;
29- import org .junit .Rule ;
30- import org .junit .Test ;
31- import org .junit .rules .TemporaryFolder ;
28+ import org .junit .jupiter .api .AfterEach ;
29+ import org .junit .jupiter .api .BeforeEach ;
30+ import org .junit .jupiter .api .Test ;
31+ import org .junit .jupiter .api .io .TempDir ;
3232import pl .project13 .core .AheadBehind ;
3333import pl .project13 .core .GitProvider ;
3434
3737 */
3838public abstract class AheadBehindTest <T extends GitProvider > {
3939
40- @ Rule public TemporaryFolder remoteRepository = new TemporaryFolder ();
40+ @ TempDir
41+ public Path remoteRepository ;
4142
42- @ Rule public TemporaryFolder localRepository = new TemporaryFolder ();
43+ @ TempDir
44+ public Path localRepository ;
4345
44- @ Rule public TemporaryFolder secondLocalRepository = new TemporaryFolder ();
46+ @ TempDir
47+ public Path secondLocalRepository ;
4548
4649 protected Git localRepositoryGit ;
4750
4851 protected Git secondLocalRepositoryGit ;
4952
5053 protected T gitProvider ;
5154
52- @ Before
55+ @ BeforeEach
5356 public void setup () throws Exception {
5457
5558 createRemoteRepository ();
@@ -65,7 +68,7 @@ public void setup() throws Exception {
6568 extraSetup ();
6669 }
6770
68- @ After
71+ @ AfterEach
6972 public void tearDown () throws Exception {
7073 if (localRepositoryGit != null ) {
7174 localRepositoryGit .close ();
@@ -122,30 +125,30 @@ public void shouldBe1AheadAnd1Behind() throws Exception {
122125 }
123126
124127 protected void createLocalCommit () throws Exception {
125- File newFile = localRepository .newFile ();
128+ File newFile = localRepository .toFile ();
126129 localRepositoryGit .add ().addFilepattern (newFile .getName ()).call ();
127130 localRepositoryGit .commit ().setMessage ("ahead" ).call ();
128131 }
129132
130133 protected void createCommitInSecondRepoAndPush () throws Exception {
131134 secondLocalRepositoryGit .pull ().call ();
132135
133- File newFile = secondLocalRepository .newFile ();
136+ File newFile = secondLocalRepository .toFile ();
134137 secondLocalRepositoryGit .add ().addFilepattern (newFile .getName ()).call ();
135138 secondLocalRepositoryGit .commit ().setMessage ("behind" ).call ();
136139
137140 secondLocalRepositoryGit .push ().call ();
138141 }
139142
140143 protected void createRemoteRepository () throws Exception {
141- Git .init ().setBare (true ).setDirectory (remoteRepository .getRoot ()).call ();
144+ Git .init ().setBare (true ).setDirectory (remoteRepository .toFile ()).call ();
142145 }
143146
144147 protected void setupLocalRepository () throws Exception {
145148 localRepositoryGit =
146149 Git .cloneRepository ()
147- .setURI (remoteRepository .getRoot ().toURI ().toString ())
148- .setDirectory (localRepository .getRoot ())
150+ .setURI (remoteRepository .toFile ().toURI ().toString ())
151+ .setDirectory (localRepository .toFile ())
149152 .setBranch ("master" )
150153 .call ();
151154
@@ -158,14 +161,14 @@ protected void setupLocalRepository() throws Exception {
158161 protected void setupSecondLocalRepository () throws Exception {
159162 secondLocalRepositoryGit =
160163 Git .cloneRepository ()
161- .setURI (remoteRepository .getRoot ().toURI ().toString ())
162- .setDirectory (secondLocalRepository .getRoot ())
164+ .setURI (remoteRepository .toFile ().toURI ().toString ())
165+ .setDirectory (secondLocalRepository .toFile ())
163166 .setBranch ("master" )
164167 .call ();
165168 }
166169
167170 protected void createAndPushInitialCommit () throws Exception {
168- File newFile = localRepository .newFile ();
171+ File newFile = localRepository .toFile ();
169172 localRepositoryGit .add ().addFilepattern (newFile .getName ()).call ();
170173 localRepositoryGit .commit ().setMessage ("initial" ).call ();
171174
0 commit comments