-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump Vert.x to 4.5.6-SNAPSHOT, Bump Scala to 3.4.0
- Loading branch information
1 parent
3d55997
commit aa96386
Showing
19 changed files
with
197 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,4 @@ | |
} | ||
} | ||
|
||
private def listToJsArr(a: Seq[_]) = JsonArray(a: _*) | ||
private def listToJsArr(a: Seq[?]) = JsonArray(a*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
vertx-lang-scala-test/src/test/scala/io/vertx/lang/scala/testing/MainVerticle.scala
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
vertx-lang-scala-test/src/test/scala/io/vertx/lang/scala/testing/MainVerticleSpec.scala
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
vertx-lang-scala-test/src/test/scala/io/vertx/lang/scala/testing/TestVerticle.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.vertx.lang.scala.testing | ||
|
||
import io.vertx.ext.web.Router | ||
import io.vertx.lang.scala.ImplicitConversions.vertxFutureToScalaFuture | ||
import io.vertx.lang.scala.json.json | ||
import io.vertx.lang.scala.* | ||
import org.slf4j.{Logger, LoggerFactory} | ||
|
||
import scala.concurrent.Future | ||
import scala.language.implicitConversions | ||
|
||
class TestVerticle extends ScalaVerticle: | ||
|
||
val log: Logger = LoggerFactory.getLogger(classOf[TestVerticle]) | ||
|
||
override def asyncStart: Future[Unit] = | ||
log.debug("asyncStart!") | ||
val router = Router.router(vertx) | ||
router | ||
.get("/ping") | ||
.handler(_.json(json"""{ "message": "pong" }""")) | ||
router | ||
.get("/hello") | ||
.handler(_.response.putHeader("content-type", "text/plain").end("Hello from Vert.x!")) | ||
router | ||
.delete("/account") | ||
.handler(_.json(json"""{ "message": "ok" }""")) | ||
vertx.createHttpServer | ||
.requestHandler(router) | ||
.listen(8888, "0.0.0.0") | ||
.mapEmpty |
60 changes: 60 additions & 0 deletions
60
vertx-lang-scala-test/src/test/scala/io/vertx/lang/scala/testing/VerticleTestingSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package io.vertx.lang.scala.testing | ||
|
||
import io.vertx.core.http.HttpClientAgent | ||
import io.vertx.lang.scala.* | ||
import io.vertx.lang.scala.ImplicitConversions.vertxFutureToScalaFuture | ||
import io.vertx.lang.scala.json.{json, Json} | ||
import io.vertx.scala.core.* | ||
import org.scalatest.FutureOutcome | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
import scala.compiletime.uninitialized | ||
import scala.language.implicitConversions | ||
|
||
class VerticleTestingSpec extends VerticleTesting[TestVerticle], Matchers: | ||
|
||
var httpClient: HttpClientAgent = uninitialized | ||
|
||
override def withFixture(test: NoArgAsyncTest): FutureOutcome = { | ||
httpClient = vertx.createHttpClient() | ||
complete { | ||
super.withFixture(test) | ||
} lastly { | ||
httpClient.close() | ||
} | ||
} | ||
|
||
"VerticleTesting" should "provide a Vertx instance" in { | ||
vertx should not be null | ||
} | ||
|
||
it should "provide a given VertxExecutionContext instance" in { | ||
summon[VertxExecutionContext] should not be null | ||
} | ||
|
||
"TestVerticle" should "bind to 8888 and answer with 'Hello from Vert.x!'" in { | ||
for { | ||
req <- httpClient.request(RequestOptions(absoluteURI = "http://127.0.0.1:8888/hello")) | ||
res <- req.send | ||
body <- res.body | ||
assertion = body.toString("UTF-8") should equal("Hello from Vert.x!") | ||
} yield assertion | ||
} | ||
|
||
it should "answer with a pong when pinged" in { | ||
for { | ||
req <- httpClient.request(RequestOptions(absoluteURI = "http://127.0.0.1:8888/ping")) | ||
res <- req.send | ||
body <- res.body | ||
assertion = body.toJsonValue should equal(Json.obj("""{ "message": "pong" }""")) | ||
} yield assertion | ||
} | ||
|
||
it should "answer with ok when DELETE /account is called" in { | ||
for { | ||
req <- httpClient.request(HttpMethod("DELETE"), 8888, "127.0.0.1", "/account") | ||
res <- req.send | ||
body <- res.body | ||
assertion = body.toJsonValue should equal(json"""{ "message": "ok" }""") | ||
} yield assertion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.