This commit is contained in:
Andy Wilkinson
2017-08-30 17:34:07 +01:00
parent afda0ec129
commit 7fc12bc8a3
29 changed files with 80 additions and 96 deletions

View File

@@ -120,12 +120,14 @@ public class FlywayAutoConfigurationTests {
registerAndRefresh(FlywayDataSourceConfiguration.class,
EmbeddedDataSourceConfiguration.class, FlywayAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
FlywaySchemaManagementProvider schemaManagementProvider = this.context.getBean(
FlywaySchemaManagementProvider.class);
assertThat(schemaManagementProvider.getSchemaManagement(this.context.getBean(
DataSource.class))).isEqualTo(SchemaManagement.UNMANAGED);
assertThat(schemaManagementProvider.getSchemaManagement(this.context.getBean(
"flywayDataSource", DataSource.class))).isEqualTo(SchemaManagement.MANAGED);
FlywaySchemaManagementProvider schemaManagementProvider = this.context
.getBean(FlywaySchemaManagementProvider.class);
assertThat(schemaManagementProvider
.getSchemaManagement(this.context.getBean(DataSource.class)))
.isEqualTo(SchemaManagement.UNMANAGED);
assertThat(schemaManagementProvider.getSchemaManagement(
this.context.getBean("flywayDataSource", DataSource.class)))
.isEqualTo(SchemaManagement.MANAGED);
}
@Test

View File

@@ -61,15 +61,16 @@ public class H2ConsoleAutoConfigurationIntegrationTests {
public void noPrincipal() throws Exception {
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(springSecurity()).build();
mockMvc.perform(get("/h2-console/").accept(MediaType.APPLICATION_JSON)).andExpect(status().isUnauthorized());
mockMvc.perform(get("/h2-console/").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isUnauthorized());
}
@Test
public void userPrincipal() throws Exception {
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(springSecurity()).build();
mockMvc.perform(get("/h2-console/").accept(MediaType.APPLICATION_JSON).with(user("test").roles("USER")))
.andExpect(status().isOk())
mockMvc.perform(get("/h2-console/").accept(MediaType.APPLICATION_JSON)
.with(user("test").roles("USER"))).andExpect(status().isOk())
.andExpect(header().string("X-Frame-Options", "SAMEORIGIN"));
}

View File

@@ -70,7 +70,8 @@ public class CustomHibernateJpaAutoConfigurationTests {
HibernateJpaAutoConfiguration.class);
this.context.refresh();
JpaProperties bean = this.context.getBean(JpaProperties.class);
Map<String, String> hibernateProperties = bean.getHibernateProperties("create-drop");
Map<String, String> hibernateProperties = bean
.getHibernateProperties("create-drop");
assertThat(hibernateProperties.get("hibernate.ejb.naming_strategy")).isNull();
}

View File

@@ -53,14 +53,14 @@ public class HibernateDefaultDdlAutoProviderTests {
+ org.apache.tomcat.jdbc.pool.DataSource.class.getName(),
"spring.datasource.database:mysql",
"spring.datasource.url:jdbc:mysql://localhost/nonexistent",
"spring.jpa.database:MYSQL"
).run((context) -> {
HibernateDefaultDdlAutoProvider ddlAutoProvider = new HibernateDefaultDdlAutoProvider(
Collections.emptyList());
assertThat(ddlAutoProvider.getDefaultDdlAuto(
context.getBean(DataSource.class))).isEqualTo("none");
"spring.jpa.database:MYSQL").run((context) -> {
HibernateDefaultDdlAutoProvider ddlAutoProvider = new HibernateDefaultDdlAutoProvider(
Collections.emptyList());
assertThat(ddlAutoProvider
.getDefaultDdlAuto(context.getBean(DataSource.class)))
.isEqualTo("none");
});
});
}
@Test
@@ -68,8 +68,9 @@ public class HibernateDefaultDdlAutoProviderTests {
this.contextRunner.run((context) -> {
HibernateDefaultDdlAutoProvider ddlAutoProvider = new HibernateDefaultDdlAutoProvider(
Collections.emptyList());
assertThat(ddlAutoProvider.getDefaultDdlAuto(
context.getBean(DataSource.class))).isEqualTo("create-drop");
assertThat(
ddlAutoProvider.getDefaultDdlAuto(context.getBean(DataSource.class)))
.isEqualTo("create-drop");
});
}
@@ -82,8 +83,7 @@ public class HibernateDefaultDdlAutoProviderTests {
.willReturn(SchemaManagement.MANAGED);
HibernateDefaultDdlAutoProvider ddlAutoProvider = new HibernateDefaultDdlAutoProvider(
Collections.singletonList(provider));
assertThat(ddlAutoProvider.getDefaultDdlAuto(
dataSource)).isEqualTo("none");
assertThat(ddlAutoProvider.getDefaultDdlAuto(dataSource)).isEqualTo("none");
});
}
@@ -96,8 +96,8 @@ public class HibernateDefaultDdlAutoProviderTests {
.willReturn(SchemaManagement.UNMANAGED);
HibernateDefaultDdlAutoProvider ddlAutoProvider = new HibernateDefaultDdlAutoProvider(
Collections.singletonList(provider));
assertThat(ddlAutoProvider.getDefaultDdlAuto(
dataSource)).isEqualTo("create-drop");
assertThat(ddlAutoProvider.getDefaultDdlAuto(dataSource))
.isEqualTo("create-drop");
});
}