use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class AbstractStoreManagerTest method testTxCrudInsertCommitCrudSelectRollback.
@Test
public void testTxCrudInsertCommitCrudSelectRollback() {
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final Car car = createNewCar();
storeManager.getDataStore().create(car);
transaction.commit();
}
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
// on récupère la liste des voitures
checkCrudCarsCount(1);
}
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class AbstractStoreManagerTest method testTxNativeInsertCommitNativeSelectRollback.
@Test
public void testTxNativeInsertCommitNativeSelectRollback() {
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final Car car = createNewCar();
nativeInsertCar(car);
transaction.commit();
}
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
// on récupère la liste des voitures
checkNativeCarsCount(1);
}
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class AbstractStoreManagerTest method testTxCrudLockCommit.
@Test
public void testTxCrudLockCommit() {
final Car car = createNewCar();
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final Car createdCar = storeManager.getDataStore().create(car);
// Check cars count
checkCrudCarsCount(1);
storeManager.getDataStore().readOneForUpdate(createdCar.getURI());
checkCrudCarsCount(1);
transaction.commit();
}
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class MultiStoreManagerTest method testOtherStoreFile.
@Test
public void testOtherStoreFile() throws Exception {
final VFile vFile = TestUtil.createVFile(fileManager, "../data/lautreamont.txt", AbstractStoreManagerTest.class);
// 1.Création du fichier depuis un fichier texte du FS
final FileInfo fileInfo = new FileInfoTemp(vFile);
final FileInfo createdFileInfo;
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
// 2. Sauvegarde en Temp
createdFileInfo = storeManager.getFileStore().create(fileInfo);
// can't read file if not commited (TODO ?)
transaction.commit();
}
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
// 3.relecture du fichier
final FileInfo readFileInfo = storeManager.getFileStore().read(createdFileInfo.getURI());
// 4. comparaison du fichier créé et du fichier lu.
final String source;
try (final OutputStream sourceOS = new java.io.ByteArrayOutputStream()) {
FileUtil.copy(vFile.createInputStream(), sourceOS);
source = sourceOS.toString();
}
final String read;
try (final OutputStream readOS = new java.io.ByteArrayOutputStream()) {
FileUtil.copy(readFileInfo.getVFile().createInputStream(), readOS);
read = readOS.toString();
}
// on vérifie que le contenu des fichiers est identique.
// assertEquals("toto", "toto");
// assertEquals("toto", "ti");
Assert.assertEquals(source, read);
Assert.assertTrue("Test contenu du fichier", read.startsWith("Chant I"));
Assert.assertTrue("Test contenu du fichier : " + secureSubString(read, 16711, "ses notes langoureuses,"), read.indexOf("ses notes langoureuses,") > 0);
Assert.assertTrue("Test contenu du fichier : " + secureSubString(read, 11004, "mal : \"Adolescent,"), read.indexOf("mal : \"Adolescent,") > 0);
// On désactive pour l'instant
// Ne marche pas sur la PIC pour cause de charset sur le àé
// Assert.assertTrue("Test contenu du fichier : " + secureSubString(read, 15579, "adieu !à ;"), read.indexOf("adieu !à ;") > 0);
}
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class SearchManagerStoreTest method testIndexDeleteData.
/**
* Test de mise à jour de l'index après une creation.
* La création s'effectue dans une seule transaction.
*/
@Test
public void testIndexDeleteData() {
testIndexAllQuery();
Assert.assertEquals(1, query("ID:10001"));
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
storeManager.getDataStore().delete(createURI(10001L));
transaction.commit();
}
waitIndexation();
Assert.assertEquals(0, query("ID:10001"));
Assert.assertEquals(initialDbItemSize - 1, query("*:*"));
}
Aggregations