Bug 54896 - JUnit sampler gives only “failed to create an instance of the class” message with constructor problems

Bugzilla Id: 54896

git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1476768 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Philippe Mouawad 2013-04-28 13:55:43 +00:00
parent 22ce57a68b
commit 26c54f46c7
2 changed files with 13 additions and 7 deletions

View File

@ -459,7 +459,10 @@ public class JUnitSampler extends AbstractSampler implements ThreadListener {
// we should log a warning, but allow the test to keep running
sresult.setSuccessful(false);
// this should be externalized to the properties
sresult.setResponseMessage("failed to create an instance of the class");
sresult.setResponseMessage("Failed to create an instance of the class:"+getClassname()
+", reasons may be missing both empty constructor and one "
+ "String constructor or failure to instanciate constructor,"
+ " check warning messages in jmeter log file");
sresult.setResponseCode(getErrorCode());
}
return sresult;
@ -504,7 +507,7 @@ public class JUnitSampler extends AbstractSampler implements ThreadListener {
strCon = null;
}
} catch (NoSuchMethodException e) {
log.info("String constructor:: " + e.getMessage());
log.info("Trying to find constructor with one String parameter returned error: " + e.getMessage());
}
try {
con = theclazz.getDeclaredConstructor(new Class[0]);
@ -512,7 +515,7 @@ public class JUnitSampler extends AbstractSampler implements ThreadListener {
params = new Object[]{};
}
} catch (NoSuchMethodException e) {
log.info("Empty constructor:: " + e.getMessage());
log.info("Trying to find empty constructor returned error: " + e.getMessage());
}
try {
// if the string constructor is not null, we use it.
@ -522,13 +525,15 @@ public class JUnitSampler extends AbstractSampler implements ThreadListener {
testclass = strCon.newInstance(strParams);
} else if (con != null){
testclass = con.newInstance(params);
} else {
log.error("No empty constructor nor string constructor found for class:"+theclazz);
}
} catch (InvocationTargetException e) {
log.warn(e.getMessage());
log.error("Error instanciating class:"+theclazz+":"+e.getMessage(), e);
} catch (InstantiationException e) {
log.info(e.getMessage());
log.error("Error instanciating class:"+theclazz+":"+e.getMessage(), e);
} catch (IllegalAccessException e) {
log.info(e.getMessage());
log.error("Error instanciating class:"+theclazz+":"+e.getMessage(), e);
}
}
}

View File

@ -141,7 +141,7 @@ It was therefore necessary to change the shortcut.
<li><bugzilla>54504</bugzilla> - Resource string not found: [clipboard_node_read_error]</li>
<li><bugzilla>54538</bugzilla> - GUI: context menu is too big</li>
<li><bugzilla>54847</bugzilla> - Cut &amp; Paste is broken with tree multi-selection</li>
<li><bugzilla>54870</bugzilla> - Tree D&D may lost leaf nodes (affected nightly build)</li>
<li><bugzilla>54870</bugzilla> - Tree D&amp;D may lost leaf nodes (affected nightly build)</li>
</ul>
<!-- =================== Improvements =================== -->
@ -157,6 +157,7 @@ It was therefore necessary to change the shortcut.
<li><bugzilla>54788</bugzilla> - JMS Point-to-Point Sampler - GUI enhancements to increase readability and ease of use</li>
<li><bugzilla>54798</bugzilla> - Using subject from EML-file for SMTP Sampler</li>
<li><bugzilla>54759</bugzilla> - SSLPeerUnverifiedException using HTTPS , property documented</li>
<li><bugzilla>54896</bugzilla> - JUnit sampler gives only “failed to create an instance of the class” message with constructor problems</li>
</ul>
<h3>Controllers</h3>