Mercurial > hg > release > icedtea-web-1.6
changeset 1200:25e7471b4912
add DeploymentPropertiesModifierTests
2015-04-10 Lukasz Dracz <ldracz@redhat.com>
add DeploymentPropertiesModifierTests
* tests/reproducers/custom/PartiallySignedAppletManifestSpecifiesSandbox/testcases/PartiallySignedAppletManifestSpecifiesSandboxTests.java:
Changed spelling of DeploymentPropertiesModifier
* tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntrySignedMatching.java
Changed spelling of DeploymentPropertiesModifier
* tests/reproducers/signed/SignedAppletManifestSpecifiesSandbox/testcases/SignedAppletManifestSpecifiesSandboxTests.java
Changed spelling of DeploymentPropertiesModifier
* tests/test-extensions-tests/net/sourceforge/jnlp/tools/DeploymentPropertiesModifierTest.java:
Added tests for DeploymentPropertiesModifier
* tests/test-extensions/net/sourceforge/jnlp/tools/DeploymentPropertiesModifier.java:
added proper spelling of this file
* tests/test-extensions/net/sourceforge/jnlp/tools/DeploymentPropetiesModifier.java:
removed due to spelling error and added proper spelling of the same file
author | Lukasz Dracz <ldracz@redhat.com> |
---|---|
date | Fri, 10 Apr 2015 11:17:03 -0400 |
parents | 348045d8bf85 |
children | 037811f1055e |
files | ChangeLog tests/reproducers/custom/PartiallySignedAppletManifestSpecifiesSandbox/testcases/PartiallySignedAppletManifestSpecifiesSandboxTests.java tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntrySignedMatching.java tests/reproducers/signed/SignedAppletManifestSpecifiesSandbox/testcases/SignedAppletManifestSpecifiesSandboxTests.java tests/test-extensions-tests/net/sourceforge/jnlp/tools/DeploymentPropertiesModifierTest.java tests/test-extensions/net/sourceforge/jnlp/tools/DeploymentPropertiesModifier.java tests/test-extensions/net/sourceforge/jnlp/tools/DeploymentPropetiesModifier.java |
diffstat | 7 files changed, 318 insertions(+), 127 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Apr 10 10:53:23 2015 -0400 +++ b/ChangeLog Fri Apr 10 11:17:03 2015 -0400 @@ -1,3 +1,19 @@ +2015-04-10 Lukasz Dracz <ldracz@redhat.com> + + add DeploymentPropertiesModifierTests + * tests/reproducers/custom/PartiallySignedAppletManifestSpecifiesSandbox/testcases/PartiallySignedAppletManifestSpecifiesSandboxTests.java: + Changed spelling of DeploymentPropertiesModifier + * tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntrySignedMatching.java + Changed spelling of DeploymentPropertiesModifier + * tests/reproducers/signed/SignedAppletManifestSpecifiesSandbox/testcases/SignedAppletManifestSpecifiesSandboxTests.java + Changed spelling of DeploymentPropertiesModifier + * tests/test-extensions-tests/net/sourceforge/jnlp/tools/DeploymentPropertiesModifierTest.java: + Added tests for DeploymentPropertiesModifier + * tests/test-extensions/net/sourceforge/jnlp/tools/DeploymentPropertiesModifier.java: + added proper spelling of this file + * tests/test-extensions/net/sourceforge/jnlp/tools/DeploymentPropetiesModifier.java: + removed due to spelling error and added proper spelling of the same file + 2015-04-10 Jie Kang <jkang@redhat.com> Kill processes in Integration Tests more cleanly * tests/test-extensions/net/sourceforge/jnlp/ProcessAssasin.java:
--- a/tests/reproducers/custom/PartiallySignedAppletManifestSpecifiesSandbox/testcases/PartiallySignedAppletManifestSpecifiesSandboxTests.java Fri Apr 10 10:53:23 2015 -0400 +++ b/tests/reproducers/custom/PartiallySignedAppletManifestSpecifiesSandbox/testcases/PartiallySignedAppletManifestSpecifiesSandboxTests.java Fri Apr 10 11:17:03 2015 -0400 @@ -37,7 +37,6 @@ import static org.junit.Assert.assertTrue; -import java.io.File; import java.io.IOException; import net.sourceforge.jnlp.ProcessResult; @@ -49,11 +48,9 @@ import net.sourceforge.jnlp.closinglisteners.AutoOkClosingListener; import net.sourceforge.jnlp.config.DeploymentConfiguration; -import net.sourceforge.jnlp.config.PathsAndFiles; import net.sourceforge.jnlp.runtime.ManifestAttributesChecker; import net.sourceforge.jnlp.security.appletextendedsecurity.AppletSecurityLevel; -import net.sourceforge.jnlp.tools.DeploymentPropetiesModifier; -import net.sourceforge.jnlp.util.FileUtils; +import net.sourceforge.jnlp.tools.DeploymentPropertiesModifier; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -68,15 +65,15 @@ private static final String STACKTRACE_NOT_GRANT_PERMISSIONS_TYPE = "Cannot grant permissions to unsigned jars"; private static final String USER_HOME = System.getProperty("user.home"); - private static DeploymentPropetiesModifier permissionsModifier; - private static DeploymentPropetiesModifier securityLevelModifier; + private static DeploymentPropertiesModifier permissionsModifier; + private static DeploymentPropertiesModifier securityLevelModifier; @BeforeClass public static void setupDeploymentProperties() throws IOException { - permissionsModifier = new DeploymentPropetiesModifier(); + permissionsModifier = new DeploymentPropertiesModifier(); permissionsModifier.setProperties(DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.PERMISSIONS.toString()); - securityLevelModifier = new DeploymentPropetiesModifier(); + securityLevelModifier = new DeploymentPropertiesModifier(); securityLevelModifier.setProperties(DeploymentConfiguration.KEY_SECURITY_LEVEL, AppletSecurityLevel.ALLOW_UNSIGNED.toChars()); }
--- a/tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntrySignedMatching.java Fri Apr 10 10:53:23 2015 -0400 +++ b/tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntrySignedMatching.java Fri Apr 10 11:17:03 2015 -0400 @@ -51,7 +51,7 @@ import net.sourceforge.jnlp.closinglisteners.RulesFolowingClosingListener; import net.sourceforge.jnlp.config.DeploymentConfiguration; import net.sourceforge.jnlp.runtime.ManifestAttributesChecker; -import net.sourceforge.jnlp.tools.DeploymentPropetiesModifier; +import net.sourceforge.jnlp.tools.DeploymentPropertiesModifier; import net.sourceforge.jnlp.util.FileUtils; import org.junit.AfterClass; import org.junit.Assert; @@ -72,11 +72,11 @@ /*5*/ "CBCheckSignedAppletDontMatchException", /*6*/ "CBCheckSignedFail"}; - private static DeploymentPropetiesModifier codebaseModifier; + private static DeploymentPropertiesModifier codebaseModifier; @BeforeClass public static void setupDeploymentProperties() throws IOException { - codebaseModifier = new DeploymentPropetiesModifier(); + codebaseModifier = new DeploymentPropertiesModifier(); codebaseModifier.setProperties(DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.CODEBASE.toString()); }
--- a/tests/reproducers/signed/SignedAppletManifestSpecifiesSandbox/testcases/SignedAppletManifestSpecifiesSandboxTests.java Fri Apr 10 10:53:23 2015 -0400 +++ b/tests/reproducers/signed/SignedAppletManifestSpecifiesSandbox/testcases/SignedAppletManifestSpecifiesSandboxTests.java Fri Apr 10 11:17:03 2015 -0400 @@ -48,7 +48,7 @@ import net.sourceforge.jnlp.closinglisteners.AutoOkClosingListener; import net.sourceforge.jnlp.config.DeploymentConfiguration; import net.sourceforge.jnlp.runtime.ManifestAttributesChecker; -import net.sourceforge.jnlp.tools.DeploymentPropetiesModifier; +import net.sourceforge.jnlp.tools.DeploymentPropertiesModifier; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -64,17 +64,17 @@ private static final String JNLP_EXPECTED_STDOUT = "Initialization Error"; private static final String JNLP_EXPECTED_STDERR = "net.sourceforge.jnlp.LaunchException"; - private static DeploymentPropetiesModifier deploymentPropetiesModifier; + private static DeploymentPropertiesModifier deploymentPropertiesModifier; @BeforeClass public static void setupDeploymentProperties() throws IOException { - deploymentPropetiesModifier = new DeploymentPropetiesModifier(); - deploymentPropetiesModifier.setProperties(DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.PERMISSIONS.toString()); + deploymentPropertiesModifier = new DeploymentPropertiesModifier(); + deploymentPropertiesModifier.setProperties(DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.PERMISSIONS.toString()); } @AfterClass public static void setbackDeploymentProperties() throws IOException { - deploymentPropetiesModifier.restoreProperties(); + deploymentPropertiesModifier.restoreProperties(); } @Test
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-extensions-tests/net/sourceforge/jnlp/tools/DeploymentPropertiesModifierTest.java Fri Apr 10 11:17:03 2015 -0400 @@ -0,0 +1,178 @@ +/* + Copyright (C) 2015 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 2. + +IcedTea is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. +*/ + +package tools; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; + +import net.sourceforge.jnlp.config.DeploymentConfiguration; +import net.sourceforge.jnlp.config.InfrastructureFileDescriptor; +import net.sourceforge.jnlp.runtime.ManifestAttributesChecker; +import net.sourceforge.jnlp.security.appletextendedsecurity.AppletSecurityLevel; +import net.sourceforge.jnlp.tools.DeploymentPropertiesModifier; +import net.sourceforge.jnlp.util.FileUtils; +import org.junit.Test; + +public class DeploymentPropertiesModifierTest { + + private File deploymentFile; + + @Test + public void testSetProperties() throws IOException { + File tempUserFile = File.createTempFile("userDeploy", ""); + tempUserFile.deleteOnExit(); + + deploymentFile = tempUserFile; + DummyInfrastructureFileDescriptor deploymentInfrastructure = new DummyInfrastructureFileDescriptor(deploymentFile); + + String properties = FileUtils.loadFileAsString(deploymentFile); + assertEquals(0, properties.length()); + + DeploymentPropertiesModifier dpm = new DeploymentPropertiesModifier(deploymentInfrastructure); + dpm.setProperties(DeploymentConfiguration.KEY_SECURITY_LEVEL, AppletSecurityLevel.ALLOW_UNSIGNED.toChars()); + String setProperty = DeploymentConfiguration.KEY_SECURITY_LEVEL + "=" + AppletSecurityLevel.ALLOW_UNSIGNED.toChars() + "\n"; + + properties = FileUtils.loadFileAsString(deploymentFile); + assertEquals(setProperty, properties); + + } + + @Test + public void testRestoreProperties() throws IOException { + File tempUserFile = File.createTempFile("userDeploy", ""); + tempUserFile.deleteOnExit(); + + deploymentFile = tempUserFile; + DummyInfrastructureFileDescriptor deploymentInfrastructure = new DummyInfrastructureFileDescriptor(deploymentFile); + + String properties = FileUtils.loadFileAsString(deploymentFile); + assertEquals(0, properties.length()); + + DeploymentPropertiesModifier dpm = new DeploymentPropertiesModifier(deploymentInfrastructure); + dpm.setProperties(DeploymentConfiguration.KEY_SECURITY_LEVEL, AppletSecurityLevel.ALLOW_UNSIGNED.toChars()); + + String setProperty = DeploymentConfiguration.KEY_SECURITY_LEVEL + "=" + AppletSecurityLevel.ALLOW_UNSIGNED.toChars() + "\n"; + properties = FileUtils.loadFileAsString(deploymentFile); + assertEquals(setProperty, properties); + + dpm.restoreProperties(); + properties = FileUtils.loadFileAsString(deploymentFile); + assertEquals(0, properties.length()); + + } + + @Test(expected = IllegalStateException.class) + public void testRestorePropertiesRequiresPropertiesSetFirst() throws IOException { + File tempUserFile = File.createTempFile("userDeploy", ""); + tempUserFile.deleteOnExit(); + + deploymentFile = tempUserFile; + DummyInfrastructureFileDescriptor deploymentInfrastructure = new DummyInfrastructureFileDescriptor(deploymentFile); + + DeploymentPropertiesModifier dpm = new DeploymentPropertiesModifier(deploymentInfrastructure); + + dpm.restoreProperties(); + String properties = FileUtils.loadFileAsString(deploymentFile); + assertEquals(0, properties.length()); + + } + + @Test (expected = IllegalStateException.class) + public void testUsingSameDeploymentPropertiesModifierThrowsException() throws IOException { + File tempUserFile = File.createTempFile("userDeploy", ""); + tempUserFile.deleteOnExit(); + + deploymentFile = tempUserFile; + DummyInfrastructureFileDescriptor deploymentInfrastructure = new DummyInfrastructureFileDescriptor(deploymentFile); + + DeploymentPropertiesModifier dpm = new DeploymentPropertiesModifier(deploymentInfrastructure); + + dpm.setProperties(DeploymentConfiguration.KEY_SECURITY_LEVEL, AppletSecurityLevel.ALLOW_UNSIGNED.toChars()); + try { + dpm.setProperties(DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.PERMISSIONS.toString()); + } catch (IllegalStateException ise) { + dpm.restoreProperties(); + throw new IllegalStateException(); + } + + } + + @Test + public void testUsingDifferentDeploymentPropertiesModifier() throws IOException { + File tempUserFile = File.createTempFile("userDeploy", ""); + tempUserFile.deleteOnExit(); + + deploymentFile = tempUserFile; + DummyInfrastructureFileDescriptor deploymentInfrastructure = new DummyInfrastructureFileDescriptor(deploymentFile); + + DeploymentPropertiesModifier dpm1 = new DeploymentPropertiesModifier(deploymentInfrastructure); + DeploymentPropertiesModifier dpm2 = new DeploymentPropertiesModifier(deploymentInfrastructure); + + dpm1.setProperties(DeploymentConfiguration.KEY_SECURITY_LEVEL, AppletSecurityLevel.ALLOW_UNSIGNED.toChars()); + dpm2.setProperties(DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.PERMISSIONS.toString()); + + String contents = DeploymentConfiguration.KEY_SECURITY_LEVEL + "=" + AppletSecurityLevel.ALLOW_UNSIGNED.toChars() + "\n" + DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK + "=" + ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.PERMISSIONS.toString() + "\n"; + String properties = FileUtils.loadFileAsString(deploymentFile); + assertEquals(contents, properties); + + dpm2.restoreProperties(); + dpm1.restoreProperties(); + } + + private static class DummyInfrastructureFileDescriptor extends InfrastructureFileDescriptor { + private final File file; + + private DummyInfrastructureFileDescriptor(File file) { + super(); + this.file = file; + } + + @Override + public File getFile() { + return file; + } + + @Override + public String getFullPath() { + return file.getAbsolutePath(); + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-extensions/net/sourceforge/jnlp/tools/DeploymentPropertiesModifier.java Fri Apr 10 11:17:03 2015 -0400 @@ -0,0 +1,111 @@ +/* + Copyright (C) 2015 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 2. + +IcedTea is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. +*/ + +package net.sourceforge.jnlp.tools; + +import java.io.IOException; +import net.sourceforge.jnlp.config.InfrastructureFileDescriptor; + +import net.sourceforge.jnlp.config.PathsAndFiles; +import net.sourceforge.jnlp.util.FileUtils; + +public class DeploymentPropertiesModifier { + + private final InfrastructureFileDescriptor src; + private String savedValue; + private String requestedProperty; + private String requestedValue; + private boolean isPropertiesSet; + + public DeploymentPropertiesModifier() { + this(PathsAndFiles.USER_DEPLOYMENT_FILE); + } + + public DeploymentPropertiesModifier(InfrastructureFileDescriptor src) { + this.src = src; + isPropertiesSet = false; + } + + public void setProperties(String property, String value) throws IOException { + if (isPropertiesSet) { + throw new IllegalStateException(); + } + isPropertiesSet = true; + requestedProperty = property; + requestedValue = value; + + setDeploymentProperties(requestedProperty, requestedValue); + } + + public void restoreProperties() throws IOException { + if (!isPropertiesSet) { + throw new IllegalStateException(); + } + isPropertiesSet = false; + + restoreDeploymentProperties(); + } + + private void setDeploymentProperties(String property, String value) throws IOException { + String properties = FileUtils.loadFileAsString(src.getFile()); + + for (String line : properties.split("\n")) { + if (line.contains(property)) { + savedValue = line; + properties = properties.replace(line, property + "=" + value + "\n"); + } + } + + if (savedValue == null) { + properties += property + "=" + value + "\n"; + } + + FileUtils.saveFile(properties, src.getFile()); + } + + private void restoreDeploymentProperties() throws IOException { + String properties = FileUtils.loadFileAsString(src.getFile()); + if (savedValue != null) { + properties = properties.replace(requestedProperty + "=" + requestedValue + "\n", savedValue); + } else { + properties = properties.replace(requestedProperty + "=" + requestedValue + "\n", ""); + } + + FileUtils.saveFile(properties, src.getFile()); + } + +}
--- a/tests/test-extensions/net/sourceforge/jnlp/tools/DeploymentPropetiesModifier.java Fri Apr 10 10:53:23 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -/* - Copyright (C) 2015 Red Hat, Inc. - -This file is part of IcedTea. - -IcedTea is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License as published by -the Free Software Foundation, version 2. - -IcedTea is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with IcedTea; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. -*/ - -package net.sourceforge.jnlp.tools; - -import java.io.IOException; -import net.sourceforge.jnlp.config.InfrastructureFileDescriptor; - -import net.sourceforge.jnlp.config.PathsAndFiles; -import net.sourceforge.jnlp.util.FileUtils; - -public class DeploymentPropetiesModifier { - - private final InfrastructureFileDescriptor src; - private String savedValue; - private String requestedProperty; - private String requestedValue; - private boolean isPropertiesSet; - - public DeploymentPropetiesModifier() { - this(PathsAndFiles.USER_DEPLOYMENT_FILE); - } - - public DeploymentPropetiesModifier(InfrastructureFileDescriptor src) { - this.src = src; - isPropertiesSet = false; - } - - public void setProperties(String property, String value) throws IOException { - if (isPropertiesSet) { - throw new IllegalStateException(); - } - isPropertiesSet = true; - requestedProperty = property; - requestedValue = value; - - setDeploymentProperties(requestedProperty, requestedValue); - } - - public void restoreProperties() throws IOException { - if (!isPropertiesSet) { - throw new IllegalStateException(); - } - isPropertiesSet = false; - - restoreDeploymentProperties(); - } - - private void setDeploymentProperties(String property, String value) throws IOException { - String properties = FileUtils.loadFileAsString(src.getFile()); - - for (String line : properties.split("\n")) { - if (line.contains(property)) { - savedValue = line; - properties = properties.replace(line, property + "=" + value + "\n"); - } - } - - if (savedValue == null) { - properties += property + "=" + value + "\n"; - } - - FileUtils.saveFile(properties, src.getFile()); - } - - private void restoreDeploymentProperties() throws IOException { - String properties = FileUtils.loadFileAsString(src.getFile()); - if (savedValue != null) { - properties = properties.replace(requestedProperty + "=" + requestedValue + "\n", savedValue); - } else { - properties = properties.replace(requestedProperty + "=" + requestedValue + "\n", ""); - } - - FileUtils.saveFile(properties, src.getFile()); - } - -}