Skip to content

Commit

Permalink
1. add new version rap v0.5
Browse files Browse the repository at this point in the history
2. QA automation testing module development 20%
    2.1 finish modify interface
  • Loading branch information
Bosn authored and Bosn committed Nov 5, 2012
1 parent 59a6a17 commit f280992
Show file tree
Hide file tree
Showing 17 changed files with 580 additions and 447 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Rigel Automation Platform
===

@version v0.4 - (latest version, in master branch)
@version v0.5 - (latest version, in master branch)
@author Bosn Ma
@weibo http://weibo.com/bosn
@mail [email protected]
Expand Down
2 changes: 1 addition & 1 deletion WebContent/account/login.vm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</tr>
<tr>
<td></td>
<td><input type="submit" value="登录" /></td>
<td><input type="submit" class="btn btn-primary" value="登录" /></td>
</tr>
#if ($errMsg && $errMsg != "")
<tr>
Expand Down
1 change: 1 addition & 0 deletions WebContent/bcom/isOkWithNum.cb.vm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"isOk":$!isOk, "num":$!num}
2 changes: 1 addition & 1 deletion WebContent/tcom/template.rap.vm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<a class="btn btn-navbar" data-toggle="collapse"
data-target=".nav-collapse"> <span class="icon-bar"></span> <span
class="icon-bar"></span> <span class="icon-bar"></span>
</a> <a class="brand" href="http://fe.lzdp.us">RAP v0.4</a>
</a> <a class="brand" href="http://fe.lzdp.us">RAP v0.5</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="$platformUrl.home">首页</a></li>
Expand Down
2 changes: 1 addition & 1 deletion src/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/mysql.remote.properties</value>
<value>classpath:/mysql.local.properties</value>
</list>
</property>
</bean>
Expand Down
9 changes: 9 additions & 0 deletions src/com/baidu/rigel/rap/common/ActionBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ public class ActionBase extends ActionSupport {
private boolean isReturnUrlFirstSet;

private boolean isLoginCtlHidden;
private int num;

public int getNum() {
return num;
}

public void setNum(int num) {
this.num = num;
}

public boolean isLoginCtlHidden() {
return isLoginCtlHidden;
Expand Down
3 changes: 1 addition & 2 deletions src/com/baidu/rigel/rap/common/ArrayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import java.util.List;

public class ArrayUtils {
@SuppressWarnings("unchecked")
public static String join(List arr, String seperator) {
public static String join(List<?> arr, String seperator) {
StringBuilder str = new StringBuilder();
boolean isFirst = true;
for (Object item : arr) {
Expand Down
17 changes: 17 additions & 0 deletions src/com/baidu/rigel/rap/mock/service/MockMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,21 @@ public interface MockMgr {
* @return JSON String
*/
public String generateData(int projectId, String pattern);

/**
* modify mock data of parameters based on mockData
* @param actionId identifier of the action to be modified
* @param mockData mock data string
* example: response.param1.subParam=@format=x.xxxx_AND_response.
* param2=@value=1_AND_response.param3.subParam.subSubParam=@length=7
*
*/
public void modify(int actionId, String mockData);

/**
* clear all mock data of object in specified projet
* @param projectId
* @return number of rows affected
*/
public int reset(int projectId);
}
11 changes: 11 additions & 0 deletions src/com/baidu/rigel/rap/mock/service/impl/MockMgrImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,16 @@ private void parseTags(String[] tags, Map<String, String> tagMap, boolean isMock
}
}
}

@Override
public void modify(int actionId, String mockData) {
// TODO Auto-generated method stub

}

@Override
public int reset(int projectId) {
return projectDao.resetMockData(projectId);
}

}
175 changes: 100 additions & 75 deletions src/com/baidu/rigel/rap/mock/web/action/MockAction.java
Original file line number Diff line number Diff line change
@@ -1,75 +1,100 @@
package com.baidu.rigel.rap.mock.web.action;

import com.baidu.rigel.rap.common.ActionBase;
import com.baidu.rigel.rap.mock.service.MockMgr;

public class MockAction extends ActionBase {

private static final long serialVersionUID = 1L;
private int id;
private String pattern;
private String content;
private String callback;
private String _c;

public String get_c() {
return _c;
}

public void set_c(String _c) {
this._c = _c;
}

public String getCallback() {
return callback;
}

public void setCallback(String callback) {
this.callback = callback;
}

private MockMgr mockMgr;

public MockMgr getMockMgr() {
return mockMgr;
}

public void setMockMgr(MockMgr mockMgr) {
this.mockMgr = mockMgr;
}

public String getContent() {
return content;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public void setContent(String content) {
this.content = content;
}

public String getPattern() {
return pattern;
}

public void setPattern(String pattern) {
this.pattern = pattern;
}

public String createData() {
if (callback != null && !callback.isEmpty()) {
setContent(callback + "(" + mockMgr.generateData(id, pattern) + ")");
} else if (_c != null && !_c.isEmpty()) {
setContent(_c + "(" + mockMgr.generateData(id, pattern) + ")");
} else {
setContent(mockMgr.generateData(id, pattern));
}
return SUCCESS;
}
}
package com.baidu.rigel.rap.mock.web.action;

import com.baidu.rigel.rap.common.ActionBase;
import com.baidu.rigel.rap.mock.service.MockMgr;

public class MockAction extends ActionBase {

private static final long serialVersionUID = 1L;
private int id;
private String pattern;
private String mockData;
private int actionId;
private int projectId;
private String content;
private String callback;
private String _c;

public void setMockData(String mockData) {
this.mockData = mockData;
}

public void setActionId(int actionId) {
this.actionId = actionId;
}

public void setProjectId(int projectId) {
this.projectId = projectId;
}

public String get_c() {
return _c;
}

public void set_c(String _c) {
this._c = _c;
}

public String getCallback() {
return callback;
}

public void setCallback(String callback) {
this.callback = callback;
}

private MockMgr mockMgr;

public MockMgr getMockMgr() {
return mockMgr;
}

public void setMockMgr(MockMgr mockMgr) {
this.mockMgr = mockMgr;
}

public String getContent() {
return content;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public void setContent(String content) {
this.content = content;
}

public String getPattern() {
return pattern;
}

public void setPattern(String pattern) {
this.pattern = pattern;
}

public String createData() {
if (callback != null && !callback.isEmpty()) {
setContent(callback + "(" + mockMgr.generateData(id, pattern) + ")");
} else if (_c != null && !_c.isEmpty()) {
setContent(_c + "(" + mockMgr.generateData(id, pattern) + ")");
} else {
setContent(mockMgr.generateData(id, pattern));
}
return SUCCESS;
}

public String modify() {
mockMgr.modify(actionId, mockData);
return SUCCESS;
}

public String reset() {
setNum(mockMgr.reset(projectId));
return SUCCESS;
}
}
49 changes: 30 additions & 19 deletions src/com/baidu/rigel/rap/mock/web/action/struts.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<package name="mock" extends="rap-default" namespace="/mock">

<action name="createData"
class="com.baidu.rigel.rap.mock.web.action.MockAction"
method="createData">
<result name="error" type="velocity">/bcom/contentWithoutEscape.cb.vm
</result>
<result name="success" type="velocity">/bcom/contentWithoutEscape.cb.vm
</result>
</action>

</package>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<package name="mock" extends="rap-default" namespace="/mock">

<action name="modify" class="com.baidu.rigel.rap.mock.web.action.MockAction"
method="modify">
<result name="error" type="velocity">/bcom/contentWithoutEscape.cb.vm
</result>
<result name="success" type="velocity">/bcom/contentWithoutEscape.cb.vm
</result>
</action>

<action name="reset" class="com.baidu.rigel.rap.mock.web.action.MockAction"
method="reset">
<result name="success" type="velocity">/bcom/isOkWithNum.cb.vm
</result>
</action>

<action name="createData" class="com.baidu.rigel.rap.mock.web.action.MockAction"
method="createData">
<result name="success" type="velocity">/bcom/isOkWithNum.cb.vm
</result>
</action>

</package>
</struts>
2 changes: 1 addition & 1 deletion src/com/baidu/rigel/rap/project/bo/Action.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

package com.baidu.rigel.rap.project.bo;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
Expand Down
10 changes: 10 additions & 0 deletions src/com/baidu/rigel/rap/project/bo/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ public void setId(int id) {
this.id = id;
}

private String mockData;

public String getMockData() {
return mockData;
}

public void setMockData(String mockData) {
this.mockData = mockData;
}

private String name;

public String getName() {
Expand Down
7 changes: 7 additions & 0 deletions src/com/baidu/rigel/rap/project/dao/ProjectDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,11 @@ String updateProject(int id, String projectData,
* @return
*/
List<Action> getMatchedActionList(int projectId, String pattern);

/**
* clear all mock data of objects in specified project
* @param projectId project id
* @return affected rows num
*/
public int resetMockData(int projectId);
}
Loading

0 comments on commit f280992

Please sign in to comment.