org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactoryBean Java Examples
The following examples show how to use
org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactoryBean.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JdbcNamespaceIntegrationTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void createAndDestroyNestedWithHsql() throws Exception { ClassPathXmlApplicationContext context = context("jdbc-destroy-nested-config.xml"); try { DataSource dataSource = context.getBean(DataSource.class); JdbcTemplate template = new JdbcTemplate(dataSource); assertNumRowsInTestTable(template, 1); context.getBean(EmbeddedDatabaseFactoryBean.class).destroy(); // Table has been dropped assertThatExceptionOfType(BadSqlGrammarException.class).isThrownBy(() -> assertNumRowsInTestTable(template, 1)); } finally { context.close(); } }
Example #2
Source File: JdbcNamespaceIntegrationTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void createAndDestroyNestedWithH2() throws Exception { ClassPathXmlApplicationContext context = context("jdbc-destroy-nested-config-h2.xml"); try { DataSource dataSource = context.getBean(DataSource.class); JdbcTemplate template = new JdbcTemplate(dataSource); assertNumRowsInTestTable(template, 1); context.getBean(EmbeddedDatabaseFactoryBean.class).destroy(); // Table has been dropped assertThatExceptionOfType(BadSqlGrammarException.class).isThrownBy(() -> assertNumRowsInTestTable(template, 1)); } finally { context.close(); } }
Example #3
Source File: EmbeddedDatabaseBeanDefinitionParser.java From spring-analysis-note with MIT License | 5 votes |
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(EmbeddedDatabaseFactoryBean.class); setGenerateUniqueDatabaseNameFlag(element, builder); setDatabaseName(element, builder); setDatabaseType(element, builder); DatabasePopulatorConfigUtils.setDatabasePopulator(element, builder); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); return builder.getBeanDefinition(); }
Example #4
Source File: EmbeddedDatabaseBeanDefinitionParser.java From java-technology-stack with MIT License | 5 votes |
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(EmbeddedDatabaseFactoryBean.class); setGenerateUniqueDatabaseNameFlag(element, builder); setDatabaseName(element, builder); setDatabaseType(element, builder); DatabasePopulatorConfigUtils.setDatabasePopulator(element, builder); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); return builder.getBeanDefinition(); }
Example #5
Source File: JdbcNamespaceIntegrationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void createAndDestroyNestedWithHsql() throws Exception { ClassPathXmlApplicationContext context = context("jdbc-destroy-nested-config.xml"); try { DataSource dataSource = context.getBean(DataSource.class); JdbcTemplate template = new JdbcTemplate(dataSource); assertNumRowsInTestTable(template, 1); context.getBean(EmbeddedDatabaseFactoryBean.class).destroy(); expected.expect(BadSqlGrammarException.class); // Table has been dropped assertNumRowsInTestTable(template, 1); } finally { context.close(); } }
Example #6
Source File: JdbcNamespaceIntegrationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void createAndDestroyNestedWithH2() throws Exception { ClassPathXmlApplicationContext context = context("jdbc-destroy-nested-config-h2.xml"); try { DataSource dataSource = context.getBean(DataSource.class); JdbcTemplate template = new JdbcTemplate(dataSource); assertNumRowsInTestTable(template, 1); context.getBean(EmbeddedDatabaseFactoryBean.class).destroy(); expected.expect(BadSqlGrammarException.class); // Table has been dropped assertNumRowsInTestTable(template, 1); } finally { context.close(); } }
Example #7
Source File: EmbeddedDatabaseBeanDefinitionParser.java From lams with GNU General Public License v2.0 | 5 votes |
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(EmbeddedDatabaseFactoryBean.class); setGenerateUniqueDatabaseNameFlag(element, builder); setDatabaseName(element, builder); setDatabaseType(element, builder); DatabasePopulatorConfigUtils.setDatabasePopulator(element, builder); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); return builder.getBeanDefinition(); }
Example #8
Source File: EmbeddedDatabaseBeanDefinitionParser.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(EmbeddedDatabaseFactoryBean.class); setGenerateUniqueDatabaseNameFlag(element, builder); setDatabaseName(element, builder); setDatabaseType(element, builder); DatabasePopulatorConfigUtils.setDatabasePopulator(element, builder); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); return builder.getBeanDefinition(); }
Example #9
Source File: JdbcNamespaceIntegrationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void createAndDestroyNestedWithHsql() throws Exception { ClassPathXmlApplicationContext context = context("jdbc-destroy-nested-config.xml"); try { DataSource dataSource = context.getBean(DataSource.class); JdbcTemplate template = new JdbcTemplate(dataSource); assertNumRowsInTestTable(template, 1); context.getBean(EmbeddedDatabaseFactoryBean.class).destroy(); expected.expect(BadSqlGrammarException.class); // Table has been dropped assertNumRowsInTestTable(template, 1); } finally { context.close(); } }
Example #10
Source File: JdbcNamespaceIntegrationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void createAndDestroyNestedWithH2() throws Exception { ClassPathXmlApplicationContext context = context("jdbc-destroy-nested-config-h2.xml"); try { DataSource dataSource = context.getBean(DataSource.class); JdbcTemplate template = new JdbcTemplate(dataSource); assertNumRowsInTestTable(template, 1); context.getBean(EmbeddedDatabaseFactoryBean.class).destroy(); expected.expect(BadSqlGrammarException.class); // Table has been dropped assertNumRowsInTestTable(template, 1); } finally { context.close(); } }
Example #11
Source File: EmbeddedDatabaseBeanDefinitionParser.java From effectivejava with Apache License 2.0 | 5 votes |
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(EmbeddedDatabaseFactoryBean.class); setDatabaseType(element, builder); DatabasePopulatorConfigUtils.setDatabasePopulator(element, builder); useIdAsDatabaseNameIfGiven(element, builder); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); return builder.getBeanDefinition(); }
Example #12
Source File: JdbcNamespaceIntegrationTests.java From effectivejava with Apache License 2.0 | 5 votes |
@Test public void createAndDestroyNestedWithHsql() throws Exception { ClassPathXmlApplicationContext context = context("jdbc-destroy-nested-config.xml"); try { DataSource dataSource = context.getBean(DataSource.class); JdbcTemplate template = new JdbcTemplate(dataSource); assertNumRowsInTestTable(template, 1); context.getBean(EmbeddedDatabaseFactoryBean.class).destroy(); expected.expect(BadSqlGrammarException.class); // Table has been dropped assertNumRowsInTestTable(template, 1); } finally { context.close(); } }
Example #13
Source File: JdbcNamespaceIntegrationTests.java From effectivejava with Apache License 2.0 | 5 votes |
@Test public void createAndDestroyNestedWithH2() throws Exception { ClassPathXmlApplicationContext context = context("jdbc-destroy-nested-config-h2.xml"); try { DataSource dataSource = context.getBean(DataSource.class); JdbcTemplate template = new JdbcTemplate(dataSource); assertNumRowsInTestTable(template, 1); context.getBean(EmbeddedDatabaseFactoryBean.class).destroy(); expected.expect(BadSqlGrammarException.class); // Table has been dropped assertNumRowsInTestTable(template, 1); } finally { context.close(); } }
Example #14
Source File: DataConfig.java From spring-data-examples with MIT License | 5 votes |
@Bean public DataSource dataSource() { EmbeddedDatabaseFactoryBean databaseFactoryBean = new EmbeddedDatabaseFactoryBean(); databaseFactoryBean.setDatabaseType(EmbeddedDatabaseType.H2); databaseFactoryBean.afterPropertiesSet(); return databaseFactoryBean.getObject(); }