Search in sources :

Example 31 with Path

use of com.questdb.std.str.Path in project questdb by bluestreak01.

the class SymbolMapTest method testReadEmptySymbolMap.

@Test
public void testReadEmptySymbolMap() throws Exception {
    TestUtils.assertMemoryLeak(() -> {
        int N = 10000;
        try (Path path = new Path().of(configuration.getRoot())) {
            create(path, "x", N, true);
            try (SymbolMapReaderImpl reader = new SymbolMapReaderImpl(configuration, path, "x", 0)) {
                Assert.assertNull(reader.value(-1));
                Assert.assertEquals(SymbolTable.VALUE_IS_NULL, reader.getQuick(null));
            }
        }
    });
}
Also used : Path(com.questdb.std.str.Path) Test(org.junit.Test)

Example 32 with Path

use of com.questdb.std.str.Path in project questdb by bluestreak01.

the class SymbolMapTest method testReaderWhenMapDoesNotExist.

@Test
public void testReaderWhenMapDoesNotExist() throws Exception {
    TestUtils.assertMemoryLeak(() -> {
        try (Path path = new Path().of(configuration.getRoot())) {
            try {
                new SymbolMapReaderImpl(configuration, path, "x", 0);
                Assert.fail();
            } catch (CairoException e) {
                Assert.assertTrue(Chars.contains(e.getMessage(), "does not exist"));
            }
        }
    });
}
Also used : Path(com.questdb.std.str.Path) Test(org.junit.Test)

Example 33 with Path

use of com.questdb.std.str.Path in project questdb by bluestreak01.

the class TableReaderTest method rmDir.

private static void rmDir(CharSequence partitionName) {
    try (Path path = new Path()) {
        path.of(root).concat("w").concat(partitionName).$();
        Assert.assertTrue(configuration.getFilesFacade().exists(path));
        Assert.assertTrue(configuration.getFilesFacade().rmdir(path));
    }
}
Also used : Path(com.questdb.std.str.Path)

Example 34 with Path

use of com.questdb.std.str.Path in project questdb by bluestreak01.

the class TableUtilsTest method testCreateFailure.

@Test
public void testCreateFailure() throws Exception {
    TestUtils.assertMemoryLeak(() -> {
        class X extends FilesFacadeImpl {

            @Override
            public int mkdirs(LPSZ path, int mode) {
                return -1;
            }
        }
        X ff = new X();
        JournalMetadata metadata = getJournalStructure().build();
        try (AppendMemory appendMemory = new AppendMemory()) {
            try (Path path = new Path()) {
                TableUtils.create(ff, path, appendMemory, temp.getRoot().getAbsolutePath(), metadata, 509);
                Assert.fail();
            } catch (CairoException e) {
                Assert.assertNotNull(e.getMessage());
            }
        }
    });
}
Also used : Path(com.questdb.std.str.Path) JournalMetadata(com.questdb.store.factory.configuration.JournalMetadata) LPSZ(com.questdb.std.str.LPSZ) FilesFacadeImpl(com.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 35 with Path

use of com.questdb.std.str.Path in project questdb by bluestreak01.

the class TableWriterTest method testOpenWriterMissingTxFile.

@Test
public void testOpenWriterMissingTxFile() throws Exception {
    TestUtils.assertMemoryLeak(() -> {
        CairoTestUtils.createAllTable(configuration, PartitionBy.NONE);
        try (Path path = new Path()) {
            Assert.assertTrue(FF.remove(path.of(root).concat("all").concat(TableUtils.TXN_FILE_NAME).$()));
            try {
                new TableWriter(configuration, "all");
                Assert.fail();
            } catch (CairoException ignore) {
            }
        }
    });
}
Also used : Path(com.questdb.std.str.Path) Test(org.junit.Test)

Aggregations

Path (com.questdb.std.str.Path)74 Test (org.junit.Test)46 File (java.io.File)8 Rnd (com.questdb.std.Rnd)7 LPSZ (com.questdb.std.str.LPSZ)6 NativeLPSZ (com.questdb.std.str.NativeLPSZ)5 NumericException (com.questdb.common.NumericException)3 RecordColumnMetadata (com.questdb.common.RecordColumnMetadata)3 DirectCharSequence (com.questdb.std.str.DirectCharSequence)3 StringSink (com.questdb.std.str.StringSink)3 RowCursor (com.questdb.common.RowCursor)2 CreateTableModel (com.questdb.griffin.lexer.model.CreateTableModel)2 ObjList (com.questdb.std.ObjList)2 JournalMetadata (com.questdb.store.factory.configuration.JournalMetadata)2 TestMicroClock (com.questdb.test.tools.TestMicroClock)2 ByteBuffer (java.nio.ByteBuffer)2 Record (com.questdb.common.Record)1 RecordCursor (com.questdb.common.RecordCursor)1 Chars (com.questdb.std.Chars)1 FilesFacade (com.questdb.std.FilesFacade)1