16
16
17
17
package org .uberfire .java .nio .fs .jgit ;
18
18
19
- import static org .fest .assertions .api .Assertions .*;
20
- import static org .uberfire .java .nio .file .StandardDeleteOption .*;
21
- import static org .uberfire .java .nio .fs .jgit .util .JGitUtil .*;
22
-
23
19
import java .io .File ;
24
20
import java .io .IOException ;
25
21
import java .io .InputStream ;
26
22
import java .io .OutputStream ;
27
23
import java .net .URI ;
28
24
import java .text .SimpleDateFormat ;
25
+ import java .util .ArrayList ;
29
26
import java .util .HashMap ;
27
+ import java .util .HashSet ;
30
28
import java .util .List ;
31
29
import java .util .Map ;
32
30
import java .util .Scanner ;
31
+ import java .util .Set ;
33
32
34
33
import org .eclipse .jgit .api .Git ;
35
34
import org .eclipse .jgit .lib .ObjectId ;
56
55
import org .uberfire .java .nio .file .attribute .BasicFileAttributes ;
57
56
import org .uberfire .java .nio .file .attribute .FileTime ;
58
57
import org .uberfire .java .nio .fs .jgit .util .JGitUtil ;
59
- import org .uberfire .java .nio .fs .jgit .util .JGitUtil .PathType ;
58
+ import org .uberfire .java .nio .fs .jgit .util .JGitUtil .*;
59
+
60
+ import static org .fest .assertions .api .Assertions .*;
61
+ import static org .uberfire .java .nio .file .StandardDeleteOption .*;
62
+ import static org .uberfire .java .nio .fs .jgit .util .JGitUtil .*;
60
63
61
64
public class JGitFileSystemProviderTest extends AbstractTestInfra {
62
65
@@ -211,7 +214,6 @@ public void testNewFileSystemClone() throws IOException {
211
214
}
212
215
213
216
@ Test
214
- @ Ignore (value = "Can't push to git using git protocol, just ssh" )
215
217
public void testNewFileSystemCloneAndPush () throws IOException {
216
218
217
219
final URI originRepo = URI .create ( "git://my-simple-test-origin-repo" );
@@ -243,22 +245,6 @@ public void testNewFileSystemCloneAndPush() throws IOException {
243
245
put ( "fileXXXXX.txt" , tempFile ( "temp" ) );
244
246
}} );
245
247
246
- provider .getFileSystem ( URI .create ( "git://my-repo?push=git://localhost:9418/my-simple-test-origin-repo&force" ) );
247
-
248
- assertThat ( fs ).isNotNull ();
249
-
250
- assertThat ( fs .getRootDirectories () ).hasSize ( 2 );
251
-
252
- for ( final Path root : fs .getRootDirectories () ) {
253
- if ( root .toAbsolutePath ().toUri ().toString ().contains ( "upstream" ) ) {
254
- assertThat ( provider .newDirectoryStream ( root , null ) ).isNotEmpty ().hasSize ( 2 );
255
- } else if ( root .toAbsolutePath ().toUri ().toString ().contains ( "origin" ) ) {
256
- assertThat ( provider .newDirectoryStream ( root , null ) ).isNotEmpty ().hasSize ( 1 );
257
- } else {
258
- assertThat ( provider .newDirectoryStream ( root , null ) ).isNotEmpty ().hasSize ( 2 );
259
- }
260
- }
261
-
262
248
final URI newRepo2 = URI .create ( "git://my-repo2" );
263
249
264
250
final Map <String , Object > env2 = new HashMap <String , Object >() {{
@@ -268,19 +254,56 @@ public void testNewFileSystemCloneAndPush() throws IOException {
268
254
269
255
final FileSystem fs2 = provider .newFileSystem ( newRepo2 , env2 );
270
256
271
- provider .getFileSystem ( URI .create ( "git://my-repo?sync=git://localhost:9418/my-simple-test-origin-repo&force" ) );
257
+ commit ( origin .gitRepo (), "user-branch" , "user1" , "user1@example.com" , "commitx" , null , null , false , new HashMap <String , File >() {{
258
+ put ( "file1UserBranch.txt" , tempFile ( "tempX" ) );
259
+ }} );
272
260
273
- assertThat ( fs2 . getRootDirectories () ). hasSize ( 2 );
261
+ provider . getFileSystem ( URI . create ( "git://my-repo2?sync=git://localhost:9418/my-simple-test-origin-repo&force" ) );
274
262
263
+ assertThat ( fs2 .getRootDirectories () ).hasSize ( 5 );
264
+
265
+ final List <String > rootURIs1 = new ArrayList <String >() {{
266
+ add ( "git://master@my-repo2/" );
267
+ add ( "git://user-branch@my-repo2/" );
268
+ add ( "git://origin/master@my-repo2/" );
269
+ add ( "git://upstream/master@my-repo2/" );
270
+ add ( "git://upstream/user-branch@my-repo2/" );
271
+ }};
272
+
273
+ final List <String > rootURIs2 = new ArrayList <String >() {{
274
+ add ( "git://master@my-repo2/" );
275
+ add ( "git://user-branch@my-repo2/" );
276
+ add ( "git://user-branch-2@my-repo2/" );
277
+ add ( "git://origin/master@my-repo2/" );
278
+ add ( "git://upstream/master@my-repo2/" );
279
+ add ( "git://upstream/user-branch@my-repo2/" );
280
+ add ( "git://upstream/user-branch-2@my-repo2/" );
281
+ }};
282
+
283
+ final Set <String > rootURIs = new HashSet <String >();
275
284
for ( final Path root : fs2 .getRootDirectories () ) {
276
- if ( root .toAbsolutePath ().toUri ().toString ().contains ( "upstream" ) ) {
277
- assertThat ( provider .newDirectoryStream ( root , null ) ).isNotEmpty ().hasSize ( 2 );
278
- } else if ( root .toAbsolutePath ().toUri ().toString ().contains ( "origin" ) ) {
279
- assertThat ( provider .newDirectoryStream ( root , null ) ).isNotEmpty ().hasSize ( 2 );
280
- } else {
281
- assertThat ( provider .newDirectoryStream ( root , null ) ).isNotEmpty ().hasSize ( 2 );
282
- }
285
+ rootURIs .add ( root .toUri ().toString () );
283
286
}
287
+
288
+ rootURIs .removeAll ( rootURIs1 );
289
+
290
+ assertThat ( rootURIs ).isEmpty ();
291
+
292
+ commit ( origin .gitRepo (), "user-branch-2" , "user1" , "user1@example.com" , "commitx" , null , null , false , new HashMap <String , File >() {{
293
+ put ( "file2UserBranch.txt" , tempFile ( "tempX" ) );
294
+ }} );
295
+
296
+ provider .getFileSystem ( URI .create ( "git://my-repo2?sync=git://localhost:9418/my-simple-test-origin-repo&force" ) );
297
+
298
+ assertThat ( fs2 .getRootDirectories () ).hasSize ( 7 );
299
+
300
+ for ( final Path root : fs2 .getRootDirectories () ) {
301
+ rootURIs .add ( root .toUri ().toString () );
302
+ }
303
+
304
+ rootURIs .removeAll ( rootURIs2 );
305
+
306
+ assertThat ( rootURIs ).isEmpty ();
284
307
}
285
308
286
309
@ Test
0 commit comments