java - Sequences not resetting for mock HSQL db and causing constraint violation between JBehave tests -
I am facing indexing problems while writing a BDD test with our API (Spring + Hibernate). We use JBHW as our BDD runner and as an HSQL DB.
Actually, I have made the following case to understand this issue.
I have two stories: Both stories are included on a table called DummyProdach. We know that each scenario is clear before we clear all the data and reset the schema using the following,
"TRUNCATE SCHEMA public RESTART identity and no check COMMIT"
and then We reinitialize table data using a predefined SQL script which includes 2 inserts to DUMMYPRODUCT,
and the sequence (supposedly)
using the drop Sequence DUMMYPRODUCT_SEQ Resets; Start the sequence DUMMYPRODUXSEQ with an increase of 3 out of 10;
But I am facing very strange behavior because the sequence is not reset between both the stories and the scenarios, instead they continue on the next story / scenario and then reset in, i.e. . Not being in the next block of scenes, due to the constraint violation
exception = java.sql.SQLIntegrityConstraintViolationException: Integrity barrier violation: unique barrier or index violation; SYS_PK_10216 Table: DUMMYPRODUCT
Experience for DUMMYPRODUCTID Insertion in DUMMYPRODUCT
(DUMMYPRODUCTID)
First Story
Scenario
Next Story
Landscape
5
6
7
8
9
10
11
12
3
4 < Br> 5 exceptions
7 exceptions
9 exceptions
landscape
4
5
6
7
8 > 9
10
11 Exceptions
13
14
15
16
17
18
20 20 22
23
24
27
Br> 6
7
8
9
10
11
12
13
14
15
16
17
18
20
21
22
24
Exception
29 Exceptions
Have you faced such issues before your HSQL implementation?
Resumes the identified identification number inside the statement table:
TRUNCA TE table T RESTART identification and any checks COMMIT This statement is up to all tables in the schema, as well as resetting the scenes that are outside the table: <> TRUNCATE SCHEMA public statement before the RESTART and no check to drop the statement sequence it goes permanently COMMIT. There is no trace of left when you make it again.
All of the above are the latest HSQLDB 2.3.x It is possible that you are using an older version, or possibly one of your statements can be tested with actually not executed. Note that you should drop the sequence with a statement and make it again with another statement.
Comments
Post a Comment