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.update.domain.UpdateConstants;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -93,7 +92,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(RestartHelper.MOVE_FILE,RestartHelper.RECORD_FILE); deletePreviousPropertyFile();
putJarBackupFiles(); putJarBackupFiles();
restartButton.setEnabled(true); restartButton.setEnabled(true);
restartLaterButton.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")); this.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Jar_Restore"));
} }
public static boolean deletePreviousPropertyFile(String move, String record) { public static boolean deletePreviousPropertyFile() {
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 (StableUtils.mkdirs(moveFile) && StableUtils.mkdirs(delFile)) {
FineLoggerFactory.getLogger().error(move + "delete failed!"); return StableUtils.deleteFile(moveFile) && StableUtils.deleteFile(delFile);
return false;
} }
if ((delFile.exists()) && (!delFile.delete())) {
FineLoggerFactory.getLogger().error(record + "delete failed!");
return false; return false;
} }
return true;
}
private void initOldVersionRestoreComps() { private void initOldVersionRestoreComps() {
this.setResizable(false); 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; package com.fr.design.update.ui.dialog;
import com.fr.design.RestartHelper;
import org.easymock.EasyMock; import com.fr.log.FineLoggerFactory;
import org.easymock.IMocksControl; import com.fr.stable.StableUtils;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import java.io.File; import java.io.File;
import java.io.IOException;
public class RestoreResultDialogTest { public class RestoreResultDialogTest {
@Test @Test
public void testDeletePreviousPropertyFile() { public void testDeletePreviousPropertyFile() {
IMocksControl control = EasyMock.createControl(); File moveFile = new File(RestartHelper.MOVE_FILE);
File testRecordFile = control.createMock(File.class); File recordFile = new File(RestartHelper.RECORD_FILE);
File testMoveFile = control.createMock(File.class); try {
EasyMock.expect(testRecordFile.getPath()).andReturn("move").anyTimes(); StableUtils.makesureFileExist(moveFile);
EasyMock.expect(testMoveFile.getPath()).andReturn("record").anyTimes(); StableUtils.makesureFileExist(recordFile);
control.replay(); Assert.assertTrue(RestoreResultDialog.deletePreviousPropertyFile());
Assert.assertTrue(RestoreResultDialog.deletePreviousPropertyFile("move","record")); } catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(),e);
}
} }
} }

Loading…
Cancel
Save