From 138114a6644091542708b044b3eeeaf8788bfd9b Mon Sep 17 00:00:00 2001 From: lucian Date: Wed, 4 Mar 2020 10:38:29 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-25688=20=E8=BF=9C=E7=A8=8B=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5war=E5=8C=85=E9=83=A8=E7=BD=B2=E7=9A=84=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8=EF=BC=8C=E8=BF=9E=E6=8E=A5=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E6=8F=90=E7=A4=BAwar=E5=8C=85=E9=83=A8=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 5 ++ .../com/fr/design/env/RemoteWorkspace.java | 10 +++- .../fr/design/env/RemoteWorkspaceTest.java | 54 +++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index eca98c8be..3a0d66774 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -131,6 +131,11 @@ public class EnvChangeEntrance { } } }); + // REPORT-25688如果是war包部署的服务器,给与提示 + if (WorkContext.getCurrent().isWarDeploy()) { + FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_War_Deploy_Tip"), + Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE); + } //REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录 JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (template != null) { diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java index cc7b02c7b..735c1a5bd 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java @@ -2,6 +2,9 @@ package com.fr.design.env; import com.fr.cluster.engine.base.FineClusterConfig; import com.fr.design.i18n.Toolkit; +import com.fr.invoke.ReflectException; +import com.fr.log.FineLoggerFactory; +import com.fr.base.operator.common.CommonOperator; import com.fr.rpc.ExceptionHandler; import com.fr.stable.AssistUtils; import com.fr.workspace.WorkContext; @@ -49,7 +52,12 @@ public class RemoteWorkspace implements Workspace { @Override public boolean isWarDeploy() { - return false; + try { + return WorkContext.getCurrent().get(CommonOperator.class).isWarDeploy(); + } catch (ReflectException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return false; + } } @Override diff --git a/designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java b/designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java new file mode 100644 index 000000000..fe7f365e6 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java @@ -0,0 +1,54 @@ +package com.fr.design.env; + +import com.fr.base.operator.common.CommonOperator; +import com.fr.invoke.ReflectException; +import com.fr.workspace.WorkContext; +import com.fr.workspace.Workspace; +import com.fr.workspace.connect.WorkspaceConnectionInfo; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/1/2 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({WorkContext.class}) +public class RemoteWorkspaceTest { + @Test + public void testIsWarDeploy() { + + Workspace workspace = EasyMock.mock(Workspace.class); + PowerMock.mockStatic(WorkContext.class); + EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes(); + + CommonOperator operator = EasyMock.createMock(CommonOperator.class); + EasyMock.expect(workspace.get(CommonOperator.class)).andReturn(operator).anyTimes(); + + EasyMock.expect(operator.isWarDeploy()).andReturn(true).once(); + EasyMock.expect(operator.isWarDeploy()).andReturn(false).once(); + EasyMock.expect(operator.isWarDeploy()).andThrow(new ReflectException()).once(); + + EasyMock.replay(workspace, operator); + PowerMock.replayAll(); + + WorkspaceConnectionInfo info = new WorkspaceConnectionInfo("url", "username", "password", "certPath", "certSecretKey"); + + RemoteWorkspace remoteWorkspace= new RemoteWorkspace(null, info); + + Assert.assertTrue(remoteWorkspace.isWarDeploy()); + Assert.assertFalse(remoteWorkspace.isWarDeploy()); + Assert.assertFalse(remoteWorkspace.isWarDeploy()); + + EasyMock.verify(workspace, operator); + PowerMock.verifyAll(); + + + } +} \ No newline at end of file