# HG changeset patch # User Jiri Vanek # Date 1441899262 -7200 # Node ID 3d086f009551fd765e549ea0b5e48a247ba2c5d4 # Parent e4aca06e627613fa277074c43c259fa4a99cc7af AppTrustWarningPanelTest.java: Backuped, reset and restored .appletTrustSettings so its content can not affect test diff -r e4aca06e6276 -r 3d086f009551 ChangeLog --- a/ChangeLog Thu Sep 10 12:15:01 2015 +0200 +++ b/ChangeLog Thu Sep 10 17:34:22 2015 +0200 @@ -1,3 +1,8 @@ +2015-09-10 Jiri Vanek + + * tests/netx/unit/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/AppTrustWarningPanelTest.java: + Backuped, reset and restored .appletTrustSettings so its content can not affect test + 2015-09-10 Jiri Vanek * netx/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmation.java: diff -r e4aca06e6276 -r 3d086f009551 tests/netx/unit/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/AppTrustWarningPanelTest.java --- a/tests/netx/unit/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/AppTrustWarningPanelTest.java Thu Sep 10 12:15:01 2015 +0200 +++ b/tests/netx/unit/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/AppTrustWarningPanelTest.java Thu Sep 10 17:34:22 2015 +0200 @@ -1,5 +1,7 @@ package net.sourceforge.jnlp.security.dialogs.apptrustwarningpanel; +import java.io.File; +import java.io.IOException; import net.sourceforge.jnlp.security.dialogs.apptrustwarningpanel.UnsignedAppletTrustWarningPanel; import net.sourceforge.jnlp.security.dialogs.apptrustwarningpanel.AppTrustWarningPanel; import java.net.URL; @@ -10,6 +12,9 @@ import javax.swing.JButton; import net.sourceforge.jnlp.PluginBridge; import net.sourceforge.jnlp.PluginParameters; +import net.sourceforge.jnlp.browsertesting.browsers.firefox.FirefoxProfilesOperator; +import net.sourceforge.jnlp.config.PathsAndFiles; +import org.junit.AfterClass; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -31,9 +36,33 @@ /* Should contain an instance of each AppTrustWarningPanel subclass */ private static List panelList = new ArrayList(); + private static File appletSecurityBackup; + + public static void backupAppletSecurity() throws IOException { + appletSecurityBackup = File.createTempFile("appletSecurity", "itwTestBAckup"); + FirefoxProfilesOperator.copyFile(PathsAndFiles.APPLET_TRUST_SETTINGS_USER.getFile(), appletSecurityBackup); + } + + public static void removeAppletSecurityImpl() throws IOException { + if (appletSecurityBackup.exists()) { + PathsAndFiles.APPLET_TRUST_SETTINGS_USER.getFile().delete(); + } + } + + @AfterClass + public static void restoreAppletSecurity() throws IOException { + if (appletSecurityBackup.exists()) { + removeAppletSecurityImpl(); + FirefoxProfilesOperator.copyFile(appletSecurityBackup, PathsAndFiles.APPLET_TRUST_SETTINGS_USER.getFile()); + appletSecurityBackup.delete(); + } + } @BeforeClass public static void setup() throws Exception { + backupAppletSecurity(); + //emptying .appletTrustSettings to not affect run of this test + removeAppletSecurityImpl(); mockCodebase = new URL("http://www.example.com"); mockDocumentBase = new URL("http://www.example.com"); mockJar = "ApplicationName.jar";