refactor: 去掉 nashorn, 采用rhino作为默认的javascript

--story=1007265 --user=刘瑞斌 脚本语言去掉nashornScript https://www.tapd.cn/55049933/s/1144562
This commit is contained in:
CaptainB 2022-04-22 18:41:47 +08:00 committed by 刘瑞斌
parent e667020a28
commit bbf5117d87
9 changed files with 21 additions and 8 deletions

View File

@ -213,6 +213,9 @@ public class MsAssertions extends MsTestElement {
if (StringUtils.equals(scriptLanguage, "rhinoScript")) { if (StringUtils.equals(scriptLanguage, "rhinoScript")) {
scriptLanguage = "rhino"; scriptLanguage = "rhino";
} }
if (StringUtils.equals(scriptLanguage, "javascript")) {
scriptLanguage = "rhino";
}
assertion.setProperty("scriptLanguage", scriptLanguage); assertion.setProperty("scriptLanguage", scriptLanguage);
assertion.setProperty("script", assertionJSR223.getScript()); assertion.setProperty("script", assertionJSR223.getScript());
return assertion; return assertion;

View File

@ -87,6 +87,9 @@ public class MsJSR223Processor extends MsTestElement {
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("rhinoScript")) { if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("rhinoScript")) {
processor.setProperty("scriptLanguage", "rhino"); processor.setProperty("scriptLanguage", "rhino");
} }
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("javascript")) {
processor.setProperty("scriptLanguage", "rhino");
}
processor.setProperty("script", this.getScript()); processor.setProperty("script", this.getScript());
final HashTree jsr223PreTree = tree.add(processor); final HashTree jsr223PreTree = tree.add(processor);

View File

@ -83,6 +83,9 @@ public class MsJSR223PostProcessor extends MsTestElement {
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("rhinoScript")) { if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("rhinoScript")) {
processor.setProperty("scriptLanguage", "rhino"); processor.setProperty("scriptLanguage", "rhino");
} }
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("javascript")) {
processor.setProperty("scriptLanguage", "rhino");
}
processor.setProperty("script", this.getScript()); processor.setProperty("script", this.getScript());
final HashTree jsr223PostTree = tree.add(processor); final HashTree jsr223PostTree = tree.add(processor);

View File

@ -96,6 +96,9 @@ public class MsJSR223PreProcessor extends MsTestElement {
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("rhinoScript")) { if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("rhinoScript")) {
processor.setProperty("scriptLanguage", "rhino"); processor.setProperty("scriptLanguage", "rhino");
} }
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("javascript")) {
processor.setProperty("scriptLanguage", "rhino");
}
processor.setProperty("script", this.getScript()); processor.setProperty("script", this.getScript());
return processor; return processor;

View File

@ -93,7 +93,7 @@ public abstract class PostmanAbstractParserParser<T> extends ApiImportAbstractPa
if (StringUtils.isNotBlank(scriptStr)) { if (StringUtils.isNotBlank(scriptStr)) {
MsJSR223PreProcessor jsr223PreProcessor = new MsJSR223PreProcessor(); MsJSR223PreProcessor jsr223PreProcessor = new MsJSR223PreProcessor();
jsr223PreProcessor.setName("JSR223PreProcessor"); jsr223PreProcessor.setName("JSR223PreProcessor");
jsr223PreProcessor.setScriptLanguage("nashornScript"); jsr223PreProcessor.setScriptLanguage("rhino");
jsr223PreProcessor.setScript(parseVariable(scriptStr.toString())); jsr223PreProcessor.setScript(parseVariable(scriptStr.toString()));
LinkedList<MsTestElement> hashTree = new LinkedList<>(); LinkedList<MsTestElement> hashTree = new LinkedList<>();
hashTree.add(jsr223PreProcessor); hashTree.add(jsr223PreProcessor);

View File

@ -140,7 +140,7 @@ export default {
], ],
isCodeEditAlive: true, isCodeEditAlive: true,
languages: [ languages: [
'beanshell', "python", "groovy", "nashornScript", "rhinoScript" 'beanshell', "python", "groovy", "javascript"
], ],
codeEditModeMap: { codeEditModeMap: {
beanshell: 'java', beanshell: 'java',
@ -148,6 +148,7 @@ export default {
groovy: 'java', groovy: 'java',
nashornScript: 'javascript', nashornScript: 'javascript',
rhinoScript: 'javascript', rhinoScript: 'javascript',
javascript: 'javascript',
}, },
codeSpan: 20, codeSpan: 20,
menuSpan: 4, menuSpan: 4,

View File

@ -104,8 +104,7 @@ export default {
{text: 'beanshell', value: 'beanshell'}, {text: 'beanshell', value: 'beanshell'},
{text: 'python', value: 'python'}, {text: 'python', value: 'python'},
{text: 'groovy', value: 'groovy'}, {text: 'groovy', value: 'groovy'},
{text: 'nashornScript', value: 'nashornScript'}, {text: 'javascript', value: 'javascript'},
{text: 'rhinoScript', value: 'rhinoScript'},
], ],
} }
}, },

View File

@ -150,8 +150,7 @@ export default {
'beanshell', 'beanshell',
"python", "python",
"groovy", "groovy",
"nashornScript", "javascript"
"rhinoScript"
], ],
codeEditModeMap: { codeEditModeMap: {
beanshell: 'java', beanshell: 'java',
@ -159,6 +158,7 @@ export default {
groovy: 'java', groovy: 'java',
nashornScript: 'javascript', nashornScript: 'javascript',
rhinoScript: 'javascript', rhinoScript: 'javascript',
javascript: 'javascript',
}, },
response: {}, response: {},
request: {}, request: {},

View File

@ -2,8 +2,7 @@ export const FUNC_TEMPLATE = {
beanshell: "", beanshell: "",
groovy: "", groovy: "",
python: "", python: "",
nashornScript: "", javascript: ""
rhinoScript: ""
} }
export function getCodeTemplate(language, requestObj) { export function getCodeTemplate(language, requestObj) {
@ -18,6 +17,8 @@ export function getCodeTemplate(language, requestObj) {
return jsCode(requestObj); return jsCode(requestObj);
case "rhinoScript": case "rhinoScript":
return jsCode(requestObj); return jsCode(requestObj);
case "javascript":
return jsCode(requestObj);
default: default:
return ""; return "";
} }