use of org.cerberus.version.Infos in project cerberus-source by cerberustesting.
the class ReadCerberusDetailInformation method processRequest.
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
JSONObject jsonResponse = new JSONObject();
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
ExecutionUUID euuid = appContext.getBean(ExecutionUUID.class);
SessionCounter sc = appContext.getBean(SessionCounter.class);
Infos infos = new Infos();
try {
jsonResponse.put("simultaneous_execution", euuid.size());
JSONArray executionArray = new JSONArray();
for (Object ex : euuid.getExecutionUUIDList().values()) {
TestCaseExecution execution = (TestCaseExecution) ex;
JSONObject object = new JSONObject();
object.put("id", execution.getId());
object.put("test", execution.getTest());
object.put("testcase", execution.getTestCase());
object.put("system", execution.getApplicationObj().getSystem());
object.put("application", execution.getApplication());
object.put("environment", execution.getEnvironmentData());
object.put("country", execution.getCountry());
object.put("robotIP", execution.getSeleniumIP());
object.put("tag", execution.getTag());
object.put("start", new Timestamp(execution.getStart()));
executionArray.put(object);
}
jsonResponse.put("simultaneous_execution_list", executionArray);
jsonResponse.put("simultaneous_session", sc.getTotalActiveSession());
jsonResponse.put("active_users", sc.getActiveUsers());
cerberusDatabaseInformation = appContext.getBean(ICerberusInformationDAO.class);
AnswerItem ans = cerberusDatabaseInformation.getDatabaseInformation();
HashMap<String, String> cerberusInformation = (HashMap<String, String>) ans.getItem();
// Database Informations.
jsonResponse.put("DatabaseProductName", cerberusInformation.get("DatabaseProductName"));
jsonResponse.put("DatabaseProductVersion", cerberusInformation.get("DatabaseProductVersion"));
jsonResponse.put("DatabaseMajorVersion", cerberusInformation.get("DatabaseMajorVersion"));
jsonResponse.put("DatabaseMinorVersion", cerberusInformation.get("DatabaseMinorVersion"));
jsonResponse.put("DriverName", cerberusInformation.get("DriverName"));
jsonResponse.put("DriverVersion", cerberusInformation.get("DriverVersion"));
jsonResponse.put("DriverMajorVersion", cerberusInformation.get("DriverMajorVersion"));
jsonResponse.put("DriverMinorVersion", cerberusInformation.get("DriverMinorVersion"));
jsonResponse.put("JDBCMajorVersion", cerberusInformation.get("JDBCMajorVersion"));
jsonResponse.put("JDBCMinorVersion", cerberusInformation.get("JDBCMinorVersion"));
// Cerberus Informations.
jsonResponse.put("projectName", infos.getProjectName());
jsonResponse.put("projectVersion", infos.getProjectVersion());
jsonResponse.put("environment", System.getProperty("org.cerberus.environment"));
databaseVersionService = appContext.getBean(IDatabaseVersioningService.class);
jsonResponse.put("databaseCerberusTargetVersion", databaseVersionService.getSQLScript().size());
myVersionService = appContext.getBean(IMyVersionService.class);
if (myVersionService.findMyVersionByKey("database") != null) {
jsonResponse.put("databaseCerberusCurrentVersion", myVersionService.findMyVersionByKey("database").getValue());
} else {
jsonResponse.put("databaseCerberusCurrentVersion", "0");
}
// JAVA Informations.
jsonResponse.put("javaVersion", System.getProperty("java.version"));
Runtime instance = Runtime.getRuntime();
int mb = 1024 * 1024;
jsonResponse.put("javaFreeMemory", instance.freeMemory() / mb);
jsonResponse.put("javaTotalMemory", instance.totalMemory() / mb);
jsonResponse.put("javaUsedMemory", (instance.totalMemory() - instance.freeMemory()) / mb);
jsonResponse.put("javaMaxMemory", instance.maxMemory() / mb);
String str1 = getServletContext().getServerInfo();
jsonResponse.put("applicationServerInfo", str1);
} catch (JSONException ex) {
LOG.warn(ex);
}
response.setContentType("application/json");
response.getWriter().print(jsonResponse.toString());
}
use of org.cerberus.version.Infos in project cerberus-source by cerberustesting.
the class ReadCerberusInformation method processRequest.
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
Infos infos = new Infos();
JSONObject data = new JSONObject();
response.setContentType("application/json");
response.setCharacterEncoding("utf8");
try {
data.put("projectName", infos.getProjectName());
data.put("projectVersion", infos.getProjectVersion());
data.put("environment", System.getProperty("org.cerberus.environment"));
databaseVersionService = appContext.getBean(IDatabaseVersioningService.class);
data.put("databaseCerberusTargetVersion", databaseVersionService.getSQLScript().size());
myVersionService = appContext.getBean(IMyVersionService.class);
if (myVersionService.findMyVersionByKey("database") != null) {
data.put("databaseCerberusCurrentVersion", myVersionService.findMyVersionByKey("database").getValue());
} else {
data.put("databaseCerberusCurrentVersion", "0");
}
} catch (JSONException ex) {
LOG.warn(ex);
}
response.getWriter().print(data.toString());
}
Aggregations