Changeset 9829 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r9827 r9829 1418 1418 */ 1419 1419 public String toXML(Collection<Entry<String, Setting<?>>> settings, boolean nopass, boolean defaults) { 1420 StringWriter sw = new StringWriter(); 1421 PrintWriter pw = new PrintWriter(sw); 1422 PreferencesWriter prefWriter = new PreferencesWriter(pw, nopass, defaults); 1423 prefWriter.write(settings); 1424 sw.flush(); 1425 StringBuffer sb = sw.getBuffer(); 1426 return sb.toString(); 1420 try ( 1421 StringWriter sw = new StringWriter(); 1422 PreferencesWriter prefWriter = new PreferencesWriter(new PrintWriter(sw), nopass, defaults); 1423 ) { 1424 prefWriter.write(settings); 1425 sw.flush(); 1426 return sw.toString(); 1427 } catch (IOException e) { 1428 Main.error(e); 1429 return null; 1430 } 1427 1431 } 1428 1432 -
trunk/test/unit/org/openstreetmap/josm/data/PreferencesTest.groovy
r7938 r9829 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.data 2 3 … … 27 28 assert Main.pref.getDefaultColor("foo").alpha == 0x12 28 29 } 30 31 void testToXml() { 32 assert Main.pref.toXML(true) == String.format( 33 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n" + 34 "<preferences xmlns='http://josm.openstreetmap.de/preferences-1.0' version='%d'>%n" + 35 " <tag key='expert' value='true'/>%n" + 36 " <tag key='jdk.Arrays.useLegacyMergeSort' value='false'/>%n" + 37 " <tag key='language' value='en'/>%n" + 38 " <tag key='osm-server.url' value='http://api06.dev.openstreetmap.org/api'/>%n" + 39 " <tag key='osm-server.username' value='josm_test'/>%n" + 40 "</preferences>%n", Version.getInstance().getVersion()) 41 } 29 42 }
Note:
See TracChangeset
for help on using the changeset viewer.