Search in sources :

Example 1 with TestFor

use of jetbrains.exodus.TestFor in project xodus by JetBrains.

the class VfsStreamsTests method testWriteAndSeek2.

@Test
@TestFor(issue = "XD-624")
public void testWriteAndSeek2() throws IOException {
    Transaction txn = env.beginTransaction();
    vfs.getConfig().setClusteringStrategy(new ClusteringStrategy.LinearClusteringStrategy(8));
    final File file = vfs.createFile(txn, "file0");
    OutputStream outputStream = vfs.writeFile(txn, file);
    final byte[] bytes = HOEGAARDEN.getBytes(StandardCharsets.UTF_8);
    outputStream.write(bytes);
    outputStream.close();
    outputStream = vfs.writeFile(txn, file, bytes.length);
    outputStream.write(bytes);
    outputStream.close();
    txn.flush();
    final InputStream inputStream = vfs.readFile(txn, file);
    Assert.assertEquals(HOEGAARDEN + HOEGAARDEN, streamAsString(inputStream));
    txn.abort();
}
Also used : Transaction(jetbrains.exodus.env.Transaction) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) Test(org.junit.Test) TestFor(jetbrains.exodus.TestFor)

Example 2 with TestFor

use of jetbrains.exodus.TestFor in project xodus by JetBrains.

the class VfsStreamsTests method testWriteAndSeek3.

@Test
@TestFor(issue = "XD-624")
public void testWriteAndSeek3() throws IOException {
    Transaction txn = env.beginTransaction();
    vfs.getConfig().setClusteringStrategy(new ClusteringStrategy.LinearClusteringStrategy(8));
    final File file = vfs.createFile(txn, "file0");
    OutputStream outputStream = vfs.writeFile(txn, file);
    final byte[] bytes = HOEGAARDEN.getBytes(StandardCharsets.UTF_8);
    outputStream.write(bytes);
    outputStream.close();
    outputStream = vfs.appendFile(txn, file);
    outputStream.write(bytes);
    outputStream.close();
    txn.flush();
    final InputStream inputStream = vfs.readFile(txn, file);
    Assert.assertEquals(HOEGAARDEN + HOEGAARDEN, streamAsString(inputStream));
    txn.abort();
}
Also used : Transaction(jetbrains.exodus.env.Transaction) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) Test(org.junit.Test) TestFor(jetbrains.exodus.TestFor)

Example 3 with TestFor

use of jetbrains.exodus.TestFor in project xodus by JetBrains.

the class TreeCursorNoDuplicatesTest method failingGetNextAndGetPrevDontInvalidateKeyValue2.

@Test
@TestFor(issue = "XD-619")
public void failingGetNextAndGetPrevDontInvalidateKeyValue2() {
    tm = createMutableTree(false, 1);
    final int treeSize = 10000;
    for (int i = 0; i < treeSize; ++i) {
        tm.put(kv(i, Integer.toString(i)));
    }
    try (Cursor cursor = tm.openCursor()) {
        ByteIterable key = null;
        while (cursor.getNext()) {
            key = cursor.getKey();
        }
        Assert.assertEquals(key(treeSize - 1), key);
        Assert.assertEquals(key(treeSize - 1), cursor.getKey());
        cursor.getNext();
        cursor.getNext();
        Assert.assertEquals(key(treeSize - 1), cursor.getKey());
        cursor.getPrev();
        Assert.assertEquals(key(treeSize - 2), cursor.getKey());
    }
    try (Cursor cursor = tm.openCursor()) {
        ByteIterable key = null;
        while (cursor.getPrev()) {
            key = cursor.getKey();
        }
        Assert.assertEquals(key(0), key);
        Assert.assertEquals(key(0), cursor.getKey());
        cursor.getPrev();
        cursor.getPrev();
        Assert.assertEquals(key(0), cursor.getKey());
        cursor.getNext();
        Assert.assertEquals(key(1), cursor.getKey());
    }
}
Also used : ByteIterable(jetbrains.exodus.ByteIterable) ArrayByteIterable(jetbrains.exodus.ArrayByteIterable) Cursor(jetbrains.exodus.env.Cursor) Test(org.junit.Test) TestFor(jetbrains.exodus.TestFor)

Example 4 with TestFor

use of jetbrains.exodus.TestFor in project xodus by JetBrains.

the class TreePutTest method createHugeTree.

@Test
@TestFor(issue = "XD-539")
public void createHugeTree() {
    if (Runtime.getRuntime().maxMemory() < 4000000000L) {
        return;
    }
    tm = createMutableTree(false, 1);
    final IntHashSet set = new IntHashSet();
    final int count = 20000;
    final StringBuilder builder = new StringBuilder("value");
    TestUtil.time("put()", () -> {
        for (int i = 0; i < count; ++i) {
            tm.put(key(Integer.toString(i)), value(builder.toString()));
            set.add(i);
            builder.append(i);
        }
    });
    final long address = saveTree();
    System.out.println("Log size: " + tm.getLog().getHighAddress());
    reopen();
    t = openTree(address, false);
    Assert.assertEquals(set.size(), t.getSize());
    TestUtil.time("get()", () -> {
        for (Integer i : set) {
            assertTrue(t.hasKey(key(Integer.toString(i))));
        }
    });
}
Also used : IntHashSet(jetbrains.exodus.core.dataStructures.hash.IntHashSet) Test(org.junit.Test) TestFor(jetbrains.exodus.TestFor)

Example 5 with TestFor

use of jetbrains.exodus.TestFor in project xodus by JetBrains.

the class PropertyCustomTypeTests method testRegisterTwiceWithoutReinit.

@TestFor(issue = "XD-603")
public void testRegisterTwiceWithoutReinit() {
    PersistentEntityStoreImpl store = getEntityStore();
    PropertyTypes propertyTypes = store.getPropertyTypes();
    PersistentStoreTransaction txn = getStoreTransaction();
    ComparablePair<Integer, String> sample = new ComparablePair<>(0, "");
    ComparablePairBinding customBinding = new ComparablePairBinding(propertyTypes, sample);
    store.registerCustomPropertyType(txn, sample.getClass(), customBinding);
    Assert.assertTrue(txn.flush());
    store.registerCustomPropertyType(txn, sample.getClass(), customBinding);
}
Also used : PropertyTypes(jetbrains.exodus.entitystore.tables.PropertyTypes) ComparablePairBinding(jetbrains.exodus.entitystore.custom.ComparablePairBinding) ComparablePair(jetbrains.exodus.entitystore.custom.ComparablePair) TestFor(jetbrains.exodus.TestFor)

Aggregations

TestFor (jetbrains.exodus.TestFor)7 Test (org.junit.Test)5 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 Cursor (jetbrains.exodus.env.Cursor)2 Transaction (jetbrains.exodus.env.Transaction)2 ArrayByteIterable (jetbrains.exodus.ArrayByteIterable)1 ByteIterable (jetbrains.exodus.ByteIterable)1 IntHashSet (jetbrains.exodus.core.dataStructures.hash.IntHashSet)1 ComparablePair (jetbrains.exodus.entitystore.custom.ComparablePair)1 ComparablePairBinding (jetbrains.exodus.entitystore.custom.ComparablePairBinding)1 EntityIterableBase (jetbrains.exodus.entitystore.iterate.EntityIterableBase)1 PropertyTypes (jetbrains.exodus.entitystore.tables.PropertyTypes)1