parent
124a499257
commit
fd20997b24
|
@ -11,7 +11,6 @@ public class GenerateDevices {
|
|||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
Configuration conf = HBaseConfiguration.create();
|
||||
try {
|
||||
System.out.println(conf.get("hbase.zookeeper.quorum"));
|
||||
|
|
|
@ -71,18 +71,6 @@ public class ScriptController extends BaseController {
|
|||
this.portPoolService = portPoolService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/test/{port}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public OperateScriptServerResponseModel testProxyConnection(int port) {
|
||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
return buildReponseModel(false,
|
||||
"has no power for recording script!!!", "", -1, null, null,
|
||||
null);
|
||||
}
|
||||
// TODO:
|
||||
return null;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/startScriptRecordServer", method = {
|
||||
RequestMethod.GET, RequestMethod.POST })
|
||||
@ResponseBody
|
||||
|
|
|
@ -8,7 +8,6 @@ public class MonitorRepository extends AbstractRepositoty {
|
|||
protected void guardOtherUniqueConditionForEntity(
|
||||
String uniquePropertyName, String value)
|
||||
throws EntityUniqueAlReadyExistException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,8 +56,6 @@ public class ExecutionOverTask extends TimerTask {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
// RunningScriptInterface runningScript = this.getRunningScript()
|
||||
// .doForComplete();
|
||||
this.getRunningScript().doForComplete();
|
||||
TestPlanScript testPlanScript = (TestPlanScript) this
|
||||
.getRunningScript();
|
||||
|
|
|
@ -8,11 +8,9 @@ import org.bench4q.master.infrastructure.highavailable.AgentRunBlotter;
|
|||
public class StopAgentFault implements FaultTolerance {
|
||||
|
||||
public StopAgentFault(Agent agent, UUID runId) {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public StopAgentFault(AgentRunBlotter buildAgentRunBlotter) {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public void doTolerance() {
|
||||
|
|
|
@ -53,7 +53,6 @@ public class Test_PluginService extends Test_PluginHelper {
|
|||
assertFalse(this.getPluginService().addPlugin(pluginContent));
|
||||
assertTure(this.getPluginService().deletePlugin(pluginName));
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -69,12 +68,14 @@ public class Test_PluginService extends Test_PluginHelper {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_loadBehaviors(){
|
||||
public void test_loadBehaviors() {
|
||||
addPluginByString();
|
||||
assertEquals(2,this.getPluginService().loadBehaviorInfoModels(pluginName).size());
|
||||
assertEquals(2,
|
||||
this.getPluginService().loadBehaviorInfoModels(pluginName)
|
||||
.size());
|
||||
}
|
||||
|
||||
private void assertTure(boolean deletePlugin) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,27 +1,29 @@
|
|||
package org.bench4q.monitor.model;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
@XmlRootElement(name="PhisicalDisk")
|
||||
|
||||
@XmlRootElement(name = "PhisicalDisk")
|
||||
public class PhysicalDiskModel {
|
||||
private List<PhysicalDiskModelChild> physicalDiskModelList;
|
||||
@XmlElementWrapper
|
||||
@XmlElement(name="Instances",type=PhysicalDiskModelChild.class)
|
||||
private List<PhysicalDiskModelChild> physicalDiskModelList;
|
||||
|
||||
@XmlElementWrapper
|
||||
@XmlElement(name = "Instances", type = PhysicalDiskModelChild.class)
|
||||
public List<PhysicalDiskModelChild> getPhysicalDiskModelList() {
|
||||
return physicalDiskModelList;
|
||||
}
|
||||
|
||||
public void setPhysicalDiskModelList(
|
||||
List<PhysicalDiskModelChild> physicalDiskModelList) {
|
||||
this.physicalDiskModelList = physicalDiskModelList;
|
||||
}
|
||||
public PhysicalDiskModel() {
|
||||
// TODO Auto-generated constructor stub
|
||||
this .physicalDiskModelList=new ArrayList<PhysicalDiskModelChild>();
|
||||
|
||||
public PhysicalDiskModel() {
|
||||
this.physicalDiskModelList = new ArrayList<PhysicalDiskModelChild>();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ public class SystemModel {
|
|||
}
|
||||
|
||||
public void setTotalProceesorTimePercent(double totalProceesorTimePercent2) {
|
||||
// TODO Auto-generated method stub
|
||||
this.totalProceesorTimePercent = totalProceesorTimePercent2;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.bench4q.monitor.model.MemoryModel;
|
|||
public class MemoryMonitor extends LinuxFileRead {
|
||||
// /proc/meminfo
|
||||
private double cacheBytes = 0;
|
||||
|
||||
public double getCacheBytes() {
|
||||
return cacheBytes;
|
||||
}
|
||||
|
@ -62,78 +63,79 @@ public class MemoryMonitor extends LinuxFileRead {
|
|||
|
||||
private double committedBytes = 0;
|
||||
private double availableKiloBytes = 0;
|
||||
|
||||
private double pagesPerSecond=0;//(k)
|
||||
private double pagesInputPerSecond=0;
|
||||
|
||||
private double pagesPerSecond = 0;// (k)
|
||||
private double pagesInputPerSecond = 0;
|
||||
private double pagesOutputPerSecond = 0;
|
||||
|
||||
|
||||
public MemoryMonitor() throws FileNotFoundException {
|
||||
// TODO Auto-generated constructor stub
|
||||
super("/proc/meminfo");
|
||||
}
|
||||
|
||||
public MemoryModel getMemoryInfo(int idleTime) throws IOException{
|
||||
MemoryModel memoryModel=new MemoryModel();
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
String time=new Integer(idleTime/1000).toString();
|
||||
Process p = rt.exec("vmstat "+time+" 2");
|
||||
BufferedReader in=new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||
StringTokenizer token ;
|
||||
String str=in.readLine();
|
||||
str=in.readLine();
|
||||
int si=0,so=0;
|
||||
token=new StringTokenizer(str);
|
||||
for(int i=0;;i++){
|
||||
str=token.nextToken().toLowerCase();
|
||||
if(str.contains("si")) {si=i;}
|
||||
if(str.contains("so")) {so=i;}
|
||||
if(!(token.hasMoreTokens())) break;
|
||||
|
||||
|
||||
}
|
||||
str=in.readLine();
|
||||
str=in.readLine();
|
||||
token=new StringTokenizer(str);
|
||||
for(int i=0;;i++){
|
||||
str=token.nextToken().toLowerCase();
|
||||
if(i==si) pagesInputPerSecond=Integer.parseInt(str);
|
||||
if(i==so) pagesOutputPerSecond=Integer.parseInt(str);
|
||||
if(!(token.hasMoreTokens())) break;
|
||||
}
|
||||
|
||||
pagesPerSecond=pagesInputPerSecond+pagesOutputPerSecond;
|
||||
|
||||
BufferedReader br = this.getBufferedReader();
|
||||
|
||||
|
||||
while ((str = br.readLine()) != null) {
|
||||
public MemoryModel getMemoryInfo(int idleTime) throws IOException {
|
||||
MemoryModel memoryModel = new MemoryModel();
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
String time = new Integer(idleTime / 1000).toString();
|
||||
Process p = rt.exec("vmstat " + time + " 2");
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(
|
||||
p.getInputStream()));
|
||||
StringTokenizer token;
|
||||
String str = in.readLine();
|
||||
str = in.readLine();
|
||||
int si = 0, so = 0;
|
||||
token = new StringTokenizer(str);
|
||||
if (!token.hasMoreTokens())
|
||||
continue;
|
||||
for (int i = 0;; i++) {
|
||||
str = token.nextToken().toLowerCase();
|
||||
if (str.contains("si")) {
|
||||
si = i;
|
||||
}
|
||||
if (str.contains("so")) {
|
||||
so = i;
|
||||
}
|
||||
if (!(token.hasMoreTokens()))
|
||||
break;
|
||||
|
||||
str = token.nextToken();
|
||||
if (!token.hasMoreTokens())
|
||||
continue;
|
||||
|
||||
if (str.equalsIgnoreCase("Cached:"))
|
||||
cacheBytes = Integer.parseInt(token.nextToken())*1024 ;
|
||||
else if (str.equalsIgnoreCase("MemFree:"))
|
||||
availableKiloBytes = Integer.parseInt(token.nextToken());
|
||||
else if (str.equalsIgnoreCase("Committed_AS:"))
|
||||
committedBytes = Integer.parseInt(token.nextToken())*1024;
|
||||
}
|
||||
memoryModel.setAvailableKiloBytes(availableKiloBytes);
|
||||
memoryModel.setCacheBytes(cacheBytes);
|
||||
memoryModel.setCommittedBytes(committedBytes);
|
||||
memoryModel.setPagesInputPerSecond(pagesInputPerSecond);
|
||||
memoryModel.setPagesOutputPerSecond(pagesOutputPerSecond);
|
||||
memoryModel.setPagesPerSecond(pagesPerSecond);
|
||||
return memoryModel;
|
||||
str = in.readLine();
|
||||
str = in.readLine();
|
||||
token = new StringTokenizer(str);
|
||||
for (int i = 0;; i++) {
|
||||
str = token.nextToken().toLowerCase();
|
||||
if (i == si)
|
||||
pagesInputPerSecond = Integer.parseInt(str);
|
||||
if (i == so)
|
||||
pagesOutputPerSecond = Integer.parseInt(str);
|
||||
if (!(token.hasMoreTokens()))
|
||||
break;
|
||||
}
|
||||
|
||||
pagesPerSecond = pagesInputPerSecond + pagesOutputPerSecond;
|
||||
|
||||
BufferedReader br = this.getBufferedReader();
|
||||
|
||||
while ((str = br.readLine()) != null) {
|
||||
token = new StringTokenizer(str);
|
||||
if (!token.hasMoreTokens())
|
||||
continue;
|
||||
|
||||
str = token.nextToken();
|
||||
if (!token.hasMoreTokens())
|
||||
continue;
|
||||
|
||||
if (str.equalsIgnoreCase("Cached:"))
|
||||
cacheBytes = Integer.parseInt(token.nextToken()) * 1024;
|
||||
else if (str.equalsIgnoreCase("MemFree:"))
|
||||
availableKiloBytes = Integer.parseInt(token.nextToken());
|
||||
else if (str.equalsIgnoreCase("Committed_AS:"))
|
||||
committedBytes = Integer.parseInt(token.nextToken()) * 1024;
|
||||
}
|
||||
memoryModel.setAvailableKiloBytes(availableKiloBytes);
|
||||
memoryModel.setCacheBytes(cacheBytes);
|
||||
memoryModel.setCommittedBytes(committedBytes);
|
||||
memoryModel.setPagesInputPerSecond(pagesInputPerSecond);
|
||||
memoryModel.setPagesOutputPerSecond(pagesOutputPerSecond);
|
||||
memoryModel.setPagesPerSecond(pagesPerSecond);
|
||||
return memoryModel;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ public class NetworkInterfaceMonitor extends LinuxFileRead {
|
|||
// /proc/net/dev
|
||||
public NetworkInterfaceMonitor() throws FileNotFoundException {
|
||||
super("/proc/net/dev");
|
||||
// TODO Auto-generated constructor stub
|
||||
bytesTotalPerSecond = new HashMap<String, Double>();
|
||||
bytesReceivedPerSecond = new HashMap<String, Double>();
|
||||
bytesSentPerSecond = new HashMap<String, Double>();
|
||||
|
|
|
@ -19,7 +19,6 @@ public class SystemMonitor extends LinuxFileRead {
|
|||
|
||||
public SystemMonitor() throws FileNotFoundException {
|
||||
super("/proc/stat");
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.bench4q.monitor.performance.linux.ProcessorMonitor;
|
|||
public class ProcessorServiceLinux {
|
||||
|
||||
public ProcessorServiceLinux() throws FileNotFoundException {
|
||||
// TODO Auto-generated constructor stub
|
||||
this.processorMonitor = new ProcessorMonitor();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
|
||||
public class ProcessorServiceWindows {
|
||||
public ProcessorServiceWindows() {
|
||||
// TODO Auto-generated constructor stub
|
||||
this.processorMonitor = new ProcessorMonitor();
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ public class LogicalDiskTest {
|
|||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (JAXBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
|
|
@ -58,8 +58,7 @@ public class MemoryTest {
|
|||
* .extractLogicalDiskModel(httpResponse.getContent());
|
||||
*
|
||||
* memoryTest.result(memoryModel); } catch (IOException e) {
|
||||
* e.printStackTrace(); } catch (JAXBException e) { // TODO Auto-generated
|
||||
* catch block e.printStackTrace(); }
|
||||
* e.printStackTrace(); } catch (JAXBException e) { e.printStackTrace(); }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.springframework.context.ApplicationContext;
|
|||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Component
|
||||
public class ProcessorTest {
|
||||
private HttpRequester httpRequester;
|
||||
private static ApplicationContext atx;
|
||||
|
@ -25,6 +25,7 @@ public class ProcessorTest {
|
|||
public HttpRequester getHttpRequester() {
|
||||
return httpRequester;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setHttpRequester(HttpRequester httpRequester) {
|
||||
this.httpRequester = httpRequester;
|
||||
|
@ -33,42 +34,44 @@ public class ProcessorTest {
|
|||
public static void main(String[] args) {
|
||||
|
||||
String urlString = "http://localhost:5556/Monitor/Processor";
|
||||
atx = new ClassPathXmlApplicationContext("org/Bench4Q/Monitor/Config/application-context.xml");
|
||||
|
||||
ProcessorTest ProcessorTest =(ProcessorTest)atx.getBean("processorTest");
|
||||
|
||||
atx = new ClassPathXmlApplicationContext(
|
||||
"org/Bench4Q/Monitor/Config/application-context.xml");
|
||||
|
||||
ProcessorTest ProcessorTest = (ProcessorTest) atx
|
||||
.getBean("processorTest");
|
||||
|
||||
try {
|
||||
|
||||
|
||||
HttpResponse httpResponse = ProcessorTest.getHttpRequester()
|
||||
.sendGet(urlString, null, null);
|
||||
|
||||
|
||||
ProcessorModel ProcessorModel = ProcessorTest
|
||||
.extractLogicalDiskModel(httpResponse.getContent());
|
||||
|
||||
|
||||
ProcessorTest.result(ProcessorModel);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (JAXBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void result(ProcessorModel ProcessorModel) {
|
||||
|
||||
Iterator<ProcessorModelChild> iterator=ProcessorModel.getProcessorModelList().iterator();
|
||||
while(iterator.hasNext()){
|
||||
ProcessorModelChild processorModelChild=iterator.next();
|
||||
System.out.println("instance"+processorModelChild.getInstance());
|
||||
|
||||
System.out.println("privilegedTimePercent"+processorModelChild.getPrivilegedTimePercent());
|
||||
System.out.println("processorTimePercent"+processorModelChild.getProcessorTimePercent());
|
||||
System.out.println("userTimePercent"+processorModelChild.getUserTimePercent());
|
||||
Iterator<ProcessorModelChild> iterator = ProcessorModel
|
||||
.getProcessorModelList().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ProcessorModelChild processorModelChild = iterator.next();
|
||||
System.out.println("instance" + processorModelChild.getInstance());
|
||||
|
||||
System.out.println("privilegedTimePercent"
|
||||
+ processorModelChild.getPrivilegedTimePercent());
|
||||
System.out.println("processorTimePercent"
|
||||
+ processorModelChild.getProcessorTimePercent());
|
||||
System.out.println("userTimePercent"
|
||||
+ processorModelChild.getUserTimePercent());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -83,5 +86,4 @@ public class ProcessorTest {
|
|||
return resultModel;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -17,11 +17,10 @@ import org.springframework.stereotype.Component;
|
|||
public class HttpRequester {
|
||||
private String defaultContentEncoding;
|
||||
|
||||
public HttpRequester()
|
||||
{
|
||||
public HttpRequester() {
|
||||
this.setDefaultContentEncoding(Charset.defaultCharset().name());
|
||||
}
|
||||
|
||||
|
||||
public String getDefaultContentEncoding() {
|
||||
return defaultContentEncoding;
|
||||
}
|
||||
|
@ -29,27 +28,27 @@ public class HttpRequester {
|
|||
public void setDefaultContentEncoding(String defaultContentEncoding) {
|
||||
this.defaultContentEncoding = defaultContentEncoding;
|
||||
}
|
||||
|
||||
|
||||
public HttpResponse sendPost(String urlString, Map<String, String> params)
|
||||
throws IOException {
|
||||
return this.send(urlString, "POST", params, "", null);
|
||||
}
|
||||
|
||||
public HttpResponse sendPostXml(String urlString, String contentString) throws IOException
|
||||
{
|
||||
|
||||
public HttpResponse sendPostXml(String urlString, String contentString)
|
||||
throws IOException {
|
||||
HashMap<String, String> hashMap = new HashMap<String, String>();
|
||||
hashMap.put("Content-Type", "application/xml");
|
||||
return this.send(urlString, "POST", null, contentString, hashMap);
|
||||
}
|
||||
|
||||
|
||||
public HttpResponse sendGet(String urlString, Map<String, String> params,
|
||||
Map<String, String> properties) throws IOException {
|
||||
return this.send(urlString, "GET", params, "", properties);
|
||||
}
|
||||
|
||||
private HttpResponse send(String urlString, String method,
|
||||
Map<String, String> parameters, String Content, Map<String, String> propertys)
|
||||
throws IOException {
|
||||
Map<String, String> parameters, String Content,
|
||||
Map<String, String> propertys) throws IOException {
|
||||
HttpURLConnection urlConnection = null;
|
||||
|
||||
if (method.equalsIgnoreCase("GET") && parameters != null) {
|
||||
|
@ -69,7 +68,7 @@ public class HttpRequester {
|
|||
if (!urlString.startsWith("http://")) {
|
||||
urlString = "http://" + urlString;
|
||||
}
|
||||
//urlString = URLEncoder.encode(urlString, "UTF-8");
|
||||
// urlString = URLEncoder.encode(urlString, "UTF-8");
|
||||
URL url = new URL(urlString);
|
||||
urlConnection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
|
@ -92,8 +91,7 @@ public class HttpRequester {
|
|||
urlConnection.getOutputStream().write(param.toString().getBytes());
|
||||
urlConnection.getOutputStream().flush();
|
||||
urlConnection.getOutputStream().close();
|
||||
}
|
||||
else if (method.equalsIgnoreCase("POST") && !Content.isEmpty()) {
|
||||
} else if (method.equalsIgnoreCase("POST") && !Content.isEmpty()) {
|
||||
urlConnection.getOutputStream().write(Content.getBytes());
|
||||
urlConnection.getOutputStream().flush();
|
||||
urlConnection.getOutputStream().close();
|
||||
|
@ -104,7 +102,6 @@ public class HttpRequester {
|
|||
|
||||
private HttpResponse makeContent(String urlString,
|
||||
HttpURLConnection urlConnection) {
|
||||
// TODO Auto-generated method stub
|
||||
HttpResponse httpResponser = new HttpResponse();
|
||||
try {
|
||||
InputStream in = urlConnection.getInputStream();
|
||||
|
|
|
@ -28,7 +28,6 @@ public class ProcessResponseModel implements MonitorResultBase {
|
|||
}
|
||||
|
||||
public void add(SampleModel model) {
|
||||
// TODO Auto-generated method stub
|
||||
if (model instanceof ProcessModel) {
|
||||
this.getProcessModels().add((ProcessModel) model);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.SessionAttributes;
|
|||
@SessionAttributes({ "accessToken", "username", "testPlanTaskList" })
|
||||
public class AuthorizeActionController extends BaseControllerService {
|
||||
private Logger logger = Logger.getLogger(AuthorizeActionController.class);
|
||||
private String baseUrl = this.masterIp+"user";
|
||||
private String baseUrl = this.masterIp + "user";
|
||||
private String INVALIDATE_INPUT = "invalidate input";
|
||||
|
||||
@RequestMapping("login")
|
||||
|
@ -74,13 +74,12 @@ public class AuthorizeActionController extends BaseControllerService {
|
|||
httpResponse.getContent());
|
||||
return extractRegisterModel(registerResponseModel);
|
||||
} catch (IOException e) {
|
||||
logger.info(e,e.fillInStackTrace());
|
||||
logger.info(e, e.fillInStackTrace());
|
||||
throw new CustomGenericException("1",
|
||||
"invalidate httpresponse:io exception", this.baseUrl
|
||||
+ "/register");
|
||||
} catch (JAXBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
logger.info(e,e.fillInStackTrace());
|
||||
logger.info(e, e.fillInStackTrace());
|
||||
throw new CustomGenericException("1",
|
||||
"invalidate httpresponse:JAXBException", this.baseUrl
|
||||
+ "/register");
|
||||
|
@ -97,20 +96,19 @@ public class AuthorizeActionController extends BaseControllerService {
|
|||
HttpResponse httpResponse = this.getHttpRequester().sendGet(url,
|
||||
params, null);
|
||||
if (HttpRequester.isInvalidResponse(httpResponse)) {
|
||||
throw new CustomGenericException("1",
|
||||
"network error:",
|
||||
throw new CustomGenericException("1", "network error:",
|
||||
"AuthorizeActionController_authorize");
|
||||
}
|
||||
|
||||
return (AuthorizeResponseModel) ObjectXmlExchange.fromXml(
|
||||
AuthorizeResponseModel.class, httpResponse.getContent());
|
||||
} catch (IOException e) {
|
||||
logger.info(e,e.fillInStackTrace());
|
||||
logger.info(e, e.fillInStackTrace());
|
||||
throw new CustomGenericException("1",
|
||||
"invalidate httpResponse:IOException",
|
||||
"AuthorizeActionController_authorize");
|
||||
} catch (JAXBException e) {
|
||||
logger.info(e,e.fillInStackTrace());
|
||||
logger.info(e, e.fillInStackTrace());
|
||||
throw new CustomGenericException("1",
|
||||
"invalidate httpResponse:JAXBException",
|
||||
"AuthorizeActionController_authorize");
|
||||
|
|
|
@ -31,14 +31,18 @@ import org.springframework.web.bind.annotation.SessionAttributes;
|
|||
@Controller
|
||||
@SessionAttributes({ "accessToken", "testPlanTaskList" })
|
||||
public class TestPlanHistoryResult extends BaseControllerService {
|
||||
private String baseUrl = CommunicateWithMaster.getMasterAddress()+"testPlan";
|
||||
private String baseUrl = CommunicateWithMaster.getMasterAddress()
|
||||
+ "testPlan";
|
||||
private TestPlanService testPlanService;
|
||||
private CommunicateWithMaster communicateWithMaster;
|
||||
|
||||
private CommunicateWithMaster getCommunicateWithMaster() {
|
||||
return communicateWithMaster;
|
||||
}
|
||||
@Autowired
|
||||
private void setCommunicateWithMaster(CommunicateWithMaster communicateWithMaster) {
|
||||
|
||||
@Autowired
|
||||
private void setCommunicateWithMaster(
|
||||
CommunicateWithMaster communicateWithMaster) {
|
||||
this.communicateWithMaster = communicateWithMaster;
|
||||
}
|
||||
|
||||
|
@ -62,22 +66,23 @@ public class TestPlanHistoryResult extends BaseControllerService {
|
|||
@RequestMapping(value = "loadTestPlans", method = { RequestMethod.GET,
|
||||
RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public BaseResponseModel
|
||||
loadTestPlans(
|
||||
public BaseResponseModel loadTestPlans(
|
||||
@ModelAttribute("accessToken") String accessToken)
|
||||
throws CustomGenericException {
|
||||
String caller = "TestPlanHistoryResult:loadTestPlans";
|
||||
String url = "testPlan"+ "/loadTestPlans";
|
||||
String url = "testPlan" + "/loadTestPlans";
|
||||
TestPlanResponseModel testPlanResponseModel = (TestPlanResponseModel) this
|
||||
.getTestPlanService()
|
||||
.getCommunicateWithMaster()
|
||||
.getResponseModel(accessToken, url,
|
||||
TestPlanResponseModel.class, null, caller);
|
||||
if (testPlanResponseModel.isSuccess()) {
|
||||
return new BaseResponseModel(true,buildTestPlanListModel(testPlanResponseModel
|
||||
.getTestPlanDBModels()));
|
||||
return new BaseResponseModel(true,
|
||||
buildTestPlanListModel(testPlanResponseModel
|
||||
.getTestPlanDBModels()));
|
||||
} else {
|
||||
return new BaseResponseModel(false,testPlanResponseModel.getFailCause());
|
||||
return new BaseResponseModel(false,
|
||||
testPlanResponseModel.getFailCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,28 +94,32 @@ public class TestPlanHistoryResult extends BaseControllerService {
|
|||
|
||||
@RequestMapping(value = "downloadReport", method = { RequestMethod.GET,
|
||||
RequestMethod.POST })
|
||||
public BaseResponseModel downloadReport(HttpServletResponse response,
|
||||
public BaseResponseModel downloadReport(HttpServletResponse response,
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@RequestParam String testPlanId) throws CustomGenericException {
|
||||
String caller="TestPlanHistory:downloadReport";
|
||||
String caller = "TestPlanHistory:downloadReport";
|
||||
try {
|
||||
HttpResponse httpResponse = this.getHttpRequester().sendGet(
|
||||
this.getBaseUrl() + "/getTestPlanReport",
|
||||
makeParamsMap("testPlanRunID", testPlanId),
|
||||
this.makeAccessTockenMap(accessToken));
|
||||
if (httpResponse == null ) {
|
||||
|
||||
throw new CustomGenericException("1", "invalidate http response", caller);
|
||||
if (httpResponse == null) {
|
||||
|
||||
throw new CustomGenericException("1",
|
||||
"invalidate http response", caller);
|
||||
}
|
||||
if(httpResponse.getContent().isEmpty())
|
||||
throw new CustomGenericException("5", "report data empty","");
|
||||
/*if(httpResponse.getContent().isEmpty())
|
||||
throw new CustomGenericException(errCode, errMsg, source)*/
|
||||
if (httpResponse.getContent().isEmpty())
|
||||
throw new CustomGenericException("5", "report data empty", "");
|
||||
/*
|
||||
* if(httpResponse.getContent().isEmpty()) throw new
|
||||
* CustomGenericException(errCode, errMsg, source)
|
||||
*/
|
||||
if (httpResponse.getCode() == HttpStatus.BAD_REQUEST_400) {
|
||||
ErrorResponseModel errorResponseModel = (ErrorResponseModel) ObjectXmlExchange
|
||||
.fromXml(ErrorResponseModel.class,
|
||||
httpResponse.getContent());
|
||||
this.getCommunicateWithMaster().logException(errorResponseModel);
|
||||
this.getCommunicateWithMaster()
|
||||
.logException(errorResponseModel);
|
||||
throw new CustomGenericException("2", FAIL_WITH_EXCEPTION + "_"
|
||||
+ errorResponseModel.getMessage(), caller + "_"
|
||||
+ errorResponseModel.getResource());
|
||||
|
@ -127,17 +136,18 @@ public class TestPlanHistoryResult extends BaseControllerService {
|
|||
outputStream.close();
|
||||
return new BaseResponseModel(true);
|
||||
} catch (IOException e) {
|
||||
throw new CustomGenericException("1", "exception:io exception", caller);
|
||||
throw new CustomGenericException("1", "exception:io exception",
|
||||
caller);
|
||||
} catch (JAXBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
throw new CustomGenericException("1", "exception:io exception", caller);
|
||||
throw new CustomGenericException("1", "exception:io exception",
|
||||
caller);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "deleteTest", method = { RequestMethod.GET,
|
||||
RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public BaseResponseModel deleteTest(HttpServletResponse response,
|
||||
public BaseResponseModel deleteTest(HttpServletResponse response,
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@RequestParam String testPlanId) throws CustomGenericException {
|
||||
String url = "testPlan" + "/removeTestPlanFromPool";
|
||||
|
@ -149,13 +159,14 @@ public class TestPlanHistoryResult extends BaseControllerService {
|
|||
.getCommunicateWithMaster()
|
||||
.getResponseModel(accessToken, url,
|
||||
TestPlanResponseModel.class, params, caller);
|
||||
|
||||
|
||||
if (testPlanResponseModel.isSuccess()) {
|
||||
|
||||
return new BaseResponseModel(true);
|
||||
} else {
|
||||
|
||||
return new BaseResponseModel(false,testPlanResponseModel.getFailCause());
|
||||
|
||||
return new BaseResponseModel(false,
|
||||
testPlanResponseModel.getFailCause());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ public class TestPlanService extends BaseService {
|
|||
}
|
||||
|
||||
public TestPlanService() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public ResultInfoModel getScriptBriefStatusResultInfo() {
|
||||
|
@ -194,12 +193,12 @@ public class TestPlanService extends BaseService {
|
|||
List<BehaviorStatusCodeResultModel> behaviorStatusCodeResultModels = new ArrayList<BehaviorStatusCodeResultModel>();
|
||||
if (scriptBehaviorsBriefModel == null)
|
||||
return behaviorStatusCodeResultModels;
|
||||
if(scriptBehaviorsBriefModel.getTestBehaviorsBriefModel()==null)
|
||||
if (scriptBehaviorsBriefModel.getTestBehaviorsBriefModel() == null)
|
||||
return behaviorStatusCodeResultModels;
|
||||
if(scriptBehaviorsBriefModel
|
||||
.getTestBehaviorsBriefModel().getBehaviorBriefModels()==null)
|
||||
scriptBehaviorsBriefModel
|
||||
.getTestBehaviorsBriefModel().getBehaviorBriefModels();
|
||||
if (scriptBehaviorsBriefModel.getTestBehaviorsBriefModel()
|
||||
.getBehaviorBriefModels() == null)
|
||||
scriptBehaviorsBriefModel.getTestBehaviorsBriefModel()
|
||||
.getBehaviorBriefModels();
|
||||
for (BehaviorBriefModel behaviorBriefModel : scriptBehaviorsBriefModel
|
||||
.getTestBehaviorsBriefModel().getBehaviorBriefModels()) {
|
||||
|
||||
|
|
|
@ -29,19 +29,17 @@ public class AuthorizeActionControllerTest {
|
|||
|
||||
@Test
|
||||
public void loginTest() throws CustomGenericException {
|
||||
// right
|
||||
this.user.setUserName("www");
|
||||
this.user.setPassword("www");
|
||||
|
||||
Assert.assertTrue(this.authorizeActionController.login(user,
|
||||
modelMap)
|
||||
.isSuccess());
|
||||
|
||||
this.user.setUserName("www");
|
||||
this.user.setPassword("123");
|
||||
Assert.assertFalse(this.authorizeActionController.login(user,
|
||||
modelMap)
|
||||
.isSuccess());
|
||||
// right
|
||||
this.user.setUserName("www");
|
||||
this.user.setPassword("www");
|
||||
|
||||
Assert.assertTrue(this.authorizeActionController.login(user, modelMap)
|
||||
.isSuccess());
|
||||
|
||||
this.user.setUserName("www");
|
||||
this.user.setPassword("123");
|
||||
Assert.assertFalse(this.authorizeActionController.login(user, modelMap)
|
||||
.isSuccess());
|
||||
|
||||
}
|
||||
|
||||
|
@ -59,7 +57,6 @@ public class AuthorizeActionControllerTest {
|
|||
Assert.assertFalse(this.authorizeActionController.adminLogin(null,
|
||||
modelMap).isSuccess());
|
||||
} catch (CustomGenericException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,12 +178,10 @@ public class TestScriptResultTest extends LoginHelper {
|
|||
.queryTestPlanResultModel(testPlanRunId, accessToken)
|
||||
.getScriptIds().get(0).toString();
|
||||
} catch (CustomGenericException e) {
|
||||
// TODO Auto-generated catch block
|
||||
logger.info(ExceptionLog.getStackTrace(e));
|
||||
return null;
|
||||
|
||||
} catch (JAXBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
logger.info(ExceptionLog.getStackTrace(e));
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue