@Override public void move( final Path source, final Path target, final CopyOption... options ) throws DirectoryNotEmptyException, AtomicMoveNotSupportedException, IOException, SecurityException { checkNotNull( "source", source ); checkNotNull( "target", target ); try { copy( source, target, options ); delete( source ); } catch ( final Exception ex ) { throw new IOException( ex ); } }
@Test public void testCopyFiles() throws IOException { final URI newRepo = URI.create( "git://copyasset-test-repo" ); PROVIDER.newFileSystem( newRepo, EMPTY_ENV ); final Path path = PROVIDER.getPath( URI.create( "git://master@copyasset-test-repo/myfile1.txt" ) ); { final OutputStream outStream = PROVIDER.newOutputStream( path ); outStream.write( "my cool content".getBytes() ); outStream.close(); } final Path path2 = PROVIDER.getPath( URI.create( "git://user_branch@copyasset-test-repo/other/path/myfile2.txt" ) ); { final OutputStream outStream2 = PROVIDER.newOutputStream( path2 ); outStream2.write( "my cool content".getBytes() ); outStream2.close(); } final Path path3 = PROVIDER.getPath( URI.create( "git://user_branch@copyasset-test-repo/myfile3.txt" ) ); { final OutputStream outStream3 = PROVIDER.newOutputStream( path3 ); outStream3.write( "my cool content".getBytes() ); outStream3.close(); } final Path target = PROVIDER.getPath( URI.create( "git://user_branch@copyasset-test-repo/myfile1.txt" ) ); PROVIDER.copy( path, target ); final DirectoryStream<Path> stream = PROVIDER.newDirectoryStream( PROVIDER.getPath( URI.create( "git://user_branch@copyasset-test-repo/" ) ), null ); for ( Path path1 : stream ) { System.out.println("content: " + path1.toUri()); } assertThat( stream ).isNotNull().hasSize( 3 ); }
final Path target = PROVIDER.getPath( URI.create( "git://other_branch@copybranch-test-repo" ) ); PROVIDER.copy( source, target ); PROVIDER.copy( source, target ); failBecauseExceptionWasNotThrown( FileAlreadyExistsException.class ); } catch ( FileAlreadyExistsException e ) { PROVIDER.copy( notExists, notExists2 ); failBecauseExceptionWasNotThrown( NoSuchFileException.class ); } catch ( NoSuchFileException e ) {
final Path target = PROVIDER.getPath( URI.create( "git://master@copydir-test-repo/" ) ); PROVIDER.copy( source, target ); final Path target = PROVIDER.getPath( URI.create( "git://master@copydir-test-repo/some/place/here/" ) ); PROVIDER.copy( source, target ); final Path target = PROVIDER.getPath( URI.create( "git://master@copydir-test-repo/soXme/place/here" ) ); PROVIDER.copy( source, target ); final Path target = PROVIDER.getPath( URI.create( "git://master@copydir-test-repo/other_here/" ) ); PROVIDER.copy( source, target ); PROVIDER.copy( source, target ); failBecauseExceptionWasNotThrown( NoSuchFileException.class ); } catch ( NoSuchFileException e ) { PROVIDER.copy( source, target ); failBecauseExceptionWasNotThrown( FileAlreadyExistsException.class ); } catch ( FileAlreadyExistsException e ) {