Browse Source

KERNEL-418 更新升级重构

persist/11.0
Bryant 5 years ago
parent
commit
69dc9bf939
  1. 16
      designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java
  2. 23
      designer-base/src/test/java/com/fr/design/update/ui/dialog/RestoreResultDialogTest.java

16
designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java

@ -93,7 +93,7 @@ public class RestoreResultDialog extends JDialog {
jarProgressLabel.setVisible(true); jarProgressLabel.setVisible(true);
progressLabelPane.add(jarProgressLabel); progressLabelPane.add(jarProgressLabel);
pane.add(progressLabelPane, BorderLayout.CENTER); pane.add(progressLabelPane, BorderLayout.CENTER);
deletePreviousPropertyFile(); deletePreviousPropertyFile(RestartHelper.MOVE_FILE,RestartHelper.RECORD_FILE);
putJarBackupFiles(); putJarBackupFiles();
restartButton.setEnabled(true); restartButton.setEnabled(true);
restartLaterButton.setEnabled(true); restartLaterButton.setEnabled(true);
@ -101,16 +101,18 @@ public class RestoreResultDialog extends JDialog {
this.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Jar_Restore")); this.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Jar_Restore"));
} }
public static void deletePreviousPropertyFile() { public static boolean deletePreviousPropertyFile(String move, String record) {
//在进行更新升级之前确保move和delete.properties删除 File moveFile = new File(move);
File moveFile = new File(RestartHelper.MOVE_FILE); File delFile = new File(record);
File delFile = new File(RestartHelper.RECORD_FILE);
if ((moveFile.exists()) && (!moveFile.delete())) { if ((moveFile.exists()) && (!moveFile.delete())) {
FineLoggerFactory.getLogger().error(RestartHelper.MOVE_FILE + "delete failed!"); FineLoggerFactory.getLogger().error(move + "delete failed!");
return false;
} }
if ((delFile.exists()) && (!delFile.delete())) { if ((delFile.exists()) && (!delFile.delete())) {
FineLoggerFactory.getLogger().error(RestartHelper.RECORD_FILE + "delete failed!"); FineLoggerFactory.getLogger().error(record + "delete failed!");
return false;
} }
return true;
} }
private void initOldVersionRestoreComps() { private void initOldVersionRestoreComps() {

23
designer-base/src/test/java/com/fr/design/update/ui/dialog/RestoreResultDialogTest.java

@ -0,0 +1,23 @@
package com.fr.design.update.ui.dialog;
import org.easymock.EasyMock;
import org.easymock.IMocksControl;
import org.junit.Assert;
import org.junit.Test;
import java.io.File;
public class RestoreResultDialogTest {
@Test
public void testDeletePreviousPropertyFile() {
IMocksControl control = EasyMock.createControl();
File testRecordFile = control.createMock(File.class);
File testMoveFile = control.createMock(File.class);
EasyMock.expect(testRecordFile.getPath()).andReturn("move").anyTimes();
EasyMock.expect(testMoveFile.getPath()).andReturn("record").anyTimes();
control.replay();
Assert.assertTrue(RestoreResultDialog.deletePreviousPropertyFile("move","record"));
}
}
Loading…
Cancel
Save