From fd20997b247dcffcd0b3dbb7cab705059a116110 Mon Sep 17 00:00:00 2001 From: coderfengyun Date: Thu, 17 Apr 2014 15:40:24 +0800 Subject: [PATCH] remove those unused tasks remove those unused tasks --- .../plugin/basic/hbase/GenerateDevices.java | 1 - .../bench4q/master/api/ScriptController.java | 12 -- .../domain/repository/MonitorRepository.java | 1 - .../schedulscript/ExecutionOverTask.java | 2 - .../faultolerence/StopAgentFault.java | 2 - .../test/service/Test_PluginService.java | 9 +- .../monitor/model/PhysicalDiskModel.java | 20 +-- .../bench4q/monitor/model/SystemModel.java | 1 - .../performance/linux/MemoryMonitor.java | 132 +++++++++--------- .../linux/NetworkInterfaceMonitor.java | 1 - .../performance/linux/SystemMonitor.java | 1 - .../service/linux/ProcessorServiceLinux.java | 1 - .../windows/ProcessorServiceWindows.java | 1 - .../bench4q/monitor/test/LogicalDiskTest.java | 1 - .../org/bench4q/monitor/test/MemoryTest.java | 3 +- .../bench4q/monitor/test/ProcessorTest.java | 46 +++--- .../test/communication/HttpRequester.java | 25 ++-- .../models/master/ProcessResponseModel.java | 1 - .../web/api/AuthorizeActionController.java | 14 +- .../web/api/TestPlanHistoryResult.java | 63 +++++---- .../bench4q/web/service/TestPlanService.java | 11 +- .../test/AuthorizeActionControllerTest.java | 25 ++-- .../web/api/test/TestScriptResultTest.java | 2 - 23 files changed, 178 insertions(+), 197 deletions(-) diff --git a/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/hbase/GenerateDevices.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/hbase/GenerateDevices.java index 79ec5c62..b8f963ed 100644 --- a/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/hbase/GenerateDevices.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/hbase/GenerateDevices.java @@ -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")); diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/api/ScriptController.java b/Bench4Q-Master/src/main/java/org/bench4q/master/api/ScriptController.java index 05273574..46281045 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/api/ScriptController.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/api/ScriptController.java @@ -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 diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/MonitorRepository.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/MonitorRepository.java index 8175646e..8eee65d5 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/MonitorRepository.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/MonitorRepository.java @@ -8,7 +8,6 @@ public class MonitorRepository extends AbstractRepositoty { protected void guardOtherUniqueConditionForEntity( String uniquePropertyName, String value) throws EntityUniqueAlReadyExistException { - // TODO Auto-generated method stub } } diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/valueobject/schedulscript/ExecutionOverTask.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/valueobject/schedulscript/ExecutionOverTask.java index 05b3838e..62542552 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/valueobject/schedulscript/ExecutionOverTask.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/valueobject/schedulscript/ExecutionOverTask.java @@ -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(); diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/highavailable/faultolerence/StopAgentFault.java b/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/highavailable/faultolerence/StopAgentFault.java index 3e08d100..1b489bad 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/highavailable/faultolerence/StopAgentFault.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/highavailable/faultolerence/StopAgentFault.java @@ -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() { diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_PluginService.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_PluginService.java index 9c492a9f..3a61252e 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_PluginService.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_PluginService.java @@ -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 } diff --git a/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java index 6f2520a5..65b0151c 100644 --- a/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java @@ -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 physicalDiskModelList; - @XmlElementWrapper - @XmlElement(name="Instances",type=PhysicalDiskModelChild.class) + private List physicalDiskModelList; + + @XmlElementWrapper + @XmlElement(name = "Instances", type = PhysicalDiskModelChild.class) public List getPhysicalDiskModelList() { return physicalDiskModelList; } + public void setPhysicalDiskModelList( List physicalDiskModelList) { this.physicalDiskModelList = physicalDiskModelList; } - public PhysicalDiskModel() { - // TODO Auto-generated constructor stub - this .physicalDiskModelList=new ArrayList(); + + public PhysicalDiskModel() { + this.physicalDiskModelList = new ArrayList(); } - + } diff --git a/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/SystemModel.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/SystemModel.java index f4adb423..8ae5d796 100644 --- a/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/SystemModel.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/model/SystemModel.java @@ -32,7 +32,6 @@ public class SystemModel { } public void setTotalProceesorTimePercent(double totalProceesorTimePercent2) { - // TODO Auto-generated method stub this.totalProceesorTimePercent = totalProceesorTimePercent2; } diff --git a/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/MemoryMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/MemoryMonitor.java index 0b11e946..9bfe1149 100644 --- a/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/MemoryMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/MemoryMonitor.java @@ -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; } - + } - - - - - diff --git a/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/NetworkInterfaceMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/NetworkInterfaceMonitor.java index 12f7de78..dee88341 100644 --- a/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/NetworkInterfaceMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/NetworkInterfaceMonitor.java @@ -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(); bytesReceivedPerSecond = new HashMap(); bytesSentPerSecond = new HashMap(); diff --git a/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/SystemMonitor.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/SystemMonitor.java index 333611b4..6cce5d9d 100644 --- a/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/SystemMonitor.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/performance/linux/SystemMonitor.java @@ -19,7 +19,6 @@ public class SystemMonitor extends LinuxFileRead { public SystemMonitor() throws FileNotFoundException { super("/proc/stat"); - // TODO Auto-generated constructor stub } diff --git a/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/ProcessorServiceLinux.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/ProcessorServiceLinux.java index f84885c4..bd7cc9bd 100644 --- a/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/ProcessorServiceLinux.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/linux/ProcessorServiceLinux.java @@ -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(); } diff --git a/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java index 0d0e17ad..35dd7124 100644 --- a/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java +++ b/Bench4Q-Monitor/src/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java @@ -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(); } diff --git a/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/LogicalDiskTest.java b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/LogicalDiskTest.java index b06882c4..1f9bcd7e 100644 --- a/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/LogicalDiskTest.java +++ b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/LogicalDiskTest.java @@ -51,7 +51,6 @@ public class LogicalDiskTest { } catch (IOException e) { e.printStackTrace(); } catch (JAXBException e) { - // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/MemoryTest.java b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/MemoryTest.java index 29852d10..9dfd75b4 100644 --- a/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/MemoryTest.java +++ b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/MemoryTest.java @@ -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(); } * * } */ diff --git a/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/ProcessorTest.java b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/ProcessorTest.java index 73218792..a7c4ac42 100644 --- a/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/ProcessorTest.java +++ b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/ProcessorTest.java @@ -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 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 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; } - } diff --git a/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/communication/HttpRequester.java b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/communication/HttpRequester.java index c6a2f389..93749b3e 100644 --- a/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/communication/HttpRequester.java +++ b/Bench4Q-Monitor/src/test/java/org/bench4q/monitor/test/communication/HttpRequester.java @@ -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 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 hashMap = new HashMap(); hashMap.put("Content-Type", "application/xml"); return this.send(urlString, "POST", null, contentString, hashMap); } - + public HttpResponse sendGet(String urlString, Map params, Map properties) throws IOException { return this.send(urlString, "GET", params, "", properties); } private HttpResponse send(String urlString, String method, - Map parameters, String Content, Map propertys) - throws IOException { + Map parameters, String Content, + Map 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(); diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/ProcessResponseModel.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/ProcessResponseModel.java index 1d9cae37..84dc8401 100644 --- a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/ProcessResponseModel.java +++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/ProcessResponseModel.java @@ -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); } diff --git a/Bench4Q-Web/src/main/java/org/bench4q/web/api/AuthorizeActionController.java b/Bench4Q-Web/src/main/java/org/bench4q/web/api/AuthorizeActionController.java index 2dd211c6..7c43088f 100644 --- a/Bench4Q-Web/src/main/java/org/bench4q/web/api/AuthorizeActionController.java +++ b/Bench4Q-Web/src/main/java/org/bench4q/web/api/AuthorizeActionController.java @@ -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"); diff --git a/Bench4Q-Web/src/main/java/org/bench4q/web/api/TestPlanHistoryResult.java b/Bench4Q-Web/src/main/java/org/bench4q/web/api/TestPlanHistoryResult.java index d58eb10c..bcdb7110 100644 --- a/Bench4Q-Web/src/main/java/org/bench4q/web/api/TestPlanHistoryResult.java +++ b/Bench4Q-Web/src/main/java/org/bench4q/web/api/TestPlanHistoryResult.java @@ -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()); } } diff --git a/Bench4Q-Web/src/main/java/org/bench4q/web/service/TestPlanService.java b/Bench4Q-Web/src/main/java/org/bench4q/web/service/TestPlanService.java index 7387072a..08ff71e5 100644 --- a/Bench4Q-Web/src/main/java/org/bench4q/web/service/TestPlanService.java +++ b/Bench4Q-Web/src/main/java/org/bench4q/web/service/TestPlanService.java @@ -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 behaviorStatusCodeResultModels = new ArrayList(); 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()) { diff --git a/Bench4Q-Web/src/test/java/org/bench4q/web/api/test/AuthorizeActionControllerTest.java b/Bench4Q-Web/src/test/java/org/bench4q/web/api/test/AuthorizeActionControllerTest.java index fa21ce54..3b286b80 100644 --- a/Bench4Q-Web/src/test/java/org/bench4q/web/api/test/AuthorizeActionControllerTest.java +++ b/Bench4Q-Web/src/test/java/org/bench4q/web/api/test/AuthorizeActionControllerTest.java @@ -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(); } } diff --git a/Bench4Q-Web/src/test/java/org/bench4q/web/api/test/TestScriptResultTest.java b/Bench4Q-Web/src/test/java/org/bench4q/web/api/test/TestScriptResultTest.java index 4960e480..8f04b244 100644 --- a/Bench4Q-Web/src/test/java/org/bench4q/web/api/test/TestScriptResultTest.java +++ b/Bench4Q-Web/src/test/java/org/bench4q/web/api/test/TestScriptResultTest.java @@ -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; }