When converting autoincrement.sql to JUnit, i have encountered a scenario where i need to assert a failure... How can i do this?

Hi Jayaram,

One way to do this is to use this utility method, which issues the
statement and expects to catch an error with a certain SQLState code:

        assertStatementError("42Y62", st,
                "alter table v2 add column c2 int");

In your case, the actual statement that you issue would be different
(it would be the CREATE TABLE statement that you expect to fail), and
the actual error code would be different, as it would be the error
that you expect, so it would be something like:

        assertStatementError("428C1", st,
"create table ai_multiple (i int,"+
"a0 int generated always as identity (start with  -1,"+
"increment by -1),"+
"a1 smallint generated always as identity,"+
"a2 int generated always as identity (start with  0),"+
"a3 bigint generated always as identity (start with  -100,"+
"increment by 10))");

Hope this helps,

bryan


Reply via email to