protected ApplicationContext getContext() {
return new ClassPathXmlApplicationContext("com/javaeye/jert/service/test/DatabaseServiceTest.xml");
}
public void testCRUD() {
Database db = new Database();
db.setName("unit_test_database");
db.setDriver("org.hsqldb.jdbcDriver");
db.setUrl("jdbc:hsqldb:mem:jert_unit_test");
db.setUsername("sa");
db.setPassword("");
service.createDatabase(db);
Database stored = service.getDatabase(db.getId());
assertEquals("unit_test_database", stored.getName());
assertEquals("org.hsqldb.jdbcDriver", stored.getDriver());
assertEquals("jdbc:hsqldb:mem:jert_unit_test", stored.getUrl());
assertEquals("sa", stored.getUsername());
assertEquals("", stored.getPassword());
stored.setPassword("changed");
service.updateDatabase(stored);
stored = service.getDatabase(db.getId());
assertEquals("changed", stored.getPassword());
service.deleteDatabase(stored);
assertNull(service.getDatabase(stored.getId()));
}