woolfel 2005/09/05 12:45:03
Modified: src/junit/org/apache/jmeter/protocol/java/sampler Tag:
rel-2-1 JUnitSampler.java
Log:
now the sampler correctly checks for constructors that are not private
peter
Revision Changes Path
No revision
No revision
1.11.2.4 +8 -2
jakarta-jmeter/src/junit/org/apache/jmeter/protocol/java/sampler/JUnitSampler.java
Index: JUnitSampler.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/junit/org/apache/jmeter/protocol/java/sampler/JUnitSampler.java,v
retrieving revision 1.11.2.3
retrieving revision 1.11.2.4
diff -u -r1.11.2.3 -r1.11.2.4
--- JUnitSampler.java 5 Sep 2005 18:30:36 -0000 1.11.2.3
+++ JUnitSampler.java 5 Sep 2005 19:45:03 -0000 1.11.2.4
@@ -19,6 +19,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.util.Enumeration;
import junit.framework.ComparisonFailure;
@@ -392,6 +393,7 @@
Constructor con = null;
Constructor strCon = null;
Class theclazz = null;
+ Object[] strParams = null;
Object[] params = null;
try
{
@@ -416,7 +418,11 @@
if (label == null || label.length() == 0) {
label = className;
}
- params = new Object[]{label};
+ if (strCon.getModifiers() == Modifier.PUBLIC) {
+ strParams = new Object[]{label};
+ } else {
+ strCon = null;
+ }
} catch (NoSuchMethodException e) {
log.info("String constructor:: " + e.getMessage());
}
@@ -435,7 +441,7 @@
// if the string constructor is null, we use the empty
// constructor to get a new instance
if (strCon != null) {
- testclass = (TestCase)strCon.newInstance(params);
+ testclass = (TestCase)strCon.newInstance(strParams);
} else if (con != null){
testclass = (TestCase)con.newInstance(params);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]