@Bean public DataSource dataSource() { return new EmbeddedDatabaseBuilder()// .setName("empty-sql-scripts-without-tx-mgr-test-db")// .build(); } }
@Bean DataSource orderDataSource() { return new EmbeddedDatabaseBuilder().// setType(EmbeddedDatabaseType.HSQL).// setName("orders").// build(); } }
@Bean public DataSource dataSource() { return new EmbeddedDatabaseBuilder()// .setName("empty-sql-scripts-test-db")// .build(); }
@Bean DataSource customerDataSource() { return new EmbeddedDatabaseBuilder().// setType(EmbeddedDatabaseType.HSQL).// setName("customers").// build(); } }
@Bean public DataSource dataSource() { return new EmbeddedDatabaseBuilder()// .addScript("classpath:/org/springframework/test/jdbc/schema.sql")// // Ensure that this in-memory database is only used by this class: .setName(getClass().getName())// .build(); }
@Bean public DataSource dataSource() { return new EmbeddedDatabaseBuilder()// .setName("populated-sql-scripts-test-db")// .addScript("classpath:/org/springframework/test/context/jdbc/schema.sql") // .build(); }
@Bean public DataSource dataSource() { return new EmbeddedDatabaseBuilder()// .setName("programmatic-tx-mgmt-test-db")// .addScript("classpath:/org/springframework/test/context/jdbc/schema.sql") // .build(); } }
/** * Since this method does not reside in a true {@code @Configuration class}, * it acts as a factory method when invoked directly (e.g., from * {@link #transactionManager()}) and as a singleton bean when retrieved * through the application context (e.g., when injected into the test * instance). The result is that this method will be called twice: * * <ol> * <li>once <em>indirectly</em> by the {@link TransactionalTestExecutionListener} * when it retrieves the {@link PlatformTransactionManager} from the * application context</li> * <li>and again when the {@link DataSource} is injected into the test * instance in {@link AbstractTransactionalAnnotatedConfigClassTests#setDataSource(DataSource)}.</li> *</ol> * * Consequently, the {@link JdbcTemplate} used by this test instance and * the {@link PlatformTransactionManager} used by the Spring TestContext * Framework will operate on two different {@code DataSource} instances, * which is almost certainly not the desired or intended behavior. */ @Bean public DataSource dataSource() { return new EmbeddedDatabaseBuilder()// .addScript("classpath:/org/springframework/test/jdbc/schema.sql")// // Ensure that this in-memory database is only used by this class: .setName(getClass().getName())// .build(); }
@Bean public DataSource dataSource2() { return new EmbeddedDatabaseBuilder()// .setName("database2")// .addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")// .addScript("classpath:/org/springframework/test/context/jdbc/data.sql")// .build(); }
@Bean public DataSource dataSource1() { return new EmbeddedDatabaseBuilder()// .setName("database1")// .addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")// .addScript("classpath:/org/springframework/test/context/jdbc/data.sql")// .build(); }
@Bean public DataSource dataSource2() { return new EmbeddedDatabaseBuilder()// .setName("database2")// .addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")// .addScript("classpath:/org/springframework/test/context/jdbc/data.sql")// .build(); } }
@Bean public DataSource dataSource1() { return new EmbeddedDatabaseBuilder()// .setName("database1")// .addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")// .addScript("classpath:/org/springframework/test/context/jdbc/data.sql")// .build(); }
@Bean public DataSource dataSource1() { return new EmbeddedDatabaseBuilder()// .setName("database1")// .addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")// .addScript("classpath:/org/springframework/test/context/jdbc/data.sql")// .build(); }
@Bean public DataSource dataSource2() { return new EmbeddedDatabaseBuilder()// .setName("database2")// .addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")// .addScript("classpath:/org/springframework/test/context/jdbc/data.sql")// .build(); }
@Bean public DataSource dataSource2() { return new EmbeddedDatabaseBuilder()// .setName("database2")// .addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")// .addScript("classpath:/org/springframework/test/context/jdbc/data.sql")// .build(); } }
@Bean public DataSource dataSource1() { return new EmbeddedDatabaseBuilder()// .setName("database1")// .addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")// .addScript("classpath:/org/springframework/test/context/jdbc/data.sql")// .build(); }
@Bean DataSource dataSource2() { return new PooledEmbeddedDataSource(new EmbeddedDatabaseBuilder().setName("badDatabase").build()); } }
@Primary @Bean DataSource dataSource2() { return new PooledEmbeddedDataSource(new EmbeddedDatabaseBuilder(). setName("dataSource2"). addScript("classpath:org/springframework/batch/core/schema-drop-hsqldb.sql"). addScript("classpath:org/springframework/batch/core/schema-hsqldb.sql"). build()); } }
@Bean DataSource dataSource1() { return new PooledEmbeddedDataSource(new EmbeddedDatabaseBuilder(). setName("dataSource1"). addScript("classpath:org/springframework/batch/core/schema-drop-hsqldb.sql"). addScript("classpath:org/springframework/batch/core/schema-hsqldb.sql"). build()); } }
@Bean DataSource dataSource() { // will be autowired by name return new PooledEmbeddedDataSource(new EmbeddedDatabaseBuilder(). setName("dataSource"). addScript("classpath:org/springframework/batch/core/schema-drop-hsqldb.sql"). addScript("classpath:org/springframework/batch/core/schema-hsqldb.sql"). build()); } }