.gitignore not work well

This commit is contained in:
coderfengyun 2014-04-08 09:53:17 +08:00
parent ec42ccc4a5
commit ae3800160b
60 changed files with 13990 additions and 18310 deletions

72
.gitignore vendored
View File

@ -1,36 +1,38 @@
/*/.project /*/.project/
/*/.classpath /*/.classpath/
/*/.settings /*/.settings/
/*/target /*/target/
/*/logs /*/logs/
/*/bin /*/bin/
/*/ScenarioParameters/
/Bench4Q-Master/.project /*/Scripts/
/Bench4Q-Master/.classpath
/Bench4Q-Master/.settings /Bench4Q-Master/.project
/Bench4Q-Master/target /Bench4Q-Master/.classpath
/Bench4Q-Master/logs /Bench4Q-Master/.settings
/Bench4Q-Master/target
/Bench4Q-Agent/.project /Bench4Q-Master/logs
/Bench4Q-Agent/.classpath
/Bench4Q-Agent/.settings /Bench4Q-Agent/.project
/Bench4Q-Agent/target /Bench4Q-Agent/.classpath
/Bench4Q-Agent/logs /Bench4Q-Agent/.settings
/Bench4Q-Agent/target
/Bench4Q-Web/.project /Bench4Q-Agent/logs
/Bench4Q-Web/.classpath
/Bench4Q-Web/.settings /Bench4Q-Web/.project
/Bench4Q-Web/target /Bench4Q-Web/.classpath
/Bench4Q-Web/logs /Bench4Q-Web/.settings
/Bench4Q-Web/target
/Bench4Q-Monitor/.project /Bench4Q-Web/logs
/Bench4Q-Monitor/.classpath
/Bench4Q-Monitor/.settings /Bench4Q-Monitor/.project
/Bench4Q-Monitor/target /Bench4Q-Monitor/.classpath
/Bench4Q-Monitor/logs /Bench4Q-Monitor/.settings
/Bench4Q-Monitor/target
/Bench4Q-Share/.project /Bench4Q-Monitor/logs
/Bench4Q-Share/.classpath
/Bench4Q-Share/.settings /Bench4Q-Share/.project
/Bench4Q-Share/target /Bench4Q-Share/.classpath
/Bench4Q-Share/.settings
/Bench4Q-Share/target
/Bench4Q-Share/logs /Bench4Q-Share/logs

View File

@ -1 +0,0 @@
row1;10;11~row2;20;21~row3,30,31~

View File

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<runScenario>
<batches>
<batches>
<behaviors>
<behaviors>
<id>1</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>http://www.baidu.com
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<use>http</use>
</behaviors>
</behaviors>
<childId>-1</childId>
<id>0</id>
<parentId>-1</parentId>
</batches>
</batches>
<poolSize>0</poolSize>
<usePlugins>
<usePlugin>
<id>http</id>
<name>Http</name>
<parameters />
</usePlugin>
<usePlugin>
<id>timer</id>
<name>ConstantTimer</name>
<parameters />
</usePlugin>
</usePlugins>
</runScenario>

View File

@ -1,397 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<runScenario>
<definedParams>
<definedParam>
<name>param_HBase</name>
<pickOrder>sequencial</pickOrder>
<type>Ppara_Table</type>
<updateStrategy>Once</updateStrategy>
</definedParam>
</definedParams>
<pages>
<page>
<batches>
<batch>
<behaviors>
<behaviorModel>
<id>0</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>1</value>
</parameter>
<parameter>
<key>endUser</key>
<value>100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>1</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>2</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>2001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>2100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>3</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>4</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>4001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>4100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>5</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>6</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>6001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>6100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>7</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>8</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>8001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>8100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>9</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>10</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>10001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>10100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>11</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>12</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>12001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>12100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>13</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>14</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>14001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>14100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>15</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>16</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>16001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>16100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>17</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>18</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>18001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>18100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>19</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
</behaviors>
<childId>-1</childId>
<id>0</id>
<parentId>-1</parentId>
</batch>
</batches>
</page>
</pages>
<poolSize>1</poolSize>
<usePlugins>
<usePlugin>
<id>hBase</id>
<name>Hbase</name>
<parameters />
</usePlugin>
<usePlugin>
<id>timer</id>
<name>ConstantTimer</name>
<parameters />
</usePlugin>
</usePlugins>
</runScenario>

View File

@ -1,17 +0,0 @@
<behaviorModel>
<id>0</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>http://133.133.12.3:8080/Bench4QTestCase/testcase.html
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>http</use>
</behaviorModel>

File diff suppressed because it is too large Load Diff

View File

@ -1,146 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<runScenario>
<batches>
<batch>
<behaviors>
<userBehavior>
<id>1</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>http://133.133.12.3:8080/Bench4QTestCase/testcase.html
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<use>http</use>
</userBehavior>
</behaviors>
<childId>2</childId>
<id>0</id>
<parentId>-1</parentId>
</batch>
<batch>
<behaviors>
<timerBehavior>
<id>0</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>2500</value>
</parameter>
</parameters>
<use>timer</use>
</timerBehavior>
</behaviors>
<childId>-1</childId>
<id>1</id>
<parentId>-1</parentId>
</batch>
<batch>
<behaviors>
<userBehavior>
<id>3</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>http://133.133.12.3:8080/Bench4QTestCase/images/3.jpg
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<use>http</use>
</userBehavior>
<userBehavior>
<id>4</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>http://133.133.12.3:8080/Bench4QTestCase/script/agentTable.js
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<use>http</use>
</userBehavior>
<userBehavior>
<id>5</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>http://133.133.12.3:8080/Bench4QTestCase/script/base.js
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<use>http</use>
</userBehavior>
<userBehavior>
<id>6</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>http://133.133.12.3:8080/Bench4QTestCase/images/1.jpg
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<use>http</use>
</userBehavior>
<userBehavior>
<id>7</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>http://133.133.12.3:8080/Bench4QTestCase/images/2.jpg
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<use>http</use>
</userBehavior>
</behaviors>
<childId>-1</childId>
<id>2</id>
<parentId>0</parentId>
</batch>
</batches>
<poolSize>0</poolSize>
<usePlugins>
<usePlugin>
<id>http</id>
<name>Http</name>
<parameters />
</usePlugin>
<usePlugin>
<id>timer</id>
<name>ConstantTimer</name>
<parameters />
</usePlugin>
</usePlugins>
</runScenario>

View File

@ -1,234 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<runScenario>
<pages>
<page>
<batches>
<batch>
<behaviors>
<behaviorModel>
<id>0</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>
http://133.133.12.3:8080/Bench4QTestCase/testcase.html
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>http</use>
</behaviorModel>
</behaviors>
<childId>2</childId>
<id>0</id>
<parentId>-1</parentId>
</batch>
<batch>
<behaviors>
<behaviorModel>
<id>0</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>230</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
</behaviors>
<childId>-1</childId>
<id>1</id>
<parentId>-1</parentId>
</batch>
<batch>
<behaviors>
<behaviorModel>
<id>1</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>http://133.133.12.3:8080/Bench4QTestCase/script/agentTable.js
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>http</use>
</behaviorModel>
<behaviorModel>
<id>2</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>http://133.133.12.3:8080/Bench4QTestCase/images/3.jpg
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>http</use>
</behaviorModel>
<behaviorModel>
<id>3</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>http://133.133.12.3:8080/Bench4QTestCase/script/base.js
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>http</use>
</behaviorModel>
<behaviorModel>
<id>4</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>http://133.133.12.3:8080/Bench4QTestCase/images/1.jpg
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>http</use>
</behaviorModel>
<behaviorModel>
<id>5</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>http://133.133.12.3:8080/Bench4QTestCase/images/2.jpg
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>http</use>
</behaviorModel>
</behaviors>
<childId>-1</childId>
<id>2</id>
<parentId>0</parentId>
</batch>
<batch>
<behaviors>
<behaviorModel>
<id>0</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>96</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
</behaviors>
<childId>-1</childId>
<id>3</id>
<parentId>-1</parentId>
</batch>
<batch>
<behaviors>
<behaviorModel>
<id>0</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>3</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
</behaviors>
<childId>-1</childId>
<id>4</id>
<parentId>-1</parentId>
</batch>
<batch>
<behaviors>
<behaviorModel>
<id>0</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>10</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
</behaviors>
<childId>-1</childId>
<id>5</id>
<parentId>-1</parentId>
</batch>
<batch>
<behaviors>
<behaviorModel>
<id>0</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>6</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
</behaviors>
<childId>-1</childId>
<id>6</id>
<parentId>-1</parentId>
</batch>
</batches>
</page>
</pages>
<poolSize>0</poolSize>
<usePlugins>
<usePlugin>
<id>http</id>
<name>Http</name>
<parameters />
</usePlugin>
<usePlugin>
<id>timer</id>
<name>ConstantTimer</name>
<parameters />
</usePlugin>
</usePlugins>
</runScenario>

View File

@ -1,66 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<runScenario>
<pages>
<page>
<batches>
<batch>
<behaviors>
<behaviorModel>
<id>0</id>
<name>Get</name>
<parameters>
<parameter>
<key>url</key>
<value>
http://www.baidu.com
</value>
</parameter>
<parameter>
<key>parameters</key>
<value></value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>http</use>
</behaviorModel>
</behaviors>
<childId>2</childId>
<id>0</id>
<parentId>-1</parentId>
</batch>
<batch>
<behaviors>
<behaviorModel>
<id>0</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>230</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
</behaviors>
<childId>-1</childId>
<id>1</id>
<parentId>-1</parentId>
</batch>
</batches>
</page>
</pages>
<poolSize>0</poolSize>
<usePlugins>
<usePlugin>
<id>http</id>
<name>Http</name>
<parameters />
</usePlugin>
<usePlugin>
<id>timer</id>
<name>ConstantTimer</name>
<parameters />
</usePlugin>
</usePlugins>
</runScenario>

View File

@ -1,9 +1,9 @@
package org.bench4q.agent.plugin.basic.hbase; package org.bench4q.agent.plugin.basic.hbase;
import org.bench4q.agent.plugin.basic.PluginReturn; import org.bench4q.agent.plugin.basic.PluginReturn;
public class ElectReturn extends PluginReturn { public class ElectReturn extends PluginReturn {
public ElectReturn(int succ, int fail) { public ElectReturn(int succ, int fail) {
super(succ, fail); super(succ, fail);
} }
} }

View File

@ -1,16 +1,16 @@
<html> <html>
<head> <head>
<title>Bench4Q Test Case</title> <title>Bench4Q Test Case</title>
<link href="style/bootstrap-cerulean.css" /> <link href="style/bootstrap-cerulean.css" />
<link href="style/bootstrap-classic.css" /> <link href="style/bootstrap-classic.css" />
<link href="style/bootstrap-cerulean.css" /> <link href="style/bootstrap-cerulean.css" />
</head> </head>
<body> <body>
<img src="images/1.jpg" alt="No this one" /> <img src="images/1.jpg" alt="No this one" />
<img src="images/2.jpg" alt="No this one" /> <img src="images/2.jpg" alt="No this one" />
<img src="images/3.jpg" alt="No this one" /> <img src="images/3.jpg" alt="No this one" />
<script src="script/agentTable.js" type="text/javascript"></script> <script src="script/agentTable.js" type="text/javascript"></script>
<script src="script/base.js" type="text/javascript"></script> <script src="script/base.js" type="text/javascript"></script>
</body> </body>
</html> </html>

View File

@ -1,390 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<runScenario>
<definedParams />
<pages>
<page>
<batches>
<batch>
<behaviors>
<behaviorModel>
<id>0</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>1</value>
</parameter>
<parameter>
<key>endUser</key>
<value>100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>1</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>2</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>2001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>2100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>3</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>4</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>4001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>4100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>5</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>6</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>6001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>6100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>7</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>8</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>8001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>8100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>9</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>10</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>10001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>10100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>11</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>12</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>12001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>12100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>13</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>14</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>14001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>14100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>15</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>16</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>16001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>16100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>17</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>18</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>18001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>18100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>19</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
</behaviors>
<childId>-1</childId>
<id>0</id>
<parentId>-1</parentId>
</batch>
</batches>
</page>
</pages>
<poolSize>1</poolSize>
<usePlugins>
<usePlugin>
<id>hBase</id>
<name>Hbase</name>
<parameters />
</usePlugin>
<usePlugin>
<id>timer</id>
<name>ConstantTimer</name>
<parameters />
</usePlugin>
</usePlugins>
</runScenario>

View File

@ -1,25 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<assembly <assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>publish</id> <id>publish</id>
<formats> <formats>
<format>tar.gz</format> <format>tar.gz</format>
</formats> </formats>
<includeBaseDirectory>false</includeBaseDirectory> <includeBaseDirectory>false</includeBaseDirectory>
<dependencySets> <dependencySets>
<dependencySet> <dependencySet>
<outputDirectory>lib</outputDirectory> <outputDirectory>lib</outputDirectory>
<useProjectArtifact>false</useProjectArtifact> <useProjectArtifact>false</useProjectArtifact>
<unpack>false</unpack> <unpack>false</unpack>
<scope>runtime</scope> <scope>runtime</scope>
</dependencySet> </dependencySet>
</dependencySets> </dependencySets>
<files> <files>
<file> <file>
<source>target/bench4q-master.jar</source> <source>target/bench4q-master.jar</source>
<outputDirectory>/</outputDirectory> <outputDirectory>/</outputDirectory>
</file> </file>
</files> </files>
</assembly> </assembly>

View File

@ -1,180 +1,180 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.bench4q</groupId> <groupId>org.bench4q</groupId>
<artifactId>bench4q-master</artifactId> <artifactId>bench4q-master</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.0 Beta</version> <version>1.0 Beta</version>
<name>Bench4Q Master</name> <name>Bench4Q Master</name>
<description>Bench4Q Master</description> <description>Bench4Q Master</description>
<organization> <organization>
<name>TCSE, ISCAS</name> <name>TCSE, ISCAS</name>
</organization> </organization>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>2.2.4</version> <version>2.2.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.11</version> <version>4.11</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId> <artifactId>spring-webmvc</artifactId>
<version>3.2.5.RELEASE</version> <version>3.2.5.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.jackson</groupId> <groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId> <artifactId>jackson-mapper-asl</artifactId>
<version>1.9.12</version> <version>1.9.12</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId> <artifactId>hibernate-core</artifactId>
<version>4.3.0.Beta3</version> <version>4.3.0.Beta3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.hibernate.javax.persistence</groupId> <groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId> <artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Draft-16</version> <version>1.0.0.Draft-16</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version> <version>5.1.25</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j</artifactId>
<version>1.2.17</version> <version>1.2.17</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-httpclient</groupId> <groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId> <artifactId>commons-httpclient</artifactId>
<version>3.1</version> <version>3.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.python</groupId> <groupId>org.python</groupId>
<artifactId>jython</artifactId> <artifactId>jython</artifactId>
<version>2.7-b1</version> <version>2.7-b1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId> <artifactId>spring-test</artifactId>
<version>3.2.5.RELEASE</version> <version>3.2.5.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.quartz-scheduler</groupId> <groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId> <artifactId>quartz</artifactId>
<version>1.8.5</version> <version>1.8.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId> <artifactId>spring-core</artifactId>
<version>3.2.5.RELEASE</version> <version>3.2.5.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId> <artifactId>slf4j-simple</artifactId>
<version>1.7.5</version> <version>1.7.5</version>
</dependency> </dependency>
<!-- this is used to create chart for report --> <!-- this is used to create chart for report -->
<dependency> <dependency>
<groupId>jfree</groupId> <groupId>jfree</groupId>
<artifactId>jfreechart</artifactId> <artifactId>jfreechart</artifactId>
<version>1.0.13</version> <version>1.0.13</version>
</dependency> </dependency>
<!-- this is used to create a pdf report --> <!-- this is used to create a pdf report -->
<dependency> <dependency>
<groupId>org.eclipse.birt.runtime.3_7_1</groupId> <groupId>org.eclipse.birt.runtime.3_7_1</groupId>
<artifactId>com.lowagie.text</artifactId> <artifactId>com.lowagie.text</artifactId>
<version>2.1.7</version> <version>2.1.7</version>
</dependency> </dependency>
<!-- for file utils --> <!-- for file utils -->
<dependency> <dependency>
<groupId>org.apache.portals.jetspeed-2</groupId> <groupId>org.apache.portals.jetspeed-2</groupId>
<artifactId>jetspeed-fileutils-maven-plugin</artifactId> <artifactId>jetspeed-fileutils-maven-plugin</artifactId>
<version>2.2.2</version> <version>2.2.2</version>
<type>maven-plugin</type> <type>maven-plugin</type>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bench4q</groupId> <groupId>org.bench4q</groupId>
<artifactId>bench4q-share</artifactId> <artifactId>bench4q-share</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId> <artifactId>jetty-servlet</artifactId>
<version>9.1.0.RC2</version> <version>9.1.0.RC2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId> <artifactId>jetty-server</artifactId>
<version>9.1.0.RC2</version> <version>9.1.0.RC2</version>
</dependency> </dependency>
<!-- this is used to parse html dom tree --> <!-- this is used to parse html dom tree -->
<dependency> <dependency>
<groupId>org.jsoup</groupId> <groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId> <artifactId>jsoup</artifactId>
<version>1.7.3</version> <version>1.7.3</version>
</dependency> </dependency>
<!-- this is used to parse http request and response --> <!-- this is used to parse http request and response -->
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore-nio</artifactId> <artifactId>httpcore-nio</artifactId>
<version>4.3</version> <version>4.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bench4q</groupId> <groupId>org.bench4q</groupId>
<artifactId>bench4q-recorder</artifactId> <artifactId>bench4q-recorder</artifactId>
<version>1.0-Beta</version> <version>1.0-Beta</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<configuration> <configuration>
<archive> <archive>
<manifest> <manifest>
<mainClass>org.bench4q.master.Main</mainClass> <mainClass>org.bench4q.master.Main</mainClass>
<addClasspath>true</addClasspath> <addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix> <classpathPrefix>lib/</classpathPrefix>
</manifest> </manifest>
</archive> </archive>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>make-zip</id> <id>make-zip</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>single</goal> <goal>single</goal>
</goals> </goals>
<configuration> <configuration>
<descriptors> <descriptors>
<descriptor>descriptor.xml</descriptor> <descriptor>descriptor.xml</descriptor>
</descriptors> </descriptors>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<configuration> <configuration>
<skip>true</skip> <skip>true</skip>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
<finalName>bench4q-master</finalName> <finalName>bench4q-master</finalName>
</build> </build>
</project> </project>

View File

@ -1,165 +1,165 @@
package org.bench4q.master.api; package org.bench4q.master.api;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.bench4q.master.domain.service.PluginService; import org.bench4q.master.domain.service.PluginService;
import org.bench4q.master.domain.service.UserService; import org.bench4q.master.domain.service.UserService;
import org.bench4q.master.exception.Bench4QException; import org.bench4q.master.exception.Bench4QException;
import org.bench4q.master.exception.ExceptionLog; import org.bench4q.master.exception.ExceptionLog;
import org.bench4q.share.models.master.plugin.PluginGUI; import org.bench4q.share.models.master.plugin.PluginGUI;
import org.bench4q.share.models.master.plugin.PluginResponseModel; import org.bench4q.share.models.master.plugin.PluginResponseModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
@Controller @Controller
@RequestMapping("/plugin") @RequestMapping("/plugin")
public class PluginController extends BaseController { public class PluginController extends BaseController {
private Logger logger = Logger.getLogger(PluginController.class); private Logger logger = Logger.getLogger(PluginController.class);
private PluginService pluginService; private PluginService pluginService;
public PluginService getPluginService() { public PluginService getPluginService() {
return pluginService; return pluginService;
} }
@Autowired @Autowired
public void setPluginService(PluginService pluginService) { public void setPluginService(PluginService pluginService) {
this.pluginService = pluginService; this.pluginService = pluginService;
} }
@RequestMapping("/loadPluginList") @RequestMapping("/loadPluginList")
@ResponseBody @ResponseBody
public PluginResponseModel loadPluginList() throws Bench4QException { public PluginResponseModel loadPluginList() throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) { if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(400 + "", "not permitted", throw new Bench4QException(400 + "", "not permitted",
"/loadPluginList"); "/loadPluginList");
} }
PluginResponseModel pluginResponseModel = new PluginResponseModel(); PluginResponseModel pluginResponseModel = new PluginResponseModel();
pluginResponseModel.setPluginList(this.getPluginService() pluginResponseModel.setPluginList(this.getPluginService()
.getPluginNameList()); .getPluginNameList());
pluginResponseModel.setSuccess(true); pluginResponseModel.setSuccess(true);
return pluginResponseModel; return pluginResponseModel;
} }
@RequestMapping(value = "loadMethods/{pluginName}", method = { @RequestMapping(value = "loadMethods/{pluginName}", method = {
RequestMethod.GET, RequestMethod.POST }) RequestMethod.GET, RequestMethod.POST })
@ResponseBody @ResponseBody
public PluginResponseModel getMethods( public PluginResponseModel getMethods(
@PathVariable("pluginName") String pluginName) @PathVariable("pluginName") String pluginName)
throws Bench4QException { throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) { if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(400 + "", "not permitted", throw new Bench4QException(400 + "", "not permitted",
"/loadMethods/{pluginName}"); "/loadMethods/{pluginName}");
} }
PluginResponseModel pluginResponseModel = new PluginResponseModel(); PluginResponseModel pluginResponseModel = new PluginResponseModel();
try { try {
pluginResponseModel.setMethodModels(this.getPluginService() pluginResponseModel.setMethodModels(this.getPluginService()
.getMethodsInPlugin(pluginName)); .getMethodsInPlugin(pluginName));
pluginResponseModel.setSuccess(true); pluginResponseModel.setSuccess(true);
return pluginResponseModel; return pluginResponseModel;
} catch (Exception e) { } catch (Exception e) {
logger.error(ExceptionLog.getStackTrace(e)); logger.error(ExceptionLog.getStackTrace(e));
pluginResponseModel.setSuccess(false); pluginResponseModel.setSuccess(false);
return pluginResponseModel; return pluginResponseModel;
} }
} }
@RequestMapping(value = "loadMethodList/{pluginName}", method = { @RequestMapping(value = "loadMethodList/{pluginName}", method = {
RequestMethod.GET, RequestMethod.POST }) RequestMethod.GET, RequestMethod.POST })
@ResponseBody @ResponseBody
public PluginResponseModel getMethodList( public PluginResponseModel getMethodList(
@PathVariable("pluginName") String pluginName) @PathVariable("pluginName") String pluginName)
throws Bench4QException { throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) { if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(400 + "", "not permitted", throw new Bench4QException(400 + "", "not permitted",
"/loadMethodList/{pluginName}"); "/loadMethodList/{pluginName}");
} }
PluginResponseModel pluginResponseModel = new PluginResponseModel(); PluginResponseModel pluginResponseModel = new PluginResponseModel();
try { try {
pluginResponseModel.setMethodList(this.getPluginService() pluginResponseModel.setMethodList(this.getPluginService()
.getMethodNameInPlugin(pluginName)); .getMethodNameInPlugin(pluginName));
pluginResponseModel.setSuccess(true); pluginResponseModel.setSuccess(true);
return pluginResponseModel; return pluginResponseModel;
} catch (Exception e) { } catch (Exception e) {
logger.error(ExceptionLog.getStackTrace(e)); logger.error(ExceptionLog.getStackTrace(e));
pluginResponseModel.setSuccess(false); pluginResponseModel.setSuccess(false);
return pluginResponseModel; return pluginResponseModel;
} }
} }
@RequestMapping(value = "loadMethodParams/{pluginName}/{methodName}", method = { @RequestMapping(value = "loadMethodParams/{pluginName}/{methodName}", method = {
RequestMethod.GET, RequestMethod.POST }) RequestMethod.GET, RequestMethod.POST })
@ResponseBody @ResponseBody
public PluginResponseModel getMethodParams( public PluginResponseModel getMethodParams(
@PathVariable("pluginName") String pluginName, @PathVariable("pluginName") String pluginName,
@PathVariable("methodName") String methodName) @PathVariable("methodName") String methodName)
throws Bench4QException { throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) { if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(400 + "", "not permitted", throw new Bench4QException(400 + "", "not permitted",
"loadMethodParams/{pluginName}/{methodName}"); "loadMethodParams/{pluginName}/{methodName}");
} }
PluginResponseModel pluginResponseModel = new PluginResponseModel(); PluginResponseModel pluginResponseModel = new PluginResponseModel();
pluginResponseModel.setMethosMethodParamModels(this.getPluginService() pluginResponseModel.setMethosMethodParamModels(this.getPluginService()
.getMethodParamModelsInPlugin(pluginName, methodName)); .getMethodParamModelsInPlugin(pluginName, methodName));
pluginResponseModel.setSuccess(true); pluginResponseModel.setSuccess(true);
return pluginResponseModel; return pluginResponseModel;
} }
@RequestMapping(value = "/addPlugin", method = { RequestMethod.PUT }) @RequestMapping(value = "/addPlugin", method = { RequestMethod.PUT })
@ResponseBody @ResponseBody
public PluginResponseModel addPlugin(@RequestBody PluginGUI pluginGUI) public PluginResponseModel addPlugin(@RequestBody PluginGUI pluginGUI)
throws Bench4QException { throws Bench4QException {
if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) { if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
throw new Bench4QException(400 + "", "not permitted", throw new Bench4QException(400 + "", "not permitted",
"addPlugin/{pluginName}/{methodName}"); "addPlugin/{pluginName}/{methodName}");
} }
PluginResponseModel pluginResponseModel = validatePlugin(pluginGUI); PluginResponseModel pluginResponseModel = validatePlugin(pluginGUI);
if (pluginResponseModel.isSuccess()) { if (pluginResponseModel.isSuccess()) {
pluginResponseModel.setSuccess(this.getPluginService().addPlugin( pluginResponseModel.setSuccess(this.getPluginService().addPlugin(
pluginGUI.getPlugin())); pluginGUI.getPlugin()));
} }
return pluginResponseModel; return pluginResponseModel;
} }
@RequestMapping(value = "/deletePlugin/{pluginName}", method = { @RequestMapping(value = "/deletePlugin/{pluginName}", method = {
RequestMethod.GET, RequestMethod.POST }) RequestMethod.GET, RequestMethod.POST })
@ResponseBody @ResponseBody
public PluginResponseModel deletePlugin( public PluginResponseModel deletePlugin(
@PathVariable("pluginName") String pluginName) @PathVariable("pluginName") String pluginName)
throws Bench4QException { throws Bench4QException {
if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) { if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
throw new Bench4QException(400 + "", "not permitted", throw new Bench4QException(400 + "", "not permitted",
"loadMethodParams/{pluginName}/{methodName}"); "loadMethodParams/{pluginName}/{methodName}");
} }
PluginResponseModel pluginResponseModel = new PluginResponseModel(); PluginResponseModel pluginResponseModel = new PluginResponseModel();
pluginResponseModel.setSuccess(this.getPluginService().deletePlugin( pluginResponseModel.setSuccess(this.getPluginService().deletePlugin(
pluginName)); pluginName));
return pluginResponseModel; return pluginResponseModel;
} }
private PluginResponseModel validatePlugin(PluginGUI pluginGUI) { private PluginResponseModel validatePlugin(PluginGUI pluginGUI) {
PluginResponseModel pluginResponseModel = new PluginResponseModel(); PluginResponseModel pluginResponseModel = new PluginResponseModel();
pluginResponseModel.setSuccess(true); pluginResponseModel.setSuccess(true);
if (pluginGUI.getPlugin() == null) { if (pluginGUI.getPlugin() == null) {
pluginResponseModel.setSuccess(false); pluginResponseModel.setSuccess(false);
pluginResponseModel.setFailMessage("plugin is null"); pluginResponseModel.setFailMessage("plugin is null");
} }
if (pluginGUI.getPlugin().getMethods() == null if (pluginGUI.getPlugin().getMethods() == null
|| pluginGUI.getPlugin().getMethods().size() == 0) { || pluginGUI.getPlugin().getMethods().size() == 0) {
pluginResponseModel.setSuccess(false); pluginResponseModel.setSuccess(false);
pluginResponseModel.setFailMessage("method is empty"); pluginResponseModel.setFailMessage("method is empty");
} }
return pluginResponseModel; return pluginResponseModel;
} }
} }

View File

@ -1,60 +1,60 @@
package org.bench4q.master.domain.entity.plugin; package org.bench4q.master.domain.entity.plugin;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
@Entity @Entity
@Table(name = "methodParamProperty") @Table(name = "methodParamProperty")
public class MethodParamProperty { public class MethodParamProperty {
private int id; private int id;
private String propertyKey; private String propertyKey;
private String propertyValue; private String propertyValue;
private MethodParam methodParam; private MethodParam methodParam;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false) @Column(name = "id", nullable = false)
public int getId() { public int getId() {
return id; return id;
} }
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@Column(name = "propertyKey", nullable = false) @Column(name = "propertyKey", nullable = false)
public String getPropertyKey() { public String getPropertyKey() {
return propertyKey; return propertyKey;
} }
public void setPropertyKey(String propertyKey) { public void setPropertyKey(String propertyKey) {
this.propertyKey = propertyKey; this.propertyKey = propertyKey;
} }
@Column(name = "propertyValue", nullable = false) @Column(name = "propertyValue", nullable = false)
public String getPropertyValue() { public String getPropertyValue() {
return propertyValue; return propertyValue;
} }
public void setPropertyValue(String propertyValue) { public void setPropertyValue(String propertyValue) {
this.propertyValue = propertyValue; this.propertyValue = propertyValue;
} }
@ManyToOne @ManyToOne
@JoinColumn(name = "methodParamId") @JoinColumn(name = "methodParamId")
public MethodParam getMethodParam() { public MethodParam getMethodParam() {
return methodParam; return methodParam;
} }
public void setMethodParam(MethodParam methodParam) { public void setMethodParam(MethodParam methodParam) {
this.methodParam = methodParam; this.methodParam = methodParam;
} }
} }

View File

@ -1,41 +1,41 @@
package org.bench4q.master.domain.entity.plugin; package org.bench4q.master.domain.entity.plugin;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EnumType; import javax.persistence.EnumType;
import javax.persistence.Enumerated; import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.bench4q.share.models.master.plugin.ParamTypeEnum; import org.bench4q.share.models.master.plugin.ParamTypeEnum;
@Entity @Entity
@Table(name = "paramType") @Table(name = "paramType")
public class ParamType { public class ParamType {
private int id; private int id;
private ParamTypeEnum type; private ParamTypeEnum type;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false) @Column(name = "id", nullable = false)
public int getId() { public int getId() {
return id; return id;
} }
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@Column(name="type",columnDefinition = "ENUM('Field', 'MultiField', 'Table','CheckBox')") @Column(name="type",columnDefinition = "ENUM('Field', 'MultiField', 'Table','CheckBox')")
public ParamTypeEnum getType() { public ParamTypeEnum getType() {
return type; return type;
} }
public void setType(ParamTypeEnum type) { public void setType(ParamTypeEnum type) {
this.type = type; this.type = type;
} }
} }

View File

@ -1,148 +1,148 @@
package org.bench4q.master.domain.factory; package org.bench4q.master.domain.factory;
import java.util.HashSet; import java.util.HashSet;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.bench4q.master.domain.entity.plugin.Method; import org.bench4q.master.domain.entity.plugin.Method;
import org.bench4q.master.domain.entity.plugin.MethodParam; import org.bench4q.master.domain.entity.plugin.MethodParam;
import org.bench4q.master.domain.entity.plugin.MethodParamProperty; import org.bench4q.master.domain.entity.plugin.MethodParamProperty;
import org.bench4q.master.domain.entity.plugin.ParamType; import org.bench4q.master.domain.entity.plugin.ParamType;
import org.bench4q.master.domain.entity.plugin.Plugin; import org.bench4q.master.domain.entity.plugin.Plugin;
import org.bench4q.master.domain.repository.PluginRepository; import org.bench4q.master.domain.repository.PluginRepository;
import org.bench4q.master.exception.Bench4QException; import org.bench4q.master.exception.Bench4QException;
import org.bench4q.share.models.master.plugin.MethodModel; import org.bench4q.share.models.master.plugin.MethodModel;
import org.bench4q.share.models.master.plugin.MethodParamModel; import org.bench4q.share.models.master.plugin.MethodParamModel;
import org.bench4q.share.models.master.plugin.MethodParamPropertyModel; import org.bench4q.share.models.master.plugin.MethodParamPropertyModel;
import org.bench4q.share.models.master.plugin.ParamTypeEnum; import org.bench4q.share.models.master.plugin.ParamTypeEnum;
import org.bench4q.share.models.master.plugin.PluginModel; import org.bench4q.share.models.master.plugin.PluginModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
public class PluginFactory { public class PluginFactory {
private PluginRepository pluginRepository; private PluginRepository pluginRepository;
public PluginRepository getPluginRepository() { public PluginRepository getPluginRepository() {
return pluginRepository; return pluginRepository;
} }
@Autowired @Autowired
public void setPluginRepository(PluginRepository pluginRepository) { public void setPluginRepository(PluginRepository pluginRepository) {
this.pluginRepository = pluginRepository; this.pluginRepository = pluginRepository;
} }
public Plugin createPluginEntity(PluginModel pluginModel) public Plugin createPluginEntity(PluginModel pluginModel)
throws Bench4QException { throws Bench4QException {
Plugin plugin = new Plugin(); Plugin plugin = new Plugin();
plugin.setPluginMethods(new HashSet<Method>()); plugin.setPluginMethods(new HashSet<Method>());
if (pluginModel.getMethods() != null) { if (pluginModel.getMethods() != null) {
for (MethodModel methodModel : pluginModel.getMethods()) { for (MethodModel methodModel : pluginModel.getMethods()) {
plugin.getPluginMethods().add( plugin.getPluginMethods().add(
createMethodEntity(methodModel, plugin)); createMethodEntity(methodModel, plugin));
} }
plugin.setName(pluginModel.getName()); plugin.setName(pluginModel.getName());
return plugin; return plugin;
} else } else
throw new Bench4QException("", "no method in plugin", ""); throw new Bench4QException("", "no method in plugin", "");
} }
private Method createMethodEntity(MethodModel methodModel, Plugin plugin) private Method createMethodEntity(MethodModel methodModel, Plugin plugin)
throws Bench4QException { throws Bench4QException {
Method method = new Method(); Method method = new Method();
method.setMethodParams(new HashSet<MethodParam>()); method.setMethodParams(new HashSet<MethodParam>());
method.setName(methodModel.getName()); method.setName(methodModel.getName());
if (methodModel.getMethodParams() != null) { if (methodModel.getMethodParams() != null) {
for (MethodParamModel methodParamModel : methodModel for (MethodParamModel methodParamModel : methodModel
.getMethodParams()) { .getMethodParams()) {
Logger.getLogger(PluginFactory.class).info( Logger.getLogger(PluginFactory.class).info(
"method model:" + methodModel.getName()); "method model:" + methodModel.getName());
method.getMethodParams().add( method.getMethodParams().add(
createMethodParamEntity(methodParamModel, method)); createMethodParamEntity(methodParamModel, method));
} }
} }
method.setPlugin(plugin); method.setPlugin(plugin);
return method; return method;
} }
private MethodParam createMethodParamEntity( private MethodParam createMethodParamEntity(
MethodParamModel methodParamModel, Method method) MethodParamModel methodParamModel, Method method)
throws Bench4QException { throws Bench4QException {
MethodParam methodParam = new MethodParam(); MethodParam methodParam = new MethodParam();
methodParam.setLable(methodParamModel.getLable()); methodParam.setLable(methodParamModel.getLable());
methodParam.setName(methodParamModel.getName()); methodParam.setName(methodParamModel.getName());
methodParam.setMethod(method); methodParam.setMethod(method);
methodParam.setParamType(createPraParamTypeWithOutId(methodParamModel methodParam.setParamType(createPraParamTypeWithOutId(methodParamModel
.getParamType())); .getParamType()));
if (methodParamModel.getMethodParamProperties() != null) { if (methodParamModel.getMethodParamProperties() != null) {
methodParam methodParam
.setMethodParamProperties(new HashSet<MethodParamProperty>()); .setMethodParamProperties(new HashSet<MethodParamProperty>());
for (MethodParamPropertyModel methodParamPropertyModel : methodParamModel for (MethodParamPropertyModel methodParamPropertyModel : methodParamModel
.getMethodParamProperties()) { .getMethodParamProperties()) {
methodParam.getMethodParamProperties().add( methodParam.getMethodParamProperties().add(
createMethodParamPropertyWithOutId( createMethodParamPropertyWithOutId(
methodParamPropertyModel, methodParam)); methodParamPropertyModel, methodParam));
} }
} }
return methodParam; return methodParam;
} }
private ParamType createPraParamTypeWithOutId(ParamTypeEnum paramTypeEnum) private ParamType createPraParamTypeWithOutId(ParamTypeEnum paramTypeEnum)
throws Bench4QException { throws Bench4QException {
return this.getPluginRepository().getParamTypeByType(paramTypeEnum); return this.getPluginRepository().getParamTypeByType(paramTypeEnum);
} }
private MethodParamProperty createMethodParamPropertyWithOutId( private MethodParamProperty createMethodParamPropertyWithOutId(
MethodParamPropertyModel methodParamPropertyModel, MethodParamPropertyModel methodParamPropertyModel,
MethodParam methodParam) { MethodParam methodParam) {
MethodParamProperty methodParamProperty = new MethodParamProperty(); MethodParamProperty methodParamProperty = new MethodParamProperty();
methodParamProperty.setPropertyKey(methodParamPropertyModel.getKey()); methodParamProperty.setPropertyKey(methodParamPropertyModel.getKey());
methodParamProperty.setPropertyValue(methodParamPropertyModel methodParamProperty.setPropertyValue(methodParamPropertyModel
.getValue()); .getValue());
methodParamProperty.setMethodParam(methodParam); methodParamProperty.setMethodParam(methodParam);
return methodParamProperty; return methodParamProperty;
} }
public static MethodModel extractMethodModel(Method method) { public static MethodModel extractMethodModel(Method method) {
MethodModel methodModel = new MethodModel(); MethodModel methodModel = new MethodModel();
methodModel.setName(method.getName()); methodModel.setName(method.getName());
if (method.getMethodParams() != null) { if (method.getMethodParams() != null) {
methodModel.setMethodParams(new HashSet<MethodParamModel>()); methodModel.setMethodParams(new HashSet<MethodParamModel>());
for (MethodParam methodParam : method.getMethodParams()) { for (MethodParam methodParam : method.getMethodParams()) {
methodModel.getMethodParams().add( methodModel.getMethodParams().add(
extractMethodParamModel(methodParam)); extractMethodParamModel(methodParam));
} }
} }
return methodModel; return methodModel;
} }
private static MethodParamModel extractMethodParamModel( private static MethodParamModel extractMethodParamModel(
MethodParam methodParam) { MethodParam methodParam) {
MethodParamModel methodParamModel = new MethodParamModel(); MethodParamModel methodParamModel = new MethodParamModel();
methodParamModel.setLable(methodParam.getLable()); methodParamModel.setLable(methodParam.getLable());
methodParamModel.setName(methodParam.getName()); methodParamModel.setName(methodParam.getName());
methodParamModel.setParamType(methodParam.getParamType().getType()); methodParamModel.setParamType(methodParam.getParamType().getType());
if (methodParam.getMethodParamProperties() != null) { if (methodParam.getMethodParamProperties() != null) {
methodParamModel methodParamModel
.setMethodParamProperties(new HashSet<MethodParamPropertyModel>()); .setMethodParamProperties(new HashSet<MethodParamPropertyModel>());
for (MethodParamProperty methodParamProperty : methodParam for (MethodParamProperty methodParamProperty : methodParam
.getMethodParamProperties()) { .getMethodParamProperties()) {
methodParamModel.getMethodParamProperties().add( methodParamModel.getMethodParamProperties().add(
extractMethodParamPropertyModel(methodParamProperty)); extractMethodParamPropertyModel(methodParamProperty));
} }
} }
return methodParamModel; return methodParamModel;
} }
private static MethodParamPropertyModel extractMethodParamPropertyModel( private static MethodParamPropertyModel extractMethodParamPropertyModel(
MethodParamProperty methodParamProperty) { MethodParamProperty methodParamProperty) {
MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel(); MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel();
methodParamPropertyModel.setKey(methodParamProperty.getPropertyKey()); methodParamPropertyModel.setKey(methodParamProperty.getPropertyKey());
methodParamPropertyModel.setValue(methodParamProperty methodParamPropertyModel.setValue(methodParamProperty
.getPropertyValue()); .getPropertyValue());
return methodParamPropertyModel; return methodParamPropertyModel;
} }
} }

View File

@ -1,127 +1,127 @@
package org.bench4q.master.domain.service; package org.bench4q.master.domain.service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.bench4q.master.domain.entity.plugin.Plugin; import org.bench4q.master.domain.entity.plugin.Plugin;
import org.bench4q.master.domain.repository.PluginRepository; import org.bench4q.master.domain.repository.PluginRepository;
import org.bench4q.master.exception.Bench4QException; import org.bench4q.master.exception.Bench4QException;
import org.bench4q.master.domain.entity.plugin.Method; import org.bench4q.master.domain.entity.plugin.Method;
import org.bench4q.master.domain.factory.PluginFactory; import org.bench4q.master.domain.factory.PluginFactory;
import org.bench4q.share.models.master.plugin.MethodModel; import org.bench4q.share.models.master.plugin.MethodModel;
import org.bench4q.share.models.master.plugin.MethodParamModel; import org.bench4q.share.models.master.plugin.MethodParamModel;
import org.bench4q.share.models.master.plugin.PluginModel; import org.bench4q.share.models.master.plugin.PluginModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
public class PluginService { public class PluginService {
private PluginRepository pluginRepository; private PluginRepository pluginRepository;
private PluginFactory pluginFactory; private PluginFactory pluginFactory;
private Logger logger = Logger.getLogger(PluginService.class); private Logger logger = Logger.getLogger(PluginService.class);
public PluginRepository getPluginRepository() { public PluginRepository getPluginRepository() {
return pluginRepository; return pluginRepository;
} }
@Autowired @Autowired
private void setPluginRepository(PluginRepository pluginRepository) { private void setPluginRepository(PluginRepository pluginRepository) {
this.pluginRepository = pluginRepository; this.pluginRepository = pluginRepository;
} }
public PluginFactory getPluginFactory() { public PluginFactory getPluginFactory() {
return pluginFactory; return pluginFactory;
} }
@Autowired @Autowired
private void setPluginFactory(PluginFactory pluginFactory) { private void setPluginFactory(PluginFactory pluginFactory) {
this.pluginFactory = pluginFactory; this.pluginFactory = pluginFactory;
} }
public boolean addPlugin(PluginModel pluginModel) throws Bench4QException { public boolean addPlugin(PluginModel pluginModel) throws Bench4QException {
return this.getPluginRepository().attatch( return this.getPluginRepository().attatch(
this.getPluginFactory().createPluginEntity(pluginModel)); this.getPluginFactory().createPluginEntity(pluginModel));
} }
public boolean deletePlugin(String pluginName) throws Bench4QException { public boolean deletePlugin(String pluginName) throws Bench4QException {
return this.getPluginRepository().detach(pluginName); return this.getPluginRepository().detach(pluginName);
} }
public List<String> getPluginNameList() throws Bench4QException { public List<String> getPluginNameList() throws Bench4QException {
List<String> pluginNameList = new ArrayList<String>(); List<String> pluginNameList = new ArrayList<String>();
Set<Plugin> plugins = getPlugins(); Set<Plugin> plugins = getPlugins();
if (plugins != null) { if (plugins != null) {
for (Plugin plugin : plugins) { for (Plugin plugin : plugins) {
pluginNameList.add(plugin.getName()); pluginNameList.add(plugin.getName());
} }
} }
return pluginNameList; return pluginNameList;
} }
private Set<Plugin> getPlugins() throws Bench4QException { private Set<Plugin> getPlugins() throws Bench4QException {
List<Plugin> loadPluginList = this.getPluginRepository().loadPlugins(); List<Plugin> loadPluginList = this.getPluginRepository().loadPlugins();
Set<Plugin> plugins = new HashSet<Plugin>(); Set<Plugin> plugins = new HashSet<Plugin>();
if (loadPluginList != null) { if (loadPluginList != null) {
for (Plugin plugin : loadPluginList) { for (Plugin plugin : loadPluginList) {
plugins.add(plugin); plugins.add(plugin);
} }
} }
return plugins; return plugins;
} }
public List<String> getMethodNameInPlugin(String pluginName) { public List<String> getMethodNameInPlugin(String pluginName) {
List<String> methodNameList = new ArrayList<String>(); List<String> methodNameList = new ArrayList<String>();
Plugin plugin = this.getPluginRepository().getPlugin(pluginName); Plugin plugin = this.getPluginRepository().getPlugin(pluginName);
List<Method> methods = this.getPluginRepository().loadMethodsInPlugin( List<Method> methods = this.getPluginRepository().loadMethodsInPlugin(
plugin); plugin);
if (methods != null) { if (methods != null) {
for (Method method : methods) { for (Method method : methods) {
methodNameList.add(method.getName()); methodNameList.add(method.getName());
} }
} }
return methodNameList; return methodNameList;
} }
private Method getMethodInPlugin(String pluginName, String methodName) private Method getMethodInPlugin(String pluginName, String methodName)
throws Bench4QException { throws Bench4QException {
Plugin plugin = this.getPluginRepository().getPlugin(pluginName); Plugin plugin = this.getPluginRepository().getPlugin(pluginName);
List<Method> methods = this.getPluginRepository().loadMethodsInPlugin( List<Method> methods = this.getPluginRepository().loadMethodsInPlugin(
plugin); plugin);
if (methods != null) { if (methods != null) {
for (Method method : methods) { for (Method method : methods) {
if (method.getName().equals(methodName)) if (method.getName().equals(methodName))
return method; return method;
} }
} }
logger.info("method is empty"); logger.info("method is empty");
throw new Bench4QException("", "no such method:" + methodName throw new Bench4QException("", "no such method:" + methodName
+ "in plugin:" + pluginName, ""); + "in plugin:" + pluginName, "");
} }
public Set<MethodParamModel> getMethodParamModelsInPlugin( public Set<MethodParamModel> getMethodParamModelsInPlugin(
String pluginName, String methodName) throws Bench4QException { String pluginName, String methodName) throws Bench4QException {
return PluginFactory.extractMethodModel( return PluginFactory.extractMethodModel(
this.getMethodInPlugin(pluginName, methodName)) this.getMethodInPlugin(pluginName, methodName))
.getMethodParams(); .getMethodParams();
} }
public Set<MethodModel> getMethodsInPlugin(String pluginName) { public Set<MethodModel> getMethodsInPlugin(String pluginName) {
Plugin plugin = this.getPluginRepository().getPlugin(pluginName); Plugin plugin = this.getPluginRepository().getPlugin(pluginName);
Set<MethodModel> methodModels = new HashSet<MethodModel>(); Set<MethodModel> methodModels = new HashSet<MethodModel>();
for (Method method : this.getPluginRepository().loadMethodsInPlugin( for (Method method : this.getPluginRepository().loadMethodsInPlugin(
plugin)) { plugin)) {
methodModels.add(PluginFactory.extractMethodModel(method)); methodModels.add(PluginFactory.extractMethodModel(method));
} }
return methodModels; return methodModels;
} }
} }

View File

@ -1,178 +1,178 @@
package org.bench4q.master.domain.testplan; package org.bench4q.master.domain.testplan;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Observable; import java.util.Observable;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.bench4q.master.domain.entity.Monitor; import org.bench4q.master.domain.entity.Monitor;
import org.bench4q.master.domain.entity.MonitorResult; import org.bench4q.master.domain.entity.MonitorResult;
import org.bench4q.master.domain.entity.TestPlan; import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.domain.entity.TestPlanScript; import org.bench4q.master.domain.entity.TestPlanScript;
import org.bench4q.master.domain.entity.TestPlanScriptResult; import org.bench4q.master.domain.entity.TestPlanScriptResult;
import org.bench4q.master.domain.factory.TestPlanFactory; import org.bench4q.master.domain.factory.TestPlanFactory;
import org.bench4q.master.domain.repository.TestPlanRepository; import org.bench4q.master.domain.repository.TestPlanRepository;
import org.bench4q.master.exception.ExceptionLog; import org.bench4q.master.exception.ExceptionLog;
import org.bench4q.master.helper.SessionHelper; import org.bench4q.master.helper.SessionHelper;
import org.bench4q.share.models.master.statistics.ScriptResultModel; import org.bench4q.share.models.master.statistics.ScriptResultModel;
import org.bench4q.share.models.monitor.MonitorMain; import org.bench4q.share.models.monitor.MonitorMain;
import org.hibernate.Session; import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
public class TestResultSave { public class TestResultSave {
private TestPlanFactory testPlanFactory; private TestPlanFactory testPlanFactory;
private SessionHelper sessionHelper; private SessionHelper sessionHelper;
private TestPlanRepository testPlanRepository; private TestPlanRepository testPlanRepository;
private Logger logger = Logger.getLogger(TestScriptResultSave.class); private Logger logger = Logger.getLogger(TestScriptResultSave.class);
private ConcurrentHashMap<String, TestPlan> runningTestPlans; private ConcurrentHashMap<String, TestPlan> runningTestPlans;
private final int SAVEINTERVAL = 5; private final int SAVEINTERVAL = 5;
public TestResultSave() { public TestResultSave() {
this.setRunningTestPlans(new ConcurrentHashMap<String, TestPlan>()); this.setRunningTestPlans(new ConcurrentHashMap<String, TestPlan>());
} }
private TestPlanRepository getTestPlanRepository() { private TestPlanRepository getTestPlanRepository() {
return testPlanRepository; return testPlanRepository;
} }
@Autowired @Autowired
private void setTestPlanRepository(TestPlanRepository testPlanRepository) { private void setTestPlanRepository(TestPlanRepository testPlanRepository) {
this.testPlanRepository = testPlanRepository; this.testPlanRepository = testPlanRepository;
} }
private SessionHelper getSessionHelper() { private SessionHelper getSessionHelper() {
return sessionHelper; return sessionHelper;
} }
@Autowired @Autowired
private void setSessionHelper(SessionHelper sessionHelper) { private void setSessionHelper(SessionHelper sessionHelper) {
this.sessionHelper = sessionHelper; this.sessionHelper = sessionHelper;
} }
private TestPlanFactory getTestPlanFactory() { private TestPlanFactory getTestPlanFactory() {
return testPlanFactory; return testPlanFactory;
} }
@Autowired @Autowired
private void setTestPlanFactory(TestPlanFactory testPlanFactory) { private void setTestPlanFactory(TestPlanFactory testPlanFactory) {
this.testPlanFactory = testPlanFactory; this.testPlanFactory = testPlanFactory;
} }
public ConcurrentHashMap<String, TestPlan> getRunningTestPlans() { public ConcurrentHashMap<String, TestPlan> getRunningTestPlans() {
return runningTestPlans; return runningTestPlans;
} }
public void setRunningTestPlans( public void setRunningTestPlans(
ConcurrentHashMap<String, TestPlan> runningTestPlans) { ConcurrentHashMap<String, TestPlan> runningTestPlans) {
this.runningTestPlans = runningTestPlans; this.runningTestPlans = runningTestPlans;
} }
public void doSaveTestPlanResult() { public void doSaveTestPlanResult() {
try { try {
ScheduledExecutorService sheScheduledExecutorService = Executors ScheduledExecutorService sheScheduledExecutorService = Executors
.newScheduledThreadPool(10); .newScheduledThreadPool(10);
sheScheduledExecutorService.scheduleAtFixedRate(new Runnable() { sheScheduledExecutorService.scheduleAtFixedRate(new Runnable() {
public void run() { public void run() {
Session session = getSessionHelper().openSession(); Session session = getSessionHelper().openSession();
Set<String> testPlanRunIdSet = getRunningTestPlans() Set<String> testPlanRunIdSet = getRunningTestPlans()
.keySet(); .keySet();
for (String testPlanRunId : testPlanRunIdSet) { for (String testPlanRunId : testPlanRunIdSet) {
getTestPlanRepository().doUpdateEntity(session, getTestPlanRepository().doUpdateEntity(session,
getRunningTestPlans().get(testPlanRunId)); getRunningTestPlans().get(testPlanRunId));
} }
runningTestPlans.clear(); runningTestPlans.clear();
session.close(); session.close();
} }
}, 0, SAVEINTERVAL, TimeUnit.SECONDS); }, 0, SAVEINTERVAL, TimeUnit.SECONDS);
} catch (Exception e) { } catch (Exception e) {
Logger.getLogger(TestPlan.class).info(e, e.fillInStackTrace()); Logger.getLogger(TestPlan.class).info(e, e.fillInStackTrace());
} }
} }
private TestPlan getTestPlan(String testPlanRunId) { private TestPlan getTestPlan(String testPlanRunId) {
if (this.getRunningTestPlans().get(testPlanRunId) != null) if (this.getRunningTestPlans().get(testPlanRunId) != null)
return this.getRunningTestPlans().get(testPlanRunId); return this.getRunningTestPlans().get(testPlanRunId);
else { else {
Session session = this.getSessionHelper().openSession(); Session session = this.getSessionHelper().openSession();
TestPlan testPlan = this.getTestPlanRepository().doGetTestPlanBy( TestPlan testPlan = this.getTestPlanRepository().doGetTestPlanBy(
session, UUID.fromString(testPlanRunId)); session, UUID.fromString(testPlanRunId));
session.close(); session.close();
if (testPlan == null) { if (testPlan == null) {
logger.error("get testPlan:" + testPlanRunId logger.error("get testPlan:" + testPlanRunId
+ " from dataBase failed"); + " from dataBase failed");
return null; return null;
} }
this.getRunningTestPlans().put(testPlanRunId, testPlan); this.getRunningTestPlans().put(testPlanRunId, testPlan);
return testPlan; return testPlan;
} }
} }
public void update(Observable messageSender, Object arg) { public void update(Observable messageSender, Object arg) {
if (messageSender instanceof Monitor) { if (messageSender instanceof Monitor) {
Monitor monitor = (Monitor) messageSender; Monitor monitor = (Monitor) messageSender;
this.updateTestplanMonitorResult(monitor.getTestPlan() this.updateTestplanMonitorResult(monitor.getTestPlan()
.getTestPlanRunId(), monitor.getHostName(), .getTestPlanRunId(), monitor.getHostName(),
(MonitorMain) arg); (MonitorMain) arg);
} else if (messageSender instanceof TestPlanScript) { } else if (messageSender instanceof TestPlanScript) {
TestPlanScript testPlanScript = (TestPlanScript) messageSender; TestPlanScript testPlanScript = (TestPlanScript) messageSender;
this.updateTestPlanScriptResult(testPlanScript.getTestPlan() this.updateTestPlanScriptResult(testPlanScript.getTestPlan()
.getTestPlanRunId(), testPlanScript.getScriptId(), .getTestPlanRunId(), testPlanScript.getScriptId(),
(ScriptResultModel) arg); (ScriptResultModel) arg);
} }
} }
private void updateTestPlanScriptResult(String testPlanRunId, int scriptId, private void updateTestPlanScriptResult(String testPlanRunId, int scriptId,
ScriptResultModel scriptResultModel) { ScriptResultModel scriptResultModel) {
try { try {
TestPlan testPlan = this.getTestPlan(testPlanRunId); TestPlan testPlan = this.getTestPlan(testPlanRunId);
if (testPlan == null) if (testPlan == null)
return; return;
TestPlanScript testPlanScript = testPlan TestPlanScript testPlanScript = testPlan
.extracSpecifiedScript(scriptId); .extracSpecifiedScript(scriptId);
List<TestPlanScriptResult> testPlanScriptResults = this List<TestPlanScriptResult> testPlanScriptResults = this
.getTestPlanFactory().createScriptResultsWithoutId( .getTestPlanFactory().createScriptResultsWithoutId(
scriptResultModel, testPlan, testPlanScript, scriptResultModel, testPlan, testPlanScript,
scriptResultModel.getSamplingTime()); scriptResultModel.getSamplingTime());
if (testPlanScript.getTestPlanScriptResults() == null) if (testPlanScript.getTestPlanScriptResults() == null)
testPlanScript testPlanScript
.setTestPlanScriptResults(new HashSet<TestPlanScriptResult>()); .setTestPlanScriptResults(new HashSet<TestPlanScriptResult>());
testPlanScript.getTestPlanScriptResults().addAll( testPlanScript.getTestPlanScriptResults().addAll(
testPlanScriptResults); testPlanScriptResults);
} catch (Exception e) { } catch (Exception e) {
logger.info(ExceptionLog.getStackTrace(e)); logger.info(ExceptionLog.getStackTrace(e));
} }
} }
private void updateTestplanMonitorResult(String testPlanRunId, private void updateTestplanMonitorResult(String testPlanRunId,
String hostName, MonitorMain monitorMain) { String hostName, MonitorMain monitorMain) {
System.out.println(testPlanRunId); System.out.println(testPlanRunId);
TestPlan testPlan = this.getTestPlan(testPlanRunId); TestPlan testPlan = this.getTestPlan(testPlanRunId);
if (testPlan == null) if (testPlan == null)
return; return;
Monitor monitor = testPlan.extractSpecifiedMonitor(hostName); Monitor monitor = testPlan.extractSpecifiedMonitor(hostName);
List<MonitorResult> monitorResults = this.getTestPlanFactory() List<MonitorResult> monitorResults = this.getTestPlanFactory()
.createMonitorResultListWithOutId(monitorMain, testPlan, .createMonitorResultListWithOutId(monitorMain, testPlan,
monitor, monitorMain.getSamplingTime()); monitor, monitorMain.getSamplingTime());
if (monitorResults == null || monitorResults.size() == 0) if (monitorResults == null || monitorResults.size() == 0)
return; return;
try { try {
monitor.getResults().addAll(monitorResults); monitor.getResults().addAll(monitorResults);
} catch (Exception e) { } catch (Exception e) {
monitor.setResults(new HashSet<MonitorResult>()); monitor.setResults(new HashSet<MonitorResult>());
monitor.getResults().addAll(monitorResults); monitor.getResults().addAll(monitorResults);
} }
} }
} }

View File

@ -1,59 +1,59 @@
package TestHelper; package TestHelper;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.bench4q.share.models.master.plugin.MethodModel; import org.bench4q.share.models.master.plugin.MethodModel;
import org.bench4q.share.models.master.plugin.MethodParamModel; import org.bench4q.share.models.master.plugin.MethodParamModel;
import org.bench4q.share.models.master.plugin.ParamTypeEnum; import org.bench4q.share.models.master.plugin.ParamTypeEnum;
import org.bench4q.share.models.master.plugin.PluginModel; import org.bench4q.share.models.master.plugin.PluginModel;
import org.bench4q.share.models.master.plugin.MethodParamPropertyModel; import org.bench4q.share.models.master.plugin.MethodParamPropertyModel;
public class Test_PlunginHelper { public class Test_PlunginHelper {
public static PluginModel createOnePlugin() { public static PluginModel createOnePlugin() {
PluginModel plugin = new PluginModel(); PluginModel plugin = new PluginModel();
MethodModel method = new MethodModel(); MethodModel method = new MethodModel();
MethodParamModel methodParamModelUrl = new MethodParamModel(); MethodParamModel methodParamModelUrl = new MethodParamModel();
methodParamModelUrl.setLable("input url"); methodParamModelUrl.setLable("input url");
methodParamModelUrl.setName("url"); methodParamModelUrl.setName("url");
methodParamModelUrl.setMethodParamProperties(generatePropertyForField()); methodParamModelUrl.setMethodParamProperties(generatePropertyForField());
methodParamModelUrl.setParamType(ParamTypeEnum.Field); methodParamModelUrl.setParamType(ParamTypeEnum.Field);
MethodParamModel methodParamsParamModel = new MethodParamModel(); MethodParamModel methodParamsParamModel = new MethodParamModel();
methodParamsParamModel.setName("queryparams"); methodParamsParamModel.setName("queryparams");
methodParamsParamModel.setLable("key=value"); methodParamsParamModel.setLable("key=value");
methodParamsParamModel.setMethodParamProperties(generatePropertyForMulti()); methodParamsParamModel.setMethodParamProperties(generatePropertyForMulti());
methodParamsParamModel.setParamType(ParamTypeEnum.MultiField); methodParamsParamModel.setParamType(ParamTypeEnum.MultiField);
Set<MethodParamModel> methodParams = new HashSet<MethodParamModel>(); Set<MethodParamModel> methodParams = new HashSet<MethodParamModel>();
methodParams.add(methodParamModelUrl); methodParams.add(methodParamModelUrl);
methodParams.add(methodParamsParamModel); methodParams.add(methodParamsParamModel);
method.setName("get"); method.setName("get");
method.setMethodParams(methodParams); method.setMethodParams(methodParams);
Set<MethodModel> methods = new HashSet<MethodModel>(); Set<MethodModel> methods = new HashSet<MethodModel>();
methods.add(method); methods.add(method);
plugin.setMethods(methods); plugin.setMethods(methods);
plugin.setName("http" + UUID.randomUUID()); plugin.setName("http" + UUID.randomUUID());
return plugin; return plugin;
} }
private static Set<MethodParamPropertyModel> generatePropertyForField() { private static Set<MethodParamPropertyModel> generatePropertyForField() {
Set<MethodParamPropertyModel> metList = new HashSet<MethodParamPropertyModel>(); Set<MethodParamPropertyModel> metList = new HashSet<MethodParamPropertyModel>();
MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel(); MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel();
methodParamPropertyModel.setKey("size"); methodParamPropertyModel.setKey("size");
methodParamPropertyModel.setValue("20"); methodParamPropertyModel.setValue("20");
metList.add(methodParamPropertyModel); metList.add(methodParamPropertyModel);
return metList; return metList;
} }
private static Set<MethodParamPropertyModel> generatePropertyForMulti() { private static Set<MethodParamPropertyModel> generatePropertyForMulti() {
Set<MethodParamPropertyModel> metList = new HashSet<MethodParamPropertyModel>(); Set<MethodParamPropertyModel> metList = new HashSet<MethodParamPropertyModel>();
MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel(); MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel();
methodParamPropertyModel.setKey("size"); methodParamPropertyModel.setKey("size");
methodParamPropertyModel.setValue("20"); methodParamPropertyModel.setValue("20");
metList.add(methodParamPropertyModel); metList.add(methodParamPropertyModel);
return metList; return metList;
} }
} }

View File

@ -1,150 +1,150 @@
package org.bench4q.master.test.controller; package org.bench4q.master.test.controller;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.io.IOException; import java.io.IOException;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.bench4q.share.communication.HttpRequester.HttpResponse; import org.bench4q.share.communication.HttpRequester.HttpResponse;
import org.bench4q.share.helper.MarshalHelper; import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.master.plugin.PluginGUI; import org.bench4q.share.models.master.plugin.PluginGUI;
import org.bench4q.share.models.master.plugin.PluginResponseModel; import org.bench4q.share.models.master.plugin.PluginResponseModel;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import TestHelper.Test_PlunginHelper; import TestHelper.Test_PlunginHelper;
public class PluginControllerTest extends TestBase { public class PluginControllerTest extends TestBase {
private final String URLSTRING = BASE_URL + "/plugin"; private final String URLSTRING = BASE_URL + "/plugin";
private String pluginName; private String pluginName;
public String getURLSTRING() { public String getURLSTRING() {
return URLSTRING; return URLSTRING;
} }
@Before @Before
public void setUp() throws IOException, JAXBException { public void setUp() throws IOException, JAXBException {
testAddPlugin(); testAddPlugin();
} }
@Test @Test
public void testAddPlugin() throws JAXBException, IOException { public void testAddPlugin() throws JAXBException, IOException {
this.setAccessTocken(this.login()); this.setAccessTocken(this.login());
String url = URLSTRING + "/addPlugin"; String url = URLSTRING + "/addPlugin";
PluginGUI pluginGUI = new PluginGUI(); PluginGUI pluginGUI = new PluginGUI();
pluginGUI.setPlugin(Test_PlunginHelper.createOnePlugin()); pluginGUI.setPlugin(Test_PlunginHelper.createOnePlugin());
pluginName = pluginGUI.getPlugin().getName(); pluginName = pluginGUI.getPlugin().getName();
String pluginContentString = MarshalHelper.marshal(PluginGUI.class, String pluginContentString = MarshalHelper.marshal(PluginGUI.class,
pluginGUI); pluginGUI);
HttpResponse httpResponse = this.httpRequester.sendPutXml(url, HttpResponse httpResponse = this.httpRequester.sendPutXml(url,
pluginContentString, pluginContentString,
makeAccessTockenMap(this.getAccessTocken())); makeAccessTockenMap(this.getAccessTocken()));
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
.tryUnmarshal(PluginResponseModel.class, .tryUnmarshal(PluginResponseModel.class,
httpResponse.getContent()); httpResponse.getContent());
Assert.assertNotNull(pluginResponseModel); Assert.assertNotNull(pluginResponseModel);
Logger.getLogger(PluginControllerTest.class).info( Logger.getLogger(PluginControllerTest.class).info(
"add:" "add:"
+ MarshalHelper.marshal(PluginResponseModel.class, + MarshalHelper.marshal(PluginResponseModel.class,
pluginResponseModel)); pluginResponseModel));
Assert.assertTrue(pluginResponseModel.isSuccess()); Assert.assertTrue(pluginResponseModel.isSuccess());
} }
@Test @Test
public void testGetMethodParamModel() throws IOException, JAXBException { public void testGetMethodParamModel() throws IOException, JAXBException {
String url = URLSTRING + "/loadMethodParams"; String url = URLSTRING + "/loadMethodParams";
String urlForLoadMethod = URLSTRING + "/loadMethodList/" + pluginName; String urlForLoadMethod = URLSTRING + "/loadMethodList/" + pluginName;
HttpResponse httpResponseMethod = this.httpRequester.sendPost( HttpResponse httpResponseMethod = this.httpRequester.sendPost(
urlForLoadMethod, null, urlForLoadMethod, null,
makeAccessTockenMap(this.getAccessTocken())); makeAccessTockenMap(this.getAccessTocken()));
PluginResponseModel pluginResponseModelMethod = (PluginResponseModel) MarshalHelper PluginResponseModel pluginResponseModelMethod = (PluginResponseModel) MarshalHelper
.unmarshal(PluginResponseModel.class, .unmarshal(PluginResponseModel.class,
httpResponseMethod.getContent()); httpResponseMethod.getContent());
assertTrue(pluginResponseModelMethod.isSuccess()); assertTrue(pluginResponseModelMethod.isSuccess());
String methodName = pluginResponseModelMethod.getMethodList().get(0); String methodName = pluginResponseModelMethod.getMethodList().get(0);
url += "/" + pluginName + "/" + methodName; url += "/" + pluginName + "/" + methodName;
HttpResponse httpResponse = this.httpRequester.sendPost(url, null, HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
makeAccessTockenMap(this.getAccessTocken())); makeAccessTockenMap(this.getAccessTocken()));
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
.tryUnmarshal(PluginResponseModel.class, .tryUnmarshal(PluginResponseModel.class,
httpResponse.getContent()); httpResponse.getContent());
Assert.assertTrue(pluginResponseModel.isSuccess()); Assert.assertTrue(pluginResponseModel.isSuccess());
assertEquals(2, pluginResponseModel.getMethosMethodParamModels().size()); assertEquals(2, pluginResponseModel.getMethosMethodParamModels().size());
} }
@Test @Test
public void testLoadPluginList() throws JAXBException, IOException { public void testLoadPluginList() throws JAXBException, IOException {
String url = URLSTRING + "/loadPluginList"; String url = URLSTRING + "/loadPluginList";
HttpResponse httpResponse = this.httpRequester.sendPost(url, null, HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
makeAccessTockenMap(this.getAccessTocken())); makeAccessTockenMap(this.getAccessTocken()));
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
.tryUnmarshal(PluginResponseModel.class, .tryUnmarshal(PluginResponseModel.class,
httpResponse.getContent()); httpResponse.getContent());
assertNotNull(pluginResponseModel); assertNotNull(pluginResponseModel);
Assert.assertTrue(pluginResponseModel.isSuccess()); Assert.assertTrue(pluginResponseModel.isSuccess());
Assert.assertTrue(pluginResponseModel.getPluginList().size() > 0); Assert.assertTrue(pluginResponseModel.getPluginList().size() > 0);
} }
@Test @Test
public void testLoadMethodNameList() throws IOException, JAXBException { public void testLoadMethodNameList() throws IOException, JAXBException {
String urlForLoadMethod = URLSTRING + "/loadMethodList/" + pluginName; String urlForLoadMethod = URLSTRING + "/loadMethodList/" + pluginName;
HttpResponse httpResponse = this.httpRequester.sendPost( HttpResponse httpResponse = this.httpRequester.sendPost(
urlForLoadMethod, null, urlForLoadMethod, null,
makeAccessTockenMap(this.getAccessTocken())); makeAccessTockenMap(this.getAccessTocken()));
System.out.println(httpResponse.getContent()); System.out.println(httpResponse.getContent());
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
.unmarshal(PluginResponseModel.class, httpResponse.getContent()); .unmarshal(PluginResponseModel.class, httpResponse.getContent());
assertNotNull(pluginResponseModel); assertNotNull(pluginResponseModel);
Assert.assertTrue(pluginResponseModel.isSuccess()); Assert.assertTrue(pluginResponseModel.isSuccess());
assertEquals(2, pluginResponseModel.getMethodList().size()); assertEquals(2, pluginResponseModel.getMethodList().size());
} }
@Test @Test
public void testDeletePlugin() throws IOException, JAXBException { public void testDeletePlugin() throws IOException, JAXBException {
setUp(); setUp();
String url = URLSTRING + "/loadPluginList"; String url = URLSTRING + "/loadPluginList";
HttpResponse httpResponse = this.httpRequester.sendPost(url, null, HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
makeAccessTockenMap(this.getAccessTocken())); makeAccessTockenMap(this.getAccessTocken()));
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
.tryUnmarshal(PluginResponseModel.class, .tryUnmarshal(PluginResponseModel.class,
httpResponse.getContent()); httpResponse.getContent());
assertTrue(pluginResponseModel.getPluginList().size() > 0); assertTrue(pluginResponseModel.getPluginList().size() > 0);
String pluginName = pluginResponseModel.getPluginList().get(0); String pluginName = pluginResponseModel.getPluginList().get(0);
url = URLSTRING + "/deletePlugin" + "/" + pluginName; url = URLSTRING + "/deletePlugin" + "/" + pluginName;
httpResponse = this.httpRequester.sendPost(url, null, httpResponse = this.httpRequester.sendPost(url, null,
makeAccessTockenMap(this.getAccessTocken())); makeAccessTockenMap(this.getAccessTocken()));
pluginResponseModel = (PluginResponseModel) MarshalHelper.tryUnmarshal( pluginResponseModel = (PluginResponseModel) MarshalHelper.tryUnmarshal(
PluginResponseModel.class, httpResponse.getContent()); PluginResponseModel.class, httpResponse.getContent());
Assert.assertTrue(pluginResponseModel.isSuccess()); Assert.assertTrue(pluginResponseModel.isSuccess());
} }
@Test @Test
public void testGetMethodInPlugin() throws IOException { public void testGetMethodInPlugin() throws IOException {
String url = URLSTRING + "/loadMethods/" + pluginName; String url = URLSTRING + "/loadMethods/" + pluginName;
HttpResponse httpResponse = this.httpRequester.sendPost(url, null, HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
makeAccessTockenMap(this.getAccessTocken())); makeAccessTockenMap(this.getAccessTocken()));
Logger.getLogger(PluginControllerTest.class).info( Logger.getLogger(PluginControllerTest.class).info(
httpResponse.getContent()); httpResponse.getContent());
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
.tryUnmarshal(PluginResponseModel.class, .tryUnmarshal(PluginResponseModel.class,
httpResponse.getContent()); httpResponse.getContent());
assertNotNull(pluginResponseModel); assertNotNull(pluginResponseModel);
assertTrue(pluginResponseModel.isSuccess()); assertTrue(pluginResponseModel.isSuccess());
assertTrue(pluginResponseModel.getMethodModels().size() == 2); assertTrue(pluginResponseModel.getMethodModels().size() == 2);
} }
@After @After
public void clear() throws IOException { public void clear() throws IOException {
String url = URLSTRING + "/deletePlugin" + "/" + pluginName; String url = URLSTRING + "/deletePlugin" + "/" + pluginName;
this.httpRequester.sendPost(url, null, this.httpRequester.sendPost(url, null,
makeAccessTockenMap(this.getAccessTocken())); makeAccessTockenMap(this.getAccessTocken()));
} }
} }

View File

@ -1,117 +1,117 @@
package org.bench4q.master.test.repository; package org.bench4q.master.test.repository;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.util.List; import java.util.List;
import org.bench4q.master.domain.entity.plugin.Method; import org.bench4q.master.domain.entity.plugin.Method;
import org.bench4q.master.domain.entity.plugin.MethodParam; import org.bench4q.master.domain.entity.plugin.MethodParam;
import org.bench4q.master.domain.entity.plugin.ParamType; import org.bench4q.master.domain.entity.plugin.ParamType;
import org.bench4q.master.domain.entity.plugin.Plugin; import org.bench4q.master.domain.entity.plugin.Plugin;
import org.bench4q.master.domain.factory.PluginFactory; import org.bench4q.master.domain.factory.PluginFactory;
import org.bench4q.master.domain.repository.PluginRepository; import org.bench4q.master.domain.repository.PluginRepository;
import org.bench4q.master.exception.Bench4QException; import org.bench4q.master.exception.Bench4QException;
import org.bench4q.share.models.master.plugin.ParamTypeEnum; import org.bench4q.share.models.master.plugin.ParamTypeEnum;
import org.bench4q.share.models.master.plugin.PluginModel; import org.bench4q.share.models.master.plugin.PluginModel;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import TestHelper.Test_PlunginHelper; import TestHelper.Test_PlunginHelper;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:service-test-context.xml" }) @ContextConfiguration(locations = { "classpath:service-test-context.xml" })
public class Test_PluginRepository { public class Test_PluginRepository {
private PluginRepository pluginRepository; private PluginRepository pluginRepository;
private String pluginName; private String pluginName;
private PluginFactory pluginFactory; private PluginFactory pluginFactory;
public PluginRepository getPluginRepository() { public PluginRepository getPluginRepository() {
return pluginRepository; return pluginRepository;
} }
@Autowired @Autowired
public void setPluginRepository(PluginRepository pluginRepository) { public void setPluginRepository(PluginRepository pluginRepository) {
this.pluginRepository = pluginRepository; this.pluginRepository = pluginRepository;
} }
public PluginFactory getPluginFactory() { public PluginFactory getPluginFactory() {
return pluginFactory; return pluginFactory;
} }
@Autowired @Autowired
public void setPluginFactory(PluginFactory pluginFactory) { public void setPluginFactory(PluginFactory pluginFactory) {
this.pluginFactory = pluginFactory; this.pluginFactory = pluginFactory;
} }
@Before @Before
public void setUp() throws Bench4QException { public void setUp() throws Bench4QException {
pluginName = addPlugin(); pluginName = addPlugin();
} }
@Test @Test
public void testGetPlugin() { public void testGetPlugin() {
assertNotNull(this.getPluginRepository().getPlugin(pluginName)); assertNotNull(this.getPluginRepository().getPlugin(pluginName));
} }
@Test @Test
public void TestLoadMethodParam() { public void TestLoadMethodParam() {
Plugin plugin = this.getPluginRepository().getPlugin(pluginName); Plugin plugin = this.getPluginRepository().getPlugin(pluginName);
MethodParam methodParam = plugin.getPluginMethods().iterator().next() MethodParam methodParam = plugin.getPluginMethods().iterator().next()
.getMethodParams().iterator().next(); .getMethodParams().iterator().next();
System.out.println(methodParam.getParamType().getClass()); System.out.println(methodParam.getParamType().getClass());
} }
@Test @Test
public void testGetMethodList() throws Bench4QException { public void testGetMethodList() throws Bench4QException {
Plugin plugin = this.getPluginRepository().getPlugin(pluginName); Plugin plugin = this.getPluginRepository().getPlugin(pluginName);
assertNotNull(plugin); assertNotNull(plugin);
assertEquals(1, plugin.getPluginMethods().size()); assertEquals(1, plugin.getPluginMethods().size());
} }
@Test @Test
public void testLoadPlugin() throws Bench4QException { public void testLoadPlugin() throws Bench4QException {
int countBeforeInsert = this.getPluginRepository().loadPlugins().size(); int countBeforeInsert = this.getPluginRepository().loadPlugins().size();
String insertPlugin = addPlugin(); String insertPlugin = addPlugin();
assertEquals(countBeforeInsert + 1, this.getPluginRepository() assertEquals(countBeforeInsert + 1, this.getPluginRepository()
.loadPlugins().size()); .loadPlugins().size());
this.getPluginRepository().detach(insertPlugin); this.getPluginRepository().detach(insertPlugin);
} }
@Test @Test
public void testGetParamTypeByType() throws Bench4QException { public void testGetParamTypeByType() throws Bench4QException {
ParamType paramType = this.getPluginRepository().getParamTypeByType( ParamType paramType = this.getPluginRepository().getParamTypeByType(
ParamTypeEnum.Field); ParamTypeEnum.Field);
assertNotNull(paramType); assertNotNull(paramType);
assertEquals(paramType.getType(), ParamTypeEnum.Field); assertEquals(paramType.getType(), ParamTypeEnum.Field);
} }
@Test @Test
public void testLoadMethodInPlugin(){ public void testLoadMethodInPlugin(){
Plugin plugin=this.getPluginRepository().getPlugin(this.pluginName); Plugin plugin=this.getPluginRepository().getPlugin(this.pluginName);
List<Method> methods=this.getPluginRepository().loadMethodsInPlugin(plugin); List<Method> methods=this.getPluginRepository().loadMethodsInPlugin(plugin);
assertNotNull(methods); assertNotNull(methods);
assertTrue(methods.size()>0); assertTrue(methods.size()>0);
} }
@After @After
public void clear() throws Bench4QException { public void clear() throws Bench4QException {
this.getPluginRepository().detach(pluginName); this.getPluginRepository().detach(pluginName);
} }
private String addPlugin() throws Bench4QException { private String addPlugin() throws Bench4QException {
PluginModel pluginModel = Test_PlunginHelper.createOnePlugin(); PluginModel pluginModel = Test_PlunginHelper.createOnePlugin();
this.getPluginRepository().attatch( this.getPluginRepository().attatch(
this.getPluginFactory().createPluginEntity(pluginModel)); this.getPluginFactory().createPluginEntity(pluginModel));
return pluginModel.getName(); return pluginModel.getName();
} }
} }

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/resource"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

23
Bench4Q-Recorder/.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>bench4q-recorder</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -1,93 +1,93 @@
<html><!--###PHBoeHBhZ2U+PHRpbWVTdGFtcD4xMC8xMi8yMDEzIDA4OjM3OjQzPC90aW1lU3RhbXA+PHRpbWVUaWxsQ0NCTlJlZnJlc2g+MTgwPC90aW1lVGlsbENDQk5SZWZyZXNoPjwvcGh4cGFnZT4=###--><head><link href="http://phx.corporate-ir.net/HttpCombiner.ashx?s=RisenCSS&amp;v=B94A18012C20431FA6ADC43CFC76EDB2" type="text/css" rel="stylesheet" /><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Baidu | Business Overview</title><script language="JavaScript" src="http://media.corporate-ir.net/media_files/irol/global_js/phoenix.js"></script><link rel="stylesheet" type="text/css" href="client/18/188488/css/ccbnIR.css" /><script type="text/javascript"><!-- <html><!--###PHBoeHBhZ2U+PHRpbWVTdGFtcD4xMC8xMi8yMDEzIDA4OjM3OjQzPC90aW1lU3RhbXA+PHRpbWVUaWxsQ0NCTlJlZnJlc2g+MTgwPC90aW1lVGlsbENDQk5SZWZyZXNoPjwvcGh4cGFnZT4=###--><head><link href="http://phx.corporate-ir.net/HttpCombiner.ashx?s=RisenCSS&amp;v=B94A18012C20431FA6ADC43CFC76EDB2" type="text/css" rel="stylesheet" /><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Baidu | Business Overview</title><script language="JavaScript" src="http://media.corporate-ir.net/media_files/irol/global_js/phoenix.js"></script><link rel="stylesheet" type="text/css" href="client/18/188488/css/ccbnIR.css" /><script type="text/javascript"><!--
var iframeids=["myframe"] var iframeids=["myframe"]
var iframehide="yes" var iframehide="yes"
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1] var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers
function resizeCaller() { function resizeCaller() {
var dyniframe=new Array() var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){ for (i=0; i<iframeids.length; i++){
if (document.getElementById) if (document.getElementById)
resizeIframe(iframeids[i]) resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above): //reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){ if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i]) var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block" tempobj.style.display="block"
} }
} }
} }
function resizeIframe(frameid){ function resizeIframe(frameid){
var currentfr=document.getElementById(frameid) var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){ if (currentfr && !window.opera){
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight; currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener) if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false) currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){ else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe) currentfr.attachEvent("onload", readjustIframe)
} }
} }
} }
function readjustIframe(loadevt) { function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot) if (iframeroot)
resizeIframe(iframeroot.id); resizeIframe(iframeroot.id);
} }
function loadintoIframe(url){ function loadintoIframe(url){
if (document.getElementById) if (document.getElementById)
document.getElementById("myframe").src=url document.getElementById("myframe").src=url
} }
if (window.addEventListener) if (window.addEventListener)
window.addEventListener("load", resizeCaller, false) window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent) else if (window.attachEvent)
window.attachEvent("onload", resizeCaller) window.attachEvent("onload", resizeCaller)
else else
window.onload=resizeCaller window.onload=resizeCaller
//--> //-->
</script><script language="Javascript"><!-- </script><script language="Javascript"><!--
function emailPage() function emailPage()
{ {
var loc = top.location; var loc = top.location;
var to = ""; var to = "";
var subject = top.document.title; var subject = top.document.title;
var body = document.location.href; var body = document.location.href;
// BUILD MAIL MESSAGE COMPONENTS // BUILD MAIL MESSAGE COMPONENTS
var doc = "mailto:" + to + var doc = "mailto:" + to +
"?subject=" + escape(subject) + "?subject=" + escape(subject) +
"&body=" + escape(body); "&body=" + escape(body);
// POP UP EMAIL MESSAGE WINDOW // POP UP EMAIL MESSAGE WINDOW
window.location = doc; window.location = doc;
} }
//--> //-->
</script><script src="http://phx.corporate-ir.net/HttpCombiner.ashx?s=RisenJS&v=B94A18012C20431FA6ADC43CFC76EDB2" type="text/javascript"></script><script type="text/javascript">Phx.AjaxToken = 'b11f528329bbcb978c6263efe73939aa2452db019b4dead38bbb2a9ddfa7cb25';</script><script type="text/javascript">var s_CCSWebHostingAccount = "trcgclientweb2090";</script><script type="text/javascript" src="./WebSideStory/s_code.js"></script></head><body><table width="100%" border="0" cellspacing="0" cellpadding="0" class="BGLogo"><tr><td width="181" height="99" align="center" nowrap="nowrap">?????<a href="http://www.baidu.com"><img src="http://media.corporate-ir.net/media_files/irol/18/188488/images/logo.gif" border="0" align="absmiddle" /></a></td><td align="right" class="Banner" id="ObjBanner">?<script><!-- </script><script src="http://phx.corporate-ir.net/HttpCombiner.ashx?s=RisenJS&v=B94A18012C20431FA6ADC43CFC76EDB2" type="text/javascript"></script><script type="text/javascript">Phx.AjaxToken = 'b11f528329bbcb978c6263efe73939aa2452db019b4dead38bbb2a9ddfa7cb25';</script><script type="text/javascript">var s_CCSWebHostingAccount = "trcgclientweb2090";</script><script type="text/javascript" src="./WebSideStory/s_code.js"></script></head><body><table width="100%" border="0" cellspacing="0" cellpadding="0" class="BGLogo"><tr><td width="181" height="99" align="center" nowrap="nowrap">?????<a href="http://www.baidu.com"><img src="http://media.corporate-ir.net/media_files/irol/18/188488/images/logo.gif" border="0" align="absmiddle" /></a></td><td align="right" class="Banner" id="ObjBanner">?<script><!--
if (screen.width<= 800) document.getElementById("ObjBanner").style.backgroundImage = "url(http://media.corporate-ir.net/media_files/irol/18/188488/images/banner800.jpg)";//--> if (screen.width<= 800) document.getElementById("ObjBanner").style.backgroundImage = "url(http://media.corporate-ir.net/media_files/irol/18/188488/images/banner800.jpg)";//-->
</script></td></tr></table><table width="100%" border="0" cellspacing="0" cellpadding="0" class="BGBar"><tr><td width="225" height="29"></td><td class="DottedLine" style="padding-right:30px;"><div align="right"><span class="ccbnLnk"><a class="ccbnLnk" onclick="emailPage()" href="#"><img border="0" src="http://media.corporate-ir.net/media_files/irol/18/188488/images/icon_email.gif" /></a></span><span class="ccbnLnk"><a class="ccbnLnk" onclick="emailPage()" href="#"> Send????</a></span><span class="ccbnLnk"><a Class="ccbnLnk"Target="_blank" href="phoenix.zhtml?c=188488&p=irol-homeprofile_pf"><img src="http://media.corporate-ir.net/media_files/irol/18/188488/images/icon_print.gif" alt="Printer Friendly Version" border="0" /></a>?</span><span class="ccbnLnk"><a Class="ccbnLnk"Target="_blank" href="phoenix.zhtml?c=188488&p=irol-homeprofile_pf">Print????</a></span><span class="ccbnLnk"><A HREF="phoenix.zhtml?c=188488&p=rssSubscription&t=&id=&" NAME=""Class="ccbnLnk"><img src="http://media.corporate-ir.net/media_files/irol/global_images/toolkit_rss.gif" border="0" alt="RSS" /></A>?</span><span class="ccbnLnk"><A HREF="phoenix.zhtml?c=188488&p=rssSubscription&t=&id=&" NAME=""Class="ccbnLnk">RSS</A></span></div></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="225" valign="top"><table width="198" border="0" cellspacing="0" cellpadding="0"><tr><td width="198" class="MTitle">Corporate Information</td></tr></table><table width="198" border="0" cellpadding="0" cellspacing="0" class="MIBoxMargin"><tr><td width="198" class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-homeprofile">Business Overview</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-products">Products</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-govmanage">Management</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-govboard">Board of Directors</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-govhighlights">Corporate Governance</a></td></tr></table><table width="198" border="0" cellspacing="0" cellpadding="0"><tr><td width="198" class="MTitle">Investor Relations</td></tr></table><table width="198" border="0" cellpadding="0" cellspacing="0" class="MIBoxMargin"><tr><td width="198" class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-irhome">Fact Sheet</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-news&amp;nyo=0">Press Releases</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-reportsAnnual">Financial Reports</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-presentations">Webcasts</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-stockquote">Stock Information</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-sec">SEC Filings</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-analysts">Analyst Coverage</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-calendar">IR Calendar</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-faq">Investor FAQs</a></td></tr></table><table width="198" border="0" cellspacing="0" cellpadding="0"><tr><td width="198" class="MTitle">Contact Baidu</td></tr></table><table width="198" border="0" cellpadding="0" cellspacing="0" class="MIBoxMargin"><tr><td width="198" class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-contacts">IR Contacts</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-inforeq">Request Information</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-alerts">Email Alert</a></td></tr></table><table width="198" border="0" cellspacing="0" cellpadding="0"><tr align="center"><td width="198" align="center"><a href="http://www.baidu.com"><img src="http://media.corporate-ir.net/media_files/irol/18/188488/images/back1.gif" alt="back to baidu" width="164" border="0" /></a></td></tr></table></td><td valign="top"><br /><h1>The Baidu Story</h1><br /><br /><span class="ccbnTxt"><p>Our name was inspired by a poem written more than 800 years ago during the Song Dynasty. The poem compares the search for a retreating beauty amid chaotic glamour with the search for one's dream while confronted by life's many obstacles. "…hundreds and thousands of times, for her I searched in chaos, suddenly, I turned by chance, to where the lights were waning, and there she stood." Baidu, whose literal meaning is “hundreds of times”, represents a persistent search for the ideal. <br><br> </script></td></tr></table><table width="100%" border="0" cellspacing="0" cellpadding="0" class="BGBar"><tr><td width="225" height="29"></td><td class="DottedLine" style="padding-right:30px;"><div align="right"><span class="ccbnLnk"><a class="ccbnLnk" onclick="emailPage()" href="#"><img border="0" src="http://media.corporate-ir.net/media_files/irol/18/188488/images/icon_email.gif" /></a></span><span class="ccbnLnk"><a class="ccbnLnk" onclick="emailPage()" href="#"> Send????</a></span><span class="ccbnLnk"><a Class="ccbnLnk"Target="_blank" href="phoenix.zhtml?c=188488&p=irol-homeprofile_pf"><img src="http://media.corporate-ir.net/media_files/irol/18/188488/images/icon_print.gif" alt="Printer Friendly Version" border="0" /></a>?</span><span class="ccbnLnk"><a Class="ccbnLnk"Target="_blank" href="phoenix.zhtml?c=188488&p=irol-homeprofile_pf">Print????</a></span><span class="ccbnLnk"><A HREF="phoenix.zhtml?c=188488&p=rssSubscription&t=&id=&" NAME=""Class="ccbnLnk"><img src="http://media.corporate-ir.net/media_files/irol/global_images/toolkit_rss.gif" border="0" alt="RSS" /></A>?</span><span class="ccbnLnk"><A HREF="phoenix.zhtml?c=188488&p=rssSubscription&t=&id=&" NAME=""Class="ccbnLnk">RSS</A></span></div></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="225" valign="top"><table width="198" border="0" cellspacing="0" cellpadding="0"><tr><td width="198" class="MTitle">Corporate Information</td></tr></table><table width="198" border="0" cellpadding="0" cellspacing="0" class="MIBoxMargin"><tr><td width="198" class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-homeprofile">Business Overview</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-products">Products</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-govmanage">Management</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-govboard">Board of Directors</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-govhighlights">Corporate Governance</a></td></tr></table><table width="198" border="0" cellspacing="0" cellpadding="0"><tr><td width="198" class="MTitle">Investor Relations</td></tr></table><table width="198" border="0" cellpadding="0" cellspacing="0" class="MIBoxMargin"><tr><td width="198" class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-irhome">Fact Sheet</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-news&amp;nyo=0">Press Releases</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-reportsAnnual">Financial Reports</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-presentations">Webcasts</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-stockquote">Stock Information</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-sec">SEC Filings</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-analysts">Analyst Coverage</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-calendar">IR Calendar</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-faq">Investor FAQs</a></td></tr></table><table width="198" border="0" cellspacing="0" cellpadding="0"><tr><td width="198" class="MTitle">Contact Baidu</td></tr></table><table width="198" border="0" cellpadding="0" cellspacing="0" class="MIBoxMargin"><tr><td width="198" class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-contacts">IR Contacts</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-inforeq">Request Information</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&amp;p=irol-alerts">Email Alert</a></td></tr></table><table width="198" border="0" cellspacing="0" cellpadding="0"><tr align="center"><td width="198" align="center"><a href="http://www.baidu.com"><img src="http://media.corporate-ir.net/media_files/irol/18/188488/images/back1.gif" alt="back to baidu" width="164" border="0" /></a></td></tr></table></td><td valign="top"><br /><h1>The Baidu Story</h1><br /><br /><span class="ccbnTxt"><p>Our name was inspired by a poem written more than 800 years ago during the Song Dynasty. The poem compares the search for a retreating beauty amid chaotic glamour with the search for one's dream while confronted by life's many obstacles. "…hundreds and thousands of times, for her I searched in chaos, suddenly, I turned by chance, to where the lights were waning, and there she stood." Baidu, whose literal meaning is “hundreds of times”, represents a persistent search for the ideal. <br><br>
Baidu was founded in 2000 by Internet pioneer Robin Li, creator of visionary search technology Hyperlink Analysis, with the mission of providing the best way for people to find what theyre looking for online. Over the past decade we have strived to fulfill this mission by listening carefully to our users needs and wants. To provide intelligent, relevant search results for the tens of billions of queries that are entered into our search platform every day, we focus on powering the best technology optimized for up-to-date local tastes and preferences. Our deep understanding of Chinese language and culture is central to our success and this kind of knowledge allows us to tailor our search technology for our users needs. Just to cite one example, we believe there are at least 38 ways of saying "I" in the Chinese language. It is important that we recognize these nuances to effectively address our users requests. Baidu was founded in 2000 by Internet pioneer Robin Li, creator of visionary search technology Hyperlink Analysis, with the mission of providing the best way for people to find what theyre looking for online. Over the past decade we have strived to fulfill this mission by listening carefully to our users needs and wants. To provide intelligent, relevant search results for the tens of billions of queries that are entered into our search platform every day, we focus on powering the best technology optimized for up-to-date local tastes and preferences. Our deep understanding of Chinese language and culture is central to our success and this kind of knowledge allows us to tailor our search technology for our users needs. Just to cite one example, we believe there are at least 38 ways of saying "I" in the Chinese language. It is important that we recognize these nuances to effectively address our users requests.
<br><br> <br><br>
We provide our users with many channels to find and share information. In addition to our core web search product, we power many popular community-based products, such as Baidu PostBar, the worlds first and largest Chinese-language query-based searchable online community platform, Baidu Knows, the worlds largest Chinese-language interactive knowledge-sharing platform, and Baidu Encyclopedia, the worlds largest user-generated Chinese-language encyclopedia, to name but a few. Beyond these marquee products we also offer dozens of helpful vertical search-based products, such as Maps, Image Search, Video Search, News Search, and many more. We power these through our cutting-edge technology, continually innovating to enhance these services. Our new Box Computing Open Platform brings users deep-linked content and even applications they can use directly through their search box. We believe that Box Computing will dramatically improve peoples search experience and become ubiquitous across all Internet devices including computers and mobile platforms. We provide our users with many channels to find and share information. In addition to our core web search product, we power many popular community-based products, such as Baidu PostBar, the worlds first and largest Chinese-language query-based searchable online community platform, Baidu Knows, the worlds largest Chinese-language interactive knowledge-sharing platform, and Baidu Encyclopedia, the worlds largest user-generated Chinese-language encyclopedia, to name but a few. Beyond these marquee products we also offer dozens of helpful vertical search-based products, such as Maps, Image Search, Video Search, News Search, and many more. We power these through our cutting-edge technology, continually innovating to enhance these services. Our new Box Computing Open Platform brings users deep-linked content and even applications they can use directly through their search box. We believe that Box Computing will dramatically improve peoples search experience and become ubiquitous across all Internet devices including computers and mobile platforms.
<br><br> <br><br>
In addition to serving individual users, we also serve as a media platform for online marketing customers. Our business model is mainly based on a performance-oriented marketing platform for businesses to cost effectively reach relevant Internet users. We offer performance-based online marketing services and display advertisements through both Baidu organic websites and our affiliated websites (our Union business). Our affiliated websites lead traffic to us through integrating a Baidu search box into their sites and/or by displaying relevant contextual promotional links for our customers. The majority of our revenue is derived from performance-based online marketing services and our customers pay on a cost per click basis that is, our customers only pay when their paid-link is clicked through and they get the “lead”. Our goal is to give our customers an online marketing platform that has a wide range of functions which they can use to meet their marketing needs and an extensive selection of tools for managing their accounts as well as data for analyzing and optimizing ROI. In addition to serving individual users, we also serve as a media platform for online marketing customers. Our business model is mainly based on a performance-oriented marketing platform for businesses to cost effectively reach relevant Internet users. We offer performance-based online marketing services and display advertisements through both Baidu organic websites and our affiliated websites (our Union business). Our affiliated websites lead traffic to us through integrating a Baidu search box into their sites and/or by displaying relevant contextual promotional links for our customers. The majority of our revenue is derived from performance-based online marketing services and our customers pay on a cost per click basis that is, our customers only pay when their paid-link is clicked through and they get the “lead”. Our goal is to give our customers an online marketing platform that has a wide range of functions which they can use to meet their marketing needs and an extensive selection of tools for managing their accounts as well as data for analyzing and optimizing ROI.
<br><br> <br><br>
To best serve our customers, our sales efforts consist of direct sales teams in first tier cities and third-party distributors in lower tier cities. This allows us to better penetrate each market and tailor our support and personal interaction based on customers needs. Today, our online marketing platform serves hundreds of thousands of small- and medium-sized enterprises (SMEs) and many branded multinational customers. The measurable ROI offered by our online marketing platform has made it one of the most effective marketing platforms for companies targeting the Chinese market. We will continue to strive to provide an extra level of value-added sales and customer service to address a wide range of customer needs. Our focus is to help the market continue to develop and educate the many companies who dont understand the benefits of search engine marketing so that we can help them grow their businesses. To best serve our customers, our sales efforts consist of direct sales teams in first tier cities and third-party distributors in lower tier cities. This allows us to better penetrate each market and tailor our support and personal interaction based on customers needs. Today, our online marketing platform serves hundreds of thousands of small- and medium-sized enterprises (SMEs) and many branded multinational customers. The measurable ROI offered by our online marketing platform has made it one of the most effective marketing platforms for companies targeting the Chinese market. We will continue to strive to provide an extra level of value-added sales and customer service to address a wide range of customer needs. Our focus is to help the market continue to develop and educate the many companies who dont understand the benefits of search engine marketing so that we can help them grow their businesses.
<br><br> <br><br>
You dont need us to tell you that Chinas Internet space is booming. With the worlds largest Internet user population 564 million as of end of 2012 and a long way to go to reach internet penetration levels of developed countries, Chinas internet is growing in both influence and sophistication. And as more and more Chinese come online, Baidu continues to innovate to meet their increasingly diverse tastes. With our goal of best serving the needs of our users and customers with intelligent and relevant solutions, we look forward to a robust future. </p> You dont need us to tell you that Chinas Internet space is booming. With the worlds largest Internet user population 564 million as of end of 2012 and a long way to go to reach internet penetration levels of developed countries, Chinas internet is growing in both influence and sophistication. And as more and more Chinese come online, Baidu continues to innovate to meet their increasingly diverse tastes. With our goal of best serving the needs of our users and customers with intelligent and relevant solutions, we look forward to a robust future. </p>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><img src="http://media.corporate-ir.net/media_files/irol/global_images/spacer.gif" width="10" height="50" /></td></tr></table><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="27" align="center" style="border-top:1px solid #D6D6D6; font-family:Arial; font-size:12px;">Copyright ? <script language="JavaScript"> </span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><img src="http://media.corporate-ir.net/media_files/irol/global_images/spacer.gif" width="10" height="50" /></td></tr></table><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="27" align="center" style="border-top:1px solid #D6D6D6; font-family:Arial; font-size:12px;">Copyright ? <script language="JavaScript">
var year=""; var year="";
mydate=new Date(); mydate=new Date();
myyear= mydate.getYear(); myyear= mydate.getYear();
year=(myyear > 200) ? myyear : 1900 + myyear; year=(myyear > 200) ? myyear : 1900 + myyear;
document.write(year); document.write(year);
</script> Baidu, Inc. All Rights Reserved.</td></tr></table></body></html </script> Baidu, Inc. All Rights Reserved.</td></tr></table></body></html

View File

@ -1,38 +1,38 @@
package org.bench4q.share.models.master; package org.bench4q.share.models.master;
import java.util.List; import java.util.List;
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel; import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel; import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
public class PluginEditScriptRequestModel { public class PluginEditScriptRequestModel {
List<BehaviorModel> behaviorModels; List<BehaviorModel> behaviorModels;
List<UsePluginModel> usePluginModels; List<UsePluginModel> usePluginModels;
String scriptName; String scriptName;
public List<BehaviorModel> getBehaviorModels() { public List<BehaviorModel> getBehaviorModels() {
return behaviorModels; return behaviorModels;
} }
public void setBehaviorModels(List<BehaviorModel> behaviorModels) { public void setBehaviorModels(List<BehaviorModel> behaviorModels) {
this.behaviorModels = behaviorModels; this.behaviorModels = behaviorModels;
} }
public List<UsePluginModel> getUsePluginModels() { public List<UsePluginModel> getUsePluginModels() {
return usePluginModels; return usePluginModels;
} }
public void setUsePluginModels(List<UsePluginModel> usePluginModels) { public void setUsePluginModels(List<UsePluginModel> usePluginModels) {
this.usePluginModels = usePluginModels; this.usePluginModels = usePluginModels;
} }
public String getScriptName() { public String getScriptName() {
return scriptName; return scriptName;
} }
public void setScriptName(String scriptName) { public void setScriptName(String scriptName) {
this.scriptName = scriptName; this.scriptName = scriptName;
} }
} }

View File

@ -1,35 +1,35 @@
package org.bench4q.share.models.master.plugin; package org.bench4q.share.models.master.plugin;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement @XmlRootElement
public class MethodModel { public class MethodModel {
private Set<MethodParamModel> methodParams; private Set<MethodParamModel> methodParams;
private String name; private String name;
@XmlElement @XmlElement
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
@XmlElementWrapper(name = "params") @XmlElementWrapper(name = "params")
@XmlElement(name = "param", type = MethodParamModel.class) @XmlElement(name = "param", type = MethodParamModel.class)
public Set<MethodParamModel> getMethodParams() { public Set<MethodParamModel> getMethodParams() {
return methodParams; return methodParams;
} }
public void setMethodParams(Set<MethodParamModel> methodParams) { public void setMethodParams(Set<MethodParamModel> methodParams) {
this.methodParams = methodParams; this.methodParams = methodParams;
} }
} }

View File

@ -1,69 +1,69 @@
package org.bench4q.share.models.master.plugin; package org.bench4q.share.models.master.plugin;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement @XmlRootElement
public class MethodParamModel { public class MethodParamModel {
private String name; private String name;
private String lable; private String lable;
private ParamTypeEnum paramType; private ParamTypeEnum paramType;
private String valueSeperator = ";"; private String valueSeperator = ";";
private String fieldSeperator = ","; private String fieldSeperator = ",";
private Set<MethodParamPropertyModel> methodParamProperties; private Set<MethodParamPropertyModel> methodParamProperties;
@XmlElement @XmlElement
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
@XmlElement @XmlElement
public String getLable() { public String getLable() {
return lable; return lable;
} }
public void setLable(String lable) { public void setLable(String lable) {
this.lable = lable; this.lable = lable;
} }
@XmlElement @XmlElement
public ParamTypeEnum getParamType() { public ParamTypeEnum getParamType() {
return paramType; return paramType;
} }
public void setParamType(ParamTypeEnum paramType) { public void setParamType(ParamTypeEnum paramType) {
this.paramType = paramType; this.paramType = paramType;
} }
@XmlElement @XmlElement
public String getValueSeperator() { public String getValueSeperator() {
return valueSeperator; return valueSeperator;
} }
public void setValueSeperator(String valueSeperator) { public void setValueSeperator(String valueSeperator) {
this.valueSeperator = valueSeperator; this.valueSeperator = valueSeperator;
} }
@XmlElement @XmlElement
public String getFieldSeperator() { public String getFieldSeperator() {
return fieldSeperator; return fieldSeperator;
} }
public void setFieldSeperator(String fieldSeperator) { public void setFieldSeperator(String fieldSeperator) {
this.fieldSeperator = fieldSeperator; this.fieldSeperator = fieldSeperator;
} }
@XmlElement @XmlElement
public Set<MethodParamPropertyModel> getMethodParamProperties() { public Set<MethodParamPropertyModel> getMethodParamProperties() {
return methodParamProperties; return methodParamProperties;
} }
public void setMethodParamProperties( public void setMethodParamProperties(
Set<MethodParamPropertyModel> methodParamProperties) { Set<MethodParamPropertyModel> methodParamProperties) {
this.methodParamProperties = methodParamProperties; this.methodParamProperties = methodParamProperties;
} }
} }

View File

@ -1,30 +1,30 @@
package org.bench4q.share.models.master.plugin; package org.bench4q.share.models.master.plugin;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement @XmlRootElement
public class MethodParamPropertyModel { public class MethodParamPropertyModel {
private String key; private String key;
private String value; private String value;
@XmlElement @XmlElement
public String getKey() { public String getKey() {
return key; return key;
} }
public void setKey(String key) { public void setKey(String key) {
this.key = key; this.key = key;
} }
@XmlElement @XmlElement
public String getValue() { public String getValue() {
return value; return value;
} }
public void setValue(String value) { public void setValue(String value) {
this.value = value; this.value = value;
} }
} }

View File

@ -1,6 +1,6 @@
package org.bench4q.share.models.master.plugin; package org.bench4q.share.models.master.plugin;
public enum ParamTypeEnum { public enum ParamTypeEnum {
Field, MultiField, CheckBox, Table Field, MultiField, CheckBox, Table
} }

View File

@ -1,18 +1,18 @@
package org.bench4q.share.models.master.plugin; package org.bench4q.share.models.master.plugin;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement @XmlRootElement
public class PluginGUI { public class PluginGUI {
private PluginModel plugin; private PluginModel plugin;
@XmlElement @XmlElement
public PluginModel getPlugin() { public PluginModel getPlugin() {
return plugin; return plugin;
} }
public void setPlugin(PluginModel plugin) { public void setPlugin(PluginModel plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
} }

View File

@ -1,33 +1,33 @@
package org.bench4q.share.models.master.plugin; package org.bench4q.share.models.master.plugin;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement @XmlRootElement
public class PluginModel { public class PluginModel {
private Set<MethodModel> methods; private Set<MethodModel> methods;
private String name; private String name;
@XmlElementWrapper(name = "methods") @XmlElementWrapper(name = "methods")
@XmlElement(name = "method", type = MethodModel.class) @XmlElement(name = "method", type = MethodModel.class)
public Set<MethodModel> getMethods() { public Set<MethodModel> getMethods() {
return methods; return methods;
} }
public void setMethods(Set<MethodModel> methods) { public void setMethods(Set<MethodModel> methods) {
this.methods = methods; this.methods = methods;
} }
@XmlElement @XmlElement
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
} }

View File

@ -1,78 +1,78 @@
package org.bench4q.share.models.master.plugin; package org.bench4q.share.models.master.plugin;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement @XmlRootElement
public class PluginResponseModel { public class PluginResponseModel {
private boolean success; private boolean success;
private List<String> pluginList; private List<String> pluginList;
private List<String> methodList; private List<String> methodList;
private Set<MethodParamModel> methosMethodParamModels; private Set<MethodParamModel> methosMethodParamModels;
private String failMessage; private String failMessage;
private Set<MethodModel> methodModels; private Set<MethodModel> methodModels;
@XmlElement @XmlElement
public boolean isSuccess() { public boolean isSuccess() {
return success; return success;
} }
public void setSuccess(boolean success) { public void setSuccess(boolean success) {
this.success = success; this.success = success;
} }
@XmlElement @XmlElement
public List<String> getPluginList() { public List<String> getPluginList() {
return pluginList; return pluginList;
} }
public void setPluginList(List<String> pluginList) { public void setPluginList(List<String> pluginList) {
this.pluginList = pluginList; this.pluginList = pluginList;
} }
@XmlElement @XmlElement
public List<String> getMethodList() { public List<String> getMethodList() {
return methodList; return methodList;
} }
public void setMethodList(List<String> methodList) { public void setMethodList(List<String> methodList) {
this.methodList = methodList; this.methodList = methodList;
} }
@XmlElementWrapper(name = "methodParamList") @XmlElementWrapper(name = "methodParamList")
@XmlElement(name = "methodParam", type = MethodParamModel.class) @XmlElement(name = "methodParam", type = MethodParamModel.class)
public Set<MethodParamModel> getMethosMethodParamModels() { public Set<MethodParamModel> getMethosMethodParamModels() {
return methosMethodParamModels; return methosMethodParamModels;
} }
public void setMethosMethodParamModels( public void setMethosMethodParamModels(
Set<MethodParamModel> methosMethodParamModels) { Set<MethodParamModel> methosMethodParamModels) {
this.methosMethodParamModels = methosMethodParamModels; this.methosMethodParamModels = methosMethodParamModels;
} }
@XmlElement @XmlElement
public String getFailMessage() { public String getFailMessage() {
return failMessage; return failMessage;
} }
public void setFailMessage(String failMessage) { public void setFailMessage(String failMessage) {
this.failMessage = failMessage; this.failMessage = failMessage;
} }
@XmlElementWrapper(name = "methods") @XmlElementWrapper(name = "methods")
@XmlElement @XmlElement
public Set<MethodModel> getMethodModels() { public Set<MethodModel> getMethodModels() {
return methodModels; return methodModels;
} }
public void setMethodModels(Set<MethodModel> methodModels) { public void setMethodModels(Set<MethodModel> methodModels) {
this.methodModels = methodModels; this.methodModels = methodModels;
} }
} }

View File

@ -1,73 +1,73 @@
package org.bench4q.share.models.master.statistics; package org.bench4q.share.models.master.statistics;
import java.util.Date; import java.util.Date;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement @XmlRootElement
public class ScriptResultModel extends SampleModel { public class ScriptResultModel extends SampleModel {
private ScriptBriefResultModel scriptBriefResultModel; private ScriptBriefResultModel scriptBriefResultModel;
private ScriptBehaviorsBriefModel scriptBehaviorsBriefModel; private ScriptBehaviorsBriefModel scriptBehaviorsBriefModel;
private ScriptPagesBriefModel scriptPagesBriefModel; private ScriptPagesBriefModel scriptPagesBriefModel;
@XmlElement @XmlElement
public ScriptBriefResultModel getScriptBriefResultModel() { public ScriptBriefResultModel getScriptBriefResultModel() {
return scriptBriefResultModel; return scriptBriefResultModel;
} }
public void setScriptBriefResultModel( public void setScriptBriefResultModel(
ScriptBriefResultModel scriptBriefResultModel) { ScriptBriefResultModel scriptBriefResultModel) {
this.scriptBriefResultModel = scriptBriefResultModel; this.scriptBriefResultModel = scriptBriefResultModel;
} }
@XmlElement @XmlElement
public ScriptBehaviorsBriefModel getScriptBehaviorsBriefModel() { public ScriptBehaviorsBriefModel getScriptBehaviorsBriefModel() {
return scriptBehaviorsBriefModel; return scriptBehaviorsBriefModel;
} }
public void setScriptBehaviorsBriefModel( public void setScriptBehaviorsBriefModel(
ScriptBehaviorsBriefModel scriptBehaviorsBriefModel) { ScriptBehaviorsBriefModel scriptBehaviorsBriefModel) {
this.scriptBehaviorsBriefModel = scriptBehaviorsBriefModel; this.scriptBehaviorsBriefModel = scriptBehaviorsBriefModel;
} }
@XmlElement @XmlElement
public ScriptPagesBriefModel getScriptPagesBriefModel() { public ScriptPagesBriefModel getScriptPagesBriefModel() {
return scriptPagesBriefModel; return scriptPagesBriefModel;
} }
public void setScriptPagesBriefModel( public void setScriptPagesBriefModel(
ScriptPagesBriefModel scriptPagesBriefModel) { ScriptPagesBriefModel scriptPagesBriefModel) {
this.scriptPagesBriefModel = scriptPagesBriefModel; this.scriptPagesBriefModel = scriptPagesBriefModel;
} }
public static ScriptResultModel buildFinishedResult() { public static ScriptResultModel buildFinishedResult() {
ScriptResultModel result = new ScriptResultModel(); ScriptResultModel result = new ScriptResultModel();
result.setScriptBehaviorsBriefModel(buildFinishedBehaviors()); result.setScriptBehaviorsBriefModel(buildFinishedBehaviors());
result.setScriptBriefResultModel(buildFinishedScenario()); result.setScriptBriefResultModel(buildFinishedScenario());
result.setScriptPagesBriefModel(buildFinishedPages()); result.setScriptPagesBriefModel(buildFinishedPages());
return result; return result;
} }
private static ScriptPagesBriefModel buildFinishedPages() { private static ScriptPagesBriefModel buildFinishedPages() {
ScriptPagesBriefModel result = new ScriptPagesBriefModel(); ScriptPagesBriefModel result = new ScriptPagesBriefModel();
result.setFinished(true); result.setFinished(true);
result.setSamplingTime(new Date()); result.setSamplingTime(new Date());
return result; return result;
} }
private static ScriptBriefResultModel buildFinishedScenario() { private static ScriptBriefResultModel buildFinishedScenario() {
ScriptBriefResultModel result = new ScriptBriefResultModel(); ScriptBriefResultModel result = new ScriptBriefResultModel();
result.setSamplingTime(new Date()); result.setSamplingTime(new Date());
result.setFinished(true); result.setFinished(true);
return result; return result;
} }
private static ScriptBehaviorsBriefModel buildFinishedBehaviors() { private static ScriptBehaviorsBriefModel buildFinishedBehaviors() {
ScriptBehaviorsBriefModel result = new ScriptBehaviorsBriefModel(); ScriptBehaviorsBriefModel result = new ScriptBehaviorsBriefModel();
result.setSamplingTime(new Date()); result.setSamplingTime(new Date());
result.setFinished(true); result.setFinished(true);
return result; return result;
} }
} }

View File

@ -1,432 +1,432 @@
package org.bench4q.web.api; package org.bench4q.web.api;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import javax.xml.transform.Source; import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema; import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory; import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator; import javax.xml.validation.Validator;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.bench4q.share.helper.ExceptionLog; import org.bench4q.share.helper.ExceptionLog;
import org.bench4q.share.helper.MarshalHelper; import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.agent.RunScenarioModel; import org.bench4q.share.models.agent.RunScenarioModel;
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel; import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel; import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
import org.bench4q.share.models.master.OperateScriptServerResponseModel; import org.bench4q.share.models.master.OperateScriptServerResponseModel;
import org.bench4q.share.models.master.PluginEditScriptRequestModel; import org.bench4q.share.models.master.PluginEditScriptRequestModel;
import org.bench4q.share.models.master.ScriptModel; import org.bench4q.share.models.master.ScriptModel;
import org.bench4q.web.exception.CustomGenericException; import org.bench4q.web.exception.CustomGenericException;
import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange; import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange;
import org.bench4q.web.model.BaseResponseModel; import org.bench4q.web.model.BaseResponseModel;
import org.bench4q.web.service.BaseService; import org.bench4q.web.service.BaseService;
import org.bench4q.web.service.ScriptService; import org.bench4q.web.service.ScriptService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes; import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.multipart.commons.CommonsMultipartFile; import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import com.google.gson.Gson; import com.google.gson.Gson;
@Controller @Controller
@SessionAttributes("accessToken") @SessionAttributes("accessToken")
public class ScriptActionController { public class ScriptActionController {
private final String baseUrl = "RecordScript"; private final String baseUrl = "RecordScript";
private ScriptService scriptService; private ScriptService scriptService;
private final String BASECALLER = "ScriptActionController:"; private final String BASECALLER = "ScriptActionController:";
private String getBaseUrl() { private String getBaseUrl() {
return baseUrl; return baseUrl;
} }
private ScriptService getScriptService() { private ScriptService getScriptService() {
return scriptService; return scriptService;
} }
@Autowired @Autowired
private void setScriptService(ScriptService scriptService) { private void setScriptService(ScriptService scriptService) {
this.scriptService = scriptService; this.scriptService = scriptService;
} }
@RequestMapping("loadScript") @RequestMapping("loadScript")
public @ResponseBody public @ResponseBody
BaseResponseModel loadScript( BaseResponseModel loadScript(
@ModelAttribute("accessToken") String accessToken) @ModelAttribute("accessToken") String accessToken)
throws CustomGenericException { throws CustomGenericException {
String caller = "ScriptActionController:loadScripts"; String caller = "ScriptActionController:loadScripts";
OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
.getScriptService() .getScriptService()
.getCommunicateWithMaster() .getCommunicateWithMaster()
.getResponseModel(accessToken, .getResponseModel(accessToken,
this.getBaseUrl() + "/loadScriptList", this.getBaseUrl() + "/loadScriptList",
OperateScriptServerResponseModel.class, null, caller); OperateScriptServerResponseModel.class, null, caller);
if (operateScriptServerResponseModel.isSuccess()) { if (operateScriptServerResponseModel.isSuccess()) {
List<ScriptModel> scripts = operateScriptServerResponseModel List<ScriptModel> scripts = operateScriptServerResponseModel
.getScriptModels(); .getScriptModels();
if (scripts == null) if (scripts == null)
scripts = new ArrayList<ScriptModel>(); scripts = new ArrayList<ScriptModel>();
return new BaseResponseModel(true, scripts); return new BaseResponseModel(true, scripts);
} else { } else {
return new BaseResponseModel(false, return new BaseResponseModel(false,
operateScriptServerResponseModel.getFailCauseString()); operateScriptServerResponseModel.getFailCauseString());
} }
} }
@RequestMapping("deleteScript") @RequestMapping("deleteScript")
public @ResponseBody public @ResponseBody
BaseResponseModel deletescript( BaseResponseModel deletescript(
@ModelAttribute("accessToken") String accessToken, @ModelAttribute("accessToken") String accessToken,
@RequestParam String scriptId) throws CustomGenericException { @RequestParam String scriptId) throws CustomGenericException {
String caller = new String("ScriptActionComntroller:deleteScript"); String caller = new String("ScriptActionComntroller:deleteScript");
String url = this.getBaseUrl() + "/deleteScript"; String url = this.getBaseUrl() + "/deleteScript";
Map<String, String> params = BaseService.makeParamsMap("scriptId", Map<String, String> params = BaseService.makeParamsMap("scriptId",
scriptId); scriptId);
OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
.getScriptService() .getScriptService()
.getCommunicateWithMaster() .getCommunicateWithMaster()
.getResponseModel(accessToken, url, .getResponseModel(accessToken, url,
OperateScriptServerResponseModel.class, params, caller); OperateScriptServerResponseModel.class, params, caller);
if (operateScriptServerResponseModel.isSuccess()) { if (operateScriptServerResponseModel.isSuccess()) {
return new BaseResponseModel(true); return new BaseResponseModel(true);
} else } else
return new BaseResponseModel(false, return new BaseResponseModel(false,
operateScriptServerResponseModel.getFailCauseString()); operateScriptServerResponseModel.getFailCauseString());
} }
@RequestMapping("editScript") @RequestMapping("editScript")
public @ResponseBody public @ResponseBody
BaseResponseModel editScript(HttpServletRequest request, BaseResponseModel editScript(HttpServletRequest request,
@ModelAttribute("accessToken") String accessToken, @ModelAttribute("accessToken") String accessToken,
@RequestParam String scriptId) throws CustomGenericException, @RequestParam String scriptId) throws CustomGenericException,
JAXBException { JAXBException {
String caller = this.BASECALLER + "editScript"; String caller = this.BASECALLER + "editScript";
String url = this.getBaseUrl() + "/queryScriptById"; String url = this.getBaseUrl() + "/queryScriptById";
Map<String, String> params = BaseService.makeParamsMap("scriptId", Map<String, String> params = BaseService.makeParamsMap("scriptId",
scriptId); scriptId);
OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
.getScriptService() .getScriptService()
.getCommunicateWithMaster() .getCommunicateWithMaster()
.getResponseModel(accessToken, url, .getResponseModel(accessToken, url,
OperateScriptServerResponseModel.class, params, caller); OperateScriptServerResponseModel.class, params, caller);
/* /*
* Logger.getLogger(ScriptActionController.class).info( * Logger.getLogger(ScriptActionController.class).info(
* MarshalHelper.marshal(OperateScriptServerResponseModel.class, * MarshalHelper.marshal(OperateScriptServerResponseModel.class,
* operateScriptServerResponseModel)); * operateScriptServerResponseModel));
*/ */
if (operateScriptServerResponseModel.isSuccess()) { if (operateScriptServerResponseModel.isSuccess()) {
List<ScriptModel> scripts = operateScriptServerResponseModel List<ScriptModel> scripts = operateScriptServerResponseModel
.getScriptModels(); .getScriptModels();
if (scripts == null || scripts.isEmpty()) if (scripts == null || scripts.isEmpty())
return new BaseResponseModel(false, "data empty"); return new BaseResponseModel(false, "data empty");
else { else {
Iterator<ScriptModel> it = scripts.iterator(); Iterator<ScriptModel> it = scripts.iterator();
ScriptModel script = it.next(); ScriptModel script = it.next();
if (script.getScriptContent() == null if (script.getScriptContent() == null
|| script.getScriptContent().isEmpty()) || script.getScriptContent().isEmpty())
return new BaseResponseModel(false, "data empty"); return new BaseResponseModel(false, "data empty");
else { else {
try { try {
RunScenarioModel result = (RunScenarioModel) ObjectXmlExchange RunScenarioModel result = (RunScenarioModel) ObjectXmlExchange
.fromXml(RunScenarioModel.class, .fromXml(RunScenarioModel.class,
script.getScriptContent()); script.getScriptContent());
Gson gson = new Gson(); Gson gson = new Gson();
String scriptContent = null; String scriptContent = null;
Logger.getLogger(ScriptActionController.class).info( Logger.getLogger(ScriptActionController.class).info(
"edit script Before toJson :" "edit script Before toJson :"
+ script.getScriptContent()); + script.getScriptContent());
scriptContent = gson.toJson(result); scriptContent = gson.toJson(result);
Logger.getLogger(ScriptActionController.class).info( Logger.getLogger(ScriptActionController.class).info(
"edit script after toJson :" + scriptContent); "edit script after toJson :" + scriptContent);
return new BaseResponseModel(true, return new BaseResponseModel(true,
(Object) scriptContent); (Object) scriptContent);
} catch (JAXBException e) { } catch (JAXBException e) {
throw new CustomGenericException("1", throw new CustomGenericException("1",
"script content is invalidate", caller); "script content is invalidate", caller);
} }
} }
} }
} else } else
return new BaseResponseModel(false, return new BaseResponseModel(false,
operateScriptServerResponseModel.getFailCauseString()); operateScriptServerResponseModel.getFailCauseString());
} }
@RequestMapping("saveEditScript") @RequestMapping("saveEditScript")
public @ResponseBody public @ResponseBody
BaseResponseModel saveEditScript( BaseResponseModel saveEditScript(
@ModelAttribute("accessToken") String accessToken, @ModelAttribute("accessToken") String accessToken,
@RequestParam String scriptId, @RequestParam String script) @RequestParam String scriptId, @RequestParam String script)
throws CustomGenericException { throws CustomGenericException {
String url = this.getBaseUrl() + "/updateScript"+"/"+scriptId; String url = this.getBaseUrl() + "/updateScript"+"/"+scriptId;
String caller = this.BASECALLER + "saveScript"; String caller = this.BASECALLER + "saveScript";
Gson gson = new Gson(); Gson gson = new Gson();
RunScenarioModel scriptModel = gson.fromJson(script, RunScenarioModel scriptModel = gson.fromJson(script,
RunScenarioModel.class); RunScenarioModel.class);
try { try {
String scriptContent = ObjectXmlExchange.toXml( String scriptContent = ObjectXmlExchange.toXml(
RunScenarioModel.class, scriptModel); RunScenarioModel.class, scriptModel);
OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
.getScriptService() .getScriptService()
.getCommunicateWithMaster() .getCommunicateWithMaster()
.getResponseModelByPut(accessToken, url,scriptContent, .getResponseModelByPut(accessToken, url,scriptContent,
OperateScriptServerResponseModel.class, OperateScriptServerResponseModel.class,
caller); caller);
if (operateScriptServerResponseModel.isSuccess()) { if (operateScriptServerResponseModel.isSuccess()) {
return new BaseResponseModel(true); return new BaseResponseModel(true);
} else } else
return new BaseResponseModel(false, return new BaseResponseModel(false,
operateScriptServerResponseModel.getFailCauseString()); operateScriptServerResponseModel.getFailCauseString());
} catch (JAXBException e) { } catch (JAXBException e) {
return new BaseResponseModel(false, e.getMessage()); return new BaseResponseModel(false, e.getMessage());
} }
} }
@RequestMapping("startRecordServer") @RequestMapping("startRecordServer")
public @ResponseBody public @ResponseBody
BaseResponseModel startRecordServer( BaseResponseModel startRecordServer(
@ModelAttribute("accessToken") String accessToken) @ModelAttribute("accessToken") String accessToken)
throws JAXBException, CustomGenericException { throws JAXBException, CustomGenericException {
String url = this.getBaseUrl() + "/startScriptRecordServer"; String url = this.getBaseUrl() + "/startScriptRecordServer";
String caller = BASECALLER + "startRecordServer"; String caller = BASECALLER + "startRecordServer";
OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
.getScriptService() .getScriptService()
.getCommunicateWithMaster() .getCommunicateWithMaster()
.getResponseModel(accessToken, url, .getResponseModel(accessToken, url,
OperateScriptServerResponseModel.class, null, caller); OperateScriptServerResponseModel.class, null, caller);
if (operateScriptServerResponseModel.isSuccess()) if (operateScriptServerResponseModel.isSuccess())
return new BaseResponseModel(true, operateScriptServerResponseModel); return new BaseResponseModel(true, operateScriptServerResponseModel);
else else
return new BaseResponseModel(false, return new BaseResponseModel(false,
operateScriptServerResponseModel.getFailCauseString()); operateScriptServerResponseModel.getFailCauseString());
} }
@RequestMapping("stopRecordServer") @RequestMapping("stopRecordServer")
public @ResponseBody public @ResponseBody
BaseResponseModel stopRecordServer( BaseResponseModel stopRecordServer(
@ModelAttribute("accessToken") String accessToken, @ModelAttribute("accessToken") String accessToken,
@RequestParam String port, @RequestParam String fileNameUUID) @RequestParam String port, @RequestParam String fileNameUUID)
throws CustomGenericException { throws CustomGenericException {
String caller = BASECALLER + "stopeRecordServer"; String caller = BASECALLER + "stopeRecordServer";
String url = this.getBaseUrl() + "/stopScriptRecordServer"; String url = this.getBaseUrl() + "/stopScriptRecordServer";
Map<String, String> params = BaseService.makeParamsMap("port", port); Map<String, String> params = BaseService.makeParamsMap("port", port);
params.put("fileNameUUID", fileNameUUID); params.put("fileNameUUID", fileNameUUID);
OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
.getScriptService() .getScriptService()
.getCommunicateWithMaster() .getCommunicateWithMaster()
.getResponseModel(accessToken, url, .getResponseModel(accessToken, url,
OperateScriptServerResponseModel.class, params, caller); OperateScriptServerResponseModel.class, params, caller);
if (operateScriptServerResponseModel.isSuccess()) if (operateScriptServerResponseModel.isSuccess())
return new BaseResponseModel(true); return new BaseResponseModel(true);
else else
return new BaseResponseModel(false, return new BaseResponseModel(false,
operateScriptServerResponseModel.getFailCauseString()); operateScriptServerResponseModel.getFailCauseString());
} }
@RequestMapping("saveRecordScript") @RequestMapping("saveRecordScript")
public @ResponseBody public @ResponseBody
BaseResponseModel saveScriptToDB(HttpServletRequest request, BaseResponseModel saveScriptToDB(HttpServletRequest request,
@ModelAttribute("accessToken") String accessToken, @ModelAttribute("accessToken") String accessToken,
@RequestParam String port, @RequestParam String scriptName, @RequestParam String port, @RequestParam String scriptName,
@RequestParam String fileNameUUID) throws CustomGenericException { @RequestParam String fileNameUUID) throws CustomGenericException {
String caller = BASECALLER + "saveRecordScript"; String caller = BASECALLER + "saveRecordScript";
String url = this.getBaseUrl() + "/saveScriptToDB"; String url = this.getBaseUrl() + "/saveScriptToDB";
Map<String, String> params = BaseService.makeParamsMap("scriptName", Map<String, String> params = BaseService.makeParamsMap("scriptName",
scriptName); scriptName);
params.put("port", port); params.put("port", port);
params.put("fileNameUUID", fileNameUUID); params.put("fileNameUUID", fileNameUUID);
OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
.getScriptService() .getScriptService()
.getCommunicateWithMaster() .getCommunicateWithMaster()
.getResponseModel(accessToken, url, .getResponseModel(accessToken, url,
OperateScriptServerResponseModel.class, params, caller); OperateScriptServerResponseModel.class, params, caller);
if (operateScriptServerResponseModel.isSuccess()) if (operateScriptServerResponseModel.isSuccess())
return new BaseResponseModel(true); return new BaseResponseModel(true);
else else
return new BaseResponseModel(false, return new BaseResponseModel(false,
operateScriptServerResponseModel.getFailCauseString()); operateScriptServerResponseModel.getFailCauseString());
} }
@RequestMapping(value = "uploadScript", method = RequestMethod.POST) @RequestMapping(value = "uploadScript", method = RequestMethod.POST)
@ResponseBody @ResponseBody
public BaseResponseModel uploadScript( public BaseResponseModel uploadScript(
@ModelAttribute("accessToken") String accessToken, @ModelAttribute("accessToken") String accessToken,
@RequestParam("script") CommonsMultipartFile script, @RequestParam("script") CommonsMultipartFile script,
@RequestParam String scriptName) throws CustomGenericException { @RequestParam String scriptName) throws CustomGenericException {
if (script.isEmpty()) { if (script.isEmpty()) {
return new BaseResponseModel(false, "empty file"); return new BaseResponseModel(false, "empty file");
} }
if (scriptName == null || scriptName.equals("")) if (scriptName == null || scriptName.equals(""))
return new BaseResponseModel(false, "empty file name"); return new BaseResponseModel(false, "empty file name");
try { try {
String scenarioModel = new String(script.getBytes()); String scenarioModel = new String(script.getBytes());
MarshalHelper.unmarshal(RunScenarioModel.class, scenarioModel); MarshalHelper.unmarshal(RunScenarioModel.class, scenarioModel);
OperateScriptServerResponseModel operateScriptServerResponseModel = this OperateScriptServerResponseModel operateScriptServerResponseModel = this
.getScriptService().uploadScript(accessToken, .getScriptService().uploadScript(accessToken,
scenarioModel, scriptName); scenarioModel, scriptName);
Logger.getLogger(ScriptActionController.class).info( Logger.getLogger(ScriptActionController.class).info(
"script:" + scenarioModel); "script:" + scenarioModel);
if (operateScriptServerResponseModel.isSuccess()) if (operateScriptServerResponseModel.isSuccess())
return new BaseResponseModel(true, (Object) new String( return new BaseResponseModel(true, (Object) new String(
"upload script:" + scriptName + " success!")); "upload script:" + scriptName + " success!"));
else else
return new BaseResponseModel(false, return new BaseResponseModel(false,
operateScriptServerResponseModel.getFailCauseString()); operateScriptServerResponseModel.getFailCauseString());
} catch (JAXBException e) { } catch (JAXBException e) {
Logger.getLogger(ScriptActionController.class).info( Logger.getLogger(ScriptActionController.class).info(
ExceptionLog.getStackTrace(e)); ExceptionLog.getStackTrace(e));
return new BaseResponseModel(false, return new BaseResponseModel(false,
"Failed:invalidated script file!"); "Failed:invalidated script file!");
} }
} }
@RequestMapping("validateScript") @RequestMapping("validateScript")
public @ResponseBody public @ResponseBody
String validateScript(@ModelAttribute("accessToken") String accessToken, String validateScript(@ModelAttribute("accessToken") String accessToken,
@RequestParam String content) { @RequestParam String content) {
String result; String result;
String message = ""; String message = "";
String schemaFileName = "src/main/webapp/WEB-INF/validateScript.xsd"; String schemaFileName = "src/main/webapp/WEB-INF/validateScript.xsd";
content = content.replace("runScenario", "runscenario") content = content.replace("runScenario", "runscenario")
.replace("poolSize", "poolsize") .replace("poolSize", "poolsize")
.replace("usePlugin", "useplugin") .replace("usePlugin", "useplugin")
.replace("userBehavior", "userbehavior") .replace("userBehavior", "userbehavior")
.replace("timerBehavior", "timerbehavior") .replace("timerBehavior", "timerbehavior")
.replace("userbehaviors", "behaviors"); .replace("userbehaviors", "behaviors");
try { try {
result = validateXmlWithSchema(schemaFileName, content); result = validateXmlWithSchema(schemaFileName, content);
if (result == "true") { if (result == "true") {
message = "Success"; message = "Success";
} else { } else {
message = URLEncoder.encode(result, "UTF-8").replace("+", ""); message = URLEncoder.encode(result, "UTF-8").replace("+", "");
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("analysis of failure:" + e.toString()); System.out.println("analysis of failure:" + e.toString());
message = "failed to read schema file"; message = "failed to read schema file";
} }
// System.out.println(message); // System.out.println(message);
return message; return message;
} }
private String validateXmlWithSchema(String schemaFileName, String xmlScript) private String validateXmlWithSchema(String schemaFileName, String xmlScript)
throws SAXException, IOException { throws SAXException, IOException {
String validationResult = ""; String validationResult = "";
SchemaFactory schemaFactory = SchemaFactory SchemaFactory schemaFactory = SchemaFactory
.newInstance("http://www.w3.org/2001/XMLSchema"); .newInstance("http://www.w3.org/2001/XMLSchema");
File schemaFile = new File(schemaFileName); File schemaFile = new File(schemaFileName);
Schema schema = schemaFactory.newSchema(schemaFile); Schema schema = schemaFactory.newSchema(schemaFile);
Validator validator = schema.newValidator(); Validator validator = schema.newValidator();
InputStream script = new ByteArrayInputStream(xmlScript.getBytes()); InputStream script = new ByteArrayInputStream(xmlScript.getBytes());
Source source = new StreamSource(script); Source source = new StreamSource(script);
try { try {
// System.out.println("enter validateXmlWithSchema"); // System.out.println("enter validateXmlWithSchema");
validator.validate(source); validator.validate(source);
validationResult = "true"; validationResult = "true";
} catch (Exception ex) { } catch (Exception ex) {
validationResult = ex.toString(); validationResult = ex.toString();
} }
return validationResult; return validationResult;
} }
@RequestMapping("readSchemaContent") @RequestMapping("readSchemaContent")
public @ResponseBody public @ResponseBody
String readSchemaContent() throws Exception { String readSchemaContent() throws Exception {
String schema = ""; String schema = "";
FileReader fr = new FileReader("src/main/webapp/WEB-INF/schema.json"); FileReader fr = new FileReader("src/main/webapp/WEB-INF/schema.json");
BufferedReader br = new BufferedReader(fr); BufferedReader br = new BufferedReader(fr);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
while ((schema = br.readLine()) != null) { while ((schema = br.readLine()) != null) {
sb.append(schema); sb.append(schema);
} }
br.close(); br.close();
String str = sb.toString(); String str = sb.toString();
return str; return str;
} }
@RequestMapping(value = "uploadPluginEditedScript", method = RequestMethod.POST) @RequestMapping(value = "uploadPluginEditedScript", method = RequestMethod.POST)
@ResponseBody @ResponseBody
public BaseResponseModel uploadPluginEditedScript( public BaseResponseModel uploadPluginEditedScript(
@ModelAttribute("accessToken") String accessToken, @ModelAttribute("accessToken") String accessToken,
@RequestBody String content) throws CustomGenericException { @RequestBody String content) throws CustomGenericException {
Gson gson = new Gson(); Gson gson = new Gson();
Logger.getLogger(ScriptActionController.class).info(content); Logger.getLogger(ScriptActionController.class).info(content);
PluginEditScriptRequestModel pluginEditScriptRequestModel = null; PluginEditScriptRequestModel pluginEditScriptRequestModel = null;
try { try {
pluginEditScriptRequestModel = gson.fromJson(content, pluginEditScriptRequestModel = gson.fromJson(content,
PluginEditScriptRequestModel.class); PluginEditScriptRequestModel.class);
} catch (Exception e) { } catch (Exception e) {
Logger.getLogger(ScriptActionController.class).info( Logger.getLogger(ScriptActionController.class).info(
ExceptionLog.getStackTrace(e)); ExceptionLog.getStackTrace(e));
} }
List<BehaviorModel> behaviorModelsList = pluginEditScriptRequestModel List<BehaviorModel> behaviorModelsList = pluginEditScriptRequestModel
.getBehaviorModels(); .getBehaviorModels();
List<UsePluginModel> usePluginModelsList = pluginEditScriptRequestModel List<UsePluginModel> usePluginModelsList = pluginEditScriptRequestModel
.getUsePluginModels(); .getUsePluginModels();
String scriptName = pluginEditScriptRequestModel.getScriptName(); String scriptName = pluginEditScriptRequestModel.getScriptName();
if (!validateScript(behaviorModelsList, usePluginModelsList)) if (!validateScript(behaviorModelsList, usePluginModelsList))
return new BaseResponseModel(false, "invalidate script"); return new BaseResponseModel(false, "invalidate script");
RunScenarioModel runScenarioModel = this RunScenarioModel runScenarioModel = this
.getScriptService() .getScriptService()
.createRunScenarioModel(behaviorModelsList, usePluginModelsList); .createRunScenarioModel(behaviorModelsList, usePluginModelsList);
try { try {
String script = ObjectXmlExchange.toXml(RunScenarioModel.class, String script = ObjectXmlExchange.toXml(RunScenarioModel.class,
runScenarioModel); runScenarioModel);
OperateScriptServerResponseModel operateScriptServerResponseModel = this OperateScriptServerResponseModel operateScriptServerResponseModel = this
.getScriptService().uploadScript(accessToken, script, .getScriptService().uploadScript(accessToken, script,
scriptName); scriptName);
if (operateScriptServerResponseModel.isSuccess()) if (operateScriptServerResponseModel.isSuccess())
return new BaseResponseModel(true, (Object) new String( return new BaseResponseModel(true, (Object) new String(
"upload script:" + scriptName + " success!")); "upload script:" + scriptName + " success!"));
else else
return new BaseResponseModel(false, return new BaseResponseModel(false,
operateScriptServerResponseModel.getFailCauseString()); operateScriptServerResponseModel.getFailCauseString());
} catch (JAXBException e) { } catch (JAXBException e) {
return new BaseResponseModel(false, return new BaseResponseModel(false,
"Failed:invalidated script file!"); "Failed:invalidated script file!");
} }
} }
private boolean validateScript(List<BehaviorModel> behaviorModels, private boolean validateScript(List<BehaviorModel> behaviorModels,
List<UsePluginModel> usePluginModels) { List<UsePluginModel> usePluginModels) {
if (behaviorModels == null || behaviorModels.size() == 0) if (behaviorModels == null || behaviorModels.size() == 0)
return false; return false;
if (usePluginModels == null || usePluginModels.size() == 0) if (usePluginModels == null || usePluginModels.size() == 0)
return false; return false;
return true; return true;
} }
} }

View File

@ -1,29 +1,29 @@
package org.bench4q.web.model; package org.bench4q.web.model;
public class NameAndIdMap { public class NameAndIdMap {
private int id; private int id;
private String name; private String name;
public NameAndIdMap(int id, String name) { public NameAndIdMap(int id, String name) {
this.id = id; this.id = id;
this.name = name; this.name = name;
} }
public int getId() { public int getId() {
return id; return id;
} }
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
} }

View File

@ -1,311 +1,311 @@
package org.bench4q.web.service; package org.bench4q.web.service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import org.bench4q.share.models.agent.ParameterModel; import org.bench4q.share.models.agent.ParameterModel;
import org.bench4q.share.models.agent.RunScenarioModel; import org.bench4q.share.models.agent.RunScenarioModel;
import org.bench4q.share.models.agent.scriptrecord.BatchModel; import org.bench4q.share.models.agent.scriptrecord.BatchModel;
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel; import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
import org.bench4q.share.models.agent.scriptrecord.PageModel; import org.bench4q.share.models.agent.scriptrecord.PageModel;
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel; import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
import org.bench4q.share.models.master.OperateScriptServerResponseModel; import org.bench4q.share.models.master.OperateScriptServerResponseModel;
import org.bench4q.share.models.master.ScriptModel; import org.bench4q.share.models.master.ScriptModel;
import org.bench4q.web.exception.CustomGenericException; import org.bench4q.web.exception.CustomGenericException;
import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange; import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange;
import org.bench4q.web.model.NameAndIdMap; import org.bench4q.web.model.NameAndIdMap;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
public class ScriptService extends BaseService { public class ScriptService extends BaseService {
private String baseUrl = "RecordScript"; private String baseUrl = "RecordScript";
public String getBaseUrl() { public String getBaseUrl() {
return baseUrl; return baseUrl;
} }
public void setBaseUrl(String baseUrl) { public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl; this.baseUrl = baseUrl;
} }
public ScriptModel queryScriptById(int id, String accessToken) public ScriptModel queryScriptById(int id, String accessToken)
throws CustomGenericException { throws CustomGenericException {
// check script id and return throw exception // check script id and return throw exception
String caller = "ScriptService:queryScript"; String caller = "ScriptService:queryScript";
OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
.getCommunicateWithMaster().getResponseModel(accessToken, .getCommunicateWithMaster().getResponseModel(accessToken,
this.getBaseUrl() + "/queryScriptById", this.getBaseUrl() + "/queryScriptById",
OperateScriptServerResponseModel.class, OperateScriptServerResponseModel.class,
makeParamsMap("scriptId", String.valueOf(id)), caller); makeParamsMap("scriptId", String.valueOf(id)), caller);
if (operateScriptServerResponseModel.isSuccess()) if (operateScriptServerResponseModel.isSuccess())
return operateScriptServerResponseModel.getScriptModels().get(0); return operateScriptServerResponseModel.getScriptModels().get(0);
else else
throw new CustomGenericException("5", "query script failed", caller throw new CustomGenericException("5", "query script failed", caller
+ ":" + id); + ":" + id);
} }
public ScriptModel queryScriptByName(String scriptName, String accessToken) public ScriptModel queryScriptByName(String scriptName, String accessToken)
throws CustomGenericException { throws CustomGenericException {
OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
.getCommunicateWithMaster().getResponseModel(accessToken, .getCommunicateWithMaster().getResponseModel(accessToken,
this.getBaseUrl() + "/queryScriptByName", this.getBaseUrl() + "/queryScriptByName",
OperateScriptServerResponseModel.class, OperateScriptServerResponseModel.class,
makeParamsMap("name", scriptName), ""); makeParamsMap("name", scriptName), "");
if (operateScriptServerResponseModel.isSuccess()) if (operateScriptServerResponseModel.isSuccess())
return operateScriptServerResponseModel.getScriptModels().get(0); return operateScriptServerResponseModel.getScriptModels().get(0);
else else
throw new CustomGenericException("5", "query script failed", "" throw new CustomGenericException("5", "query script failed", ""
+ ":" + scriptName); + ":" + scriptName);
} }
public List<ScriptModel> queryScripts(List<Integer> scriptIds, public List<ScriptModel> queryScripts(List<Integer> scriptIds,
String accessToken) throws CustomGenericException { String accessToken) throws CustomGenericException {
String caller = "ScriptService:queryScript"; String caller = "ScriptService:queryScript";
List<ScriptModel> scriptModels = new ArrayList<ScriptModel>(); List<ScriptModel> scriptModels = new ArrayList<ScriptModel>();
for (Integer scriptId : scriptIds) { for (Integer scriptId : scriptIds) {
OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
.getCommunicateWithMaster() .getCommunicateWithMaster()
.getResponseModel( .getResponseModel(
accessToken, accessToken,
this.getBaseUrl() + "/queryScriptById", this.getBaseUrl() + "/queryScriptById",
OperateScriptServerResponseModel.class, OperateScriptServerResponseModel.class,
makeParamsMap("scriptId", String.valueOf(scriptId)), makeParamsMap("scriptId", String.valueOf(scriptId)),
caller); caller);
if (operateScriptServerResponseModel.isSuccess()) if (operateScriptServerResponseModel.isSuccess())
scriptModels.add(operateScriptServerResponseModel scriptModels.add(operateScriptServerResponseModel
.getScriptModels().get(0)); .getScriptModels().get(0));
else else
throw new CustomGenericException("5", "query script failed", throw new CustomGenericException("5", "query script failed",
caller + ":" + scriptId); caller + ":" + scriptId);
} }
return scriptModels; return scriptModels;
} }
public Map<String, Integer> getScriptNameIdMap( public Map<String, Integer> getScriptNameIdMap(
List<ScriptModel> scriptModels) throws CustomGenericException { List<ScriptModel> scriptModels) throws CustomGenericException {
Map<String, Integer> map = new HashMap<String, Integer>(); Map<String, Integer> map = new HashMap<String, Integer>();
for (ScriptModel scriptModel : scriptModels) { for (ScriptModel scriptModel : scriptModels) {
map.put(scriptModel.getName(), scriptModel.getId()); map.put(scriptModel.getName(), scriptModel.getId());
} }
return map; return map;
} }
public List<NameAndIdMap> getScriptIdNameMap(List<ScriptModel> scriptModels) public List<NameAndIdMap> getScriptIdNameMap(List<ScriptModel> scriptModels)
throws CustomGenericException { throws CustomGenericException {
List<NameAndIdMap> nameAndIdMaps = new ArrayList<NameAndIdMap>(); List<NameAndIdMap> nameAndIdMaps = new ArrayList<NameAndIdMap>();
for (ScriptModel scriptModel : scriptModels) { for (ScriptModel scriptModel : scriptModels) {
NameAndIdMap nameAndIdMap = new NameAndIdMap(scriptModel.getId(), NameAndIdMap nameAndIdMap = new NameAndIdMap(scriptModel.getId(),
scriptModel.getName()); scriptModel.getName());
nameAndIdMaps.add(nameAndIdMap); nameAndIdMaps.add(nameAndIdMap);
} }
return nameAndIdMaps; return nameAndIdMaps;
} }
public Map<String, Integer> getPageNameAndIdMap( public Map<String, Integer> getPageNameAndIdMap(
List<ScriptModel> scriptModels) throws JAXBException { List<ScriptModel> scriptModels) throws JAXBException {
try { try {
Map<String, Integer> map = new HashMap<String, Integer>(); Map<String, Integer> map = new HashMap<String, Integer>();
for (ScriptModel scriptModel : scriptModels) { for (ScriptModel scriptModel : scriptModels) {
Map<String, Integer> pageMap = getPageNameAndIdMap((RunScenarioModel) ObjectXmlExchange Map<String, Integer> pageMap = getPageNameAndIdMap((RunScenarioModel) ObjectXmlExchange
.fromXml(RunScenarioModel.class, .fromXml(RunScenarioModel.class,
scriptModel.getScriptContent())); scriptModel.getScriptContent()));
if (pageMap != null) if (pageMap != null)
map.putAll(pageMap); map.putAll(pageMap);
} }
return map; return map;
} catch (NullPointerException e) { } catch (NullPointerException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
} }
private Map<String, Integer> getPageNameAndIdMap( private Map<String, Integer> getPageNameAndIdMap(
RunScenarioModel runScenarioModel) { RunScenarioModel runScenarioModel) {
List<PageModel> pageModels = runScenarioModel.getPages(); List<PageModel> pageModels = runScenarioModel.getPages();
try { try {
Map<String, Integer> map = new HashMap<String, Integer>(); Map<String, Integer> map = new HashMap<String, Integer>();
for (int i = 0; i < pageModels.size(); i++) { for (int i = 0; i < pageModels.size(); i++) {
map.put("page_" + i, i); map.put("page_" + i, i);
} }
return map; return map;
} catch (NullPointerException e) { } catch (NullPointerException e) {
return null; return null;
} }
} }
public Map<String, Integer> getBehaviorNameAndIdMap( public Map<String, Integer> getBehaviorNameAndIdMap(
List<ScriptModel> scriptModels) throws JAXBException { List<ScriptModel> scriptModels) throws JAXBException {
try { try {
Map<String, Integer> map = new HashMap<String, Integer>(); Map<String, Integer> map = new HashMap<String, Integer>();
for (ScriptModel scriptModel : scriptModels) { for (ScriptModel scriptModel : scriptModels) {
Map<String, Integer> behaviorMap = getBehaviorNameAndIdMap((RunScenarioModel) ObjectXmlExchange Map<String, Integer> behaviorMap = getBehaviorNameAndIdMap((RunScenarioModel) ObjectXmlExchange
.fromXml(RunScenarioModel.class, .fromXml(RunScenarioModel.class,
scriptModel.getScriptContent())); scriptModel.getScriptContent()));
if (behaviorMap != null) if (behaviorMap != null)
map.putAll(behaviorMap); map.putAll(behaviorMap);
} }
return map; return map;
} catch (NullPointerException e) { } catch (NullPointerException e) {
return null; return null;
} }
} }
public List<String> getScriptPages(RunScenarioModel runScenarioModel) { public List<String> getScriptPages(RunScenarioModel runScenarioModel) {
try { try {
List<String> scriptPages = new ArrayList<String>(); List<String> scriptPages = new ArrayList<String>();
for (int i = 1; i < scriptPages.size(); i++) { for (int i = 1; i < scriptPages.size(); i++) {
scriptPages.add("page_" + i); scriptPages.add("page_" + i);
} }
return scriptPages; return scriptPages;
} catch (NullPointerException e) { } catch (NullPointerException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
} }
public List<String> getScriptBehaviorUrl(RunScenarioModel runScenarioModel) { public List<String> getScriptBehaviorUrl(RunScenarioModel runScenarioModel) {
List<BehaviorModel> behaviorModelsWithUrl = getBehaviorModelsHasUrl(runScenarioModel); List<BehaviorModel> behaviorModelsWithUrl = getBehaviorModelsHasUrl(runScenarioModel);
if (behaviorModelsWithUrl == null) if (behaviorModelsWithUrl == null)
return null; return null;
List<String> urList = new ArrayList<String>(); List<String> urList = new ArrayList<String>();
for (BehaviorModel behaviorModelWithUrl : behaviorModelsWithUrl) { for (BehaviorModel behaviorModelWithUrl : behaviorModelsWithUrl) {
String url = generateUrl(behaviorModelWithUrl.getParameters()); String url = generateUrl(behaviorModelWithUrl.getParameters());
urList.add(url); urList.add(url);
} }
return urList; return urList;
} }
public Map<String, Integer> getBehaviorNameAndIdMap( public Map<String, Integer> getBehaviorNameAndIdMap(
RunScenarioModel runScenarioModel) { RunScenarioModel runScenarioModel) {
try { try {
Map<String, Integer> map = new HashMap<String, Integer>(); Map<String, Integer> map = new HashMap<String, Integer>();
List<BehaviorModel> behaviorModels = this List<BehaviorModel> behaviorModels = this
.getBehaviorModelsHasUrl(runScenarioModel); .getBehaviorModelsHasUrl(runScenarioModel);
if (behaviorModels == null) if (behaviorModels == null)
return null; return null;
for (BehaviorModel behaviorModel : behaviorModels) { for (BehaviorModel behaviorModel : behaviorModels) {
String url = this.generateUrl(behaviorModel.getParameters()); String url = this.generateUrl(behaviorModel.getParameters());
if (url != null) if (url != null)
map.put(url, behaviorModel.getId()); map.put(url, behaviorModel.getId());
} }
return map; return map;
} catch (NullPointerException e) { } catch (NullPointerException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
} }
private String generateUrl(List<ParameterModel> parameterModels) { private String generateUrl(List<ParameterModel> parameterModels) {
String url = new String(""); String url = new String("");
int i = 0; int i = 0;
for (ParameterModel parameterModel : parameterModels) { for (ParameterModel parameterModel : parameterModels) {
if (i == 1 && parameterModel.getValue() != null) if (i == 1 && parameterModel.getValue() != null)
url += "?" + parameterModel.getValue(); url += "?" + parameterModel.getValue();
if (i > 1 && parameterModel.getValue() != null) if (i > 1 && parameterModel.getValue() != null)
url += "&" + parameterModel.getValue(); url += "&" + parameterModel.getValue();
i++; i++;
} }
if (url.length() <= 0) if (url.length() <= 0)
return null; return null;
return url; return url;
} }
private List<BehaviorModel> getBehaviorModelsHasUrl( private List<BehaviorModel> getBehaviorModelsHasUrl(
RunScenarioModel runScenarioModel) { RunScenarioModel runScenarioModel) {
try { try {
List<BehaviorModel> behaviorModels = getBehaviorModels(runScenarioModel); List<BehaviorModel> behaviorModels = getBehaviorModels(runScenarioModel);
if (behaviorModels == null) if (behaviorModels == null)
return null; return null;
List<BehaviorModel> behaviorModelsWithUrl = new ArrayList<BehaviorModel>(); List<BehaviorModel> behaviorModelsWithUrl = new ArrayList<BehaviorModel>();
for (BehaviorModel behaviorModel : behaviorModels) { for (BehaviorModel behaviorModel : behaviorModels) {
List<ParameterModel> parameterModels = new ArrayList<ParameterModel>(); List<ParameterModel> parameterModels = new ArrayList<ParameterModel>();
parameterModels.addAll(behaviorModel.getParameters()); parameterModels.addAll(behaviorModel.getParameters());
for (ParameterModel parameterModel : parameterModels) { for (ParameterModel parameterModel : parameterModels) {
if (parameterModel.getKey().equals("url")) if (parameterModel.getKey().equals("url"))
behaviorModelsWithUrl.add(behaviorModel); behaviorModelsWithUrl.add(behaviorModel);
break; break;
} }
} }
return behaviorModelsWithUrl; return behaviorModelsWithUrl;
} catch (NullPointerException e) { } catch (NullPointerException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
} }
private List<BehaviorModel> getBehaviorModels( private List<BehaviorModel> getBehaviorModels(
RunScenarioModel runScenarioModel) { RunScenarioModel runScenarioModel) {
try { try {
List<BatchModel> batchModels = new ArrayList<BatchModel>(); List<BatchModel> batchModels = new ArrayList<BatchModel>();
for (PageModel pageModel : runScenarioModel.getPages()) for (PageModel pageModel : runScenarioModel.getPages())
batchModels.addAll(pageModel.getBatches()); batchModels.addAll(pageModel.getBatches());
List<BehaviorModel> behaviorModels = new ArrayList<BehaviorModel>(); List<BehaviorModel> behaviorModels = new ArrayList<BehaviorModel>();
for (BatchModel batchModel : batchModels) for (BatchModel batchModel : batchModels)
behaviorModels.addAll(batchModel.getBehaviors()); behaviorModels.addAll(batchModel.getBehaviors());
return behaviorModels; return behaviorModels;
} catch (NullPointerException e) { } catch (NullPointerException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
} }
public RunScenarioModel createRunScenarioModel( public RunScenarioModel createRunScenarioModel(
List<BehaviorModel> behaviorModels, List<BehaviorModel> behaviorModels,
List<UsePluginModel> usedPluginModels) { List<UsePluginModel> usedPluginModels) {
RunScenarioModel runScenarioModel = new RunScenarioModel(); RunScenarioModel runScenarioModel = new RunScenarioModel();
runScenarioModel runScenarioModel
.setPages(createPageModelsWithBehaviorList(behaviorModels)); .setPages(createPageModelsWithBehaviorList(behaviorModels));
runScenarioModel.setUsePlugins(usedPluginModels); runScenarioModel.setUsePlugins(usedPluginModels);
return runScenarioModel; return runScenarioModel;
} }
private List<PageModel> createPageModelsWithBehaviorList( private List<PageModel> createPageModelsWithBehaviorList(
List<BehaviorModel> behaviorModels) { List<BehaviorModel> behaviorModels) {
List<PageModel> pageModels = new ArrayList<PageModel>(); List<PageModel> pageModels = new ArrayList<PageModel>();
for (BehaviorModel behaviorModel : behaviorModels) { for (BehaviorModel behaviorModel : behaviorModels) {
pageModels.add(createPageModelWithOneBehaviorModel(behaviorModel)); pageModels.add(createPageModelWithOneBehaviorModel(behaviorModel));
} }
return pageModels; return pageModels;
} }
private PageModel createPageModelWithOneBehaviorModel( private PageModel createPageModelWithOneBehaviorModel(
BehaviorModel behaviorModel) { BehaviorModel behaviorModel) {
PageModel pageModel = new PageModel(); PageModel pageModel = new PageModel();
pageModel.setBatches(new ArrayList<BatchModel>()); pageModel.setBatches(new ArrayList<BatchModel>());
pageModel.getBatches().add( pageModel.getBatches().add(
createBatchModelWithOneBehavior(behaviorModel)); createBatchModelWithOneBehavior(behaviorModel));
return pageModel; return pageModel;
} }
private BatchModel createBatchModelWithOneBehavior( private BatchModel createBatchModelWithOneBehavior(
BehaviorModel behaviorModel) { BehaviorModel behaviorModel) {
BatchModel batchModel = new BatchModel(); BatchModel batchModel = new BatchModel();
batchModel.setBehaviors(new ArrayList<BehaviorModel>()); batchModel.setBehaviors(new ArrayList<BehaviorModel>());
batchModel.getBehaviors().add(behaviorModel); batchModel.getBehaviors().add(behaviorModel);
batchModel.setChildId(-1); batchModel.setChildId(-1);
batchModel.setParentId(-1); batchModel.setParentId(-1);
batchModel.setId(behaviorModel.getId()); batchModel.setId(behaviorModel.getId());
return batchModel; return batchModel;
} }
public OperateScriptServerResponseModel uploadScript(String accessToken, public OperateScriptServerResponseModel uploadScript(String accessToken,
String scenarioModel, String scriptName) String scenarioModel, String scriptName)
throws CustomGenericException { throws CustomGenericException {
String url = "RecordScript" + "/uploadScript" + "/" + scriptName; String url = "RecordScript" + "/uploadScript" + "/" + scriptName;
return (OperateScriptServerResponseModel) getCommunicateWithMaster() return (OperateScriptServerResponseModel) getCommunicateWithMaster()
.getResponseModelByPut(accessToken, url, scenarioModel, .getResponseModelByPut(accessToken, url, scenarioModel,
OperateScriptServerResponseModel.class, "upload script"); OperateScriptServerResponseModel.class, "upload script");
} }
} }

View File

@ -1,6 +1,6 @@
.loginDiv { .loginDiv {
margin: 20px auto; margin: 20px auto;
width: 958px; width: 958px;
height: 600px; height: 600px;
background-color: #efefef; background-color: #efefef;
} }

View File

@ -1,42 +1,42 @@
.registerContainer { .registerContainer {
background-color: #efefef; background-color: #efefef;
padding-top: 80px; padding-top: 80px;
padding-left: 20px; padding-left: 20px;
padding-bottom: 50px; padding-bottom: 50px;
padding-right: 20px; padding-right: 20px;
} }
.left { .left {
float: left; float: left;
} }
.bench4qLog { .bench4qLog {
float: right; float: right;
} }
.tipContainer { .tipContainer {
height: 50px; height: 50px;
width: 50%; width: 50%;
margin-bottom: 30px; margin-bottom: 30px;
} }
.registerInput { .registerInput {
margin-bottom: 20px; margin-bottom: 20px;
} }
.hide { .hide {
display: none; display: none;
} }
.userInput { .userInput {
margin-bottom: 50px; margin-bottom: 50px;
} }
input { input {
vertical-align: middle; vertical-align: middle;
} }
.submitDiv { .submitDiv {
float: left; float: left;
margin-right: 50px; margin-right: 50px;
} }

View File

@ -1,6 +1,6 @@
addField=Add Field addField=Add Field
removeField=Remove Field removeField=Remove Field
addCol=addCol addCol=addCol
removeCol=removeCol removeCol=removeCol
save=Save save=Save
cancel=Cancel cancel=Cancel

View File

@ -1,6 +1,6 @@
addField=\u6DFB\u52A0\u57DF addField=\u6DFB\u52A0\u57DF
removeField=\u79FB\u9664\u57DF removeField=\u79FB\u9664\u57DF
addCol=\u6DFB\u52A0\u884C addCol=\u6DFB\u52A0\u884C
removeCol=\u79FB\u9664\u884C removeCol=\u79FB\u9664\u884C
cancel=\u53D6\u6D88 cancel=\u53D6\u6D88
save=\u4FDD\u5B58 save=\u4FDD\u5B58

File diff suppressed because it is too large Load Diff

View File

@ -1,144 +1,144 @@
<%@page language="java" contentType="text/html; charset=GBK" <%@page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%> pageEncoding="GBK"%>
<html> <html>
<head> <head>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="pragma" content="no-cache"> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Bench4Q</title> <title>Bench4Q</title>
<link rel="search" type="application/opensearchdescription+xml" <link rel="search" type="application/opensearchdescription+xml"
href="https://github.com/opensearch.xml" title="GitHub"> href="https://github.com/opensearch.xml" title="GitHub">
<link rel="fluid-icon" href="https://github.com/fluidicon.png" <link rel="fluid-icon" href="https://github.com/fluidicon.png"
title="GitHub"> title="GitHub">
<link rel="shortcut icon" href="favicon.ico" type="images/x-icon"> <link rel="shortcut icon" href="favicon.ico" type="images/x-icon">
<meta content="authenticity_token" name="csrf-param"> <meta content="authenticity_token" name="csrf-param">
<meta content="wedm5SiF4gf6cxpqmjS1xTCRp86Sc8PAssZUiID8N0M=" <meta content="wedm5SiF4gf6cxpqmjS1xTCRp86Sc8PAssZUiID8N0M="
name="csrf-token"> name="csrf-token">
<link href="lib/github/css/github-6053501db2b69fd2b04652c6349117be14468ce4.css" <link href="lib/github/css/github-6053501db2b69fd2b04652c6349117be14468ce4.css"
media="screen" rel="stylesheet" type="text/css"> media="screen" rel="stylesheet" type="text/css">
<link href="lib/github/css/github2-277183b6724249eea8a7d10300542831eac78d3f.css" <link href="lib/github/css/github2-277183b6724249eea8a7d10300542831eac78d3f.css"
media="screen" rel="stylesheet" type="text/css"> media="screen" rel="stylesheet" type="text/css">
<link href="css/login.css" rel="stylesheet"> <link href="css/login.css" rel="stylesheet">
<link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css" rel="stylesheet"> <link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css" rel="stylesheet">
<script src="lib/other/frameworks-a450c7f907bdc1ee6b362ab1ecca811c761fd259.js" <script src="lib/other/frameworks-a450c7f907bdc1ee6b362ab1ecca811c761fd259.js"
type="text/javascript"></script> type="text/javascript"></script>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><link rel="stylesheet" type="text/css" href="flip_ie.css"/><![endif]--> <!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><link rel="stylesheet" type="text/css" href="flip_ie.css"/><![endif]-->
<!-- <script src="http://www.google.com/jsapi"></script> --> <!-- <script src="http://www.google.com/jsapi"></script> -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head> </head>
<body class="logged_out wider windows env-production "> <body class="logged_out wider windows env-production ">
<div id="wrapper"> <div id="wrapper">
<div id="header" class="true clearfix"> <div id="header" class="true clearfix">
<div class="container clearfix"> <div class="container clearfix">
<a class="site-logo" href="index.jsp"> <img alt="GitHub" <a class="site-logo" href="index.jsp"> <img alt="GitHub"
class="github-logo-4x" src="images/headerLogo.png" height="30"> <img class="github-logo-4x" src="images/headerLogo.png" height="30"> <img
alt="GitHub" class="github-logo-4x-hover" src="images/bench4q-2.png" alt="GitHub" class="github-logo-4x-hover" src="images/bench4q-2.png"
height="30"> height="30">
</a> </a>
<ul class="top-nav logged_out"> <ul class="top-nav logged_out">
<li class="login"><a href="login.jsp"><fmt:message key="login_jsp_home" /></a></li> <li class="login"><a href="login.jsp"><fmt:message key="login_jsp_home" /></a></li>
<li class="login"><a href="register.jsp"><fmt:message key="login_jsp_register" /></a></li> <li class="login"><a href="register.jsp"><fmt:message key="login_jsp_register" /></a></li>
</ul> </ul>
</div> </div>
</div> </div>
<div class="site home"> <div class="site home">
<div class="container"> <div class="container">
<div class="pagehead homehead"> <div class="pagehead homehead">
<div class="hero"> <div class="hero">
<h1><fmt:message key="login_jsp_Title" /></h1> <h1><fmt:message key="login_jsp_Title" /></h1>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="loginDiv"> <div class="loginDiv">
<div style="height: 20px"></div> <div style="height: 20px"></div>
<div style="font-size: 18px; margin-left: 280px"> <div style="font-size: 18px; margin-left: 280px">
<h1><fmt:message key="login_jsp_welcome" /></h1> <h1><fmt:message key="login_jsp_welcome" /></h1>
</div> </div>
<div style="height: 60px;"></div> <div style="height: 60px;"></div>
<div id="div1" style="float: left; width: 270px; height: 300px;"></div> <div id="div1" style="float: left; width: 270px; height: 300px;"></div>
<div id="div2" <div id="div2"
style="width: 400px; height: 300px; float: left; background-color: #e9f1f4; border: efefff 1px solid;"> style="width: 400px; height: 300px; float: left; background-color: #e9f1f4; border: efefff 1px solid;">
<div style="width: 100%; height: 100%"> <div style="width: 100%; height: 100%">
<div style="width: 100%; height: 40px; background-color: #607989"> <div style="width: 100%; height: 40px; background-color: #607989">
<div style="width: 10%; height: 40px; float: left"></div> <div style="width: 10%; height: 40px; float: left"></div>
<div <div
style="font-size: 20px; color: #ffffff; padding-top: 5px; font-weight: 900"> style="font-size: 20px; color: #ffffff; padding-top: 5px; font-weight: 900">
<fmt:message key="login_jsp_signIn" /> <a <fmt:message key="login_jsp_signIn" /> <a
style="font-size: 15px; color: #ffffff; font-weight: normal" style="font-size: 15px; color: #ffffff; font-weight: normal"
href="register.jsp">(<fmt:message key="login_jsp_register" />)</a> href="register.jsp">(<fmt:message key="login_jsp_register" />)</a>
</div> </div>
</div> </div>
<div style="width: 100%; height: 260px;"> <div style="width: 100%; height: 260px;">
<div style="height: 10px; width: 100%"></div> <div style="height: 10px; width: 100%"></div>
<div style="height: 40px; width: 100% border:black 1px solid;"> <div style="height: 40px; width: 100% border:black 1px solid;">
<div <div
style="height: 40px; width: 30px; padding-left: 40px; float: left"> style="height: 40px; width: 30px; padding-left: 40px; float: left">
<img src="images/username.jpg" /> <img src="images/username.jpg" />
</div> </div>
<div style="height: 40px; padding-top: 9px;"> <div style="height: 40px; padding-top: 9px;">
&nbsp;&nbsp;&nbsp;<fmt:message key="login_jsp_username" /> </div> &nbsp;&nbsp;&nbsp;<fmt:message key="login_jsp_username" /> </div>
</div> </div>
<div style="height: 2px; width: 100%"></div> <div style="height: 2px; width: 100%"></div>
<div> <div>
<input autofocus type="text" id="username" name="username" <input autofocus type="text" id="username" name="username"
style="font-size: 18px; margin-left: 40px; height: 30px; width: 300px;" style="font-size: 18px; margin-left: 40px; height: 30px; width: 300px;"
onblur="checkName(this.value)" /> onblur="checkName(this.value)" />
<div id='alertUserName' <div id='alertUserName'
style='display: none; color: red; margin-left: 40px'><fmt:message key="login_jsp_usernameWarnning" /> </div> style='display: none; color: red; margin-left: 40px'><fmt:message key="login_jsp_usernameWarnning" /> </div>
</div> </div>
<div style="height: 10px; width: 100%"></div> <div style="height: 10px; width: 100%"></div>
<div style="height: 40px; width: 100%"> <div style="height: 40px; width: 100%">
<div <div
style="height: 40px; width: 30; padding-left: 40px; float: left"> style="height: 40px; width: 30; padding-left: 40px; float: left">
<img src="images/password.jpg" /> <img src="images/password.jpg" />
</div> </div>
<div style="height: 40px; padding-top: 9px;"> <div style="height: 40px; padding-top: 9px;">
&nbsp;&nbsp;&nbsp;<fmt:message key="login_jsp_password" /> </div> &nbsp;&nbsp;&nbsp;<fmt:message key="login_jsp_password" /> </div>
</div> </div>
<div style="height: 10px; width: 100%"></div> <div style="height: 10px; width: 100%"></div>
<div> <div>
<input type="password" id="password" name="password" <input type="password" id="password" name="password"
style="font-size: 18px; margin-left: 40px; height: 30px; width: 300px;" style="font-size: 18px; margin-left: 40px; height: 30px; width: 300px;"
onblur="checkPass(this.value)" /> onblur="checkPass(this.value)" />
<div id='alertPassWord' <div id='alertPassWord'
style='display: none; color: red; margin-left: 40px'><fmt:message key="login_jsp_passwordWarnning" /> </div> style='display: none; color: red; margin-left: 40px'><fmt:message key="login_jsp_passwordWarnning" /> </div>
</div> </div>
<div style="height: 20px; width: 100%"></div> <div style="height: 20px; width: 100%"></div>
<div style="height: 40px; padding-left: 40px;"> <div style="height: 40px; padding-left: 40px;">
<button type="submit" class="btn btn-large btn-primary" <button type="submit" class="btn btn-large btn-primary"
onClick="login()"><fmt:message key="login_jsp_signIn" /> </button> onClick="login()"><fmt:message key="login_jsp_signIn" /> </button>
<button type="submit" class="btn btn-large btn-primary" <button type="submit" class="btn btn-large btn-primary"
onClick="adminLogin()"><fmt:message key="login_jsp_admin" /> </button> onClick="adminLogin()"><fmt:message key="login_jsp_admin" /> </button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js"></script>
<script src="script/login.js"></script> <script src="script/login.js"></script>
</body> </body>
</html> </html>

View File

@ -1,269 +1,269 @@
<!DOCTYPE html> <!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%> pageEncoding="UTF-8"%>
<html> <html>
<head> <head>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Bench4Q</title> <title>Bench4Q</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" <meta name="description"
content="Bench4Q, a new method for QOS benchmarking."> content="Bench4Q, a new method for QOS benchmarking.">
<link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css" rel="stylesheet"> <link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css" rel="stylesheet">
<link href="lib/chrisma/css/opa-icons.css" rel="stylesheet"> <link href="lib/chrisma/css/opa-icons.css" rel="stylesheet">
<link <link
href="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.2/css/bootstrap-responsive.css" href="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.2/css/bootstrap-responsive.css"
rel="stylesheet"> rel="stylesheet">
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet"> <link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<style type="text/css"> <style type="text/css">
body { body {
padding-bottom: 40px; padding-bottom: 40px;
} }
.sidebar-nav { .sidebar-nav {
padding: 9px 0; padding: 9px 0;
} }
</style> </style>
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet"> <link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<link href="css/bench4q.css" rel="stylesheet"> <link href="css/bench4q.css" rel="stylesheet">
<link href='css/plugin.css' rel='stylesheet'> <link href='css/plugin.css' rel='stylesheet'>
<link rel="shortcut icon" href="images/bench4q.png"> <link rel="shortcut icon" href="images/bench4q.png">
<!-- The HTML5 shim, for IE6-8 support of HTML5 elements --> <!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]--> <![endif]-->
<!-- The fav icon --> <!-- The fav icon -->
<link rel="shortcut icon" href="img/favicon.ico"> <link rel="shortcut icon" href="img/favicon.ico">
</head> </head>
<body> <body>
<fmt:bundle basename="i18n"> <fmt:bundle basename="i18n">
<!-- topbar starts --> <!-- topbar starts -->
<jsp:include page="publiccontrol/navigatebar.jsp"></jsp:include> <jsp:include page="publiccontrol/navigatebar.jsp"></jsp:include>
<!-- topbar ends --> <!-- topbar ends -->
<div class="container-fluid"> <div class="container-fluid">
<div class="row-fluid"> <div class="row-fluid">
<jsp:include page="publiccontrol/leftmenubar.jsp"></jsp:include> <jsp:include page="publiccontrol/leftmenubar.jsp"></jsp:include>
<noscript> <noscript>
<div class="alert alert-block span10"> <div class="alert alert-block span10">
<h4 class="alert-heading"> <h4 class="alert-heading">
<fmt:message key="warning" /> <fmt:message key="warning" />
! !
</h4> </h4>
<p> <p>
<fmt:message key="warningcontent1" /> <fmt:message key="warningcontent1" />
<a href="http://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a> <a href="http://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a>
<fmt:message key="warningcontent2" /> <fmt:message key="warningcontent2" />
. .
</p> </p>
</div> </div>
</noscript> </noscript>
<div id="content" class="span10"> <div id="content" class="span10">
<!-- content starts --> <!-- content starts -->
<div> <div>
<ul class="breadcrumb"> <ul class="breadcrumb">
<li><a href="homepage.jsp"><fmt:message key="home" /></a> <span <li><a href="homepage.jsp"><fmt:message key="home" /></a> <span
class="divider">/</span></li> class="divider">/</span></li>
<li><a href="script.jsp"><fmt:message <li><a href="script.jsp"><fmt:message
key="scriptmanagement" /></a><span class="divider">/</span></li> key="scriptmanagement" /></a><span class="divider">/</span></li>
<li><a href="plugin.jsp"><fmt:message <li><a href="plugin.jsp"><fmt:message
key="script_jsp_makeScript" /></a></li> key="script_jsp_makeScript" /></a></li>
</ul> </ul>
</div> </div>
<div class="row-fluid sortable"> <div class="row-fluid sortable">
<div class="box span6"> <div class="box span6">
<div class="box-header well" data-original-title> <div class="box-header well" data-original-title>
<i class="icon-pencil left"></i> <i class="icon-pencil left"></i>
<h2> <h2>
<span><fmt:message key="plugin_jsp_plugins" />(usePlugins)</span> <span><fmt:message key="plugin_jsp_plugins" />(usePlugins)</span>
</h2> </h2>
<div class="box-icon"> <div class="box-icon">
<a href="#" class="btn btn-setting btn-round"><i <a href="#" class="btn btn-setting btn-round"><i
class="icon-plus"></i></a> <a href="#" class="btn btn-round"><i class="icon-plus"></i></a> <a href="#" class="btn btn-round"><i
class="icon-list"></i></a> <a href="#" class="icon-list"></i></a> <a href="#"
class="btn btn-minimize btn-round"><i class="btn btn-minimize btn-round"><i
class="icon-chevron-up"></i></a> class="icon-chevron-up"></i></a>
</div> </div>
</div> </div>
<div class="box-content row-fluid"> <div class="box-content row-fluid">
<div id="pluginArea" class="listArea span9"></div> <div id="pluginArea" class="listArea span9"></div>
<div class=" span3 button-div"> <div class=" span3 button-div">
<div> <div>
<button type="submit" class="btn btn-primary btn-width" <button type="submit" class="btn btn-primary btn-width"
id="addPlugin" onClick="addPlugin();"> id="addPlugin" onClick="addPlugin();">
<fmt:message key="plugin_jsp_add" /> <fmt:message key="plugin_jsp_add" />
</button> </button>
</div> </div>
<div> <div>
<button type="submit" class="btn btn-primary btn-width" <button type="submit" class="btn btn-primary btn-width"
id="removePlugin" onClick="removePluginByClicked();"> id="removePlugin" onClick="removePluginByClicked();">
<fmt:message key="plugin_jsp_remove" /> <fmt:message key="plugin_jsp_remove" />
</button> </button>
</div> </div>
<div> <div>
<button type="submit" class="btn btn-primary btn-width" <button type="submit" class="btn btn-primary btn-width"
id="removeAllPlugin" onClick="clearPluginChoosedList();"> id="removeAllPlugin" onClick="clearPluginChoosedList();">
<fmt:message key="plugin_jsp_clear" /> <fmt:message key="plugin_jsp_clear" />
</button> </button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!--/span--> <!--/span-->
<!-- Behavior start --> <!-- Behavior start -->
<div class="box span6"> <div class="box span6">
<div class="box-header well" data-original-title> <div class="box-header well" data-original-title>
<i class="icon-pencil left"></i> <i class="icon-pencil left"></i>
<h2> <h2>
<i></i> <i></i>
<fmt:message key="plugin_jsp_behavior" /> <fmt:message key="plugin_jsp_behavior" />
(behaviors) (behaviors)
</h2> </h2>
<div class="box-icon"> <div class="box-icon">
<a href="#" class="btn btn-setting btn-round"><i <a href="#" class="btn btn-setting btn-round"><i
class="icon-plus"></i></a> <a href="#" class="btn btn-round"><i class="icon-plus"></i></a> <a href="#" class="btn btn-round"><i
class="icon-list"></i></a> <a href="#" class="icon-list"></i></a> <a href="#"
class="btn btn-minimize btn-round"><i class="btn btn-minimize btn-round"><i
class="icon-chevron-up"></i></a> class="icon-chevron-up"></i></a>
</div> </div>
</div> </div>
<div class="box-content row-fluid"> <div class="box-content row-fluid">
<div id="behaviorArea" class="listArea span9"></div> <div id="behaviorArea" class="listArea span9"></div>
<div class="span3 button-div"> <div class="span3 button-div">
<div class="hide" id="insertBefore"> <div class="hide" id="insertBefore">
<button type="submit" class="btn btn-primary btn-width" <button type="submit" class="btn btn-primary btn-width"
onClick="insert();"> onClick="insert();">
<fmt:message key="plugin_jsp_insertBefore" /> <fmt:message key="plugin_jsp_insertBefore" />
</button> </button>
</div> </div>
<div> <div>
<button type="submit" class="btn btn-primary btn-width" <button type="submit" class="btn btn-primary btn-width"
onClick="insertAfter();"> onClick="insertAfter();">
<fmt:message key="plugin_jsp_insertAfter" /> <fmt:message key="plugin_jsp_insertAfter" />
</button> </button>
</div> </div>
<div> <div>
<button type="submit" class="btn btn-primary btn-width" <button type="submit" class="btn btn-primary btn-width"
id="removeBehavior_Plugin" id="removeBehavior_Plugin"
onClick="removeInsertPluginByClicked();"> onClick="removeInsertPluginByClicked();">
<fmt:message key="plugin_jsp_remove" /> <fmt:message key="plugin_jsp_remove" />
</button> </button>
</div> </div>
<div> <div>
<button type="submit" class="btn btn-primary btn-width" <button type="submit" class="btn btn-primary btn-width"
onClick="clearPluginMethodList();"> onClick="clearPluginMethodList();">
<fmt:message key="plugin_jsp_clear" /> <fmt:message key="plugin_jsp_clear" />
</button> </button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="showPluginMethod" class="showPluginMethod"></div> <div id="showPluginMethod" class="showPluginMethod"></div>
</div> </div>
<!--/row--> <!--/row-->
<!-- content ends --> <!-- content ends -->
<div class="hide" id="submitBehaviors"> <div class="hide" id="submitBehaviors">
<p> <p>
<fmt:message key="plugin_jsp_scriptName"></fmt:message> <fmt:message key="plugin_jsp_scriptName"></fmt:message>
<input id="writeAScriptName" type="text" name="scriptName" <input id="writeAScriptName" type="text" name="scriptName"
size=20></input> size=20></input>
</p> </p>
<p> <p>
<button class='btn-large' onClick="submitBehaviors(this);"> <button class='btn-large' onClick="submitBehaviors(this);">
<fmt:message key="plugin_jsp_submit" /> <fmt:message key="plugin_jsp_submit" />
</button> </button>
</p> </p>
</div> </div>
</div> </div>
<!--/#content.span10--> <!--/#content.span10-->
</div> </div>
<hr> <hr>
<div class="modal hide fade " id="myModal_Plugin"> <div class="modal hide fade " id="myModal_Plugin">
<div class="modal-header"> <div class="modal-header">
<button type="button" id="myModal-close" class="close" <button type="button" id="myModal-close" class="close"
data-dismiss="modal">×</button> data-dismiss="modal">×</button>
<h3> <h3>
<fmt:message key="plugin_jsp_addNewPlugin" /> <fmt:message key="plugin_jsp_addNewPlugin" />
</h3> </h3>
</div> </div>
<div class="modal-body" style="height: 260px;"> <div class="modal-body" style="height: 260px;">
<div class="inset scroll" id="choosePlugin"></div> <div class="inset scroll" id="choosePlugin"></div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-primary btn-width" <button type="button" class="btn btn-primary btn-width"
onClick="pluginFinish();" id="pluginFinish"> onClick="pluginFinish();" id="pluginFinish">
<fmt:message key="plugin_jsp_finish" /> <fmt:message key="plugin_jsp_finish" />
</button> </button>
<button type="button" class="btn btn-primary btn-width" <button type="button" class="btn btn-primary btn-width"
onClick="pluginCancel();" id="pluginCancel"> onClick="pluginCancel();" id="pluginCancel">
<fmt:message key="plugin_jsp_cancel" /> <fmt:message key="plugin_jsp_cancel" />
</button> </button>
</div> </div>
</div> </div>
<div class="modal hide fade " id="myModal_Behavior"> <div class="modal hide fade " id="myModal_Behavior">
<div class="modal-header"> <div class="modal-header">
<button type="button" id="myModal-close" class="close" <button type="button" id="myModal-close" class="close"
data-dismiss="modal">×</button> data-dismiss="modal">×</button>
<h3> <h3>
<fmt:message key="plugin_jsp_chooseBehaviors" /> <fmt:message key="plugin_jsp_chooseBehaviors" />
</h3> </h3>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="row-fluid"> <div class="row-fluid">
<div class="span6 behavior-box scroll"> <div class="span6 behavior-box scroll">
<div id="insertPluginAreaPlugins"></div> <div id="insertPluginAreaPlugins"></div>
</div> </div>
<div class="span6 behavior-box scroll"> <div class="span6 behavior-box scroll">
<div id="pluginMethod"></div> <div id="pluginMethod"></div>
</div> </div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-primary btn-width" <button type="button" class="btn btn-primary btn-width"
onClick="behaviorFinish();" id="behaviorFinish"> onClick="behaviorFinish();" id="behaviorFinish">
<fmt:message key="plugin_jsp_finish" /> <fmt:message key="plugin_jsp_finish" />
</button> </button>
<button type="button" class="btn btn-primary btn-width" onClick="" <button type="button" class="btn btn-primary btn-width" onClick=""
id="behaviorCancel"> id="behaviorCancel">
<fmt:message key="plugin_jsp_cancel" /> <fmt:message key="plugin_jsp_cancel" />
</button> </button>
</div> </div>
</div> </div>
<jsp:include page="publiccontrol/footer.jsp"></jsp:include> <jsp:include page="publiccontrol/footer.jsp"></jsp:include>
</div> </div>
<!--/.fluid-container--> <!--/.fluid-container-->
<!-- external javascript <!-- external javascript
================================================== --> ================================================== -->
<!-- Placed at the end of the document so the pages load faster --> <!-- Placed at the end of the document so the pages load faster -->
<!-- jQuery --> <!-- jQuery -->
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js"></script>
<script <script
src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.4/jquery-ui.min.js"></script> src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.4/jquery-ui.min.js"></script>
<script src="lib/jqueryi18n/jquery.i18n.properties-1.0.9.js"></script> <script src="lib/jqueryi18n/jquery.i18n.properties-1.0.9.js"></script>
<script src="lib/bootstrap/js/bootstrap-modal.js"></script> <script src="lib/bootstrap/js/bootstrap-modal.js"></script>
<script <script
src='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.js'></script> src='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.js'></script>
<script src="lib/chrisma/js/jquery.cookie.js"></script> <script src="lib/chrisma/js/jquery.cookie.js"></script>
<script src="lib/chrisma/js/theme.js"></script> <script src="lib/chrisma/js/theme.js"></script>
<script src="script/base.js"></script> <script src="script/base.js"></script>
<script src="script/pluginModel.js"></script> <script src="script/pluginModel.js"></script>
<script src="script/plugin-new.js"></script> <script src="script/plugin-new.js"></script>
<script src="script/behaviorsForm.js"></script> <script src="script/behaviorsForm.js"></script>
</fmt:bundle> </fmt:bundle>
</body> </body>
</html> </html>

View File

@ -1,104 +1,104 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<link rel="shortcut icon" href="images/bench4q.png"> <link rel="shortcut icon" href="images/bench4q.png">
<link href="lib/bootstrap/css/bootstrap.css" rel="stylesheet"> <link href="lib/bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="lib/github/css/github-6053501db2b69fd2b04652c6349117be14468ce4.css" <link href="lib/github/css/github-6053501db2b69fd2b04652c6349117be14468ce4.css"
media="screen" rel="stylesheet"> media="screen" rel="stylesheet">
<link href="css/index.css" media="screen" rel="stylesheet"> <link href="css/index.css" media="screen" rel="stylesheet">
<link href="css/register.css" media="screen" rel="stylesheet"> <link href="css/register.css" media="screen" rel="stylesheet">
<link rel="shortcut icon" href="images/bench4q.png"> <link rel="shortcut icon" href="images/bench4q.png">
<style type="text/css"> <style type="text/css">
/* body { /* body {
padding-bottom: 40px; padding-bottom: 40px;
} }
.sidebar-nav { .sidebar-nav {
padding: 9px 0; padding: 9px 0;
} */ } */
</style> </style>
</head> </head>
<body> <body>
<div id="header" class="true clearfix" style="height: 50px"> <div id="header" class="true clearfix" style="height: 50px">
<div class="container clearfix"> <div class="container clearfix">
<a class="site-logo" href="index.jsp"><img id="bench4q" <a class="site-logo" href="index.jsp"><img id="bench4q"
src="images/headerLogo.png" height="30" /></a> src="images/headerLogo.png" height="30" /></a>
<ul class="top-nav logged_out"> <ul class="top-nav logged_out">
<li class="login"><a href="login.jsp"><fmt:message <li class="login"><a href="login.jsp"><fmt:message
key="index_jsp_login" /></a></li> key="index_jsp_login" /></a></li>
</ul> </ul>
</div> </div>
</div> </div>
<div class="container"> <div class="container">
<div class="header"> <div class="header">
<h1> <h1>
<fmt:message key="index_jsp_Title" /> <fmt:message key="index_jsp_Title" />
</h1> </h1>
</div> </div>
<div class="registerContainer"> <div class="registerContainer">
<div class="left "> <div class="left ">
<div class="tipContainer"> <div class="tipContainer">
<img src="images/tips.jpg" /> <img src="images/tips.jpg" />
</div> </div>
<div class="userInput"> <div class="userInput">
<div class="registerInput row-fluid"> <div class="registerInput row-fluid">
<img alt="bench4q-username" src="images/username.jpg"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UserName:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <img alt="bench4q-username" src="images/username.jpg"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UserName:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<input id="username" name="username" tabindex="1" type="text" <input id="username" name="username" tabindex="1" type="text"
onchange="form_validation('username')"> onchange="form_validation('username')">
</div> </div>
<div class="hide"> <div class="hide">
<img src="images/error.jpg"> <span>the username must <img src="images/error.jpg"> <span>the username must
be 5-20 letters or numbers</span> be 5-20 letters or numbers</span>
</div> </div>
<div class="registerInput row-fluid"> <div class="registerInput row-fluid">
<img alt="bench4q-password" src="images/password.jpg"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <img alt="bench4q-password" src="images/password.jpg"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<input id="password" name="password" tabindex="1" type="text" <input id="password" name="password" tabindex="1" type="text"
onchange="form_validation('password')"> onchange="form_validation('password')">
</div> </div>
<div class="hide"> <div class="hide">
<img src="images/error.jpg"> <span>the password must <img src="images/error.jpg"> <span>the password must
be 6-20 letters or numbers </span> be 6-20 letters or numbers </span>
</div> </div>
<div class="registerInput row-fluid"> <div class="registerInput row-fluid">
<img alt="bench4q-retype-password" src="images/retype.jpg"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Re-Password:&nbsp; <img alt="bench4q-retype-password" src="images/retype.jpg"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Re-Password:&nbsp;
</span> <input id="retype_pwd" name="retype_pwd" tabindex="1" type="text" </span> <input id="retype_pwd" name="retype_pwd" tabindex="1" type="text"
onchange="form_validation('retype_pwd')"> onchange="form_validation('retype_pwd')">
</div> </div>
<div class="hide"> <div class="hide">
<img src="images/error.jpg"> <span>the <img src="images/error.jpg"> <span>the
retype-password is wrong</span> retype-password is wrong</span>
</div> </div>
</div> </div>
<div class="row-fluid"> <div class="row-fluid">
<div class="submitDiv"> <div class="submitDiv">
<input type="image" name="Submit" value="Register" <input type="image" name="Submit" value="Register"
src="images/submit.jpg" src="images/submit.jpg"
onMouseOver="this.src='images/submiton.jpg'" onMouseOver="this.src='images/submiton.jpg'"
onMouseOut="this.src='images/submit.jpg'" onMouseOut="this.src='images/submit.jpg'"
onClick="javascript:password_validation();return false" /> onClick="javascript:password_validation();return false" />
</div> </div>
<div class="submitDiv"> <div class="submitDiv">
<img name="Clear" src="images/clear.jpg" <img name="Clear" src="images/clear.jpg"
onMouseOver="this.src='images/clearon.jpg'" onMouseOver="this.src='images/clearon.jpg'"
onMouseOut="this.src='images/clear.jpg'" onMouseOut="this.src='images/clear.jpg'"
onClick="javascript:clean();return false" /> onClick="javascript:clean();return false" />
</div> </div>
</div> </div>
</div> </div>
<div class="bench4qLog"> <div class="bench4qLog">
<img src="images/bench4qblog.jpg" /> <img src="images/bench4qblog.jpg" />
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</div> </div>
<!-- for scripts --> <!-- for scripts -->
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.min.js"></script>
<script src="script/register.js"></script> <script src="script/register.js"></script>
</body> </body>
</html> </html>

View File

@ -1,276 +1,276 @@
function loadProperties() { function loadProperties() {
jQuery.i18n.properties({// 加载资浏览器语言对应的资源文件 jQuery.i18n.properties({// 加载资浏览器语言对应的资源文件
name : 'i18n', // 资源文件名称 name : 'i18n', // 资源文件名称
path : 'i18n/', // 资源文件路径 path : 'i18n/', // 资源文件路径
mode : 'map', // 用 Map 的方式使用资源文件中的值 mode : 'map', // 用 Map 的方式使用资源文件中的值
}); });
} }
function createBehaviorsForm(data, behaviorData, behaviorIndex) { function createBehaviorsForm(data, behaviorData, behaviorIndex) {
var methodParams = new Array(); var methodParams = new Array();
var fieldHTML = ""; var fieldHTML = "";
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
methodParams.push(data[i]); methodParams.push(data[i]);
} }
for (var j = 0; j < methodParams.length; j++) { for (var j = 0; j < methodParams.length; j++) {
var methodParamModel = new MethodParamModel(methodParams[j].name, var methodParamModel = new MethodParamModel(methodParams[j].name,
methodParams[j].lable, methodParams[j].valueSeperator, methodParams[j].lable, methodParams[j].valueSeperator,
methodParams[j].fieldSeperator, methodParams[j].paramType, methodParams[j].fieldSeperator, methodParams[j].paramType,
methodParams[j].methodParamProperties); methodParams[j].methodParamProperties);
var methodParamProperties = new Array(); var methodParamProperties = new Array();
for (var q = 0; q < methodParamModel.methodParamProperties.length; q++) { for (var q = 0; q < methodParamModel.methodParamProperties.length; q++) {
var methodParamPropertyModel = new MethodParamPropertyModel( var methodParamPropertyModel = new MethodParamPropertyModel(
methodParamModel.methodParamProperties[q].key, methodParamModel.methodParamProperties[q].key,
methodParamModel.methodParamProperties[q].value); methodParamModel.methodParamProperties[q].value);
methodParamProperties.push(methodParamPropertyModel); methodParamProperties.push(methodParamPropertyModel);
} }
var type = methodParamModel.paramType; var type = methodParamModel.paramType;
var size = 0, cols = "", rows = ""; var size = 0, cols = "", rows = "";
for (var p = 0; p < methodParamProperties.length; p++) { for (var p = 0; p < methodParamProperties.length; p++) {
var methodParamProertyModel = methodParamProperties[p]; var methodParamProertyModel = methodParamProperties[p];
if (methodParamProertyModel.key == "size") { if (methodParamProertyModel.key == "size") {
size = methodParamProertyModel.value; size = methodParamProertyModel.value;
} else if (methodParamProertyModel.key == "cols") { } else if (methodParamProertyModel.key == "cols") {
cols = methodParamProertyModel.value; cols = methodParamProertyModel.value;
} else if (methodParamProertyModel.key == "rows") { } else if (methodParamProertyModel.key == "rows") {
rows = methodParamProertyModel.value; rows = methodParamProertyModel.value;
} }
} }
if (type == "Field") { if (type == "Field") {
fieldHTML += createField(methodParamModel.lable, fieldHTML += createField(methodParamModel.lable,
methodParamModel.name, size, behaviorIndex); methodParamModel.name, size, behaviorIndex);
} else if (type == "MultiField") { } else if (type == "MultiField") {
fieldHTML += createMultiField(methodParamModel.lable, fieldHTML += createMultiField(methodParamModel.lable,
methodParamModel.name, size, behaviorIndex); methodParamModel.name, size, behaviorIndex);
} else if (type == "Table") { } else if (type == "Table") {
fieldHTML += createTable(methodParamModel, cols, behaviorIndex); fieldHTML += createTable(methodParamModel, cols, behaviorIndex);
} else if (type == "CheckBox") { } else if (type == "CheckBox") {
fieldHTML += createCheckBox(methodParamModel, rows, behaviorIndex); fieldHTML += createCheckBox(methodParamModel, rows, behaviorIndex);
} }
} }
return fieldHTML; return fieldHTML;
} }
function createField(label, name, size, behaviorIndex) { function createField(label, name, size, behaviorIndex) {
if (size == 0) { if (size == 0) {
size = 20; size = 20;
} }
var divNode = document.createElement("div"); var divNode = document.createElement("div");
var p = document.createElement("p"); var p = document.createElement("p");
var labelNode = document.createTextNode(label); var labelNode = document.createTextNode(label);
var div = document.createElement("div"); var div = document.createElement("div");
var nameNode = document.createTextNode(name); var nameNode = document.createTextNode(name);
var input = document.createElement("input"); var input = document.createElement("input");
$(divNode).attr("class", "Field sample_frame"); $(divNode).attr("class", "Field sample_frame");
$(divNode).attr("id", behaviorIndex + "_" + name); $(divNode).attr("id", behaviorIndex + "_" + name);
$(div).attr("class", "sample_sub_frame"); $(div).attr("class", "sample_sub_frame");
$(input).attr("type", "text"); $(input).attr("type", "text");
$(input).attr("size", size); $(input).attr("size", size);
$(input).attr("id", name + "_input"); $(input).attr("id", name + "_input");
p.appendChild(labelNode); p.appendChild(labelNode);
div.appendChild(nameNode); div.appendChild(nameNode);
div.appendChild(input); div.appendChild(input);
divNode.appendChild(p); divNode.appendChild(p);
divNode.appendChild(div); divNode.appendChild(div);
return divNode.outerHTML; return divNode.outerHTML;
} }
function createMultiField(label, name, size, behaviorIndex) { function createMultiField(label, name, size, behaviorIndex) {
if (size == 0) { if (size == 0) {
size = 20; size = 20;
} }
var divNode = document.createElement("div"); var divNode = document.createElement("div");
var p = document.createElement("p"); var p = document.createElement("p");
var labelNode = document.createTextNode(name + ":" + label); var labelNode = document.createTextNode(name + ":" + label);
var div = document.createElement("div"); var div = document.createElement("div");
var addFieldButton = document.createElement("button"); var addFieldButton = document.createElement("button");
var addFieldNode = document.createTextNode($.i18n var addFieldNode = document.createTextNode($.i18n
.prop("addField")); .prop("addField"));
var removeFieldButton = document.createElement("button"); var removeFieldButton = document.createElement("button");
var removeFieldNode = document.createTextNode($.i18n var removeFieldNode = document.createTextNode($.i18n
.prop("removeField")); .prop("removeField"));
var br = document.createElement("br"); var br = document.createElement("br");
var table = document.createElement("table"); var table = document.createElement("table");
$(divNode).attr("class", "MultiField sample_frame"); $(divNode).attr("class", "MultiField sample_frame");
$(divNode).attr("id", behaviorIndex + "_" + name); $(divNode).attr("id", behaviorIndex + "_" + name);
$(div).attr("class", "sample_sub_frame"); $(div).attr("class", "sample_sub_frame");
$(addFieldButton).attr("type", "submit"); $(addFieldButton).attr("type", "submit");
$(addFieldButton).attr("class", "btn-large"); $(addFieldButton).attr("class", "btn-large");
$(addFieldButton).attr("onClick", $(addFieldButton).attr("onClick",
"addField(" + size + "," + behaviorIndex + ");"); "addField(" + size + "," + behaviorIndex + ");");
$(removeFieldButton).attr("type", "submit"); $(removeFieldButton).attr("type", "submit");
$(removeFieldButton).attr("class", "btn-large"); $(removeFieldButton).attr("class", "btn-large");
$(removeFieldButton).attr("onClick", "removeField(this)"); $(removeFieldButton).attr("onClick", "removeField(this)");
$(table).attr("id", "addFieldTable_" + behaviorIndex); $(table).attr("id", "addFieldTable_" + behaviorIndex);
$(table).attr("class", "table-margin"); $(table).attr("class", "table-margin");
p.appendChild(labelNode); p.appendChild(labelNode);
addFieldButton.appendChild(addFieldNode); addFieldButton.appendChild(addFieldNode);
removeFieldButton.appendChild(removeFieldNode); removeFieldButton.appendChild(removeFieldNode);
div.appendChild(addFieldButton); div.appendChild(addFieldButton);
div.appendChild(removeFieldButton); div.appendChild(removeFieldButton);
div.appendChild(br); div.appendChild(br);
div.appendChild(table); div.appendChild(table);
divNode.appendChild(p); divNode.appendChild(p);
divNode.appendChild(div); divNode.appendChild(div);
return divNode.outerHTML; return divNode.outerHTML;
} }
var field; var field;
function addField(size, addId) { function addField(size, addId) {
field = $("#addFieldTable_" + addId).children().length; field = $("#addFieldTable_" + addId).children().length;
var data = "field_" + field + ":"; var data = "field_" + field + ":";
field = field + 1; field = field + 1;
var newTrNode = document.createElement("tr"); var newTrNode = document.createElement("tr");
var newTdNode1 = document.createElement("td"); var newTdNode1 = document.createElement("td");
var newTdNode2 = document.createElement("td"); var newTdNode2 = document.createElement("td");
newTdNode1.setAttribute("class", data); newTdNode1.setAttribute("class", data);
var textNode = document.createTextNode(data); var textNode = document.createTextNode(data);
var inputNode = document.createElement("input"); var inputNode = document.createElement("input");
inputNode.setAttribute("type", "text"); inputNode.setAttribute("type", "text");
inputNode.setAttribute("size", size); inputNode.setAttribute("size", size);
newTdNode1.appendChild(textNode); newTdNode1.appendChild(textNode);
newTdNode2.appendChild(inputNode); newTdNode2.appendChild(inputNode);
newTrNode.appendChild(newTdNode1); newTrNode.appendChild(newTdNode1);
newTrNode.appendChild(newTdNode2); newTrNode.appendChild(newTdNode2);
document.getElementById("addFieldTable_" + addId).appendChild(newTrNode); document.getElementById("addFieldTable_" + addId).appendChild(newTrNode);
} }
function removeField(selectedNode) { function removeField(selectedNode) {
var table = selectedNode.nextSibling.nextSibling; var table = selectedNode.nextSibling.nextSibling;
var deletedNode = table.lastChild; var deletedNode = table.lastChild;
table.removeChild(deletedNode); table.removeChild(deletedNode);
} }
function createTable(methodParamModel, cols, behaviorIndex) { function createTable(methodParamModel, cols, behaviorIndex) {
var name = methodParamModel.name; var name = methodParamModel.name;
var label = methodParamModel.lable; var label = methodParamModel.lable;
var valueSeperator = methodParamModel.valueSeperator; var valueSeperator = methodParamModel.valueSeperator;
var table_content = cols.split(valueSeperator); var table_content = cols.split(valueSeperator);
var tr = document.createElement("tr"); var tr = document.createElement("tr");
for (var i = 0; i < table_content.length; i++) { for (var i = 0; i < table_content.length; i++) {
var th = document.createElement("th"); var th = document.createElement("th");
var text = document.createTextNode(table_content[i]); var text = document.createTextNode(table_content[i]);
th.appendChild(text); th.appendChild(text);
tr.appendChild(th); tr.appendChild(th);
} }
var tr_content = document.createElement("tr"); var tr_content = document.createElement("tr");
for (var j = 0; j < table_content.length; j++) { for (var j = 0; j < table_content.length; j++) {
var td_content = document.createElement("td"); var td_content = document.createElement("td");
var text_content = document.createElement("input"); var text_content = document.createElement("input");
text_content.setAttribute("type", "text"); text_content.setAttribute("type", "text");
td_content.appendChild(text_content); td_content.appendChild(text_content);
tr_content.appendChild(td_content); tr_content.appendChild(td_content);
} }
var divNode = document.createElement("div"); var divNode = document.createElement("div");
var p = document.createElement("p"); var p = document.createElement("p");
var labelNode = document.createTextNode(label); var labelNode = document.createTextNode(label);
var div = document.createElement("div"); var div = document.createElement("div");
var nameNode = document.createTextNode(name); var nameNode = document.createTextNode(name);
var br1 = document.createElement("br"); var br1 = document.createElement("br");
var br2 = document.createElement("br"); var br2 = document.createElement("br");
var addColButton = document.createElement("button"); var addColButton = document.createElement("button");
var addColNode = document.createTextNode($.i18n.prop("addCol")); var addColNode = document.createTextNode($.i18n.prop("addCol"));
var removeColButton = document.createElement("button"); var removeColButton = document.createElement("button");
var removeColNode = document.createTextNode($.i18n var removeColNode = document.createTextNode($.i18n
.prop("removeCol")); .prop("removeCol"));
var table = document.createElement("table"); var table = document.createElement("table");
var thead = document.createElement("thead"); var thead = document.createElement("thead");
var tbody = document.createElement("tbody"); var tbody = document.createElement("tbody");
$(divNode).attr("class", "Table sample_frame"); $(divNode).attr("class", "Table sample_frame");
$(divNode).attr("id", behaviorIndex + "_" + name); $(divNode).attr("id", behaviorIndex + "_" + name);
$(div).attr("class", "sample_sub_frame"); $(div).attr("class", "sample_sub_frame");
$(addColButton).attr("type", "submit"); $(addColButton).attr("type", "submit");
$(addColButton).attr("class", "btn-large"); $(addColButton).attr("class", "btn-large");
$(addColButton).attr("onClick", "addCol(this)"); $(addColButton).attr("onClick", "addCol(this)");
$(removeColButton).attr("type", "submit"); $(removeColButton).attr("type", "submit");
$(removeColButton).attr("class", "btn-large"); $(removeColButton).attr("class", "btn-large");
$(removeColButton).attr("onClick", "removeCol(this)"); $(removeColButton).attr("onClick", "removeCol(this)");
$(table).attr("class", behaviorIndex + "_operateTableCols"); $(table).attr("class", behaviorIndex + "_operateTableCols");
$(table).attr("class", "table-margin"); $(table).attr("class", "table-margin");
p.appendChild(labelNode); p.appendChild(labelNode);
addColButton.appendChild(addColNode); addColButton.appendChild(addColNode);
removeColButton.appendChild(removeColNode); removeColButton.appendChild(removeColNode);
thead.appendChild(tr); thead.appendChild(tr);
tbody.appendChild(tr_content); tbody.appendChild(tr_content);
table.appendChild(thead); table.appendChild(thead);
table.appendChild(tbody); table.appendChild(tbody);
div.appendChild(nameNode); div.appendChild(nameNode);
div.appendChild(br1); div.appendChild(br1);
div.appendChild(addColButton); div.appendChild(addColButton);
div.appendChild(removeColButton); div.appendChild(removeColButton);
div.appendChild(br2); div.appendChild(br2);
div.appendChild(table); div.appendChild(table);
divNode.appendChild(p); divNode.appendChild(p);
divNode.appendChild(div); divNode.appendChild(div);
return divNode.outerHTML; return divNode.outerHTML;
} }
function addCol(selectedNode) { function addCol(selectedNode) {
var tbody = selectedNode.nextSibling.nextSibling.nextSibling.lastChild; var tbody = selectedNode.nextSibling.nextSibling.nextSibling.lastChild;
var length = tbody.previousSibling.firstChild.childNodes.length; var length = tbody.previousSibling.firstChild.childNodes.length;
var tr = document.createElement("tr"); var tr = document.createElement("tr");
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
var td = document.createElement("td"); var td = document.createElement("td");
var input = document.createElement("input"); var input = document.createElement("input");
input.setAttribute("type", "text"); input.setAttribute("type", "text");
td.appendChild(input); td.appendChild(input);
tr.appendChild(td); tr.appendChild(td);
} }
tbody.appendChild(tr); tbody.appendChild(tr);
} }
function removeCol(selectedNode) { function removeCol(selectedNode) {
var tbody = selectedNode.nextSibling.nextSibling.lastChild; var tbody = selectedNode.nextSibling.nextSibling.lastChild;
var removeNode = tbody.lastChild; var removeNode = tbody.lastChild;
tbody.removeChild(removeNode); tbody.removeChild(removeNode);
} }
function createCheckBox(methodParamModel, rows, behaviorIndex) { function createCheckBox(methodParamModel, rows, behaviorIndex) {
var name = methodParamModel.name; var name = methodParamModel.name;
var label = methodParamModel.lable; var label = methodParamModel.lable;
var valueSeperator = methodParamModel.valueSeperator; var valueSeperator = methodParamModel.valueSeperator;
var cb_content = rows.split(valueSeperator); var cb_content = rows.split(valueSeperator);
var result = document.createElement("div"); var result = document.createElement("div");
var divNode = document.createElement("div"); var divNode = document.createElement("div");
var p = document.createElement("p"); var p = document.createElement("p");
var div = document.createElement("div"); var div = document.createElement("div");
var br = document.createElement("br"); var br = document.createElement("br");
var divInput = document.createElement("div"); var divInput = document.createElement("div");
var labelNode = document.createTextNode(label); var labelNode = document.createTextNode(label);
var nameNode = document.createTextNode(name); var nameNode = document.createTextNode(name);
$(divNode).attr("class", "CheckBox sample_frame"); $(divNode).attr("class", "CheckBox sample_frame");
$(divNode).attr("id", "checkbox_" + name + "_" + behaviorIndex); $(divNode).attr("id", "checkbox_" + name + "_" + behaviorIndex);
$(div).attr("class", "sample_sub_frame"); $(div).attr("class", "sample_sub_frame");
$(divInput).attr("class", "sample_sub_frame"); $(divInput).attr("class", "sample_sub_frame");
p.appendChild(labelNode); p.appendChild(labelNode);
for (var i = 0; i < cb_content.length; i++) { for (var i = 0; i < cb_content.length; i++) {
var checkBoxNode = document.createElement("input"); var checkBoxNode = document.createElement("input");
var brInput = document.createElement("br"); var brInput = document.createElement("br");
checkBoxNode.setAttribute("type", "checkbox"); checkBoxNode.setAttribute("type", "checkbox");
checkBoxNode.setAttribute("name", "checkbox_" + name + "_" checkBoxNode.setAttribute("name", "checkbox_" + name + "_"
+ behaviorIndex); + behaviorIndex);
checkBoxNode.setAttribute("value", cb_content[i]); checkBoxNode.setAttribute("value", cb_content[i]);
var checkBoxValue = document.createTextNode(cb_content[i]); var checkBoxValue = document.createTextNode(cb_content[i]);
divInput.appendChild(checkBoxNode); divInput.appendChild(checkBoxNode);
divInput.appendChild(checkBoxValue); divInput.appendChild(checkBoxValue);
divInput.appendChild(brInput); divInput.appendChild(brInput);
} }
div.appendChild(nameNode); div.appendChild(nameNode);
div.appendChild(br); div.appendChild(br);
div.appendChild(divInput); div.appendChild(divInput);
divNode.appendChild(p); divNode.appendChild(p);
divNode.appendChild(div); divNode.appendChild(div);
result.appendChild(divNode); result.appendChild(divNode);
return $(result).html(); return $(result).html();
} }

View File

@ -1,279 +1,279 @@
var pluginNameList = new Array(); var pluginNameList = new Array();
var parameters = new HashMap(); var parameters = new HashMap();
var parameterList = new HashMap(); var parameterList = new HashMap();
var pluginName; var pluginName;
function loadUsePluigns(data) { function loadUsePluigns(data) {
for (var i = 0; i < data.usePlugins.length; i++) { for (var i = 0; i < data.usePlugins.length; i++) {
var usePlugin = data.usePlugins[i]; var usePlugin = data.usePlugins[i];
pluginNameList.push(usePlugin.id); pluginNameList.push(usePlugin.id);
} }
var selectNode = document.getElementsByName("usePlugins")[0]; var selectNode = document.getElementsByName("usePlugins")[0];
for (var j = 0; j < pluginNameList.length; j++) { for (var j = 0; j < pluginNameList.length; j++) {
var textNode = document.createTextNode(pluginNameList[j]); var textNode = document.createTextNode(pluginNameList[j]);
var optionNode = document.createElement("option"); var optionNode = document.createElement("option");
optionNode.setAttribute("value", pluginNameList[j]); optionNode.setAttribute("value", pluginNameList[j]);
optionNode.appendChild(textNode); optionNode.appendChild(textNode);
selectNode.appendChild(optionNode); selectNode.appendChild(optionNode);
} }
} }
function choosePlugin() { function choosePlugin() {
var plugin = document.getElementById("usePlugins"); var plugin = document.getElementById("usePlugins");
if (plugin.options[plugin.selectedIndex].value != 0) { if (plugin.options[plugin.selectedIndex].value != 0) {
pluginName = plugin.options[plugin.selectedIndex].value; pluginName = plugin.options[plugin.selectedIndex].value;
} }
loadBehaviors(); loadBehaviors();
} }
var clickScriptId; var clickScriptId;
function chooseBehavior() { function chooseBehavior() {
var behaviorMethod = 0; var behaviorMethod = 0;
var behaviors = document.getElementById("behaviors"); var behaviors = document.getElementById("behaviors");
if (behaviors.options[behaviors.selectedIndex].value != 0) { if (behaviors.options[behaviors.selectedIndex].value != 0) {
behaviorMethod = behaviors.options[behaviors.selectedIndex].value; behaviorMethod = behaviors.options[behaviors.selectedIndex].value;
} }
document.getElementById("showPluginMethodForm").innerHTML = ""; document.getElementById("showPluginMethodForm").innerHTML = "";
var plugin_id = behaviorMethod.split("_")[0]; var plugin_id = behaviorMethod.split("_")[0];
var behavior_id = behaviorMethod.split("_")[1]; var behavior_id = behaviorMethod.split("_")[1];
clickScriptId = plugin_id + "_" + behavior_id; clickScriptId = plugin_id + "_" + behavior_id;
loadFormParameters(plugin_id, behavior_id); loadFormParameters(plugin_id, behavior_id);
} }
function loadBehaviors() { function loadBehaviors() {
$('#behaviors').html(""); $('#behaviors').html("");
var selectNode = document.getElementsByName("behaviors")[0]; var selectNode = document.getElementsByName("behaviors")[0];
var text = document.createTextNode("Please choose one behavior"); var text = document.createTextNode("Please choose one behavior");
var option = document.createElement("option"); var option = document.createElement("option");
option.appendChild(text); option.appendChild(text);
selectNode.appendChild(option); selectNode.appendChild(option);
$.each(modelData.pages, function(i, item) { $.each(modelData.pages, function(i, item) {
$.each(item.batches, function(i, item) { $.each(item.batches, function(i, item) {
var id = item.Id; var id = item.Id;
$.each(item.behaviors, function(i, item) { $.each(item.behaviors, function(i, item) {
if (item.use == pluginName) { if (item.use == pluginName) {
var textNode = document.createTextNode(item.use + "_" + id var textNode = document.createTextNode(item.use + "_" + id
+ "." + item.name + "_" + item.id); + "." + item.name + "_" + item.id);
var optionNode = document.createElement("option"); var optionNode = document.createElement("option");
optionNode.setAttribute("value", id + "_" + item.id); optionNode.setAttribute("value", id + "_" + item.id);
optionNode.appendChild(textNode); optionNode.appendChild(textNode);
selectNode.appendChild(optionNode); selectNode.appendChild(optionNode);
} }
}); });
}); });
}); });
} }
function loadFormParameters(plugin_id, behavior_id) { function loadFormParameters(plugin_id, behavior_id) {
var plugin = "", method = ""; var plugin = "", method = "";
alert("parameters"); alert("parameters");
$.each(modelData.pages, function(i, item) { $.each(modelData.pages, function(i, item) {
$.each(item.batches, function(i, item) { $.each(item.batches, function(i, item) {
if (item.Id == plugin_id) { if (item.Id == plugin_id) {
$.each(item.behaviors, function(i, item) { $.each(item.behaviors, function(i, item) {
if (item.id == behavior_id) { if (item.id == behavior_id) {
plugin = item.use; plugin = item.use;
method = item.name; method = item.name;
$.each(item.parameters, function(i, item) { $.each(item.parameters, function(i, item) {
parameters.put(item.key, item.value); parameters.put(item.key, item.value);
alert("key="+item.key+",value="+item.value); alert("key="+item.key+",value="+item.value);
}); });
} }
}); });
} }
}); });
}); });
loadMethodParameters(plugin, method, plugin_id, behavior_id); loadMethodParameters(plugin, method, plugin_id, behavior_id);
} }
function loadMethodParameters(plugin, method, plugin_id, behavior_id) { function loadMethodParameters(plugin, method, plugin_id, behavior_id) {
var behaviorData = plugin + "_" + plugin_id + "." + method + "_" var behaviorData = plugin + "_" + plugin_id + "." + method + "_"
+ behavior_id; + behavior_id;
var behaviorIndex = /*plugin_id+"_"+*/ behavior_id; var behaviorIndex = /*plugin_id+"_"+*/ behavior_id;
$ $
.post( .post(
"loadMethodParameters", "loadMethodParameters",
{ {
pluginName : plugin, pluginName : plugin,
methodName : method methodName : method
}, },
function(data) { function(data) {
if (!data.success) { if (!data.success) {
alert(data.failedMessage); alert(data.failedMessage);
return; return;
} }
data = data.data; data = data.data;
var documentHtml = ""; var documentHtml = "";
var boxHeader = ""; var boxHeader = "";
var fieldHTML = createBehaviorsForm(data, behaviorData, var fieldHTML = createBehaviorsForm(data, behaviorData,
behaviorIndex); behaviorIndex);
boxHeader = "<div class='box-header well' data-original-title> " boxHeader = "<div class='box-header well' data-original-title> "
+ "<i class='icon-pencil left'></i>" + "<i class='icon-pencil left'></i>"
+ "<h2>sample:<i>" + "<h2>sample:<i>"
+ behaviorData + behaviorData
+ "</i></h2></div>"; + "</i></h2></div>";
documentHtml = "<div id='" documentHtml = "<div id='"
+ behaviorIndex + behaviorIndex
+ "' class=''><p class='hide'>" + "' class=''><p class='hide'>"
+ behaviorData + behaviorData
+ "</p><div class='span10 box' style='margin-left:15px;'>" + "</p><div class='span10 box' style='margin-left:15px;'>"
+ boxHeader + "<div class='box-content'>" + boxHeader + "<div class='box-content'>"
+ fieldHTML + "</div></div></div>"; + fieldHTML + "</div></div></div>";
document.getElementById("showPluginMethodForm").innerHTML += documentHtml; document.getElementById("showPluginMethodForm").innerHTML += documentHtml;
createForm(behaviorIndex); createForm(behaviorIndex);
}); });
} }
function createForm(behaviorIndex) { function createForm(behaviorIndex) {
var formNode = document.getElementById(behaviorIndex); var formNode = document.getElementById(behaviorIndex);
var contents = formNode.lastChild.lastChild.childNodes; var contents = formNode.lastChild.lastChild.childNodes;
var contentLength = contents.length; var contentLength = contents.length;
for (var j = 0; j < contentLength; j++) { for (var j = 0; j < contentLength; j++) {
var type = $(contents[j]).attr("class"); var type = $(contents[j]).attr("class");
if (type == "Field sample_frame") { if (type == "Field sample_frame") {
var key = contents[j].lastChild.firstChild.nodeValue; var key = contents[j].lastChild.firstChild.nodeValue;
var value = parameters.get(key); var value = parameters.get(key);
if (value != "" && value != null) { if (value != "" && value != null) {
$(contents[j].lastChild.lastChild).val(value); $(contents[j].lastChild.lastChild).val(value);
} }
} else if (type == "MultiField sample_frame") { } else if (type == "MultiField sample_frame") {
var key = contents[j].firstChild.firstChild.nodeValue.split(":")[0]; var key = contents[j].firstChild.firstChild.nodeValue.split(":")[0];
var value = parameters.get(key); var value = parameters.get(key);
if(value==null){ if(value==null){
addField(20,behaviorIndex); addField(20,behaviorIndex);
} }
else { else {
value = value.split(";"); value = value.split(";");
var fieldLength = value.length; var fieldLength = value.length;
for (var t = 0; t < fieldLength; t++) { for (var t = 0; t < fieldLength; t++) {
addField(20, behaviorIndex); addField(20, behaviorIndex);
$($(contents[j]).find("table").children()[t]).find("input") $($(contents[j]).find("table").children()[t]).find("input")
.val(value[t]); .val(value[t]);
} }
} }
} else if (type == "Table sample_frame") { } else if (type == "Table sample_frame") {
var key = contents[j].lastChild.firstChild.nodeValue; var key = contents[j].lastChild.firstChild.nodeValue;
/*//参数不统一 /*//参数不统一
if(key=="header"){ if(key=="header"){
key="headers"; key="headers";
}*/ }*/
var value = parameters.get(key); var value = parameters.get(key);
alert("key="+key+",value="+value); alert("key="+key+",value="+value);
if (value != "" && value != null) { if (value != "" && value != null) {
value = parameters.get(key).split("|;"); value = parameters.get(key).split("|;");
var table = $(contents[j]).find("table"); var table = $(contents[j]).find("table");
var col = table.find("th").length; var col = table.find("th").length;
var row = value.length - 1; var row = value.length - 1;
var tbody = $(contents[j]).find("tbody"); var tbody = $(contents[j]).find("tbody");
for (var m = 0; m < row; m++) { for (var m = 0; m < row; m++) {
var input = value[m].split("|"); var input = value[m].split("|");
if (m != 0) { if (m != 0) {
var selectedNode = contents[j].lastChild.firstChild.nextSibling.nextSibling; var selectedNode = contents[j].lastChild.firstChild.nextSibling.nextSibling;
addCol(selectedNode); addCol(selectedNode);
} }
for (var n = 0; n < col; n++) { for (var n = 0; n < col; n++) {
var rowNode = $(tbody).children()[m]; var rowNode = $(tbody).children()[m];
var colNode = $(rowNode).children()[n]; var colNode = $(rowNode).children()[n];
$(colNode).find("input").val(input[n]); $(colNode).find("input").val(input[n]);
alert("input["+n+"]="+input[n]); alert("input["+n+"]="+input[n]);
} }
} }
} }
} }
} }
} }
function saveFormModification() { function saveFormModification() {
alert("saveFormModification"); alert("saveFormModification");
var div = document.getElementById("showPluginMethodForm").firstChild; var div = document.getElementById("showPluginMethodForm").firstChild;
var plugin_method = div.firstChild.firstChild.nodeValue.split("."); var plugin_method = div.firstChild.firstChild.nodeValue.split(".");
var pluginId = plugin_method[0].split("_")[1]; var pluginId = plugin_method[0].split("_")[1];
var behaviorId = plugin_method[1].split("_")[1]; var behaviorId = plugin_method[1].split("_")[1];
var contents = div.lastChild.lastChild.childNodes; var contents = div.lastChild.lastChild.childNodes;
var length = contents.length; var length = contents.length;
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
var node = contents[i]; var node = contents[i];
var key = "", value = "", temp = ""; var key = "", value = "", temp = "";
if ($(node).attr("class") == "Field sample_frame") { if ($(node).attr("class") == "Field sample_frame") {
key = node.lastChild.firstChild.nodeValue; key = node.lastChild.firstChild.nodeValue;
temp = $(node).find("input").val(); temp = $(node).find("input").val();
if (temp != "") { if (temp != "") {
value = temp; value = temp;
} }
} else if ($(node).attr("class") == "MultiField sample_frame") { } else if ($(node).attr("class") == "MultiField sample_frame") {
key = node.firstChild.firstChild.nodeValue.split(":")[0]; key = node.firstChild.firstChild.nodeValue.split(":")[0];
var fieldNode = $(node).find("table").children(); var fieldNode = $(node).find("table").children();
var fieldLength = $(fieldNode).length; var fieldLength = $(fieldNode).length;
for (var j = 0; j < fieldLength; j++) { for (var j = 0; j < fieldLength; j++) {
temp = $(fieldNode[j]).find("input").val(); temp = $(fieldNode[j]).find("input").val();
if (temp != "") { if (temp != "") {
value += temp; value += temp;
} }
if (j != fieldLength - 1) { if (j != fieldLength - 1) {
value += ";"; value += ";";
} }
} }
} else if ($(node).attr("class") == "Table sample_frame") { } else if ($(node).attr("class") == "Table sample_frame") {
key = node.lastChild.firstChild.nodeValue; key = node.lastChild.firstChild.nodeValue;
var table = $(node).find("table"); var table = $(node).find("table");
var col = table.find("th").length; var col = table.find("th").length;
var row = table.find("tbody").children().length; var row = table.find("tbody").children().length;
var tbody = $(node).find("tbody"); var tbody = $(node).find("tbody");
for (var m = 0; m < row; m++) { for (var m = 0; m < row; m++) {
for (var n = 0; n < col; n++) { for (var n = 0; n < col; n++) {
var rowNode = $(tbody).children()[m]; var rowNode = $(tbody).children()[m];
var colNode = $(rowNode).children()[n]; var colNode = $(rowNode).children()[n];
temp = $(colNode).find("input").val(); temp = $(colNode).find("input").val();
if (temp != "") { if (temp != "") {
value += temp + "|"; value += temp + "|";
} }
} }
if (value != "") { if (value != "") {
value += ";"; value += ";";
} }
} }
} else if ($(node).attr("class") == "CheckBox sample_frame") { } else if ($(node).attr("class") == "CheckBox sample_frame") {
key = node.lastChild.firstChild.nodeValue; key = node.lastChild.firstChild.nodeValue;
var id = $(node).attr("id"); var id = $(node).attr("id");
$('input[name=' + id + ']:checked').each(function() { $('input[name=' + id + ']:checked').each(function() {
temp = $(this).val(); temp = $(this).val();
if (temp != "") { if (temp != "") {
value += temp + ";"; value += temp + ";";
} }
}); });
} }
parameterList.put(key, value); parameterList.put(key, value);
} }
modifyJsonData(pluginId, behaviorId); modifyJsonData(pluginId, behaviorId);
} }
function modifyJsonData(pluginId, behaviorId) { function modifyJsonData(pluginId, behaviorId) {
alert("modifyJsonData"); alert("modifyJsonData");
$.each(modelData.pages, function(i, item) { $.each(modelData.pages, function(i, item) {
$.each(item.batches, function(i, item) { $.each(item.batches, function(i, item) {
if (item.Id == pluginId) { if (item.Id == pluginId) {
$.each(item.behaviors, function(i, item) { $.each(item.behaviors, function(i, item) {
if (item.id == behaviorId) { if (item.id == behaviorId) {
$.each(item.parameters, function(i, item) { $.each(item.parameters, function(i, item) {
if(parameterList.exists(item.key)){ if(parameterList.exists(item.key)){
item.value = parameterList.get(item.key); item.value = parameterList.get(item.key);
} }
}); });
/*var keyList=parameterList.getKeys(); /*var keyList=parameterList.getKeys();
for(var i=0;i<keyList.length;i++){ for(var i=0;i<keyList.length;i++){
alert("keyList is "+keyList[i]); alert("keyList is "+keyList[i]);
var parameterModel=new ParameterModel(keyList[i],parameterList.get(keyList[i])); var parameterModel=new ParameterModel(keyList[i],parameterList.get(keyList[i]));
item.parameters[i] = JSON.stringify(parameterModel); item.parameters[i] = JSON.stringify(parameterModel);
alert("json is "+item.parameters[i]); alert("json is "+item.parameters[i]);
} }
alert("item.parameters="+item.parameters);*/ alert("item.parameters="+item.parameters);*/
} }
}); });
} }
}); });
}); });
} }

View File

@ -1,478 +1,478 @@
var pluginChoosedList = new Array(); var pluginChoosedList = new Array();
var pluginIndex = new HashMap(); var pluginIndex = new HashMap();
var pluginList = new Array(); var pluginList = new Array();
var pluginMethodList = new Array(); var pluginMethodList = new Array();
var usePluginList = new Array(); var usePluginList = new Array();
var behaviors = new Array(); var behaviors = new Array();
var clickPluginMethodNode = -1; var clickPluginMethodNode = -1;
var clickPluginChoosedNode = 0; var clickPluginChoosedNode = 0;
var place = ""; var place = "";
$(document).ready(function() { $(document).ready(function() {
loadPluginList(); loadPluginList();
}); });
function loadPluginList() { function loadPluginList() {
$.post("loadPlugin", {}, function(data) { $.post("loadPlugin", {}, function(data) {
if (!data.success) { if (!data.success) {
alert(data.failedMessage); alert(data.failedMessage);
return; return;
} }
data = data.data;// List<String> pluginList data = data.data;// List<String> pluginList
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
pluginList.push(data[i]); pluginList.push(data[i]);
pluginIndex.put(data[i], 0); pluginIndex.put(data[i], 0);
} }
}); });
} }
function getMethod(pluglin) { function getMethod(pluglin) {
var aMethodList = ""; var aMethodList = "";
$.post("loadMethod", { $.post("loadMethod", {
pluginName : plugin pluginName : plugin
}, function(data) { }, function(data) {
if (!data.success) { if (!data.success) {
alert(data.failedMessage); alert(data.failedMessage);
return; return;
} }
data = data.data;// List<String> methodList data = data.data;// List<String> methodList
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
aMethodList.push(data[i]); aMethodList.push(data[i]);
} }
}); });
return aMethodList; return aMethodList;
} }
function addPlugin() { function addPlugin() {
var html = ""; var html = "";
for (var j = 0; j < pluginList.length; j++) { for (var j = 0; j < pluginList.length; j++) {
html += createLineWithRadio(pluginList[j], "plugin"); html += createLineWithRadio(pluginList[j], "plugin");
} }
$('#choosePlugin').html(html); $('#choosePlugin').html(html);
$('#myModal_Plugin').modal('show'); $('#myModal_Plugin').modal('show');
$("input:radio").click(function() { $("input:radio").click(function() {
$(this).attr("checked", "checked"); $(this).attr("checked", "checked");
}); });
} }
function createLineWithRadio(lineText, nameAttr) { function createLineWithRadio(lineText, nameAttr) {
var textNode = document.createTextNode(lineText); var textNode = document.createTextNode(lineText);
var divNode = document.createElement("div"); var divNode = document.createElement("div");
var inputNode = document.createElement("input"); var inputNode = document.createElement("input");
var brNode = document.createElement("br"); var brNode = document.createElement("br");
inputNode.setAttribute("type", "radio"); inputNode.setAttribute("type", "radio");
inputNode.setAttribute("name", nameAttr); inputNode.setAttribute("name", nameAttr);
inputNode.setAttribute("class", "chooseOnePlugin"); inputNode.setAttribute("class", "chooseOnePlugin");
inputNode.setAttribute("value", lineText); inputNode.setAttribute("value", lineText);
divNode.appendChild(inputNode); divNode.appendChild(inputNode);
divNode.appendChild(textNode); divNode.appendChild(textNode);
divNode.appendChild(brNode); divNode.appendChild(brNode);
return $(divNode).html() + "<br>"; return $(divNode).html() + "<br>";
} }
function createALine(pluginName, index, list) { function createALine(pluginName, index, list) {
var div = document.createElement("div"); var div = document.createElement("div");
var p = document.createElement("p"); var p = document.createElement("p");
var i = document.createElement("i"); var i = document.createElement("i");
var textNode = document.createTextNode(pluginName); var textNode = document.createTextNode(pluginName);
div.setAttribute("id", index); div.setAttribute("id", index);
i.setAttribute("class", "icon-hand-right"); i.setAttribute("class", "icon-hand-right");
p.setAttribute("id", index); p.setAttribute("id", index);
p.setAttribute("class", ""); p.setAttribute("class", "");
if (list == "pluginMethodList") { if (list == "pluginMethodList") {
p.setAttribute("onClick", "showMethodDocument(this)");// loadMethodParams p.setAttribute("onClick", "showMethodDocument(this)");// loadMethodParams
} else if (list == "pluginChoosedList") { } else if (list == "pluginChoosedList") {
p.setAttribute("onClick", "choosePlugin(" + index + ");"); p.setAttribute("onClick", "choosePlugin(" + index + ");");
} }
p.setAttribute("style", "cursor:pointer;width:85%"); p.setAttribute("style", "cursor:pointer;width:85%");
p.appendChild(i); p.appendChild(i);
p.appendChild(textNode); p.appendChild(textNode);
div.appendChild(p); div.appendChild(p);
return div; return div;
} }
function choosePlugin(index) { function choosePlugin(index) {
clickPluginChoosedNode = index; clickPluginChoosedNode = index;
var pluginChoosedNode = $('#pluginArea').children(); var pluginChoosedNode = $('#pluginArea').children();
var length = pluginChoosedNode.length; var length = pluginChoosedNode.length;
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
if (i == clickPluginChoosedNode) { if (i == clickPluginChoosedNode) {
$(pluginChoosedNode[i]).find("p").attr("class", "visited"); $(pluginChoosedNode[i]).find("p").attr("class", "visited");
} else { } else {
$(pluginChoosedNode[i]).find("p").attr("class", ""); $(pluginChoosedNode[i]).find("p").attr("class", "");
} }
} }
} }
function pluginFinish() { function pluginFinish() {
$('#myModal_Plugin').modal('hide'); $('#myModal_Plugin').modal('hide');
var pluginName; var pluginName;
var item = $("input[type='radio']:checked").val(); var item = $("input[type='radio']:checked").val();
var aPluginIndex = pluginIndex.get(item); var aPluginIndex = pluginIndex.get(item);
pluginIndex.put(item, aPluginIndex + 1); pluginIndex.put(item, aPluginIndex + 1);
pluginName = item + "_" + aPluginIndex; pluginName = item + "_" + aPluginIndex;
pluginChoosedList.push(pluginName); pluginChoosedList.push(pluginName);
createPluginChoosedLines(); createPluginChoosedLines();
} }
function createPluginChoosedLines() { function createPluginChoosedLines() {
document.getElementById('pluginArea').innerHTML = ""; document.getElementById('pluginArea').innerHTML = "";
for (var j = 0; j < pluginChoosedList.length; j++) { for (var j = 0; j < pluginChoosedList.length; j++) {
var div = createALine(pluginChoosedList[j], j, "pluginChoosedList"); var div = createALine(pluginChoosedList[j], j, "pluginChoosedList");
document.getElementById('pluginArea').appendChild(div); document.getElementById('pluginArea').appendChild(div);
} }
} }
function removePluginByClicked() { function removePluginByClicked() {
var length = pluginChoosedList.length; var length = pluginChoosedList.length;
for (var i = parseInt(clickPluginChoosedNode + 1); i < length; i++) { for (var i = parseInt(clickPluginChoosedNode + 1); i < length; i++) {
pluginChoosedList[i - 1] = pluginChoosedList[i]; pluginChoosedList[i - 1] = pluginChoosedList[i];
} }
pluginChoosedList.splice(length - 1, 1); pluginChoosedList.splice(length - 1, 1);
createPluginChoosedLines(); createPluginChoosedLines();
} }
function clearPluginChoosedList() { function clearPluginChoosedList() {
pluginChoosedList.splice(0, pluginChoosedList.length); pluginChoosedList.splice(0, pluginChoosedList.length);
for (var i = 0; i < pluginList.length; i++) { for (var i = 0; i < pluginList.length; i++) {
pluginIndex.put(pluginList[i], 0); pluginIndex.put(pluginList[i], 0);
} }
document.getElementById('pluginArea').innerHTML = ""; document.getElementById('pluginArea').innerHTML = "";
} }
function insert() { function insert() {
place = "before"; place = "before";
insertPlugin(); insertPlugin();
} }
function insertAfter() { function insertAfter() {
place = "after"; place = "after";
insertPlugin(); insertPlugin();
} }
function insertPlugin() { function insertPlugin() {
document.getElementById("pluginMethod").innerHTML = ""; document.getElementById("pluginMethod").innerHTML = "";
$('#myModal_Behavior').modal('show'); $('#myModal_Behavior').modal('show');
var chooesedPluginHtml = ""; var chooesedPluginHtml = "";
for (var i = 0; i < pluginChoosedList.length; i++) { for (var i = 0; i < pluginChoosedList.length; i++) {
chooesedPluginHtml += createLineWithRadio(pluginChoosedList[i], chooesedPluginHtml += createLineWithRadio(pluginChoosedList[i],
"plugin"); "plugin");
} }
$("#insertPluginAreaPlugins").html(chooesedPluginHtml); $("#insertPluginAreaPlugins").html(chooesedPluginHtml);
} }
$('#insertPluginAreaPlugins').click(function() { $('#insertPluginAreaPlugins').click(function() {
var item = $("input[type='radio']:checked").val(); var item = $("input[type='radio']:checked").val();
showInsertPlugin(item); showInsertPlugin(item);
}); });
function showInsertPlugin(pluginName) { function showInsertPlugin(pluginName) {
getMethodList(pluginName); getMethodList(pluginName);
} }
function getMethodList(methodData) { function getMethodList(methodData) {
var methodHtml = ""; var methodHtml = "";
var methodList = new Array(); var methodList = new Array();
var plugin_method_List = new Array(); var plugin_method_List = new Array();
var type = methodData.split("_"); var type = methodData.split("_");
var plugin = type[0]; var plugin = type[0];
$.post("loadMethod", { $.post("loadMethod", {
pluginName : plugin pluginName : plugin
}, function(data) { }, function(data) {
if (!data.success) { if (!data.success) {
alert(data.failedMessage); alert(data.failedMessage);
return; return;
} }
data = data.data;// List<String> methodList data = data.data;// List<String> methodList
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
plugin_method_List.push(methodData + "." + data[i]);// httpPlugin_0.post plugin_method_List.push(methodData + "." + data[i]);// httpPlugin_0.post
methodList.push(data[i]); methodList.push(data[i]);
methodHtml += createLineWithRadio(methodList[i], "method"); methodHtml += createLineWithRadio(methodList[i], "method");
} }
document.getElementById("pluginMethod").innerHTML = methodHtml; document.getElementById("pluginMethod").innerHTML = methodHtml;
}); });
} }
function behaviorFinish() { function behaviorFinish() {
var plugin = $("input[name='plugin']:checked").val(); var plugin = $("input[name='plugin']:checked").val();
var method = $("input[name='method']:checked").val(); var method = $("input[name='method']:checked").val();
if (plugin != null && plugin != "" && method != null && method != "") { if (plugin != null && plugin != "" && method != null && method != "") {
showPluginMethod(plugin, method); showPluginMethod(plugin, method);
} else { } else {
alert("The plugin or the method shouldn't be null!"); alert("The plugin or the method shouldn't be null!");
$('#myModal_Behavior').modal('hide'); $('#myModal_Behavior').modal('hide');
} }
} }
var mark; var mark;
function showPluginMethod(plugin, method) { function showPluginMethod(plugin, method) {
var behaviorData = plugin + "." + method; var behaviorData = plugin + "." + method;
var length = pluginMethodList.length; var length = pluginMethodList.length;
alert("pluginMehtodList.length="+pluginMethodList.length); alert("pluginMehtodList.length="+pluginMethodList.length);
var documentChild = document.getElementById("showPluginMethod").childNodes; var documentChild = document.getElementById("showPluginMethod").childNodes;
if (place == "before") { if (place == "before") {
for (var j = length - 1; j >= clickPluginMethodNode; j--) { for (var j = length - 1; j >= clickPluginMethodNode; j--) {
pluginMethodList[j + 1] = pluginMethodList[j]; pluginMethodList[j + 1] = pluginMethodList[j];
$(documentChild[j]).attr("id", parseInt(j + 1)); $(documentChild[j]).attr("id", parseInt(j + 1));
} }
mark = clickPluginMethodNode; mark = clickPluginMethodNode;
clickPluginMethodNode=parseInt(clickPluginMethodNode + 1); clickPluginMethodNode=parseInt(clickPluginMethodNode + 1);
pluginMethodList[mark] = behaviorData; pluginMethodList[mark] = behaviorData;
} else if (place == "after") { } else if (place == "after") {
mark = parseInt(clickPluginMethodNode + 1); mark = parseInt(clickPluginMethodNode + 1);
if (clickPluginMethodNode == parseInt(length - 1) if (clickPluginMethodNode == parseInt(length - 1)
&& clickPluginMethodNode != -1) { && clickPluginMethodNode != -1) {
pluginMethodList.push(behaviorData); pluginMethodList.push(behaviorData);
} else { } else {
for (var j = parseInt(length - 1); j >= mark; j--) { for (var j = parseInt(length - 1); j >= mark; j--) {
pluginMethodList[j + 1] = pluginMethodList[j]; pluginMethodList[j + 1] = pluginMethodList[j];
$(documentChild[j]).attr("id", parseInt(j + 1)); $(documentChild[j]).attr("id", parseInt(j + 1));
} }
pluginMethodList[mark] = behaviorData; pluginMethodList[mark] = behaviorData;
} }
} }
$('#insertBefore').attr("class", "show"); $('#insertBefore').attr("class", "show");
$('#myModal_Behavior').modal('hide'); $('#myModal_Behavior').modal('hide');
/*loadMethodParams(behaviorData,mark);*/ /*loadMethodParams(behaviorData,mark);*/
createPluginMethodLines(); createPluginMethodLines();
} }
function createPluginMethodLines() { function createPluginMethodLines() {
document.getElementById("showPluginMethod").innerHTML = ""; document.getElementById("showPluginMethod").innerHTML = "";
document.getElementById('behaviorArea').innerHTML = ""; document.getElementById('behaviorArea').innerHTML = "";
for (var j = 0; j < pluginMethodList.length; j++) { for (var j = 0; j < pluginMethodList.length; j++) {
var div = createALine(pluginMethodList[j], j, "pluginMethodList"); var div = createALine(pluginMethodList[j], j, "pluginMethodList");
if(j==clickPluginMethodNode){ if(j==clickPluginMethodNode){
$(div).find("p").attr("class","visited"); $(div).find("p").attr("class","visited");
} }
document.getElementById('behaviorArea').appendChild(div); document.getElementById('behaviorArea').appendChild(div);
loadMethodParams(pluginMethodList[j], j); loadMethodParams(pluginMethodList[j], j);
} }
} }
function showMethodDocument(selectedNode) { function showMethodDocument(selectedNode) {
clickPluginMethodNode = parseInt($(selectedNode).attr("id")); clickPluginMethodNode = parseInt($(selectedNode).attr("id"));
var length = $("#showPluginMethod").children().length; var length = $("#showPluginMethod").children().length;
var behaviorAreaChild = $('#behaviorArea').children(); var behaviorAreaChild = $('#behaviorArea').children();
var div = $("#showPluginMethod").children(); var div = $("#showPluginMethod").children();
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
if (behaviorAreaChild[i].getAttribute("id") != clickPluginMethodNode) { if (behaviorAreaChild[i].getAttribute("id") != clickPluginMethodNode) {
$(behaviorAreaChild[i]).find("p").attr("class", ""); $(behaviorAreaChild[i]).find("p").attr("class", "");
} else { } else {
$(behaviorAreaChild[i]).find("p").attr("class", "visited"); $(behaviorAreaChild[i]).find("p").attr("class", "visited");
} }
} }
for (var j = 0; j < length; j++) { for (var j = 0; j < length; j++) {
if (div[j].getAttribute("id") == clickPluginMethodNode) { if (div[j].getAttribute("id") == clickPluginMethodNode) {
$(div[j]).show(); $(div[j]).show();
} else { } else {
$(div[j]).hide(); $(div[j]).hide();
} }
} }
$('#submitBehaviors').attr("class", "show"); $('#submitBehaviors').attr("class", "show");
} }
function removeInsertPluginByClicked() { function removeInsertPluginByClicked() {
var length = $('#behaviorArea').children().length; var length = $('#behaviorArea').children().length;
var removeDocumentNode = document.getElementById("showPluginMethod").childNodes; var removeDocumentNode = document.getElementById("showPluginMethod").childNodes;
for (var i = parseInt(clickPluginMethodNode + 1); i < length; i++) { for (var i = parseInt(clickPluginMethodNode + 1); i < length; i++) {
pluginMethodList[i - 1] = pluginMethodList[i]; pluginMethodList[i - 1] = pluginMethodList[i];
} }
pluginMethodList.splice(length - 1, 1);// js Array remove element pluginMethodList.splice(length - 1, 1);// js Array remove element
createPluginMethodLines(); createPluginMethodLines();
for (var j = 0; j < length; j++) { for (var j = 0; j < length; j++) {
if ($(removeDocumentNode[j]).attr("id") == clickPluginMethodNode) { if ($(removeDocumentNode[j]).attr("id") == clickPluginMethodNode) {
document.getElementById("showPluginMethod").removeChild( document.getElementById("showPluginMethod").removeChild(
removeDocumentNode[j]); removeDocumentNode[j]);
} }
} }
} }
function clearPluginMethodList() { function clearPluginMethodList() {
pluginMethodList.splice(0, pluginMethodList.length); pluginMethodList.splice(0, pluginMethodList.length);
document.getElementById('behaviorArea').innerHTML = ""; document.getElementById('behaviorArea').innerHTML = "";
document.getElementById("showPluginMethod").innerHTML = ""; document.getElementById("showPluginMethod").innerHTML = "";
$('#submitBehaviors').attr("class", "hide"); $('#submitBehaviors').attr("class", "hide");
} }
function loadMethodParams(behaviorData, behaviorIndex) { function loadMethodParams(behaviorData, behaviorIndex) {
alert("loadMehtodParams"); alert("loadMehtodParams");
var temp = behaviorData.split('.'); var temp = behaviorData.split('.');
var plugin = temp[0].split('_')[0]; var plugin = temp[0].split('_')[0];
var method = temp[1]; var method = temp[1];
$.post("loadMethodParameters", { $.post("loadMethodParameters", {
pluginName : plugin, pluginName : plugin,
methodName : method methodName : method
}, function(data) { }, function(data) {
if (!data.success) { if (!data.success) {
alert(data.failedMessage); alert(data.failedMessage);
return; return;
} }
data = data.data; data = data.data;
var documentHtml = ""; var documentHtml = "";
var boxHeader = ""; var boxHeader = "";
boxHeader = "<div class='box-header well' data-original-title> " boxHeader = "<div class='box-header well' data-original-title> "
+ "<i class='icon-pencil left'></i>" + "<h2>sample:<i>" + "<i class='icon-pencil left'></i>" + "<h2>sample:<i>"
+ behaviorData + "</i></h2></div>"; + behaviorData + "</i></h2></div>";
var fieldHTML=createBehaviorsForm(data, behaviorData, behaviorIndex); var fieldHTML=createBehaviorsForm(data, behaviorData, behaviorIndex);
documentHtml = "<div id='" documentHtml = "<div id='"
+ behaviorIndex + behaviorIndex
+ "' class='hide'><p class='hide'>" + "' class='hide'><p class='hide'>"
+ behaviorData + behaviorData
+ "</p><div class='span12 box' style='margin-left:-2px;'>" + "</p><div class='span12 box' style='margin-left:-2px;'>"
+ boxHeader + boxHeader
+ "<div class='box-content'>" + "<div class='box-content'>"
+ fieldHTML + fieldHTML
+ "</div><div class='left table-margin'><button class='btn btn-primary btn-width' type='submit' onClick='saveBehavior(this);'>" + "</div><div class='left table-margin'><button class='btn btn-primary btn-width' type='submit' onClick='saveBehavior(this);'>"
+ $.i18n.prop("save") + $.i18n.prop("save")
+ "</button>" + "</button>"
+ "&nbsp;&nbsp;<button class='btn btn-primary btn-width' type='submit' onClick='cancelBehavior(this);'>" + "&nbsp;&nbsp;<button class='btn btn-primary btn-width' type='submit' onClick='cancelBehavior(this);'>"
+ $.i18n.prop("cancel") + "</button></div></div></div>"; + $.i18n.prop("cancel") + "</button></div></div></div>";
document.getElementById("showPluginMethod").innerHTML += documentHtml; document.getElementById("showPluginMethod").innerHTML += documentHtml;
}); });
} }
function saveBehavior(selectedNode) { function saveBehavior(selectedNode) {
var uploadNode = selectedNode.parentNode.previousSibling; var uploadNode = selectedNode.parentNode.previousSibling;
var div = uploadNode.childNodes; var div = uploadNode.childNodes;
var length = div.length; var length = div.length;
var behaviorIndex = 0, use = "", name = "", type = ""; var behaviorIndex = 0, use = "", name = "", type = "";
var plugin_method = selectedNode.parentNode.parentNode.parentNode.firstChild.firstChild.nodeValue var plugin_method = selectedNode.parentNode.parentNode.parentNode.firstChild.firstChild.nodeValue
.split("."); .split(".");
name = plugin_method[1]; name = plugin_method[1];
use = plugin_method[0].split("_")[0]; use = plugin_method[0].split("_")[0];
if (use == "timer") { if (use == "timer") {
type = "TIMERBEHAVIOR"; type = "TIMERBEHAVIOR";
} else if(use=="http"){ } else if(use=="http"){
type = "USERBEHAVIOR"; type = "USERBEHAVIOR";
} }
var parameters = new Array(); var parameters = new Array();
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
var node = div[i]; var node = div[i];
var nodeId = $(node).attr("id").split("_"); var nodeId = $(node).attr("id").split("_");
behaviorIndex = nodeId[0]; behaviorIndex = nodeId[0];
var parameterModel; var parameterModel;
var key = "", value = "", temp = ""; var key = "", value = "", temp = "";
if ($(node).attr("class") == "Field sample_frame") { if ($(node).attr("class") == "Field sample_frame") {
key = node.lastChild.firstChild.nodeValue; key = node.lastChild.firstChild.nodeValue;
temp = $(node).find("input").val(); temp = $(node).find("input").val();
if (temp != "") { if (temp != "") {
value = temp; value = temp;
} }
} else if ($(node).attr("class") == "MultiField sample_frame") { } else if ($(node).attr("class") == "MultiField sample_frame") {
key = node.firstChild.firstChild.nodeValue.split(":")[0]; key = node.firstChild.firstChild.nodeValue.split(":")[0];
var fieldNode = $(node).find("table").children(); var fieldNode = $(node).find("table").children();
var fieldLength = $(fieldNode).length; var fieldLength = $(fieldNode).length;
for (var j = 0; j < fieldLength; j++) { for (var j = 0; j < fieldLength; j++) {
temp = $(fieldNode[j]).find("input").val(); temp = $(fieldNode[j]).find("input").val();
if(temp!=""){ if(temp!=""){
value += temp; value += temp;
} }
if (j!=fieldLength-1) { if (j!=fieldLength-1) {
value += ";"; value += ";";
} }
} }
} else if ($(node).attr("class") == "Table sample_frame") { } else if ($(node).attr("class") == "Table sample_frame") {
key = node.lastChild.firstChild.nodeValue; key = node.lastChild.firstChild.nodeValue;
var table = $(node).find("table"); var table = $(node).find("table");
var col = table.find("th").length; var col = table.find("th").length;
var row = table.find("tbody").children().length; var row = table.find("tbody").children().length;
var tbody = $(node).find("tbody"); var tbody = $(node).find("tbody");
for (var m = 0; m < row; m++) { for (var m = 0; m < row; m++) {
for (var n = 0; n < col; n++) { for (var n = 0; n < col; n++) {
var rowNode = $(tbody).children()[m]; var rowNode = $(tbody).children()[m];
var colNode = $(rowNode).children()[n]; var colNode = $(rowNode).children()[n];
temp = $(colNode).find("input").val(); temp = $(colNode).find("input").val();
if (temp != "") { if (temp != "") {
value += temp + "|"; value += temp + "|";
} }
} }
if (value != "") { if (value != "") {
value += ";"; value += ";";
} }
} }
} else if ($(node).attr("class") == "CheckBox sample_frame") { } else if ($(node).attr("class") == "CheckBox sample_frame") {
key = node.lastChild.firstChild.nodeValue; key = node.lastChild.firstChild.nodeValue;
var id = $(node).attr("id"); var id = $(node).attr("id");
$('input[name=' + id + ']:checked').each(function() { $('input[name=' + id + ']:checked').each(function() {
temp = $(this).val(); temp = $(this).val();
if (temp != "") { if (temp != "") {
value += temp + ";"; value += temp + ";";
} }
}); });
} }
if (value != "") { if (value != "") {
parameterModel = new ParameterModel(key, value); parameterModel = new ParameterModel(key, value);
parameters.push(parameterModel); parameters.push(parameterModel);
} }
} }
var behaviorModel = new BehaviorModel(behaviorIndex, use, name, type, var behaviorModel = new BehaviorModel(behaviorIndex, use, name, type,
parameters); parameters);
behaviors.push(behaviorModel); behaviors.push(behaviorModel);
alert("save success!"); alert("save success!");
} }
function submitBehaviors(selectedNode) { function submitBehaviors(selectedNode) {
var scriptName = $(selectedNode.parentNode.parentNode).find("input").val(); var scriptName = $(selectedNode.parentNode.parentNode).find("input").val();
if (scriptName == null || scriptName == "") { if (scriptName == null || scriptName == "") {
alert("Please input scriptName."); alert("Please input scriptName.");
return; return;
} }
if (behaviors.length == 0) { if (behaviors.length == 0) {
alert("Please save the behavior or fill in the form."); alert("Please save the behavior or fill in the form.");
return; return;
} }
for (var i = 0; i < pluginChoosedList.length; i++) { for (var i = 0; i < pluginChoosedList.length; i++) {
var id = pluginChoosedList[i].split("_")[0]; var id = pluginChoosedList[i].split("_")[0];
var name = ""; var name = "";
var parameters = new Array(); var parameters = new Array();
if (id == "http") { if (id == "http") {
name = "Http"; name = "Http";
} else if (id == "timer") { } else if (id == "timer") {
name = "ConstantTimer"; name = "ConstantTimer";
} }
var usePluginModel = new UsePluginModel(id, name, parameters); var usePluginModel = new UsePluginModel(id, name, parameters);
usePluginList.push(usePluginModel); usePluginList.push(usePluginModel);
} }
var scriptModel = new PluginEditScriptRequestModel(behaviors, var scriptModel = new PluginEditScriptRequestModel(behaviors,
usePluginList, scriptName); usePluginList, scriptName);
$.ajax({ $.ajax({
type : "POST", type : "POST",
url : "uploadPluginEditedScript", url : "uploadPluginEditedScript",
contentType : "application/json", contentType : "application/json",
data : JSON.stringify(scriptModel), data : JSON.stringify(scriptModel),
success : function(data) { success : function(data) {
if (!data.success) { if (!data.success) {
alert(data.failedMessage); alert(data.failedMessage);
return; return;
} }
data = data.data; data = data.data;
window.location.replace("script.jsp"); window.location.replace("script.jsp");
}, },
error : function(request, status, error) { error : function(request, status, error) {
} }
}); });
} }
function cancelBehavior(selectedNode) { function cancelBehavior(selectedNode) {
var divNode = selectedNode.parentNode.parentNode.parentNode; var divNode = selectedNode.parentNode.parentNode.parentNode;
$(divNode).hide(); $(divNode).hide();
} }
$('#pluginCancel').click(function() { $('#pluginCancel').click(function() {
$('#myModal_Plugin').modal('hide'); $('#myModal_Plugin').modal('hide');
}); });
$('#behaviorCancel').click(function() { $('#behaviorCancel').click(function() {
$('#myModal_Behavior').modal('hide'); $('#myModal_Behavior').modal('hide');
}); });

View File

@ -1,85 +1,85 @@
function form_validation(name) { function form_validation(name) {
var input_value = document.getElementsByName(name)[0].value; var input_value = document.getElementsByName(name)[0].value;
var regx = /^[a-zA-Z0-9]+$/; var regx = /^[a-zA-Z0-9]+$/;
if (!regx.test(input_value)) { if (!regx.test(input_value)) {
alert(name + " must be number!"); alert(name + " must be number!");
if (name == "username") { if (name == "username") {
$('#usrmsg').show(); $('#usrmsg').show();
document.getElementsByName('username')[0].value = ""; document.getElementsByName('username')[0].value = "";
document.getElementsByName('username')[0].style.border = "1px solid red"; document.getElementsByName('username')[0].style.border = "1px solid red";
} }
else if (name == "password") { else if (name == "password") {
$('#pwdmsg').show(); $('#pwdmsg').show();
document.getElementsByName('password')[0].value = ""; document.getElementsByName('password')[0].value = "";
document.getElementsByName('password')[0].style.border = "1px solid red"; document.getElementsByName('password')[0].style.border = "1px solid red";
} }
} else { } else {
document.getElementsByName(name)[0].style.border = "1px solid #ddd"; document.getElementsByName(name)[0].style.border = "1px solid #ddd";
if (name == "username") if (name == "username")
$('#usrmsg').hide(); $('#usrmsg').hide();
else if (name == "password") else if (name == "password")
$('#pwdmsg').hide(); $('#pwdmsg').hide();
} }
} }
function clean() { function clean() {
document.getElementsByName('username')[0].value = ""; document.getElementsByName('username')[0].value = "";
document.getElementsByName('password')[0].value = ""; document.getElementsByName('password')[0].value = "";
document.getElementsByName('retype_pwd')[0].value = ""; document.getElementsByName('retype_pwd')[0].value = "";
} }
function register() { function register() {
var userName = $('#username').val(); var userName = $('#username').val();
var password = $('#password').val(); var password = $('#password').val();
var rePassword = $("#retype_pwd").val(); var rePassword = $("#retype_pwd").val();
$.post('register', { $.post('register', {
userName : userName, userName : userName,
password : password, password : password,
rePassword : rePassword rePassword : rePassword
}, function(data) { }, function(data) {
if (data.success) { if (data.success) {
window.location.replace("registerSuccess.jsp"); window.location.replace("registerSuccess.jsp");
} else { } else {
alert(data.failedMessage); alert(data.failedMessage);
// $('#registerMsg').html($.i18n.prop('msgRegister')); // $('#registerMsg').html($.i18n.prop('msgRegister'));
} }
}, "json"); }, "json");
} }
function password_validation() { function password_validation() {
var null_flag = 0; var null_flag = 0;
var user_name = document.getElementsByName('username')[0].value; var user_name = document.getElementsByName('username')[0].value;
var retype_pwd = document.getElementsByName('retype_pwd')[0].value; var retype_pwd = document.getElementsByName('retype_pwd')[0].value;
var input_pwd = document.getElementsByName('password')[0].value; var input_pwd = document.getElementsByName('password')[0].value;
if (user_name == "") { if (user_name == "") {
$('#usrmsg').show(); $('#usrmsg').show();
document.getElementsByName('username')[0].value = ""; document.getElementsByName('username')[0].value = "";
document.getElementsByName('username')[0].style.border = "1px solid red"; document.getElementsByName('username')[0].style.border = "1px solid red";
null_flag = 1; null_flag = 1;
} else { } else {
$('#usrmsg').hide(); $('#usrmsg').hide();
document.getElementsByName('username')[0].style.border = ""; document.getElementsByName('username')[0].style.border = "";
} }
if (input_pwd == "") { if (input_pwd == "") {
$('#pwdmsg').show(); $('#pwdmsg').show();
document.getElementsByName('password')[0].value = ""; document.getElementsByName('password')[0].value = "";
document.getElementsByName('password')[0].style.border = "1px solid red"; document.getElementsByName('password')[0].style.border = "1px solid red";
null_flag = 1; null_flag = 1;
} else { } else {
$('#pwdmsg').hide(); $('#pwdmsg').hide();
document.getElementsByName('password')[0].style.border = ""; document.getElementsByName('password')[0].style.border = "";
} }
if (input_pwd != retype_pwd) { if (input_pwd != retype_pwd) {
$('#rtpmsg').show(); $('#rtpmsg').show();
document.getElementsByName('retype_pwd')[0].value = ""; document.getElementsByName('retype_pwd')[0].value = "";
document.getElementsByName('retype_pwd')[0].style.border = "1px solid red"; document.getElementsByName('retype_pwd')[0].style.border = "1px solid red";
null_flag = 1; null_flag = 1;
} else { } else {
$('#rtpmsg').hide(); $('#rtpmsg').hide();
document.getElementsByName('retype_pwd')[0].style.border = ""; document.getElementsByName('retype_pwd')[0].style.border = "";
} }
if (null_flag == 0) if (null_flag == 0)
register(); register();
} }

View File

@ -1,112 +1,112 @@
package org.bench4q.web.api.test; package org.bench4q.web.api.test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.util.List; import java.util.List;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import junit.framework.Assert; import junit.framework.Assert;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.bench4q.share.enums.master.TestPlanStatus; import org.bench4q.share.enums.master.TestPlanStatus;
import org.bench4q.web.api.MonitorController; import org.bench4q.web.api.MonitorController;
import org.bench4q.web.exception.CustomGenericException; import org.bench4q.web.exception.CustomGenericException;
import org.bench4q.web.model.BaseResponseModel; import org.bench4q.web.model.BaseResponseModel;
import org.bench4q.web.model.ResultModel; import org.bench4q.web.model.ResultModel;
import org.bench4q.web.model.WebTestPlanResultModel; import org.bench4q.web.model.WebTestPlanResultModel;
import org.bench4q.web.tool.test.GsonHelper; import org.bench4q.web.tool.test.GsonHelper;
import org.bench4q.web.tool.test.LoginHelper; import org.bench4q.web.tool.test.LoginHelper;
import org.bench4q.web.tool.test.TestPlanHelper; import org.bench4q.web.tool.test.TestPlanHelper;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" }) @ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" })
public class TestMonitorResult extends LoginHelper { public class TestMonitorResult extends LoginHelper {
private MonitorController monitorController; private MonitorController monitorController;
private TestPlanHelper startTestPlan; private TestPlanHelper startTestPlan;
private String accessToken; private String accessToken;
private String testPlanId; private String testPlanId;
private Logger logger = Logger.getLogger(TestMonitorResult.class); private Logger logger = Logger.getLogger(TestMonitorResult.class);
public MonitorController getMonitorController() { public MonitorController getMonitorController() {
return monitorController; return monitorController;
} }
@Autowired @Autowired
public void setMonitorController(MonitorController monitorController) { public void setMonitorController(MonitorController monitorController) {
this.monitorController = monitorController; this.monitorController = monitorController;
} }
public TestPlanHelper getStartTestPlan() { public TestPlanHelper getStartTestPlan() {
return startTestPlan; return startTestPlan;
} }
@Autowired @Autowired
public void setStartTestPlan(TestPlanHelper startTestPlan) { public void setStartTestPlan(TestPlanHelper startTestPlan) {
this.startTestPlan = startTestPlan; this.startTestPlan = startTestPlan;
} }
@Before @Before
public void setUp() { public void setUp() {
this.accessToken = login(); this.accessToken = login();
this.getStartTestPlan().startTest(accessToken); this.getStartTestPlan().startTest(accessToken);
this.testPlanId = this.getStartTestPlan().getTestPlanRunId(); this.testPlanId = this.getStartTestPlan().getTestPlanRunId();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void test_getMemoryResult() throws InterruptedException, public void test_getMemoryResult() throws InterruptedException,
CustomGenericException, JAXBException { CustomGenericException, JAXBException {
testTestPlanStatus(); testTestPlanStatus();
BaseResponseModel baseResponseModel = this.getMonitorController() BaseResponseModel baseResponseModel = this.getMonitorController()
.getMemoryStatus(accessToken, testPlanId, .getMemoryStatus(accessToken, testPlanId,
TestPlanHelper.MONITOR_IP, "5556", "pagesPerSecond", TestPlanHelper.MONITOR_IP, "5556", "pagesPerSecond",
"0"); "0");
assertTrue(baseResponseModel.isSuccess()); assertTrue(baseResponseModel.isSuccess());
List<ResultModel> resultModels = (List<ResultModel>) baseResponseModel List<ResultModel> resultModels = (List<ResultModel>) baseResponseModel
.getData(); .getData();
logger.info(GsonHelper.getGson().toJson(resultModels)); logger.info(GsonHelper.getGson().toJson(resultModels));
assertTrue(resultModels.size() > 0); assertTrue(resultModels.size() > 0);
} }
@Test @Test
public void test_getCpuResult() throws InterruptedException, CustomGenericException, JAXBException{ public void test_getCpuResult() throws InterruptedException, CustomGenericException, JAXBException{
testTestPlanStatus(); testTestPlanStatus();
BaseResponseModel baseResponseModel = this.getMonitorController() BaseResponseModel baseResponseModel = this.getMonitorController()
.getCpuResult(accessToken, testPlanId, TestPlanHelper.MONITOR_IP, "5556", "cpu0", "processorTimePercent", "0"); .getCpuResult(accessToken, testPlanId, TestPlanHelper.MONITOR_IP, "5556", "cpu0", "processorTimePercent", "0");
assertTrue(baseResponseModel.isSuccess()); assertTrue(baseResponseModel.isSuccess());
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<ResultModel> resultModels = (List<ResultModel>) baseResponseModel List<ResultModel> resultModels = (List<ResultModel>) baseResponseModel
.getData(); .getData();
logger.info(GsonHelper.getGson().toJson(resultModels)); logger.info(GsonHelper.getGson().toJson(resultModels));
assertTrue(resultModels.size() > 0); assertTrue(resultModels.size() > 0);
} }
@Test @Test
public void test_getNetwork() throws InterruptedException, CustomGenericException, JAXBException{ public void test_getNetwork() throws InterruptedException, CustomGenericException, JAXBException{
testTestPlanStatus(); testTestPlanStatus();
BaseResponseModel baseResponseModel = this.getMonitorController() BaseResponseModel baseResponseModel = this.getMonitorController()
.getCpuResult(accessToken, testPlanId, TestPlanHelper.MONITOR_IP, "5556", "cpu0", "processorTimePercent", "0"); .getCpuResult(accessToken, testPlanId, TestPlanHelper.MONITOR_IP, "5556", "cpu0", "processorTimePercent", "0");
assertTrue(baseResponseModel.isSuccess()); assertTrue(baseResponseModel.isSuccess());
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<ResultModel> resultModels = (List<ResultModel>) baseResponseModel List<ResultModel> resultModels = (List<ResultModel>) baseResponseModel
.getData(); .getData();
logger.info(GsonHelper.getGson().toJson(resultModels)); logger.info(GsonHelper.getGson().toJson(resultModels));
assertTrue(resultModels.size() > 0); assertTrue(resultModels.size() > 0);
} }
private void testTestPlanStatus() throws InterruptedException, private void testTestPlanStatus() throws InterruptedException,
CustomGenericException, JAXBException { CustomGenericException, JAXBException {
Assert.assertNotNull(this.getStartTestPlan().getTestPlanRunId()); Assert.assertNotNull(this.getStartTestPlan().getTestPlanRunId());
assertNotNull(testPlanId); assertNotNull(testPlanId);
Thread.sleep(6000); Thread.sleep(6000);
WebTestPlanResultModel webTestPlanResultModel = this.getStartTestPlan() WebTestPlanResultModel webTestPlanResultModel = this.getStartTestPlan()
.queryTestPlanResultModel(testPlanId, accessToken); .queryTestPlanResultModel(testPlanId, accessToken);
assertEquals(TestPlanStatus.InRunning, assertEquals(TestPlanStatus.InRunning,
webTestPlanResultModel.getCurrentStatus()); webTestPlanResultModel.getCurrentStatus());
} }
} }

View File

@ -1,219 +1,219 @@
package org.bench4q.web.api.test; package org.bench4q.web.api.test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import junit.framework.Assert; import junit.framework.Assert;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.bench4q.share.enums.master.TestPlanStatus; import org.bench4q.share.enums.master.TestPlanStatus;
import org.bench4q.share.helper.ExceptionLog; import org.bench4q.share.helper.ExceptionLog;
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel; import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
import org.bench4q.share.models.master.statistics.ScriptPagesBriefModel; import org.bench4q.share.models.master.statistics.ScriptPagesBriefModel;
import org.bench4q.web.api.TestPlanActionController; import org.bench4q.web.api.TestPlanActionController;
import org.bench4q.web.exception.CustomGenericException; import org.bench4q.web.exception.CustomGenericException;
import org.bench4q.web.model.BaseResponseModel; import org.bench4q.web.model.BaseResponseModel;
import org.bench4q.web.model.ResultModel; import org.bench4q.web.model.ResultModel;
import org.bench4q.web.model.SutInfo; import org.bench4q.web.model.SutInfo;
import org.bench4q.web.model.WebTestPlanResultModel; import org.bench4q.web.model.WebTestPlanResultModel;
import org.bench4q.web.service.TestPlanService; import org.bench4q.web.service.TestPlanService;
import org.bench4q.web.tool.test.GsonHelper; import org.bench4q.web.tool.test.GsonHelper;
import org.bench4q.web.tool.test.LoginHelper; import org.bench4q.web.tool.test.LoginHelper;
import org.bench4q.web.tool.test.TestPlanHelper; import org.bench4q.web.tool.test.TestPlanHelper;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.google.gson.Gson; import com.google.gson.Gson;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" }) @ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" })
public class TestScriptResultTest extends LoginHelper { public class TestScriptResultTest extends LoginHelper {
private TestPlanActionController testPlanActionController; private TestPlanActionController testPlanActionController;
private TestPlanHelper testPlanHelper; private TestPlanHelper testPlanHelper;
private String testPlanId; private String testPlanId;
private String accessToken; private String accessToken;
private Logger logger = Logger.getLogger(TestScriptResultTest.class); private Logger logger = Logger.getLogger(TestScriptResultTest.class);
private TestPlanService testPlanService; private TestPlanService testPlanService;
private String scriptId; private String scriptId;
public TestPlanActionController getTestPlanActionController() { public TestPlanActionController getTestPlanActionController() {
return testPlanActionController; return testPlanActionController;
} }
@Autowired @Autowired
public void setTestPlanActionController( public void setTestPlanActionController(
TestPlanActionController testPlanActionController) { TestPlanActionController testPlanActionController) {
this.testPlanActionController = testPlanActionController; this.testPlanActionController = testPlanActionController;
} }
public TestPlanHelper getStartTestPlan() { public TestPlanHelper getStartTestPlan() {
return testPlanHelper; return testPlanHelper;
} }
@Autowired @Autowired
public void setStartTestPlan(TestPlanHelper startTestPlan) { public void setStartTestPlan(TestPlanHelper startTestPlan) {
this.testPlanHelper = startTestPlan; this.testPlanHelper = startTestPlan;
} }
public TestPlanService getTestPlanService() { public TestPlanService getTestPlanService() {
return testPlanService; return testPlanService;
} }
@Autowired @Autowired
public void setTestPlanService(TestPlanService testPlanService) { public void setTestPlanService(TestPlanService testPlanService) {
this.testPlanService = testPlanService; this.testPlanService = testPlanService;
} }
@Before @Before
public void setUp() { public void setUp() {
this.accessToken = this.login(); this.accessToken = this.login();
this.testPlanHelper.startTest(accessToken); this.testPlanHelper.startTest(accessToken);
this.testPlanId = this.testPlanHelper.getTestPlanRunId(); this.testPlanId = this.testPlanHelper.getTestPlanRunId();
this.scriptId = this.getOneScriptId(testPlanId, accessToken); this.scriptId = this.getOneScriptId(testPlanId, accessToken);
} }
@After @After
public void clean() throws CustomGenericException { public void clean() throws CustomGenericException {
this.getStartTestPlan().cleanUpTest(this.accessToken); this.getStartTestPlan().cleanUpTest(this.accessToken);
} }
@Test @Test
public void test_getReplaceList() throws CustomGenericException, public void test_getReplaceList() throws CustomGenericException,
JAXBException { JAXBException {
Assert.assertNotNull(this.getStartTestPlan().getTestPlanRunId()); Assert.assertNotNull(this.getStartTestPlan().getTestPlanRunId());
BaseResponseModel baseResponseModel = this BaseResponseModel baseResponseModel = this
.getTestPlanActionController().getReplaceList(this.accessToken, .getTestPlanActionController().getReplaceList(this.accessToken,
this.testPlanHelper.getTestPlanRunId()); this.testPlanHelper.getTestPlanRunId());
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Integer> scriptIdMap = (Map<String, Integer>) baseResponseModel Map<String, Integer> scriptIdMap = (Map<String, Integer>) baseResponseModel
.getData(); .getData();
Assert.assertTrue(scriptIdMap.size() > 0); Assert.assertTrue(scriptIdMap.size() > 0);
} }
@Test @Test
public void test_getTestPageBriefModel() throws InterruptedException, public void test_getTestPageBriefModel() throws InterruptedException,
CustomGenericException, JAXBException { CustomGenericException, JAXBException {
assertNotNull(this.testPlanId); assertNotNull(this.testPlanId);
assertNotNull(this.scriptId); assertNotNull(this.scriptId);
Thread.sleep(3000); Thread.sleep(3000);
WebTestPlanResultModel webTestPlanResultModel = this.getStartTestPlan() WebTestPlanResultModel webTestPlanResultModel = this.getStartTestPlan()
.queryTestPlanResultModel(testPlanId, accessToken); .queryTestPlanResultModel(testPlanId, accessToken);
assertEquals(TestPlanStatus.InRunning, assertEquals(TestPlanStatus.InRunning,
webTestPlanResultModel.getCurrentStatus()); webTestPlanResultModel.getCurrentStatus());
BaseResponseModel baseResponseModel = this BaseResponseModel baseResponseModel = this
.getTestPlanActionController().getScriptPageBriefModel( .getTestPlanActionController().getScriptPageBriefModel(
accessToken, testPlanId, scriptId); accessToken, testPlanId, scriptId);
ScriptPagesBriefModel scriptPagesBriefModel = (ScriptPagesBriefModel) baseResponseModel ScriptPagesBriefModel scriptPagesBriefModel = (ScriptPagesBriefModel) baseResponseModel
.getData(); .getData();
logger.info(GsonHelper.getGson().toJson(scriptPagesBriefModel)); logger.info(GsonHelper.getGson().toJson(scriptPagesBriefModel));
assertTrue(scriptPagesBriefModel.getScriptPageBriefModels().size() > 0); assertTrue(scriptPagesBriefModel.getScriptPageBriefModels().size() > 0);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void test_getScriptBriefStatus() throws NoSuchFieldException, public void test_getScriptBriefStatus() throws NoSuchFieldException,
CustomGenericException, JAXBException, InterruptedException { CustomGenericException, JAXBException, InterruptedException {
Assert.assertNotNull(testPlanId); Assert.assertNotNull(testPlanId);
String scriptId = getOneScriptId(this.getStartTestPlan() String scriptId = getOneScriptId(this.getStartTestPlan()
.getTestPlanRunId(), accessToken); .getTestPlanRunId(), accessToken);
Assert.assertNotNull(scriptId); Assert.assertNotNull(scriptId);
Thread.sleep(3000); Thread.sleep(3000);
BaseResponseModel baseResponseModelForTestPlan = this BaseResponseModel baseResponseModelForTestPlan = this
.getTestPlanActionController().queryTestPlan(accessToken, .getTestPlanActionController().queryTestPlan(accessToken,
this.testPlanId); this.testPlanId);
assertTrue(baseResponseModelForTestPlan.isSuccess()); assertTrue(baseResponseModelForTestPlan.isSuccess());
WebTestPlanResultModel webTestPlanResultModel = (WebTestPlanResultModel) baseResponseModelForTestPlan WebTestPlanResultModel webTestPlanResultModel = (WebTestPlanResultModel) baseResponseModelForTestPlan
.getData(); .getData();
assertEquals(TestPlanStatus.InRunning, assertEquals(TestPlanStatus.InRunning,
webTestPlanResultModel.getCurrentStatus()); webTestPlanResultModel.getCurrentStatus());
BaseResponseModel baseResponseModel = this BaseResponseModel baseResponseModel = this
.getTestPlanActionController().getScriptBriefStatus( .getTestPlanActionController().getScriptBriefStatus(
accessToken, this.testPlanId, accessToken, this.testPlanId,
this.getOneScriptId(this.testPlanId, accessToken), this.getOneScriptId(this.testPlanId, accessToken),
"averageResponseTime", "0"); "averageResponseTime", "0");
assertTrue(baseResponseModel.isSuccess()); assertTrue(baseResponseModel.isSuccess());
List<ResultModel> resultModels = (List<ResultModel>) baseResponseModel List<ResultModel> resultModels = (List<ResultModel>) baseResponseModel
.getData(); .getData();
Logger.getLogger("get result model"); Logger.getLogger("get result model");
Logger.getLogger(TestScriptResultTest.class).info( Logger.getLogger(TestScriptResultTest.class).info(
"resultModel:" + GsonHelper.getGson().toJson(resultModels)); "resultModel:" + GsonHelper.getGson().toJson(resultModels));
assertTrue(resultModels.size() > 0); assertTrue(resultModels.size() > 0);
} }
@Test @Test
public void test_getScriptBehaviorBriefModel() public void test_getScriptBehaviorBriefModel()
throws CustomGenericException, JAXBException, InterruptedException { throws CustomGenericException, JAXBException, InterruptedException {
assertNotNull(this.testPlanId); assertNotNull(this.testPlanId);
String scriptId = getOneScriptId(this.getStartTestPlan() String scriptId = getOneScriptId(this.getStartTestPlan()
.getTestPlanRunId(), accessToken); .getTestPlanRunId(), accessToken);
Thread.sleep(3000); Thread.sleep(3000);
BaseResponseModel baseResponseModel = this BaseResponseModel baseResponseModel = this
.getTestPlanActionController().getScriptBehaviorBriefModel( .getTestPlanActionController().getScriptBehaviorBriefModel(
accessToken, this.testPlanId, scriptId); accessToken, this.testPlanId, scriptId);
ScriptBehaviorsBriefModel scriptBehaviorsBriefModel = (ScriptBehaviorsBriefModel) baseResponseModel ScriptBehaviorsBriefModel scriptBehaviorsBriefModel = (ScriptBehaviorsBriefModel) baseResponseModel
.getData(); .getData();
logger.info(GsonHelper.getGson().toJson(scriptBehaviorsBriefModel)); logger.info(GsonHelper.getGson().toJson(scriptBehaviorsBriefModel));
Assert.assertNotNull(scriptBehaviorsBriefModel); Assert.assertNotNull(scriptBehaviorsBriefModel);
Assert.assertNotNull(scriptBehaviorsBriefModel Assert.assertNotNull(scriptBehaviorsBriefModel
.getTestBehaviorsBriefModel()); .getTestBehaviorsBriefModel());
Assert.assertTrue(scriptBehaviorsBriefModel Assert.assertTrue(scriptBehaviorsBriefModel
.getTestBehaviorsBriefModel().getBehaviorBriefModels().size() > 0); .getTestBehaviorsBriefModel().getBehaviorBriefModels().size() > 0);
} }
private String getOneScriptId(String testPlanRunId, String accessToken) { private String getOneScriptId(String testPlanRunId, String accessToken) {
try { try {
return this.getStartTestPlan() return this.getStartTestPlan()
.queryTestPlanResultModel(testPlanRunId, accessToken) .queryTestPlanResultModel(testPlanRunId, accessToken)
.getScriptIds().get(0).toString(); .getScriptIds().get(0).toString();
} catch (CustomGenericException e) { } catch (CustomGenericException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
logger.info(ExceptionLog.getStackTrace(e)); logger.info(ExceptionLog.getStackTrace(e));
return null; return null;
} catch (JAXBException e) { } catch (JAXBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
logger.info(ExceptionLog.getStackTrace(e)); logger.info(ExceptionLog.getStackTrace(e));
return null; return null;
} }
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void test_getSutInfo() throws CustomGenericException, JAXBException, public void test_getSutInfo() throws CustomGenericException, JAXBException,
InterruptedException { InterruptedException {
testTestPlanStatus(); testTestPlanStatus();
List<SutInfo> sutInfos = (List<SutInfo>) this List<SutInfo> sutInfos = (List<SutInfo>) this
.getTestPlanActionController() .getTestPlanActionController()
.getSutInfo(accessToken, testPlanId).getData(); .getSutInfo(accessToken, testPlanId).getData();
for (SutInfo sutInfo : sutInfos) { for (SutInfo sutInfo : sutInfos) {
assertEquals("5556", sutInfo.getPort()); assertEquals("5556", sutInfo.getPort());
assertEquals(TestPlanHelper.MONITOR_IP, sutInfo.getIp()); assertEquals(TestPlanHelper.MONITOR_IP, sutInfo.getIp());
Gson gson = new Gson(); Gson gson = new Gson();
logger.info(gson.toJson(sutInfo)); logger.info(gson.toJson(sutInfo));
} }
assertEquals(1, sutInfos.size()); assertEquals(1, sutInfos.size());
} }
private void testTestPlanStatus() throws InterruptedException, private void testTestPlanStatus() throws InterruptedException,
CustomGenericException, JAXBException { CustomGenericException, JAXBException {
Assert.assertNotNull(this.getStartTestPlan().getTestPlanRunId()); Assert.assertNotNull(this.getStartTestPlan().getTestPlanRunId());
assertNotNull(testPlanId); assertNotNull(testPlanId);
Thread.sleep(6000); Thread.sleep(6000);
WebTestPlanResultModel webTestPlanResultModel = this.getStartTestPlan() WebTestPlanResultModel webTestPlanResultModel = this.getStartTestPlan()
.queryTestPlanResultModel(testPlanId, accessToken); .queryTestPlanResultModel(testPlanId, accessToken);
assertEquals(TestPlanStatus.InRunning, assertEquals(TestPlanStatus.InRunning,
webTestPlanResultModel.getCurrentStatus()); webTestPlanResultModel.getCurrentStatus());
} }
} }

View File

@ -1,52 +1,52 @@
package org.bench4q.web.api.test; package org.bench4q.web.api.test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.bench4q.web.api.TestPlanHistoryResult; import org.bench4q.web.api.TestPlanHistoryResult;
import org.bench4q.web.exception.CustomGenericException; import org.bench4q.web.exception.CustomGenericException;
import org.bench4q.web.model.BaseResponseModel; import org.bench4q.web.model.BaseResponseModel;
import org.bench4q.web.model.TestPlanListModel; import org.bench4q.web.model.TestPlanListModel;
import org.bench4q.web.tool.test.GsonHelper; import org.bench4q.web.tool.test.GsonHelper;
import org.bench4q.web.tool.test.LoginHelper; import org.bench4q.web.tool.test.LoginHelper;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" }) @ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" })
public class TestTestHistory extends LoginHelper { public class TestTestHistory extends LoginHelper {
private TestPlanHistoryResult testPlanHistoryResult; private TestPlanHistoryResult testPlanHistoryResult;
private String accessToken; private String accessToken;
private Logger logger = Logger.getLogger(TestTestHistory.class); private Logger logger = Logger.getLogger(TestTestHistory.class);
public TestPlanHistoryResult getTestPlanHistoryResult() { public TestPlanHistoryResult getTestPlanHistoryResult() {
return testPlanHistoryResult; return testPlanHistoryResult;
} }
@Autowired @Autowired
public void setTestPlanHistoryResult( public void setTestPlanHistoryResult(
TestPlanHistoryResult testPlanHistoryResult) { TestPlanHistoryResult testPlanHistoryResult) {
this.testPlanHistoryResult = testPlanHistoryResult; this.testPlanHistoryResult = testPlanHistoryResult;
} }
@Before @Before
public void setUp() { public void setUp() {
this.accessToken = login(); this.accessToken = login();
} }
@Test @Test
public void test_loadTestHistory() throws CustomGenericException { public void test_loadTestHistory() throws CustomGenericException {
BaseResponseModel baseResponseModel = this.getTestPlanHistoryResult() BaseResponseModel baseResponseModel = this.getTestPlanHistoryResult()
.loadTestPlans(accessToken); .loadTestPlans(accessToken);
logger.info(GsonHelper.getGson().toJson(baseResponseModel)); logger.info(GsonHelper.getGson().toJson(baseResponseModel));
assertTrue(baseResponseModel.isSuccess()); assertTrue(baseResponseModel.isSuccess());
TestPlanListModel testPlanListModel = (TestPlanListModel) baseResponseModel TestPlanListModel testPlanListModel = (TestPlanListModel) baseResponseModel
.getData(); .getData();
assertTrue(testPlanListModel.getList().size() > 0); assertTrue(testPlanListModel.getList().size() > 0);
} }
} }

View File

@ -1,10 +1,10 @@
package org.bench4q.web.tool.test; package org.bench4q.web.tool.test;
import com.google.gson.Gson; import com.google.gson.Gson;
public class GsonHelper { public class GsonHelper {
public static Gson getGson() { public static Gson getGson() {
return new Gson(); return new Gson();
} }
} }

View File

@ -1,87 +1,87 @@
package org.bench4q.web.tool.test; package org.bench4q.web.tool.test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.util.List; import java.util.List;
import org.bench4q.share.models.master.ScriptModel; import org.bench4q.share.models.master.ScriptModel;
import org.bench4q.web.api.ScriptActionController; import org.bench4q.web.api.ScriptActionController;
import org.bench4q.web.exception.CustomGenericException; import org.bench4q.web.exception.CustomGenericException;
import org.bench4q.web.model.BaseResponseModel; import org.bench4q.web.model.BaseResponseModel;
import org.bench4q.web.tool.test.LoginHelper; import org.bench4q.web.tool.test.LoginHelper;
import org.bench4q.web.tool.test.TestPlanHelper; import org.bench4q.web.tool.test.TestPlanHelper;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" }) @ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" })
public class TestLoginHelper { public class TestLoginHelper {
private LoginHelper loginHelper; private LoginHelper loginHelper;
private ScriptActionController scriptActionController; private ScriptActionController scriptActionController;
private TestPlanHelper startTestPlan; private TestPlanHelper startTestPlan;
public LoginHelper getLoginHelper() { public LoginHelper getLoginHelper() {
return loginHelper; return loginHelper;
} }
@Autowired @Autowired
public void setLoginHelper(LoginHelper loginHelper) { public void setLoginHelper(LoginHelper loginHelper) {
this.loginHelper = loginHelper; this.loginHelper = loginHelper;
} }
public TestPlanHelper getStartTestPlan() { public TestPlanHelper getStartTestPlan() {
return startTestPlan; return startTestPlan;
} }
@Autowired @Autowired
public void setStartTestPlan(TestPlanHelper startTestPlan) { public void setStartTestPlan(TestPlanHelper startTestPlan) {
this.startTestPlan = startTestPlan; this.startTestPlan = startTestPlan;
} }
public ScriptActionController getScriptActionController() { public ScriptActionController getScriptActionController() {
return scriptActionController; return scriptActionController;
} }
@Autowired @Autowired
public void setScriptActionController( public void setScriptActionController(
ScriptActionController scriptActionController) { ScriptActionController scriptActionController) {
this.scriptActionController = scriptActionController; this.scriptActionController = scriptActionController;
} }
@Test @Test
public void testLoginHelper() { public void testLoginHelper() {
String accessToken = this.getLoginHelper().login(); String accessToken = this.getLoginHelper().login();
assertNotNull(accessToken); assertNotNull(accessToken);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testLoginHelperRight() throws CustomGenericException { public void testLoginHelperRight() throws CustomGenericException {
String accessToken = this.getLoginHelper().login(); String accessToken = this.getLoginHelper().login();
BaseResponseModel baseResponseModel = this BaseResponseModel baseResponseModel = this
.getScriptActionController().loadScript(accessToken); .getScriptActionController().loadScript(accessToken);
List<ScriptModel> scriptModels=(List<ScriptModel>) List<ScriptModel> scriptModels=(List<ScriptModel>)
baseResponseModel.getData(); baseResponseModel.getData();
assertTrue(baseResponseModel.isSuccess()); assertTrue(baseResponseModel.isSuccess());
assertTrue(scriptModels.size()>0); assertTrue(scriptModels.size()>0);
} }
@Test @Test
public void testLoginInStartTest() throws CustomGenericException{ public void testLoginInStartTest() throws CustomGenericException{
String accessToken = this.getLoginHelper().login(); String accessToken = this.getLoginHelper().login();
this.getStartTestPlan().startTest(accessToken); this.getStartTestPlan().startTest(accessToken);
assertNotNull(this.getStartTestPlan().getTestPlanRunId()); assertNotNull(this.getStartTestPlan().getTestPlanRunId());
} }
@After @After
public void clean() throws CustomGenericException{ public void clean() throws CustomGenericException{
String accessToken = this.getLoginHelper().login(); String accessToken = this.getLoginHelper().login();
this.getStartTestPlan().cleanUpTest(accessToken); this.getStartTestPlan().cleanUpTest(accessToken);
} }
} }

View File

@ -1,109 +1,109 @@
package org.bench4q.web.tool.test; package org.bench4q.web.tool.test;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.bench4q.share.helper.ExceptionLog; import org.bench4q.share.helper.ExceptionLog;
import org.bench4q.share.models.master.TestPlanResultModel; import org.bench4q.share.models.master.TestPlanResultModel;
import org.bench4q.web.api.TestPlanActionController; import org.bench4q.web.api.TestPlanActionController;
import org.bench4q.web.exception.CustomGenericException; import org.bench4q.web.exception.CustomGenericException;
import org.bench4q.web.model.TestPlanRequestModel; import org.bench4q.web.model.TestPlanRequestModel;
import org.bench4q.web.model.WebScriptModel; import org.bench4q.web.model.WebScriptModel;
import org.bench4q.web.model.WebTestPlanResultModel; import org.bench4q.web.model.WebTestPlanResultModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
@Component @Component
public class TestPlanHelper { public class TestPlanHelper {
public static final String MONITOR_IP = "133.133.12.3"; public static final String MONITOR_IP = "133.133.12.3";
private ScriptHelper scriptHelper; private ScriptHelper scriptHelper;
private TestPlanActionController testPlanActionController; private TestPlanActionController testPlanActionController;
private String testPlanRunId; private String testPlanRunId;
public TestPlanActionController getTestPlanActionController() { public TestPlanActionController getTestPlanActionController() {
return testPlanActionController; return testPlanActionController;
} }
@Autowired @Autowired
public void setTestPlanActionController( public void setTestPlanActionController(
TestPlanActionController testPlanActionController) { TestPlanActionController testPlanActionController) {
this.testPlanActionController = testPlanActionController; this.testPlanActionController = testPlanActionController;
} }
public ScriptHelper getScriptHelper() { public ScriptHelper getScriptHelper() {
return scriptHelper; return scriptHelper;
} }
@Autowired @Autowired
public void setScriptHelper(ScriptHelper scriptHelper) { public void setScriptHelper(ScriptHelper scriptHelper) {
this.scriptHelper = scriptHelper; this.scriptHelper = scriptHelper;
} }
public String getTestPlanRunId() { public String getTestPlanRunId() {
return testPlanRunId; return testPlanRunId;
} }
private void setTestPlanRunId(String testPlanRunId) { private void setTestPlanRunId(String testPlanRunId) {
this.testPlanRunId = testPlanRunId; this.testPlanRunId = testPlanRunId;
} }
public void startTest(String accessToken) { public void startTest(String accessToken) {
try { try {
TestPlanResultModel testPlanResultModel = (TestPlanResultModel) this TestPlanResultModel testPlanResultModel = (TestPlanResultModel) this
.getTestPlanActionController() .getTestPlanActionController()
.runTestPlan(accessToken, new ModelMap(), .runTestPlan(accessToken, new ModelMap(),
createTestPlanWithMonitor(accessToken)).getData(); createTestPlanWithMonitor(accessToken)).getData();
this.setTestPlanRunId(testPlanResultModel.getTestPlanId() this.setTestPlanRunId(testPlanResultModel.getTestPlanId()
.toString()); .toString());
} catch (Exception e) { } catch (Exception e) {
Logger.getLogger(TestPlanHelper.class).info( Logger.getLogger(TestPlanHelper.class).info(
ExceptionLog.getStackTrace(e)); ExceptionLog.getStackTrace(e));
} }
} }
public TestPlanRequestModel createTestPlanWithMonitor(String accessToken) public TestPlanRequestModel createTestPlanWithMonitor(String accessToken)
throws JAXBException, IOException, CustomGenericException { throws JAXBException, IOException, CustomGenericException {
List<String> ipList = new ArrayList<>(); List<String> ipList = new ArrayList<>();
ipList.add(MONITOR_IP); ipList.add(MONITOR_IP);
TestPlanRequestModel testPlanRequestModel = new TestPlanRequestModel(); TestPlanRequestModel testPlanRequestModel = new TestPlanRequestModel();
testPlanRequestModel.setIpList(ipList); testPlanRequestModel.setIpList(ipList);
testPlanRequestModel.setTestPlanName("forTest"); testPlanRequestModel.setTestPlanName("forTest");
testPlanRequestModel testPlanRequestModel
.setScriptList(generateWebScriptModels(accessToken)); .setScriptList(generateWebScriptModels(accessToken));
return testPlanRequestModel; return testPlanRequestModel;
} }
private List<WebScriptModel> generateWebScriptModels(String accessToken) private List<WebScriptModel> generateWebScriptModels(String accessToken)
throws JAXBException, IOException, CustomGenericException { throws JAXBException, IOException, CustomGenericException {
List<WebScriptModel> scriptList = new ArrayList<WebScriptModel>(); List<WebScriptModel> scriptList = new ArrayList<WebScriptModel>();
WebScriptModel webScriptModel = new WebScriptModel(); WebScriptModel webScriptModel = new WebScriptModel();
webScriptModel.setCooldown(1); webScriptModel.setCooldown(1);
webScriptModel.setExecuteRange(50); webScriptModel.setExecuteRange(50);
webScriptModel.setId(this.getScriptHelper() webScriptModel.setId(this.getScriptHelper()
.upLoadScriptAndGetId(accessToken).getId()); .upLoadScriptAndGetId(accessToken).getId());
webScriptModel.setLoad(30); webScriptModel.setLoad(30);
webScriptModel.setWarmup(1); webScriptModel.setWarmup(1);
scriptList.add(webScriptModel); scriptList.add(webScriptModel);
return scriptList; return scriptList;
} }
public void cleanUpTest(String accessToken) throws CustomGenericException { public void cleanUpTest(String accessToken) throws CustomGenericException {
/*this.getScriptHelper().deleteScript(accessToken);*/ /*this.getScriptHelper().deleteScript(accessToken);*/
} }
public WebTestPlanResultModel queryTestPlanResultModel( public WebTestPlanResultModel queryTestPlanResultModel(
String testPlanRunId, String accessToken) String testPlanRunId, String accessToken)
throws CustomGenericException, JAXBException { throws CustomGenericException, JAXBException {
WebTestPlanResultModel webTestPlanResultModel = (WebTestPlanResultModel) this WebTestPlanResultModel webTestPlanResultModel = (WebTestPlanResultModel) this
.getTestPlanActionController() .getTestPlanActionController()
.queryTestPlan(accessToken, testPlanRunId).getData(); .queryTestPlan(accessToken, testPlanRunId).getData();
return webTestPlanResultModel; return webTestPlanResultModel;
} }
} }

View File

@ -1,3 +1,3 @@
Bench4Q Bench4Q
======= =======
A QoS-Oriented E-Commerce Benchmark A QoS-Oriented E-Commerce Benchmark