Giter Club home page Giter Club logo

Comments (3)

mostafa-korkar1 avatar mostafa-korkar1 commented on May 18, 2024

at io.vertx.core.impl.future.FutureImpl$2.onFailure(FutureImpl.java:117)
at io.vertx.core.impl.future.FutureImpl$ListenerArray.onFailure(FutureImpl.java:268)
at io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75)
at io.vertx.core.impl.future.FutureImpl.tryFail(FutureImpl.java:230)
at io.vertx.core.impl.future.Mapping.onFailure(Mapping.java:45)
at io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75)
at io.vertx.core.impl.future.FutureImpl.tryFail(FutureImpl.java:230)
at io.vertx.core.impl.future.PromiseImpl.tryFail(PromiseImpl.java:23)
at io.vertx.sqlclient.impl.QueryResultBuilder.tryFail(QueryResultBuilder.java:116)
at io.vertx.core.Promise.fail(Promise.java:89)
at io.vertx.core.Promise.handle(Promise.java:53)
at io.vertx.core.Promise.handle(Promise.java:29)
at io.vertx.core.impl.future.FutureImpl$3.onFailure(FutureImpl.java:153)
at io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75)
at io.vertx.core.impl.future.FutureImpl.tryFail(FutureImpl.java:230)
at io.vertx.core.impl.future.Composition$1.onFailure(Composition.java:66)
at io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75)
at io.vertx.core.impl.future.FailedFuture.addListener(FailedFuture.java:98)
at io.vertx.core.impl.future.Composition.onFailure(Composition.java:55)
at io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75)
at io.vertx.core.impl.future.FutureImpl.tryFail(FutureImpl.java:230)
at io.vertx.core.impl.future.PromiseImpl.tryFail(PromiseImpl.java:23)
at io.vertx.core.impl.future.PromiseImpl.onFailure(PromiseImpl.java:54)
at io.vertx.core.impl.future.PromiseImpl.handle(PromiseImpl.java:43)
at io.vertx.core.impl.future.PromiseImpl.handle(PromiseImpl.java:23)
at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:55)
at io.vertx.core.impl.EventLoopContext.lambda$emit$1(EventLoopContext.java:62)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)

May 09, 2023 11:59:11 PM com.coral.bookstore.service.BookHandler$Companion$buildErrorResponse$1 invoke
SEVERE: buildErrorResponse - Error : io.vertx.core.impl.NoStackTraceThrowable: Pool closed

from vertx-sql-client.

mostafa-korkar1 avatar mostafa-korkar1 commented on May 18, 2024

my DB Connection class as following:

`
class DBConnection {

private val logger = Logger.getLogger(DBConnection::class.java.name)

fun pgPool(vertx : Vertx): PgPool {
val context: Context = vertx.orCreateContext
val activeProfile : String = context.config().getString("active_profile", "TEST")
logger.info("DBConnection - active Profile : ".plus(activeProfile))
lateinit var config: JsonObject
lateinit var connectOptions : PgConnectOptions
lateinit var poolOptions : PoolOptions
if (activeProfile.equals("DEV")) {
config = vertx.fileSystem().readFileBlocking("DB_Connection.json").toJsonObject()
connectOptions = PgConnectOptions()
.setPort(config.getInteger("port"))
.setHost(config.getString("host"))
.setDatabase(config.getString("database"))
.setUser(config.getString("user"))
.setPassword(config.getString("password"))
// Pool Options
poolOptions = PoolOptions().setMaxSize(config.getInteger("max_pool_size")).setShared(true)
}else {
connectOptions = PgConnectOptions.fromUri(context.config().getString("db.uri"))
.setUser(context.config().getString("db.username"))
.setPassword(context.config().getString("db.password"))
poolOptions = PoolOptions().setMaxSize(context.config().getInteger("max_pool_size")).setShared(true)
}

// Create the pool from the data object
return PgPool.pool(vertx, connectOptions, poolOptions)

}
}
`

from vertx-sql-client.

mostafa-korkar1 avatar mostafa-korkar1 commented on May 18, 2024

my Test class as following :

`
@testcontainers
@ExtendWith(VertxExtension::class)
class MainVerticleIntegrationTest {

private val logger = Logger.getLogger(MainVerticleIntegrationTest::class.java.name)
private val deploymentOptions: DeploymentOptions = DeploymentOptions()

@beforeeach
fun deploy_verticle(vertx: Vertx, testContext: VertxTestContext) {
val dbUri = postgresqlContainer.jdbcUrl.substringAfter("jdbc:")
deploymentOptions.config = jsonObjectOf(
"db.uri" to dbUri,
"db.username" to DB_USERNAME,
"db.password" to DB_PASSWORD,
"max_pool_size" to 5
)
vertx.deployVerticle(MainVerticle(), deploymentOptions, testContext.succeeding { _ -> testContext.completeNow() })
}

@test
fun test() {
assertThat(postgresqlContainer.isRunning).isTrue
}

@test
@DisplayName("test_return_all_books")
fun test_return_all_books(vertx: Vertx, testContext: VertxTestContext) {

var bookInfoToBeMatched = BookInfo(1, "zxc3", "Test 1", 52)
var client: HttpClient = vertx.createHttpClient()
client.request(HttpMethod.GET, 8090, "localhost", "/books")
  .compose(HttpClientRequest::send)
  .compose(HttpClientResponse::body)
  .onSuccess { body ->
    testContext.verify {
      val bookInfos = toList(body.toJsonArray())
      assertThat(bookInfos).anyMatch { it -> checkingBookMatching(it, bookInfoToBeMatched) }
    }
    testContext.completeNow()
  }
  .onFailure { failure -> testContext.failNow(failure) };

}
companion object {
private const val DB_NAME = "coral_book_store"
private const val DB_USERNAME = "coral"
private const val DB_PASSWORD = "coral"

@Container
private var postgresqlContainer: PostgreSQLContainer<Nothing> = PostgreSQLContainer<Nothing>("postgres:15")
  .apply {
    withDatabaseName(DB_NAME)
    withUsername(DB_USERNAME)
    withPassword(DB_PASSWORD)
  }

}
}
`

from vertx-sql-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.