"<?xml version=\"1.0\"?>\n<!DOCTYPE database SYSTEM \"" + LocalEntityResolver.DTD_PREFIX + "\">\n" +
    public void testComplex() throws Exception    {        // A = id:INTEGER, parentId:INTEGER, name:VARCHAR(32); fk 'parent' -> A (parentId -> id), unique(name)        // B = id:TIMESTAMP, aid:INTEGER, cid:CHAR(32) fk -> A (aid -> id), fk -> C (cid -> id), index(aid,cid)        // C = id:CHAR(32), text:LONGVARCHAR; index 'byText' (text)                Database model = readModel(            "<database name='test'>\n" +            "  <table name='A'\n" +            "         description='Table A'>\n" +            "    <column name='id'\n" +            "            type='INTEGER'\n" +            "            autoIncrement='true'\n" +            "            primaryKey='true'\n" +            "            required='true'\n" +            "            description='The primary key of table A'/>\n" +            "    <column name='parentId'\n" +            "            type='INTEGER'\n" +            "            description='The field for the foreign key parent'/>\n" +            "    <column name='name'\n" +            "            type='VARCHAR'\n" +            "            size='32'\n" +            "            required='true'\n" +            "            description='The name'/>\n" +            "    <foreign-key name='parent' foreignTable='A'>\n" +            "       <reference local='parentId' foreign='id'/>\n" +            "    </foreign-key>\n" +            "    <unique>\n" +            "      <unique-column name='name'/>\n" +            "    </unique>\n" +            "  </table>\n" +            "  <table name='B'\n" +            "         description='Table B'>\n" +            "    <column name='id'\n" +            "            type='TIMESTAMP'\n" +            "            primaryKey='true'\n" +            "            required='true'\n" +            "            description='The primary key of table B'/>\n" +            "    <column name='aid'\n" +            "            type='INTEGER'\n" +            "            description='The field for the foreign key towards A'/>\n" +            "    <column name='cid'\n" +            "            type='CHAR'\n" +            "            size='32'\n" +            "            description='The field for the foreign key towards C'/>\n" +            "    <foreign-key foreignTable='A'>\n" +            "       <reference local='aid' foreign='id'/>\n" +            "    </foreign-key>\n" +            "    <foreign-key foreignTable='C'>\n" +            "       <reference local='cid' foreign='id'/>\n" +            "    </foreign-key>\n" +            "    <index>\n" +            "      <index-column name='aid'/>\n" +            "      <index-column name='cid'/>\n" +            "    </index>\n" +            "  </table>\n" +            "  <table name='C'\n" +            "         description='Table C'>\n" +            "    <column name='id'\n" +            "            type='CHAR'\n" +            "            size='32'\n" +            "            primaryKey='true'\n" +            "            required='true'\n" +            "            description='The primary key of table C'/>\n" +            "    <column name='text'\n" +            "            type='LONGVARCHAR'\n" +            "            description='The text'/>\n" +            "    <index name='byText'>\n" +            "      <index-column name='text'/>\n" +            "    </index>\n" +            "  </table>\n" +            "</database>");        assertEquals("test",                     model.getName());        assertEquals(3,                     model.getTableCount());        // table A        Table table = model.getTable(0);        assertEquals("A",                     table.getName());        assertEquals("Table A",                     table.getDescription());        assertEquals(3,                     table.getColumnCount());        assertEquals(1,                     table.getForeignKeyCount());        assertEquals(1,                     table.getIndexCount());        Column column = table.getColumn(0);        assertEquals("id",                     column.getName());        assertEquals("INTEGER",                     column.getType());        assertEquals(Types.INTEGER,                     column.getTypeCode());        assertNull(column.getSize());        assertEquals(0,                     column.getSizeAsInt());        assertTrue(column.isPrimaryKey());        assertTrue(column.isRequired());        assertTrue(column.isAutoIncrement());        assertNull(column.getDefaultValue());        assertEquals("The primary key of table A",                     column.getDescription());        assertEquals(1, table.getAutoIncrementColumns().length);        assertEquals(column,                     table.getAutoIncrementColumns()[0]);        column = table.getColumn(1);        assertEquals("parentId",                     column.getName());        assertEquals("INTEGER",                     column.getType());        assertEquals(Types.INTEGER,                     column.getTypeCode());        assertNull(column.getSize());        assertEquals(0,                     column.getSizeAsInt());        assertFalse(column.isPrimaryKey());        assertFalse(column.isRequired());        assertFalse(column.isAutoIncrement());        assertNull(column.getDefaultValue());        assertEquals("The field for the foreign key parent",                     column.getDescription());        column = table.getColumn(2);        assertEquals("name",                     column.getName());        assertEquals("VARCHAR",                     column.getType());        assertEquals(Types.VARCHAR,                     column.getTypeCode());        assertEquals("32",                     column.getSize());        assertEquals(32,                     column.getSizeAsInt());        assertFalse(column.isPrimaryKey());        assertTrue(column.isRequired());        assertFalse(column.isAutoIncrement());        assertNull(column.getDefaultValue());        assertEquals("The name",                     column.getDescription());        ForeignKey fk = table.getForeignKey(0);        assertEquals("parent",                     fk.getName());        assertEquals(table,                     fk.getForeignTable());        assertEquals("A",                     fk.getForeignTableName());        assertEquals(1,                     fk.getReferenceCount());        Reference ref = fk.getFirstReference();        assertEquals(table.getColumn(1),                     ref.getLocalColumn());        assertEquals("parentId",                     ref.getLocalColumnName());        assertEquals(table.getColumn(0),                     ref.getForeignColumn());        assertEquals("id",                     ref.getForeignColumnName());        Index index = table.getIndex(0);        assertNull(index.getName());        assertTrue(index.isUnique());        assertEquals(1,                     index.getColumnCount());        IndexColumn indexColumn = index.getColumn(0);        assertEquals("name",                     indexColumn.getName());        assertNull(indexColumn.getSize());        // table B                table = model.getTable(1);        assertEquals("B",                     table.getName());        assertEquals("Table B",                     table.getDescription());        assertEquals(0, table.getAutoIncrementColumns().length);        assertEquals(3,                     table.getColumnCount());        assertEquals(2,                     table.getForeignKeyCount());        assertEquals(1,                     table.getIndexCount());        column = table.getColumn(0);        assertEquals("id",                     column.getName());        assertEquals("TIMESTAMP",                     column.getType());        assertEquals(Types.TIMESTAMP,                     column.getTypeCode());        assertNull(column.getSize());        assertEquals(0,                     column.getSizeAsInt());        assertTrue(column.isPrimaryKey());        assertTrue(column.isRequired());        assertFalse(column.isAutoIncrement());        assertNull(column.getDefaultValue());        assertEquals("The primary key of table B",                     column.getDescription());        column = table.getColumn(1);        assertEquals("aid",                     column.getName());        assertEquals("INTEGER",                     column.getType());        assertEquals(Types.INTEGER,                     column.getTypeCode());        assertNull(column.getSize());        assertEquals(0,                     column.getSizeAsInt());        assertFalse(column.isPrimaryKey());        assertFalse(column.isRequired());        assertFalse(column.isAutoIncrement());        assertNull(column.getDefaultValue());        assertEquals("The field for the foreign key towards A",                     column.getDescription());        column = table.getColumn(2);        assertEquals("cid",                     column.getName());        assertEquals("CHAR",                     column.getType());        assertEquals(Types.CHAR,                     column.getTypeCode());        assertEquals("32",                     column.getSize());        assertEquals(32,                     column.getSizeAsInt());        assertFalse(column.isPrimaryKey());        assertFalse(column.isRequired());        assertFalse(column.isAutoIncrement());        assertNull(column.getDefaultValue());        assertEquals("The field for the foreign key towards C",                     column.getDescription());        fk = table.getForeignKey(0);        assertNull(fk.getName());        assertEquals(model.getTable(0),                     fk.getForeignTable());        assertEquals("A",                     fk.getForeignTableName());        assertEquals(1,                     fk.getReferenceCount());        ref = fk.getFirstReference();        assertEquals(table.getColumn(1),                     ref.getLocalColumn());        assertEquals("aid",                     ref.getLocalColumnName());        assertEquals(model.getTable(0).getColumn(0),                     ref.getForeignColumn());        assertEquals("id",                     ref.getForeignColumnName());        fk = table.getForeignKey(1);        assertNull(fk.getName());        assertEquals(model.getTable(2),                     fk.getForeignTable());        assertEquals("C",                     fk.getForeignTableName());        assertEquals(1,                     fk.getReferenceCount());        ref = fk.getFirstReference();        assertEquals(table.getColumn(2),                     ref.getLocalColumn());        assertEquals("cid",                     ref.getLocalColumnName());        assertEquals(model.getTable(2).getColumn(0),                     ref.getForeignColumn());        assertEquals("id",                     ref.getForeignColumnName());        index = table.getIndex(0);        assertNull(index.getName());        assertFalse(index.isUnique());        assertEquals(2,                     index.getColumnCount());        indexColumn = index.getColumn(0);        assertEquals("aid",                     indexColumn.getName());        assertNull(indexColumn.getSize());        indexColumn = index.getColumn(1);        assertEquals("cid",                     indexColumn.getName());        assertNull(indexColumn.getSize());        // table C        table = model.getTable(2);        assertEquals("C",                     table.getName());        assertEquals("Table C",                     table.getDescription());        assertEquals(0, table.getAutoIncrementColumns().length);        assertEquals(2,                     table.getColumnCount());        assertEquals(0,                     table.getForeignKeyCount());        assertEquals(1,                     table.getIndexCount());        column = table.getColumn(0);        assertEquals("id",                     column.getName());        assertEquals("CHAR",                     column.getType());        assertEquals(Types.CHAR,                     column.getTypeCode());        assertEquals("32",                     column.getSize());        assertEquals(32,                     column.getSizeAsInt());        assertTrue(column.isPrimaryKey());        assertTrue(column.isRequired());        assertFalse(column.isAutoIncrement());        assertNull(column.getDefaultValue());        assertEquals("The primary key of table C",                     column.getDescription());        column = table.getColumn(1);        assertEquals("text",                     column.getName());        assertEquals("LONGVARCHAR",                     column.getType());        assertEquals(Types.LONGVARCHAR,                     column.getTypeCode());        assertNull(column.getSize());        assertEquals(0,                     column.getSizeAsInt());        assertFalse(column.isPrimaryKey());        assertFalse(column.isRequired());        assertFalse(column.isAutoIncrement());        assertNull(column.getDefaultValue());        assertEquals("The text",                     column.getDescription());        index = table.getIndex(0);        assertEquals("byText",                     index.getName());        assertFalse(index.isUnique());        assertEquals(1,                     index.getColumnCount());        indexColumn = index.getColumn(0);        assertEquals("text",                     indexColumn.getName());        assertNull(indexColumn.getSize());        assertEquals(            "  <database name=\"test\">\n" +            "    <table name=\"A\" description=\"Table A\">\n" +            "      <column name=\"id\" primaryKey=\"true\" required=\"true\" type=\"INTEGER\" autoIncrement=\"true\" description=\"The primary key of table A\"/>\n" +            "      <column name=\"parentId\" primaryKey=\"false\" required=\"false\" type=\"INTEGER\" autoIncrement=\"false\" description=\"The field for the foreign key parent\"/>\n" +            "      <column name=\"name\" primaryKey=\"false\" required=\"true\" type=\"VARCHAR\" size=\"32\" autoIncrement=\"false\" description=\"The name\"/>\n" +            "      <foreign-key foreignTable=\"A\" name=\"parent\">\n" +            "        <reference local=\"parentId\" foreign=\"id\"/>\n" +            "      </foreign-key>\n" +            "      <unique>\n" +            "        <unique-column name=\"name\"/>\n" +            "      </unique>\n" +            "    </table>\n" +            "    <table name=\"B\" description=\"Table B\">\n" +            "      <column name=\"id\" primaryKey=\"true\" required=\"true\" type=\"TIMESTAMP\" autoIncrement=\"false\" description=\"The primary key of table B\"/>\n" +            "      <column name=\"aid\" primaryKey=\"false\" required=\"false\" type=\"INTEGER\" autoIncrement=\"false\" description=\"The field for the foreign key towards A\"/>\n" +            "      <column name=\"cid\" primaryKey=\"false\" required=\"false\" type=\"CHAR\" size=\"32\" autoIncrement=\"false\" description=\"The field for the foreign key towards C\"/>\n" +            "      <foreign-key foreignTable=\"A\">\n" +            "        <reference local=\"aid\" foreign=\"id\"/>\n" +            "      </foreign-key>\n" +            "      <foreign-key foreignTable=\"C\">\n" +            "        <reference local=\"cid\" foreign=\"id\"/>\n" +            "      </foreign-key>\n" +            "      <index>\n" +            "        <index-column name=\"aid\"/>\n" +            "        <index-column name=\"cid\"/>\n" +            "      </index>\n" +            "    </table>\n" +            "    <table name=\"C\" description=\"Table C\">\n" +            "      <column name=\"id\" primaryKey=\"true\" required=\"true\" type=\"CHAR\" size=\"32\" autoIncrement=\"false\" description=\"The primary key of table C\"/>\n" +            "      <column name=\"text\" primaryKey=\"false\" required=\"false\" type=\"LONGVARCHAR\" autoIncrement=\"false\" description=\"The text\"/>\n" +            "      <index name=\"byText\">\n" +            "        <index-column name=\"text\"/>\n" +            "      </index>\n" +            "    </table>\n" +            "  </database>\n",            writeModel(model));    }