remove those unused tasks

remove those unused tasks
This commit is contained in:
coderfengyun 2014-04-17 15:40:24 +08:00
parent 124a499257
commit fd20997b24
23 changed files with 178 additions and 197 deletions

View File

@ -11,7 +11,6 @@ public class GenerateDevices {
* @param args * @param args
*/ */
public static void main(String[] args) { public static void main(String[] args) {
// TODO Auto-generated method stub
Configuration conf = HBaseConfiguration.create(); Configuration conf = HBaseConfiguration.create();
try { try {
System.out.println(conf.get("hbase.zookeeper.quorum")); System.out.println(conf.get("hbase.zookeeper.quorum"));

View File

@ -71,18 +71,6 @@ public class ScriptController extends BaseController {
this.portPoolService = portPoolService; 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 = { @RequestMapping(value = "/startScriptRecordServer", method = {
RequestMethod.GET, RequestMethod.POST }) RequestMethod.GET, RequestMethod.POST })
@ResponseBody @ResponseBody

View File

@ -8,7 +8,6 @@ public class MonitorRepository extends AbstractRepositoty {
protected void guardOtherUniqueConditionForEntity( protected void guardOtherUniqueConditionForEntity(
String uniquePropertyName, String value) String uniquePropertyName, String value)
throws EntityUniqueAlReadyExistException { throws EntityUniqueAlReadyExistException {
// TODO Auto-generated method stub
} }
} }

View File

@ -56,8 +56,6 @@ public class ExecutionOverTask extends TimerTask {
@Override @Override
public void run() { public void run() {
// RunningScriptInterface runningScript = this.getRunningScript()
// .doForComplete();
this.getRunningScript().doForComplete(); this.getRunningScript().doForComplete();
TestPlanScript testPlanScript = (TestPlanScript) this TestPlanScript testPlanScript = (TestPlanScript) this
.getRunningScript(); .getRunningScript();

View File

@ -8,11 +8,9 @@ import org.bench4q.master.infrastructure.highavailable.AgentRunBlotter;
public class StopAgentFault implements FaultTolerance { public class StopAgentFault implements FaultTolerance {
public StopAgentFault(Agent agent, UUID runId) { public StopAgentFault(Agent agent, UUID runId) {
// TODO Auto-generated constructor stub
} }
public StopAgentFault(AgentRunBlotter buildAgentRunBlotter) { public StopAgentFault(AgentRunBlotter buildAgentRunBlotter) {
// TODO Auto-generated constructor stub
} }
public void doTolerance() { public void doTolerance() {

View File

@ -53,7 +53,6 @@ public class Test_PluginService extends Test_PluginHelper {
assertFalse(this.getPluginService().addPlugin(pluginContent)); assertFalse(this.getPluginService().addPlugin(pluginContent));
assertTure(this.getPluginService().deletePlugin(pluginName)); assertTure(this.getPluginService().deletePlugin(pluginName));
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
@ -69,12 +68,14 @@ public class Test_PluginService extends Test_PluginHelper {
} }
@Test @Test
public void test_loadBehaviors(){ public void test_loadBehaviors() {
addPluginByString(); addPluginByString();
assertEquals(2,this.getPluginService().loadBehaviorInfoModels(pluginName).size()); assertEquals(2,
this.getPluginService().loadBehaviorInfoModels(pluginName)
.size());
} }
private void assertTure(boolean deletePlugin) { private void assertTure(boolean deletePlugin) {
// TODO Auto-generated method stub
} }

View File

@ -1,27 +1,29 @@
package org.bench4q.monitor.model; package org.bench4q.monitor.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="PhisicalDisk")
@XmlRootElement(name = "PhisicalDisk")
public class PhysicalDiskModel { public class PhysicalDiskModel {
private List<PhysicalDiskModelChild> physicalDiskModelList; private List<PhysicalDiskModelChild> physicalDiskModelList;
@XmlElementWrapper
@XmlElement(name="Instances",type=PhysicalDiskModelChild.class) @XmlElementWrapper
@XmlElement(name = "Instances", type = PhysicalDiskModelChild.class)
public List<PhysicalDiskModelChild> getPhysicalDiskModelList() { public List<PhysicalDiskModelChild> getPhysicalDiskModelList() {
return physicalDiskModelList; return physicalDiskModelList;
} }
public void setPhysicalDiskModelList( public void setPhysicalDiskModelList(
List<PhysicalDiskModelChild> physicalDiskModelList) { List<PhysicalDiskModelChild> physicalDiskModelList) {
this.physicalDiskModelList = physicalDiskModelList; this.physicalDiskModelList = physicalDiskModelList;
} }
public PhysicalDiskModel() {
// TODO Auto-generated constructor stub public PhysicalDiskModel() {
this .physicalDiskModelList=new ArrayList<PhysicalDiskModelChild>(); this.physicalDiskModelList = new ArrayList<PhysicalDiskModelChild>();
} }
} }

View File

@ -32,7 +32,6 @@ public class SystemModel {
} }
public void setTotalProceesorTimePercent(double totalProceesorTimePercent2) { public void setTotalProceesorTimePercent(double totalProceesorTimePercent2) {
// TODO Auto-generated method stub
this.totalProceesorTimePercent = totalProceesorTimePercent2; this.totalProceesorTimePercent = totalProceesorTimePercent2;
} }

View File

@ -12,6 +12,7 @@ import org.bench4q.monitor.model.MemoryModel;
public class MemoryMonitor extends LinuxFileRead { public class MemoryMonitor extends LinuxFileRead {
// /proc/meminfo // /proc/meminfo
private double cacheBytes = 0; private double cacheBytes = 0;
public double getCacheBytes() { public double getCacheBytes() {
return cacheBytes; return cacheBytes;
} }
@ -62,78 +63,79 @@ public class MemoryMonitor extends LinuxFileRead {
private double committedBytes = 0; private double committedBytes = 0;
private double availableKiloBytes = 0; private double availableKiloBytes = 0;
private double pagesPerSecond=0;//(k) private double pagesPerSecond = 0;// (k)
private double pagesInputPerSecond=0; private double pagesInputPerSecond = 0;
private double pagesOutputPerSecond = 0; private double pagesOutputPerSecond = 0;
public MemoryMonitor() throws FileNotFoundException { public MemoryMonitor() throws FileNotFoundException {
// TODO Auto-generated constructor stub
super("/proc/meminfo"); super("/proc/meminfo");
} }
public MemoryModel getMemoryInfo(int idleTime) throws IOException{ public MemoryModel getMemoryInfo(int idleTime) throws IOException {
MemoryModel memoryModel=new MemoryModel(); MemoryModel memoryModel = new MemoryModel();
Runtime rt = Runtime.getRuntime(); Runtime rt = Runtime.getRuntime();
String time=new Integer(idleTime/1000).toString(); String time = new Integer(idleTime / 1000).toString();
Process p = rt.exec("vmstat "+time+" 2"); Process p = rt.exec("vmstat " + time + " 2");
BufferedReader in=new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader in = new BufferedReader(new InputStreamReader(
StringTokenizer token ; p.getInputStream()));
String str=in.readLine(); StringTokenizer token;
str=in.readLine(); String str = in.readLine();
int si=0,so=0; str = in.readLine();
token=new StringTokenizer(str); int si = 0, so = 0;
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) {
token = new StringTokenizer(str); token = new StringTokenizer(str);
if (!token.hasMoreTokens()) for (int i = 0;; i++) {
continue; 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); str = in.readLine();
memoryModel.setCacheBytes(cacheBytes); str = in.readLine();
memoryModel.setCommittedBytes(committedBytes); token = new StringTokenizer(str);
memoryModel.setPagesInputPerSecond(pagesInputPerSecond); for (int i = 0;; i++) {
memoryModel.setPagesOutputPerSecond(pagesOutputPerSecond); str = token.nextToken().toLowerCase();
memoryModel.setPagesPerSecond(pagesPerSecond); if (i == si)
return memoryModel; 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;
} }
} }

View File

@ -21,7 +21,6 @@ public class NetworkInterfaceMonitor extends LinuxFileRead {
// /proc/net/dev // /proc/net/dev
public NetworkInterfaceMonitor() throws FileNotFoundException { public NetworkInterfaceMonitor() throws FileNotFoundException {
super("/proc/net/dev"); super("/proc/net/dev");
// TODO Auto-generated constructor stub
bytesTotalPerSecond = new HashMap<String, Double>(); bytesTotalPerSecond = new HashMap<String, Double>();
bytesReceivedPerSecond = new HashMap<String, Double>(); bytesReceivedPerSecond = new HashMap<String, Double>();
bytesSentPerSecond = new HashMap<String, Double>(); bytesSentPerSecond = new HashMap<String, Double>();

View File

@ -19,7 +19,6 @@ public class SystemMonitor extends LinuxFileRead {
public SystemMonitor() throws FileNotFoundException { public SystemMonitor() throws FileNotFoundException {
super("/proc/stat"); super("/proc/stat");
// TODO Auto-generated constructor stub
} }

View File

@ -9,7 +9,6 @@ import org.bench4q.monitor.performance.linux.ProcessorMonitor;
public class ProcessorServiceLinux { public class ProcessorServiceLinux {
public ProcessorServiceLinux() throws FileNotFoundException { public ProcessorServiceLinux() throws FileNotFoundException {
// TODO Auto-generated constructor stub
this.processorMonitor = new ProcessorMonitor(); this.processorMonitor = new ProcessorMonitor();
} }

View File

@ -7,7 +7,6 @@ import org.springframework.beans.factory.annotation.Autowired;
public class ProcessorServiceWindows { public class ProcessorServiceWindows {
public ProcessorServiceWindows() { public ProcessorServiceWindows() {
// TODO Auto-generated constructor stub
this.processorMonitor = new ProcessorMonitor(); this.processorMonitor = new ProcessorMonitor();
} }

View File

@ -51,7 +51,6 @@ public class LogicalDiskTest {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (JAXBException e) { } catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -58,8 +58,7 @@ public class MemoryTest {
* .extractLogicalDiskModel(httpResponse.getContent()); * .extractLogicalDiskModel(httpResponse.getContent());
* *
* memoryTest.result(memoryModel); } catch (IOException e) { * memoryTest.result(memoryModel); } catch (IOException e) {
* e.printStackTrace(); } catch (JAXBException e) { // TODO Auto-generated * e.printStackTrace(); } catch (JAXBException e) { e.printStackTrace(); }
* catch block e.printStackTrace(); }
* *
* } * }
*/ */

View File

@ -17,7 +17,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
public class ProcessorTest { public class ProcessorTest {
private HttpRequester httpRequester; private HttpRequester httpRequester;
private static ApplicationContext atx; private static ApplicationContext atx;
@ -25,6 +25,7 @@ public class ProcessorTest {
public HttpRequester getHttpRequester() { public HttpRequester getHttpRequester() {
return httpRequester; return httpRequester;
} }
@Autowired @Autowired
public void setHttpRequester(HttpRequester httpRequester) { public void setHttpRequester(HttpRequester httpRequester) {
this.httpRequester = httpRequester; this.httpRequester = httpRequester;
@ -33,42 +34,44 @@ public class ProcessorTest {
public static void main(String[] args) { public static void main(String[] args) {
String urlString = "http://localhost:5556/Monitor/Processor"; String urlString = "http://localhost:5556/Monitor/Processor";
atx = new ClassPathXmlApplicationContext("org/Bench4Q/Monitor/Config/application-context.xml"); atx = new ClassPathXmlApplicationContext(
"org/Bench4Q/Monitor/Config/application-context.xml");
ProcessorTest ProcessorTest =(ProcessorTest)atx.getBean("processorTest");
ProcessorTest ProcessorTest = (ProcessorTest) atx
.getBean("processorTest");
try { try {
HttpResponse httpResponse = ProcessorTest.getHttpRequester() HttpResponse httpResponse = ProcessorTest.getHttpRequester()
.sendGet(urlString, null, null); .sendGet(urlString, null, null);
ProcessorModel ProcessorModel = ProcessorTest ProcessorModel ProcessorModel = ProcessorTest
.extractLogicalDiskModel(httpResponse.getContent()); .extractLogicalDiskModel(httpResponse.getContent());
ProcessorTest.result(ProcessorModel); ProcessorTest.result(ProcessorModel);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (JAXBException e) { } catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
public void result(ProcessorModel ProcessorModel) { 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()); Iterator<ProcessorModelChild> iterator = ProcessorModel
System.out.println("processorTimePercent"+processorModelChild.getProcessorTimePercent()); .getProcessorModelList().iterator();
System.out.println("userTimePercent"+processorModelChild.getUserTimePercent()); 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; return resultModel;
} }
} }

View File

@ -17,11 +17,10 @@ import org.springframework.stereotype.Component;
public class HttpRequester { public class HttpRequester {
private String defaultContentEncoding; private String defaultContentEncoding;
public HttpRequester() public HttpRequester() {
{
this.setDefaultContentEncoding(Charset.defaultCharset().name()); this.setDefaultContentEncoding(Charset.defaultCharset().name());
} }
public String getDefaultContentEncoding() { public String getDefaultContentEncoding() {
return defaultContentEncoding; return defaultContentEncoding;
} }
@ -29,27 +28,27 @@ public class HttpRequester {
public void setDefaultContentEncoding(String defaultContentEncoding) { public void setDefaultContentEncoding(String defaultContentEncoding) {
this.defaultContentEncoding = defaultContentEncoding; this.defaultContentEncoding = defaultContentEncoding;
} }
public HttpResponse sendPost(String urlString, Map<String, String> params) public HttpResponse sendPost(String urlString, Map<String, String> params)
throws IOException { throws IOException {
return this.send(urlString, "POST", params, "", null); 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<String, String> hashMap = new HashMap<String, String>();
hashMap.put("Content-Type", "application/xml"); hashMap.put("Content-Type", "application/xml");
return this.send(urlString, "POST", null, contentString, hashMap); return this.send(urlString, "POST", null, contentString, hashMap);
} }
public HttpResponse sendGet(String urlString, Map<String, String> params, public HttpResponse sendGet(String urlString, Map<String, String> params,
Map<String, String> properties) throws IOException { Map<String, String> properties) throws IOException {
return this.send(urlString, "GET", params, "", properties); return this.send(urlString, "GET", params, "", properties);
} }
private HttpResponse send(String urlString, String method, private HttpResponse send(String urlString, String method,
Map<String, String> parameters, String Content, Map<String, String> propertys) Map<String, String> parameters, String Content,
throws IOException { Map<String, String> propertys) throws IOException {
HttpURLConnection urlConnection = null; HttpURLConnection urlConnection = null;
if (method.equalsIgnoreCase("GET") && parameters != null) { if (method.equalsIgnoreCase("GET") && parameters != null) {
@ -69,7 +68,7 @@ public class HttpRequester {
if (!urlString.startsWith("http://")) { if (!urlString.startsWith("http://")) {
urlString = "http://" + urlString; urlString = "http://" + urlString;
} }
//urlString = URLEncoder.encode(urlString, "UTF-8"); // urlString = URLEncoder.encode(urlString, "UTF-8");
URL url = new URL(urlString); URL url = new URL(urlString);
urlConnection = (HttpURLConnection) url.openConnection(); urlConnection = (HttpURLConnection) url.openConnection();
@ -92,8 +91,7 @@ public class HttpRequester {
urlConnection.getOutputStream().write(param.toString().getBytes()); urlConnection.getOutputStream().write(param.toString().getBytes());
urlConnection.getOutputStream().flush(); urlConnection.getOutputStream().flush();
urlConnection.getOutputStream().close(); urlConnection.getOutputStream().close();
} } else if (method.equalsIgnoreCase("POST") && !Content.isEmpty()) {
else if (method.equalsIgnoreCase("POST") && !Content.isEmpty()) {
urlConnection.getOutputStream().write(Content.getBytes()); urlConnection.getOutputStream().write(Content.getBytes());
urlConnection.getOutputStream().flush(); urlConnection.getOutputStream().flush();
urlConnection.getOutputStream().close(); urlConnection.getOutputStream().close();
@ -104,7 +102,6 @@ public class HttpRequester {
private HttpResponse makeContent(String urlString, private HttpResponse makeContent(String urlString,
HttpURLConnection urlConnection) { HttpURLConnection urlConnection) {
// TODO Auto-generated method stub
HttpResponse httpResponser = new HttpResponse(); HttpResponse httpResponser = new HttpResponse();
try { try {
InputStream in = urlConnection.getInputStream(); InputStream in = urlConnection.getInputStream();

View File

@ -28,7 +28,6 @@ public class ProcessResponseModel implements MonitorResultBase {
} }
public void add(SampleModel model) { public void add(SampleModel model) {
// TODO Auto-generated method stub
if (model instanceof ProcessModel) { if (model instanceof ProcessModel) {
this.getProcessModels().add((ProcessModel) model); this.getProcessModels().add((ProcessModel) model);
} }

View File

@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.SessionAttributes;
@SessionAttributes({ "accessToken", "username", "testPlanTaskList" }) @SessionAttributes({ "accessToken", "username", "testPlanTaskList" })
public class AuthorizeActionController extends BaseControllerService { public class AuthorizeActionController extends BaseControllerService {
private Logger logger = Logger.getLogger(AuthorizeActionController.class); 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"; private String INVALIDATE_INPUT = "invalidate input";
@RequestMapping("login") @RequestMapping("login")
@ -74,13 +74,12 @@ public class AuthorizeActionController extends BaseControllerService {
httpResponse.getContent()); httpResponse.getContent());
return extractRegisterModel(registerResponseModel); return extractRegisterModel(registerResponseModel);
} catch (IOException e) { } catch (IOException e) {
logger.info(e,e.fillInStackTrace()); logger.info(e, e.fillInStackTrace());
throw new CustomGenericException("1", throw new CustomGenericException("1",
"invalidate httpresponse:io exception", this.baseUrl "invalidate httpresponse:io exception", this.baseUrl
+ "/register"); + "/register");
} catch (JAXBException e) { } catch (JAXBException e) {
// TODO Auto-generated catch block logger.info(e, e.fillInStackTrace());
logger.info(e,e.fillInStackTrace());
throw new CustomGenericException("1", throw new CustomGenericException("1",
"invalidate httpresponse:JAXBException", this.baseUrl "invalidate httpresponse:JAXBException", this.baseUrl
+ "/register"); + "/register");
@ -97,20 +96,19 @@ public class AuthorizeActionController extends BaseControllerService {
HttpResponse httpResponse = this.getHttpRequester().sendGet(url, HttpResponse httpResponse = this.getHttpRequester().sendGet(url,
params, null); params, null);
if (HttpRequester.isInvalidResponse(httpResponse)) { if (HttpRequester.isInvalidResponse(httpResponse)) {
throw new CustomGenericException("1", throw new CustomGenericException("1", "network error",
"network error",
"AuthorizeActionController_authorize"); "AuthorizeActionController_authorize");
} }
return (AuthorizeResponseModel) ObjectXmlExchange.fromXml( return (AuthorizeResponseModel) ObjectXmlExchange.fromXml(
AuthorizeResponseModel.class, httpResponse.getContent()); AuthorizeResponseModel.class, httpResponse.getContent());
} catch (IOException e) { } catch (IOException e) {
logger.info(e,e.fillInStackTrace()); logger.info(e, e.fillInStackTrace());
throw new CustomGenericException("1", throw new CustomGenericException("1",
"invalidate httpResponse:IOException", "invalidate httpResponse:IOException",
"AuthorizeActionController_authorize"); "AuthorizeActionController_authorize");
} catch (JAXBException e) { } catch (JAXBException e) {
logger.info(e,e.fillInStackTrace()); logger.info(e, e.fillInStackTrace());
throw new CustomGenericException("1", throw new CustomGenericException("1",
"invalidate httpResponse:JAXBException", "invalidate httpResponse:JAXBException",
"AuthorizeActionController_authorize"); "AuthorizeActionController_authorize");

View File

@ -31,14 +31,18 @@ import org.springframework.web.bind.annotation.SessionAttributes;
@Controller @Controller
@SessionAttributes({ "accessToken", "testPlanTaskList" }) @SessionAttributes({ "accessToken", "testPlanTaskList" })
public class TestPlanHistoryResult extends BaseControllerService { public class TestPlanHistoryResult extends BaseControllerService {
private String baseUrl = CommunicateWithMaster.getMasterAddress()+"testPlan"; private String baseUrl = CommunicateWithMaster.getMasterAddress()
+ "testPlan";
private TestPlanService testPlanService; private TestPlanService testPlanService;
private CommunicateWithMaster communicateWithMaster; private CommunicateWithMaster communicateWithMaster;
private CommunicateWithMaster getCommunicateWithMaster() { private CommunicateWithMaster getCommunicateWithMaster() {
return communicateWithMaster; return communicateWithMaster;
} }
@Autowired
private void setCommunicateWithMaster(CommunicateWithMaster communicateWithMaster) { @Autowired
private void setCommunicateWithMaster(
CommunicateWithMaster communicateWithMaster) {
this.communicateWithMaster = communicateWithMaster; this.communicateWithMaster = communicateWithMaster;
} }
@ -62,22 +66,23 @@ public class TestPlanHistoryResult extends BaseControllerService {
@RequestMapping(value = "loadTestPlans", method = { RequestMethod.GET, @RequestMapping(value = "loadTestPlans", method = { RequestMethod.GET,
RequestMethod.POST }) RequestMethod.POST })
@ResponseBody @ResponseBody
public BaseResponseModel public BaseResponseModel loadTestPlans(
loadTestPlans(
@ModelAttribute("accessToken") String accessToken) @ModelAttribute("accessToken") String accessToken)
throws CustomGenericException { throws CustomGenericException {
String caller = "TestPlanHistoryResult:loadTestPlans"; String caller = "TestPlanHistoryResult:loadTestPlans";
String url = "testPlan"+ "/loadTestPlans"; String url = "testPlan" + "/loadTestPlans";
TestPlanResponseModel testPlanResponseModel = (TestPlanResponseModel) this TestPlanResponseModel testPlanResponseModel = (TestPlanResponseModel) this
.getTestPlanService() .getTestPlanService()
.getCommunicateWithMaster() .getCommunicateWithMaster()
.getResponseModel(accessToken, url, .getResponseModel(accessToken, url,
TestPlanResponseModel.class, null, caller); TestPlanResponseModel.class, null, caller);
if (testPlanResponseModel.isSuccess()) { if (testPlanResponseModel.isSuccess()) {
return new BaseResponseModel(true,buildTestPlanListModel(testPlanResponseModel return new BaseResponseModel(true,
.getTestPlanDBModels())); buildTestPlanListModel(testPlanResponseModel
.getTestPlanDBModels()));
} else { } 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, @RequestMapping(value = "downloadReport", method = { RequestMethod.GET,
RequestMethod.POST }) RequestMethod.POST })
public BaseResponseModel downloadReport(HttpServletResponse response, public BaseResponseModel downloadReport(HttpServletResponse response,
@ModelAttribute("accessToken") String accessToken, @ModelAttribute("accessToken") String accessToken,
@RequestParam String testPlanId) throws CustomGenericException { @RequestParam String testPlanId) throws CustomGenericException {
String caller="TestPlanHistory:downloadReport"; String caller = "TestPlanHistory:downloadReport";
try { try {
HttpResponse httpResponse = this.getHttpRequester().sendGet( HttpResponse httpResponse = this.getHttpRequester().sendGet(
this.getBaseUrl() + "/getTestPlanReport", this.getBaseUrl() + "/getTestPlanReport",
makeParamsMap("testPlanRunID", testPlanId), makeParamsMap("testPlanRunID", testPlanId),
this.makeAccessTockenMap(accessToken)); this.makeAccessTockenMap(accessToken));
if (httpResponse == null ) { if (httpResponse == null) {
throw new CustomGenericException("1", "invalidate http response", caller); throw new CustomGenericException("1",
"invalidate http response", caller);
} }
if(httpResponse.getContent().isEmpty()) if (httpResponse.getContent().isEmpty())
throw new CustomGenericException("5", "report data empty",""); throw new CustomGenericException("5", "report data empty", "");
/*if(httpResponse.getContent().isEmpty()) /*
throw new CustomGenericException(errCode, errMsg, source)*/ * if(httpResponse.getContent().isEmpty()) throw new
* CustomGenericException(errCode, errMsg, source)
*/
if (httpResponse.getCode() == HttpStatus.BAD_REQUEST_400) { if (httpResponse.getCode() == HttpStatus.BAD_REQUEST_400) {
ErrorResponseModel errorResponseModel = (ErrorResponseModel) ObjectXmlExchange ErrorResponseModel errorResponseModel = (ErrorResponseModel) ObjectXmlExchange
.fromXml(ErrorResponseModel.class, .fromXml(ErrorResponseModel.class,
httpResponse.getContent()); httpResponse.getContent());
this.getCommunicateWithMaster().logException(errorResponseModel); this.getCommunicateWithMaster()
.logException(errorResponseModel);
throw new CustomGenericException("2", FAIL_WITH_EXCEPTION + "_" throw new CustomGenericException("2", FAIL_WITH_EXCEPTION + "_"
+ errorResponseModel.getMessage(), caller + "_" + errorResponseModel.getMessage(), caller + "_"
+ errorResponseModel.getResource()); + errorResponseModel.getResource());
@ -127,17 +136,18 @@ public class TestPlanHistoryResult extends BaseControllerService {
outputStream.close(); outputStream.close();
return new BaseResponseModel(true); return new BaseResponseModel(true);
} catch (IOException e) { } catch (IOException e) {
throw new CustomGenericException("1", "exception:io exception", caller); throw new CustomGenericException("1", "exception:io exception",
caller);
} catch (JAXBException e) { } catch (JAXBException e) {
// TODO Auto-generated catch block throw new CustomGenericException("1", "exception:io exception",
throw new CustomGenericException("1", "exception:io exception", caller); caller);
} }
} }
@RequestMapping(value = "deleteTest", method = { RequestMethod.GET, @RequestMapping(value = "deleteTest", method = { RequestMethod.GET,
RequestMethod.POST }) RequestMethod.POST })
@ResponseBody @ResponseBody
public BaseResponseModel deleteTest(HttpServletResponse response, public BaseResponseModel deleteTest(HttpServletResponse response,
@ModelAttribute("accessToken") String accessToken, @ModelAttribute("accessToken") String accessToken,
@RequestParam String testPlanId) throws CustomGenericException { @RequestParam String testPlanId) throws CustomGenericException {
String url = "testPlan" + "/removeTestPlanFromPool"; String url = "testPlan" + "/removeTestPlanFromPool";
@ -149,13 +159,14 @@ public class TestPlanHistoryResult extends BaseControllerService {
.getCommunicateWithMaster() .getCommunicateWithMaster()
.getResponseModel(accessToken, url, .getResponseModel(accessToken, url,
TestPlanResponseModel.class, params, caller); TestPlanResponseModel.class, params, caller);
if (testPlanResponseModel.isSuccess()) { if (testPlanResponseModel.isSuccess()) {
return new BaseResponseModel(true); return new BaseResponseModel(true);
} else { } else {
return new BaseResponseModel(false,testPlanResponseModel.getFailCause()); return new BaseResponseModel(false,
testPlanResponseModel.getFailCause());
} }
} }

View File

@ -37,7 +37,6 @@ public class TestPlanService extends BaseService {
} }
public TestPlanService() { public TestPlanService() {
// TODO Auto-generated constructor stub
} }
public ResultInfoModel getScriptBriefStatusResultInfo() { public ResultInfoModel getScriptBriefStatusResultInfo() {
@ -194,12 +193,12 @@ public class TestPlanService extends BaseService {
List<BehaviorStatusCodeResultModel> behaviorStatusCodeResultModels = new ArrayList<BehaviorStatusCodeResultModel>(); List<BehaviorStatusCodeResultModel> behaviorStatusCodeResultModels = new ArrayList<BehaviorStatusCodeResultModel>();
if (scriptBehaviorsBriefModel == null) if (scriptBehaviorsBriefModel == null)
return behaviorStatusCodeResultModels; return behaviorStatusCodeResultModels;
if(scriptBehaviorsBriefModel.getTestBehaviorsBriefModel()==null) if (scriptBehaviorsBriefModel.getTestBehaviorsBriefModel() == null)
return behaviorStatusCodeResultModels; return behaviorStatusCodeResultModels;
if(scriptBehaviorsBriefModel if (scriptBehaviorsBriefModel.getTestBehaviorsBriefModel()
.getTestBehaviorsBriefModel().getBehaviorBriefModels()==null) .getBehaviorBriefModels() == null)
scriptBehaviorsBriefModel scriptBehaviorsBriefModel.getTestBehaviorsBriefModel()
.getTestBehaviorsBriefModel().getBehaviorBriefModels(); .getBehaviorBriefModels();
for (BehaviorBriefModel behaviorBriefModel : scriptBehaviorsBriefModel for (BehaviorBriefModel behaviorBriefModel : scriptBehaviorsBriefModel
.getTestBehaviorsBriefModel().getBehaviorBriefModels()) { .getTestBehaviorsBriefModel().getBehaviorBriefModels()) {

View File

@ -29,19 +29,17 @@ public class AuthorizeActionControllerTest {
@Test @Test
public void loginTest() throws CustomGenericException { public void loginTest() throws CustomGenericException {
// right // right
this.user.setUserName("www"); this.user.setUserName("www");
this.user.setPassword("www"); this.user.setPassword("www");
Assert.assertTrue(this.authorizeActionController.login(user, Assert.assertTrue(this.authorizeActionController.login(user, modelMap)
modelMap) .isSuccess());
.isSuccess());
this.user.setUserName("www");
this.user.setUserName("www"); this.user.setPassword("123");
this.user.setPassword("123"); Assert.assertFalse(this.authorizeActionController.login(user, modelMap)
Assert.assertFalse(this.authorizeActionController.login(user, .isSuccess());
modelMap)
.isSuccess());
} }
@ -59,7 +57,6 @@ public class AuthorizeActionControllerTest {
Assert.assertFalse(this.authorizeActionController.adminLogin(null, Assert.assertFalse(this.authorizeActionController.adminLogin(null,
modelMap).isSuccess()); modelMap).isSuccess());
} catch (CustomGenericException e) { } catch (CustomGenericException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -178,12 +178,10 @@ public class TestScriptResultTest extends LoginHelper {
.queryTestPlanResultModel(testPlanRunId, accessToken) .queryTestPlanResultModel(testPlanRunId, accessToken)
.getScriptIds().get(0).toString(); .getScriptIds().get(0).toString();
} catch (CustomGenericException e) { } catch (CustomGenericException e) {
// TODO Auto-generated catch block
logger.info(ExceptionLog.getStackTrace(e)); logger.info(ExceptionLog.getStackTrace(e));
return null; return null;
} catch (JAXBException e) { } catch (JAXBException e) {
// TODO Auto-generated catch block
logger.info(ExceptionLog.getStackTrace(e)); logger.info(ExceptionLog.getStackTrace(e));
return null; return null;
} }