db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David W. Van Couvering" <David.Vancouver...@Sun.COM>
Subject Re: [jira] Commented: (DERBY-1162) Add mechanism to assert/compare SQLStates
Date Wed, 29 Mar 2006 17:40:09 GMT
I again can't comment directly in JIRA as it is unavailable.

I was corrected by Dan on this some time ago, and I have to agree with 
him that since the SQLState class is not part of the public API we 
shouldn't be relying on it.

I think that if an individual tester wants to use something more 
descriptive than "25001" then they can create a constant for the string.

I think it might be worthwhile to create a utility test class that 
contains constants for all the SQL States that are currently being 
tested against.  One could even cut-and-paste from the SQL spec, which 
lists all standard SQL states using the following format

INVALID_TRANSACTION_STATE_ACTIVE_SQL_TRANSACTION:
constant SQLSTATE_TYPE :="25001";

and then run some kind of sed script to turn it from their format to 
Java, and be good to go, e.g

public static final String 
INVALID_TRANSACTION_STATE_ACTIVE_SQL_TRANSACTION = "25001";

I can remove the assertSQLState from the BaseJDBCTestCase.  Maybe I'll 
get inspired and add the constants file too... :)

David

Daniel John Debrunner (JIRA) wrote:
>     [ http://issues.apache.org/jira/browse/DERBY-1162?page=comments#action_12372258 ]

> 
> Daniel John Debrunner commented on DERBY-1162:
> ----------------------------------------------
> 
> SQLStates are always five characters so I'm not sure why the method needs to truncate
the expected value.
> 
> From the comments in the description it seems as though you are expecting tests should
use constants from the engine's SQLState.
> That is not good practice, it is not part of the public api and it can lead to hidden
bugs.
> 
> If a test is checking for SQLState.SOME_ERROR in a test, then if a error in coding changes
that, say from a SQL Standard 23001 error
> to 2E001 then the test will continue to pass, even though a bug was introduced.
> 
> 
>>Add mechanism to assert/compare SQLStates
>>-----------------------------------------
>>
>>         Key: DERBY-1162
>>         URL: http://issues.apache.org/jira/browse/DERBY-1162
>>     Project: Derby
>>        Type: Sub-task
>>  Components: Test
>>    Versions: 10.2.0.0
>> Environment: JUnit test environment
>>    Reporter: Kristian Waagan
>>    Assignee: Kristian Waagan
>>    Priority: Minor
>>     Fix For: 10.2.0.0
>> Attachments: DERBY-1162-1a.diff
>>
>>The JUnit test environment needs a mechanism to assert/compare SQLStates. The goal
is to be able to reference states from SQLState without having to care if the length of the
identifier is 5,7 or more characters long.
>>A way to do this already exist in StandardException.getSQLStateFromIdentifier, but
it is too unwieldy and long. I suggest adding  'assertSQLState(String, String, SQLException)'
method to BaseJDBCTestCase.
> 
> 

Mime
View raw message