[Title]modify result test file name 54/10854/1
authorshihyun.kim <shihyun.kim@samsung.com>
Mon, 14 Oct 2013 08:36:16 +0000 (17:36 +0900)
committershihyun.kim <shihyun.kim@samsung.com>
Mon, 14 Oct 2013 08:36:16 +0000 (17:36 +0900)
Signed-off-by: shihyun.kim <shihyun.kim@samsung.com>
InstallManager_java/src/org/tizen/installmanager/core/Performance.java
InstallManager_java/src/org/tizen/installmanager/ui/InstallManagerWindow.java

index 7d001cc..ab40a54 100644 (file)
@@ -11,6 +11,9 @@ import org.tizen.installmanager.lib.Log;
 import org.tizen.installmanager.util.PathUtil;
 
 public class Performance {
+       public static final String INSTALL_TEST_FILE_NAME = "installtime";
+       public static final String REMOVE_TEST_FILE_NAME = "removetime";
+       
        //total time
        private static Date imStartTime = null;
        private static Date imEndTime = null;
@@ -156,41 +159,117 @@ public class Performance {
        
        public static void printTestResultXmlFormat() {
                //get file name of test result
-                               SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
-                               String testFileName = formatter.format(imStartTime) + ".xml";
-                               
-                               String testResultFilePath = PathUtil.get(InstallManagerConstants.getInstallManagerTestResultPath(), testFileName);
-                               File testResultFile = new File(testResultFilePath);
-                               
-                               if (!testResultFile.getParentFile().exists()) {
-                                       testResultFile.getParentFile().mkdirs();
+               SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
+               String testFileName = formatter.format(imStartTime) + ".xml";
+               
+               String testResultFilePath = PathUtil.get(InstallManagerConstants.getInstallManagerTestResultPath(), testFileName);
+               File testResultFile = new File(testResultFilePath);
+               
+               if (!testResultFile.getParentFile().exists()) {
+                       testResultFile.getParentFile().mkdirs();
+               }
+               
+               BufferedWriter out = null;
+               try {
+                       out = new BufferedWriter(new FileWriter(testResultFile));
+                       out.write(getTestSuiteXml("InstallManager performance test", 4, getTotalTime()));
+                       out.newLine();
+                       out.write(getTestCaseXml("InitTest", "The initialization time", getInitializeTime()));
+                       out.newLine();
+                       out.write(getTestCaseXml("DownloadTest", "The download time", getDownloadTime()));
+                       out.newLine();
+                       out.write(getTestCaseXml("InstallTest", "The installation time", getInstallationTime()));
+                       out.newLine();
+                       out.write(getTestCaseXml("RemoveTest", "The removal time", getRemovalTime()));
+                       out.newLine();
+                       out.write("</testsuite>");
+               } catch (IOException e) {
+                       Log.ExceptionLog(e);
+               } finally {
+                       if (out != null) {
+                               try {
+                                       out.close();
+                               } catch (IOException e) {
+                                       Log.ExceptionLog(e);
                                }
-                               
-                               BufferedWriter out = null;
+                       }
+               }
+       }
+       
+       public static void printTestResultXmlFormat2() {
+               if (installationStartTime != null) {
+                       printInstallTestResultXmlFormat();
+               } else {
+                       printRemoveTestResultXmlFormat();
+               }
+       }
+       
+       public static void printInstallTestResultXmlFormat() {
+               //get file name of test result
+               SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
+               String testFileName = INSTALL_TEST_FILE_NAME + "_" + formatter.format(imStartTime) + ".xml";
+               
+               String testResultFilePath = PathUtil.get(InstallManagerConstants.getInstallManagerTestResultPath(), testFileName);
+               File testResultFile = new File(testResultFilePath);
+               
+               if (!testResultFile.getParentFile().exists()) {
+                       testResultFile.getParentFile().mkdirs();
+               }
+               
+               BufferedWriter out = null;
+               try {
+                       out = new BufferedWriter(new FileWriter(testResultFile));
+                       out.write(getTestSuiteXml("InstallManager performance test", 3, getTotalTime()));
+                       out.newLine();
+                       out.write(getTestCaseXml("InitTest", "The initialization time", getInitializeTime()));
+                       out.newLine();
+                       out.write(getTestCaseXml("DownloadTest", "The download time", getDownloadTime()));
+                       out.newLine();
+                       out.write(getTestCaseXml("InstallTest", "The installation time", getInstallationTime()));
+                       out.newLine();
+                       out.write("</testsuite>");
+               } catch (IOException e) {
+                       Log.ExceptionLog(e);
+               } finally {
+                       if (out != null) {
+                               try {
+                                       out.close();
+                               } catch (IOException e) {
+                                       Log.ExceptionLog(e);
+                               }
+                       }
+               }
+       }
+       
+       public static void printRemoveTestResultXmlFormat() {
+               //get file name of test result
+               SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
+               String testFileName = REMOVE_TEST_FILE_NAME + "_" + formatter.format(imStartTime) + ".xml";
+               
+               String testResultFilePath = PathUtil.get(InstallManagerConstants.getInstallManagerTestResultPath(), testFileName);
+               File testResultFile = new File(testResultFilePath);
+               
+               if (!testResultFile.getParentFile().exists()) {
+                       testResultFile.getParentFile().mkdirs();
+               }
+               
+               BufferedWriter out = null;
+               try {
+                       out = new BufferedWriter(new FileWriter(testResultFile));
+                       out.write(getTestSuiteXml("InstallManager performance test", 1, getTotalTime()));
+                       out.newLine();
+                       out.write("</testsuite>");
+               } catch (IOException e) {
+                       Log.ExceptionLog(e);
+               } finally {
+                       if (out != null) {
                                try {
-                                       out = new BufferedWriter(new FileWriter(testResultFile));
-                                       out.write(getTestSuiteXml("InstallManager performance test", 4, getTotalTime()));
-                                       out.newLine();
-                                       out.write(getTestCaseXml("InitTest", "The initialization time", getInitializeTime()));
-                                       out.newLine();
-                                       out.write(getTestCaseXml("DownloadTest", "The download time", getDownloadTime()));
-                                       out.newLine();
-                                       out.write(getTestCaseXml("InstallTest", "The installation time", getInstallationTime()));
-                                       out.newLine();
-                                       out.write(getTestCaseXml("RemoveTest", "The removal time", getRemovalTime()));
-                                       out.newLine();
-                                       out.write("</testsuite>");
+                                       out.close();
                                } catch (IOException e) {
                                        Log.ExceptionLog(e);
-                               } finally {
-                                       if (out != null) {
-                                               try {
-                                                       out.close();
-                                               } catch (IOException e) {
-                                                       Log.ExceptionLog(e);
-                                               }
-                                       }
                                }
+                       }
+               }
        }
        
        private static String getTestSuiteXml(String testName, int testNum, long time) {
index c9480f0..163d3a1 100644 (file)
@@ -855,6 +855,7 @@ public class InstallManagerWindow extends ApplicationWindow {
                                Performance.setIMEndTime();
                                if (Options.doTest) {
                                        Performance.printTestResultXmlFormat();
+                                       Performance.printTestResultXmlFormat2();
                                }
                                
                                System.exit(0);
@@ -870,6 +871,7 @@ public class InstallManagerWindow extends ApplicationWindow {
                                Performance.setIMEndTime();
                                if (Options.doTest) {
                                        Performance.printTestResultXmlFormat();
+                                       Performance.printTestResultXmlFormat2();
                                }
                                
                                System.exit(0);
@@ -958,6 +960,7 @@ public class InstallManagerWindow extends ApplicationWindow {
                        
                        if (Options.doTest) {
                                Performance.printTestResultXmlFormat();
+                               Performance.printTestResultXmlFormat2();
                        }
                        
                        Log.LogTitle("Installmanager finish");