Search in sources :

Example 1 with DuplicateRecordException

use of org.teiid.metadata.DuplicateRecordException in project teiid by teiid.

the class TestDynamicImportedMetaData method testDuplicateException.

@Test
public void testDuplicateException() throws Exception {
    MetadataFactory mf = createMetadataFactory("x", new Properties());
    MetadataFactory mf1 = createMetadataFactory("y", new Properties());
    Table dup = mf.addTable("dup");
    Table dup1 = mf1.addTable("dup");
    mf.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup);
    mf1.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup1);
    MetadataStore ms = mf.asMetadataStore();
    ms.addSchema(mf1.asMetadataStore().getSchemas().values().iterator().next());
    server.deployVDB("test", ms);
    // $NON-NLS-1$
    Connection conn = server.createConnection("jdbc:teiid:test");
    Properties importProperties = new Properties();
    mf = getMetadata(importProperties, conn);
    Table t = mf.asMetadataStore().getSchemas().get("TEST").getTables().get("TEST.X.DUP");
    assertEquals("\"test\".\"x\".\"dup\"", t.getNameInSource());
    importProperties.setProperty("importer.useFullSchemaName", Boolean.FALSE.toString());
    try {
        getMetadata(importProperties, conn);
        fail();
    } catch (DuplicateRecordException e) {
    }
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) DuplicateRecordException(org.teiid.metadata.DuplicateRecordException) Table(org.teiid.metadata.Table) MetadataFactory(org.teiid.metadata.MetadataFactory) Connection(java.sql.Connection) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

Connection (java.sql.Connection)1 Properties (java.util.Properties)1 Test (org.junit.Test)1 DuplicateRecordException (org.teiid.metadata.DuplicateRecordException)1 MetadataFactory (org.teiid.metadata.MetadataFactory)1 MetadataStore (org.teiid.metadata.MetadataStore)1 Table (org.teiid.metadata.Table)1