Summary: | JdbcInterceptor config parameter parsing errors | ||
---|---|---|---|
Product: | Tomcat Modules | Reporter: | Glen Taylor <inetdevboy+apache> |
Component: | jdbc-pool | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
Attachments: |
Patch for PoolProperties.java
New unit test for parser Updated unit test per comments |
Description
Glen Taylor
2013-01-09 20:51:23 UTC
Created attachment 29833 [details]
Patch for PoolProperties.java
Created attachment 29835 [details]
New unit test for parser
FWIW, test cases using the following idiom: caught = null; try { props.getJdbcInterceptorsAsArray(); } catch (Exception e) { caught = e; } assertNull(caught); can be written somewhat more simply like this: try { props.getJdbcInterceptorsAsArray(); } catch (Exception e) { assertFail("Didn't expect exception"); } Likewise: caught = null; try { props.getJdbcInterceptorsAsArray(); } catch (Exception e) { caught = e; } assertNotNull(caught); can be written like this: try { props.getJdbcInterceptorsAsArray(); assertFail("Expected Exception"); } catch (Exception e) { // Expected } Created attachment 29836 [details]
Updated unit test per comments
Well, the JUnit 3.8.1 pulled in by Maven doesn't have an "assertFail(String)" method, but I think the "fail(String)" alternative is there in spirit. Point(s) taken, unit test attachment updated.
I had been doing more with the Exception in case 1, and didn't refactor far enough when that changed, and case 2 was copy/paste laziness (blah,blah). Thanks for the good suggestions.
(In reply to comment #3) > FWIW, test cases using the following idiom: > (..) > can be written somewhat more simply like this: > > try { > props.getJdbcInterceptorsAsArray(); > } catch (Exception e) { > assertFail("Didn't expect exception"); > } 1. Just add "throws Exception" to the test method. JUnit notices the thrown exception and the test does not pass. 2. It is the first time I am seeing "assertFail". A typo? The method that I know about is called fail(message) (Assert.fail(..)). Sorry, yes, I meant "fail()". As for "throws Exception" doesn't that change a failure into an "error" when JUnit runs? |