Changeset 7085 in josm


Ignore:
Timestamp:
2014-05-09T06:41:29+02:00 (11 years ago)
Author:
Don-vip
Message:

allow to disable auto-save of preferences file for unit tests (ant chmod does not seem to work from Jenkins)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/build.xml

    r7079 r7085  
    267267            <replace file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_USERNAME@" value="${osm.username}"/>
    268268            <replace file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_PASSWORD@" value="${osm.password}"/>
    269                 <!-- Works only on Windows, does nothing on Unix -->
    270                 <attrib file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" readonly="true"/>
    271             <!-- Works only on Unix, does nothing on Windows -->
    272                 <chmod file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" perm="ugo-w" verbose="true"/>
    273269        </sequential>
    274270    </macrodef>
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r7083 r7085  
    8686     */
    8787    private File preferencesDirFile = null;
     88
    8889    /**
    8990     * Internal storage for the cache directory.
    9091     */
    9192    private File cacheDirFile = null;
     93
     94    /**
     95     * Determines if preferences file is saved each time a property is changed.
     96     */
     97    private boolean saveOnPut = true;
    9298
    9399    /**
     
    10361042                settingsMap.put(key, settingCopy);
    10371043            }
    1038             try {
    1039                 save();
    1040             } catch (IOException e){
    1041                 Main.warn(tr("Failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()));
     1044            if (saveOnPut) {
     1045                try {
     1046                    save();
     1047                } catch (IOException e){
     1048                    Main.warn(tr("Failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()));
     1049                }
    10421050            }
    10431051        }
     
    16421650        return a.equals(b);
    16431651    }
     1652
     1653    /**
     1654     * Enables or not the preferences file auto-save mechanism (save each time a setting is changed).
     1655     * This behaviour is enabled by default.
     1656     * @param enable if {@code true}, makes JOSM save preferences file each time a setting is changed
     1657     * @since 7085
     1658     */
     1659    public final void enableSaveOnPut(boolean enable) {
     1660        synchronized (this) {
     1661            saveOnPut = enable;
     1662        }
     1663    }
    16441664}
  • trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java

    r7081 r7085  
    4747        System.setProperty("josm.home", josmHome);
    4848        Main.initApplicationPreferences();
     49        Main.pref.enableSaveOnPut(false);
    4950        I18n.init();
    5051        // initialize the plaform hook, and
Note: See TracChangeset for help on using the changeset viewer.