-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29974 from loicmathieu/missing-codestart-tests
Add missing IT for codestart examples
- Loading branch information
Showing
19 changed files
with
361 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...tools/src/test/java/io/quarkus/devtools/codestarts/quarkus/AmazonLambdaCodestartTest.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,32 @@ | ||
package io.quarkus.devtools.codestarts.quarkus; | ||
|
||
import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language.JAVA; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest; | ||
|
||
public class AmazonLambdaCodestartTest { | ||
@RegisterExtension | ||
public static QuarkusCodestartTest codestartTest = QuarkusCodestartTest.builder() | ||
.codestarts("amazon-lambda") | ||
.languages(JAVA) | ||
.build(); | ||
|
||
@Test | ||
void testContent() throws Throwable { | ||
codestartTest.checkGeneratedSource("org.acme.lambda.GreetingLambda"); | ||
codestartTest.checkGeneratedSource("org.acme.lambda.Person"); | ||
|
||
codestartTest.checkGeneratedTestSource("org.acme.lambda.LambdaHandlerTest"); | ||
codestartTest.checkGeneratedTestSource("org.acme.lambda.LambdaHandlerTestIT"); | ||
} | ||
|
||
@Test | ||
@EnabledIfSystemProperty(named = "build-projects", matches = "true") | ||
void buildAllProjectsForLocalUse() throws Throwable { | ||
codestartTest.buildAllProjects(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...src/test/java/io/quarkus/devtools/codestarts/quarkus/AzureFunctionsHttpCodestartTest.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,30 @@ | ||
package io.quarkus.devtools.codestarts.quarkus; | ||
|
||
import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language.JAVA; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest; | ||
|
||
public class AzureFunctionsHttpCodestartTest { | ||
@RegisterExtension | ||
public static QuarkusCodestartTest codestartTest = QuarkusCodestartTest.builder() | ||
.codestarts("azure-functions-http") | ||
.languages(JAVA) | ||
.build(); | ||
|
||
@Test | ||
void testContent() throws Throwable { | ||
codestartTest.assertThatGeneratedFileMatchSnapshot(JAVA, "azure-config/function.json"); | ||
codestartTest.assertThatGeneratedFileMatchSnapshot(JAVA, "azure-config/host.json"); | ||
codestartTest.assertThatGeneratedFileMatchSnapshot(JAVA, "azure-config/local.settings.json"); | ||
} | ||
|
||
@Test | ||
@EnabledIfSystemProperty(named = "build-projects", matches = "true") | ||
void buildAllProjectsForLocalUse() throws Throwable { | ||
codestartTest.buildAllProjects(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
.../src/test/java/io/quarkus/devtools/codestarts/quarkus/FunqyAmazonLambdaCodestartTest.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,32 @@ | ||
package io.quarkus.devtools.codestarts.quarkus; | ||
|
||
import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language.JAVA; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest; | ||
|
||
public class FunqyAmazonLambdaCodestartTest { | ||
@RegisterExtension | ||
public static QuarkusCodestartTest codestartTest = QuarkusCodestartTest.builder() | ||
.codestarts("funqy-amazon-lambda") | ||
.languages(JAVA) | ||
.build(); | ||
|
||
@Test | ||
void testContent() throws Throwable { | ||
codestartTest.checkGeneratedSource("org.acme.funqy.GreetingFunction"); | ||
codestartTest.checkGeneratedSource("org.acme.funqy.Person"); | ||
|
||
codestartTest.checkGeneratedTestSource("org.acme.funqy.FunqyTest"); | ||
codestartTest.checkGeneratedTestSource("org.acme.funqy.FunqyIT"); | ||
} | ||
|
||
@Test | ||
@EnabledIfSystemProperty(named = "build-projects", matches = "true") | ||
void buildAllProjectsForLocalUse() throws Throwable { | ||
codestartTest.buildAllProjects(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...src/test/java/io/quarkus/devtools/codestarts/quarkus/FunqyKnativeEventsCodestartTest.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,32 @@ | ||
package io.quarkus.devtools.codestarts.quarkus; | ||
|
||
import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language.JAVA; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest; | ||
|
||
public class FunqyKnativeEventsCodestartTest { | ||
@RegisterExtension | ||
public static QuarkusCodestartTest codestartTest = QuarkusCodestartTest.builder() | ||
.codestarts("funqy-knative-events") | ||
.languages(JAVA) | ||
.build(); | ||
|
||
@Test | ||
void testContent() throws Throwable { | ||
codestartTest.checkGeneratedSource("org.acme.funqy.cloudevent.CloudEventGreeting"); | ||
codestartTest.checkGeneratedSource("org.acme.funqy.cloudevent.Person"); | ||
|
||
codestartTest.checkGeneratedTestSource("org.acme.funqy.cloudevent.FunqyTest"); | ||
codestartTest.checkGeneratedTestSource("org.acme.funqy.cloudevent.FunqyIT"); | ||
} | ||
|
||
@Test | ||
@EnabledIfSystemProperty(named = "build-projects", matches = "true") | ||
void buildAllProjectsForLocalUse() throws Throwable { | ||
codestartTest.buildAllProjects(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...onLambdaCodestartTest/testContent/src_main_java_ilove_quark_us_lambda_GreetingLambda.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,12 @@ | ||
package ilove.quark.us.lambda; | ||
|
||
import com.amazonaws.services.lambda.runtime.Context; | ||
import com.amazonaws.services.lambda.runtime.RequestHandler; | ||
|
||
public class GreetingLambda implements RequestHandler<Person, String> { | ||
|
||
@Override | ||
public String handleRequest(Person input, Context context) { | ||
return "Hello " + input.getName(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...s__/AmazonLambdaCodestartTest/testContent/src_main_java_ilove_quark_us_lambda_Person.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,15 @@ | ||
package ilove.quark.us.lambda; | ||
|
||
public class Person { | ||
|
||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public Person setName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ambdaCodestartTest/testContent/src_test_java_ilove_quark_us_lambda_LambdaHandlerTest.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,31 @@ | ||
package ilove.quark.us.lambda; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.containsString; | ||
|
||
@QuarkusTest | ||
public class LambdaHandlerTest { | ||
|
||
@Test | ||
public void testSimpleLambdaSuccess() throws Exception { | ||
// you test your lambdas by invoking on http://localhost:8081 | ||
// this works in dev mode too | ||
|
||
Person in = new Person(); | ||
in.setName("Stu"); | ||
given() | ||
.contentType("application/json") | ||
.accept("application/json") | ||
.body(in) | ||
.when() | ||
.post() | ||
.then() | ||
.statusCode(200) | ||
.body(containsString("Hello Stu")); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...bdaCodestartTest/testContent/src_test_java_ilove_quark_us_lambda_LambdaHandlerTestIT.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,9 @@ | ||
package ilove.quark.us.lambda; | ||
|
||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
|
||
@QuarkusIntegrationTest | ||
public class LambdaHandlerTestIT extends LambdaHandlerTest { | ||
|
||
// Execute the same tests but in native mode. | ||
} |
17 changes: 17 additions & 0 deletions
17
...rces/__snapshots__/AzureFunctionsHttpCodestartTest/testContent/azure-config_function.json
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,17 @@ | ||
{ | ||
"scriptFile" : "../test-codestart-1.0.0-codestart.jar", | ||
"entryPoint" : "io.quarkus.azure.functions.resteasy.runtime.Function.run", | ||
"bindings" : [ { | ||
"type" : "httpTrigger", | ||
"direction" : "in", | ||
"name" : "req", | ||
"route" : "{*path}", | ||
"methods" : [ "GET", "POST", "HEAD", "PUT", "OPTIONS", "DELETE" ], | ||
"dataType" : "binary", | ||
"authLevel" : "ANONYMOUS" | ||
}, { | ||
"type" : "http", | ||
"direction" : "out", | ||
"name" : "$return" | ||
} ] | ||
} |
3 changes: 3 additions & 0 deletions
3
...esources/__snapshots__/AzureFunctionsHttpCodestartTest/testContent/azure-config_host.json
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,3 @@ | ||
{ | ||
"version": "2.0" | ||
} |
7 changes: 7 additions & 0 deletions
7
..._snapshots__/AzureFunctionsHttpCodestartTest/testContent/azure-config_local.settings.json
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,7 @@ | ||
{ | ||
"IsEncrypted": false, | ||
"Values": { | ||
"AzureWebJobsStorage": "", | ||
"FUNCTIONS_WORKER_RUNTIME": "java" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...nLambdaCodestartTest/testContent/src_main_java_ilove_quark_us_funqy_GreetingFunction.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,11 @@ | ||
package ilove.quark.us.funqy; | ||
|
||
import io.quarkus.funqy.Funq; | ||
|
||
public class GreetingFunction { | ||
|
||
@Funq | ||
public String myFunqyGreeting(Person friend) { | ||
return "Hello " + friend.getName(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...FunqyAmazonLambdaCodestartTest/testContent/src_main_java_ilove_quark_us_funqy_Person.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,19 @@ | ||
package ilove.quark.us.funqy; | ||
|
||
public class Person { | ||
private String name; | ||
|
||
public Person() {} | ||
|
||
public Person(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...unqyAmazonLambdaCodestartTest/testContent/src_test_java_ilove_quark_us_funqy_FunqyIT.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,10 @@ | ||
package ilove.quark.us.funqy; | ||
|
||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
|
||
@QuarkusIntegrationTest | ||
public class FunqyIT extends FunqyTest { | ||
|
||
// Run the same tests | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...qyAmazonLambdaCodestartTest/testContent/src_test_java_ilove_quark_us_funqy_FunqyTest.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,31 @@ | ||
package ilove.quark.us.funqy; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.containsString; | ||
|
||
@QuarkusTest | ||
public class FunqyTest { | ||
|
||
@Test | ||
public void testFunqyLambda() throws Exception { | ||
// you test your lambdas by invoking on http://localhost:8081 | ||
// this works in dev mode too | ||
|
||
Person in = new Person(); | ||
in.setName("Bill"); | ||
given() | ||
.contentType("application/json") | ||
.accept("application/json") | ||
.body(in) | ||
.when() | ||
.post() | ||
.then() | ||
.statusCode(200) | ||
.body(containsString("Hello Bill")); | ||
} | ||
|
||
} | ||
|
13 changes: 13 additions & 0 deletions
13
...artTest/testContent/src_main_java_ilove_quark_us_funqy_cloudevent_CloudEventGreeting.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 ilove.quark.us.funqy.cloudevent; | ||
|
||
import io.quarkus.funqy.Funq; | ||
import org.jboss.logging.Logger; | ||
|
||
public class CloudEventGreeting { | ||
private static final Logger log = Logger.getLogger(CloudEventGreeting.class); | ||
|
||
@Funq | ||
public void myCloudEventGreeting(Person input) { | ||
log.info("Hello " + input.getName()); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...EventsCodestartTest/testContent/src_main_java_ilove_quark_us_funqy_cloudevent_Person.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,19 @@ | ||
package ilove.quark.us.funqy.cloudevent; | ||
|
||
public class Person { | ||
private String name; | ||
|
||
public Person() {} | ||
|
||
public Person(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...ventsCodestartTest/testContent/src_test_java_ilove_quark_us_funqy_cloudevent_FunqyIT.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,10 @@ | ||
package ilove.quark.us.funqy.cloudevent; | ||
|
||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
|
||
@QuarkusIntegrationTest | ||
public class FunqyIT extends FunqyTest { | ||
|
||
// Run the same tests | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...ntsCodestartTest/testContent/src_test_java_ilove_quark_us_funqy_cloudevent_FunqyTest.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,28 @@ | ||
package ilove.quark.us.funqy.cloudevent; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.restassured.RestAssured; | ||
import org.hamcrest.Matchers; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.UUID; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
|
||
@QuarkusTest | ||
public class FunqyTest { | ||
|
||
@Test | ||
public void testCloudEvent() { | ||
RestAssured.given().contentType("application/json") | ||
.header("ce-specversion", "1.0") | ||
.header("ce-id", UUID.randomUUID().toString()) | ||
.header("ce-type", "myCloudEventGreeting") | ||
.header("ce-source", "test") | ||
.body("{ \"name\": \"Bill\" }") | ||
.post("/") | ||
.then().statusCode(204); | ||
} | ||
} |