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();
}
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();
}
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());
}
}
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))));
}
});
}
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);
}
Aggregations