You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Jayaram Subramanian <rs...@gmail.com> on 2010/01/12 04:34:23 UTC

Validating failures during JUnit conversion

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

Detail
-- table with more than one generated column spec should fail
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));
With Regards
Jayaram

Re: Validating failures during JUnit conversion

Posted by Bryan Pendleton <bp...@amberpoint.com>.
> ERROR XSDB6: Another instance of Derby may have already booted the 
> database C:\java\Derby\source\trunk\MyDbTest.

There is a lock file which is created and held open when a Derby
process has opened the database.

The lock file is released when the JVM is exited or the database is shut down.

Since you are getting this error, it is most likely because
you still have a test process which is running and which has
the database open (perhaps in the Eclipse debugger?)

You should be able to look through the various "run" windows
in Eclipse and make sure that all your test and debug runs are
ended, and then you should be able to start a new run against
the database.

thanks,

bryan


Re: Validating failures during JUnit conversion

Posted by Jayaram Subramanian <rs...@gmail.com>.
Thanks Bryan,
Also a small query.. I am running IJ.java to get the results and then get
them converted into JUNit.. I have started getting the following error when
trying to run the IJ..


ERROR XJ040: Failed to start database 'MyDbTest', see the next exception for
details.

ERROR XSDB6: Another instance of Derby may have already booted the database
C:\java\Derby\source\trunk\MyDbTest.
Am i missing something or should i have to reload the project in eclipse?

With Regards
Jayaram

On Mon, Jan 11, 2010 at 10:01 PM, Bryan Pendleton <bpendleton@amberpoint.com
> wrote:

>  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
>
>
>

Re: Validating failures during JUnit conversion

Posted by Bryan Pendleton <bp...@amberpoint.com>.
> 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