assertTrue( list.contains( "folder1/file1.dat" ) );
assertTrue( list.contains( "folder2/file2.dat" ) );
}
public void testCopyDirectory() throws Exception {
ScmActionFactory svn = new SvnActionFactory( svnUrl,
"mrtrout",
"drools" );
CompositeScmAction actions = new CompositeScmAction();
ScmAction addDirectory = new AddDirectory( "",
"folder1" );
actions.addScmAction( addDirectory );
byte[] content1 = new byte[]{1, 1, 1, 1};
ScmAction addFile = new AddFile( "folder1",
"file1.dat",
content1 );
actions.addScmAction( addFile );
addDirectory = new AddDirectory( "folder1",
"folder1_1" );
actions.addScmAction( addDirectory );
byte[] content2 = new byte[]{1, 0, 0, 1};
addFile = new AddFile( "folder1/folder1_1",
"file1.dat",
content2 );
actions.addScmAction( addFile );
svn.execute( actions,
"test message" );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
svn.getContent( "folder1",
"file1.dat",
-1,
baos );
assertTrue( Arrays.equals( content1,
baos.toByteArray() ) );
baos = new ByteArrayOutputStream();
svn.getContent( "folder1/folder1_1",
"file1.dat",
-1,
baos );
assertTrue( Arrays.equals( content2,
baos.toByteArray() ) );
List list = convertToStringList( svn.listEntries( "" ) );
assertTrue( list.contains( "folder1" ) );
assertTrue( list.contains( "folder1/folder1_1/file1.dat" ) );
assertFalse( list.contains( "folder2/folder1/file1.dat" ) );
// Now copy the directory
actions = new CompositeScmAction();
addDirectory = new AddDirectory( "",
"folder2" );
actions.addScmAction( addDirectory );
ScmAction copyDirectory = new CopyDirectory( "folder1",
"folder2/folder1",
svn.getLatestRevision() );
actions.addScmAction( copyDirectory );
svn.execute( actions,
"test message" );
baos = new ByteArrayOutputStream();
svn.getContent( "folder1",
"file1.dat",
-1,
baos );
assertTrue( Arrays.equals( content1,
baos.toByteArray() ) );
baos = new ByteArrayOutputStream();
svn.getContent( "folder1/folder1_1",
"file1.dat",
-1,
baos );
assertTrue( Arrays.equals( content2,
baos.toByteArray() ) );
baos = new ByteArrayOutputStream();
svn.getContent( "folder2/folder1",
"file1.dat",
-1,
baos );
assertTrue( Arrays.equals( content1,
baos.toByteArray() ) );
baos = new ByteArrayOutputStream();
svn.getContent( "folder2/folder1/folder1_1",
"file1.dat",
-1,
baos );
assertTrue( Arrays.equals( content2,
baos.toByteArray() ) );
list = convertToStringList( svn.listEntries( "" ) );
assertTrue( list.contains( "folder1" ) );
assertTrue( list.contains( "folder1/folder1_1/file1.dat" ) );
assertTrue( list.contains( "folder2/folder1/file1.dat" ) );
}