@Override protected void setUp() throws Exception { super.setUp(); DataSource dataSource = mock(DataSource.class); factory = new DefaultDataFieldMaxValueIncrementerFactory(dataSource); }
public void testInvalidDatabaseType(){ try{ factory.getIncrementer("invalidtype", "NAME"); fail(); } catch(IllegalArgumentException ex){ //expected } }
public void testSupportedDatabaseType(){ assertTrue(factory.isSupportedIncrementerType("db2")); assertTrue(factory.isSupportedIncrementerType("db2zos")); assertTrue(factory.isSupportedIncrementerType("mysql")); assertTrue(factory.isSupportedIncrementerType("derby")); assertTrue(factory.isSupportedIncrementerType("oracle")); assertTrue(factory.isSupportedIncrementerType("postgres")); assertTrue(factory.isSupportedIncrementerType("hsql")); assertTrue(factory.isSupportedIncrementerType("sqlserver")); assertTrue(factory.isSupportedIncrementerType("sybase")); assertTrue(factory.isSupportedIncrementerType("sqlite")); }
public void testOracle(){ factory.setIncrementerColumnName("ID"); assertTrue(factory.getIncrementer("oracle", "NAME") instanceof OracleSequenceMaxValueIncrementer); }
public DefaultSequenceMaxValueIncrementerFactory(DataSource dataSource) { this.dataSource = dataSource; delegate = new DefaultDataFieldMaxValueIncrementerFactory(dataSource); delegate.setIncrementerColumnName(incrementerColumnName); }
@Override public void afterPropertiesSet() throws Exception { DataFieldMaxValueIncrementerFactory factory = new DefaultDataFieldMaxValueIncrementerFactory(dataSource); this.incrementer = factory.getIncrementer(DatabaseType.fromMetaData(dataSource).name(), tablePrefix + "JOB_SEQ"); }
public void testNullIncrementerName(){ try{ factory.getIncrementer("db2", null); fail(); } catch(IllegalArgumentException ex){ //expected } }
public void testUnsupportedDatabaseType(){ assertFalse(factory.isSupportedIncrementerType("invalidtype")); }
@Override public void afterPropertiesSet() throws Exception { Assert.notNull(dataSource, "DataSource must not be null."); if (jdbcOperations == null) { jdbcOperations = new JdbcTemplate(dataSource); } if (incrementerFactory == null) { incrementerFactory = new DefaultDataFieldMaxValueIncrementerFactory(dataSource); } if (databaseType == null) { databaseType = DatabaseType.fromMetaData(dataSource).name(); logger.info("No database type set, using meta data indicating: " + databaseType); } if (lobHandler == null && databaseType.equalsIgnoreCase(DatabaseType.ORACLE.toString())) { lobHandler = new DefaultLobHandler(); } if(serializer == null) { Jackson2ExecutionContextStringSerializer defaultSerializer = new Jackson2ExecutionContextStringSerializer(); serializer = defaultSerializer; } Assert.isTrue(incrementerFactory.isSupportedIncrementerType(databaseType), "'" + databaseType + "' is an unsupported database type. The supported database types are " + StringUtils.arrayToCommaDelimitedString(incrementerFactory.getSupportedIncrementerTypes())); if(lobType != null) { Assert.isTrue(isValidTypes(lobType), "lobType must be a value from the java.sql.Types class"); } super.afterPropertiesSet(); }
public void testMsSqlServer(){ assertTrue(factory.getIncrementer("sqlserver", "NAME") instanceof SqlServerMaxValueIncrementer); }
@Override public boolean isSupportedIncrementerType(String databaseType) { return delegate.isSupportedIncrementerType(databaseType); }
@Override public void afterPropertiesSet() throws Exception { if (incrementerFactory == null) { incrementerFactory = new DefaultDataFieldMaxValueIncrementerFactory(dataSource); } super.afterPropertiesSet(); }
public void testDb2zos(){ assertTrue(factory.getIncrementer("db2zos", "NAME") instanceof Db2MainframeMaxValueIncrementer); }
@Override public void afterPropertiesSet() throws Exception { DataFieldMaxValueIncrementerFactory factory = new DefaultDataFieldMaxValueIncrementerFactory(dataSource); this.incrementer = factory.getIncrementer(DatabaseType.fromMetaData(dataSource).name(), tablePrefix + "JOB_SEQ"); }
public void testDerby(){ assertTrue(factory.getIncrementer("derby", "NAME") instanceof DerbyMaxValueIncrementer); }
@Override public void afterPropertiesSet() throws Exception { DataFieldMaxValueIncrementerFactory factory = new DefaultDataFieldMaxValueIncrementerFactory(dataSource); this.incremeter = factory.getIncrementer(DatabaseType.fromMetaData(dataSource).name(), tablePrefix + "JOB_SEQ"); }
public void testSqlite(){ assertTrue(factory.getIncrementer("sqlite", "NAME") instanceof SqliteMaxValueIncrementer); }
@Override public void afterPropertiesSet() throws Exception { DataFieldMaxValueIncrementerFactory factory = new DefaultDataFieldMaxValueIncrementerFactory(dataSource); this.incrementer = factory.getIncrementer(DatabaseType.fromMetaData(dataSource).name(), tablePrefix + "JOB_SEQ"); }
public void testDb2(){ assertTrue(factory.getIncrementer("db2", "NAME") instanceof Db2LuwMaxValueIncrementer); }
@Override public void afterPropertiesSet() throws Exception { Assert.notNull(dataSource, "DataSource must not be null."); Assert.notNull(jobRepository, "JobRepository must not be null."); Assert.notNull(jobLocator, "JobLocator must not be null."); Assert.notNull(jobLauncher, "JobLauncher must not be null."); Assert.notNull(jobExplorer, "JobExplorer must not be null."); jdbcTemplate = new JdbcTemplate(dataSource); if (incrementerFactory == null) { incrementerFactory = new DefaultDataFieldMaxValueIncrementerFactory(dataSource); } if (databaseType == null) { databaseType = DatabaseType.fromMetaData(dataSource).name(); logger.info("No database type set, using meta data indicating: " + databaseType); } if (lobHandler == null) { lobHandler = new DefaultLobHandler(); } if (serializer == null) { this.serializer = new Jackson2ExecutionContextStringSerializer(); } Assert.isTrue(incrementerFactory.isSupportedIncrementerType(databaseType), "'" + databaseType + "' is an unsupported database type. The supported database types are " + StringUtils.arrayToCommaDelimitedString(incrementerFactory.getSupportedIncrementerTypes())); }