Search in sources :

Example 26 with VTransactionWritable

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);
    }
}
Also used : Car(io.vertigo.dynamo.store.data.domain.car.Car) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 27 with VTransactionWritable

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);
    }
}
Also used : Car(io.vertigo.dynamo.store.data.domain.car.Car) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 28 with VTransactionWritable

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();
    }
}
Also used : Car(io.vertigo.dynamo.store.data.domain.car.Car) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 29 with VTransactionWritable

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);
    }
}
Also used : FileInfo(io.vertigo.dynamo.file.model.FileInfo) OutputStream(java.io.OutputStream) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) VFile(io.vertigo.dynamo.file.model.VFile) FileInfoTemp(io.vertigo.dynamo.store.data.fileinfo.FileInfoTemp) Test(org.junit.Test) AbstractStoreManagerTest(io.vertigo.dynamo.store.datastore.AbstractStoreManagerTest)

Example 30 with VTransactionWritable

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("*:*"));
}
Also used : VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Aggregations

VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)80 Test (org.junit.Test)63 Car (io.vertigo.dynamo.store.data.domain.car.Car)22 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)22 Task (io.vertigo.dynamo.task.model.Task)22 SuperHero (io.vertigo.dynamo.task.data.domain.SuperHero)18 DtList (io.vertigo.dynamo.domain.model.DtList)7 Flower (io.vertigo.dynamo.kvstore.data.Flower)6 Famille (io.vertigo.dynamo.store.data.domain.famille.Famille)6 SqlConnection (io.vertigo.database.sql.connection.SqlConnection)5 DtListURI (io.vertigo.dynamo.domain.model.DtListURI)5 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)4 DtListURIForCriteria (io.vertigo.dynamo.domain.model.DtListURIForCriteria)4 URI (io.vertigo.dynamo.domain.model.URI)4 Item (io.vertigo.dynamo.search.data.domain.Item)4 SearchIndexDefinition (io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)4 Car (io.vertigo.dynamo.search_2_4.data.domain.Car)4 TaskEngineSelect (io.vertigo.dynamox.task.TaskEngineSelect)4 ArrayList (java.util.ArrayList)4 Domain (io.vertigo.dynamo.domain.metamodel.Domain)3