Hi,
Based upon our suggestion, I tried using the search_path of jmeter.properties file to
control where AllTests.java will search for subclasses of TestCase. Didn't work on my
first attempt, then I realized that when running JMeter itself (NewDriver.java), the
JMeterUtils.getProperties(String) was called to load the property file. In
AllTests.java there is no similar statement, so I added
JMeterUtils.getProperties(propFile) to AllTests.java and things worked fine but you
must supply the jmeter.property filename as argument. Attached below is the new
AllTests.java with the modification.
Also during my endeavours to get the AllTests.java working with my own unit tests, I
realized that the ClassFinder.findClassesThatExtend(Class[]) method which calls
ClassFinder.findClassesInPath(List, List) would not work correctly if the
classpath/search_path contains directories with ending slash e.g.
/usr/local/jakarta-jmeter/src/. Classes found under this directory will have their
first char truncated - rg.apache.jmeter.junit.AllTests was returned instead of
org.apache.jmeter.junit.AllTests. I added methods fixEndingSlash() to ClassFinder and
called this to remove the ending slash of all directories before they are searched.
This resovled the problem. I also wrote a unit test for
ClassFinder.findClassesInPath(List, List) to show the problem. The test though had to
be written as a public static inner class of ClassFinder 'cos findClassesInPath(List,
List) is a private method and can't be accessed from outside the class. This should
not affect production 'cos the inne!
r classes is generated as a separate class i.e. ClassFinder$Test.class. During unit
testing of this class I encountered a problem because the
ClassFinder.findClassesThatExtend(Classes[]) will not look for inner classes. I made
a change to this and voila, AllTests.java will pick up this class for testing without
additional effort. To show the problem, just change the testPath variable in
ClassFinder$Test.testFindClassesInPaths() method to add a slash at the end and the
test will fail. Look at the filename generated. Remove the ending slash and the test
will success. Check the filename generated again. I've included the modified
ClassFinder below as well.
NOTE : I realized that JMeter will only pick out classes if they exist both in the
classpath and search_path.
Also I know that you are extremely tied-up as you are the only active project
member/leader so I looked into the possibility dropping extension classes into ext/ on
your behalf. I created a new UrlConfig and HTTPSampler (called UrlConfigFull and
HTTPSamplerFull) and dropped them into ext/. Added the ext/ into both classpath and
search_path. Started JMeter and I could see the option to add the new UrlConfigFull.
I stopped working after that 'cos it's very late already 1:14am. Keep you updated on
this tomorrow.
Thanks.
-----Original Message-----
From: Mike Stover <[EMAIL PROTECTED]>
Date: Tue, 10 Jul 2001 08:05:12 +0000
To: [EMAIL PROTECTED]
Subject: Re: JMeter extensions and browser emulation
> > I was about to embark on writing an extension of HTTPSampler.java to
> > automatically download images, applets etc so I wanted to write the test
> > cases first using jUnit. The src/org/apache/jmeter/junit/AllTests.java
> > automatically creates a test suite based on the classes which extend
> > TestCase in ApacheJMeter.jar. Does this mean that my new test cases has to
> > be added to the .jar even during development? I know ways to circumvent
> > this but pls help me out by telling me how you do it 'cos I would rather
> > foll w your standardized way.
>
> AllTests searches the classpath for classes that extend TestCase. But, it
> only searches those segments of the classpath that you specify (prevents
> searching sun's classes needlessly). I would suggest modifying
> jmeter.properties to include a directory or jar where you want your test
> cases to live during development. The "search_paths" property indicates
> where JMeter should look for classes. By default, it searches the current
> directory and ApacheJMeter.jar. If you want a different directory to be
> searched, add it to both your classpath and to this property. Actually, I
> think and "ext" directory under JMeter would be a good idea - people like
> yourself could add their own extensions onto JMeter. I would write the
> jmeter script file to include all jars from "ext", and I would modify
> jmeter.properties to include jakarta-jmeter/ext as a directory to search.
> That way, all elements you dropped into that directory would be found by the
> gui automatically. When you finish your new sampler, I may want to do that.
>
> Thanks for your other suggestions - I will try to incorporate them.
>
> -Mike
>
--
__________________________________________________
Get FREE 50 MB email @ http://www.AtoZasia.com
Powered by Outblaze
AllTests.java
ClassFinder.java
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]