Search in sources :

Example 1 with TestMicroClock

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

the class CairoLineProtoParserTest 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.300000000000\t11\tfalse\tnice\t2017-10-03T10:00:00.000Z\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 getClock() {
            try {
                return new TestMicroClock(DateFormatUtils.parseDateTime("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(com.questdb.std.str.Path) LPSZ(com.questdb.std.str.LPSZ) NumericException(com.questdb.common.NumericException) TestMicroClock(com.questdb.test.tools.TestMicroClock) Test(org.junit.Test)

Example 2 with TestMicroClock

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

the class CairoLineProtoParserTest method testReservedName.

@Test
public void testReservedName() throws Exception {
    final String expected = "sym\tdouble\tint\tbool\tstr\ttimestamp\n" + "ok\t2.100000000000\t11\tfalse\tdone\t2017-10-03T10:00:00.000Z\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 getClock() {
            try {
                return new TestMicroClock(DateFormatUtils.parseDateTime("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").put(Files.SEPARATOR).$(), configuration.getMkDirMode());
        assertThat(expected, lines, "y", configuration);
        Assert.assertEquals(TableUtils.TABLE_RESERVED, TableUtils.exists(configuration.getFilesFacade(), path, root, "x"));
    }
}
Also used : Path(com.questdb.std.str.Path) NumericException(com.questdb.common.NumericException) TestMicroClock(com.questdb.test.tools.TestMicroClock) Test(org.junit.Test)

Aggregations

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