diff --git a/README.md b/README.md index f85a240..621d8fe 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Rigel Automation Platform === - @version v0.4.0 + @version v0.5.0 @author Bosn Ma @weibo http://weibo.com/bosn @mail bosn@outlook.com diff --git a/UPDATELOG.md b/UPDATELOG.md index e8acd62..71e2914 100644 --- a/UPDATELOG.md +++ b/UPDATELOG.md @@ -1,6 +1,8 @@ ======================rap v0.5 ================================================= * data mock - fix problems when request URL is absolute + fix problems when request URL is absolute 07/15/2013 + enhance JSON import, default add @value into remark field 07/15/2013 + fix bugs when JSON imported has Array elements 07/16/2013 ======================rap v0.4 ================================================= * change version back to 0.4 @@ -9,7 +11,7 @@ * add new tag format like @format[3], @value[4] to affect specified index of array element * add new tag regex like @regex=[a-zA-Z]bc to import powerful regular expression mechanism * update pageTester, add new tabs modify and reset which can help operate on mock data - + ======================rap v1.3 ================================================= * UE: login automatically redirect 09/10/2012 * add new mock data tag:@value=[xx], for mocking from 01 to 30, eg->@value=2012-09-[xx], output: 2012-09-01, 2012-09-02, 2012-09-03... 09/10/2012 @@ -17,7 +19,7 @@ * add @code @end support for action description area for code formatting 09/10/2012 * increase size of working area 09/10/2012 * fix bugs (data type choose, word file export encoding, etc.) 09/10/2012 - + ======================rap v1.2 ================================================= * simplify operation flow √ 08/29/2012 * fix shortcuts compatibilities in different browsers (1.1 only support Firefox) 07/24/2012 diff --git a/WebContent/stat/js/core/rap.js b/WebContent/stat/js/core/rap.js index 18f0996..5d2d65d 100644 --- a/WebContent/stat/js/core/rap.js +++ b/WebContent/stat/js/core/rap.js @@ -3,9 +3,9 @@ var rap = rap || {}; /******************************************************** - * * - * ##util module begin * - * * + * * + * ##util module begin * + * * ********************************************************/ /** @@ -25,7 +25,7 @@ var rap = rap || {}; * @return 转义后的输出 */ util.escaper.escapeInHJ = function(inputStr) { - var inputStr = inputStr.replace(/\&/g, "&"); + inputStr.replace(/\&/g, "&"); inputStr = inputStr.replace(/\/g, ">"); inputStr = inputStr.replace(/\\/g, "\\\\"); @@ -2899,6 +2899,11 @@ var rap = rap || {}; /** * process JSON import + * + * @param {object} f value to be processed + * @param {string} k key + * @param {number} pid parameter id + * @param {boolean} notFirst */ function processJSONImport(f, k, pId, notFirst) { var id, param, item; @@ -2914,16 +2919,21 @@ var rap = rap || {}; } } var key; + var f2; // child of f2 if (f instanceof Array && f.length) { if (notFirst) { item = f[0]; - if (typeof f === 'string') { + f2 = f[0]; + if (typeof f2 === 'string') { param.dataType = 'array'; - } else if (typeof f === 'number') { + param.remark = '@value=' + f; + } else if (typeof f2 === 'number') { param.dataType = 'array'; - } else if (typeof f === 'boolean') { + param.remark = '@value=' + f; + } else if (typeof f2 === 'boolean') { param.dataType = 'array'; - } else if (f !== null && typeof f === 'object') { + param.remark = '@value=' + f; + } else if (f !== null && typeof f2 === 'object') { param.dataType = 'array'; for (key in item) { processJSONImport(item[key], key, notFirst ? id : null, true); @@ -2931,11 +2941,20 @@ var rap = rap || {}; } } } else if (typeof f === 'string') { - param && (param.dataType = 'string'); + if(param) { + param.dataType = 'string'; + param.remark = '@value=' + f; + } } else if (typeof f === 'number') { - param && (param.dataType = 'number'); + if(param) { + param.dataType = 'number'; + param.remark = '@value=' + f; + } } else if (typeof f === 'boolean') { - param && (param.dataType = 'boolean'); + if(param) { + param.dataType = 'boolean'; + param.remark = '@value=' + f; + } } else if (typeof f === 'undefined') { } else if (f === null) { } else if (typeof f === 'object') { @@ -2949,10 +2968,10 @@ var rap = rap || {}; /*************************************************** - * * - * ##html-template-engine-begin * - * * - * */ + * * + * ##html-template-engine-begin * + * * + * */ /** diff --git a/build/classes/com/baidu/rigel/rap/mock/service/impl/MockMgrImpl.class b/build/classes/com/baidu/rigel/rap/mock/service/impl/MockMgrImpl.class index 41d35ff..f909caf 100644 Binary files a/build/classes/com/baidu/rigel/rap/mock/service/impl/MockMgrImpl.class and b/build/classes/com/baidu/rigel/rap/mock/service/impl/MockMgrImpl.class differ diff --git a/src/com/baidu/rigel/rap/mock/service/impl/MockMgrImpl.java b/src/com/baidu/rigel/rap/mock/service/impl/MockMgrImpl.java index 5df9510..15b3ab4 100644 --- a/src/com/baidu/rigel/rap/mock/service/impl/MockMgrImpl.java +++ b/src/com/baidu/rigel/rap/mock/service/impl/MockMgrImpl.java @@ -337,16 +337,20 @@ private void parseTags(String[] tags, Map tagMap, boolean isMock // tag format validation if (tag.startsWith("@") && tag.contains("=")) { if (tag.startsWith("@value")) { - String val = tag.split("=")[1]; - if (val.contains("[xx]") && isMocking) { - Integer n = _num++ % 30; - val = val.replace("[xx]", n >= 10 ? n.toString() : "0" + n); - } - if (tag.contains("value[")) { - tagMap.put("value_index", val + "_INDEX_" + tag.substring(tag.indexOf("[") + 1, tag.indexOf("]"))); - } else { - tagMap.put("value", val); - } + String[] valueSplitArr = tag.split("="); + String val = null; + if (valueSplitArr.length > 1) { + val = valueSplitArr[1]; + if (val.contains("[xx]") && isMocking) { + Integer n = _num++ % 30; + val = val.replace("[xx]", n >= 10 ? n.toString() : "0" + n); + } + if (tag.contains("value[")) { + tagMap.put("value_index", val + "_INDEX_" + tag.substring(tag.indexOf("[") + 1, tag.indexOf("]"))); + } else { + tagMap.put("value", val); + } + } } else if (tag.startsWith("@format")) { if (tag.contains("format[")) { tagMap.put("format_index", tag.split("=")[1] + "_INDEX_" + tag.substring(tag.indexOf("[") + 1, tag.indexOf("]")));