Mercurial > hg > release > icedtea-web-1.6
changeset 1260:3d086f009551
AppTrustWarningPanelTest.java: Backuped, reset and restored .appletTrustSettings so its content can not affect test
author | Jiri Vanek <jvanek@redhat.com> |
---|---|
date | Thu, 10 Sep 2015 17:34:22 +0200 |
parents | e4aca06e6276 |
children | ba6519dd5e79 |
files | ChangeLog tests/netx/unit/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/AppTrustWarningPanelTest.java |
diffstat | 2 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 <jvanek@redhat.com> + + * 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 <jvanek@redhat.com> * netx/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmation.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<AppTrustWarningPanel> panelList = new ArrayList<AppTrustWarningPanel>(); + 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";