Search in sources :

Example 1 with Infos

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());
}
Also used : TestCaseExecution(org.cerberus.crud.entity.TestCaseExecution) HashMap(java.util.HashMap) SessionCounter(org.cerberus.crud.entity.SessionCounter) ExecutionUUID(org.cerberus.engine.entity.ExecutionUUID) ICerberusInformationDAO(org.cerberus.database.dao.ICerberusInformationDAO) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) IMyVersionService(org.cerberus.crud.service.IMyVersionService) Timestamp(java.sql.Timestamp) AnswerItem(org.cerberus.util.answer.AnswerItem) ApplicationContext(org.springframework.context.ApplicationContext) JSONObject(org.json.JSONObject) JSONObject(org.json.JSONObject) IDatabaseVersioningService(org.cerberus.database.IDatabaseVersioningService) Infos(org.cerberus.version.Infos)

Example 2 with Infos

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());
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) IMyVersionService(org.cerberus.crud.service.IMyVersionService) IDatabaseVersioningService(org.cerberus.database.IDatabaseVersioningService) Infos(org.cerberus.version.Infos)

Aggregations

IMyVersionService (org.cerberus.crud.service.IMyVersionService)2 IDatabaseVersioningService (org.cerberus.database.IDatabaseVersioningService)2 Infos (org.cerberus.version.Infos)2 JSONException (org.json.JSONException)2 JSONObject (org.json.JSONObject)2 ApplicationContext (org.springframework.context.ApplicationContext)2 Timestamp (java.sql.Timestamp)1 HashMap (java.util.HashMap)1 SessionCounter (org.cerberus.crud.entity.SessionCounter)1 TestCaseExecution (org.cerberus.crud.entity.TestCaseExecution)1 ICerberusInformationDAO (org.cerberus.database.dao.ICerberusInformationDAO)1 ExecutionUUID (org.cerberus.engine.entity.ExecutionUUID)1 AnswerItem (org.cerberus.util.answer.AnswerItem)1 JSONArray (org.json.JSONArray)1