Skip to content

Commit

Permalink
Adds safety measure in test preparation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Gasser committed Jan 17, 2024
1 parent 9fdf320 commit 5b74ea0
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import java.nio.file.Files
* An abstract class for test cases that test for correctness of serialization
*
* @author Ralph Gasser
* @version 1.5.0
* @version 1.5.1
*/
abstract class AbstractSerializationTest: AbstractEntityTest() {

Expand Down Expand Up @@ -93,18 +93,23 @@ abstract class AbstractSerializationTest: AbstractEntityTest() {

/* Start inserting. */
val txn = this.manager.startTransaction(TransactionType.SYSTEM_EXCLUSIVE)
val ctx = DefaultQueryContext("serialization-populate", this.catalogue, txn)
val catalogueTx = this.catalogue.newTx(ctx)
val schema = catalogueTx.schemaForName(this.schemaName)
val schemaTx = schema.newTx(ctx)
val entity = schemaTx.entityForName(this.entityName)
val entityTx = entity.newTx(ctx)

/* Insert data and track how many entries have been stored for the test later. */
repeat(TestConstants.TEST_COLLECTION_SIZE) {
entityTx.insert(nextRecord(it))
try {
val ctx = DefaultQueryContext("serialization-populate", this.catalogue, txn)
val catalogueTx = this.catalogue.newTx(ctx)
val schema = catalogueTx.schemaForName(this.schemaName)
val schemaTx = schema.newTx(ctx)
val entity = schemaTx.entityForName(this.entityName)
val entityTx = entity.newTx(ctx)

/* Insert data and track how many entries have been stored for the test later. */
repeat(TestConstants.TEST_COLLECTION_SIZE) {
entityTx.insert(nextRecord(it))
}
txn.commit()
} catch (e: Throwable) {
txn.rollback()
throw e
}
txn.commit()
}

/**
Expand Down

0 comments on commit 5b74ea0

Please sign in to comment.