예제 #1
0
 @Test
 public void testPropertiesOverride() throws Exception {
   ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
   Properties p = new Properties();
   p.setProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS, Boolean.TRUE.toString());
   Mockito.stub(conn.getExecutionProperties()).toReturn(p);
   StatementImpl statement =
       new StatementImpl(conn, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
   assertEquals(
       Boolean.TRUE.toString(),
       statement.getExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS));
   statement.setExecutionProperty(
       ExecutionProperties.ANSI_QUOTED_IDENTIFIERS, Boolean.FALSE.toString());
   assertEquals(
       Boolean.FALSE.toString(),
       statement.getExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS));
   assertEquals(
       Boolean.TRUE.toString(), p.getProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS));
 }
예제 #2
0
  @Test
  public void testFK() throws Exception {
    String ddl =
        "CREATE FOREIGN TABLE G1(g1e1 integer, g1e2 varchar, PRIMARY KEY(g1e1, g1e2));\n"
            + "CREATE FOREIGN TABLE G2( g2e1 integer, g2e2 varchar, "
            + "FOREIGN KEY (g2e1, g2e2) REFERENCES G1 (g1e1, g1e2) options (\"teiid_rel:allow-join\" true))";

    Schema s = helpParse(ddl, "model").getSchema();
    Map<String, Table> tableMap = s.getTables();
    assertEquals(2, tableMap.size());

    assertTrue("Table not found", tableMap.containsKey("G1"));
    assertTrue("Table not found", tableMap.containsKey("G2"));

    Table table = tableMap.get("G2");
    ForeignKey fk = table.getForeignKeys().get(0);
    assertEquals(Boolean.TRUE.toString(), fk.getProperty(ForeignKey.ALLOW_JOIN, false));
    assertEquals(fk.getColumns(), table.getColumns());
    assertEquals("G1", fk.getReferenceTableName());
  }