# HG changeset patch # User Jiri Vanek # Date 1441900497 -7200 # Node ID cd2bcad72cd5c9ad61b39ba752f5d1d3bf3d0edd # Parent 38218c5268d468b1b4de4d2501c0591724188f74 AppTrustWarningPanelTest.java: Backuped, reset and restored .appletTrustSettings so its content can not affect test diff -r 38218c5268d4 -r cd2bcad72cd5 ChangeLog --- a/ChangeLog Thu Sep 10 12:17:47 2015 +0200 +++ b/ChangeLog Thu Sep 10 17:54:57 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 38218c5268d4 -r cd2bcad72cd5 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:17:47 2015 +0200 +++ b/tests/netx/unit/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/AppTrustWarningPanelTest.java Thu Sep 10 17:54:57 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,8 @@ import javax.swing.JButton; import net.sourceforge.jnlp.PluginBridge; import net.sourceforge.jnlp.PluginParameters; +import net.sourceforge.jnlp.browsertesting.browsers.firefox.FirefoxProfilesOperator; +import org.junit.AfterClass; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -31,9 +35,33 @@ /* Should contain an instance of each AppTrustWarningPanel subclass */ private static List panelList = new ArrayList(); + private static File appletSecurityBackup; + private static final File trustFile = new File(System.getProperty("user.home") + "/.config/icedtea-web/.appletTrustSettings"); + + public static void backupAppletSecurity() throws IOException { + appletSecurityBackup = File.createTempFile("appletSecurity", "itwTestBAckup"); + FirefoxProfilesOperator.copyFile(trustFile, appletSecurityBackup); + } + public static void removeAppletSecurityImpl() throws IOException { + if (appletSecurityBackup.exists()) { + trustFile.delete(); + } + } + + @AfterClass + public static void restoreAppletSecurity() throws IOException { + if (appletSecurityBackup.exists()) { + removeAppletSecurityImpl(); + FirefoxProfilesOperator.copyFile(appletSecurityBackup, trustFile); + 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";