You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by ms...@apache.org on 2002/05/01 03:39:41 UTC
cvs commit: jakarta-jmeter/src_1/org/apache/jmeter/visualizers/gui AbstractVisualizer.java
mstover1 02/04/30 18:39:41
Modified: src_1/org/apache/jmeter/gui JMeterFileFilter.java
src_1/org/apache/jmeter/gui/action Analyze.java Load.java
src_1/org/apache/jmeter/gui/util FileDialoger.java
FilePanel.java
src_1/org/apache/jmeter/reporters ResultCollector.java
src_1/org/apache/jmeter/resources messages.properties
messages_ja.properties messages_no.properties
src_1/org/apache/jmeter/threads JMeterThread.java
src_1/org/apache/jmeter/util ClassFinder.java
SearchByClass.java
src_1/org/apache/jmeter/visualizers AssertionVisualizer.java
GraphAccumVisualizer.java SplineVisualizer.java
StatVisualizer.java TableVisualizer.java
ViewResultsFullVisualizer.java
ViewResultsVisualizer.java
src_1/org/apache/jmeter/visualizers/gui
AbstractVisualizer.java
Added: src_1/org/apache/jmeter/threads JMeterThreadMonitor.java
Log:
Debugging results-saving code in src_1
Revision Changes Path
1.3 +25 -2 jakarta-jmeter/src_1/org/apache/jmeter/gui/JMeterFileFilter.java
Index: JMeterFileFilter.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/JMeterFileFilter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JMeterFileFilter.java 29 Apr 2002 17:08:08 -0000 1.2
+++ JMeterFileFilter.java 1 May 2002 01:39:40 -0000 1.3
@@ -58,8 +58,15 @@
import java.io.*;
import javax.swing.*;
import javax.swing.filechooser.*;
+import java.util.Arrays;
public class JMeterFileFilter extends javax.swing.filechooser.FileFilter {
+ String[] exts;
+
+ public JMeterFileFilter(String[] extensions)
+ {
+ exts = extensions;
+ }
public boolean accept(File f) {
boolean isAccepted = false;
@@ -67,7 +74,7 @@
if (f.isDirectory()) {
isAccepted = true;
} else {
- if (f.getName().toLowerCase().endsWith(".jmx")) {
+ if (accept(f.getName().toLowerCase())) {
isAccepted = true;
} else {
isAccepted = false;
@@ -76,8 +83,24 @@
return isAccepted;
}
+
+ public boolean accept(String filename)
+ {
+ for(int i = 0;i < exts.length;i++)
+ {
+ if(filename.endsWith(exts[i]))
+ {
+ return true;
+ }
+ }
+ if(exts.length == 0)
+ {
+ return true;
+ }
+ return false;
+ }
public String getDescription() {
- return "JMeter (*.jmx)";
+ return "JMeter "+Arrays.asList(exts).toString();
}
}
1.3 +2 -2 jakarta-jmeter/src_1/org/apache/jmeter/gui/action/Analyze.java
Index: Analyze.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/action/Analyze.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Analyze.java 29 Apr 2002 17:08:08 -0000 1.2
+++ Analyze.java 1 May 2002 01:39:40 -0000 1.3
@@ -72,7 +72,7 @@
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
- *@created $Date: 2002/04/29 17:08:08 $
+ *@created $Date: 2002/05/01 01:39:40 $
*@version 1.0
***************************************/
public class Analyze implements Command
@@ -108,7 +108,7 @@
public void doAction(ActionEvent e)
{
FileReporter analyzer = new FileReporter();
- File f = FileDialoger.promptToOpenFile().getSelectedFile();
+ File f = FileDialoger.promptToOpenFile(new String[]{".jtl"}).getSelectedFile();
if(f != null)
{
try
1.3 +2 -2 jakarta-jmeter/src_1/org/apache/jmeter/gui/action/Load.java
Index: Load.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/action/Load.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Load.java 29 Apr 2002 17:08:08 -0000 1.2
+++ Load.java 1 May 2002 01:39:40 -0000 1.3
@@ -75,7 +75,7 @@
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
- *@created $Date: 2002/04/29 17:08:08 $
+ *@created $Date: 2002/05/01 01:39:40 $
*@version 1.0
***************************************/
public class Load implements Command
@@ -109,7 +109,7 @@
***************************************/
public void doAction(ActionEvent e)
{
- JFileChooser chooser = FileDialoger.promptToOpenFile();
+ JFileChooser chooser = FileDialoger.promptToOpenFile(new String[]{".jmx"});
InputStream reader = null;
try
{
1.3 +9 -4 jakarta-jmeter/src_1/org/apache/jmeter/gui/util/FileDialoger.java
Index: FileDialoger.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/util/FileDialoger.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FileDialoger.java 29 Apr 2002 17:08:09 -0000 1.2
+++ FileDialoger.java 1 May 2002 01:39:40 -0000 1.3
@@ -9,7 +9,7 @@
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
- *@created $Date: 2002/04/29 17:08:09 $
+ *@created $Date: 2002/05/01 01:39:40 $
*@version 1.0
***************************************/
@@ -36,7 +36,7 @@
*@returns The JFileChooser that interacted with the user, after they are
* finished using it (accept or otherwise).
***************************************/
- public static JFileChooser promptToOpenFile()
+ public static JFileChooser promptToOpenFile(String[] exts)
{
JFileChooser jfc = null;
@@ -58,12 +58,17 @@
jfc = new JFileChooser(lastJFCDirectory);
}
- jfc.addChoosableFileFilter(new JMeterFileFilter());
+ jfc.addChoosableFileFilter(new JMeterFileFilter(exts));
jfc.showOpenDialog(GuiPackage.getInstance().getMainFrame());
lastJFCDirectory = jfc.getCurrentDirectory().getAbsolutePath();
return jfc;
}
+
+ public static JFileChooser promptToOpenFile()
+ {
+ return promptToOpenFile(new String[0]);
+ }
/****************************************
* Prompts the user to choose a file from their filesystems for our own devious
@@ -102,7 +107,7 @@
jfc.setSelectedFile(new File(lastJFCDirectory, filename));
}
- jfc.addChoosableFileFilter(new JMeterFileFilter());
+ jfc.addChoosableFileFilter(new JMeterFileFilter(new String[]{".jmx"}));
jfc.showSaveDialog(GuiPackage.getInstance().getMainFrame());
lastJFCDirectory = jfc.getCurrentDirectory().getAbsolutePath();
1.3 +12 -3 jakarta-jmeter/src_1/org/apache/jmeter/gui/util/FilePanel.java
Index: FilePanel.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/util/FilePanel.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FilePanel.java 30 Apr 2002 02:41:32 -0000 1.2
+++ FilePanel.java 1 May 2002 01:39:40 -0000 1.3
@@ -52,7 +52,9 @@
{
add(label);
add(filename);
+ filename.addActionListener(this);
add(browse);
+ browse.setActionCommand("browse");
browse.addActionListener(this);
}
@@ -94,10 +96,17 @@
*/
public void actionPerformed(ActionEvent e)
{
- JFileChooser chooser = FileDialoger.promptToOpenFile();
- if(chooser != null && chooser.getSelectedFile() != null)
+ if(e.getActionCommand().equals("browse"))
+ {
+ JFileChooser chooser = FileDialoger.promptToOpenFile(new String[]{".jtl"});
+ if(chooser != null && chooser.getSelectedFile() != null)
+ {
+ filename.setText(chooser.getSelectedFile().getPath());
+ fireFileChanged();
+ }
+ }
+ else
{
- filename.setText(chooser.getSelectedFile().getPath());
fireFileChanged();
}
}
1.6 +38 -14 jakarta-jmeter/src_1/org/apache/jmeter/reporters/ResultCollector.java
Index: ResultCollector.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/reporters/ResultCollector.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ResultCollector.java 30 Apr 2002 02:41:32 -0000 1.5
+++ ResultCollector.java 1 May 2002 01:39:40 -0000 1.6
@@ -62,13 +62,14 @@
import org.apache.jmeter.visualizers.ViewResultsVisualizer;
import org.apache.avalon.framework.configuration.*;
import org.xml.sax.SAXException;
+import org.apache.jmeter.exceptions.*;
import org.apache.jmeter.testelement.TestListener;
/**
* Title: Description: Copyright: Copyright (c) 2001 Company:
*
*@author Michael Stover
- *@created $Date: 2002/04/30 02:41:32 $
+ *@created $Date: 2002/05/01 01:39:40 $
*@version 1.0
*/
@@ -85,6 +86,10 @@
private PrintWriter out;
private DefaultConfigurationSerializer serializer = new DefaultConfigurationSerializer();
private boolean inLoading = false;
+ private boolean inTest = false;
+ private static Set openFiles = new HashSet();
+ private static Map fileOwners = new HashMap();
+
/**
* !ToDo (Constructor description)
@@ -99,15 +104,27 @@
*
*@param f The new filename value`
*/
- public void setFilename(String f) throws IOException
+ public void setFilename(String f) throws IOException,IllegalUserActionException
{
+ if(openFiles.contains(f) && !fileOwners.get(f).equals(this))
+ {
+ throw new IllegalUserActionException(JMeterUtils.getResString("file_already_in_use"));
+ }
+ if(inTest)
+ {
+ throw new IllegalUserActionException(JMeterUtils.getResString("busy_testing"));
+ }
System.out.println("Setting filename");
try
{
- filename = f;
finalizeFileOutput();
- clear();
+ openFiles.remove(filename);
+ fileOwners.remove(filename);
+ filename = f;
loadExistingFile();
+ openFiles.add(filename);
+ fileOwners.put(filename,this);
+ finalizeFileOutput();
}
catch(SAXException e)
{
@@ -123,15 +140,18 @@
public void testEnded()
{
finalizeFileOutput();
+ inTest = false;
}
public void testStarted()
{
+ inTest = true;
}
public void loadExistingFile()
throws SAXException, IOException, ConfigurationException {
inLoading = true;
+ clear();
try {
Configuration savedSamples = getConfiguration(filename);
readSamples(savedSamples);
@@ -144,9 +164,9 @@
* Description of the Method
*/
private void writeFileStart()
- {
- out.print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- out.print("<testResults>\n");
+ {
+ out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ out.println("<testResults>");
}
/**
@@ -364,20 +384,24 @@
private void initializeFileOutput() throws IOException,
ConfigurationException,SAXException
{
+
if(out == null && filename != null)
{
if(!inLoading)
{
loadExistingFile();
}
- try
- {
- out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(filename)));
- writeFileStart();
- }
- catch(FileNotFoundException e)
+ if(out == null)
{
- out = null;
+ try
+ {
+ out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(filename)));
+ writeFileStart();
+ }
+ catch(FileNotFoundException e)
+ {
+ out = null;
+ }
}
}
}
1.5 +3 -1 jakarta-jmeter/src_1/org/apache/jmeter/resources/messages.properties
Index: messages.properties
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/resources/messages.properties,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- messages.properties 29 Apr 2002 17:08:13 -0000 1.4
+++ messages.properties 1 May 2002 01:39:40 -0000 1.5
@@ -209,4 +209,6 @@
http_response_code=HTTP response code
aggregate_report=Aggregate Report
login_config_element=Login Config Element
-menu_non_test_elements=Non-Test Elements
\ No newline at end of file
+menu_non_test_elements=Non-Test Elements
+file_already_in_use=That file is already in use
+busy_testing=I'm busy testing, please stop the test before changing settings
\ No newline at end of file
1.4 +3 -1 jakarta-jmeter/src_1/org/apache/jmeter/resources/messages_ja.properties
Index: messages_ja.properties
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/resources/messages_ja.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- messages_ja.properties 29 Apr 2002 17:08:13 -0000 1.3
+++ messages_ja.properties 1 May 2002 01:39:40 -0000 1.4
@@ -203,4 +203,6 @@
http_response_code=HTTP response code
aggregate_report=Aggregate Report
login_config_element=Login Config Element
-menu_non_test_elements=Non-Test Elements
\ No newline at end of file
+menu_non_test_elements=Non-Test Elements
+file_already_in_use=That file is already in use
+busy_testing=I'm busy testing, please stop the test before changing settings
\ No newline at end of file
1.4 +3 -1 jakarta-jmeter/src_1/org/apache/jmeter/resources/messages_no.properties
Index: messages_no.properties
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/resources/messages_no.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- messages_no.properties 29 Apr 2002 17:08:13 -0000 1.3
+++ messages_no.properties 1 May 2002 01:39:40 -0000 1.4
@@ -194,4 +194,6 @@
http_response_code=HTTP response code
aggregate_report=Aggregate Report
login_config_element=Login Config Element
-menu_non_test_elements=Non-Test Elements
\ No newline at end of file
+menu_non_test_elements=Non-Test Elements
+file_already_in_use=That file is already in use
+busy_testing=I'm busy testing, please stop the test before changing settings
\ No newline at end of file
1.7 +32 -64 jakarta-jmeter/src_1/org/apache/jmeter/threads/JMeterThread.java
Index: JMeterThread.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/threads/JMeterThread.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JMeterThread.java 30 Apr 2002 02:41:32 -0000 1.6
+++ JMeterThread.java 1 May 2002 01:39:40 -0000 1.7
@@ -65,135 +65,103 @@
import org.apache.jmeter.timers.Timer;
import org.apache.jmeter.util.ListedHashTree;
import org.apache.jmeter.testelement.TestElement;
-
/****************************************
* The JMeter interface to the sampling process, allowing JMeter to see the
* timing, add listeners for sampling events and to stop the sampling process.
*
*@author $Author: mstover1 $
- *@created $Date: 2002/04/30 02:41:32 $
- *@version $Revision: 1.6 $
+ *@created $Date: 2002/05/01 01:39:40 $
+ *@version $Revision: 1.7 $
***************************************/
-public class JMeterThread implements Runnable, java.io.Serializable
-{
+public class JMeterThread implements Runnable, java.io.Serializable {
static Map samplers = new HashMap();
-
int initialDelay = 0;
Controller controller;
private boolean running;
ListedHashTree testTree;
TestCompiler compiler;
JMeterThreadMonitor monitor;
-
/****************************************
* !ToDo (Constructor description)
***************************************/
- public JMeterThread() { }
-
- public JMeterThread(ListedHashTree test,JMeterThreadMonitor monitor)
- {
+ public JMeterThread() {}
+ public JMeterThread(ListedHashTree test, JMeterThreadMonitor monitor) {
this.monitor = monitor;
testTree = test;
compiler = new TestCompiler(testTree);
- controller = (Controller)testTree.getArray()[0];
+ controller = (Controller) testTree.getArray()[0];
}
-
/****************************************
* !ToDo (Method description)
***************************************/
- public void run()
- {
+ public void run() {
testTree.traverse(compiler);
running = true;
//listeners = controller.getListeners();
Sampler entry = null;
rampUpDelay();
- while(running)
- {
- while(controller.hasNext())
- {
+ while (running) {
+ while (controller.hasNext()) {
SamplePackage pack = compiler.configureSampler(controller.next());
delay(pack.getTimers());
SampleResult result = pack.getSampler().sample(null);
- checkAssertions(pack.getAssertions(),result);
- notifyListeners(pack.getSampleListeners(),result);
+ checkAssertions(pack.getAssertions(), result);
+ notifyListeners(pack.getSampleListeners(), result);
}
- if(controller.isDone())
- {
+ if (controller.isDone()) {
running = false;
}
}
monitor.threadFinished(this);
}
-
/****************************************
* !ToDo (Method description)
***************************************/
- public void stop()
- {
+ public void stop() {
running = false;
}
-
- private void checkAssertions(List assertions, SampleResult result)
- {
+ private void checkAssertions(List assertions, SampleResult result) {
Iterator iter = assertions.iterator();
- while(iter.hasNext())
- {
- result.addAssertionResult(((Assertion)iter.next()).getResult(result));
+ while (iter.hasNext()) {
+ result.addAssertionResult(((Assertion) iter.next()).getResult(result));
}
}
-
- private void delay(List timers)
- {
+ private void delay(List timers) {
int sum = 0;
Iterator iter = timers.iterator();
- while(iter.hasNext())
- {
- sum += ((Timer)iter.next()).delay();
+ while (iter.hasNext()) {
+ sum += ((Timer) iter.next()).delay();
}
- try
- {
+ try {
Thread.sleep(sum);
}
- catch(InterruptedException e)
- {
+ catch (InterruptedException e) {
e.printStackTrace();
}
}
-
- private void notifyListeners(List listeners,SampleResult result)
- {
- SampleEvent event = new SampleEvent(result, (String)controller.getProperty(TestElement.NAME));
+ private void notifyListeners(List listeners, SampleResult result) {
+ SampleEvent event =
+ new SampleEvent(result, (String) controller.getProperty(TestElement.NAME));
Iterator iter = listeners.iterator();
- while(iter.hasNext())
- {
- SampleListener item = (SampleListener)iter.next();
+ while (iter.hasNext()) {
+ SampleListener item = (SampleListener) iter.next();
item.sampleOccurred(event);
}
}
-
- public void setInitialDelay(int delay)
- {
+ public void setInitialDelay(int delay) {
initialDelay = delay;
}
-
/****************************************
* Initial delay if ramp-up period is active for this group
***************************************/
- private void rampUpDelay()
- {
- if(initialDelay > 0)
- {
- try
- {
+ private void rampUpDelay() {
+ if (initialDelay > 0) {
+ try {
Thread.sleep(initialDelay);
}
- catch(InterruptedException e)
- {
+ catch (InterruptedException e) {
e.printStackTrace();
}
}
}
-
-}
-
+}
\ No newline at end of file
1.1 jakarta-jmeter/src_1/org/apache/jmeter/threads/JMeterThreadMonitor.java
Index: JMeterThreadMonitor.java
===================================================================
package org.apache.jmeter.threads;
/**
* @author Administrator
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
*/
public interface JMeterThreadMonitor
{
public void threadFinished(JMeterThread thread);
}
1.4 +298 -1058 jakarta-jmeter/src_1/org/apache/jmeter/util/ClassFinder.java
Index: ClassFinder.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/util/ClassFinder.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ClassFinder.java 29 Apr 2002 17:08:14 -0000 1.3
+++ ClassFinder.java 1 May 2002 01:39:40 -0000 1.4
@@ -105,32 +105,13 @@
* <http://www.apache.org/>.
*/
-
package org.apache.jmeter.util;
-
-
-
import java.util.*;
-
-
-
import java.util.zip.*;
-
-
-
import java.io.*;
-
-
import java.lang.reflect.Modifier;
-
-
-
import junit.framework.TestCase;
-
-
-
import org.apache.log4j.*;
-
/************************************************************
* This class finds classes that implement one or more specified interfaces.
@@ -148,475 +129,247 @@
*@version 1.0
***********************************************************/
-
-
-
-public class ClassFinder
-
-{
-
-
-
+public class ClassFinder {
private static Category catClass =
-
- Category.getInstance(ClassFinder.class.getName());
-
-
-
- private ClassFinder()
-
- {
-
- }
-
-
-
+ Category.getInstance(ClassFinder.class.getName());
+ private ClassFinder() {}
// static only
-
-
-
/************************************************************
-
+
* Convenience method for <code>findClassesThatExtend(Class[], boolean)</code>
-
+
* with the option to include inner classes in the search set to false
-
+
*
-
+
*@param superClasses Description of Parameter
-
+
*@return ArrayList containing discovered classes.
-
+
*@exception IOException
-
+
*@exception ClassNotFoundException
-
+
***********************************************************/
-
-
-
- public static List findClassesThatExtend(Class[] superClasses) throws IOException, ClassNotFoundException
-
- {
-
+ public static List findClassesThatExtend(Class[] superClasses)
+ throws IOException, ClassNotFoundException {
return findClassesThatExtend(superClasses, false);
-
}
-
-
-
/************************************************************
-
+
* Find classes in the provided path(s)/jar(s) that extend the class(es).
-
+
*
-
+
*@param superClasses Description of Parameter
-
+
*@param innerClasses indicate whether to include inner classes
-
+
* in the search
-
+
*@return ArrayList containing discovered classes.
-
+
*@exception IOException
-
+
*@exception ClassNotFoundException
-
+
***********************************************************/
-
- private static String[] addJarsInPath(String[] paths)
- {
+ private static String[] addJarsInPath(String[] paths) {
Set fullList = new HashSet();
for (int i = 0; i < paths.length; i++) {
fullList.add(paths[i]);
- if(!paths[i].endsWith(".jar"))
- {
+ if (!paths[i].endsWith(".jar")) {
File dir = new File(paths[i]);
- if(dir.exists() && dir.isDirectory())
- {
- String[] jars = dir.list(new FilenameFilter(){
- public boolean accept(File f,String name)
- {
- if(name.endsWith(".jar"))
- {
+ if (dir.exists() && dir.isDirectory()) {
+ String[] jars = dir.list(new FilenameFilter() {
+ public boolean accept(File f, String name) {
+ if (name.endsWith(".jar")) {
return true;
}
return false;
}
});
- for (int x = 0; x < jars.length; x++)
- {
+ for (int x = 0; x < jars.length; x++) {
fullList.add(jars[x]);
}
}
}
}
- return (String[])fullList.toArray(new String[0]);
- }
-
-
-
- public static List findClassesThatExtend(Class[] superClasses, boolean innerClasses) throws IOException, ClassNotFoundException
-
- {
+ return (String[]) fullList.toArray(new String[0]);
+ }
+ public static List findClassesThatExtend(
+ Class[] superClasses,
+ boolean innerClasses)
+ throws IOException, ClassNotFoundException {
List listPaths = null;
ArrayList listClasses = null;
List listSuperClasses = null;
- String[] strPathsOrJars = JMeterUtils.split(JMeterUtils.getPropDefault(
- "search_paths", ".;ApacheJMeter.jar"), ";");
+ String[] strPathsOrJars =
+ JMeterUtils.split(
+ JMeterUtils.getPropDefault("search_paths", ".;ApacheJMeter.jar"),
+ ";");
strPathsOrJars = addJarsInPath(strPathsOrJars);
- if (catClass.isDebugEnabled())
- {
- for (int k = 0; k < strPathsOrJars.length; k++)
- {
+ if (catClass.isDebugEnabled()) {
+ for (int k = 0; k < strPathsOrJars.length; k++) {
catClass.debug("strPathsOrJars : " + strPathsOrJars[k]);
}
}
listPaths = getClasspathMatches(strPathsOrJars);
- if (catClass.isDebugEnabled())
- {
+ if (catClass.isDebugEnabled()) {
Iterator tIter = listPaths.iterator();
- for (; tIter.hasNext(); )
- {
+ for (; tIter.hasNext();) {
catClass.debug("listPaths : " + tIter.next());
}
}
listClasses = new ArrayList();
listSuperClasses = new ArrayList();
- for (int i = 0; i < superClasses.length; i++)
- {
+ for (int i = 0; i < superClasses.length; i++) {
listSuperClasses.add(superClasses[i].getName());
}
// first get all the classes
findClassesInPaths(listPaths, listClasses);
- if (catClass.isDebugEnabled())
- {
+ if (catClass.isDebugEnabled()) {
Iterator tIter = listClasses.iterator();
- for (; tIter.hasNext(); )
- {
+ for (; tIter.hasNext();) {
catClass.debug("listClasses : " + tIter.next());
}
}
- List subClassList = findAllSubclasses(listSuperClasses, listClasses, innerClasses);
-
+ List subClassList =
+ findAllSubclasses(listSuperClasses, listClasses, innerClasses);
return subClassList;
-
}
-
-
-
-
-
/************************************************************
-
+
* Convenience method to <code>findClassesByInterface(String[], Class[],
-
+
* boolean)</code> with option to include inner classes in the search set to
-
+
* false
-
+
*
-
+
*@param interfaces Array of interfaces to search for.
-
+
*@param strPathsOrJars paths and jars to search
-
+
*@return ArrayList containing discovered classes.
-
+
*@exception IOException
-
+
*@exception ClassNotFoundException !ToDo (Exception description)
-
+
***********************************************************/
-
- public static ArrayList findClassesByInterface(String[] strPathsOrJars,
-
- Class[] interfaces) throws IOException, ClassNotFoundException
-
- {
-
+ public static ArrayList findClassesByInterface(
+ String[] strPathsOrJars,
+ Class[] interfaces)
+ throws IOException, ClassNotFoundException {
return findClassesByInterface(strPathsOrJars, interfaces, false);
-
}
-
-
-
/************************************************************
-
+
* Find classes in the provided path(s)/jar(s) that implement the
-
+
* interface(s).
-
+
*
-
+
*@param interfaces Array of interfaces to search for.
-
+
*@param strPathsOrJars paths and jars to search
-
+
*@param innerClasses Indicate whether the search includes
-
+
* inner classes
-
+
*@return ArrayList containing discovered classes.
-
+
*@exception IOException
-
+
*@exception ClassNotFoundException
-
+
***********************************************************/
-
-
-
- public static ArrayList findClassesByInterface(String[] strPathsOrJars, Class[] interfaces, boolean innerClasses) throws IOException, ClassNotFoundException
-
- {
-
-
-
+ public static ArrayList findClassesByInterface(
+ String[] strPathsOrJars,
+ Class[] interfaces,
+ boolean innerClasses)
+ throws IOException, ClassNotFoundException {
List listPaths = null;
-
-
-
ArrayList listClasses = null;
-
-
-
ArrayList listClassesWithInterface = null;
-
-
-
String strClassName = null;
-
-
-
Iterator iterClasses = null;
-
-
-
Class tempClass = null;
-
-
-
boolean foundIt;
-
-
-
int i;
-
-
-
listPaths = getClasspathMatches(strPathsOrJars);
-
-
-
listClasses = new ArrayList();
-
-
-
// first get all the classes
-
-
-
findClassesInPaths(listPaths, listClasses);
-
-
-
// then filter by the specified interfaces;
-
-
-
// if the array is null or empty, keep all classes
-
-
-
- if (interfaces == null || interfaces.length == 0)
-
- {
-
-
-
+ if (interfaces == null || interfaces.length == 0) {
listClassesWithInterface = listClasses;
-
- }
-
-
-
- else
-
- {
-
-
-
+ } else {
// make a copy of the ArrayList, and remove all classes that
-
-
-
// don't implement one of the interefaces
-
-
-
- listClassesWithInterface = (ArrayList)listClasses.clone();
-
-
-
+ listClassesWithInterface = (ArrayList) listClasses.clone();
iterClasses = listClasses.iterator();
-
-
-
- while (iterClasses.hasNext())
-
- {
-
-
-
- strClassName = (String)iterClasses.next();
-
-
-
+ while (iterClasses.hasNext()) {
+ strClassName = (String) iterClasses.next();
foundIt = false;
-
-
-
// only check classes if they are not inner classes
-
// or we intend to check for inner classes
-
- if ((strClassName.indexOf("$") == -1) || innerClasses)
-
- {
-
+ if ((strClassName.indexOf("$") == -1) || innerClasses) {
// might throw an exception, assume this is ignorable
-
-
-
- try
-
- {
-
-
-
+ try {
tempClass = Class.forName(strClassName);
-
-
-
- for (i = 0; i < interfaces.length; i++)
-
- {
-
-
-
- if (classImplementsInterface(tempClass, interfaces[i]))
-
- {
-
-
-
+ for (i = 0; i < interfaces.length; i++) {
+ if (classImplementsInterface(tempClass, interfaces[i])) {
foundIt = true;
-
-
-
break;
-
}
-
-
-
}
-
-
-
- }
-
-
-
- catch (Throwable ignored)
-
- {
-
- }
-
-
-
+ } catch (Throwable ignored) {}
}
-
-
-
- if (!foundIt)
-
- {
-
-
-
+ if (!foundIt) {
listClassesWithInterface.remove(strClassName);
-
}
-
-
-
}
-
-
-
}
-
-
-
// listClassesWithInterface only contains classes that directly
-
-
-
// implement the interface(s); to get all classes we need
-
-
-
// subclasses of these, too
-
-
-
return findAllSubclasses(listClassesWithInterface, listClasses, innerClasses);
-
}
-
-
-
-
-
- private static List getClasspathMatches(String[] strPathsOrJars)
- {
+ private static List getClasspathMatches(String[] strPathsOrJars) {
ArrayList listPaths = null;
StringTokenizer stPaths = null;
String strPath = null;
int i;
listPaths = new ArrayList();
- stPaths = new StringTokenizer(System.getProperty("java.class.path"), System.getProperty("path.separator"));
- if (strPathsOrJars != null)
- {
+ stPaths =
+ new StringTokenizer(
+ System.getProperty("java.class.path"),
+ System.getProperty("path.separator"));
+ if (strPathsOrJars != null) {
strPathsOrJars = fixDotDirs(strPathsOrJars);
strPathsOrJars = fixSlashes(strPathsOrJars);
strPathsOrJars = fixEndingSlashes(strPathsOrJars);
}
// find all jar files or paths that end with strPathOrJar
- while (stPaths.hasMoreTokens())
- {
- strPath = fixDotDir((String)stPaths.nextToken());
+ while (stPaths.hasMoreTokens()) {
+ strPath = fixDotDir((String) stPaths.nextToken());
strPath = fixSlashes(strPath);
strPath = fixEndingSlashes(strPath);
- if (strPathsOrJars == null)
- {
+ if (strPathsOrJars == null) {
listPaths.add(strPath);
- }
- else
- {
- for (i = 0; i < strPathsOrJars.length; i++)
- {
- if (catClass.isDebugEnabled())
- {
+ } else {
+ for (i = 0; i < strPathsOrJars.length; i++) {
+ if (catClass.isDebugEnabled()) {
catClass.debug("strPath(lower) : " + strPath.toLowerCase());
catClass.debug("strPathsOrJars[" + i + "] : " + strPathsOrJars[i]);
}
- if (strPath.endsWith(strPathsOrJars[i]))
- {
+ if (strPath.endsWith(strPathsOrJars[i])) {
catClass.debug("match!!!");
listPaths.add(strPath);
}
@@ -625,704 +378,301 @@
}
return listPaths;
}
-
-
- /************************************************************
-
+
+ /************************************************************
* Get all interfaces that the class implements, including parent interfaces.
-
- * This keeps us from having to instantiate and check instanceof, which
-
- * wouldn't work anyway since instanceof requires a hard-coded class or
-
- * interface name.
-
- *
-
- *@param theClass the class to get interfaces for
-
- *@param hInterfaces a Map to store the discovered interfaces in
-
+ * This keeps us from having to instantiate and check instanceof, which
+ * wouldn't work anyway since instanceof requires a hard-coded class or
+ * interface name.
+ *
+ *@param theClass the class to get interfaces for
+ *@param hInterfaces a Map to store the discovered interfaces in
***********************************************************/
-
-
-
- private static void getAllInterfaces(Class theClass, Map hInterfaces)
-
- {
-
-
-
+ private static void getAllInterfaces(Class theClass, Map hInterfaces) {
Class[] interfaces = theClass.getInterfaces();
-
-
-
- for (int i = 0; i < interfaces.length; i++)
-
- {
-
-
-
+ for (int i = 0; i < interfaces.length; i++) {
hInterfaces.put(interfaces[i].getName(), interfaces[i]);
-
-
-
getAllInterfaces(interfaces[i], hInterfaces);
-
-
-
}
-
-
-
}
-
-
-
-
-
- private static String[] fixDotDirs(String[] paths)
- {
- for (int i = 0; i < paths.length; i++)
- {
+ private static String[] fixDotDirs(String[] paths) {
+ for (int i = 0; i < paths.length; i++) {
paths[i] = fixDotDir(paths[i]);
}
return paths;
}
-
- private static String fixDotDir(String path)
- {
- if (path != null && path.equals("."))
- {
+ private static String fixDotDir(String path) {
+ if (path != null && path.equals(".")) {
return System.getProperty("user.dir");
- }
- else
- {
+ } else {
return path.trim();
}
}
-
-
-
-
-
- private static String[] fixEndingSlashes(String[] strings)
-
- {
-
+ private static String[] fixEndingSlashes(String[] strings) {
String[] strNew = new String[strings.length];
-
- for (int i = 0; i < strings.length; i++)
-
- {
-
+ for (int i = 0; i < strings.length; i++) {
strNew[i] = fixEndingSlashes(strings[i]);
-
}
-
return strNew;
-
}
-
-
-
- private static String fixEndingSlashes(String string)
-
- {
-
- if (string.endsWith("/") || string.endsWith("\\"))
-
- {
-
+ private static String fixEndingSlashes(String string) {
+ if (string.endsWith("/") || string.endsWith("\\")) {
string = string.substring(0, string.length() - 1);
-
string = fixEndingSlashes(string);
-
}
-
return string;
-
}
-
-
-
- private static String[] fixSlashes(String[] strings)
-
- {
-
+ private static String[] fixSlashes(String[] strings) {
String[] strNew = new String[strings.length];
-
- for (int i = 0; i < strings.length; i++)
-
- {
-
- strNew[i] = fixSlashes(strings[i])/*.toLowerCase()*/;
-
+ for (int i = 0; i < strings.length; i++) {
+ strNew[i] = fixSlashes(strings[i]) /*.toLowerCase()*/;
}
-
-
-
return strNew;
-
}
-
-
-
-
-
- private static String fixSlashes(String str)
-
- {
-
-
-
+ private static String fixSlashes(String str) {
// replace \ with /
-
-
-
str = str.replace('\\', '/');
-
-
-
// compress multiples into singles;
-
-
-
// do in 2 steps with dummy string
-
-
-
// to avoid infinte loop
-
-
-
str = replaceString(str, "//", "_____");
-
-
-
str = replaceString(str, "_____", "/");
-
-
-
return str;
-
}
-
-
-
-
-
- private static String replaceString(String s, String strToFind, String strToReplace)
-
- {
-
-
-
+ private static String replaceString(
+ String s,
+ String strToFind,
+ String strToReplace) {
int index;
-
-
-
int currentPos;
-
-
-
StringBuffer buffer = null;
-
-
-
- if (s.indexOf(strToFind) == -1)
-
- {
-
-
-
+ if (s.indexOf(strToFind) == -1) {
return s;
-
}
-
-
-
currentPos = 0;
-
-
-
buffer = new StringBuffer();
-
-
-
- while (true)
-
- {
-
-
-
+ while (true) {
index = s.indexOf(strToFind, currentPos);
-
-
-
- if (index == -1)
-
- {
-
-
-
+ if (index == -1) {
break;
-
}
-
-
-
buffer.append(s.substring(currentPos, index));
-
-
-
buffer.append(strToReplace);
-
-
-
currentPos = index + strToFind.length();
-
-
-
}
-
-
-
buffer.append(s.substring(currentPos));
-
-
-
return buffer.toString();
-
}
-
-
-
-
-
/************************************************************
-
+
* Determine if the class implements the interface.
-
+
*
-
+
*@param theClass the class to check
-
+
*@param theInterface the interface to look for
-
+
*@return boolean true if it implements
-
+
***********************************************************/
-
-
-
- private static boolean classImplementsInterface(Class theClass, Class theInterface)
-
- {
-
-
-
+ private static boolean classImplementsInterface(
+ Class theClass,
+ Class theInterface) {
HashMap mapInterfaces = new HashMap();
-
-
-
String strKey = null;
-
-
-
// pass in the map by reference since the method is recursive
-
-
-
getAllInterfaces(theClass, mapInterfaces);
-
-
-
Iterator iterInterfaces = mapInterfaces.keySet().iterator();
-
-
-
- while (iterInterfaces.hasNext())
-
- {
-
-
-
- strKey = (String)iterInterfaces.next();
-
-
-
- if (mapInterfaces.get(strKey) == theInterface)
-
- {
-
-
-
+ while (iterInterfaces.hasNext()) {
+ strKey = (String) iterInterfaces.next();
+ if (mapInterfaces.get(strKey) == theInterface) {
return true;
-
}
-
-
-
}
-
-
-
return false;
-
}
-
-
-
/************************************************************
-
+
* Convenience method for <code>findAllSubclasses(List, List, boolean)</code>
-
+
* with the option to include inner classes in the search set to false
-
+
*
-
+
*@param listSuperClasses the base classes to find subclasses for
-
+
*@param listAllClasses the collection of classes to search in
-
+
*@return ArrayList of the subclasses
-
+
***********************************************************/
-
-
-
- private static ArrayList findAllSubclasses(List listSuperClasses, List listAllClasses)
-
- {
-
+ private static ArrayList findAllSubclasses(
+ List listSuperClasses,
+ List listAllClasses) {
return findAllSubclasses(listSuperClasses, listAllClasses, false);
-
}
-
-
-
/************************************************************
-
+
* Finds all classes that extend the classes in the listSuperClasses
-
+
* ArrayList, searching in the listAllClasses ArrayList.
-
+
*
-
+
*@param listSuperClasses the base classes to find subclasses for
-
+
*@param listAllClasses the collection of classes to search in
-
+
*@param innerClasses indicate whether to include inner classes in the
-
+
* search
-
+
*@return ArrayList of the subclasses
-
+
***********************************************************/
-
-
-
- private static ArrayList findAllSubclasses(List listSuperClasses, List listAllClasses, boolean innerClasses)
-
- {
-
-
-
+ private static ArrayList findAllSubclasses(
+ List listSuperClasses,
+ List listAllClasses,
+ boolean innerClasses) {
Iterator iterClasses = null;
-
-
-
ArrayList listSubClasses = null;
-
-
-
String strClassName = null;
-
-
-
Class tempClass = null;
-
-
-
listSubClasses = new ArrayList();
-
-
-
iterClasses = listSuperClasses.iterator();
-
-
-
- while (iterClasses.hasNext())
-
- {
-
-
-
- strClassName = (String)iterClasses.next();
-
-
-
+ while (iterClasses.hasNext()) {
+ strClassName = (String) iterClasses.next();
// only check classes if they are not inner classes
-
// or we intend to check for inner classes
-
- if ((strClassName.indexOf("$") == -1) || innerClasses)
-
- {
-
+ if ((strClassName.indexOf("$") == -1) || innerClasses) {
// might throw an exception, assume this is ignorable
-
-
-
- try
-
- {
-
-
-
+ try {
tempClass = Class.forName(strClassName);
-
-
-
- findAllSubclassesOneClass(tempClass, listAllClasses, listSubClasses, innerClasses);
-
- // call by reference - recursive
-
-
-
- }
-
-
-
- catch (Throwable ignored)
-
- {
-
- }
-
-
-
+ findAllSubclassesOneClass(
+ tempClass,
+ listAllClasses,
+ listSubClasses,
+ innerClasses);
+ // call by reference - recursive
+ } catch (Throwable ignored) {}
}
-
-
-
}
-
-
-
return listSubClasses;
-
}
-
-
-
/************************************************************
-
+
* Convenience method for <code>findAllSubclassesOneClass(Class, List, List,
-
+
* boolean)</code> with option to include inner classes in the search set to
-
+
* false
-
+
*
-
+
*@param theClass the parent class
-
+
*@param listAllClasses the collection of classes to search in
-
+
*@param listSubClasses the collection of discovered subclasses
-
+
***********************************************************/
-
-
-
- private static void findAllSubclassesOneClass(Class theClass,
-
- List listAllClasses, List listSubClasses)
-
- {
-
- findAllSubclassesOneClass(theClass, listAllClasses,
-
- listSubClasses, false);
-
+ private static void findAllSubclassesOneClass(
+ Class theClass,
+ List listAllClasses,
+ List listSubClasses) {
+ findAllSubclassesOneClass(theClass, listAllClasses, listSubClasses, false);
}
-
-
-
/************************************************************
-
+
* Finds all classes that extend the class, searching in the listAllClasses
-
+
* ArrayList.
-
+
*
-
+
*@param theClass the parent class
-
+
*@param listAllClasses the collection of classes to search in
-
+
*@param listSubClasses the collection of discovered subclasses
-
+
*@param innerClasses indicates whether inners classes should be included
-
+
* in the search
-
+
***********************************************************/
-
-
-
- private static void findAllSubclassesOneClass(Class theClass,
-
- List listAllClasses, List listSubClasses, boolean innerClasses)
-
- {
-
+ private static void findAllSubclassesOneClass(
+ Class theClass,
+ List listAllClasses,
+ List listSubClasses,
+ boolean innerClasses) {
Iterator iterClasses = null;
-
String strClassName = null;
-
String strSuperClassName = null;
-
Class c = null;
-
Class cParent = null;
-
boolean bIsSubclass = false;
-
strSuperClassName = theClass.getName();
-
iterClasses = listAllClasses.iterator();
-
- while (iterClasses.hasNext())
-
- {
-
- strClassName = (String)iterClasses.next();
-
+ while (iterClasses.hasNext()) {
+ strClassName = (String) iterClasses.next();
// only check classes if they are not inner classes
-
// or we intend to check for inner classes
-
- if ((strClassName.indexOf("$") == -1) || innerClasses)
-
- {
-
+ if ((strClassName.indexOf("$") == -1) || innerClasses) {
// might throw an exception, assume this is ignorable
-
- try
-
- {
-
- // Class.forName() doesn't like nulls
- if(strClassName == null) continue;
-
+ try {
+ // Class.forName() doesn't like nulls
+ if (strClassName == null)
+ continue;
c = Class.forName(strClassName);
-
- if (!c.isInterface() && !Modifier.isAbstract(c.getModifiers()))
-
- {
-
+ if (!c.isInterface() && !Modifier.isAbstract(c.getModifiers())) {
bIsSubclass = theClass.isAssignableFrom(c);
-
- }
-
- else
-
- {
-
+ } else {
bIsSubclass = false;
-
}
-
- if (bIsSubclass)
-
- {
-
+ if (bIsSubclass) {
listSubClasses.add(strClassName);
-
}
-
- }
-
- catch (Throwable ignored)
-
- {
-
- }
-
+ } catch (Throwable ignored) {}
}
-
}
-
}
-
-
-
/************************************************************
-
+
* Converts a class file from the text stored in a Jar file to a version that
-
+
* can be used in Class.forName().
-
+
*
-
+
*@param strClassName the class name from a Jar file
-
+
*@return String the Java-style dotted version of the name
-
+
***********************************************************/
-
-
-
- private static String fixClassName(String strClassName)
-
- {
-
-
-
+ private static String fixClassName(String strClassName) {
strClassName = strClassName.replace('\\', '.');
-
-
-
strClassName = strClassName.replace('/', '.');
-
-
-
strClassName = strClassName.substring(0, strClassName.length() - 6);
-
// remove ".class"
-
-
-
return strClassName;
-
}
-
-
-
-
-
/************************************************************
-
+
* Description of the Method
-
+
*
-
+
*@param strPath Description of Parameter
-
+
*@param listClasses Description of Parameter
-
+
*@exception IOException Description of Exception
-
+
***********************************************************/
-
-
-
- private static void findClassesInOnePath(String strPath, List listClasses) throws IOException
- {
+ private static void findClassesInOnePath(String strPath, List listClasses)
+ throws IOException {
File file = null;
String strPathName = null;
ZipFile zipFile = null;
@@ -1330,249 +680,139 @@
Enumeration entries = null;
String strEntry = null;
file = new File(strPath);
- if (file.isDirectory())
- {
+ if (file.isDirectory()) {
findClassesInPathsDir(strPath, file, listClasses);
- }
- else if (file.exists())
- {
- zipFile = new ZipFile(file);
- entries = zipFile.entries();
- while (entries.hasMoreElements())
- {
- strEntry = entries.nextElement().toString();
- if (strEntry.endsWith(".class"))
- {
- listClasses.add(fixClassName(strEntry));
+ } else
+ if (file.exists()) {
+ zipFile = new ZipFile(file);
+ entries = zipFile.entries();
+ while (entries.hasMoreElements()) {
+ strEntry = entries.nextElement().toString();
+ if (strEntry.endsWith(".class")) {
+ listClasses.add(fixClassName(strEntry));
+ }
}
}
- }
}
-
-
-
-
-
/************************************************************
-
+
* Description of the Method
-
+
*
-
+
*@param listPaths Description of Parameter
-
+
*@param listClasses Description of Parameter
-
+
*@exception IOException Description of Exception
-
+
***********************************************************/
-
-
-
- private static void findClassesInPaths(List listPaths, List listClasses) throws IOException
-
- {
-
-
-
+ private static void findClassesInPaths(List listPaths, List listClasses)
+ throws IOException {
Iterator iterPaths = listPaths.iterator();
-
-
-
- while (iterPaths.hasNext())
-
- {
-
-
-
- findClassesInOnePath((String)iterPaths.next(), listClasses);
-
-
-
+ while (iterPaths.hasNext()) {
+ findClassesInOnePath((String) iterPaths.next(), listClasses);
}
-
-
-
}
-
-
-
-
-
/************************************************************
-
+
* Description of the Method
-
+
*
-
+
*@param strPathElement Description of Parameter
-
+
*@param dir Description of Parameter
-
+
*@param listClasses Description of Parameter
-
+
*@exception IOException Description of Exception
-
+
***********************************************************/
-
-
-
- private static void findClassesInPathsDir(String strPathElement, File dir, List listClasses) throws IOException
- {
+ private static void findClassesInPathsDir(
+ String strPathElement,
+ File dir,
+ List listClasses)
+ throws IOException {
File file = null;
String[] list = dir.list();
- for (int i = 0; i < list.length; i++)
- {
+ for (int i = 0; i < list.length; i++) {
file = new File(dir, list[i]);
- if (file.isDirectory())
- {
+ if (file.isDirectory()) {
findClassesInPathsDir(strPathElement, file, listClasses);
- }
- else if (file.exists() && (file.length() != 0) && list[i].endsWith(".class"))
- {
- listClasses.add(file.getPath().substring(strPathElement.length() + 1,
- file.getPath().lastIndexOf(".")).replace(File.separator.charAt(0), '.'));
- }
+ } else
+ if (file.exists() && (file.length() != 0) && list[i].endsWith(".class")) {
+ listClasses.add(
+ file
+ .getPath()
+ .substring(strPathElement.length() + 1, file.getPath().lastIndexOf("."))
+ .replace(File.separator.charAt(0), '.'));
+ }
}
}
-
-
-
/************************************************************
-
+
* !ToDo (Class description)
-
+
*
-
+
*@author $Author: mstover1 $
-
- *@created $Date: 2002/04/29 17:08:14 $
-
- *@version $Revision: 1.3 $
-
+
+ *@created $Date: 2002/05/01 01:39:40 $
+
+ *@version $Revision: 1.4 $
+
***********************************************************/
-
- public static class Test extends TestCase
-
- {
-
+ public static class Test extends TestCase {
/************************************************************
-
+
* !ToDo (Constructor description)
-
+
*
-
+
*@param name !ToDo (Parameter description)
-
+
***********************************************************/
-
- public Test(String name)
-
- {
-
+ public Test(String name) {
super(name);
-
}
-
-
-
// For a given testPath, get the name of the classes in the path and its
-
// subpaths. Append the first class name found to the testPath to ensure
-
// that the file is found.
-
/************************************************************
-
+
* !ToDo
-
+
***********************************************************/
-
- public void testFindClassesInPaths()
-
- {
-
+ public void testFindClassesInPaths() {
String testPath = System.getProperty("user.dir") + "/bin/classes";
-
List listPaths = new ArrayList();
-
ArrayList listClasses = new ArrayList();
-
// listPaths will contain the path/jars where all classes will be listed
-
listPaths.add(testPath);
-
- try
-
- {
-
+ try {
findClassesInPaths(listPaths, listClasses);
-
- }
-
- catch (IOException e)
-
- {
-
+ } catch (IOException e) {
fail("IOException thrown");
-
}
-
Iterator iter = listClasses.iterator();
-
- if (iter.hasNext())
-
- {
-
+ if (iter.hasNext()) {
String fullname = null;
-
// check if file exist
-
String fileSeparator = System.getProperty("file.separator");
-
- String filename = (String)iter.next();
-
+ String filename = (String) iter.next();
filename = filename.replace('.', fileSeparator.charAt(0));
-
- if (testPath.endsWith(fileSeparator))
-
- {
-
+ if (testPath.endsWith(fileSeparator)) {
fullname = testPath + filename + ".class";
-
- }
-
- else
-
- {
-
+ } else {
fullname = testPath + fileSeparator + filename + ".class";
-
}
-
File file = new File(fullname);
-
this.assertTrue(fullname + " is not a file", file.isFile());
-
- }
-
- else
-
- {
-
+ } else {
// if testPath is empty, fail the test
-
- fail(testPath +
-
- " is empty. Please choose a path which has at least one file");
-
+ fail(testPath + " is empty. Please choose a path which has at least one file");
}
-
}
-
}
-
-}
-
-
-
+}
\ No newline at end of file
1.3 +18 -45 jakarta-jmeter/src_1/org/apache/jmeter/util/SearchByClass.java
Index: SearchByClass.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/util/SearchByClass.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SearchByClass.java 30 Apr 2002 02:41:32 -0000 1.2
+++ SearchByClass.java 1 May 2002 01:39:40 -0000 1.3
@@ -1,7 +1,5 @@
package org.apache.jmeter.util;
-
import java.util.*;
-
/**
* <p>Title: </p>
* <p>Description: </p>
@@ -10,69 +8,44 @@
* @author unascribed
* @version 1.0
*/
-
-public class SearchByClass implements ListedHashTreeVisitor
-{
+public class SearchByClass implements ListedHashTreeVisitor {
List objectsOfClass = new LinkedList();
Map subTrees = new HashMap();
Class searchClass = null;
-
- public SearchByClass()
- {
- }
-
- public SearchByClass(Class searchClass)
- {
+ public SearchByClass() {}
+ public SearchByClass(Class searchClass) {
this.searchClass = searchClass;
}
-
- public Collection getSearchResults()
- {
+ public Collection getSearchResults() {
return objectsOfClass;
}
-
- public ListedHashTree getSubTree(Object root)
- {
- return (ListedHashTree)subTrees.get(root);
+ public ListedHashTree getSubTree(Object root) {
+ return (ListedHashTree) subTrees.get(root);
}
-
- public void addNode(Object node,ListedHashTree subTree)
- {
- if(node.getClass().isAssignableFrom(searchClass))
- {
+ public void addNode(Object node, ListedHashTree subTree) {
+ if (node.getClass().isAssignableFrom(searchClass)) {
objectsOfClass.add(node);
ListedHashTree tree = new ListedHashTree(node);
- tree.set(node,subTree);
- subTrees.put(node,tree);
+ tree.set(node, subTree);
+ subTrees.put(node, tree);
}
}
-
- public static class Test extends junit.framework.TestCase
- {
- public Test(String name)
- {
+ public static class Test extends junit.framework.TestCase {
+ public Test(String name) {
super(name);
}
-
- public void testSearch() throws Exception
- {
+ public void testSearch() throws Exception {
ListedHashTree tree = new ListedHashTree();
SearchByClass searcher = new SearchByClass(Integer.class);
String one = "one";
String two = "two";
Integer o = new Integer(1);
- tree.add(one,o);
- tree.get(one).add(o,two);
+ tree.add(one, o);
+ tree.get(one).add(o, two);
tree.traverse(searcher);
- assertEquals(1,searcher.getSearchResults().size());
+ assertEquals(1, searcher.getSearchResults().size());
}
}
-
- public void subtractNode()
- {
- }
-
- public void processPath()
- {
- }
+ public void subtractNode() {}
+ public void processPath() {}
}
1.6 +2 -13 jakarta-jmeter/src_1/org/apache/jmeter/visualizers/AssertionVisualizer.java
Index: AssertionVisualizer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/visualizers/AssertionVisualizer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AssertionVisualizer.java 29 Apr 2002 17:08:15 -0000 1.5
+++ AssertionVisualizer.java 1 May 2002 01:39:40 -0000 1.6
@@ -72,7 +72,7 @@
* Apache
*
*@author Michael Stover
- *@created $Date: 2002/04/29 17:08:15 $
+ *@created $Date: 2002/05/01 01:39:40 $
*@version 1.0
***************************************/
@@ -103,18 +103,6 @@
/****************************************
* !ToDo (Method description)
*
- *@return !ToDo (Return description)
- ***************************************/
- public TestElement createTestElement()
- {
- ResultCollector collector = new ResultCollector();
- configureTestElement(collector);
- return collector;
- }
-
- /****************************************
- * !ToDo (Method description)
- *
*@param sample !ToDo (Parameter description)
***************************************/
public void add(SampleResult sample)
@@ -177,6 +165,7 @@
// NAME
mainPanel.add(getNamePanel());
+ mainPanel.add(getFilePanel());
// TEXTAREA LABEL
JLabel textAreaLabel = new JLabel(JMeterUtils.getResString("assertion_textarea_label"));
1.5 +2 -2 jakarta-jmeter/src_1/org/apache/jmeter/visualizers/GraphAccumVisualizer.java
Index: GraphAccumVisualizer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/visualizers/GraphAccumVisualizer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- GraphAccumVisualizer.java 29 Apr 2002 17:08:15 -0000 1.4
+++ GraphAccumVisualizer.java 1 May 2002 01:39:40 -0000 1.5
@@ -72,7 +72,7 @@
*
*@author Khor Soon Hin
*@created 2001/08/11
- *@version $Revision: 1.4 $ $Date: 2002/04/29 17:08:15 $
+ *@version $Revision: 1.5 $ $Date: 2002/05/01 01:39:40 $
***************************************/
public class GraphAccumVisualizer extends AbstractVisualizer
implements ImageVisualizer, GraphAccumListener,Clearable
@@ -229,8 +229,8 @@
panelTitleLabel.setFont(new Font(curFont.getFontName(), curFont.getStyle(), curFontSize));
mainPanel.add(panelTitleLabel);
-
mainPanel.add(this.getNamePanel());
+ mainPanel.add(getFilePanel());
JScrollPane graphScrollPanel = new
JScrollPane(graph, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
1.5 +4 -3 jakarta-jmeter/src_1/org/apache/jmeter/visualizers/SplineVisualizer.java
Index: SplineVisualizer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/visualizers/SplineVisualizer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SplineVisualizer.java 29 Apr 2002 17:08:15 -0000 1.4
+++ SplineVisualizer.java 1 May 2002 01:39:40 -0000 1.5
@@ -70,7 +70,7 @@
* GraphVisualizer.
*
*@author <a href="mailto:norguet@bigfoot.com">Jean-Pierre Norguet</a>
- *@created $Date: 2002/04/29 17:08:15 $
+ *@created $Date: 2002/05/01 01:39:40 $
*@version 0.9.1
***************************************/
public class SplineVisualizer extends AbstractVisualizer implements ImageVisualizer,
@@ -178,6 +178,7 @@
// NAME
mainPanel.add(getNamePanel());
+ mainPanel.add(getFilePanel());
maximumLabel = new JLabel(JMeterUtils.getResString("spline_visualizer_maximum"));
maximumLabel.setForeground(MAXIMUM_COLOR);
maximumLabel.setBackground(backColor);
@@ -358,8 +359,8 @@
* Component showing a Spline curve.
*
*@author $Author: mstover1 $
- *@created $Date: 2002/04/29 17:08:15 $
- *@version $Revision: 1.4 $
+ *@created $Date: 2002/05/01 01:39:40 $
+ *@version $Revision: 1.5 $
***************************************/
public class SplineGraph extends JComponent
{
1.5 +8 -7 jakarta-jmeter/src_1/org/apache/jmeter/visualizers/StatVisualizer.java
Index: StatVisualizer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/visualizers/StatVisualizer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StatVisualizer.java 29 Apr 2002 17:08:15 -0000 1.4
+++ StatVisualizer.java 1 May 2002 01:39:40 -0000 1.5
@@ -81,7 +81,7 @@
* Company: Apache Foundation
*
*@author James Boutcher
- *@created $Date: 2002/04/29 17:08:15 $
+ *@created $Date: 2002/05/01 01:39:40 $
*@version 1.0
***************************************/
@@ -365,6 +365,7 @@
panelTitleLabel.setFont(new Font(curFont.getFontName(), curFont.getStyle(), curFontSize));
mainPanel.add(panelTitleLabel);
+ mainPanel.add(getFilePanel());
myStatTableModel = new StatTableModel();
@@ -393,8 +394,8 @@
* support our dynamically-sizing TableModel for this visualizer.
*
*@author $Author: mstover1 $
- *@created $Date: 2002/04/29 17:08:15 $
- *@version $Revision: 1.4 $
+ *@created $Date: 2002/05/01 01:39:40 $
+ *@version $Revision: 1.5 $
***************************************/
class SortFilterModel extends AbstractTableModel
@@ -579,8 +580,8 @@
* !ToDo (Class description)
*
*@author $Author: mstover1 $
- *@created $Date: 2002/04/29 17:08:15 $
- *@version $Revision: 1.4 $
+ *@created $Date: 2002/05/01 01:39:40 $
+ *@version $Revision: 1.5 $
***************************************/
private class Row implements Comparable
{
@@ -629,8 +630,8 @@
* Class which implements the model for our main table in this visualizer.
*
*@author $Author: mstover1 $
- *@created $Date: 2002/04/29 17:08:15 $
- *@version $Revision: 1.4 $
+ *@created $Date: 2002/05/01 01:39:40 $
+ *@version $Revision: 1.5 $
***************************************/
class StatTableModel extends AbstractTableModel
1.5 +2 -1 jakarta-jmeter/src_1/org/apache/jmeter/visualizers/TableVisualizer.java
Index: TableVisualizer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/visualizers/TableVisualizer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TableVisualizer.java 29 Apr 2002 17:08:15 -0000 1.4
+++ TableVisualizer.java 1 May 2002 01:39:40 -0000 1.5
@@ -72,7 +72,7 @@
*
*@author <a href="mailto:alf@i100.no">Alf Hogemark</a>
*@created March 10, 2002
- *@version $Revision: 1.4 $
+ *@version $Revision: 1.5 $
***************************************/
public class TableVisualizer extends AbstractVisualizer
implements GraphListener, Clearable
@@ -193,6 +193,7 @@
// NAME
mainPanel.add(getNamePanel());
+ mainPanel.add(getFilePanel());
// Set up the table itself
table = new JTable(model);
1.6 +5 -42 jakarta-jmeter/src_1/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java
Index: ViewResultsFullVisualizer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ViewResultsFullVisualizer.java 29 Apr 2002 17:08:15 -0000 1.5
+++ ViewResultsFullVisualizer.java 1 May 2002 01:39:40 -0000 1.6
@@ -70,6 +70,7 @@
import org.apache.jmeter.visualizers.gui.AbstractVisualizer;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jmeter.gui.util.VerticalLayout;
/****************************************
* Allows the tester to view the textual response from sampling an Entry. This
@@ -78,63 +79,24 @@
*
*@author Khor Soon Hin
*@created 2001/07/25
- *@version $Revision: 1.5 $ $Date: 2002/04/29 17:08:15 $
+ *@version $Revision: 1.6 $ $Date: 2002/05/01 01:39:40 $
***************************************/
public class ViewResultsFullVisualizer extends ViewResultsVisualizer implements
TreeSelectionListener
{
- /****************************************
- * !ToDo (Field description)
- ***************************************/
public final static Color SERVER_ERROR_COLOR = Color.red;
- /****************************************
- * !ToDo (Field description)
- ***************************************/
public final static Color CLIENT_ERROR_COLOR = Color.blue;
- /****************************************
- * !ToDo (Field description)
- ***************************************/
public final static Color REDIRECT_COLOR = Color.green;
- /****************************************
- * !ToDo (Field description)
- ***************************************/
protected DefaultMutableTreeNode root;
- /****************************************
- * !ToDo (Field description)
- ***************************************/
protected DefaultTreeModel treeModel;
- /****************************************
- * !ToDo (Field description)
- ***************************************/
protected GridBagLayout gridBag;
- /****************************************
- * !ToDo (Field description)
- ***************************************/
protected GridBagConstraints gbc;
- /****************************************
- * !ToDo (Field description)
- ***************************************/
protected JPanel resultPanel;
- /****************************************
- * !ToDo (Field description)
- ***************************************/
protected JScrollPane treePane;
- /****************************************
- * !ToDo (Field description)
- ***************************************/
protected JScrollPane resultPane;
- /****************************************
- * !ToDo (Field description)
- ***************************************/
protected JSplitPane treeSplitPane;
- /****************************************
- * !ToDo (Field description)
- ***************************************/
protected JTree jTree;
- /****************************************
- * !ToDo (Field description)
- ***************************************/
protected int childIndex;
private static Category catClass =
@@ -374,7 +336,7 @@
***************************************/
protected void init()
{
- this.setLayout(new GridLayout(1, 1));
+ this.setLayout(new BorderLayout());
catClass.debug("Start : init1");
SampleResult rootSampleResult = new SampleResult();
rootSampleResult.setSampleLabel("Root");
@@ -391,7 +353,8 @@
resultPane = new JScrollPane(resultPanel);
treeSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
treePane, resultPane);
- add(treeSplitPane);
+ add(getFilePanel(),BorderLayout.NORTH);
+ add(treeSplitPane,BorderLayout.CENTER);
catClass.debug("End : init1");
}
}
1.6 +3 -19 jakarta-jmeter/src_1/org/apache/jmeter/visualizers/ViewResultsVisualizer.java
Index: ViewResultsVisualizer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/visualizers/ViewResultsVisualizer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ViewResultsVisualizer.java 29 Apr 2002 17:08:15 -0000 1.5
+++ ViewResultsVisualizer.java 1 May 2002 01:39:40 -0000 1.6
@@ -73,15 +73,14 @@
* "Continue" button.
*
*@author $Author: mstover1 $
- *@created $Date: 2002/04/29 17:08:15 $
- *@version $Revision: 1.5 $ $Date: 2002/04/29 17:08:15 $
+ *@created $Date: 2002/05/01 01:39:40 $
+ *@version $Revision: 1.6 $ $Date: 2002/05/01 01:39:40 $
***************************************/
public class ViewResultsVisualizer extends AbstractVisualizer implements ActionListener, Clearable
{
private JTextArea display;
private JButton next;
private JTextField label;
- private ResultCollector model;
/****************************************
* !ToDo (Constructor description)
@@ -106,22 +105,6 @@
}
}
- /**
- * Method getModel.
- * @return ResultCollector
- */
- protected ResultCollector getModel()
- {
- return model;
- }
-
- public TestElement createTestElement()
- {
- model = new ResultCollector();
- configureTestElement(model);
- return model;
- }
-
public String getStaticLabel()
{
return JMeterUtils.getResString("view_results_title");
@@ -181,6 +164,7 @@
// NAME
mainPanel.add(getNamePanel());
+ mainPanel.add(getFilePanel());
// INNER PANEL
JPanel innerPanel = new JPanel();
1.7 +40 -43 jakarta-jmeter/src_1/org/apache/jmeter/visualizers/gui/AbstractVisualizer.java
Index: AbstractVisualizer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/visualizers/gui/AbstractVisualizer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractVisualizer.java 30 Apr 2002 02:41:32 -0000 1.6
+++ AbstractVisualizer.java 1 May 2002 01:39:41 -0000 1.7
@@ -4,6 +4,8 @@
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.event.*;
+
+import org.apache.jmeter.exceptions.IllegalUserActionException;
import org.apache.jmeter.gui.JMeterGUIComponent;
import org.apache.jmeter.gui.NamePanel;
import org.apache.jmeter.gui.util.MenuFactory;
@@ -13,18 +15,20 @@
import org.apache.jmeter.visualizers.Visualizer;
import org.apache.jmeter.reporters.ResultCollector;
import org.apache.jmeter.gui.util.FilePanel;
+import org.apache.jmeter.gui.util.FileDialoger;
+import org.apache.jmeter.util.JMeterUtils;
/****************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
- *@created $Date: 2002/04/30 02:41:32 $
+ *@created $Date: 2002/05/01 01:39:41 $
*@version 1.0
***************************************/
-public abstract class AbstractVisualizer extends JPanel implements JMeterGUIComponent,
- Visualizer,ChangeListener
-{
+public abstract class AbstractVisualizer
+ extends JPanel
+ implements JMeterGUIComponent, Visualizer, ChangeListener {
/****************************************
* !ToDo (Field description)
@@ -36,20 +40,21 @@
/****************************************
* !ToDo (Constructor description)
***************************************/
- public AbstractVisualizer()
- {
+ public AbstractVisualizer() {
namePanel = new NamePanel();
filePanel = new FilePanel(this);
setName(getStaticLabel());
}
- protected NamePanel getNamePanel()
- {
+ protected NamePanel getNamePanel() {
return namePanel;
}
- protected FilePanel getFilePanel()
- {
+ protected ResultCollector getModel() {
+ return collector;
+ }
+
+ protected FilePanel getFilePanel() {
return filePanel;
}
@@ -58,8 +63,7 @@
*
*@param name !ToDo (Parameter description)
***************************************/
- public void setName(String name)
- {
+ public void setName(String name) {
super.setName(name);
namePanel.setName(name);
}
@@ -69,18 +73,15 @@
*
*@return !ToDo (Return description)
***************************************/
- public String getName()
- {
+ public String getName() {
return namePanel.getName();
}
- public void setFile(String filename)
- {
+ public void setFile(String filename) {
filePanel.setFilename(filename);
}
- public String getFile()
- {
+ public String getFile() {
return filePanel.getFilename();
}
@@ -89,15 +90,13 @@
*
*@return !ToDo (Return description)
***************************************/
- public JPopupMenu createPopupMenu()
- {
+ public JPopupMenu createPopupMenu() {
return MenuFactory.getDefaultVisualizerMenu();
}
- public void stateChanged(ChangeEvent e)
- {
+ public void stateChanged(ChangeEvent e) {
System.out.println("getting new collector");
- collector = (ResultCollector)createTestElement();
+ collector = (ResultCollector) createTestElement();
}
/****************************************
@@ -105,9 +104,8 @@
*
*@param element !ToDo (Parameter description)
***************************************/
- public void configure(TestElement element)
- {
- setName((String)element.getProperty(TestElement.NAME));
+ public void configure(TestElement element) {
+ setName((String) element.getProperty(TestElement.NAME));
}
/****************************************
@@ -115,27 +113,27 @@
*
*@return !ToDo (Return description)
***************************************/
- public Collection getMenuCategories()
- {
- return Arrays.asList(new String[]{MenuFactory.LISTENERS});
+ public Collection getMenuCategories() {
+ return Arrays.asList(new String[] { MenuFactory.LISTENERS });
}
- public TestElement createTestElement()
- {
- if(collector == null)
- {
+ public TestElement createTestElement() {
+ if (collector == null) {
collector = new ResultCollector();
}
configureTestElement(collector);
- try
- {
- if(!getFile().equals(""))
- {
- collector.setFilename(getFile());
+ try {
+ if (!getFile().equals("")) {
+ try {
+ collector.setFilename(getFile());
+ }
+ catch (IllegalUserActionException e) {
+ JMeterUtils.reportErrorToUser(e.getMessage());
+ setFile("");
+ }
}
}
- catch(IOException e)
- {
+ catch (IOException e) {
e.printStackTrace();
}
return collector;
@@ -146,11 +144,10 @@
*
*@param mc !ToDo (Parameter description)
***************************************/
- protected void configureTestElement(AbstractListenerElement mc)
- {
+ protected void configureTestElement(AbstractListenerElement mc) {
mc.setProperty(TestElement.NAME, getName());
mc.setProperty(TestElement.GUI_CLASS, this.getClass().getName());
mc.setProperty(TestElement.TEST_CLASS, mc.getClass().getName());
mc.setListener(this);
}
-}
+}
\ No newline at end of file
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>