-
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.
Qute: fix template global class generation in the dev mode
- if a non-application template global class is present we have to reflect this fact when assigning the priority for an application template global resolver; otherwise a conflict may occur
- Loading branch information
Showing
11 changed files
with
176 additions
and
20 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
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
8 changes: 8 additions & 0 deletions
8
...yment/src/test/java/io/quarkus/qute/deployment/devmode/QuteDummyTemplateGlobalMarker.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,8 @@ | ||
package io.quarkus.qute.deployment.devmode; | ||
|
||
/** | ||
* Marker interface for {@link TemplateGlobalDevModeTest}. | ||
*/ | ||
public interface QuteDummyTemplateGlobalMarker { | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...eployment/src/test/java/io/quarkus/qute/deployment/devmode/TemplateGlobalDevModeTest.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,45 @@ | ||
package io.quarkus.qute.deployment.devmode; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
|
||
/** | ||
* Test that template globals added in the dev mode are generated correctly after live reload. | ||
* <p> | ||
* The {@link QuteDummyTemplateGlobalMarker} is used to identify an application archive where a dummy built-in class with | ||
* template globals is added. | ||
*/ | ||
public class TemplateGlobalDevModeTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest config = new QuarkusDevModeTest() | ||
.withApplicationRoot(root -> root | ||
.addClasses(TestRoute.class, QuteDummyTemplateGlobalMarker.class) | ||
.addAsResource(new StringAsset( | ||
"{quteDummyFoo}:{testFoo ?: 'NA'}"), | ||
"templates/test.html")); | ||
|
||
@Test | ||
public void testTemplateGlobals() { | ||
given().get("test") | ||
.then() | ||
.statusCode(200) | ||
.body(Matchers.equalTo("bar:NA")); | ||
|
||
// Add application globals - the priority sequence should be automatically | ||
// increased before it's used for TestGlobals | ||
config.addSourceFile(TestGlobals.class); | ||
|
||
given().get("test") | ||
.then() | ||
.statusCode(200) | ||
.body(Matchers.equalTo("bar:baz")); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/devmode/TestGlobals.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 io.quarkus.qute.deployment.devmode; | ||
|
||
import io.quarkus.qute.TemplateGlobal; | ||
|
||
@TemplateGlobal | ||
public class TestGlobals { | ||
|
||
public static String testFoo() { | ||
return "baz"; | ||
} | ||
} |
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