-
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.
- Loading branch information
Showing
8 changed files
with
130 additions
and
2 deletions.
There are no files selected for viewing
65 changes: 63 additions & 2 deletions
65
...easy-qute/deployment/src/test/java/io/quarkus/qute/resteasy/deployment/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 |
---|---|---|
@@ -1,25 +1,86 @@ | ||
package io.quarkus.qute.resteasy.deployment; | ||
|
||
import java.util.Map; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.QueryParam; | ||
|
||
import org.jboss.resteasy.annotations.jaxrs.QueryParam; | ||
|
||
import io.quarkus.qute.Template; | ||
import io.quarkus.qute.TemplateInstance; | ||
import io.quarkus.qute.api.CheckedTemplateInstance; | ||
import io.quarkus.resteasy.qute.runtime.ResteasyTemplate; | ||
|
||
@Path("hello") | ||
public class HelloResource { | ||
|
||
public static class typeError2 extends CheckedTemplateInstance { | ||
public typeError2(String name) { | ||
} | ||
} | ||
|
||
public static class typedTemplate extends CheckedTemplateInstance { | ||
// // GENERATED | ||
// private final Map<String, Object> bindings = new HashMap<>(); | ||
|
||
public typedTemplate(String name, Map<String, Object> other) { | ||
// // GENERATED | ||
// bindings.put("name", name); | ||
} | ||
|
||
// // GENERATED | ||
// @Override | ||
// protected String getTemplateId() { | ||
// return "HelloResource/typedTemplate"; | ||
// } | ||
// | ||
// // GENERATED | ||
// @Override | ||
// protected Map<String, Object> getBindings() { | ||
// return bindings; | ||
// } | ||
} | ||
|
||
@Inject | ||
Template hello; | ||
|
||
@GET | ||
public TemplateInstance get(@QueryParam("name") String name) { | ||
public TemplateInstance get(@QueryParam String name) { | ||
if (name == null) { | ||
name = "world"; | ||
} | ||
return hello.data("name", name); | ||
} | ||
|
||
@Path("no-injection") | ||
@GET | ||
public TemplateInstance hello(@QueryParam String name) { | ||
if (name == null) { | ||
name = "world"; | ||
} | ||
return ResteasyTemplate.data("name", name); | ||
} | ||
|
||
@Path("type-error") | ||
@GET | ||
public TemplateInstance typeError() { | ||
return ResteasyTemplate.data("name", "world"); | ||
} | ||
|
||
@Path("type-error2") | ||
@GET | ||
public typeError2 typeError2() { | ||
return new typeError2("world"); | ||
} | ||
|
||
@Path("typed-template") | ||
@GET | ||
public typedTemplate typedTemplate(@QueryParam String name) { | ||
if (name == null) { | ||
name = "world"; | ||
} | ||
return new typedTemplate(name, null); | ||
} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
...easy-qute/deployment/src/test/java/io/quarkus/qute/resteasy/deployment/TypeErrorTest.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 io.quarkus.qute.resteasy.deployment; | ||
|
||
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.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
import org.wildfly.common.Assert; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class TypeErrorTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest configError = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClass(HelloResource.class) | ||
.addAsResource("templates/HelloResource/hello.txt") | ||
.addAsResource("templates/HelloResource/typeError.txt") | ||
.addAsResource(new StringAsset("Hello {name}!"), "templates/hello.txt")) | ||
.assertException(t -> { | ||
Assert.assertTrue(t.getMessage().contains("Incorrect expression: name.foo()")); | ||
}); | ||
|
||
@Test | ||
public void emptyTest() { | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...asy-qute/deployment/src/test/java/io/quarkus/qute/resteasy/deployment/TypeErrorTest2.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,29 @@ | ||
package io.quarkus.qute.resteasy.deployment; | ||
|
||
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.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
import org.wildfly.common.Assert; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class TypeErrorTest2 { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest configError = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClass(HelloResource.class) | ||
.addAsResource("templates/HelloResource/hello.txt") | ||
.addAsResource("templates/HelloResource/typeError2.txt") | ||
.addAsResource(new StringAsset("Hello {name}!"), "templates/hello.txt")) | ||
.assertException(t -> { | ||
t.printStackTrace(); | ||
Assert.assertTrue(t.getMessage().contains("Incorrect expression: name.foo()")); | ||
}); | ||
|
||
@Test | ||
public void emptyTest() { | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
extensions/resteasy-qute/deployment/src/test/resources/templates/HelloResource/hello.txt
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 @@ | ||
Salut {name}! |
1 change: 1 addition & 0 deletions
1
extensions/resteasy-qute/deployment/src/test/resources/templates/HelloResource/typeError.txt
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 @@ | ||
{@java.lang.String name}Salut {name.foo()}! |
1 change: 1 addition & 0 deletions
1
...nsions/resteasy-qute/deployment/src/test/resources/templates/HelloResource/typeError2.txt
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 @@ | ||
Salut {name.foo()}! |
1 change: 1 addition & 0 deletions
1
...ons/resteasy-qute/deployment/src/test/resources/templates/HelloResource/typedTemplate.txt
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 @@ | ||
Salut {name}! |