http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/ExceptionTestBase.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/ExceptionTestBase.java b/wicket-core/src/test/java/org/apache/wicket/util/ExceptionTestBase.java index ae7fc9a..05d2203 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/ExceptionTestBase.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/ExceptionTestBase.java @@ -16,11 +16,14 @@ */ package org.apache.wicket.util; -import java.lang.reflect.Constructor; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; -import org.junit.Assert; -import org.junit.Test; +import java.lang.reflect.Constructor; +import org.junit.jupiter.api.Test; /** * Base class for testing exceptions in order to make sure that they achieve 100% test coverage. @@ -28,7 +31,7 @@ import org.junit.Test; * * @author Chris Turner */ -public abstract class ExceptionTestBase extends Assert +public abstract class ExceptionTestBase { /** @@ -45,14 +48,14 @@ public abstract class ExceptionTestBase extends Assert * If test fails */ @Test - public final void emptyConstructor() throws Exception + final void emptyConstructor() throws Exception { Class<?> c = Class.forName(getExceptionClassName()); Constructor<?> constructor = c.getConstructor((Class[])null); Exception e = (Exception)constructor.newInstance((Object[])null); - Assert.assertNotNull("Exception should be created", e); - Assert.assertNull(e.getMessage()); - Assert.assertNull(e.getCause()); + assertNotNull(e, "Exception should be created"); + assertNull(e.getMessage()); + assertNull(e.getCause()); } /** @@ -62,14 +65,14 @@ public abstract class ExceptionTestBase extends Assert * If test fails */ @Test - public final void messageConstructor() throws Exception + final void messageConstructor() throws Exception { Class<?> c = Class.forName(getExceptionClassName()); Constructor<?> constructor = c.getConstructor(new Class[] { String.class }); Exception e = (Exception)constructor.newInstance("test message"); - Assert.assertNotNull("Exception should be created", e); - Assert.assertEquals("test message", e.getMessage()); - Assert.assertNull(e.getCause()); + assertNotNull(e, "Exception should be created"); + assertEquals("test message", e.getMessage()); + assertNull(e.getCause()); } /** @@ -79,14 +82,14 @@ public abstract class ExceptionTestBase extends Assert * If test fails */ @Test - public final void causeConstructor() throws Exception + final void causeConstructor() throws Exception { NullPointerException npe = new NullPointerException(); Class<?> c = Class.forName(getExceptionClassName()); Constructor<?> constructor = c.getConstructor(new Class[] { Throwable.class }); Exception e = (Exception)constructor.newInstance(npe); - Assert.assertNotNull("Exception should be created", e); - Assert.assertSame(npe, e.getCause()); + assertNotNull(e, "Exception should be created"); + assertSame(npe, e.getCause()); } /** @@ -96,15 +99,15 @@ public abstract class ExceptionTestBase extends Assert * If test fails */ @Test - public final void messageAndCauseConstructor() throws Exception + final void messageAndCauseConstructor() throws Exception { NullPointerException npe = new NullPointerException(); Class<?> c = Class.forName(getExceptionClassName()); Constructor<?> constructor = c.getConstructor(new Class[] { String.class, Throwable.class }); Exception e = (Exception)constructor.newInstance("test message", npe); - Assert.assertNotNull("Exception should be created", e); - Assert.assertEquals("test message", e.getMessage()); - Assert.assertSame(npe, e.getCause()); + assertNotNull(e, "Exception should be created"); + assertEquals("test message", e.getMessage()); + assertSame(npe, e.getCause()); } }
http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/Log4jEventHistory.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/Log4jEventHistory.java b/wicket-core/src/test/java/org/apache/wicket/util/Log4jEventHistory.java index a0c17e2..8d87ea9 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/Log4jEventHistory.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/Log4jEventHistory.java @@ -26,7 +26,7 @@ import org.apache.log4j.spi.LoggingEvent; /** * Log the log4j messages for further assertions * */ -public class Log4jEventHistory extends AppenderSkeleton +class Log4jEventHistory extends AppenderSkeleton { private List<LoggingEvent> history = new ArrayList<LoggingEvent>(); http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java b/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java index ab7f8ad..9dc3347 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java @@ -16,31 +16,30 @@ */ package org.apache.wicket.util.cookies; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; - import javax.servlet.http.Cookie; import org.apache.wicket.Page; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.util.cookies.CookieValuePersisterTestPage.TestForm; import org.apache.wicket.util.tester.WicketTestCase; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * * @author Juergen Donnerstag */ -public class CookieUtilsTest extends WicketTestCase +class CookieUtilsTest extends WicketTestCase { - @Before - public void before() + @BeforeEach + void before() { tester.startPage(CookieValuePersisterTestPage.class); } @@ -51,7 +50,7 @@ public class CookieUtilsTest extends WicketTestCase */ @SuppressWarnings({ "unchecked" }) @Test - public void test1() throws Exception + void test1() throws Exception { // How does the test work: Make sure you have a page, form and form component properly set // up (getRelativePath() etc.). See #before(). @@ -127,7 +126,7 @@ public class CookieUtilsTest extends WicketTestCase } @Test - public void saveLoadValue() + void saveLoadValue() { CookieUtils utils = new CookieUtils(); String value1 = "value one"; @@ -135,11 +134,11 @@ public class CookieUtilsTest extends WicketTestCase utils.save(key, value1); before(); // execute a request cycle, so the response cookie is send with the next request String result = utils.load(key); - assertThat(result, is(equalTo(value1))); + assertEquals(value1, result); } @Test - public void defaults() + void defaults() { CookieDefaults defaults = new CookieDefaults(); defaults.setComment("A comment"); @@ -153,7 +152,7 @@ public class CookieUtilsTest extends WicketTestCase utils.save(key, value1); before(); // execute a request cycle, so the response cookie is send with the next request Cookie result = utils.getCookie(key); - assertThat(result.getComment(), is(equalTo(defaults.getComment()))); + assertEquals(defaults.getComment(), result.getComment()); } private void copyCookieFromResponseToRequest() http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieValuePersisterTestPage.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieValuePersisterTestPage.java b/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieValuePersisterTestPage.java index 7aa134b..9144162 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieValuePersisterTestPage.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieValuePersisterTestPage.java @@ -56,7 +56,7 @@ public class CookieValuePersisterTestPage extends WebPage * @param id * Name of form */ - public TestForm(final String id) + TestForm(final String id) { super(id); add(new TextField<String>("input", new Model<String>("test"))); http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/cookies/PreserveRequestCookieAfterLinkClickTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/cookies/PreserveRequestCookieAfterLinkClickTest.java b/wicket-core/src/test/java/org/apache/wicket/util/cookies/PreserveRequestCookieAfterLinkClickTest.java index 9d5213c..fde9098 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/cookies/PreserveRequestCookieAfterLinkClickTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/cookies/PreserveRequestCookieAfterLinkClickTest.java @@ -16,6 +16,8 @@ */ package org.apache.wicket.util.cookies; +import static org.junit.jupiter.api.Assertions.assertEquals; + import javax.servlet.http.Cookie; import org.apache.wicket.MarkupContainer; @@ -25,15 +27,15 @@ import org.apache.wicket.markup.html.link.Link; import org.apache.wicket.util.resource.IResourceStream; import org.apache.wicket.util.resource.StringResourceStream; import org.apache.wicket.util.tester.WicketTestCase; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test for https://issues.apache.org/jira/browse/WICKET-5425 */ -public class PreserveRequestCookieAfterLinkClickTest extends WicketTestCase +class PreserveRequestCookieAfterLinkClickTest extends WicketTestCase { @Test - public void cookiesTransferAfterClickingLink() + void cookiesTransferAfterClickingLink() { Cookie testCookie = new Cookie("lostCookie", "lostValue"); testCookie.setMaxAge(1); @@ -48,9 +50,9 @@ public class PreserveRequestCookieAfterLinkClickTest extends WicketTestCase assertEquals("lostValue", firstCookie.getValue()); } - public static class Page1 extends WebPage implements IMarkupResourceStreamProvider + public static class Page1 extends WebPage implements IMarkupResourceStreamProvider { - public Page1() + public Page1() { add(new Link<Void>("testCookieTransfer") { @@ -68,7 +70,7 @@ public class PreserveRequestCookieAfterLinkClickTest extends WicketTestCase } } - public static class Page2 extends WebPage implements IMarkupResourceStreamProvider + public static class Page2 extends WebPage implements IMarkupResourceStreamProvider { @Override public IResourceStream getMarkupResourceStream(MarkupContainer container, Class<?> containerClass) http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectStatefullTestPage.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectStatefullTestPage.java b/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectStatefullTestPage.java index 9c717e8..0af469b 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectStatefullTestPage.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectStatefullTestPage.java @@ -33,7 +33,7 @@ public class SetCookieAndRedirectStatefullTestPage extends WebPage private static final long serialVersionUID = 1L; /** */ - public static final String cookieName = "CookieValuePersisterStatelessTestPage"; + private static final String cookieName = "CookieValuePersisterStatelessTestPage"; private IModel<String> inputModel; http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectStatelessTestPage.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectStatelessTestPage.java b/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectStatelessTestPage.java index 0b921a1..665bd9d 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectStatelessTestPage.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectStatelessTestPage.java @@ -34,7 +34,7 @@ public class SetCookieAndRedirectStatelessTestPage extends WebPage private static final long serialVersionUID = 1L; /** */ - public static final String cookieName = "CookieValuePersisterStatelessTestPage"; + private static final String cookieName = "CookieValuePersisterStatelessTestPage"; private IModel<String> inputModel; http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectTest.java b/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectTest.java index 5a253bc..4429c0c 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/cookies/SetCookieAndRedirectTest.java @@ -16,21 +16,22 @@ */ package org.apache.wicket.util.cookies; -import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; +import java.util.List; import javax.servlet.http.Cookie; import org.apache.wicket.Page; import org.apache.wicket.util.tester.FormTester; import org.apache.wicket.util.tester.WicketTestCase; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests setting a cookie and calling setResponsePage() in the same request. * * @author Bertrand Guay-Paquet */ -public class SetCookieAndRedirectTest extends WicketTestCase +class SetCookieAndRedirectTest extends WicketTestCase { private static final String cookieValue = "cookieValue"; @@ -38,7 +39,7 @@ public class SetCookieAndRedirectTest extends WicketTestCase * Validate proper cookie value set with stateful page */ @Test - public void statefulPage() + void statefulPage() { tester.startPage(SetCookieAndRedirectStatefullTestPage.class); FormTester formTester = tester.newFormTester("form"); @@ -55,7 +56,7 @@ public class SetCookieAndRedirectTest extends WicketTestCase * Validate proper cookie value set with stateless page */ @Test - public void statelessPage() + void statelessPage() { tester.startPage(SetCookieAndRedirectStatelessTestPage.class); FormTester formTester = tester.newFormTester("form"); http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/file/WebApplicationPathTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/file/WebApplicationPathTest.java b/wicket-core/src/test/java/org/apache/wicket/util/file/WebApplicationPathTest.java index 9532d99..81c288e 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/file/WebApplicationPathTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/file/WebApplicationPathTest.java @@ -16,25 +16,25 @@ */ package org.apache.wicket.util.file; -import java.net.URL; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import java.net.URL; import javax.servlet.ServletContext; import org.apache.wicket.core.util.file.WebApplicationPath; import org.apache.wicket.util.resource.IResourceStream; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatchers; -import org.mockito.Matchers; import org.mockito.Mockito; /** * @since 1.5.5 */ -public class WebApplicationPathTest extends Assert +class WebApplicationPathTest { @Test - public void doNotServeResourcesFromWebInf() throws Exception + void doNotServeResourcesFromWebInf() throws Exception { URL webUrl = new URL("file://dummyFile"); http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/io/SerializableCheckerTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/io/SerializableCheckerTest.java b/wicket-core/src/test/java/org/apache/wicket/util/io/SerializableCheckerTest.java index 0fdce37..8e7d3e1 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/io/SerializableCheckerTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/io/SerializableCheckerTest.java @@ -16,28 +16,23 @@ */ package org.apache.wicket.util.io; -import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.io.NotSerializableException; import java.io.Serializable; -import java.util.Map; -import java.util.Set; -import org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream; -import org.apache.wicket.core.util.objects.checker.ObjectSerializationChecker; import org.apache.wicket.core.util.objects.checker.AbstractObjectChecker; import org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream; -import org.apache.wicket.core.util.objects.checker.IObjectChecker; +import org.apache.wicket.core.util.objects.checker.ObjectSerializationChecker; import org.apache.wicket.util.value.ValueMap; -import org.hamcrest.Matchers; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Pedro Santos */ -public class SerializableCheckerTest extends Assert +class SerializableCheckerTest { /** @@ -46,10 +41,11 @@ public class SerializableCheckerTest extends Assert * @throws IOException */ @Test - public void valueMap() throws IOException + void valueMap() throws IOException { - CheckingObjectOutputStream checker = new CheckingObjectOutputStream(new ByteArrayOutputStream(), - new ObjectSerializationChecker(new NotSerializableException())); + CheckingObjectOutputStream checker = new CheckingObjectOutputStream( + new ByteArrayOutputStream(), + new ObjectSerializationChecker(new NotSerializableException())); checker.writeObject(new ValueMap()); } @@ -62,15 +58,37 @@ public class SerializableCheckerTest extends Assert * @throws IOException */ @Test - public void checkObjectsByIdentity() throws IOException + void checkObjectsByIdentity() throws IOException { CountingChecker countingChecker = new CountingChecker(); - CheckingObjectOutputStream outputStream = new CheckingObjectOutputStream(new ByteArrayOutputStream(), countingChecker); + CheckingObjectOutputStream outputStream = new CheckingObjectOutputStream( + new ByteArrayOutputStream(), countingChecker); final IdentityTestType type = new IdentityTestType(); type.member = new SerializableTypeWithMember(type); outputStream.writeObject(type); - assertThat(countingChecker.getCount(), is(2)); + assertEquals(2, countingChecker.getCount()); + } + + /** + * @throws IOException + */ + @Test + void nonSerializableTypeDetection() throws IOException + { + CheckingObjectOutputStream checker = new CheckingObjectOutputStream( + new ByteArrayOutputStream(), + new ObjectSerializationChecker(new NotSerializableException())); + String exceptionMessage = null; + try + { + checker.writeObject(new TestType2()); + } + catch (CheckingObjectOutputStream.ObjectCheckException e) + { + exceptionMessage = e.getMessage(); + } + assertTrue(exceptionMessage.contains(NonSerializableType.class.getName())); } private static class CountingChecker extends AbstractObjectChecker @@ -100,26 +118,6 @@ public class SerializableCheckerTest extends Assert } } - /** - * @throws IOException - */ - @Test - public void nonSerializableTypeDetection() throws IOException - { - CheckingObjectOutputStream checker = new CheckingObjectOutputStream(new ByteArrayOutputStream(), - new ObjectSerializationChecker(new NotSerializableException())); - String exceptionMessage = null; - try - { - checker.writeObject(new TestType2()); - } - catch (CheckingObjectOutputStream.ObjectCheckException e) - { - exceptionMessage = e.getMessage(); - } - assertTrue(exceptionMessage.contains(NonSerializableType.class.getName())); - } - private static class IdentityTestType implements Serializable { private static final long serialVersionUID = 1L; http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/lang/Country2.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/lang/Country2.java b/wicket-core/src/test/java/org/apache/wicket/util/lang/Country2.java index 6f78975..04ffbad 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/lang/Country2.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/lang/Country2.java @@ -19,7 +19,7 @@ package org.apache.wicket.util.lang; /** * @author jcompagner */ -public class Country2 extends Country +class Country2 extends Country { private final Country country; http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/lang/Document.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/lang/Document.java b/wicket-core/src/test/java/org/apache/wicket/util/lang/Document.java index 11c05fd..1b59337 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/lang/Document.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/lang/Document.java @@ -19,7 +19,7 @@ package org.apache.wicket.util.lang; import java.util.HashMap; import java.util.Map; -public class Document { +class Document { private Map<String, Object> values = new HashMap<>(); http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java b/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java index 5041696..0f11b13 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java @@ -16,6 +16,14 @@ */ package org.apache.wicket.util.lang; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; @@ -41,9 +49,9 @@ import org.apache.wicket.util.convert.ConversionException; import org.apache.wicket.util.convert.IConverter; import org.apache.wicket.util.convert.converter.AbstractConverter; import org.apache.wicket.util.tester.WicketTestCase; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * @author jcompagner @@ -60,8 +68,8 @@ public class PropertyResolverTest extends WicketTestCase /** * @throws Exception */ - @Before - public void before() + @BeforeEach + void before() { person = new Person(); } @@ -69,8 +77,8 @@ public class PropertyResolverTest extends WicketTestCase /** * @throws Exception */ - @After - public void after() + @AfterEach + void after() { PropertyResolver.destroy(tester.getApplication()); } @@ -79,7 +87,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void simpleExpression() throws Exception + void simpleExpression() throws Exception { String name = (String) PropertyResolver.getValue("name", person); assertNull(name); @@ -92,8 +100,8 @@ public class PropertyResolverTest extends WicketTestCase /** * @throws Exception */ - @Test(expected = ConversionException.class) - public void primitiveValue() throws Exception + @Test + void primitiveValue() throws Exception { Integer integer = (Integer)PropertyResolver.getValue("age", person); assertTrue(integer == 0); @@ -102,16 +110,16 @@ public class PropertyResolverTest extends WicketTestCase integer = (Integer)PropertyResolver.getValue("age", person); assertTrue(integer == 10); - PropertyResolver.setValue("age", person, null, CONVERTER); - fail("primitive type can't be set to null"); - + assertThrows(ConversionException.class, () -> { + PropertyResolver.setValue("age", person, null, CONVERTER); + }); } /** * @throws Exception */ @Test - public void pathExpression() throws Exception + void pathExpression() throws Exception { person.setAddress(new Address()); PropertyResolver.setValue("address.street", person, "wicket-street", CONVERTER); @@ -124,7 +132,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void testNull() throws Exception + void testNull() throws Exception { String street = (String)PropertyResolver.getValue("address.street", person); assertNull(street); @@ -134,7 +142,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void nullCreation() throws Exception + void nullCreation() throws Exception { PropertyResolver.setValue("address.street", person, "wicket-street", CONVERTER); String street = (String)PropertyResolver.getValue("address.street", person); @@ -154,7 +162,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void getterOnly() throws Exception + void getterOnly() throws Exception { PropertyResolver.setValue("country", person, new Country("US"), CONVERTER); PropertyResolver.getValue("country.name", person); @@ -172,7 +180,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void pathExpressionWithConversion() throws Exception + void pathExpressionWithConversion() throws Exception { person.setAddress(new Address()); PropertyResolver.setValue("address.number", person, "10", CONVERTER); @@ -194,7 +202,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void mapLookup() throws Exception + void mapLookup() throws Exception { Address address = new Address(); PropertyResolver.setValue("addressMap", person, new HashMap<String, Address>(), CONVERTER); @@ -208,7 +216,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void mapWithDotLookup() throws Exception + void mapWithDotLookup() throws Exception { Address address = new Address(); HashMap<String, Address> hm = new HashMap<String, Address>(); @@ -225,7 +233,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void listLookup() throws Exception + void listLookup() throws Exception { PropertyResolver.setValue("addressList", person, new ArrayList<Address>(), CONVERTER); PropertyResolver.setValue("addressList.0", person, new Address(), CONVERTER); @@ -243,7 +251,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void arrayLookup() throws Exception + void arrayLookup() throws Exception { PropertyResolver.setValue("addressArray", person, new Address[] { new Address(), null }, CONVERTER); @@ -260,7 +268,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void arrayLookupByBrackets() throws Exception + void arrayLookupByBrackets() throws Exception { PropertyResolver.setValue("addressArray", person, new Address[] { new Address(), null }, CONVERTER); @@ -277,7 +285,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void propertyByIndexLookup() throws Exception + void propertyByIndexLookup() throws Exception { PropertyResolver.setValue("addressAt.0", person, new Address(), CONVERTER); PropertyResolver.setValue("addressAt.0.street", person, "wicket-street", CONVERTER); @@ -289,7 +297,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void getPropertyByNotExistingIndexArrayLookup() throws Exception + void getPropertyByNotExistingIndexArrayLookup() throws Exception { PropertyResolver.setValue("addressArray", person, new Address[] { }, CONVERTER); String street = (String)PropertyResolver.getValue("addressArray.0.street", person); @@ -302,7 +310,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void getPropertyByNotExistingIndexListLookup() throws Exception + void getPropertyByNotExistingIndexListLookup() throws Exception { PropertyResolver.setValue("addressList", person, new ArrayList<Address>(), CONVERTER); String street = (String)PropertyResolver.getValue("addressList.0.street", person); @@ -315,7 +323,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void getIndexPropertyDirectly() throws Exception + void getIndexPropertyDirectly() throws Exception { Address address = new Address(); Address[] addresses = new Address[] { address }; @@ -328,7 +336,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void listSizeLookup() throws Exception + void listSizeLookup() throws Exception { List<Address> addresses = new ArrayList<Address>(); addresses.add(new Address()); @@ -345,7 +353,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void mapSizeLookup() throws Exception + void mapSizeLookup() throws Exception { Map<String, Address> addresses = new HashMap<String, Address>(); Address address = new Address(); @@ -362,7 +370,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void arraySizeLookup() throws Exception + void arraySizeLookup() throws Exception { person.setAddressArray(new Address[] { new Address(), new Address() }); Object size = PropertyResolver.getValue("addressArray.length", person); @@ -375,7 +383,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void methodLookup() throws Exception + void methodLookup() throws Exception { Address[] addresses = new Address[] { new Address(), new Address() }; person.setAddressArray(addresses); @@ -387,7 +395,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void field() throws Exception + void field() throws Exception { Address address = new Address(); PropertyResolver.setValue("address2", person, address, CONVERTER); @@ -409,7 +417,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void testPrivateField() throws Exception + void testPrivateField() throws Exception { Address address = new Address(); PropertyResolver.setValue("privateAddress", person, address, CONVERTER); @@ -421,7 +429,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void privateFieldOfSuperClass() throws Exception + void privateFieldOfSuperClass() throws Exception { Person2 person2 = new Person2(); Address address = new Address(); @@ -434,7 +442,7 @@ public class PropertyResolverTest extends WicketTestCase * */ @Test - public void getTargetClass() + void getTargetClass() { Address address = new Address(); @@ -459,7 +467,7 @@ public class PropertyResolverTest extends WicketTestCase * */ @Test - public void getTargetField() + void getTargetField() { Address address = new Address(); @@ -484,7 +492,7 @@ public class PropertyResolverTest extends WicketTestCase * */ @Test - public void getTargetGetter() + void getTargetGetter() { Address address = new Address(); @@ -509,7 +517,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void onlyPrimitiveGetter() throws Exception + void onlyPrimitiveGetter() throws Exception { Person person = new Person(); @@ -524,7 +532,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void onlyStringGetter() throws Exception + void onlyStringGetter() throws Exception { Person person = new Person(); @@ -539,7 +547,7 @@ public class PropertyResolverTest extends WicketTestCase * */ @Test - public void getTargetSetter() + void getTargetSetter() { Address address = new Address(); @@ -561,7 +569,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void overriddenGetter() throws Exception + void overriddenGetter() throws Exception { Person2 person = new Person2(); person.setName("foo"); @@ -580,7 +588,7 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void propertyClassWithSubType() throws Exception + void propertyClassWithSubType() throws Exception { Person person = new Person(); assertEquals(String.class, PropertyResolver.getPropertyClass("country.name", person)); @@ -614,7 +622,7 @@ public class PropertyResolverTest extends WicketTestCase * Tests the PropertyModel with vector. */ @Test - public void propertyModel() + void propertyModel() { String value = (String)PropertyResolver.getValue("testValue", new InnerVectorPOJO()); assertEquals("vector", value); @@ -624,7 +632,7 @@ public class PropertyResolverTest extends WicketTestCase * */ @Test - public void directFieldSetWithDifferentTypeThanGetter() + void directFieldSetWithDifferentTypeThanGetter() { final DirectFieldSetWithDifferentTypeThanGetter obj = new DirectFieldSetWithDifferentTypeThanGetter(); PropertyResolver.setValue("value", obj, 1, null); @@ -646,7 +654,7 @@ public class PropertyResolverTest extends WicketTestCase * @see <a href="https://issues.apache.org/jira/browse/WICKET-1802">WICKET-1802</a> */ @Test - public void conversionExceptionMessageContainsTheObjectPropertyBeingSet() + void conversionExceptionMessageContainsTheObjectPropertyBeingSet() { try { @@ -673,7 +681,7 @@ public class PropertyResolverTest extends WicketTestCase * WICKET-3441 */ @Test - public void dateToStringConverting() + void dateToStringConverting() { IConverterLocator converterLocator = new ConverterLocator(); Locale locale = Locale.GERMAN; @@ -694,7 +702,7 @@ public class PropertyResolverTest extends WicketTestCase * WICKET-3441 */ @Test - public void dateToLongConverting() + void dateToLongConverting() { ConverterLocator converterLocator = new ConverterLocator(); final IConverter<Date> dateConverter = converterLocator.get(Date.class); @@ -751,7 +759,7 @@ public class PropertyResolverTest extends WicketTestCase * WICKET-5623 custom properties */ @Test - public void custom() { + void custom() { Document document = new Document(); document.setType("type"); document.setProperty("string", "string"); @@ -766,7 +774,7 @@ public class PropertyResolverTest extends WicketTestCase assertEquals("string", PropertyResolver.getValue("string", document)); assertEquals("string2", PropertyResolver.getValue("nested.string", document)); } - + class CustomGetAndSetLocator implements IPropertyLocator { private IPropertyLocator locator = new DefaultPropertyLocator(); @@ -781,7 +789,7 @@ public class PropertyResolverTest extends WicketTestCase } return getAndSet; } - + public class DocumentPropertyGetAndSet extends AbstractGetAndSet { private String name; http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/lang/WicketObjectsTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/lang/WicketObjectsTest.java b/wicket-core/src/test/java/org/apache/wicket/util/lang/WicketObjectsTest.java index 2862945..0808a91 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/lang/WicketObjectsTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/lang/WicketObjectsTest.java @@ -16,6 +16,12 @@ */ package org.apache.wicket.util.lang; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.Serializable; import org.apache.wicket.core.util.lang.WicketObjects; @@ -23,21 +29,20 @@ import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.util.tester.WicketTestCase; -import org.junit.Test; - +import org.junit.jupiter.api.Test; /** * Tests the WicketObjects class. * * @author Martijn Dashorst */ -public class WicketObjectsTest extends WicketTestCase +class WicketObjectsTest extends WicketTestCase { /** * Test method for WicketObjects.cloneModel(null) */ @Test - public void cloneModelNull() + void cloneModelNull() { Object clone = WicketObjects.cloneModel(null); assertEquals(null, clone); @@ -47,7 +52,7 @@ public class WicketObjectsTest extends WicketTestCase * Test method for WicketObjects.cloneObject(null) */ @Test - public void cloneObjectNull() + void cloneObjectNull() { Object clone = WicketObjects.cloneObject(null); assertEquals(null, clone); @@ -57,7 +62,7 @@ public class WicketObjectsTest extends WicketTestCase * Test method for WicketObjects.cloneModel(String) */ @Test - public void cloneModelString() + void cloneModelString() { String cloneMe = "Mini-me"; @@ -70,7 +75,7 @@ public class WicketObjectsTest extends WicketTestCase * Test method for WicketObjects.cloneObject(String) */ @Test - public void cloneObjectString() + void cloneObjectString() { String cloneMe = "Mini-me"; @@ -83,7 +88,7 @@ public class WicketObjectsTest extends WicketTestCase * Test method for WicketObjects.cloneModel(nonSerializableObject) */ @Test - public void cloneModelNonSerializableObject() + void cloneModelNonSerializableObject() { Object cloneMe = new Object(); @@ -102,7 +107,7 @@ public class WicketObjectsTest extends WicketTestCase * Test method for WicketObjects.cloneObject(nonSerializableObject) */ @Test - public void cloneObjectNonSerializableObject() + void cloneObjectNonSerializableObject() { Object cloneMe = new Object(); @@ -122,7 +127,7 @@ public class WicketObjectsTest extends WicketTestCase */ @SuppressWarnings({ "unchecked" }) @Test - public void componentClone() + void componentClone() { PropertyModel<String> pm = new PropertyModel<>(new TextField<>("test", Model.of("test")), "modelObject"); @@ -134,7 +139,7 @@ public class WicketObjectsTest extends WicketTestCase * Test method for 'org.apache.wicket.util.lang.Objects.clone(Object)' */ @Test - public void cloneCloneObject() + void cloneCloneObject() { CloneObject cloneMe = new CloneObject(); cloneMe.nr = 1; http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/markup/xhtml/WellFormedXmlTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/markup/xhtml/WellFormedXmlTest.java b/wicket-core/src/test/java/org/apache/wicket/util/markup/xhtml/WellFormedXmlTest.java index a8e7628..26cfc9d 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/markup/xhtml/WellFormedXmlTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/markup/xhtml/WellFormedXmlTest.java @@ -16,14 +16,14 @@ */ package org.apache.wicket.util.markup.xhtml; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Checks that the html markup files are well formed xml-s. * * @author akiraly */ -public class WellFormedXmlTest extends WellFormedXmlTestCase +class WellFormedXmlTest extends WellFormedXmlTestCase { @Test @Override http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java b/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java index 6dd3d0f..44d8f90 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java @@ -16,6 +16,10 @@ */ package org.apache.wicket.util.resource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -25,25 +29,12 @@ import java.util.Arrays; import org.apache.wicket.util.file.Path; import org.apache.wicket.util.tester.WicketTestCase; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class PathTest extends WicketTestCase +class PathTest extends WicketTestCase { - @Test - public void loadFromRootUsingSubpathInFilename() throws Exception - { - final String contents = PathTest.class.getName() + ": loaded from root"; - final File file = createTempFile(contents); - final File root = findRoot(file); - final Path path = new Path(root.getCanonicalPath()); - String relative = root.toURI().relativize(file.toURI()).getPath(); - IResourceStream rs = path.find(PathTest.class, relative); - assertNotNull(rs); - assertContents(contents, rs); - } - - public static void assertContents(String expectedContents, IResourceStream rs) + private static void assertContents(String expectedContents, IResourceStream rs) throws ResourceStreamNotFoundException, IOException { InputStream in = rs.getInputStream(); @@ -53,10 +44,10 @@ public class PathTest extends WicketTestCase final int expectedLength = expectedBytes.length; byte[] buf = new byte[expectedLength * 2]; int read = in.read(buf, 0, buf.length); - assertEquals("contents do not match", expectedLength, read); + assertEquals(expectedLength, read, "contents do not match"); byte[] buf2 = new byte[expectedLength]; System.arraycopy(buf, 0, buf2, 0, expectedLength); - assertTrue("contents do not match", Arrays.equals(expectedBytes, buf2)); + assertTrue(Arrays.equals(expectedBytes, buf2), "contents do not match"); } finally { @@ -64,19 +55,7 @@ public class PathTest extends WicketTestCase } } - @Test - public void loadFilenameFromPath() throws Exception - { - final String contents = PathTest.class.getName() + ": loaded from prefix"; - final File file = createTempFile(contents); - final File parent = file.getParentFile(); - final Path path = new Path(parent.getCanonicalPath()); - IResourceStream rs = path.find(PathTest.class, file.getName()); - assertNotNull(rs); - assertContents(contents, rs); - } - - public static File createTempFile(String contents) throws IOException + private static File createTempFile(String contents) throws IOException { FileOutputStream out = null; try @@ -96,7 +75,7 @@ public class PathTest extends WicketTestCase } } - public static File findRoot(File file) + private static File findRoot(File file) { final File parent = file.getParentFile(); if (parent == null) @@ -108,4 +87,29 @@ public class PathTest extends WicketTestCase return findRoot(parent); } } + + @Test + void loadFromRootUsingSubpathInFilename() throws Exception + { + final String contents = PathTest.class.getName() + ": loaded from root"; + final File file = createTempFile(contents); + final File root = findRoot(file); + final Path path = new Path(root.getCanonicalPath()); + String relative = root.toURI().relativize(file.toURI()).getPath(); + IResourceStream rs = path.find(PathTest.class, relative); + assertNotNull(rs); + assertContents(contents, rs); + } + + @Test + void loadFilenameFromPath() throws Exception + { + final String contents = PathTest.class.getName() + ": loaded from prefix"; + final File file = createTempFile(contents); + final File parent = file.getParentFile(); + final Path path = new Path(parent.getCanonicalPath()); + IResourceStream rs = path.find(PathTest.class, file.getName()); + assertNotNull(rs); + assertContents(contents, rs); + } } http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/resource/ResourceStreamLocatorTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/resource/ResourceStreamLocatorTest.java b/wicket-core/src/test/java/org/apache/wicket/util/resource/ResourceStreamLocatorTest.java index 66cb967..80ae833 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/resource/ResourceStreamLocatorTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/resource/ResourceStreamLocatorTest.java @@ -16,6 +16,9 @@ */ package org.apache.wicket.util.resource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import java.io.File; import java.io.IOException; import java.net.URI; @@ -30,8 +33,7 @@ import org.apache.wicket.core.util.resource.locator.ResourceStreamLocator; import org.apache.wicket.util.file.IResourceFinder; import org.apache.wicket.util.string.Strings; import org.apache.wicket.util.tester.WicketTestCase; -import org.junit.Test; - +import org.junit.jupiter.api.Test; /** * ResourceStreamLocator test. Tests construction of resource names with @@ -64,8 +66,8 @@ public class ResourceStreamLocatorTest extends WicketTestCase * @param locale * @param extension */ - public void createAndTestResource(IResourceFinder sourcePath, String style, String variation, - Locale locale, String extension) + private void createAndTestResource(IResourceFinder sourcePath, String style, String variation, + Locale locale, String extension) { IResourceStreamLocator locator = new ResourceStreamLocator(sourcePath); IResourceStream resource = locator.locate(this.getClass(), this.getClass() @@ -78,7 +80,7 @@ public class ResourceStreamLocatorTest extends WicketTestCase * * @param sourcePath */ - public void executeMultiple(IResourceFinder sourcePath) + private void executeMultiple(IResourceFinder sourcePath) { createAndTestResource(sourcePath, null, null, null, ""); createAndTestResource(sourcePath, "style", null, null, "_style"); @@ -112,7 +114,7 @@ public class ResourceStreamLocatorTest extends WicketTestCase * Test locating a resource. */ @Test - public void locateInClasspath() + void locateInClasspath() { // Execute without source path executeMultiple(new ClassPathResourceFinder("")); @@ -133,7 +135,7 @@ public class ResourceStreamLocatorTest extends WicketTestCase */ private void compareFilename(IResourceStream resource, String name) { - assertNotNull("Did not find resource: " + name, resource); + assertNotNull(resource, "Did not find resource: " + name); String filename = Strings.replaceAll(this.getClass().getName(), ".", "/").toString(); filename += name + ".txt"; @@ -143,7 +145,7 @@ public class ResourceStreamLocatorTest extends WicketTestCase { filename = Strings.afterLast(filename, '/'); resourcePath = Strings.afterLast(resourcePath, '/'); - assertEquals("Did not find resource", filename, resourcePath); + assertEquals(filename, resourcePath, "Did not find resource"); } } @@ -154,7 +156,7 @@ public class ResourceStreamLocatorTest extends WicketTestCase * the resource * @return the path of the resource as a string */ - public static String getPath(IResourceStream resource) + private static String getPath(IResourceStream resource) { if (resource instanceof UrlResourceStream) { http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/resource/UrlResourceStreamTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/resource/UrlResourceStreamTest.java b/wicket-core/src/test/java/org/apache/wicket/util/resource/UrlResourceStreamTest.java index 5a066d9..b724dd4 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/resource/UrlResourceStreamTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/resource/UrlResourceStreamTest.java @@ -16,6 +16,8 @@ */ package org.apache.wicket.util.resource; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.IOException; import java.io.InputStream; import java.net.URL; @@ -25,20 +27,19 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.wicket.core.util.resource.UrlResourceStream; import org.apache.wicket.util.lang.Bytes; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Kent Tong */ -public class UrlResourceStreamTest extends Assert { +class UrlResourceStreamTest { /** * lastModified() shouldn't change the content length if the file isn't really changed. * * @throws IOException */ @Test - public void lastModifiedForResourceInJar() throws IOException { + void lastModifiedForResourceInJar() throws IOException { String anyClassInJarFile = "/java/lang/String.class"; URL url = getClass().getResource(anyClassInJarFile); UrlResourceStream stream = new UrlResourceStream(url); @@ -59,7 +60,7 @@ public class UrlResourceStreamTest extends Assert { * @throws ResourceStreamNotFoundException */ @Test - public void loadJustOnce() throws IOException, ResourceStreamNotFoundException { + void loadJustOnce() throws IOException, ResourceStreamNotFoundException { String anyClassInJarFile = "/java/lang/String.class"; URL realURL = getClass().getResource(anyClassInJarFile); @@ -116,8 +117,8 @@ public class UrlResourceStreamTest extends Assert { private final URL realURL; - public CountingURLStreamHandler(URL realURL, AtomicInteger connectCounter, - AtomicInteger streamCounter) { + CountingURLStreamHandler(URL realURL, AtomicInteger connectCounter, + AtomicInteger streamCounter) { this.connectCounter = connectCounter; this.streamCounter = streamCounter; this.realURL = realURL; http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/resource/locator/CachingResourceStreamLocatorTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/resource/locator/CachingResourceStreamLocatorTest.java b/wicket-core/src/test/java/org/apache/wicket/util/resource/locator/CachingResourceStreamLocatorTest.java index ca01230..21b4cf5 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/resource/locator/CachingResourceStreamLocatorTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/resource/locator/CachingResourceStreamLocatorTest.java @@ -16,10 +16,8 @@ */ package org.apache.wicket.util.resource.locator; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -38,22 +36,21 @@ import org.apache.wicket.core.util.resource.locator.caching.CachingResourceStrea import org.apache.wicket.util.resource.FileResourceStream; import org.apache.wicket.util.resource.IResourceStream; import org.apache.wicket.util.resource.StringResourceStream; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for CachingResourceStreamLocator * * <a href="https://issues.apache.org/jira/browse/WICKET-3511">WICKET-3511</a> */ -public class CachingResourceStreamLocatorTest +class CachingResourceStreamLocatorTest { /** * Tests NullResourceStreamReference */ @Test - public void notExistingResource() + void notExistingResource() { IResourceStreamLocator resourceStreamLocator = mock(IResourceStreamLocator.class); @@ -73,7 +70,7 @@ public class CachingResourceStreamLocatorTest * Tests strict before non-strict matching without a specific locale. */ @Test - public void strictBeforeNonStrictMatchingWithoutLocaleDoesntResultInInvalidNonStrictMatch() + void strictBeforeNonStrictMatchingWithoutLocaleDoesntResultInInvalidNonStrictMatch() { IResourceStreamLocator resourceStreamLocator = new ResourceStreamLocator( new ClassPathResourceFinder("")); @@ -91,20 +88,20 @@ public class CachingResourceStreamLocatorTest IResourceStream strictLocate = cachingLocator.locate(AbstractDefaultAjaxBehavior.class, filename, style, variation, locale, extension, true); - assertThat(strictLocate, is(not(nullValue()))); + assertNotNull(strictLocate); // followed by a non-strict search for the same resource also finds it IResourceStream nonStrictLocate = cachingLocator.locate(AbstractDefaultAjaxBehavior.class, filename, style, variation, locale, extension, false); - assertThat(nonStrictLocate, is(not(nullValue()))); + assertNotNull(nonStrictLocate); } /** * Tests strict before non-strict matching with a specific locale. */ @Test - public void strictMatchingDoesntInvalidateNonStrictMatching() + void strictMatchingDoesntInvalidateNonStrictMatching() { IResourceStreamLocator resourceStreamLocator = new ResourceStreamLocator( new ClassPathResourceFinder("")); @@ -121,20 +118,20 @@ public class CachingResourceStreamLocatorTest // a strict lookup of a localized resource should not find the non-localized resource IResourceStream strictLocate = cachingLocator.locate(AbstractDefaultAjaxBehavior.class, filename, style, variation, locale, extension, true); - assertThat(strictLocate, is(nullValue())); + assertNull(strictLocate); // but a non-strict lookup with a locale should fall back to the non-localized resource IResourceStream nonStrictLocate = cachingLocator.locate(AbstractDefaultAjaxBehavior.class, filename, style, variation, locale, extension, false); - assertThat(nonStrictLocate, is(not(nullValue()))); + assertNotNull(nonStrictLocate); } /** * Tests non-strict before strict matching with a specific locale. */ @Test - public void nonStrictMatchingDoesntResultInInvalidStrictMatch() + void nonStrictMatchingDoesntResultInInvalidStrictMatch() { IResourceStreamLocator resourceStreamLocator = new ResourceStreamLocator( new ClassPathResourceFinder("")); @@ -152,21 +149,21 @@ public class CachingResourceStreamLocatorTest IResourceStream nonStrictLocate = cachingLocator.locate(AbstractDefaultAjaxBehavior.class, filename, style, variation, locale, extension, false); - assertThat(nonStrictLocate, is(not(nullValue()))); + assertNotNull(nonStrictLocate); // but a strict lookup with a specific locale should not fall back to the non-localized // resource IResourceStream strictLocate = cachingLocator.locate(AbstractDefaultAjaxBehavior.class, filename, style, variation, locale, extension, true); - assertThat(strictLocate, is(nullValue())); + assertNull(strictLocate); } /** * Tests FileResourceStreamReference */ @Test - public void fileResource() + void fileResource() { IResourceStreamLocator resourceStreamLocator = mock(IResourceStreamLocator.class); @@ -190,7 +187,7 @@ public class CachingResourceStreamLocatorTest * Tests two FileResourceStreamReferences with different extensions */ @Test - public void fileResourceDifferentExtensions() + void fileResourceDifferentExtensions() { IResourceStreamLocator resourceStreamLocator = mock(IResourceStreamLocator.class); @@ -219,7 +216,7 @@ public class CachingResourceStreamLocatorTest * @throws Exception */ @Test - public void urlResource() throws Exception + void urlResource() throws Exception { IResourceStreamLocator resourceStreamLocator = mock(IResourceStreamLocator.class); @@ -242,7 +239,7 @@ public class CachingResourceStreamLocatorTest * UrlResourceStream). These should <strong>not</strong> be cached. */ @Test - public void lightweightResource() + void lightweightResource() { IResourceStreamLocator resourceStreamLocator = mock(IResourceStreamLocator.class); http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/resource/locator/ResourceNameIteratorTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/resource/locator/ResourceNameIteratorTest.java b/wicket-core/src/test/java/org/apache/wicket/util/resource/locator/ResourceNameIteratorTest.java index 6c804b1..0212315 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/resource/locator/ResourceNameIteratorTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/resource/locator/ResourceNameIteratorTest.java @@ -16,6 +16,10 @@ */ package org.apache.wicket.util.resource.locator; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; @@ -26,19 +30,18 @@ import org.apache.wicket.core.util.resource.locator.LocaleResourceNameIterator; import org.apache.wicket.core.util.resource.locator.ResourceNameIterator; import org.apache.wicket.core.util.resource.locator.StyleAndVariationResourceNameIterator; import org.apache.wicket.util.tester.WicketTestCase; -import org.junit.Test; - +import org.junit.jupiter.api.Test; /** * @author Pedro Santos */ -public class ResourceNameIteratorTest extends WicketTestCase +class ResourceNameIteratorTest extends WicketTestCase { /** * Asserting no duplicated locale sufix get iterated */ @Test - public void localeResourceNameIterator() + void localeResourceNameIterator() { Locale locale = new Locale("a", "b", "c"); LocaleResourceNameIterator iterator = new LocaleResourceNameIterator(locale, false); @@ -81,7 +84,7 @@ public class ResourceNameIteratorTest extends WicketTestCase * */ @Test - public void styleAndVariationResourceNameIterator() + void styleAndVariationResourceNameIterator() { StyleAndVariationResourceNameIterator iterator = new StyleAndVariationResourceNameIterator( null, null); @@ -120,7 +123,7 @@ public class ResourceNameIteratorTest extends WicketTestCase * */ @Test - public void extensionResourceNameIterator() + void extensionResourceNameIterator() { ExtensionResourceNameIterator iterator = new ExtensionResourceNameIterator(null); assertTrue(iterator.hasNext()); @@ -146,7 +149,7 @@ public class ResourceNameIteratorTest extends WicketTestCase * */ @Test - public void noDuplicateVariations() + void noDuplicateVariations() { String path = "patch.extension"; String style = null; @@ -167,7 +170,7 @@ public class ResourceNameIteratorTest extends WicketTestCase * */ @Test - public void noTrailingDotWhenNoExtension() + void noTrailingDotWhenNoExtension() { Iterator<String> iterator = new ResourceNameIterator("foo", null, null, null, null, false); http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/string/JavaScriptStripperTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/string/JavaScriptStripperTest.java b/wicket-core/src/test/java/org/apache/wicket/util/string/JavaScriptStripperTest.java index 1ffe164..adf1417 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/string/JavaScriptStripperTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/string/JavaScriptStripperTest.java @@ -16,20 +16,23 @@ */ package org.apache.wicket.util.string; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.apache.wicket.core.util.string.JavaScriptStripper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests {@link JavaScriptStripper} * * @author <a href="mailto:[email protected]">Jean-Baptiste Quenot</a> */ -public class JavaScriptStripperTest extends Assert +class JavaScriptStripperTest { /** */ @Test - public void unixWICKET501() + void unixWICKET501() { String s = new JavaScriptStripper().stripCommentsAndWhitespace(" // Handle the common XPath // expression\n if ( !t.indexOf(\"//\") ) {"); assertEquals(" \n if ( !t.indexOf(\"//\") ) {", s); @@ -37,7 +40,7 @@ public class JavaScriptStripperTest extends Assert /** */ @Test - public void dosWICKET501() + void dosWICKET501() { String s = new JavaScriptStripper().stripCommentsAndWhitespace(" // Handle the common XPath // expression\r\n if ( !t.indexOf(\"//\") ) {"); assertEquals(" \r\nif ( !t.indexOf(\"//\") ) {", s); @@ -45,7 +48,7 @@ public class JavaScriptStripperTest extends Assert /** */ @Test - public void macWICKET501() + void macWICKET501() { String s = new JavaScriptStripper().stripCommentsAndWhitespace(" // Handle the common XPath // expression\r if ( !t.indexOf(\"//\") ) {"); assertEquals(" \r if ( !t.indexOf(\"//\") ) {", s); @@ -53,7 +56,7 @@ public class JavaScriptStripperTest extends Assert /** */ @Test - public void regexp() + void regexp() { String s = new JavaScriptStripper().stripCommentsAndWhitespace(" t = jQuery.trim(t).replace( /^\\/\\//i, \"\" );"); assertEquals(" t = jQuery.trim(t).replace( /^\\/\\//i, \"\" );", s); @@ -61,7 +64,7 @@ public class JavaScriptStripperTest extends Assert /** */ @Test - public void regexp2() + void regexp2() { String s = new JavaScriptStripper().stripCommentsAndWhitespace("foo.replace(/\"//*strip me*/, \"\"); // strip me\rdoFoo();"); assertEquals("foo.replace(/\"/, \"\"); \rdoFoo();", s); @@ -69,7 +72,7 @@ public class JavaScriptStripperTest extends Assert /** */ @Test - public void regexp3() + void regexp3() { String s = new JavaScriptStripper().stripCommentsAndWhitespace("parseFloat( elem.filter.match(/alpha\\(opacity=(.*)\\)/)[1] ) / 100 : 1;\r//foo"); assertEquals("parseFloat( elem.filter.match(/alpha\\(opacity=(.*)\\)/)[1] ) / 100 : 1;\r", @@ -78,7 +81,7 @@ public class JavaScriptStripperTest extends Assert /** */ @Test - public void regexp4() + void regexp4() { String before = " attr: /**/ //xyz\n /\\[((?:[\\w-]*:)?[\\w-]+)\\s*(?:([!^$*~|]?=)\\s*((['\"])([^\\4]*?)\\4|([^'\"][^\\]]*?)))?\\]/ after regex"; String after = new JavaScriptStripper().stripCommentsAndWhitespace(before); @@ -89,7 +92,7 @@ public class JavaScriptStripperTest extends Assert /** */ @Test - public void WICKET1806() + void WICKET1806() { String before = "a = [ /^(\\[) *@?([\\w-]+) *([!*$^~=]*) *('?\"?)(.*?)\\4 *\\]/ ]; b()"; String after = new JavaScriptStripper().stripCommentsAndWhitespace(before); @@ -100,7 +103,7 @@ public class JavaScriptStripperTest extends Assert /** */ @Test - public void WICKET2060_1() + void WICKET2060_1() { String before = " a b c"; String after = new JavaScriptStripper().stripCommentsAndWhitespace(before); @@ -110,7 +113,7 @@ public class JavaScriptStripperTest extends Assert /** */ @Test - public void WICKET2060_2() + void WICKET2060_2() { String before = " a \n b c\n\n"; String after = new JavaScriptStripper().stripCommentsAndWhitespace(before); @@ -120,7 +123,7 @@ public class JavaScriptStripperTest extends Assert /** */ @Test - public void WICKET2060_3() + void WICKET2060_3() { String before = "return this.__unbind__(type, fn);"; String after = new JavaScriptStripper().stripCommentsAndWhitespace(before); @@ -130,7 +133,7 @@ public class JavaScriptStripperTest extends Assert /** */ @Test - public void WICKET4760() + void WICKET4760() { String before = "x++ //\nx++"; String after = new JavaScriptStripper().stripCommentsAndWhitespace(before); @@ -140,7 +143,7 @@ public class JavaScriptStripperTest extends Assert /** */ // @formatter:off - public static String TESTSTRING2 = + private static String TESTSTRING2 = " var test = function () {\n" + " var c = \"!=\";\n" + " /* from jquery 1.5.1 */\n" + @@ -158,7 +161,7 @@ public class JavaScriptStripperTest extends Assert /** */ @Test - public void regExThatStartsWithExclamationMark() + void regExThatStartsWithExclamationMark() { String result = new JavaScriptStripper().stripCommentsAndWhitespace(TESTSTRING2); assertFalse(result.contains("This code will be stripped")); http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/string/interpolator/PropertyVariableInterpolatorTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/string/interpolator/PropertyVariableInterpolatorTest.java b/wicket-core/src/test/java/org/apache/wicket/util/string/interpolator/PropertyVariableInterpolatorTest.java index 8438f81..e437501 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/string/interpolator/PropertyVariableInterpolatorTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/string/interpolator/PropertyVariableInterpolatorTest.java @@ -16,22 +16,23 @@ */ package org.apache.wicket.util.string.interpolator; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.apache.wicket.core.util.string.interpolator.PropertyVariableInterpolator; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests {@link PropertyVariableInterpolator} * * @author Gerolf Seitz */ -public class PropertyVariableInterpolatorTest extends Assert +class PropertyVariableInterpolatorTest { /** * */ @Test - public void withValue() + void withValue() { TestClass object = new TestClass("value"); String result = new PropertyVariableInterpolator("${key}", object).toString(); @@ -43,7 +44,7 @@ public class PropertyVariableInterpolatorTest extends Assert * '$' and '${key}' is interpolated to the respective value */ @Test - public void withValueAndEscape() + void withValueAndEscape() { TestClass object = new TestClass("3.24"); String result = new PropertyVariableInterpolator("$$${key}", object).toString(); @@ -54,7 +55,7 @@ public class PropertyVariableInterpolatorTest extends Assert * */ @Test - public void withoutValue() + void withoutValue() { String result = new PropertyVariableInterpolator("${key}", null).toString(); assertEquals("${key}", result.toString()); @@ -64,7 +65,7 @@ public class PropertyVariableInterpolatorTest extends Assert { private final String key; - public TestClass(String key) + TestClass(String key) { this.key = key; } http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/template/CssTemplateTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/template/CssTemplateTest.java b/wicket-core/src/test/java/org/apache/wicket/util/template/CssTemplateTest.java index 05e1d6f..f60cc77 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/template/CssTemplateTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/template/CssTemplateTest.java @@ -18,13 +18,13 @@ package org.apache.wicket.util.template; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test of {@link CssTemplate} */ -public class CssTemplateTest +class CssTemplateTest { /** @@ -33,7 +33,7 @@ public class CssTemplateTest * @see <a href="https://issues.apache.org/jira/browse/WICKET-3187">WICKET-3187</a> */ @Test - public void simpleConstructor() + void simpleConstructor() { new CssTemplate(new TextTemplate() { http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/tester/CookiePage.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/tester/CookiePage.java b/wicket-core/src/test/java/org/apache/wicket/util/tester/CookiePage.java index fce6756..241e9f6 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/tester/CookiePage.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/tester/CookiePage.java @@ -16,9 +16,10 @@ */ package org.apache.wicket.util.tester; +import static org.junit.jupiter.api.Assertions.assertEquals; + import javax.servlet.http.Cookie; -import org.junit.Assert; import org.apache.wicket.request.http.WebRequest; import org.apache.wicket.request.http.WebResponse; @@ -52,7 +53,7 @@ public class CookiePage extends DummyHomePage super.onConfigure(); Cookie cookie = ((WebRequest) getRequest()).getCookie(cookieName); - Assert.assertEquals(cookieValue, cookie.getValue()); + assertEquals(cookieValue, cookie.getValue()); WebResponse response = (WebResponse) getResponse(); response.addCookie(cookie); http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/tester/FormTesterSubmitLinkTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/tester/FormTesterSubmitLinkTest.java b/wicket-core/src/test/java/org/apache/wicket/util/tester/FormTesterSubmitLinkTest.java index 82fa25b..654fce2 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/tester/FormTesterSubmitLinkTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/tester/FormTesterSubmitLinkTest.java @@ -16,6 +16,9 @@ */ package org.apache.wicket.util.tester; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.apache.wicket.MarkupContainer; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; @@ -30,12 +33,12 @@ import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.util.resource.IResourceStream; import org.apache.wicket.util.resource.StringResourceStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * <a href="https://issues.apache.org/jira/browse/WICKET-3711">WICKET-3711</a> */ -public class FormTesterSubmitLinkTest extends WicketTestCase +class FormTesterSubmitLinkTest extends WicketTestCase { /** * Submit via SubmitLink. @@ -43,7 +46,7 @@ public class FormTesterSubmitLinkTest extends WicketTestCase * This should work the same as regular submit */ @Test - public void submitLink() + void submitLink() { tester.startPage(TestPage.class); @@ -58,7 +61,7 @@ public class FormTesterSubmitLinkTest extends WicketTestCase * Submit the form */ @Test - public void regularSubmit() + void regularSubmit() { tester.startPage(TestPage.class); @@ -70,7 +73,7 @@ public class FormTesterSubmitLinkTest extends WicketTestCase } @Test - public void radioComponentValueEncoding() + void radioComponentValueEncoding() { class TestPage extends WebPage implements IMarkupResourceStreamProvider @@ -80,7 +83,7 @@ public class FormTesterSubmitLinkTest extends WicketTestCase private String value; private boolean submitted; - public TestPage() + TestPage() { Form<Void> form = new Form<Void>("form"); add(form); http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java b/wicket-core/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java index fe152ef..3f91b2c 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java @@ -16,6 +16,13 @@ */ package org.apache.wicket.util.tester; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +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; import java.util.List; import java.util.Locale; @@ -37,22 +44,21 @@ import org.apache.wicket.util.resource.IResourceStream; import org.apache.wicket.util.resource.StringResourceStream; import org.apache.wicket.util.tester.MockFormFileUploadPage.MockDomainObjectFileUpload; import org.apache.wicket.util.tester.MockFormPage.MockDomainObject; -import org.junit.Test; - +import org.junit.jupiter.api.Test; /** * Test of FormTester. * * @author frankbille */ -public class FormTesterTest extends WicketTestCase +class FormTesterTest extends WicketTestCase { /** * Test that normal use of the formtester (no file uploads) works. */ @Test - public void formTester() + void formTester() { tester.startPage(MockFormPage.class); MockFormPage page = (MockFormPage)tester.getLastRenderedPage(); @@ -77,7 +83,7 @@ public class FormTesterTest extends WicketTestCase /** */ @Test - public void checkboxValuesCanBeSelectedWithBoolean() + void checkboxValuesCanBeSelectedWithBoolean() { tester.startPage(MockFormPage.class); MockFormPage page = (MockFormPage)tester.getLastRenderedPage(); @@ -102,7 +108,7 @@ public class FormTesterTest extends WicketTestCase * upload to a FileUploadField works. */ @Test - public void addFile() + void addFile() { tester.startPage(MockFormFileUploadPage.class); MockFormFileUploadPage page = (MockFormFileUploadPage)tester.getLastRenderedPage(); @@ -126,7 +132,7 @@ public class FormTesterTest extends WicketTestCase FileUpload fileUpload = page.getFileUpload(); assertNotNull(fileUpload); - assertTrue("setFile failed, no upload content detected.", fileUpload.getBytes().length > 0); + assertTrue(fileUpload.getBytes().length > 0, "setFile failed, no upload content detected."); assertEquals("pom.xml", fileUpload.getClientFileName()); assertEquals("text/xml", fileUpload.getContentType()); } @@ -137,7 +143,7 @@ public class FormTesterTest extends WicketTestCase * upload to a FileUploadField works. */ @Test - public void addBinaryFile() + void addBinaryFile() { tester.startPage(MockFormFileUploadPage.class); MockFormFileUploadPage page = (MockFormFileUploadPage)tester.getLastRenderedPage(); @@ -149,8 +155,9 @@ public class FormTesterTest extends WicketTestCase FormTester formTester = tester.newFormTester("form"); - formTester.setFile("file", new File(getBasedir() + - "src/test/java/org/apache/wicket/util/tester/bg.jpg"), "image/jpeg"); + formTester.setFile("file", + new File(getBasedir() + "src/test/java/org/apache/wicket/util/tester/bg.jpg"), + "image/jpeg"); formTester.setValue("text", "Mock value"); formTester.submit(); @@ -162,9 +169,9 @@ public class FormTesterTest extends WicketTestCase FileUpload fileUpload = page.getFileUpload(); assertNotNull(fileUpload); - assertTrue( + assertTrue(fileUpload.getBytes().length == 428, "uploaded content does not have the right size, expected 428, got " + - fileUpload.getBytes().length, fileUpload.getBytes().length == 428); + fileUpload.getBytes().length); assertEquals("bg.jpg", fileUpload.getClientFileName()); assertEquals("image/jpeg", fileUpload.getContentType()); } @@ -173,7 +180,7 @@ public class FormTesterTest extends WicketTestCase * Test that formTester deal with Multipart form correctly when no actual upload */ @Test - public void submitWithoutUploadFile() + void submitWithoutUploadFile() { // tester.startPage(MockFormFileUploadPage.class, new PageParameters("required=true")); tester.startPage(MockFormFileUploadPage.class); @@ -195,7 +202,7 @@ public class FormTesterTest extends WicketTestCase * Test that formTester deal with Multipart form correctly when no actual upload */ @Test - public void submitMultipartForm() + void submitMultipartForm() { tester.startPage(MockFormFileUploadPage.class, new PageParameters().set("required", false)); MockFormFileUploadPage page = (MockFormFileUploadPage)tester.getLastRenderedPage(); @@ -218,7 +225,7 @@ public class FormTesterTest extends WicketTestCase * @throws Exception */ @Test - public void noParametersCreatedForDisabledComponents() throws Exception + void noParametersCreatedForDisabledComponents() throws Exception { tester.startPage(new MockFormPage() { @@ -254,24 +261,26 @@ public class FormTesterTest extends WicketTestCase } @Test - public void wantOnChangeSelectionNotification() + void wantOnChangeSelectionNotification() { class TestPage extends WebPage implements IMarkupResourceStreamProvider { private String selection; - public TestPage() + TestPage() { Form<Object> form = new Form<>("form"); add(form); List<String> choices = Arrays.asList("opt 1", "opt 2"); - form.add(new DropDownChoice<String>("selector", Model.of(""), choices).add(new FormComponentUpdatingBehavior() { - @Override - protected void onUpdate() + form.add(new DropDownChoice<String>("selector", Model.of(""), choices) + .add(new FormComponentUpdatingBehavior() { - selection = (String)getFormComponent().getDefaultModelObject(); - } - })); + @Override + protected void onUpdate() + { + selection = (String)getFormComponent().getDefaultModelObject(); + } + })); } @Override @@ -293,39 +302,39 @@ public class FormTesterTest extends WicketTestCase } @Test - public void testNestedFormHandlingOnInnerSubmit() throws Exception + void testNestedFormHandlingOnInnerSubmit() throws Exception { NestedFormPage page = tester.startPage(NestedFormPage.class); FormTester form = tester.newFormTester("outer:inner"); form.submit("submit"); - assertFalse("should not directly submit inner form - browsers submit the outer form!", - page.url.contains("inner")); - assertFalse("outer form should not be processed", page.outerSubmitted); - assertTrue("inner form should be processed", page.innerSubmitted); + assertFalse(page.url.contains("inner"), + "should not directly submit inner form - browsers submit the outer form!"); + assertFalse(page.outerSubmitted, "outer form should not be processed"); + assertTrue(page.innerSubmitted, "inner form should be processed"); } @Test - public void testNestedFormHandlingOnInnerSubmitWithOuterForm() throws Exception + void testNestedFormHandlingOnInnerSubmitWithOuterForm() throws Exception { NestedFormPage page = tester.startPage(NestedFormPage.class); FormTester form = tester.newFormTester("outer"); form.submit("inner:submit"); - assertFalse("should not directly submit inner form - browsers submit the outer form!", - page.url.contains("inner")); - assertFalse("outer form should not be processed", page.outerSubmitted); - assertTrue("inner form should be processed", page.innerSubmitted); + assertFalse(page.url.contains("inner"), + "should not directly submit inner form - browsers submit the outer form!"); + assertFalse(page.outerSubmitted, "outer form should not be processed"); + assertTrue(page.innerSubmitted, "inner form should be processed"); } @Test - public void testNestedFormHandlingOnOuterSubmit() throws Exception + void testNestedFormHandlingOnOuterSubmit() throws Exception { NestedFormPage page = tester.startPage(NestedFormPage.class); FormTester form = tester.newFormTester("outer"); form.submit(); - assertFalse("should not directly submit inner form - browsers submit the outer form!", - page.url.contains("inner")); - assertTrue("outer form should be processed", page.outerSubmitted); - assertTrue("inner form should be processed", page.innerSubmitted); + assertFalse(page.url.contains("inner"), + "should not directly submit inner form - browsers submit the outer form!"); + assertTrue(page.outerSubmitted, "outer form should be processed"); + assertTrue(page.innerSubmitted, "inner form should be processed"); } } http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/tester/MockFormSubmitsPage.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/tester/MockFormSubmitsPage.java b/wicket-core/src/test/java/org/apache/wicket/util/tester/MockFormSubmitsPage.java index 6117c15..05b2040 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/tester/MockFormSubmitsPage.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/tester/MockFormSubmitsPage.java @@ -69,11 +69,11 @@ public class MockFormSubmitsPage extends WebPage }); } - protected void onAjaxSubmitLinkSubmit(AjaxRequestTarget target) + void onAjaxSubmitLinkSubmit(AjaxRequestTarget target) { } - protected void onAjaxButtonSubmit(AjaxRequestTarget target) + void onAjaxButtonSubmit(AjaxRequestTarget target) { } } http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithFormAndAjaxFormSubmitBehavior.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithFormAndAjaxFormSubmitBehavior.java b/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithFormAndAjaxFormSubmitBehavior.java index 8132265..cf4f07d 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithFormAndAjaxFormSubmitBehavior.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithFormAndAjaxFormSubmitBehavior.java @@ -104,7 +104,7 @@ public class MockPageWithFormAndAjaxFormSubmitBehavior extends WebPage * * @param name */ - public Pojo(String name) + Pojo(String name) { this.name = name; } http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithLabelInEnclosure.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithLabelInEnclosure.java b/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithLabelInEnclosure.java index 06e6ca2..0c1d146 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithLabelInEnclosure.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithLabelInEnclosure.java @@ -19,14 +19,13 @@ package org.apache.wicket.util.tester; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.basic.Label; /** * Mock page which has an ajax link in an enclosure. Clicking the link invokes ajax rendering the link again. * * @author Domas Poliakas (disblader) */ -public class MockPageWithLabelInEnclosure extends WebPage { +class MockPageWithLabelInEnclosure extends WebPage { public MockPageWithLabelInEnclosure() { // Clicking this link re-renders the link itself http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/tester/MockResourceLinkPage.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/tester/MockResourceLinkPage.java b/wicket-core/src/test/java/org/apache/wicket/util/tester/MockResourceLinkPage.java index 0f84693..801066c 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/tester/MockResourceLinkPage.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/tester/MockResourceLinkPage.java @@ -32,7 +32,7 @@ public class MockResourceLinkPage extends WebPage /** * Construct. */ - public MockResourceLinkPage() + private MockResourceLinkPage() { add(new ResourceLink<Void>("link", new PackageResourceReference(MockResourceLinkPage.class, "test.html"))); http://git-wip-us.apache.org/repos/asf/wicket/blob/645f239c/wicket-core/src/test/java/org/apache/wicket/util/tester/StartComponentInPageRedirectToRenderTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/tester/StartComponentInPageRedirectToRenderTest.java b/wicket-core/src/test/java/org/apache/wicket/util/tester/StartComponentInPageRedirectToRenderTest.java index 4a766f9..5fc8db2 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/tester/StartComponentInPageRedirectToRenderTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/tester/StartComponentInPageRedirectToRenderTest.java @@ -21,12 +21,12 @@ import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.mock.MockApplication; import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.settings.RequestCycleSettings; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * https://issues.apache.org/jira/browse/WICKET-5679 */ -public class StartComponentInPageRedirectToRenderTest extends WicketTestCase +class StartComponentInPageRedirectToRenderTest extends WicketTestCase { @Override protected WebApplication newApplication() @@ -43,7 +43,7 @@ public class StartComponentInPageRedirectToRenderTest extends WicketTestCase } @Test - public void startComponentInPageRedirectToRender() + void startComponentInPageRedirectToRender() { tester.startComponentInPage(new Label("foo")); }
