Skip to main content
cuerpo editado
Origen Enlace

tengoTengo problemas al mockear un test que utiliza el postgres, si le pongo datos ficticios a la cadena de conexion del postgres me sale error al momento de compilar. Adjunto estructura y build.

spring:
 datasource:
   driver-class-name: org.postgresql.Driver
    hikari:
      jdbc-url: jdbc:postgresql://localhost:5432/example?currentSchema=public
      username: usuario
      password: password

introducir la descripción de la imagen aquí

2023-05-29 09:47:37.357 ERROR 8880 --- [           main] o.s.boot.SpringApplication                   : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/ingrid/ms/aplicacion/config/DataSourceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.NullPointerException

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/ingrid/ms/aplicacion/config/DataSourceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.NullPointerException

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.NullPointerException

Caused by: java.lang.NullPointerException: null

org.postgresql.util.PSQLException: FATAL: password authentication failed for user "usuario"

El lenguaje usado es Java y test JUnit y Mockito

Saben de que otra manera puedo mockear?

tengo problemas al mockear un test que utiliza el postgres, si le pongo datos ficticios a la cadena de conexion del postgres me sale error al momento de compilar. Adjunto estructura y build.

spring:
 datasource:
   driver-class-name: org.postgresql.Driver
    hikari:
      jdbc-url: jdbc:postgresql://localhost:5432/example?currentSchema=public
      username: usuario
      password: password

introducir la descripción de la imagen aquí

2023-05-29 09:47:37.357 ERROR 8880 --- [           main] o.s.boot.SpringApplication                   : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/ingrid/ms/aplicacion/config/DataSourceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.NullPointerException

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/ingrid/ms/aplicacion/config/DataSourceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.NullPointerException

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.NullPointerException

Caused by: java.lang.NullPointerException: null

org.postgresql.util.PSQLException: FATAL: password authentication failed for user "usuario"

El lenguaje usado es Java y test JUnit y Mockito

Saben de que otra manera puedo mockear?

Tengo problemas al mockear un test que utiliza el postgres, si le pongo datos ficticios a la cadena de conexion del postgres me sale error al momento de compilar. Adjunto estructura y build.

spring:
 datasource:
   driver-class-name: org.postgresql.Driver
    hikari:
      jdbc-url: jdbc:postgresql://localhost:5432/example?currentSchema=public
      username: usuario
      password: password

introducir la descripción de la imagen aquí

2023-05-29 09:47:37.357 ERROR 8880 --- [           main] o.s.boot.SpringApplication                   : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/ingrid/ms/aplicacion/config/DataSourceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.NullPointerException

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/ingrid/ms/aplicacion/config/DataSourceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.NullPointerException

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.NullPointerException

Caused by: java.lang.NullPointerException: null

org.postgresql.util.PSQLException: FATAL: password authentication failed for user "usuario"

El lenguaje usado es Java y test JUnit y Mockito

Saben de que otra manera puedo mockear?

Origen Enlace

Como mockear el Postgres en WebFlux

tengo problemas al mockear un test que utiliza el postgres, si le pongo datos ficticios a la cadena de conexion del postgres me sale error al momento de compilar. Adjunto estructura y build.

spring:
 datasource:
   driver-class-name: org.postgresql.Driver
    hikari:
      jdbc-url: jdbc:postgresql://localhost:5432/example?currentSchema=public
      username: usuario
      password: password

introducir la descripción de la imagen aquí

2023-05-29 09:47:37.357 ERROR 8880 --- [           main] o.s.boot.SpringApplication                   : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/ingrid/ms/aplicacion/config/DataSourceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.NullPointerException

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/ingrid/ms/aplicacion/config/DataSourceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.NullPointerException

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.NullPointerException

Caused by: java.lang.NullPointerException: null

org.postgresql.util.PSQLException: FATAL: password authentication failed for user "usuario"

El lenguaje usado es Java y test JUnit y Mockito

Saben de que otra manera puedo mockear?