示例#1
0
  @Test
  public void testTime() throws Exception {
    FileConnection connection = Mockito.mock(FileConnection.class);
    Mockito.stub(connection.getFile("names.xls"))
        .toReturn(UnitTestUtil.getTestDataFile("names.xlsx"));

    ArrayList results = helpExecute(commonDDL, connection, "select \"time\" from Sheet1");
    assertEquals("[[10:12:14]]", results.toString());
  }
示例#2
0
  @Test
  public void testExecutionLimit2() throws Exception {
    FileConnection connection = Mockito.mock(FileConnection.class);
    Mockito.stub(connection.getFile("names.xls"))
        .toReturn(UnitTestUtil.getTestDataFile("names.xls"));

    ArrayList results = helpExecute(commonDDL, connection, "select FirstName from Sheet1 LIMIT 1");
    assertEquals("[[John]]", results.toString());
  }
示例#3
0
  @Test
  public void testExecutionNE() throws Exception {
    FileConnection connection = Mockito.mock(FileConnection.class);
    Mockito.stub(connection.getFile("names.xls"))
        .toReturn(UnitTestUtil.getTestDataFile("names.xls"));

    ArrayList results =
        helpExecute(commonDDL, connection, "select FirstName from Sheet1 WHERE ROW_ID != 16");
    assertEquals("[[John], [Jane], [Sarah], [Rocky], [Total]]", results.toString());
  }
示例#4
0
  @Test
  public void testExecutionWithDataNumberWithHeaderXLS() throws Exception {
    String ddl =
        "CREATE FOREIGN TABLE Sheet1 (\n"
            + "	ROW_ID integer OPTIONS (SEARCHABLE 'All_Except_Like', \"teiid_excel:CELL_NUMBER\" 'ROW_ID'),\n"
            + "	FirstName string OPTIONS (SEARCHABLE 'Unsearchable', \"teiid_excel:CELL_NUMBER\" '7'),\n"
            + "	LastName string OPTIONS (SEARCHABLE 'Unsearchable', \"teiid_excel:CELL_NUMBER\" '8'),\n"
            + "	Age double OPTIONS (SEARCHABLE 'Unsearchable', \"teiid_excel:CELL_NUMBER\" '9'),\n"
            + "	CONSTRAINT PK0 PRIMARY KEY(ROW_ID)\n"
            + ") OPTIONS (\"teiid_excel:FILE\" 'names.xls', \"teiid_excel:FIRST_DATA_ROW_NUMBER\" '18');";

    FileConnection connection = Mockito.mock(FileConnection.class);
    Mockito.stub(connection.getFile("names.xls"))
        .toReturn(UnitTestUtil.getTestDataFile("names.xls"));

    ArrayList results = helpExecute(ddl, connection, "select * from Sheet1");
    assertEquals("[[18, Rocky, Dog, 3.0], [19, Total, null, 110.0]]", results.toString());
  }
示例#5
0
  @Test
  public void testExecutionWithDataNumberXLSX() throws Exception {
    String ddl =
        "CREATE FOREIGN TABLE Sheet1 (\n"
            + "	ROW_ID integer OPTIONS (SEARCHABLE 'All_Except_Like', \"teiid_excel:CELL_NUMBER\" 'ROW_ID'),\n"
            + "	column1 string OPTIONS (SEARCHABLE 'Unsearchable', \"teiid_excel:CELL_NUMBER\" '1'),\n"
            + "	column2 string OPTIONS (SEARCHABLE 'Unsearchable', \"teiid_excel:CELL_NUMBER\" '2'),\n"
            + "	column3 string OPTIONS (SEARCHABLE 'Unsearchable', \"teiid_excel:CELL_NUMBER\" '3'),\n"
            + "	CONSTRAINT PK0 PRIMARY KEY(ROW_ID)\n"
            + ") OPTIONS (\"teiid_excel:FILE\" 'names.xlsx', \"teiid_excel:FIRST_DATA_ROW_NUMBER\" '6');";

    FileConnection connection = Mockito.mock(FileConnection.class);
    Mockito.stub(connection.getFile("names.xlsx"))
        .toReturn(UnitTestUtil.getTestDataFile("names.xlsx"));

    ArrayList results = helpExecute(ddl, connection, "select * from Sheet1");
    assertEquals("[[6, Rocky, Dog, 3.0]]", results.toString());
  }
示例#6
0
  @Test
  public void testExecutionNoDataNumberXLSX() throws Exception {
    String ddl =
        "CREATE FOREIGN TABLE Sheet1 (\n"
            + "	ROW_ID integer OPTIONS (SEARCHABLE 'All_Except_Like', \"teiid_excel:CELL_NUMBER\" 'ROW_ID'),\n"
            + "	column1 string OPTIONS (SEARCHABLE 'Unsearchable', \"teiid_excel:CELL_NUMBER\" '1'),\n"
            + "	column2 string OPTIONS (SEARCHABLE 'Unsearchable', \"teiid_excel:CELL_NUMBER\" '2'),\n"
            + "	column3 string OPTIONS (SEARCHABLE 'Unsearchable', \"teiid_excel:CELL_NUMBER\" '3'),\n"
            + "	CONSTRAINT PK0 PRIMARY KEY(ROW_ID)\n"
            + ") OPTIONS (\"teiid_excel:FILE\" 'names.xlsx');";

    FileConnection connection = Mockito.mock(FileConnection.class);
    Mockito.stub(connection.getFile("names.xlsx"))
        .toReturn(UnitTestUtil.getTestDataFile("names.xlsx"));

    ArrayList results = helpExecute(ddl, connection, "select * from Sheet1");
    assertEquals(
        "[[1, FirstName, LastName, Age], [2, John, Doe, null], [3, Jane, Smith, 40.0], [4, Matt, Liek, 13.0], [5, Sarah, Byne, 10.0], [6, Rocky, Dog, 3.0]]",
        results.toString());
  }