forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Qute message bundles - search for localized files in all app archives
- resolves quarkusio#24090
- Loading branch information
Showing
4 changed files
with
129 additions
and
25 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
40 changes: 40 additions & 0 deletions
40
...oyment/src/test/java/io/quarkus/qute/deployment/i18n/LocalizedFileDuplicateFoundTest.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,40 @@ | ||
package io.quarkus.qute.deployment.i18n; | ||
|
||
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.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class LocalizedFileDuplicateFoundTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> root.addAsResource(new StringAsset("hello=Ahoj!"), "messages/messages_cs.properties")) | ||
.withAdditionalDependency( | ||
d -> d.addAsResource(new StringAsset("hello=Cau!"), "messages/messages_cs.properties")) | ||
.assertException(t -> { | ||
Throwable e = t; | ||
IllegalStateException ise = null; | ||
while (e != null) { | ||
if (e instanceof IllegalStateException) { | ||
ise = (IllegalStateException) e; | ||
break; | ||
} | ||
e = e.getCause(); | ||
} | ||
assertNotNull(ise); | ||
assertTrue(ise.getMessage().contains("Duplicate localized files found:"), ise.getMessage()); | ||
assertTrue(ise.getMessage().contains("messages_cs.properties"), ise.getMessage()); | ||
}); | ||
|
||
@Test | ||
public void testValidation() { | ||
fail(); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...eployment/src/test/java/io/quarkus/qute/deployment/i18n/LocalizedFileOutsideRootTest.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.deployment.i18n; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.qute.i18n.Localized; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class LocalizedFileOutsideRootTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> root.addClass(BravoMessages.class)) | ||
.overrideConfigKey("quarkus.default-locale", "en") | ||
.withAdditionalDependency( | ||
d -> d.addAsResource(new StringAsset("hello=Ahoj!"), "messages/msg_cs.properties")); | ||
|
||
@Localized("cs") | ||
BravoMessages messages; | ||
|
||
@Test | ||
public void testLocalizedFile() { | ||
assertEquals("Ahoj!", messages.hello()); | ||
} | ||
|
||
} |