diff --git a/hibernate5/src/test/java/com/baeldung/hibernate/multitenancy/schema/SchemaMultiTenantConnectionProvider.java b/hibernate5/src/test/java/com/baeldung/hibernate/multitenancy/schema/SchemaMultiTenantConnectionProvider.java index 5045c3ee8e..601eba651c 100644 --- a/hibernate5/src/test/java/com/baeldung/hibernate/multitenancy/schema/SchemaMultiTenantConnectionProvider.java +++ b/hibernate5/src/test/java/com/baeldung/hibernate/multitenancy/schema/SchemaMultiTenantConnectionProvider.java @@ -8,12 +8,15 @@ import java.util.Properties; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; import org.hibernate.engine.jdbc.connections.spi.AbstractMultiTenantConnectionProvider; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; -import org.junit.Assert; @SuppressWarnings("serial") public class SchemaMultiTenantConnectionProvider extends AbstractMultiTenantConnectionProvider { - private final ConnectionProvider connectionProvider = initConnectionProvider(); + private final ConnectionProvider connectionProvider; + + public SchemaMultiTenantConnectionProvider() throws IOException { + connectionProvider = initConnectionProvider(); + } @Override protected ConnectionProvider getAnyConnectionProvider() { @@ -33,13 +36,9 @@ public class SchemaMultiTenantConnectionProvider extends AbstractMultiTenantConn return connection; } - private ConnectionProvider initConnectionProvider() { + private ConnectionProvider initConnectionProvider() throws IOException { Properties properties = new Properties(); - try { - properties.load(getClass().getResourceAsStream("/hibernate-schema-multitenancy.properties")); - } catch (IOException e) { - Assert.fail("Error loading resource. Cause: " + e.getMessage()); - } + properties.load(getClass().getResourceAsStream("/hibernate-schema-multitenancy.properties")); DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl(); connectionProvider.configure(properties);