forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Qute type-safe validation - validate namespace extension methods
- also improve the error message if no resolver is found for a namespace at runtime - resolves quarkusio#20701 (cherry picked from commit 2cef352)
- Loading branch information
1 parent
79b41d4
commit 0a23066
Showing
7 changed files
with
200 additions
and
37 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
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
58 changes: 58 additions & 0 deletions
58
...o/quarkus/qute/deployment/extensions/NamespaceTemplateExtensionValidationFailureTest.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,58 @@ | ||
package io.quarkus.qute.deployment.extensions; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
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 io.quarkus.qute.TemplateException; | ||
import io.quarkus.qute.TemplateExtension; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class NamespaceTemplateExtensionValidationFailureTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addAsResource(new StringAsset( | ||
"{bro:surname}\n" | ||
+ "{bro:name.bubu}"), | ||
"templates/foo.html") | ||
.addClasses(SomeExtensions.class)) | ||
.assertException(t -> { | ||
Throwable e = t; | ||
TemplateException te = null; | ||
while (e != null) { | ||
if (e instanceof TemplateException) { | ||
te = (TemplateException) e; | ||
break; | ||
} | ||
e = e.getCause(); | ||
} | ||
assertNotNull(te); | ||
assertTrue(te.getMessage().contains("Found template problems (2)"), te.getMessage()); | ||
assertTrue(te.getMessage().contains("no matching namespace [bro] extension method found"), te.getMessage()); | ||
assertTrue(te.getMessage().contains("property/method [bubu] not found on class [java.lang.String]"), | ||
te.getMessage()); | ||
}); | ||
|
||
@Test | ||
public void test() { | ||
fail(); | ||
} | ||
|
||
@TemplateExtension(namespace = "bro") | ||
public static class SomeExtensions { | ||
|
||
static String name() { | ||
return "bubu"; | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.