From 99b088dcd494d34681540816dba3070e30a929a6 Mon Sep 17 00:00:00 2001 From: "Frederick G. Oconer" Date: Wed, 7 Jun 2006 02:34:18 +0000 Subject: [PATCH] Changed DataOutputStream to PrintWriter when generating the report xml file. git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@412256 13f79535-47bb-0310-9956-ffa450edef68 --- tooling/maven-activemq-perf-plugin/pom.xml | 4 +- .../activemq/tool/JmsClientSystemSupport.java | 2 +- .../activemq/tool/PerfMeasurementTool.java | 25 ++--- .../activemq/tool/PerfReportGenerator.java | 95 ++++++++++--------- 4 files changed, 60 insertions(+), 66 deletions(-) diff --git a/tooling/maven-activemq-perf-plugin/pom.xml b/tooling/maven-activemq-perf-plugin/pom.xml index afdcf5497c..339827cab1 100644 --- a/tooling/maven-activemq-perf-plugin/pom.xml +++ b/tooling/maven-activemq-perf-plugin/pom.xml @@ -25,12 +25,12 @@ incubator-activemq activemq-core - 4.0-SNAPSHOT + 4.1-SNAPSHOT incubator-activemq activemq-console - 4.0-SNAPSHOT + 4.1-SNAPSHOT incubator-activemq diff --git a/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java b/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java index 677dfc0e3f..4b5ba54a89 100644 --- a/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java +++ b/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java @@ -54,7 +54,7 @@ public abstract class JmsClientSystemSupport { report.setTestSettings(getSettings()); report.startGenerateReport(); - performanceSampler.setDataOutputStream(report.getDataOutputStream()); + performanceSampler.setWriter(report.getWriter()); clientThreadGroup = new ThreadGroup(getThreadGroupName()); for (int i=0; i\n"); + getWriter().println(""); client.reset(); } } @@ -186,12 +185,4 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable { } } } - - public void writeResult(String result) { - try { - getDataOutputStream().writeChars(result); - } catch (IOException e) { - e.printStackTrace(); - } - } } diff --git a/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/PerfReportGenerator.java b/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/PerfReportGenerator.java index 6141f34f42..ec47d7a42e 100644 --- a/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/PerfReportGenerator.java +++ b/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/PerfReportGenerator.java @@ -1,25 +1,34 @@ +/** + * + * Copyright 2005-2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apache.activemq.tool; -import java.io.DataOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.util.Properties; +import java.io.PrintWriter; import java.util.Enumeration; -import java.util.Iterator; +import java.util.Properties; -/** - * Created by IntelliJ IDEA. - * User: admin - * Date: Jun 5, 2006 - * Time: 10:57:52 AM - * To change this template use File | Settings | File Templates. - */ public class PerfReportGenerator { private String reportDirectory = null; private String reportName = null; - private DataOutputStream dataOutputStream = null; + private PrintWriter writer = null; private Properties testSettings; @@ -44,61 +53,55 @@ public class PerfReportGenerator { File reportFile = null; if (reportDir != null) { - String filename = (this.getReportName()).substring(this.getReportName().lastIndexOf(".")+1)+"-"+createReportName(getTestSettings()); + String filename = (this.getReportName()).substring(this.getReportName().lastIndexOf(".") + 1) + "-" + createReportName(getTestSettings()); reportFile = new File(this.getReportDirectory() + File.separator + filename + ".xml"); } try { - dataOutputStream = new DataOutputStream(new FileOutputStream(reportFile)); - dataOutputStream.writeChars(getTestInformation().toString()); + this.writer = new PrintWriter(new FileOutputStream(reportFile)); + addTestInformation(getWriter()); } catch (IOException e1) { e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } public void stopGenerateReport() { - try { - dataOutputStream.writeChars("\n"); - dataOutputStream.flush(); - dataOutputStream.close(); - } catch (IOException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } + this.getWriter().println(""); + this.getWriter().println(""); + this.getWriter().flush(); + this.getWriter().close(); } - protected String getTestInformation() { - StringBuffer buffer = new StringBuffer(); + protected void addTestInformation(PrintWriter writer) { - buffer.append("\n"); - buffer.append("\n"); + writer.println(""); + writer.println(""); - buffer.append("" + System.getProperty("os.name") + "\n"); - buffer.append("" + System.getProperty("java.version") + "\n"); + writer.println("" + System.getProperty("os.name") + ""); + writer.println("" + System.getProperty("java.version") + ""); - if(this.getTestSettings()!=null){ + if (this.getTestSettings() != null) { Enumeration keys = getTestSettings().propertyNames(); - buffer.append("\n"); + writer.println(""); String key; String key2; - while(keys.hasMoreElements()){ + while (keys.hasMoreElements()) { key = (String) keys.nextElement(); - key2 = key.substring(key.indexOf(".")+1); - buffer.append("<" + key2 +">" + getTestSettings().get(key) + "\n"); + key2 = key.substring(key.indexOf(".") + 1); + writer.println("<" + key2 + ">" + getTestSettings().get(key) + ""); } - buffer.append("\n"); + writer.println(""); } - buffer.append("\n"); - buffer.append("\n"); - - return buffer.toString(); + writer.println(""); + writer.println(""); } - public DataOutputStream getDataOutputStream() { - return this.dataOutputStream; + public PrintWriter getWriter() { + return this.writer; } @@ -115,22 +118,22 @@ public class PerfReportGenerator { } public String createReportName(Properties testSettings) { - if(testSettings!=null){ - String[] keys = {"client.destCount","consumer.asyncRecv","consumer.durable", - "producer.messageSize","sysTest.numClients","sysTest.totalDests"}; + if (testSettings != null) { + String[] keys = {"client.destCount", "consumer.asyncRecv", "consumer.durable", + "producer.messageSize", "sysTest.numClients", "sysTest.totalDests"}; StringBuffer buffer = new StringBuffer(); String key; String val; String temp; - for(int i=0;i