@Test public void verifyWriteSettngs() throws IOException, ManipulationException { URL resource = SettingsIOTest.class.getResource( "settings.xml" ); assertNotNull( resource ); File originalSettingsFile = new File( resource.getFile() ); assertTrue( originalSettingsFile.exists() ); Settings settings = new DefaultSettingsReader().read( originalSettingsFile, Collections.emptyMap() ); assertNull( settings.getModelEncoding() ); File targetFile = folder.newFile( "settings.xml" ); new SettingsIO( null ).write( settings, targetFile ); assertFalse( FileUtils.contentEquals( targetFile, originalSettingsFile ) ); }
public void write( Settings settings, File settingsFile ) throws ManipulationException { try { LineSeparator ls; String intro = ""; String outtro = ""; if ( settingsFile.length() > 0 ) { ls = FileIO.determineEOL( settingsFile ); ModelETLRequest request = new ModelETLRequest(); request.setLineSeparator( ls.value() ); ModelETL etl = modelETLFactories.newInstance( request ); etl.extract( settingsFile ); intro = (String) FieldUtils.getDeclaredField( JDomModelETL.class, "intro", true ).get( etl ); outtro = (String) FieldUtils.getDeclaredField( JDomModelETL.class, "outtro", true ).get( etl ); } else { ls = LineSeparator.NL; } jdomSettingsConverter.setLineSeparator( ls.value() ); jdomSettingsConverter.write( settings, settingsFile, intro, outtro); } catch ( IOException | JDOMException | ReleaseExecutionException | IllegalAccessException e ) { throw new ManipulationException( "Failed to create repo removal backup settings.xml file: {}", settingsFile, e ); } }
SettingsIO { public void write( Settings settings, File settingsFile ) throws ManipulationException { try { LineSeparator ls; String intro = ""; String outtro = ""; if ( settingsFile.length() > 0 ) { ls = FileIO.determineEOL( settingsFile ); ModelETLRequest request = new ModelETLRequest(); request.setLineSeparator( ls.value() ); ModelETL etl = modelETLFactories.newInstance( request ); etl.extract( settingsFile ); intro = (String) FieldUtils.getDeclaredField( JDomModelETL.class, "intro", true ).get( etl ); outtro = (String) FieldUtils.getDeclaredField( JDomModelETL.class, "outtro", true ).get( etl ); } else { ls = LineSeparator.NL; } jdomSettingsConverter.setLineSeparator( ls.value() ); jdomSettingsConverter.write( settings, settingsFile, intro, outtro); } catch ( IOException | JDOMException | ReleaseExecutionException | IllegalAccessException e ) { throw new ManipulationException( "Failed to create repo removal backup settings.xml file: {}", settingsFile, e ); } } }
SettingsIO { public void write( Settings settings, File settingsFile ) throws ManipulationException { try { LineSeparator ls; String intro = ""; String outtro = ""; if ( settingsFile.length() > 0 ) { ls = FileIO.determineEOL( settingsFile ); ModelETLRequest request = new ModelETLRequest(); request.setLineSeparator( ls.value() ); ModelETL etl = modelETLFactories.newInstance( request ); etl.extract( settingsFile ); intro = (String) FieldUtils.getDeclaredField( JDomModelETL.class, "intro", true ).get( etl ); outtro = (String) FieldUtils.getDeclaredField( JDomModelETL.class, "outtro", true ).get( etl ); } else { ls = LineSeparator.NL; } jdomSettingsConverter.setLineSeparator( ls.value() ); jdomSettingsConverter.write( settings, settingsFile, intro, outtro); } catch ( IOException | JDOMException | ReleaseExecutionException | IllegalAccessException e ) { throw new ManipulationException( "Failed to create repo removal backup settings.xml file: {}", settingsFile, e ); } } @Inject  SettingsIO(SettingsBuilder settingsBuilder); }
SettingsIO { public void write( Settings settings, File settingsFile ) throws ManipulationException { try { LineSeparator ls; String intro = ""; String outtro = ""; if ( settingsFile.length() > 0 ) { ls = FileIO.determineEOL( settingsFile ); ModelETLRequest request = new ModelETLRequest(); request.setLineSeparator( ls.value() ); ModelETL etl = modelETLFactories.newInstance( request ); etl.extract( settingsFile ); intro = (String) FieldUtils.getDeclaredField( JDomModelETL.class, "intro", true ).get( etl ); outtro = (String) FieldUtils.getDeclaredField( JDomModelETL.class, "outtro", true ).get( etl ); } else { ls = LineSeparator.NL; } jdomSettingsConverter.setLineSeparator( ls.value() ); jdomSettingsConverter.write( settings, settingsFile, intro, outtro); } catch ( IOException | JDOMException | ReleaseExecutionException | IllegalAccessException e ) { throw new ManipulationException( "Failed to create repo removal backup settings.xml file: {}", settingsFile, e ); } } @Inject  SettingsIO(SettingsBuilder settingsBuilder); void write( Settings settings, File settingsFile ); void update( Settings settings, File settingsFile ); }
SettingsIO { public void write( Settings settings, File settingsFile ) throws ManipulationException { try { LineSeparator ls; String intro = ""; String outtro = ""; if ( settingsFile.length() > 0 ) { ls = FileIO.determineEOL( settingsFile ); ModelETLRequest request = new ModelETLRequest(); request.setLineSeparator( ls.value() ); ModelETL etl = modelETLFactories.newInstance( request ); etl.extract( settingsFile ); intro = (String) FieldUtils.getDeclaredField( JDomModelETL.class, "intro", true ).get( etl ); outtro = (String) FieldUtils.getDeclaredField( JDomModelETL.class, "outtro", true ).get( etl ); } else { ls = LineSeparator.NL; } jdomSettingsConverter.setLineSeparator( ls.value() ); jdomSettingsConverter.write( settings, settingsFile, intro, outtro); } catch ( IOException | JDOMException | ReleaseExecutionException | IllegalAccessException e ) { throw new ManipulationException( "Failed to create repo removal backup settings.xml file: {}", settingsFile, e ); } } @Inject  SettingsIO(SettingsBuilder settingsBuilder); void write( Settings settings, File settingsFile ); void update( Settings settings, File settingsFile );  }