use of org.teiid.translator.FileConnection in project teiid by teiid.
the class TestFileConnection method testParentPaths.
@Test(expected = ResourceException.class)
public void testParentPaths() throws Exception {
FileManagedConnectionFactory fmcf = new FileManagedConnectionFactory();
fmcf.setParentDirectory("foo");
fmcf.setAllowParentPaths(false);
BasicConnectionFactory bcf = fmcf.createConnectionFactory();
FileConnection fc = (FileConnection) bcf.getConnection();
fc.getFile(".." + File.separator + "x");
}
use of org.teiid.translator.FileConnection in project teiid by teiid.
the class TestExcelExecution method testExecutionHeaderWithEmptyCell.
/**
* Test a sheet with a header row where 1 column is empty
* @throws Exception
*/
@Test
public void testExecutionHeaderWithEmptyCell() throws Exception {
String ddl = "SET NAMESPACE 'http://www.teiid.org/translator/excel/2014' AS teiid_excel;\n\n" + "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\" '1'),\n" + " LastName string OPTIONS (SEARCHABLE 'Unsearchable', \"teiid_excel:CELL_NUMBER\" '2'),\n" + " Age double OPTIONS (SEARCHABLE 'Unsearchable', \"teiid_excel:CELL_NUMBER\" '4'),\n" + " CONSTRAINT PK0 PRIMARY KEY(ROW_ID)\n" + ") OPTIONS (NAMEINSOURCE 'Sheet1', \"teiid_excel:FILE\" 'empty-ignore.xls', \"teiid_excel:FIRST_DATA_ROW_NUMBER\" '2');";
FileConnection connection = Mockito.mock(FileConnection.class);
Mockito.stub(connection.getFile("empty-ignore.xls")).toReturn(UnitTestUtil.getTestDataFile("empty-ignore.xls"));
ArrayList results = helpExecute(ddl, connection, "select * from Sheet1");
assertEquals(6, results.size());
ArrayList row = (ArrayList) results.get(4);
assertEquals(4, row.size());
}
use of org.teiid.translator.FileConnection in project teiid by teiid.
the class TestExcelExecution method testExecutionLE.
@Test
public void testExecutionLE() 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], [Matt]]", results.toString());
}
use of org.teiid.translator.FileConnection in project teiid by teiid.
the class TestExcelExecution method testExecutionGT.
@Test
public void testExecutionGT() 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("[[Sarah], [Rocky], [Total]]", results.toString());
}
use of org.teiid.translator.FileConnection in project teiid by teiid.
the class TestExcelExecution method testExecutionAnd.
@Test
public void testExecutionAnd() 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 and ROW_ID < 18");
assertEquals("[[Sarah]]", results.toString());
}
Aggregations