-
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.
Merge pull request #16583 from mkouba/qute-message-bundles-nested-int…
…erface Type-safe message bundles - handle nested bundle classes correctly
- Loading branch information
Showing
3 changed files
with
80 additions
and
23 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
51 changes: 51 additions & 0 deletions
51
...loyment/src/test/java/io/quarkus/qute/deployment/i18n/NestedMessageBundleDevModeTest.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,51 @@ | ||
package io.quarkus.qute.deployment.i18n; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import javax.enterprise.event.Observes; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.qute.i18n.Message; | ||
import io.quarkus.qute.i18n.MessageBundle; | ||
import io.quarkus.qute.i18n.MessageBundles; | ||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.restassured.RestAssured; | ||
import io.vertx.ext.web.Router; | ||
|
||
public class NestedMessageBundleDevModeTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest testConfig = new QuarkusDevModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(MyNestedMessages.class, TestRouteConfig.class)); | ||
|
||
@Test | ||
public void testMessages() { | ||
assertEquals("Hello Jachym!", RestAssured.get("test").then().statusCode(200).extract().body().asString()); | ||
testConfig.modifySourceFile(NestedMessageBundleDevModeTest.class, s -> s.replace("Hello {name}!", "Hi {name}!")); | ||
assertEquals("Hi Jachym!", RestAssured.get("test").then().statusCode(200).extract().body().asString()); | ||
} | ||
|
||
@MessageBundle | ||
public interface MyNestedMessages { | ||
|
||
@Message("Hello {name}!") | ||
String hello_name(String name); | ||
|
||
} | ||
|
||
public static class TestRouteConfig { | ||
|
||
void addTestRoute(@Observes Router router) { | ||
router.route("/test") | ||
.produces("text/plain") | ||
.handler(rc -> rc.response().end(MessageBundles.get(MyNestedMessages.class).hello_name("Jachym"))); | ||
} | ||
|
||
} | ||
|
||
} |