WriteCommandExecution extends AbstractCommandExecution { @Override public void execute() throws CommandException { try { File f = new File( this.instr.getFilePath()); Utils.writeStringInto( this.instr.getContent(), f ); } catch( IOException e ) { throw new CommandException( e ); } } WriteCommandExecution( WriteCommandInstruction instr ); @Override void execute();  }
@Test public void testExecute_success() throws Exception { File tf = this.folder.newFile(); Assert.assertEquals( 0, tf.length()); WriteCommandExecution exec = buildExecutor( "write this into " + tf.getAbsolutePath()); exec.execute(); Assert.assertNotSame( 0, tf.length()); }
@Test( expected = CommandException.class ) public void testExecute_failure() throws Exception { File tf = this.folder.newFolder(); WriteCommandExecution exec = buildExecutor( "write this into " + tf.getAbsolutePath()); exec.execute(); }