@@ -373,47 +373,65 @@ void hibernatePropertiesCustomizerCanDisableBeanContainer() {
373373 }
374374
375375 @ Test
376- void dataSourceSchemaCreatedEventFiredWhenDdlAutoPropertyIsSet () {
377- dataSourceSchemaCreatedEventFired ("spring.jpa.hibernate.ddl-auto:create-drop" , true );
376+ void vendorPropertiesWithEmbeddedDatabaseAndNoDdlProperty () {
377+ contextRunner ().run (vendorProperties ((vendorProperties ) -> {
378+ assertThat (vendorProperties ).doesNotContainKeys (AvailableSettings .HBM2DDL_DATABASE_ACTION );
379+ assertThat (vendorProperties .get (AvailableSettings .HBM2DDL_AUTO )).isEqualTo ("create-drop" );
380+ }));
378381 }
379382
380383 @ Test
381- void dataSourceSchemaCreatedEventNotFiredWhenDdlAutoPropertyIsSetToNone () {
382- dataSourceSchemaCreatedEventFired ("spring.jpa.hibernate.ddl-auto:none" , false );
384+ void vendorPropertiesWithDdlAutoPropertyIsSet () {
385+ contextRunner ().withPropertyValues ("spring.jpa.hibernate.ddl-auto=update" )
386+ .run (vendorProperties ((vendorProperties ) -> {
387+ assertThat (vendorProperties ).doesNotContainKeys (AvailableSettings .HBM2DDL_DATABASE_ACTION );
388+ assertThat (vendorProperties .get (AvailableSettings .HBM2DDL_AUTO )).isEqualTo ("update" );
389+ }));
383390 }
384391
385392 @ Test
386- void dataSourceSchemaCreatedEventFiredWhenHibernateSpecificDdlAutoPropertyIsSet () {
387- dataSourceSchemaCreatedEventFired ("spring.jpa.properties.hibernate.hbm2ddl.auto=create" , true );
393+ void vendorPropertiesWithDdlAutoPropertyAndHibernatePropertiesAreSet () {
394+ contextRunner ()
395+ .withPropertyValues ("spring.jpa.hibernate.ddl-auto=update" ,
396+ "spring.jpa.properties.hibernate.hbm2ddl.auto=create-drop" )
397+ .run (vendorProperties ((vendorProperties ) -> {
398+ assertThat (vendorProperties ).doesNotContainKeys (AvailableSettings .HBM2DDL_DATABASE_ACTION );
399+ assertThat (vendorProperties .get (AvailableSettings .HBM2DDL_AUTO )).isEqualTo ("create-drop" );
400+ }));
388401 }
389402
390403 @ Test
391- void dataSourceSchemaCreatedEventNotFiredWhenHibernateSpecificDdlAutoPropertyIsSetToNone () {
392- dataSourceSchemaCreatedEventFired ("spring.jpa.properties.hibernate.hbm2ddl.auto=none" , false );
404+ void vendorPropertiesWithDdlAutoPropertyIsSetToNone () {
405+ contextRunner ().withPropertyValues ("spring.jpa.hibernate.ddl-auto=none" )
406+ .run (vendorProperties ((vendorProperties ) -> assertThat (vendorProperties ).doesNotContainKeys (
407+ AvailableSettings .HBM2DDL_DATABASE_ACTION , AvailableSettings .HBM2DDL_AUTO )));
393408 }
394409
395410 @ Test
396- void dataSourceSchemaCreatedEventFiredWhenJpaDbActionPropertyIsSet () {
397- dataSourceSchemaCreatedEventFired (
398- "spring.jpa.properties.javax.persistence.schema-generation.database.action=drop-and-create" , true );
411+ void vendorPropertiesWhenJpaDdlActionIsSet () {
412+ contextRunner ()
413+ .withPropertyValues ("spring.jpa.properties.javax.persistence.schema-generation.database.action=create" )
414+ .run (vendorProperties ((vendorProperties ) -> {
415+ assertThat (vendorProperties .get (AvailableSettings .HBM2DDL_DATABASE_ACTION )).isEqualTo ("create" );
416+ assertThat (vendorProperties ).doesNotContainKeys (AvailableSettings .HBM2DDL_AUTO );
417+ }));
399418 }
400419
401420 @ Test
402- void dataSourceSchemaCreatedEventNotFiredWhenJpaDbActionPropertyIsSetToNone () {
403- dataSourceSchemaCreatedEventFired (
404- "spring.jpa.properties.javax.persistence.schema-generation.database.action=none" , false );
405- }
406-
407- private void dataSourceSchemaCreatedEventFired (String schemaGenerationPropertyWithValue ,
408- boolean expectEventToBeFired ) {
409- contextRunner ().withUserConfiguration (JpaUsingApplicationListenerConfiguration .class )
410- .withPropertyValues ("spring.datasource.initialization-mode=never" , schemaGenerationPropertyWithValue )
411- .run ((context ) -> {
412- assertThat (context ).hasNotFailed ();
413- assertThat (context .getBean (EventCapturingApplicationListener .class ).events .stream ()
414- .filter (DataSourceSchemaCreatedEvent .class ::isInstance ))
415- .hasSize (expectEventToBeFired ? 1 : 0 );
416- });
421+ void vendorPropertiesWhenBothDdlAutoPropertiesAreSet () {
422+ contextRunner ()
423+ .withPropertyValues ("spring.jpa.properties.javax.persistence.schema-generation.database.action=create" ,
424+ "spring.jpa.hibernate.ddl-auto=create-only" )
425+ .run (vendorProperties ((vendorProperties ) -> {
426+ assertThat (vendorProperties .get (AvailableSettings .HBM2DDL_DATABASE_ACTION )).isEqualTo ("create" );
427+ assertThat (vendorProperties .get (AvailableSettings .HBM2DDL_AUTO )).isEqualTo ("create-only" );
428+ }));
429+ }
430+
431+ private ContextConsumer <AssertableApplicationContext > vendorProperties (
432+ Consumer <Map <String , Object >> vendorProperties ) {
433+ return (context ) -> vendorProperties
434+ .accept (context .getBean (HibernateJpaConfiguration .class ).getVendorProperties ());
417435 }
418436
419437 @ Test
0 commit comments