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;
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) {