|  | 
|  | 1 | +/* Hibernate, Relational Persistence for Idiomatic Java | 
|  | 2 | + * | 
|  | 3 | + * SPDX-License-Identifier: Apache-2.0 | 
|  | 4 | + * Copyright: Red Hat Inc. and Hibernate Authors | 
|  | 5 | + */ | 
|  | 6 | +package org.hibernate.reactive; | 
|  | 7 | + | 
|  | 8 | +import org.hibernate.cfg.Configuration; | 
|  | 9 | +import org.hibernate.reactive.provider.Settings; | 
|  | 10 | +import org.hibernate.service.spi.ServiceException; | 
|  | 11 | + | 
|  | 12 | +import org.junit.jupiter.api.Test; | 
|  | 13 | + | 
|  | 14 | +import io.vertx.junit5.Timeout; | 
|  | 15 | +import io.vertx.junit5.VertxTestContext; | 
|  | 16 | + | 
|  | 17 | +import static java.util.concurrent.TimeUnit.MINUTES; | 
|  | 18 | +import static org.assertj.core.api.Assertions.assertThat; | 
|  | 19 | +import static org.hibernate.reactive.testing.ReactiveAssertions.assertThrown; | 
|  | 20 | + | 
|  | 21 | +/** | 
|  | 22 | + * Check that the right exception is thrown when there is an error when the JDBC URI scheme is not recognized. | 
|  | 23 | + */ | 
|  | 24 | +@Timeout(value = 10, timeUnit = MINUTES) | 
|  | 25 | +public class WrongJdbcUrlTest extends BaseReactiveTest { | 
|  | 26 | + | 
|  | 27 | +	@Override | 
|  | 28 | +	protected void setProperties(Configuration configuration) { | 
|  | 29 | +		configuration.setProperty( Settings.JAKARTA_JDBC_URL, "jdbc:h2:~/h2temp" ); | 
|  | 30 | +		setSqlLoggingProperties( configuration ); | 
|  | 31 | +	} | 
|  | 32 | + | 
|  | 33 | +	@Override | 
|  | 34 | +	public void before(VertxTestContext context) { | 
|  | 35 | +		// We need to postpone the creation of the factory so that we can check the exception | 
|  | 36 | +	} | 
|  | 37 | + | 
|  | 38 | +	@Test | 
|  | 39 | +	public void testWithTransaction(VertxTestContext context) { | 
|  | 40 | +		test( context, assertThrown( ServiceException.class, setupSessionFactory( this::constructConfiguration ) ) | 
|  | 41 | +				.thenAccept( WrongJdbcUrlTest::assertException ) | 
|  | 42 | +		); | 
|  | 43 | +	} | 
|  | 44 | + | 
|  | 45 | +	private static void assertException(Throwable throwable) { | 
|  | 46 | +		assertThat( throwable.getMessage().toLowerCase() ) | 
|  | 47 | +				.contains( "could not determine dialect from connection uri" ); | 
|  | 48 | +	} | 
|  | 49 | + | 
|  | 50 | +} | 
0 commit comments