-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
176 additions
and
5 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
13 changes: 13 additions & 0 deletions
13
...-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/params/HelloResource.java
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,13 @@ | ||
package io.quarkus.vertx.http.testrunner.params; | ||
|
||
import io.vertx.core.Handler; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
public class HelloResource implements Handler<RoutingContext> { | ||
|
||
@Override | ||
public void handle(RoutingContext event) { | ||
event.response().end("hello"); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...tx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/params/OddResource.java
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,13 @@ | ||
package io.quarkus.vertx.http.testrunner.params; | ||
|
||
import io.vertx.core.Handler; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
public class OddResource implements Handler<RoutingContext> { | ||
|
||
@Override | ||
public void handle(RoutingContext event) { | ||
event.response().end(Boolean.toString(Integer.parseInt(event.pathParam("num")) % 2 == 1)); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
.../vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/params/ParamET.java
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,33 @@ | ||
package io.quarkus.vertx.http.testrunner.params; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.is; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
public class ParamET { | ||
|
||
@Test | ||
public void testHelloEndpoint() { | ||
given() | ||
.when().get("/hello") | ||
.then() | ||
.statusCode(200) | ||
.body(is("hello")); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(ints = { 1, 4, 11, 17 }) | ||
void shouldValidateOddNumbers(int x) { | ||
given() | ||
.when().get("/odd/" + x) | ||
.then() | ||
.statusCode(200) | ||
.body(is("true")); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ns/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/params/Setup.java
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,16 @@ | ||
package io.quarkus.vertx.http.testrunner.params; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.event.Observes; | ||
|
||
import io.vertx.ext.web.Router; | ||
|
||
@ApplicationScoped | ||
public class Setup { | ||
|
||
public void route(@Observes Router router) { | ||
router.route("/hello").handler(new HelloResource()); | ||
router.route("/odd/:num").handler(new OddResource()); | ||
} | ||
|
||
} |
74 changes: 74 additions & 0 deletions
74
...ment/src/test/java/io/quarkus/vertx/http/testrunner/params/TestParameterizedTestCase.java
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,74 @@ | ||
package io.quarkus.vertx.http.testrunner.params; | ||
|
||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; | ||
import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; | ||
|
||
public class TestParameterizedTestCase { | ||
|
||
@RegisterExtension | ||
static QuarkusDevModeTest test = new QuarkusDevModeTest() | ||
.setArchiveProducer(new Supplier<JavaArchive>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class).addClasses(OddResource.class, Setup.class, HelloResource.class) | ||
.add(new StringAsset(ContinuousTestingTestUtils.appProperties()), | ||
"application.properties"); | ||
} | ||
}) | ||
.setTestArchiveProducer(new Supplier<JavaArchive>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class).addClass(ParamET.class); | ||
} | ||
}); | ||
|
||
@Test | ||
public void testParameterizedTests() throws InterruptedException { | ||
TestStatus ts = ContinuousTestingTestUtils.waitForFirstRunToComplete(); | ||
Assertions.assertEquals(1L, ts.getLastRun()); | ||
Assertions.assertEquals(1L, ts.getTestsFailed()); | ||
Assertions.assertEquals(4L, ts.getTestsPassed()); | ||
Assertions.assertEquals(0L, ts.getTestsSkipped()); | ||
Assertions.assertEquals(-1L, ts.getRunning()); | ||
|
||
test.modifyTestSourceFile(ParamET.class, new Function<String, String>() { | ||
@Override | ||
public String apply(String s) { | ||
return s.replace("4", "3"); | ||
} | ||
}); | ||
ts = ContinuousTestingTestUtils.waitForRun(2); | ||
Assertions.assertEquals(2L, ts.getLastRun()); | ||
Assertions.assertEquals(0L, ts.getTestsFailed()); | ||
Assertions.assertEquals(5L, ts.getTestsPassed()); //passing test should not have been run | ||
Assertions.assertEquals(0L, ts.getTestsSkipped()); | ||
Assertions.assertEquals(-1L, ts.getRunning()); | ||
Assertions.assertEquals(5L, ts.getTotalTestsPassed()); | ||
|
||
test.modifySourceFile(HelloResource.class, new Function<String, String>() { | ||
@Override | ||
public String apply(String s) { | ||
return s.replace("hello", "boo"); | ||
} | ||
}); | ||
ts = ContinuousTestingTestUtils.waitForRun(3); | ||
Assertions.assertEquals(3L, ts.getLastRun()); | ||
Assertions.assertEquals(1L, ts.getTestsFailed()); | ||
Assertions.assertEquals(0L, ts.getTestsPassed()); | ||
Assertions.assertEquals(4L, ts.getTotalTestsPassed()); | ||
Assertions.assertEquals(0L, ts.getTestsSkipped()); | ||
Assertions.assertEquals(-1L, ts.getRunning()); | ||
|
||
} | ||
} |