import java.sql.SQLException;
import org.apache.log4j.Logger;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.dialect.MySQL5Dialect;
+import org.hibernate.dialect.MySQL5InnoDBDialect;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.wamblee.general.BeanKernel;
import org.wamblee.security.authorization.AuthorizationService;
_container = new DefaultContainer("top");
DatabaseComponentFactory.addDatabaseConfig(_container);
_container.addComponent(new DatasourceComponent("datasource"));
- ClassConfiguration useraccessorConfig = new ClassConfiguration(TestUserAccessor.class);
+ ClassConfiguration useraccessorConfig = new ClassConfiguration(
+ TestUserAccessor.class);
useraccessorConfig.getObjectConfig().getSetterConfig().initAllSetters();
_container.addComponent("userAccessor", useraccessorConfig);
_container.addComponent(new AuthorizationComponent("authorization",
true));
-
- ClassConfiguration dbtesterConfig = new ClassConfiguration(DatabaseTesterComponent.class);
+ ClassConfiguration dbtesterConfig = new ClassConfiguration(
+ DatabaseTesterComponent.class);
dbtesterConfig.getObjectConfig().getSetterConfig().initAllSetters();
- _container
- .addComponent("databaseTester", dbtesterConfig);
+ _container.addComponent("databaseTester", dbtesterConfig);
ObjectConfiguration config = new ObjectConfiguration(
PersistentAuthorizationServiceTest.class);
public void setHibernateTemplate(HibernateTemplate aHibernateTemplate) {
_hibernateTemplate = aHibernateTemplate;
}
-
+
public void setAuthorizationService(
AuthorizationService aAuthorizationService) {
_authorizationService = aAuthorizationService;
/*
* (non-Javadoc)
*
- * @see org.wamblee.security.authorization.AuthorizationServiceTest#createService()
+ * @see
+ * org.wamblee.security.authorization.AuthorizationServiceTest#createService
+ * ()
*/
@Override
protected AuthorizationService createService() {
/*
* (non-Javadoc)
*
- * @see org.wamblee.security.authorization.AuthorizationServiceTest#checkRuleCount(int)
+ * @see
+ * org.wamblee.security.authorization.AuthorizationServiceTest#checkRuleCount
+ * (int)
*/
@Override
protected void checkRuleCount(int aCount) {
try {
assertEquals(1, _databaseTester.getTableSize(SERVICE_TABLE));
assertEquals(aCount, _databaseTester.getTableSize(RULES_TABLE));
- assertEquals(aCount, _databaseTester.getTableSize(SERVICE_RULES_TABLE));
+ assertEquals(aCount, _databaseTester
+ .getTableSize(SERVICE_RULES_TABLE));
assertEquals(aCount, _databaseTester.getTableSize(USERCOND_TABLE));
assertEquals(aCount, _databaseTester.getTableSize(PATHCOND_TABLE));
- assertEquals(aCount, _databaseTester.getTableSize(OPERATIONCOND_TABLE));
+ assertEquals(aCount, _databaseTester
+ .getTableSize(OPERATIONCOND_TABLE));
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
+ public void testSchemaExport() {
+ Configuration config = new Configuration();
+ for (String mappingFile: new AuthorizationMappingFiles()) {
+ config.addResource(mappingFile);
+ }
+ config.setProperty("hibernate.dialect", MySQL5InnoDBDialect.class.getName());
+ SchemaExport exporter = new SchemaExport(config);
+ exporter.setOutputFile("target/mysql5.schema.sql");
+ exporter.create(true,false);
+ }
+
public void testPerformance() {
PersistentAuthorizationService service = (PersistentAuthorizationService) getService();