Skip to content

Commit

Permalink
help with debugging platform unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed May 4, 2012
1 parent 9706b72 commit 89674c2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
Expand Up @@ -154,7 +154,7 @@ public void createDatabase(Database targetDatabase, boolean dropTablesFirst,
String createSql = ddlBuilder.createTables(targetDatabase, false);

if (log.isDebugEnabled()) {
log.debug("Generated create sql: \n", createSql);
log.debug("Generated create sql: \n{}", createSql);
}

String delimiter = getDdlBuilder().getDatabaseInfo().getSqlCommandDelimiter();
Expand Down Expand Up @@ -246,6 +246,10 @@ public Table readTableFromDatabase(String catalogName, String schemaName, String
}
}
}

if (table != null && log.isDebugEnabled()) {
log.debug("Just read table: \n{}", table.toVerboseString());
}
return table;
}

Expand Down
Expand Up @@ -4,6 +4,8 @@

import junit.framework.Assert;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jumpmind.db.io.DatabaseIO;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.IDatabasePlatform;
Expand All @@ -14,19 +16,31 @@ public class DatabasePlatformTest extends AbstractDbTest {

private static IDatabasePlatform platform;

protected final static String SIMPLE_TABLE = "test_simple_table";

@BeforeClass
public static void setup() throws Exception {
platform = DbTestUtils.createDatabasePlatform(DbTestUtils.ROOT);
}

@Test
public void testCreateDatabase() throws Exception {
platform.createDatabase(new DatabaseIO().read(new InputStreamReader(
DatabasePlatformTest.class.getResourceAsStream("/testCreateDatabase.xml"))), true,
false);

Table table = platform.getTableFromCache("test_simple_table", true);
Assert.assertNotNull(table);
Assert.assertEquals(true, table.getColumnWithName("id").isAutoIncrement());
public void testCreateAndReadTestSimpleTable() throws Exception {

Logger logger = Logger.getLogger("org.jumpmind.db");
Level origLevel = logger.getLevel();
try {
logger.setLevel(Level.TRACE);

platform.createDatabase(new DatabaseIO().read(new InputStreamReader(
DatabasePlatformTest.class.getResourceAsStream("/testCreateDatabase.xml"))),
true, false);
Table table = platform.getTableFromCache(SIMPLE_TABLE, true);
Assert.assertNotNull("Could not find " + SIMPLE_TABLE, table);
Assert.assertEquals("The id column was not read in as an autoincrement column", true,
table.getColumnWithName("id").isAutoIncrement());

} finally {
logger.setLevel(origLevel);
}
}
}

0 comments on commit 89674c2

Please sign in to comment.