-
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.
- Loading branch information
Thorsten Marx
committed
Oct 2, 2024
1 parent
f8fe425
commit 9971433
Showing
9 changed files
with
121 additions
and
10 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
74 changes: 74 additions & 0 deletions
74
cms-core/src/test/java/com/condation/cms/core/messages/ThemeMessageSourceTest.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,74 @@ | ||
package com.condation.cms.core.messages; | ||
|
||
/*- | ||
* #%L | ||
* cms-core | ||
* %% | ||
* Copyright (C) 2023 - 2024 CondationCMS | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/gpl-3.0.html>. | ||
* #L% | ||
*/ | ||
|
||
|
||
import com.condation.cms.api.SiteProperties; | ||
import java.nio.file.Path; | ||
import java.util.Map; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* | ||
* @author t.marx | ||
*/ | ||
public class ThemeMessageSourceTest { | ||
|
||
private static DefaultMessageSource messageSource; | ||
private static ThemeMessageSource themeMessageSource; | ||
|
||
@BeforeAll | ||
public static void setup() { | ||
final SiteProperties siteProperties = new SiteProperties(Map.of("language", "de")); | ||
messageSource = new DefaultMessageSource( | ||
siteProperties, | ||
Path.of("src/test/resources/messages") | ||
); | ||
|
||
themeMessageSource = new ThemeMessageSource( | ||
siteProperties, | ||
Path.of("src/test/resources/parent_messages"), | ||
messageSource | ||
); | ||
} | ||
|
||
@Test | ||
public void from_child() { | ||
var label = themeMessageSource.getLabel("abundle", "message.child"); | ||
Assertions.assertThat(label).isEqualTo("hello child"); | ||
} | ||
|
||
@Test | ||
public void from_parent() { | ||
var label = themeMessageSource.getLabel("abundle", "message.parent"); | ||
Assertions.assertThat(label).isEqualTo("hello parent"); | ||
} | ||
|
||
@Test | ||
public void override_parent() { | ||
var label = themeMessageSource.getLabel("abundle", "parent"); | ||
Assertions.assertThat(label).isEqualTo("I override the parent"); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -20,3 +20,5 @@ | |
### | ||
|
||
button.submit=Absenden | ||
message.child=hello child | ||
parent=I override the parent |
23 changes: 23 additions & 0 deletions
23
cms-core/src/test/resources/parent_messages/abundle.properties
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,23 @@ | ||
# #%L | ||
# cms-api | ||
# %% | ||
# Copyright (C) 2023 - 2024 Marx-Software | ||
# %% | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public | ||
# License along with this program. If not, see | ||
# <http://www.gnu.org/licenses/gpl-3.0.html>. | ||
# #L% | ||
### | ||
|
||
message.parent=hello parent | ||
parent=I'm the parent |
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,2 +1,3 @@ | ||
contact.form.title={0} Formular | ||
contact.form.button.submit=Abschicken | ||
contact.form.button.submit=Abschicken | ||
message.site=Site |
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 +1,2 @@ | ||
contact.form.button.submit=Submit | ||
contact.form.button.submit=Submit | ||
message.theme.parent=Parent theme |
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 +1,2 @@ | ||
contact.form.button.submit=Submit | ||
contact.form.button.submit=Submit | ||
message.theme.child=Child theme |
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