parent
eda9f6c279
commit
cbc19f8207
|
@ -232,7 +232,7 @@ public class HttpPlugin extends ParameterBarn {
|
|||
long contentLength = 0;
|
||||
String contentType = "";
|
||||
try {
|
||||
System.out.println(method.getURI().toString());
|
||||
// System.out.println(method.getURI().toString());
|
||||
responseCode = this.getHttpClient().executeMethod(method);
|
||||
method.getStatusLine().toString();
|
||||
Header[] responseHeaders = method.getResponseHeaders();
|
||||
|
|
|
@ -6,12 +6,18 @@ import java.util.Stack;
|
|||
import org.bench4q.agent.datacollector.DataCollector;
|
||||
import org.bench4q.agent.scenario.instruction.Instruction;
|
||||
import org.bench4q.agent.scenario.instruction.TestInstruction;
|
||||
import org.bench4q.share.models.agent.scriptrecord.ConditionBehaviorModel;
|
||||
import org.bench4q.share.exception.Bench4QRunTimeException;
|
||||
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
|
||||
import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
|
||||
|
||||
public class ConditionBehavior extends PluginImplementBehavior {
|
||||
|
||||
public ConditionBehavior(ConditionBehaviorModel condition) {
|
||||
public ConditionBehavior(BehaviorModel condition) {
|
||||
if (!condition.getType().equalsIgnoreCase(TEST_BEHAVIOR)) {
|
||||
throw new Bench4QRunTimeException(
|
||||
"Expected type is TEST_BEHAVIOR, but is "
|
||||
+ condition.getType());
|
||||
}
|
||||
buildAndGenerateParameterPart(condition);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,19 @@ package org.bench4q.agent.test.model;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlElements;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
|
||||
import org.bench4q.share.models.agent.scriptrecord.IfBehaviorModel;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
@ -27,4 +34,21 @@ public class ModelTest {
|
|||
assertTrue(object instanceof BehaviorModel);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarshalInheritence() {
|
||||
Container batchModel = new Container();
|
||||
batchModel.behaviorModels.add(new IfBehaviorModel());
|
||||
batchModel.behaviorModels.add(new BehaviorModel());
|
||||
System.out.println(MarshalHelper.tryMarshal(batchModel));
|
||||
}
|
||||
|
||||
@XmlRootElement
|
||||
private static class Container {
|
||||
@XmlElementWrapper(name = "behaviorModels")
|
||||
@XmlElements({
|
||||
@XmlElement(name = "behavior", type = BehaviorModel.class),
|
||||
@XmlElement(name = "ifBehavior", type = IfBehaviorModel.class) })
|
||||
private List<BehaviorModel> behaviorModels = new ArrayList<BehaviorModel>();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,11 +83,12 @@ public class Test_Behavior {
|
|||
|
||||
@Test
|
||||
public void testCompileIfBehavior2Instruction() {
|
||||
// TODO:
|
||||
List<BehaviorModel> elseBehaviors = new ArrayList<BehaviorModel>(), thenBehaviors = new ArrayList<BehaviorModel>();
|
||||
// Behavior behavior =
|
||||
// Behavior.buildWith(BehaviorModel.IfBehaviorBuilder(
|
||||
// BehaviorModel.testBehaviorBuilder(1, "isDefined", "context",
|
||||
// Arrays.asList(ParameterModel.createParameter("name",
|
||||
// "a"))), thenBehaviors, elseBehaviors));
|
||||
Behavior behavior = Behavior.buildWith(BehaviorModel.IfBehaviorBuilder(
|
||||
BehaviorModel.testBehaviorBuilder(1, "isDefined", "context",
|
||||
Arrays.asList(ParameterModel.createParameter("name",
|
||||
"a"))), thenBehaviors, elseBehaviors));
|
||||
assertNotNull(behavior);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html; charset=GBK"><script type='text/javascript'>document.domain='baidu.com';</script></head><body></body><script>try{parent.bdcallback({"CNYBA.fx":{na:"美元人民币",pc:"6.1400",op:"0.0000",la:"6.1403",hi:"6.1411",lo:"6.1360",bp1:"6.1418",ap1:"6.1403",zde:"0.0003",zdf:"0.00",type:"4",time:"2014-09-19 16:31:55"},"HKCNBA.fx":{na:"港元人民币",pc:"0.7922",op:"0.0000",la:"0.7921",hi:"0.7923",lo:"0.7916",bp1:"0.7924",ap1:"0.7921",zde:"-0.0001",zdf:"-0.01",type:"4",time:"2014-09-19 17:15:40"},"ERCNBA.fx":{na:"欧元人民币",pc:"7.9341",op:"0.0000",la:"7.9099",hi:"7.9356",lo:"7.8995",bp1:"7.9131",ap1:"7.9099",zde:"-0.0242",zdf:"-0.31",type:"4",time:"2014-09-19 17:17:09"},"UKCNBA.fx":{na:"英镑人民币",pc:"10.0696",op:"0.0000",la:"10.0590",hi:"10.1469",lo:"10.0406",bp1:"10.0640",ap1:"10.0590",zde:"-0.0106",zdf:"-0.11",type:"4",time:"2014-09-19 17:17:08"},"USDJPY.fx":{na:"美元日元",pc:"108.7800",op:"108.8000",la:"108.8200",hi:"109.4500",lo:"108.7600",bp1:"108.8200",ap1:"108.8400",zde:"0.0400",zdf:"0.04",type:"1",time:"2014-09-19 17:18:58"},"EURUSD.fx":{na:"欧元美元",pc:"1.2917",op:"1.2917",la:"1.2884",hi:"1.2928",lo:"1.2866",bp1:"1.2884",ap1:"1.2885",zde:"-0.0033",zdf:"-0.26",type:"1",time:"2014-09-19 17:18:57"},"GBPUSD.fx":{na:"英镑美元",pc:"1.6427",op:"1.6438",la:"1.6382",hi:"1.6523",lo:"1.6353",bp1:"1.6382",ap1:"1.6386",zde:"-0.0045",zdf:"-0.27",type:"1",time:"2014-09-19 17:18:57"},"tofnow":{time:"2014-09-19 17:24:08"}})}catch(e){}</script></html
|
|
@ -0,0 +1,17 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Bench4Q Test Case</title>
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
<link href="style/bootstrap-classic.css" />
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
</head>
|
||||
<body>
|
||||
<img src="images/1.jpg" alt="No this one" />
|
||||
<img src="images/2.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/base.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
</html
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlElements;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "batch")
|
||||
|
@ -42,6 +43,9 @@ public class BatchModel {
|
|||
}
|
||||
|
||||
@XmlElementWrapper(name = "behaviors")
|
||||
// @XmlElements({
|
||||
// @XmlElement(name = "behaviorModel", type = BehaviorModel.class),
|
||||
// @XmlElement(name = "ifBehaviorModel", type = IfBehaviorModel.class) })
|
||||
@XmlElement(name = "behaviorModel")
|
||||
public List<BehaviorModel> getBehaviors() {
|
||||
return behaviors;
|
||||
|
@ -50,12 +54,13 @@ public class BatchModel {
|
|||
public void setBehaviors(List<BehaviorModel> behaviors) {
|
||||
this.behaviors = behaviors;
|
||||
}
|
||||
|
||||
public BatchModel(int id){
|
||||
|
||||
public BatchModel(int id) {
|
||||
this.id = id;
|
||||
this.behaviors = new ArrayList<BehaviorModel>();
|
||||
}
|
||||
public BatchModel(){
|
||||
|
||||
|
||||
public BatchModel() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,8 +108,9 @@ public class BehaviorModel {
|
|||
}
|
||||
|
||||
public static BehaviorModel IfBehaviorBuilder(
|
||||
BehaviorModel testBehaviorBuilder) {
|
||||
// TODo:
|
||||
BehaviorModel testBehaviorBuilder,
|
||||
List<BehaviorModel> thenBehaviors, List<BehaviorModel> elseBehaviors) {
|
||||
// TODO:
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,18 +6,18 @@ import javax.xml.bind.annotation.XmlElement;
|
|||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
@XmlRootElement(name = "ifBehaviorModel")
|
||||
public class IfBehaviorModel extends BehaviorModel {
|
||||
private ConditionBehaviorModel condition;
|
||||
private BehaviorModel condition;
|
||||
private List<BehaviorModel> thenBehaviors;
|
||||
private List<BehaviorModel> elseBehaviors;
|
||||
|
||||
@XmlElement
|
||||
public ConditionBehaviorModel getCondition() {
|
||||
public BehaviorModel getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public void setCondition(ConditionBehaviorModel condition) {
|
||||
public void setCondition(BehaviorModel condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package org.bench4q.share.models.agent.scriptrecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.bench4q.share.models.agent.ParameterModel;
|
||||
|
||||
@XmlRootElement
|
||||
public class PluginedBehaviorModel extends BehaviorModel {
|
||||
private String use;
|
||||
private String name;
|
||||
private String type;
|
||||
private List<ParameterModel> parameters;
|
||||
|
||||
@XmlElement
|
||||
public String getUse() {
|
||||
return use;
|
||||
}
|
||||
|
||||
public void setUse(String use) {
|
||||
this.use = use;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name = "parameters")
|
||||
@XmlElement(name = "parameter")
|
||||
public List<ParameterModel> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters(List<ParameterModel> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
@XmlRootElement
|
||||
public static class UserBehaviorModel extends PluginedBehaviorModel {
|
||||
}
|
||||
|
||||
@XmlRootElement
|
||||
public static class TimerBehaviorModel extends PluginedBehaviorModel {
|
||||
}
|
||||
|
||||
@XmlRootElement
|
||||
public static class ControlBehaviorModel extends PluginedBehaviorModel {
|
||||
}
|
||||
|
||||
@XmlRootElement
|
||||
public static class ConditionBehaviorModel extends PluginedBehaviorModel {
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
package org.bench4q.web.test.masterMessager;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.AgentModel;
|
||||
import org.bench4q.share.models.master.AgentResponseModel;
|
||||
import org.bench4q.web.masterMessager.AgentManagerMessager;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" })
|
||||
public class AgentManagerMessagerTest extends MessagerTestBase {
|
||||
private AgentManagerMessager agentManagerMessager;
|
||||
private String baseUrl = "/agentManage";
|
||||
|
||||
public AgentManagerMessager getAgentManagerMessager() {
|
||||
return agentManagerMessager;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setAgentManagerMessager(
|
||||
AgentManagerMessager agentManagerMessager) {
|
||||
this.agentManagerMessager = agentManagerMessager;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
startServer();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void clear() {
|
||||
stopServer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_addAgent() {
|
||||
String url = baseUrl + "/addAgentToPool";
|
||||
|
||||
this.getWireMock().register(
|
||||
post(urlEqualTo(url))
|
||||
.withRequestBody(
|
||||
equalToXml(MarshalHelper
|
||||
.tryMarshal(createAgentModel())))
|
||||
.willReturn(
|
||||
aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type",
|
||||
"application/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.agentManagerMessager.addAgent(null,
|
||||
MarshalHelper.tryMarshal(createAgentModel())));
|
||||
}
|
||||
|
||||
private AgentModel createAgentModel() {
|
||||
AgentModel agentModel = new AgentModel();
|
||||
agentModel.setMaxLoad(500);
|
||||
agentModel.setPort(6565);
|
||||
return agentModel;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_deleteAgent() {
|
||||
String url = baseUrl + "/removeAgentFromPool?hostName=&agentId=";
|
||||
this.getWireMock().register(
|
||||
get(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.agentManagerMessager.deleteAgent(null, "", ""));
|
||||
assertTrue(this.agentManagerMessager.deleteAgent(null, "", "")
|
||||
.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_loadAgents() {
|
||||
String url = baseUrl + "/queryAgentList";
|
||||
this.getWireMock().register(
|
||||
get(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.agentManagerMessager.loadAgents(null));
|
||||
assertTrue(this.agentManagerMessager.loadAgents(null).isSuccess());
|
||||
}
|
||||
|
||||
private String createResponse() {
|
||||
AgentResponseModel agentResponseModel = new AgentResponseModel();
|
||||
agentResponseModel.setSuccess(true);
|
||||
return MarshalHelper.tryMarshal(agentResponseModel);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package org.bench4q.web.test.masterMessager;
|
||||
|
||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
||||
import com.github.tomakehurst.wiremock.client.WireMock;
|
||||
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
|
||||
|
||||
public abstract class MessagerTestBase {
|
||||
private static WireMockServer wireMockServer;
|
||||
private static WireMock wireMock;
|
||||
private static final int port = 6000;
|
||||
|
||||
protected static void startServer() {
|
||||
WireMockConfiguration wmc = new WireMockConfiguration();
|
||||
wmc.bindAddress("localhost");
|
||||
wmc.port(port);
|
||||
wireMockServer = new WireMockServer(wmc);
|
||||
wireMockServer.start();
|
||||
wireMock = new WireMock("localhost", port);
|
||||
}
|
||||
|
||||
protected static void stopServer() {
|
||||
wireMockServer.stop();
|
||||
}
|
||||
|
||||
public WireMock getWireMock() {
|
||||
return wireMock;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
//package org.bench4q.web.test.masterMessager;
|
||||
//
|
||||
//import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
//
|
||||
//import static org.junit.Assert.*;
|
||||
//
|
||||
//import org.bench4q.share.helper.MarshalHelper;
|
||||
//import org.bench4q.share.models.master.MonitorMemoryResponseModel;
|
||||
//import org.bench4q.share.models.master.MonitorProcessorResponseModel;
|
||||
//import org.bench4q.web.masterMessager.MonitorMessager;
|
||||
//
|
||||
//import org.junit.AfterClass;
|
||||
//import org.junit.BeforeClass;
|
||||
//import org.junit.Test;
|
||||
//import org.junit.runner.RunWith;
|
||||
//
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.test.context.ContextConfiguration;
|
||||
//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
//
|
||||
//@RunWith(SpringJUnit4ClassRunner.class)
|
||||
//@ContextConfiguration("file:src/test/resources/bench4qweb-servlet.xml")
|
||||
//public class MonitorMessageTest extends MessagerTestBase {
|
||||
// private MonitorMessager monitorMessager;
|
||||
// private String baseUrl = "/monitorController";
|
||||
//
|
||||
// public MonitorMessager getMonitorMessager() {
|
||||
// return monitorMessager;
|
||||
// }
|
||||
//
|
||||
// @Autowired
|
||||
// public void setMonitorMessager(MonitorMessager monitorMessager) {
|
||||
// this.monitorMessager = monitorMessager;
|
||||
// }
|
||||
//
|
||||
// @BeforeClass
|
||||
// public static void setUp() {
|
||||
// startServer();
|
||||
// }
|
||||
//
|
||||
// @AfterClass
|
||||
// public static void clear() {
|
||||
// stopServer();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_memory() {
|
||||
// String url = baseUrl + "/memorySUTInfo";
|
||||
// MonitorMemoryResponseModel monitorMemoryResponseModel = new MonitorMemoryResponseModel();
|
||||
// String response = MarshalHelper.tryMarshal(monitorMemoryResponseModel);
|
||||
// this.getWireMock().register(
|
||||
// post(urlEqualTo(url))
|
||||
// .withRequestBody(containing("testPlanId"))
|
||||
// .withRequestBody(containing("hostName"))
|
||||
// .withRequestBody(containing("port"))
|
||||
// .withRequestBody(containing("duationBegin"))
|
||||
// .willReturn(
|
||||
// aResponse().withStatus(200)
|
||||
// .withHeader("Content-Type", "text/xml")
|
||||
// .withBody(response)));
|
||||
// assertNotNull(this.monitorMessager.memory(null, "", "", "", ""));
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_porcessor() {
|
||||
// String url = baseUrl + "/processorSUTInfo";
|
||||
// MonitorProcessorResponseModel monitorProcessorResponseModel = new MonitorProcessorResponseModel();
|
||||
// String response = MarshalHelper
|
||||
// .tryMarshal(monitorProcessorResponseModel);
|
||||
// this.getWireMock().register(
|
||||
// post(urlEqualTo(url))
|
||||
// .withRequestBody(containing("testPlanId"))
|
||||
// .withRequestBody(containing("hostName"))
|
||||
// .withRequestBody(containing("port"))
|
||||
// .withRequestBody(containing("duationBegin"))
|
||||
// .willReturn(
|
||||
// aResponse().withStatus(200)
|
||||
// .withHeader("Content-Type", "text/xml")
|
||||
// .withBody(response)));
|
||||
// assertNotNull(this.monitorMessager.porcessor(null, "", "", "", ""));
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -1,29 +0,0 @@
|
|||
package org.bench4q.web.test.masterMessager;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class ParamInfoModel_Test {
|
||||
private String label;
|
||||
private String name;
|
||||
|
||||
@XmlElement
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLable(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
package org.bench4q.web.test.masterMessager;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.plugin.PluginResponseModel;
|
||||
import org.bench4q.web.masterMessager.PluginMessager;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("file:src/test/resources/bench4qweb-servlet.xml")
|
||||
public class PluginMessageTest extends MessagerTestBase {
|
||||
private String pluginName = "pluginName";
|
||||
private PluginMessager pluginMessager;
|
||||
private String baseUrl = "/plugin";
|
||||
|
||||
public PluginMessager getPluginMessager() {
|
||||
return pluginMessager;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setPluginMessager(PluginMessager pluginMessager) {
|
||||
this.pluginMessager = pluginMessager;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
startServer();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void clear() {
|
||||
stopServer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_loadPluginUIModels() {
|
||||
String url = baseUrl + "/loadPluginList";
|
||||
this.getWireMock().register(
|
||||
get(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.pluginMessager.loadPluginUIModels(null));
|
||||
assertTrue(this.pluginMessager.loadPluginUIModels(null).isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_loadPluginNameList() {
|
||||
String url = baseUrl + "/loadPluginNameList";
|
||||
this.getWireMock().register(
|
||||
get(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.pluginMessager.loadPluginNameList(null));
|
||||
assertTrue(this.pluginMessager.loadPluginNameList(null).isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getPluginInfoModel() {
|
||||
String url = baseUrl + "/getPlugin/" + pluginName;
|
||||
this.getWireMock().register(
|
||||
get(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.pluginMessager.getPluginInfoModel(null, pluginName));
|
||||
assertTrue(this.pluginMessager.getPluginInfoModel(null, pluginName)
|
||||
.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_loadBehaviors() {
|
||||
String url = baseUrl + "/loadBehaviors/" + pluginName;
|
||||
this.getWireMock().register(
|
||||
get(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.pluginMessager.loadBehaviors(null, pluginName));
|
||||
assertTrue(this.pluginMessager.loadBehaviors(null, pluginName)
|
||||
.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_addPlugin() {
|
||||
String url = baseUrl + "/addPlugin";
|
||||
this.getWireMock().register(
|
||||
put(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.pluginMessager.addPlugin(null, ""));
|
||||
assertTrue(this.pluginMessager.addPlugin(null, "").isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_deletePlugin() {
|
||||
String url = baseUrl + "/deletePlugin/" + pluginName;
|
||||
this.getWireMock().register(
|
||||
get(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.pluginMessager.deletePlugin(null, pluginName));
|
||||
assertTrue(this.pluginMessager.deletePlugin(null, pluginName)
|
||||
.isSuccess());
|
||||
}
|
||||
|
||||
public String createResponse() {
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
pluginResponseModel.setSuccess(true);
|
||||
return MarshalHelper.tryMarshal(pluginResponseModel);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
package org.bench4q.web.test.masterMessager;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.OrganizeRecordPortResponseModel;
|
||||
import org.bench4q.web.masterMessager.RecordPortMessager;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" })
|
||||
public class PortMessageTest extends MessagerTestBase {
|
||||
|
||||
private RecordPortMessager recordPortMessager;
|
||||
|
||||
public RecordPortMessager getRecordPortMessager() {
|
||||
return recordPortMessager;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setRecordPortMessager(RecordPortMessager recordPortMessager) {
|
||||
this.recordPortMessager = recordPortMessager;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
|
||||
startServer();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void shutDowm() {
|
||||
stopServer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_addPort() throws IOException, JAXBException {
|
||||
|
||||
this.getWireMock().register(post(urlEqualTo("/RecordPort/addPortToPortPool"))
|
||||
.withRequestBody(containing("port")).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
OrganizeRecordPortResponseModel responseModel = recordPortMessager
|
||||
.addPort(null, "8090");
|
||||
assertNotNull(responseModel);
|
||||
assertTrue(responseModel.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_deletePort() throws JAXBException {
|
||||
this.getWireMock().register(post(urlEqualTo("/RecordPort/removePortFromPool"))
|
||||
.withRequestBody(containing("port")).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
OrganizeRecordPortResponseModel responseModel = recordPortMessager
|
||||
.deletePort(null, "8090");
|
||||
assertNotNull(responseModel);
|
||||
assertTrue(responseModel.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_loadPorts() throws JAXBException {
|
||||
this.getWireMock().register(post(urlEqualTo("/RecordPort/loadPortList"))
|
||||
.willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
OrganizeRecordPortResponseModel responseModel = recordPortMessager
|
||||
.loadPorts(null);
|
||||
assertNotNull(responseModel);
|
||||
assertTrue(responseModel.isSuccess());
|
||||
assertNotNull(responseModel.getPortModels());
|
||||
}
|
||||
|
||||
private String createResponse() throws JAXBException {
|
||||
OrganizeRecordPortResponseModel organizeRecordPortResponseModel = new OrganizeRecordPortResponseModel();
|
||||
organizeRecordPortResponseModel.setSuccess(true);
|
||||
|
||||
String response = MarshalHelper.marshal(
|
||||
OrganizeRecordPortResponseModel.class,
|
||||
organizeRecordPortResponseModel);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,197 +0,0 @@
|
|||
package org.bench4q.web.test.masterMessager;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.containing;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.post;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.OperateScriptServerResponseModel;
|
||||
import org.bench4q.share.models.master.ScriptModel;
|
||||
import org.bench4q.web.masterMessager.ScriptMessager;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "file:src/test/resources/bench4qweb-servlet.xml" })
|
||||
public class ScriptMessagerTest extends MessagerTestBase {
|
||||
private ScriptMessager scriptMessager;
|
||||
private String port = "8090";
|
||||
private String baseUrl = "/script";
|
||||
|
||||
public ScriptMessager getScriptMessager() {
|
||||
return scriptMessager;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setScriptMessager(ScriptMessager scriptMessager) {
|
||||
this.scriptMessager = scriptMessager;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
startServer();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void clear() {
|
||||
stopServer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_StartScriptRecordPort() {
|
||||
|
||||
String url = this.baseUrl + "/startScriptRecordServer";
|
||||
this.getWireMock().register(
|
||||
post(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.getScriptMessager().startScriptRecordServer(null));
|
||||
assertTrue(this.getScriptMessager().startScriptRecordServer(null)
|
||||
.isSuccess());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_stopScriptRecordServer() {
|
||||
String url = this.baseUrl + "/stopScriptRecordServer";
|
||||
this.getWireMock().register(
|
||||
post(urlEqualTo(url))
|
||||
.withRequestBody(containing("port"))
|
||||
.withRequestBody(containing("fileNameUUID"))
|
||||
.willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
|
||||
assertNotNull(this.getScriptMessager().stopScriptRecordServer(null,
|
||||
port, ""));
|
||||
assertTrue(this.getScriptMessager()
|
||||
.stopScriptRecordServer(null, port, "").isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_saveScriptRecorded() {
|
||||
String url = this.baseUrl + "/saveScriptToDB";
|
||||
this.getWireMock().register(
|
||||
post(urlEqualTo(url))
|
||||
.withRequestBody(containing("scriptName"))
|
||||
.withRequestBody(containing("port"))
|
||||
.withRequestBody(containing("fileNameUUID"))
|
||||
.willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.getScriptMessager().saveScriptRecorded(null, "",
|
||||
port, ""));
|
||||
assertTrue(this.getScriptMessager()
|
||||
.saveScriptRecorded(null, "", port, "").isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_uploadScript() {
|
||||
String scriptName = "scriptName";
|
||||
String url = this.baseUrl + "/uploadScript/" + scriptName;
|
||||
this.getWireMock().register(
|
||||
post(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.getScriptMessager().uploadScript(null, scriptName,
|
||||
"", null));
|
||||
assertTrue(this.getScriptMessager()
|
||||
.uploadScript(null, scriptName, "", null).isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_deleteScript() {
|
||||
String url = this.baseUrl + "/deleteScript";
|
||||
this.getWireMock().register(
|
||||
post(urlEqualTo(url)).withRequestBody(containing("scriptId"))
|
||||
.willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.getScriptMessager().deleteScript(null, ""));
|
||||
assertTrue(this.getScriptMessager().deleteScript(null, "").isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_updateScript() {
|
||||
String scriptId = UUID.randomUUID().toString();
|
||||
String url = this.baseUrl + "/updateScript/" + scriptId;
|
||||
this.getWireMock().register(
|
||||
post(urlEqualTo(url)).withRequestBody(containing("content"))
|
||||
.willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.getScriptMessager().updateScript(null, scriptId, "",null));
|
||||
assertTrue(this.getScriptMessager().updateScript(null, scriptId, "",null)
|
||||
.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_loadScript() {
|
||||
String url = this.baseUrl + "/loadScriptList";
|
||||
this.getWireMock().register(
|
||||
post(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.getScriptMessager().loadScripts(null));
|
||||
assertTrue(this.getScriptMessager().loadScripts(null).isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_queryScriptById() {
|
||||
String url = this.baseUrl + "/queryScriptById";
|
||||
this.getWireMock().register(
|
||||
post(urlEqualTo(url)).withRequestBody(containing("scriptId"))
|
||||
.willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.getScriptMessager().queryScriptById(null, ""));
|
||||
assertTrue(this.getScriptMessager().queryScriptById(null, "")
|
||||
.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_queryScriptByName() {
|
||||
String url = this.baseUrl + "/queryScriptByName";
|
||||
this.getWireMock().register(
|
||||
post(urlEqualTo(url)).withRequestBody(containing("name"))
|
||||
.willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.getScriptMessager().queryScriptByName(null, ""));
|
||||
assertTrue(this.getScriptMessager().queryScriptByName(null, "")
|
||||
.isSuccess());
|
||||
}
|
||||
|
||||
private String createResponse() {
|
||||
ScriptModel scriptModel=new ScriptModel();
|
||||
List<ScriptModel> list=new ArrayList<ScriptModel>();
|
||||
list.add(scriptModel);
|
||||
OperateScriptServerResponseModel operateScriptServerResponseModel = new OperateScriptServerResponseModel();
|
||||
operateScriptServerResponseModel.setSuccess(true);
|
||||
operateScriptServerResponseModel.setScriptModels(list);
|
||||
return MarshalHelper.tryMarshal(operateScriptServerResponseModel);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,176 +0,0 @@
|
|||
package org.bench4q.web.test.masterMessager;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.TestPlanResponseModel;
|
||||
import org.bench4q.share.models.master.TestPlanResultModel;
|
||||
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
|
||||
import org.bench4q.web.masterMessager.TestPlanMessager;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("file:src/test/resources/bench4qweb-servlet.xml")
|
||||
public class TestPlanMessageTest extends MessagerTestBase {
|
||||
private TestPlanMessager testPlanMessager;
|
||||
private String baseUrl = "/testPlan";
|
||||
private String testPlanId = "testPlanId";
|
||||
private String scriptId = "scriptId";
|
||||
|
||||
public TestPlanMessager getTestPlanMessager() {
|
||||
return testPlanMessager;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setTestPlanMessager(TestPlanMessager testPlanMessager) {
|
||||
this.testPlanMessager = testPlanMessager;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
startServer();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void clear() {
|
||||
stopServer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_runTestPlan() {
|
||||
String url = baseUrl + "/run";
|
||||
this.getWireMock().register(
|
||||
post(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.testPlanMessager.runTestPlan(null, ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getRunningTestInfo() {
|
||||
String url = baseUrl + "/getRunningInfo";
|
||||
this.getWireMock().register(
|
||||
post(urlEqualTo(url)).withRequestBody(containing("testPlanId"))
|
||||
.willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.testPlanMessager.getRunningTestInfo(null, ""));
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void test_getScriptBriefResult() {
|
||||
// TestPlanScriptBriefResultModel testPlanScriptBriefResultModel = new
|
||||
// TestPlanScriptBriefResultModel();
|
||||
// String response = MarshalHelper
|
||||
// .tryMarshal(testPlanScriptBriefResultModel);
|
||||
// String url = baseUrl + '/' + testPlanId + '/' + scriptId + '/'
|
||||
// + duationBegin;
|
||||
// System.out.println(url);
|
||||
// this.getWireMock().register(
|
||||
// get(urlEqualTo(url)).willReturn(
|
||||
// aResponse().withStatus(200)
|
||||
// .withHeader("Content-Type", "text/xml")
|
||||
// .withBody(response)));
|
||||
// assertNotNull(this.testPlanMessager.getScriptBriefResult(null,
|
||||
// testPlanId, scriptId, duationBegin));
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void test_getScriptBehaviorsBriefResult() {
|
||||
ScriptBehaviorsBriefModel scriptBehaviorsBriefModel = new ScriptBehaviorsBriefModel();
|
||||
scriptBehaviorsBriefModel.setFinished(true);
|
||||
String response = MarshalHelper.tryMarshal(scriptBehaviorsBriefModel);
|
||||
String url = baseUrl +"/getBehaviorsBrief"+ '/' + testPlanId + '/' + scriptId;
|
||||
this.getWireMock().register(
|
||||
get(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(response)));
|
||||
assertNotNull(this.testPlanMessager.getScriptBehaviorsBriefResult(null,
|
||||
testPlanId, scriptId));
|
||||
assertTrue(this.testPlanMessager.getScriptBehaviorsBriefResult(null,
|
||||
testPlanId, scriptId).isFinished());
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void test_getPageBriefResult() {
|
||||
// ScriptPagesBriefModel scriptPagesBriefModel = new ScriptPagesBriefModel();
|
||||
// String response = MarshalHelper.tryMarshal(scriptPagesBriefModel);
|
||||
// String url = baseUrl + '/' + testPlanId + '/' + scriptId;
|
||||
// this.getWireMock().register(
|
||||
// get(urlEqualTo(url)).willReturn(
|
||||
// aResponse().withStatus(200)
|
||||
// .withHeader("Content-Type", "text/xml")
|
||||
// .withBody(response)));
|
||||
// assertNotNull(this.testPlanMessager.getPageBriefResult(null,
|
||||
// testPlanId, scriptId));
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void test_queryTestPlanById() {
|
||||
// String testPlanRunId = "testPlanRunId";
|
||||
// String url = baseUrl + "/queryTestPlan/" + testPlanRunId;
|
||||
// this.getWireMock().register(
|
||||
// get(urlEqualTo(url)).willReturn(
|
||||
// aResponse().withStatus(200)
|
||||
// .withHeader("Content-Type", "text/xml")
|
||||
// .withBody(this.createResponse())));
|
||||
// assertNotNull(this.testPlanMessager.queryTestPlanById(null,
|
||||
// testPlanRunId));
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void test_deleteTestPlan() {
|
||||
TestPlanResponseModel testPlanResponseModel = new TestPlanResponseModel();
|
||||
testPlanResponseModel.setSuccess(true);
|
||||
String response = MarshalHelper.tryMarshal(testPlanResponseModel);
|
||||
String url = baseUrl + "/removeTestPlanFromPool";
|
||||
this.getWireMock().register(
|
||||
post(urlEqualTo(url)).withRequestBody(containing("testPlanId"))
|
||||
.willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(response)));
|
||||
assertNotNull(this.testPlanMessager.deleteTestPlan(null, testPlanId));
|
||||
assertTrue(this.testPlanMessager.deleteTestPlan(null, testPlanId)
|
||||
.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_loadTestPlans() {
|
||||
String url = baseUrl + "/loadTestPlans";
|
||||
TestPlanResponseModel testPlanResponseModel = new TestPlanResponseModel();
|
||||
testPlanResponseModel.setSuccess(true);
|
||||
String response = MarshalHelper.tryMarshal(testPlanResponseModel);
|
||||
this.getWireMock().register(
|
||||
post(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(response)));
|
||||
assertNotNull(this.testPlanMessager.loadTestPlans(null));
|
||||
assertTrue(this.testPlanMessager.loadTestPlans(null).isSuccess());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getTestPlanReport() {
|
||||
|
||||
}
|
||||
|
||||
public String createResponse() {
|
||||
TestPlanResultModel testPlanResultModel = new TestPlanResultModel();
|
||||
return MarshalHelper.tryMarshal(testPlanResultModel);
|
||||
}
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
package org.bench4q.web.test.masterMessager;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.AuthorizeResponseModel;
|
||||
import org.bench4q.share.models.master.RegisterResponseModel;
|
||||
|
||||
import org.bench4q.web.masterMessager.UserMessager;
|
||||
import org.junit.AfterClass;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("file:src/test/resources/bench4qweb-servlet.xml")
|
||||
public class UserMessageTest extends MessagerTestBase {
|
||||
private UserMessager userMessager;
|
||||
private String baseUrl = "/user";
|
||||
|
||||
public UserMessager getUserMessager() {
|
||||
return userMessager;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setUserMessager(UserMessager userMessager) {
|
||||
this.userMessager = userMessager;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
startServer();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void clear() {
|
||||
stopServer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_register() {
|
||||
String url = baseUrl + "/register?scope=&userName=&password=";
|
||||
RegisterResponseModel registerResponseModel = new RegisterResponseModel();
|
||||
registerResponseModel.setSuccess(true);
|
||||
String response = MarshalHelper.tryMarshal(registerResponseModel);
|
||||
this.getWireMock().register(
|
||||
get(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(response)));
|
||||
assertNotNull(this.userMessager.register("", "", ""));
|
||||
assertTrue(this.userMessager.register("", "", "").isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_adminLogin() {
|
||||
String url = baseUrl + "/adminAuthorize?userName=&password=";
|
||||
this.getWireMock().register(
|
||||
get(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.userMessager.adminLogin("", ""));
|
||||
assertTrue(this.userMessager.adminLogin("", "").isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_normalLogin() {
|
||||
String url = baseUrl + "/normalAuthorize?userName=&password=";
|
||||
this.getWireMock().register(
|
||||
get(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.userMessager.normalLogin("", ""));
|
||||
assertTrue(this.userMessager.normalLogin("", "").isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_deleteUser() {
|
||||
String userName = "userName";
|
||||
String url = baseUrl + "/deleteUser/" + userName;
|
||||
this.getWireMock().register(
|
||||
get(urlEqualTo(url)).willReturn(
|
||||
aResponse().withStatus(200)
|
||||
.withHeader("Content-Type", "text/xml")
|
||||
.withBody(this.createResponse())));
|
||||
assertNotNull(this.userMessager.deleteUser(userName));
|
||||
assertTrue(this.userMessager.deleteUser(userName).isSuccess());
|
||||
}
|
||||
|
||||
public String createResponse() {
|
||||
AuthorizeResponseModel authorizeResponseModel = new AuthorizeResponseModel();
|
||||
authorizeResponseModel.setSuccess(true);
|
||||
return MarshalHelper.tryMarshal(authorizeResponseModel);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue