From be70765682c49ad8f0e1622c2f350bac5f4ba241 Mon Sep 17 00:00:00 2001 From: "shihyun.kim" Date: Mon, 14 Oct 2013 17:36:16 +0900 Subject: [PATCH] [Title]modify result test file name Signed-off-by: shihyun.kim --- .../org/tizen/installmanager/core/Performance.java | 139 ++++++++++++++++----- .../installmanager/ui/InstallManagerWindow.java | 3 + 2 files changed, 112 insertions(+), 30 deletions(-) diff --git a/InstallManager_java/src/org/tizen/installmanager/core/Performance.java b/InstallManager_java/src/org/tizen/installmanager/core/Performance.java index 7d001cc..ab40a54 100644 --- a/InstallManager_java/src/org/tizen/installmanager/core/Performance.java +++ b/InstallManager_java/src/org/tizen/installmanager/core/Performance.java @@ -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(""); + } 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(""); + } 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(""); + } 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(""); + 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) { diff --git a/InstallManager_java/src/org/tizen/installmanager/ui/InstallManagerWindow.java b/InstallManager_java/src/org/tizen/installmanager/ui/InstallManagerWindow.java index c9480f0..163d3a1 100644 --- a/InstallManager_java/src/org/tizen/installmanager/ui/InstallManagerWindow.java +++ b/InstallManager_java/src/org/tizen/installmanager/ui/InstallManagerWindow.java @@ -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"); -- 2.7.4