Browse Source

KERNEL-418 更新升级重构

research/11.0
Bryant 5 years ago
parent
commit
8a56c817a5
  1. 18
      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

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

@ -7,7 +7,6 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.update.domain.UpdateConstants;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
@ -93,7 +92,7 @@ public class RestoreResultDialog extends JDialog {
jarProgressLabel.setVisible(true);
progressLabelPane.add(jarProgressLabel);
pane.add(progressLabelPane, BorderLayout.CENTER);
deletePreviousPropertyFile(RestartHelper.MOVE_FILE,RestartHelper.RECORD_FILE);
deletePreviousPropertyFile();
putJarBackupFiles();
restartButton.setEnabled(true);
restartLaterButton.setEnabled(true);
@ -101,19 +100,14 @@ public class RestoreResultDialog extends JDialog {
this.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Jar_Restore"));
}
public static boolean deletePreviousPropertyFile(String move, String record) {
File moveFile = new File(move);
File delFile = new File(record);
if ((moveFile.exists()) && (!moveFile.delete())) {
FineLoggerFactory.getLogger().error(move + "delete failed!");
return false;
public static boolean deletePreviousPropertyFile() {
File moveFile = new File(RestartHelper.MOVE_FILE);
File delFile = new File(RestartHelper.RECORD_FILE);
if (StableUtils.mkdirs(moveFile) && StableUtils.mkdirs(delFile)) {
return StableUtils.deleteFile(moveFile) && StableUtils.deleteFile(delFile);
}
if ((delFile.exists()) && (!delFile.delete())) {
FineLoggerFactory.getLogger().error(record + "delete failed!");
return false;
}
return true;
}
private void initOldVersionRestoreComps() {
this.setResizable(false);

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

@ -1,23 +1,26 @@
package com.fr.design.update.ui.dialog;
import org.easymock.EasyMock;
import org.easymock.IMocksControl;
import com.fr.design.RestartHelper;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import org.junit.Assert;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
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"));
File moveFile = new File(RestartHelper.MOVE_FILE);
File recordFile = new File(RestartHelper.RECORD_FILE);
try {
StableUtils.makesureFileExist(moveFile);
StableUtils.makesureFileExist(recordFile);
Assert.assertTrue(RestoreResultDialog.deletePreviousPropertyFile());
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(),e);
}
}
}

Loading…
Cancel
Save