Failed Testcases because of Equal Check on Exception Messages

Description

When trying to build activity-engine, certain tests fail, because they use assertTextPresent() which checks, whether a resulting exception contains a previously defined text.

However, on a system with a locale other than English (UK/US), or other versions of JDK, this tests may fail, as often exceptions are localized or report differently:

Examples:

org.activiti.engine.test.bpmn.parse.BpmnParseTest, line 42

assertTextPresent("Attribute 'invalidAttribute' is not allowed to appear in element 'process'", e.getMessage());

Exception Message on a German System:

[cvc-complex-type.3.2.2: Das Attribut 'invalidAttribute' darf nicht in Element 'process' verwendet werden. | org/activiti/engine/test/bpmn/parse/BpmnParseTest.testInvalidProcessDefinition.bpmn20.xml | line 7 | column 55

Means the same, test case things its different.

The following test cases suffer from this:

testQueryByException(org.activiti.engine.test.api.mgmt.JobQueryTest)

[problem evaluating script: javax.script.ScriptException: java.lang.RuntimeException: This is an exception thrown from scriptTask], but was [problem evaluating script: This is an exception thrown from scriptTask]

testQueryByExceptionMessage(org.activiti.engine.test.api.mgmt.JobQueryTest)

junit.framework.AssertionFailedError: expected presence of [problem evaluating script: javax.script.ScriptException: java.lang.RuntimeException: This is an exception thrown from scriptTask], but was [problem evaluating script: This is an exception thrown from scriptTask]

testQueryByExceptionMessageEmpty(org.activiti.engine.test.api.mgmt.JobQueryTest)

junit.framework.AssertionFailedError: expected presence of [problem evaluating script: javax.script.ScriptException: java.lang.RuntimeException: This is an exception thrown from scriptTask], but was [problem evaluating script: This is an exception thrown from scriptTask]

testInvalidProcessDefinition(org.activiti.engine.test.bpmn.parse.BpmnParseTest)

As seen above.

Generally this way of unit testing should be considered broken and unreliable. A better way must be found to prove, whether an exception is correctly thrown or not.

Environment

Windows XP or 7, German Version (in this case), happends on all versions despite English.

Assignee

Bernd Ruecker (camunda)

Reporter

Heiko Kopp

Labels

None

Components

Fix versions

Affects versions

Priority

Major
Configure