use of com.questdb.model.TestEntity in project questdb by bluestreak01.
the class TestUtils method generateTestEntityData.
public static void generateTestEntityData(JournalWriter<TestEntity> w, int count, long timetamp, int increment) throws JournalException {
String[] symbols = { "AGK.L", "BP.L", "TLW.L", "ABF.L", "LLOY.L", "BT-A.L", "WTB.L", "RRS.L", "ADM.L", "GKN.L", "HSBA.L", null };
Rnd r = new Rnd();
for (int i = 0; i < count; i++) {
TestEntity e = new TestEntity();
e.setSym(symbols[Math.abs(r.nextInt() % (symbols.length))]);
e.setAnInt(Math.abs(r.nextInt()));
e.setADouble(Math.abs(r.nextDouble()));
e.setBStr(UUID.randomUUID().toString());
e.setDStr(UUID.randomUUID().toString());
e.setDwStr(UUID.randomUUID().toString());
e.setTimestamp(timetamp);
timetamp += increment;
w.append(e);
}
w.commit();
}
use of com.questdb.model.TestEntity in project questdb by bluestreak01.
the class IntegrationTest method testTwoJournalsSync.
@Test
public void testTwoJournalsSync() throws Exception {
int size = 10000;
try (JournalWriter<Quote> remote1 = getFactory().writer(Quote.class, "remote1", 2 * size)) {
try (JournalWriter<TestEntity> remote2 = getFactory().writer(TestEntity.class, "remote2", 2 * size)) {
server.publish(remote1);
server.publish(remote2);
server.start();
final CountDownLatch latch = new CountDownLatch(2);
client.subscribe(Quote.class, "remote1", "local1", 2 * size, new JournalListener() {
@Override
public void onCommit() {
latch.countDown();
}
@Override
public void onEvent(int event) {
}
});
client.subscribe(TestEntity.class, "remote2", "local2", 2 * size, new JournalListener() {
@Override
public void onCommit() {
latch.countDown();
}
@Override
public void onEvent(int event) {
}
});
client.start();
TestUtils.generateQuoteData(remote1, size);
TestUtils.generateTestEntityData(remote2, size);
latch.await();
client.halt();
server.halt();
try (Journal<Quote> local1 = getFactory().reader(Quote.class, "local1")) {
Assert.assertEquals("Local1 has wrong size", size, local1.size());
}
try (Journal<TestEntity> local2 = getFactory().reader(TestEntity.class, "local2")) {
Assert.assertEquals("Remote2 has wrong size", size, remote2.size());
Assert.assertEquals("Local2 has wrong size", size, local2.size());
}
}
}
}
use of com.questdb.model.TestEntity in project questdb by bluestreak01.
the class PrinterTest method testCRLFStripping.
@Test
public void testCRLFStripping() {
try (JournalPrinter printer = new JournalPrinter()) {
printer.setAppender(testAppender).setNullString("").types(String.class, TestEntity.class).v(0).c(new StripCRLFStringConverter(printer)).h("Test String").f("bStr").c(new StripCRLFStringConverter(printer)).h("destination");
printer.out("test string", new TestEntity().setBStr("ok\nbunny"));
printer.out("test\nstring2\r_good", new TestEntity().setBStr("ok foxy"));
testAppender.assertLine("test string\tok bunny", 0);
testAppender.assertLine("test string2_good\tok foxy", 1);
}
}
use of com.questdb.model.TestEntity in project questdb by bluestreak01.
the class SortTest method testSortInt.
@Test
public void testSortInt() throws JournalException {
int last = -1;
for (TestEntity p : q.all().asResultSet().sort("anInt").bufferedIterator()) {
Assert.assertTrue("Journal records are out of order", last <= p.getAnInt());
last = p.getAnInt();
}
}
use of com.questdb.model.TestEntity in project questdb by bluestreak01.
the class JournalTest method testAppendBreak.
@Test
public void testAppendBreak() throws Exception {
Rnd random = new Rnd(System.nanoTime(), System.currentTimeMillis());
try (JournalWriter<TestEntity> w = getFactory().writer(TestEntity.class)) {
try {
w.append(new TestEntity().setSym("ABC").setDStr("test1"));
w.append(new TestEntity().setSym("ABC").setDStr(random.nextString(100)));
w.append(new TestEntity().setSym("ABC").setDStr(random.nextString(70000)).setTimestamp(-1));
} catch (Exception e) {
// OK
} finally {
w.commit();
}
w.append(new TestEntity().setSym("ABC").setDStr(random.nextString(300)));
Assert.assertEquals(3, w.query().all().withKeys("ABC").asResultSet().size());
Assert.assertEquals(1, w.query().head().withKeys("ABC").asResultSet().size());
}
}
Aggregations