"<?xml version=\"1.0\"?>\n<!DOCTYPE database SYSTEM \"" + LocalEntityResolver.DTD_PREFIX + "\">\n" +
    public void testForeignkey() throws Exception    {        Database model = readModel(            "<database name='test'>\n" +            "  <table name='SomeTable'\n" +            "         description='Some table'>\n" +            "    <column name='ID'\n" +            "            type='VARCHAR'\n" +            "            size='16'\n" +            "            primaryKey='true'\n" +            "            required='true'\n" +            "            description='The primary key'/>\n" +            "  </table>\n" +            "  <table name='AnotherTable'\n" +            "         description='And another table'>\n" +            "    <column name='Some_ID'\n" +            "            type='VARCHAR'\n" +            "            size='16'\n" +            "            description='The foreign key'/>\n" +            "    <foreign-key foreignTable='SomeTable'>\n" +            "       <reference local='Some_ID' foreign='ID'/>\n" +            "    </foreign-key>\n" +            "  </table>\n" +            "</database>");        assertEquals("test",                     model.getName());        assertEquals(2,                     model.getTableCount());        Table someTable = model.getTable(0);        assertEquals("SomeTable",                     someTable.getName());        assertEquals("Some table",                     someTable.getDescription());        assertEquals(0, someTable.getAutoIncrementColumns().length);        assertEquals(1,                     someTable.getColumnCount());        assertEquals(0,                     someTable.getForeignKeyCount());        assertEquals(0,                     someTable.getIndexCount());        Column pkColumn = someTable.getColumn(0);        assertEquals("ID",                     pkColumn.getName());        assertEquals("VARCHAR",                     pkColumn.getType());        assertEquals(Types.VARCHAR,                     pkColumn.getTypeCode());        assertEquals(16,                     pkColumn.getSizeAsInt());        assertTrue(pkColumn.isPrimaryKey());        assertTrue(pkColumn.isRequired());        assertFalse(pkColumn.isAutoIncrement());        assertNull(pkColumn.getDefaultValue());        assertEquals("The primary key",                     pkColumn.getDescription());        Table anotherTable = model.getTable(1);        assertEquals("AnotherTable",                     anotherTable.getName());        assertEquals("And another table",                     anotherTable.getDescription());        assertEquals(0, anotherTable.getAutoIncrementColumns().length);        assertEquals(1,                     anotherTable.getColumnCount());        assertEquals(1,                     anotherTable.getForeignKeyCount());        assertEquals(0,                     anotherTable.getIndexCount());        Column fkColumn = anotherTable.getColumn(0);        assertEquals("Some_ID",                     fkColumn.getName());        assertEquals("VARCHAR",                     fkColumn.getType());        assertEquals(Types.VARCHAR,                     fkColumn.getTypeCode());        assertEquals(16,                     fkColumn.getSizeAsInt());        assertFalse(fkColumn.isPrimaryKey());        assertFalse(fkColumn.isRequired());        assertFalse(fkColumn.isAutoIncrement());        assertEquals("The foreign key",                     fkColumn.getDescription());        ForeignKey fk = anotherTable.getForeignKey(0);        assertNull(fk.getName());        assertEquals(someTable,                     fk.getForeignTable());        assertEquals(someTable.getName(),                     fk.getForeignTableName());        assertEquals(1,                     fk.getReferenceCount());        Reference ref = fk.getFirstReference();        assertEquals(fkColumn,                     ref.getLocalColumn());        assertEquals("Some_ID",                     ref.getLocalColumnName());        assertEquals(pkColumn,                     ref.getForeignColumn());        assertEquals("ID",                     ref.getForeignColumnName());        assertEquals(            "  <database name=\"test\">\n" +            "    <table name=\"SomeTable\" description=\"Some table\">\n" +            "      <column name=\"ID\" primaryKey=\"true\" required=\"true\" type=\"VARCHAR\" size=\"16\" autoIncrement=\"false\" description=\"The primary key\"/>\n" +            "    </table>\n" +            "    <table name=\"AnotherTable\" description=\"And another table\">\n" +            "      <column name=\"Some_ID\" primaryKey=\"false\" required=\"false\" type=\"VARCHAR\" size=\"16\" autoIncrement=\"false\" description=\"The foreign key\"/>\n" +            "      <foreign-key foreignTable=\"SomeTable\">\n" +            "        <reference local=\"Some_ID\" foreign=\"ID\"/>\n" +            "      </foreign-key>\n" +            "    </table>\n" +            "  </database>\n",            writeModel(model));    }