Search in sources :

Example 1 with TestMicroClock

use of io.questdb.test.tools.TestMicroClock in project questdb by bluestreak01.

the class LineUdpParserImplTest method testReservedName.

@Test
public void testReservedName() throws Exception {
    final String expected = "sym\tdouble\tint\tbool\tstr\ttimestamp\n" + "ok\t2.1\t11\tfalse\tdone\t2017-10-03T10:00:00.000000Z\n";
    String lines = "x,sym2=xyz double=1.6,int=15i,bool=true,str=\"string1\"\n" + "x,sym1=abc double=1.3,int=11i,bool=false,str=\"string2\"\n" + "y,sym=ok double=2.1,int=11i,bool=false,str=\"done\"\n";
    CairoConfiguration configuration = new DefaultCairoConfiguration(root) {

        @Override
        public MicrosecondClock getMicrosecondClock() {
            try {
                return new TestMicroClock(TimestampFormatUtils.parseTimestamp("2017-10-03T10:00:00.000Z"), 10);
            } catch (NumericException e) {
                throw new RuntimeException(e);
            }
        }
    };
    try (Path path = new Path()) {
        Files.mkdirs(path.of(root).concat("x").slash$(), configuration.getMkDirMode());
        assertThat(expected, lines, "y", configuration);
        Assert.assertEquals(TableUtils.TABLE_RESERVED, TableUtils.exists(configuration.getFilesFacade(), path, root, "x"));
    }
}
Also used : Path(io.questdb.std.str.Path) TestMicroClock(io.questdb.test.tools.TestMicroClock) Test(org.junit.Test)

Example 2 with TestMicroClock

use of io.questdb.test.tools.TestMicroClock in project questdb by bluestreak01.

the class LineUdpParserImplTest method testCannotCreateTable.

@Test
public void testCannotCreateTable() throws Exception {
    TestFilesFacade ff = new TestFilesFacade() {

        boolean called = false;

        @Override
        public int mkdirs(LPSZ path, int mode) {
            if (Chars.endsWith(path, "x" + Files.SEPARATOR)) {
                called = true;
                return -1;
            }
            return super.mkdirs(path, mode);
        }

        @Override
        public boolean wasCalled() {
            return called;
        }
    };
    final String expected = "sym\tdouble\tint\tbool\tstr\ttimestamp\n" + "zzz\t1.3\t11\tfalse\tnice\t2017-10-03T10:00:00.000000Z\n";
    String lines = "x,sym2=xyz double=1.6,int=15i,bool=true,str=\"string1\"\n" + "x,sym1=abc double=1.3,int=11i,bool=false,str=\"string2\"\n" + "y,sym=zzz double=1.3,int=11i,bool=false,str=\"nice\"\n";
    CairoConfiguration configuration = new DefaultCairoConfiguration(root) {

        @Override
        public FilesFacade getFilesFacade() {
            return ff;
        }

        @Override
        public MicrosecondClock getMicrosecondClock() {
            try {
                return new TestMicroClock(TimestampFormatUtils.parseTimestamp("2017-10-03T10:00:00.000Z"), 10);
            } catch (NumericException e) {
                throw new RuntimeException(e);
            }
        }
    };
    assertThat(expected, lines, "y", configuration);
    Assert.assertTrue(ff.wasCalled());
    try (Path path = new Path()) {
        Assert.assertEquals(TableUtils.TABLE_DOES_NOT_EXIST, TableUtils.exists(ff, path, root, "all"));
    }
}
Also used : Path(io.questdb.std.str.Path) LPSZ(io.questdb.std.str.LPSZ) TestMicroClock(io.questdb.test.tools.TestMicroClock) Test(org.junit.Test)

Aggregations

Path (io.questdb.std.str.Path)2 TestMicroClock (io.questdb.test.tools.TestMicroClock)2 Test (org.junit.Test)2 LPSZ (io.questdb.std.str.LPSZ)1