### Question:
VersioningFileProvider extends AbstractFileProvider { @Override public void deleteVersion( final String page, final int version ) throws ProviderException { final File dir = findOldPageDir( page ); int latest = findLatestVersion( page ); if( version == PageProvider.LATEST_VERSION || version == latest || (version == 1 && latest == -1) ) { try { final Properties props = getPageProperties( page ); props.remove( ((latest > 0) ? latest : 1)+".author" ); putPageProperties( page, props ); } catch( final IOException e ) { log.error("Unable to modify page properties",e); throw new ProviderException("Could not modify page properties: " + e.getMessage()); } super.deleteVersion( page, PageProvider.LATEST_VERSION ); latest = findLatestVersion( page ); final File pageDir = findOldPageDir( page ); final File previousFile = new File( pageDir, latest + FILE_EXT ); final File pageFile = findPage(page); try( final InputStream in = new BufferedInputStream( new FileInputStream( previousFile ) ); final OutputStream out = new BufferedOutputStream( new FileOutputStream( pageFile ) ) ) { if( previousFile.exists() ) { FileUtil.copyContents( in, out ); pageFile.setLastModified( previousFile.lastModified() ); } } catch( final IOException e ) { log.fatal("Something wrong with the page directory - you may have just lost data!",e); } return; } final File pageFile = new File( dir, ""+version+FILE_EXT ); if( pageFile.exists() ) { if( !pageFile.delete() ) { log.error("Unable to delete page." + pageFile.getPath() ); } } else { throw new NoSuchVersionException("Page "+page+", version="+version); } }  @Override void initialize( final Engine engine, final Properties properties ); @Override synchronized String getPageText( final String page, int version ); @Override synchronized void putPageText( final Page page, final String text ); @Override Page getPageInfo( final String page, final int version ); @Override boolean pageExists( final String pageName, final int version ); @Override List< Page > getVersionHistory( final String page ); @Override void deletePage( final String page ); @Override void deleteVersion( final String page, final int version ); @Override Collection< Page > getAllPages(); @Override String getProviderInfo(); @Override void movePage( final String from, final String to ); static final String PAGEDIR; static final String PROPERTYFILE; }### Answer:
@Test public void testDeleteVersion() throws Exception { engine.saveText( NAME1, "v1\r\n" ); engine.saveText( NAME1, "v2\r\n" ); engine.saveText( NAME1, "v3\r\n" ); final PageManager mgr = engine.getManager( PageManager.class ); final PageProvider provider = mgr.getProvider(); List l = provider.getVersionHistory( NAME1 ); Assertions.assertEquals( 3, l.size(), "wrong # of versions" ); provider.deleteVersion( NAME1, 2 ); l = provider.getVersionHistory( NAME1 ); Assertions.assertEquals( 2, l.size(), "wrong # of versions" ); Assertions.assertEquals( "v1\r\n", provider.getPageText( NAME1, 1 ), "v1" ); Assertions.assertEquals( "v3\r\n", provider.getPageText( NAME1, 3 ), "v3" ); try { provider.getPageText( NAME1, 2 ); Assertions.fail( "v2" ); } catch( final NoSuchVersionException e ) { } }