Search in sources :

Example 11 with Source

use of org.apache.calcite.util.Source in project calcite by apache.

the class FileReaderTest method testFileReaderDataNoTh.

/**
 * Tests {@link FileReader} with no headings static file - data.
 */
@Test
public void testFileReaderDataNoTh() throws FileReaderException {
    final Source source = Sources.file(null, file("target/test-classes/tableNoTH.html"));
    FileReader t = new FileReader(source);
    Iterator<Elements> i = t.iterator();
    Elements row = i.next();
    assertTrue(row.get(2).text().equals("R0C2"));
}
Also used : Elements(org.jsoup.select.Elements) Source(org.apache.calcite.util.Source) Test(org.junit.Test)

Example 12 with Source

use of org.apache.calcite.util.Source in project calcite by apache.

the class FileReaderTest method testFileReaderData.

/**
 * Test {@link FileReader} with static file - data.
 */
@Test
public void testFileReaderData() throws FileReaderException {
    final Source source = Sources.file(null, file("target/test-classes/tableOK.html"));
    FileReader t = new FileReader(source);
    Iterator<Elements> i = t.iterator();
    Elements row = i.next();
    assertTrue(row.get(2).text().equals("R0C2"));
    row = i.next();
    assertTrue(row.get(0).text().equals("R1C0"));
}
Also used : Elements(org.jsoup.select.Elements) Source(org.apache.calcite.util.Source) Test(org.junit.Test)

Example 13 with Source

use of org.apache.calcite.util.Source in project calcite by apache.

the class FileReaderTest method testFileReaderHeadingsBadFile.

/**
 * Tests {@link FileReader} with bad static file - headings.
 */
@Test
public void testFileReaderHeadingsBadFile() throws FileReaderException {
    final Source source = Sources.file(null, file("target/test-classes/tableNoTheadTbody.html"));
    FileReader t = new FileReader(source);
    Elements headings = t.getHeadings();
    assertTrue(headings.get(1).text().equals("H1"));
}
Also used : Elements(org.jsoup.select.Elements) Source(org.apache.calcite.util.Source) Test(org.junit.Test)

Example 14 with Source

use of org.apache.calcite.util.Source in project calcite by apache.

the class FileReaderTest method testFileReaderIterator.

/**
 * Tests {@link FileReader} iterator with static file,
 */
@Test
public void testFileReaderIterator() throws FileReaderException {
    final Source source = Sources.file(null, file("target/test-classes/tableOK.html"));
    FileReader t = new FileReader(source);
    Elements row = null;
    for (Elements aT : t) {
        row = aT;
    }
    assertFalse(row == null);
    assertTrue(row.get(1).text().equals("R2C1"));
}
Also used : Elements(org.jsoup.select.Elements) Source(org.apache.calcite.util.Source) Test(org.junit.Test)

Aggregations

Source (org.apache.calcite.util.Source)14 Test (org.junit.Test)8 Elements (org.jsoup.select.Elements)6 File (java.io.File)4 Table (org.apache.calcite.schema.Table)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 FilenameFilter (java.io.FilenameFilter)2 MalformedURLException (java.net.MalformedURLException)2 CsvFilterableTable (org.apache.calcite.adapter.csv.CsvFilterableTable)2 JsonTable (org.apache.calcite.adapter.csv.JsonTable)2 RelProtoDataType (org.apache.calcite.rel.type.RelProtoDataType)2