You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Simon Laws <si...@googlemail.com> on 2009/02/26 15:28:21 UTC
[2.x][1.x] exception comparison in stests
Can we be a bit more precise about what sort of exceptions are expected from
a failing test. For example, could we have...
public class ASM_0004_TestCase extends BaseJAXWSTestCase {
protected TestConfiguration getTestConfiguration() {
TestConfiguration config = new TestConfiguration();
config.testName = "ASM_0004";
config.input = "request";
config.output = "org.osoa.sca.ServiceRuntimeException:
Too many targets on reference: reference1";
config.composite = "Test_ASM_0004.composite";
config.testServiceName = "TestClient";
config.testClass = ASM_0002_Client.class;
config.serviceInterface = TestInvocation.class;
return config;
}
} // end class Test_ASM_0004
Where the config.output specified precisely what exception is expected.
This needs a change in the base class to pull out explicit exceptions
public void setUp() throws Exception {
try {
startContribution();
} catch (Exception e) {
// If the SCA runtime refuses to start an invalid contribution,
then this is also
// regarded as a successful outcome
System.out.println( "Exception received - detail: " +
e.getMessage() );
if (e.getCause() instanceof InvocationTargetException){
assertEquals( testConfiguration.getExpectedOutput(),
((InvocationTargetException)e.getCause()).getCause().getMessage() );
} else {
assertEquals( testConfiguration.getExpectedOutput(),
"exception" );
}
System.out.println("Test " + testConfiguration.getTestName() + "
completed successfully");
// Mark this test as not to proceed further
proceed = false;
} // end try
}
This does raise the question of why our exceptions are so awkwardly nested
but that's a different question. Hence the exact nature of how we identify
and extract the exception is subject to debate.
Simon