Skip to content

Commit

Permalink
fix merge errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Bosn committed Mar 24, 2014
1 parent 75e5679 commit ed0856e
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 90 deletions.
2 changes: 1 addition & 1 deletion WebContent/demo/mock.plugin/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<!-- <script type="text/javascript"
src="http://rap.alibaba-inc.com/rap.plugin.js?projectId=79"></script> -->
<script type="text/javascript"
src="http://etaoux-bj.taobao.ali.com:8080/rap.plugin.js?projectId=79&mode=0"></script>
src="http://etaoux-bj.taobao.ali.com:8080/rap.plugin.js?projectId=79&mode=3"></script>
<!-- 引入RAP结束 -->
</head>
<body>
Expand Down
46 changes: 23 additions & 23 deletions WebContent/platform/home.vm
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
#parse('/tcom/template.rap.vm')
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>欢迎使用RAP </title>
#includeNewRapStatic
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>欢迎使用RAP </title>
#includeNewRapStatic
<style type="text/css">
.marketing { text-align: center; color: #5a5a5a; }
.marketing h1 { margin: 60px 0 10px; font-size: 40px; font-weight: 200; line-height: 1; letter-spacing: -1px; }
.marketing h2 { font-weight: 200; margin-bottom: 5px; }
.marketing p { font-size: 16px; line-height: 1.5; }
.marketing .marketing-byline { margin-bottom: 40px; font-size: 20px; font-weight: 300; line-height: 25px; color: #999; }
.hero-unit h1{margin-top: 40px; margin-bottom: 20px;}
.hero-unit {margin-bottom: 100px; margin-top: 100px; text-align: center;}
.label {
color: #666;
}
.row-fluid p, .row-fluid h2 {text-align: center;}
.row-fluid p {color: #999;}
.extra {margin-top: 100px; text-align: center; margin-bottom: 100px;}
.extra p {margin-top: 20px;}
.hero-unit h1{margin-top: 40px; margin-bottom: 20px;}
.hero-unit {margin-bottom: 100px; margin-top: 100px; text-align: center;}
.label {
color: #666;
}
.row-fluid p, .row-fluid h2 {text-align: center;}
.row-fluid p {color: #999;}
.extra {margin-top: 100px; text-align: center; margin-bottom: 100px;}
.extra p {margin-top: 20px;}
</style>
</head>
<body>
#bodyNewStart
</head>
<body>
#bodyNewStart
<!-- title block begin -->
<div class="hero-unit">
<h1>RAP(Rigel Automation Platform)</h1>
Expand All @@ -40,7 +40,7 @@

<!-- feature block begin -->
<div class="row-fluid">
<div class="row">
<div class="row">
<div class="col-sm-3" style="margin-left: 4%;">
<img src="${staticRoot}/img/home_img_1.png" class="">
<h2>接口版本管理</h2>
Expand All @@ -59,10 +59,10 @@
</div>
</div>
<div class="extra">
<h1>相关链接</h1>
<p>对于RAP平台的任何问题,欢迎邮件至<a href="mailto:huoyong.msb@taobao.com">[email protected]</a></p>
<p>RAP是THX平台中的产品,想了解THX更多内容,请访问:<a href="http://thx.alibaba-inc.com" target="_blank">http://thx.alibaba-inc.com</a></p>
<p>RAP Github Repo: <a href="http://github.com/thx/RAP" target="_blank">http://github.com/thx/RAP</a></p>
<h1>相关链接</h1>
<p>对于RAP平台的任何问题,欢迎邮件至<a href="mailto:zhifu.wzf@alibaba-inc.com">思竹</a> 或 <a href="mailto:[email protected]">霍雍g</a></p>
<p>RAP是THX平台中的产品,想了解THX更多内容,请访问:<a href="http://thx.alibaba-inc.com" target="_blank">http://thx.alibaba-inc.com</a></p>
<p>RAP Github Repo: <a href="http://github.com/thx/RAP" target="_blank">http://github.com/thx/RAP</a></p>
</div>
<!-- feature block end -->

Expand Down Expand Up @@ -100,6 +100,6 @@
-->
<!-- case block end -->

#bodyEnd
</body>
#bodyEnd
</body>
</html>
88 changes: 26 additions & 62 deletions WebContent/stat/js/util/mock.plugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*! rap.plugin Mar.10th 2014 */
(function() {
var node = null;
Expand Down Expand Up @@ -66,9 +65,9 @@
rapUrlConverterJQuery(oOptions);
var oldSuccess = oOptions.success;
oOptions.success = function(data) {
if (PREFIX == '/mockjs/') {
data = Mock.mock(data);
}
if (PREFIX == '/mockjs/') {
data = Mock.mock(data);
}
oldSuccess.apply(this, arguments);
};
} else if(isInWhiteList(url) && !oOptions.RAP_NOT_TRACK) {
Expand Down Expand Up @@ -111,46 +110,25 @@
rapUrlConverterKissy(oOptions);
oldSuccess = oOptions.success;
oOptions.success = function(data) {
if (PREFIX == '/mockjs/') {
data = Mock.mock(data);
}
if (PREFIX == '/mockjs/') {
data = Mock.mock(data);
}
oldSuccess.apply(this, arguments);
};
} else {
if (!oOptions.RAP_NOT_TRACK) {
// real data checking
var oldSuccess = oOptions.success;
oOptions.success = function() {
var realData = arguments[0];
KISSY.IO({
url : url,
dataType : 'jsonp',
jsonp : '_c',
RAP_NOT_TRACK : true,
success : function(mockData) {
var validator = new StructureValidator(realData, mockData);
var result = validator.getResult();
var realDataResult = result.left;
var rapDataResult = result.right;
var i;

if (realDataResult.length === 0 && rapDataResult.length === 0) {
console.log('接口结构校验完毕,未发现问题。');
} else {
for (i = 0; i < realDataResult.length; i++) {
validatorResultLog(realDataResult[i]);
}
for (i = 0; i < rapDataResult.length; i++) {
validatorResultLog(rapDataResult[i], true);
}
}
}
});
oldSuccess.apply(this,arguments);

} else if(isInWhiteList(url) && !oOptions.RAP_NOT_TRACK) {
var checkerOptions = {url:oOptions.url};
rapUrlConverterKissy(checkerOptions);
checkerOptions.RAP_NOT_TRACK = true;
checkerOptions.success = checkerHandler;
// real data checking
oldSuccess = oOptions.success;
oOptions.success = function() {
var realData = arguments[0];
checkerOptions.context = {
data : realData
};
// perform real data check
KISSY.IO(checkerOptions);
IO(checkerOptions);
oldSuccess.apply(this,arguments);
};

Expand All @@ -162,21 +140,7 @@
}, {
requires: ['ajax']
});

function replace(modules) {
var splited = modules;
if (KISSY.isString(modules)) {
splited = modules.split(',');
}
var index = -1;
for (var i = 0, l = splited.length; i < l; i++) {
var name = KISSY.trim(splited[i]).toLowerCase();
if (name === 'ajax' || name === 'io') {
splited[i] = 'rap_io'
}
}
return splited.join(',');
}


KISSY.use = function(modules, callback) {
var args = arguments;
Expand Down Expand Up @@ -223,10 +187,10 @@
}


function checkerHandler(mockData) {
if (PREFIX == '/mockjs/') {
mockData = Mock.mock(mockData);
}
function checkerHandler(mockData) {
if (PREFIX == '/mockjs/') {
mockData = Mock.mock(mockData);
}
var realData = this.data;
var validator = new StructureValidator(realData, mockData);
var result = validator.getResult();
Expand Down Expand Up @@ -353,7 +317,7 @@
* example: www.baidu.com/a => alibaba-inc.com/mock/106/a
*/
function rapUrlConverterKissy(options) {
var url = options.url;
var url = options.url;
if (!options || typeof options !== 'object') {
throw Error('illegal option object:' + options);
}
Expand All @@ -371,7 +335,7 @@
* example: www.baidu.com/a => alibaba-inc.com/mock/106/a
*/
function rapUrlConverterJQuery(options) {
var url = options.url;
var url = options.url;
if (!options || typeof options !== 'object') {
throw Error('illegal option object:' + options);
}
Expand Down Expand Up @@ -425,4 +389,4 @@
return PREFIX;
}
};
})();
})();
3 changes: 2 additions & 1 deletion src/com/taobao/rigel/rap/mock/service/MockMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ public interface MockMgr {
* @param projectId
* @param pattern
* @return JSON String
* @throws UnsupportedEncodingException
*/
public String generateData(int projectId, String pattern);
public String generateData(int projectId, String pattern) throws UnsupportedEncodingException;

/**
* modify mock data of parameters based on mockData
Expand Down
7 changes: 5 additions & 2 deletions src/com/taobao/rigel/rap/mock/service/impl/MockMgrImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public void setProjectDao(ProjectDao projectDao) {
}

@Override
public String generateData(int projectId, String pattern) {
public String generateData(int projectId, String pattern) throws UnsupportedEncodingException {
_num = 1;
String originalPattern = pattern;
System.out.println("pattern before processed:" + pattern);
if (pattern.contains("?")) {
pattern = pattern.substring(0, pattern.indexOf("?"));
Expand All @@ -68,7 +69,9 @@ public String generateData(int projectId, String pattern) {
.getMatchedActionList(projectId, pattern);
if (aList.size() == 0)
return "{\"isOk\":false, \"errMsg\":\"no matched action\"}";
Action action = aList.get(0);

Action action = actionPick(aList, originalPattern);

String desc = action.getDescription();
Set<Parameter> pList = action.getResponseParameterList();
// load mock data by QA
Expand Down
2 changes: 1 addition & 1 deletion src/com/taobao/rigel/rap/mock/web/action/MockAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void setPattern(String pattern) {
}
}

public String createData() {
public String createData() throws UnsupportedEncodingException {
String _c = get_c();
if (callback != null && !callback.isEmpty()) {
setContent(callback + "(" + mockMgr.generateData(id, pattern) + ")");
Expand Down

0 comments on commit ed0856e

Please sign in to comment.