This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git
The following commit(s) were added to refs/heads/master by this push:
new abab1682aa WICKET-7117 Fixed tests in ApacheLicenceHeaderTest and
LocalizerTest. Also fixed code warnings. (#908)
abab1682aa is described below
commit abab1682aac22371738d7e7214514b7f781e3134
Author: Johan Stuyts <[email protected]>
AuthorDate: Mon Jul 1 12:58:27 2024 +0200
WICKET-7117 Fixed tests in ApacheLicenceHeaderTest and LocalizerTest. Also
fixed code warnings. (#908)
---
.../test/java/org/apache/wicket/LocalizerTest.java | 25 +++++++++++-----------
.../core/util/license/ApacheLicenceHeaderTest.java | 8 ++++---
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git
a/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java
b/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java
index 9f922e58d0..40b92cbb97 100644
--- a/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java
+++ b/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java
@@ -18,7 +18,6 @@ package org.apache.wicket;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.Arrays;
@@ -36,7 +35,6 @@ import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.resource.DummyApplication;
import org.apache.wicket.resource.loader.ComponentStringResourceLoader;
import org.apache.wicket.settings.ResourceSettings;
-import org.apache.wicket.util.string.Strings;
import org.apache.wicket.util.tester.WicketTester;
import org.apache.wicket.util.value.ValueMap;
import org.junit.jupiter.api.AfterEach;
@@ -68,7 +66,7 @@ class LocalizerTest
}
@AfterEach
- void tearDown() throws Exception
+ void tearDown()
{
tester.destroy();
}
@@ -151,7 +149,7 @@ class LocalizerTest
ValueMap vm = new ValueMap();
vm.put("user", "John Doe");
vm.put("rating", 4.5);
- IModel<ValueMap> model = new Model<ValueMap>(vm);
+ IModel<ValueMap> model = new Model<>(vm);
assertEquals("John Doe gives 4,5 stars",
localizer.getString("test.substitute", null, model,
null),
"Property substitution should occur");
@@ -194,7 +192,7 @@ class LocalizerTest
{
Session.get().setLocale(Locale.GERMAN);
- HashMap<String, Object> model = new HashMap<String, Object>();
+ HashMap<String, Object> model = new HashMap<>();
model.put("user", "juergen");
model.put("rating", 4.5);
@@ -216,6 +214,10 @@ class LocalizerTest
void test_1851_1()
{
MyMockPage page = new MyMockPage();
+ // Set it to any locale except for Dutch (or a variant
thereof), because there is a file
+ // containing Dutch translations for MyMockPage. Those
translations will not match
+ // 'value 1' below.
+ tester.getSession().setLocale(Locale.FRENCH);
tester.getApplication().getResourceSettings().setThrowExceptionOnMissingResource(false);
tester.getApplication().getResourceSettings().setUseDefaultOnMissingResource(false);
@@ -226,10 +228,7 @@ class LocalizerTest
option = localizer.getStringIgnoreSettings("dummy.null",
page.drop1, null, null);
assertNull(option);
- if (Strings.isEmpty(option))
- {
- option = localizer.getString("null", page.drop1,
"CHOOSE_ONE");
- }
+ option = localizer.getString("null", page.drop1, "CHOOSE_ONE");
assertEquals("value 1", option);
tester.getApplication().getResourceSettings().setThrowExceptionOnMissingResource(false);
@@ -247,7 +246,7 @@ class LocalizerTest
try
{
localizer.getString("dummy.null", page.drop1, null,
null);
- assertTrue(false, "Expected an exception to happen");
+ fail("Expected an exception to happen");
}
catch (MissingResourceException ex)
{
@@ -269,12 +268,12 @@ class LocalizerTest
*/
MyMockPage()
{
- final Form<Void> form = new Form<Void>("form");
+ final Form<Void> form = new Form<>("form");
add(form);
String[] choices = { "choice1", "choice2" };
- drop1 = new DropDownChoice<String>("drop1",
Arrays.asList(choices));
- drop2 = new DropDownChoice<String>("drop2",
Arrays.asList(choices));
+ drop1 = new DropDownChoice<>("drop1",
Arrays.asList(choices));
+ drop2 = new DropDownChoice<>("drop2",
Arrays.asList(choices));
form.add(drop1);
form.add(drop2);
diff --git
a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/license/ApacheLicenceHeaderTest.java
b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/license/ApacheLicenceHeaderTest.java
index 168638b825..5426729976 100644
---
a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/license/ApacheLicenceHeaderTest.java
+++
b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/license/ApacheLicenceHeaderTest.java
@@ -17,8 +17,6 @@
package org.apache.wicket.core.util.license;
-import java.io.File;
-
import org.apache.wicket.util.license.ApacheLicenseHeaderTestCase;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -146,7 +144,11 @@ class ApacheLicenceHeaderTest extends
ApacheLicenseHeaderTestCase
}
finally
{
- System.setProperty(propertyName, basedir);
+ if (basedir == null) {
+ System.clearProperty(propertyName);
+ } else {
+ System.setProperty(propertyName, basedir);
+ }
}
}
}