@ -55,6 +55,7 @@ import java.io.File;
import java.io.IOException ;
import java.io.IOException ;
import java.net.URI ;
import java.net.URI ;
import java.nio.file.Files ;
import java.nio.file.Files ;
import java.nio.file.Path ;
import java.util.HashMap ;
import java.util.HashMap ;
import java.util.Map ;
import java.util.Map ;
@ -199,6 +200,15 @@ public class RepoCommandTest extends RepositoryTestCase {
return r ;
return r ;
}
}
private static void assertContents ( Path path , String expected )
throws IOException {
try ( BufferedReader reader = Files . newBufferedReader ( path , UTF_8 ) ) {
String content = reader . readLine ( ) ;
assertEquals ( "Unexpected content in " + path . getFileName ( ) ,
expected , content ) ;
}
}
@Test
@Test
public void runTwiceIsNOP ( ) throws Exception {
public void runTwiceIsNOP ( ) throws Exception {
try ( Repository child = cloneRepository ( groupADb , true ) ;
try ( Repository child = cloneRepository ( groupADb , true ) ;
@ -474,12 +484,7 @@ public class RepoCommandTest extends RepositoryTestCase {
. call ( ) ;
. call ( ) ;
File hello = new File ( db . getWorkTree ( ) , "foo/hello.txt" ) ;
File hello = new File ( db . getWorkTree ( ) , "foo/hello.txt" ) ;
assertTrue ( "submodule should be checked out" , hello . exists ( ) ) ;
assertTrue ( "submodule should be checked out" , hello . exists ( ) ) ;
try ( BufferedReader reader = Files . newBufferedReader ( hello . toPath ( ) ,
assertContents ( hello . toPath ( ) , "master world" ) ;
UTF_8 ) ) {
String content = reader . readLine ( ) ;
assertEquals ( "submodule content should be as expected" ,
"master world" , content ) ;
}
}
}
@Test
@Test
@ -565,21 +570,11 @@ public class RepoCommandTest extends RepositoryTestCase {
// The original file should exist
// The original file should exist
File hello = new File ( localDb . getWorkTree ( ) , "foo/hello.txt" ) ;
File hello = new File ( localDb . getWorkTree ( ) , "foo/hello.txt" ) ;
assertTrue ( "The original file should exist" , hello . exists ( ) ) ;
assertTrue ( "The original file should exist" , hello . exists ( ) ) ;
try ( BufferedReader reader = Files . newBufferedReader ( hello . toPath ( ) ,
assertContents ( hello . toPath ( ) , "master world" ) ;
UTF_8 ) ) {
String content = reader . readLine ( ) ;
assertEquals ( "The original file should have expected content" ,
"master world" , content ) ;
}
// The dest file should also exist
// The dest file should also exist
hello = new File ( localDb . getWorkTree ( ) , "Hello" ) ;
hello = new File ( localDb . getWorkTree ( ) , "Hello" ) ;
assertTrue ( "The destination file should exist" , hello . exists ( ) ) ;
assertTrue ( "The destination file should exist" , hello . exists ( ) ) ;
try ( BufferedReader reader = Files . newBufferedReader ( hello . toPath ( ) ,
assertContents ( hello . toPath ( ) , "master world" ) ;
UTF_8 ) ) {
String content = reader . readLine ( ) ;
assertEquals ( "The destination file should have expected content" ,
"master world" , content ) ;
}
}
}
@Test
@Test
@ -671,12 +666,7 @@ public class RepoCommandTest extends RepositoryTestCase {
. setURI ( rootUri )
. setURI ( rootUri )
. call ( ) ;
. call ( ) ;
File hello = new File ( db . getWorkTree ( ) , "foo/hello.txt" ) ;
File hello = new File ( db . getWorkTree ( ) , "foo/hello.txt" ) ;
try ( BufferedReader reader = Files . newBufferedReader ( hello . toPath ( ) ,
assertContents ( hello . toPath ( ) , "branch world" ) ;
UTF_8 ) ) {
String content = reader . readLine ( ) ;
assertEquals ( "submodule content should be as expected" ,
"branch world" , content ) ;
}
}
}
@Test
@Test
@ -698,12 +688,7 @@ public class RepoCommandTest extends RepositoryTestCase {
. setURI ( rootUri )
. setURI ( rootUri )
. call ( ) ;
. call ( ) ;
File hello = new File ( db . getWorkTree ( ) , "foo/hello.txt" ) ;
File hello = new File ( db . getWorkTree ( ) , "foo/hello.txt" ) ;
try ( BufferedReader reader = Files . newBufferedReader ( hello . toPath ( ) ,
assertContents ( hello . toPath ( ) , "branch world" ) ;
UTF_8 ) ) {
String content = reader . readLine ( ) ;
assertEquals ( "submodule content should be as expected" ,
"branch world" , content ) ;
}
}
}
@Test
@Test
@ -771,12 +756,7 @@ public class RepoCommandTest extends RepositoryTestCase {
assertFalse ( "The foo/Hello file should be skipped" ,
assertFalse ( "The foo/Hello file should be skipped" ,
foohello . exists ( ) ) ;
foohello . exists ( ) ) ;
// The content of Hello file should be expected
// The content of Hello file should be expected
try ( BufferedReader reader = Files . newBufferedReader ( hello . toPath ( ) ,
assertContents ( hello . toPath ( ) , "branch world" ) ;
UTF_8 ) ) {
String content = reader . readLine ( ) ;
assertEquals ( "The Hello file should have expected content" ,
"branch world" , content ) ;
}
}
}
}
}
@ -1143,12 +1123,7 @@ public class RepoCommandTest extends RepositoryTestCase {
. setURI ( rootUri )
. setURI ( rootUri )
. call ( ) ;
. call ( ) ;
File hello = new File ( db . getWorkTree ( ) , "foo/hello.txt" ) ;
File hello = new File ( db . getWorkTree ( ) , "foo/hello.txt" ) ;
try ( BufferedReader reader = Files . newBufferedReader ( hello . toPath ( ) ,
assertContents ( hello . toPath ( ) , "branch world" ) ;
UTF_8 ) ) {
String content = reader . readLine ( ) ;
assertEquals ( "submodule content should be as expected" ,
"branch world" , content ) ;
}
}
}
@Test
@Test