Search in sources :

Example 16 with FileConnection

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");
}
Also used : BasicConnectionFactory(org.teiid.resource.spi.BasicConnectionFactory) FileConnection(org.teiid.translator.FileConnection) Test(org.junit.Test)

Example 17 with FileConnection

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());
}
Also used : ArrayList(java.util.ArrayList) FileConnection(org.teiid.translator.FileConnection) Test(org.junit.Test)

Example 18 with FileConnection

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());
}
Also used : ArrayList(java.util.ArrayList) FileConnection(org.teiid.translator.FileConnection) Test(org.junit.Test)

Example 19 with FileConnection

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());
}
Also used : ArrayList(java.util.ArrayList) FileConnection(org.teiid.translator.FileConnection) Test(org.junit.Test)

Example 20 with FileConnection

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());
}
Also used : ArrayList(java.util.ArrayList) FileConnection(org.teiid.translator.FileConnection) Test(org.junit.Test)

Aggregations

FileConnection (org.teiid.translator.FileConnection)27 Test (org.junit.Test)25 ArrayList (java.util.ArrayList)21 File (java.io.File)6 BasicConnectionFactory (org.teiid.resource.spi.BasicConnectionFactory)3 MetadataFactory (org.teiid.metadata.MetadataFactory)2 ProcedureExecution (org.teiid.translator.ProcedureExecution)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Blob (java.sql.Blob)1 Clob (java.sql.Clob)1 SQLException (java.sql.SQLException)1 SQLXML (java.sql.SQLXML)1 Timestamp (java.sql.Timestamp)1 List (java.util.List)1 Properties (java.util.Properties)1 ResourceException (javax.resource.ResourceException)1 VirtualFile (org.jboss.vfs.VirtualFile)1 ReaderInputStream (org.teiid.core.util.ReaderInputStream)1 VirtualFileConnection (org.teiid.file.VirtualFileConnection)1