- upgrade junit4 with junit5 in wicket-util - replace Junit4 Methods in WicketTester.java - remove junit 4 dependencies in pom.xml
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/978ea5cb Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/978ea5cb Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/978ea5cb Branch: refs/heads/master Commit: 978ea5cb9a01dcb9ad192a9413d9a18db35b8ca5 Parents: de2aedd Author: renoth <[email protected]> Authored: Tue Jul 31 12:32:49 2018 +0200 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Wed Sep 26 15:36:17 2018 +0300 ---------------------------------------------------------------------- pom.xml | 18 +- wicket-core/pom.xml | 12 +- .../apache/wicket/util/tester/WicketTester.java | 488 ++++++++++--------- wicket-util/pom.xml | 13 +- .../license/AbstractLicenseHeaderHandler.java | 103 ++-- .../license/ApacheLicenseHeaderTestCase.java | 307 ++++++------ .../util/license/CssLicenseHeaderHandler.java | 4 +- .../util/license/JavaLicenseHeaderHandler.java | 10 +- .../license/PropertiesLicenseHeaderHandler.java | 10 +- .../license/VelocityLicenseHeaderHandler.java | 10 +- .../util/license/XmlLicenseHeaderHandler.java | 19 +- .../util/license/XmlPrologHeaderHandler.java | 19 +- .../markup/xhtml/WellFormedXmlTestCase.java | 18 +- .../org/apache/wicket/util/LongEncoderTest.java | 10 +- .../wicket/util/collections/IntHashMapTest.java | 16 +- .../wicket/util/collections/MicroMapTest.java | 13 +- .../wicket/util/collections/MiniMapTest.java | 13 +- .../collections/MostRecentlyUsedMapTest.java | 6 +- .../collections/ReverseListIteratorTest.java | 7 +- .../converter/BigIntegerConverterTest.java | 19 +- .../converter/LocalDateConverterTest.java | 14 +- .../converter/LocalDateTimeConverterTest.java | 14 +- .../converter/LocalTimeConverterTest.java | 14 +- .../converter/ZonedDateTimeConverterTest.java | 14 +- .../apache/wicket/util/crypt/Base64Test.java | 7 +- .../wicket/util/crypt/SunJceCryptTest.java | 19 +- ...UnlimitedStrengthJurisdictionPolicyTest.java | 23 +- .../wicket/util/encoding/UrlDecoderTest.java | 4 +- .../wicket/util/encoding/UrlEncoderTest.java | 11 +- .../org/apache/wicket/util/file/FilesTest.java | 131 ++--- .../apache/wicket/util/file/WebXmlFileTest.java | 14 +- .../apache/wicket/util/io/ConnectionsTest.java | 19 +- .../apache/wicket/util/io/LastModifiedTest.java | 11 +- .../apache/wicket/util/io/XmlReaderTest.java | 8 +- .../org/apache/wicket/util/lang/ArgsTest.java | 25 +- .../org/apache/wicket/util/lang/BytesTest.java | 53 +- .../apache/wicket/util/lang/ClassesTest.java | 7 +- .../apache/wicket/util/lang/NumbersTest.java | 7 +- .../apache/wicket/util/lang/ObjectsTest.java | 7 +- .../apache/wicket/util/lang/PackagesTest.java | 7 +- .../apache/wicket/util/lang/PrimitivesTest.java | 28 +- .../util/parse/metapattern/MetaPatternTest.java | 12 +- .../parsers/VariableAssignmentParserTest.java | 7 +- .../wicket/util/resource/ResourceUtilsTest.java | 34 +- .../org/apache/wicket/util/size/BytesTest.java | 19 +- .../util/string/AppendingStringBufferTest.java | 9 +- .../util/string/PrependingStringBufferTest.java | 8 +- .../wicket/util/string/StringListTest.java | 7 +- .../wicket/util/string/StringValueTest.java | 48 +- .../apache/wicket/util/string/StringsTest.java | 48 +- .../interpolator/VariableInterpolatorTest.java | 8 +- .../apache/wicket/util/time/DurationTest.java | 13 +- .../apache/wicket/util/time/TimeFrameTest.java | 27 +- .../apache/wicket/util/time/TimeMapTest.java | 7 +- .../apache/wicket/util/time/TimeOfDayTest.java | 8 +- .../org/apache/wicket/util/time/TimeTest.java | 6 +- .../apache/wicket/util/value/LongValueTest.java | 6 +- .../apache/wicket/util/value/ValueMapTest.java | 9 +- .../wicket/util/visit/AllVisitFilterTest.java | 7 +- .../wicket/util/visit/ClassVisitFilterTest.java | 8 +- 60 files changed, 937 insertions(+), 906 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 0e8297d..8edc8af 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ <cglib.version>3.2.8</cglib.version> <jacoco.version>0.8.2</jacoco.version> <jetty.version>9.4.12.v20180830</jetty.version> - <junit.version>4.12</junit.version> + <junit.version>5.2.0</junit.version> <spring.version>5.1.0.RELEASE</spring.version> <servlet-api.version>3.1.0</servlet-api.version> <maven.javadoc.version>3.0.1</maven.javadoc.version> @@ -494,16 +494,10 @@ </exclusions> </dependency> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> <version>${junit.version}</version> <scope>test</scope> - <exclusions> - <exclusion> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-core</artifactId> - </exclusion> - </exclusions> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> @@ -587,10 +581,6 @@ <artifactId>slf4j-api</artifactId> </dependency> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </dependency> - <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> </dependency> @@ -1295,7 +1285,7 @@ <inherited>true</inherited> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> - <version>2.9</version> + <version>3.0.0</version> <reportSets> <reportSet> <reports> http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-core/pom.xml ---------------------------------------------------------------------- diff --git a/wicket-core/pom.xml b/wicket-core/pom.xml index d9d8342..e19d904 100644 --- a/wicket-core/pom.xml +++ b/wicket-core/pom.xml @@ -37,8 +37,8 @@ </description> <dependencies> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> <!-- provided because of WicketTester --> <scope>provided</scope> <optional>true</optional> @@ -64,6 +64,14 @@ <artifactId>jdk-serializable-functional</artifactId> </dependency> <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </dependency> + <dependency> + <groupId>com.github.openjson</groupId> + <artifactId>openjson</artifactId> + </dependency> + <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <scope>test</scope> http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java b/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java index 613bb02..a35aa0d 100644 --- a/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java +++ b/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java @@ -16,22 +16,6 @@ */ package org.apache.wicket.util.tester; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -import javax.servlet.ServletContext; - -import junit.framework.AssertionFailedError; - import org.apache.commons.collections4.CollectionUtils; import org.apache.wicket.Component; import org.apache.wicket.MarkupContainer; @@ -54,14 +38,24 @@ import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.util.lang.Args; import org.apache.wicket.util.lang.Objects; +import org.opentest4j.AssertionFailedError; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.servlet.ServletContext; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + +import static org.junit.jupiter.api.Assertions.*; + /** * A helper class to ease unit testing of Wicket applications without the need for a servlet * container. To start a test, either use <code>startPage</code> or <code>startPanel</code>: - * + * * <pre> * // production page * public class MyPage extends WebPage @@ -79,16 +73,16 @@ import org.slf4j.LoggerFactory; * } * } * </pre> - * + * * <pre> * // test code * private WicketTester tester; - * + * * public void setUp() * { * tester = new WicketTester(); * } - * + * * public void testRenderMyPage() * { * // start and render the test page @@ -99,10 +93,10 @@ import org.slf4j.LoggerFactory; * tester.assertLabel("myMessage", "Hello!"); * } * </pre> - * + * * The above example is straight forward: start <code>MyPage.class</code> and assert * <code>Label</code> it rendered. Next, we try to navigate through a <code>Link</code>: - * + * * <pre> * // production page * public class YourPage extends WebPage @@ -113,7 +107,7 @@ import org.slf4j.LoggerFactory; * info("Wicket Rocks ;-)"); * } * } - * + * * // test code * public void testLinkToYourPage() * { @@ -124,11 +118,11 @@ import org.slf4j.LoggerFactory; * tester.assertLabel("yourMessage", "Hi!"); * } * </pre> - * + * * <code>tester.clickLink(path);</code> will simulate user click on the component (in this case, * it's a <code>Link</code>) and render the response page <code>YourPage</code>. Ok, unit test of * <code>MyPage</code> is completed. Now we test <code>YourPage</code> standalone: - * + * * <pre> * // test code * public void testRenderYourPage() @@ -141,30 +135,28 @@ import org.slf4j.LoggerFactory; * tester.assertInfoMessages(new String[] { "Wicket Rocks ;-)" }); * } * </pre> - * + * * Many methods require a 'path' parameter. E.g. the page relative path can be obtained via * {@link Component#getPageRelativePath()}. Since each Component has an ID/name, any Component can * also be referenced by its ID {@link MarkupContainer#get(String)}. And since MarkupContainer's and * its subclasses are containers which allow to add Components (in sync with the markup hierarchy), * you may not only access direct childs but also subchilds like get("myPanel:myForm:myNameField") * separating each ID with a ':'. - * + * * Cookie handling: - * - * There are some expectations about wicket tester cookie handling which should match as best as - * it can be with a real client server request response cycle: - * - all valid cookies set before a request is made (tester.getRequest().addCookie()) should - * appear in the page request - * - all cookies set in the response should appear in the last response (tester.getLastResponse()) - * after the request is made (expired cookies and others) - * - all cookies set in the response should appear even after a redirect response is made - * until the final response (tester.getLastResponse()) is written to the client (wicket tester) - * - all valid cookies (maxAge!=0) from the last response should be added to - * the next request cookies (tester.getRequest().getCookies()) - * - * + * + * There are some expectations about wicket tester cookie handling which should match as best as it + * can be with a real client server request response cycle: - all valid cookies set before a request + * is made (tester.getRequest().addCookie()) should appear in the page request - all cookies set in + * the response should appear in the last response (tester.getLastResponse()) after the request is + * made (expired cookies and others) - all cookies set in the response should appear even after a + * redirect response is made until the final response (tester.getLastResponse()) is written to the + * client (wicket tester) - all valid cookies (maxAge!=0) from the last response should be added to + * the next request cookies (tester.getRequest().getCookies()) + * + * * TODO General: Example usage of FormTester - * + * * @author Ingram Chen * @author Juergen Donnerstag * @author Frank Bille @@ -185,7 +177,7 @@ public class WicketTester extends BaseWicketTester /** * Creates a <code>WicketTester</code> and automatically creates a <code>WebApplication</code>. - * + * * @param homePage * a home page <code>Class</code> */ @@ -196,7 +188,7 @@ public class WicketTester extends BaseWicketTester /** * Creates a <code>WicketTester</code>. - * + * * @param application * a <code>WicketTester</code> <code>WebApplication</code> object */ @@ -207,13 +199,13 @@ public class WicketTester extends BaseWicketTester /** * Creates a <code>WicketTester</code> to help unit testing. - * + * * @param application * a <code>WicketTester</code> <code>WebApplication</code> object * @param path * the absolute path on disk to the web application's contents (e.g. war root) - may * be <code>null</code> - * + * * @see org.apache.wicket.mock.MockApplication#MockApplication() */ public WicketTester(final WebApplication application, final String path) @@ -223,7 +215,7 @@ public class WicketTester extends BaseWicketTester /** * Creates a <code>WicketTester</code> to help unit testing. - * + * * @param application * a <code>WicketTester</code> <code>WebApplication</code> object * @param servletCtx @@ -233,10 +225,10 @@ public class WicketTester extends BaseWicketTester { super(application, servletCtx); } - + /** * Creates a <code>WicketTester</code> to help unit testing. - * + * * @param application * a <code>WicketTester</code> <code>WebApplication</code> object * @param init @@ -246,10 +238,10 @@ public class WicketTester extends BaseWicketTester { super(application, init); } - + /** * Creates a <code>WicketTester</code> to help unit testing. - * + * * @param application * a <code>WicketTester</code> <code>WebApplication</code> object * @param servletCtx @@ -263,19 +255,41 @@ public class WicketTester extends BaseWicketTester } /** + * Returns the current Maven build directory taken from the <tt>basedir</tt> system property, or + * null if not set + * + * @return path with a trailing slash + */ + public static String getBasedir() + { + String basedir = System.getProperty("basedir"); + if (basedir != null) + { + basedir = basedir + "/"; + } + else + { + basedir = ""; + } + return basedir; + } + + /** * Asserts that the Ajax location header is present. */ public void assertAjaxLocation() { if (null != getLastResponse().getHeader("Location")) { - fail("Location header should *not* be present when using Ajax"); + throw new AssertionFailedError( + "Location header should *not* be present when using Ajax"); } String ajaxLocation = getLastResponse().getHeader("Ajax-Location"); if (null == ajaxLocation) { - throw new AssertionFailedError("Ajax-Location header should be present when using Ajax"); + throw new AssertionFailedError( + "Ajax-Location header should be present when using Ajax"); } int statusCode = getLastResponse().getStatus(); @@ -287,7 +301,7 @@ public class WicketTester extends BaseWicketTester /** * Asserts a <code>Component</code> class. - * + * * @param path * path to <code>Component</code> * @param expectedComponentClass @@ -299,8 +313,19 @@ public class WicketTester extends BaseWicketTester } /** - * Asserts that the <code>Component</code> a the given path has a behavior - * of the given type. + * + * @param result + */ + private void assertResult(Result result) + { + if (result.wasFailed()) + { + throw new AssertionFailedError(result.getMessage()); + } + } + + /** + * Asserts that the <code>Component</code> a the given path has a behavior of the given type. * * @param path * path to <code>Component</code> @@ -314,49 +339,49 @@ public class WicketTester extends BaseWicketTester Component component = assertExists(path); List<? extends Behavior> behaviors = component.getBehaviors(expectedBehaviorClass); final String message = String.format("Component '%s' has no behaviors of type '%s'", - component.getPageRelativePath(), expectedBehaviorClass); + component.getPageRelativePath(), expectedBehaviorClass); assertResult(new Result(CollectionUtils.isEmpty(behaviors), message)); } /** * Tests that a <code>Component</code> has been added to a <code>AjaxRequestTarget</code>, using - * {@link org.apache.wicket.ajax.AjaxRequestTarget#add(Component...)}. This method actually tests that a - * <code>Component</code> is on the Ajax response sent back to the client. + * {@link org.apache.wicket.ajax.AjaxRequestTarget#add(Component...)}. This method actually + * tests that a <code>Component</code> is on the Ajax response sent back to the client. * <p> * PLEASE NOTE! This method doesn't actually insert the <code>Component</code> in the client DOM * tree, using JavaScript. But it shouldn't be needed because you just have to trust that Wicket * Ajax JavaScript works. - * - * @param component - * a <code>Component</code> to be tested + * + * @param componentPath + * a <code>Component</code> path to test */ - public void assertComponentOnAjaxResponse(Component component) + public void assertComponentOnAjaxResponse(String componentPath) { - Result result = isComponentOnAjaxResponse(component); - assertResult(result); + Component component = getComponentFromLastRenderedPage(componentPath, false); + assertComponentOnAjaxResponse(component); } /** * Tests that a <code>Component</code> has been added to a <code>AjaxRequestTarget</code>, using - * {@link org.apache.wicket.ajax.AjaxRequestTarget#add(Component...)}. This method actually tests that a - * <code>Component</code> is on the Ajax response sent back to the client. + * {@link org.apache.wicket.ajax.AjaxRequestTarget#add(Component...)}. This method actually + * tests that a <code>Component</code> is on the Ajax response sent back to the client. * <p> * PLEASE NOTE! This method doesn't actually insert the <code>Component</code> in the client DOM * tree, using JavaScript. But it shouldn't be needed because you just have to trust that Wicket * Ajax JavaScript works. - * - * @param componentPath - * a <code>Component</code> path to test + * + * @param component + * a <code>Component</code> to be tested */ - public void assertComponentOnAjaxResponse(String componentPath) + public void assertComponentOnAjaxResponse(Component component) { - Component component = getComponentFromLastRenderedPage(componentPath, false); - assertComponentOnAjaxResponse(component); + Result result = isComponentOnAjaxResponse(component); + assertResult(result); } /** * Asserts the content of last rendered page contains (matches) a given regex pattern. - * + * * @param pattern * a regex pattern to match */ @@ -367,7 +392,7 @@ public class WicketTester extends BaseWicketTester /** * The opposite of {@link #assertContains(String)}. - * + * * @param pattern * pattern */ @@ -380,9 +405,9 @@ public class WicketTester extends BaseWicketTester * Asserts that a component's markup has loaded with the given variation * * @param component - * The component which markup to check + * The component which markup to check * @param expectedVariation - * The expected variation of the component's markup + * The expected variation of the component's markup */ public void assertMarkupVariation(Component component, String expectedVariation) { @@ -392,21 +417,44 @@ public class WicketTester extends BaseWicketTester String actualVariation = markup.getMarkupResourceStream().getVariation(); if (Objects.equal(expectedVariation, actualVariation) == false) { - result = Result.fail(String.format("Wrong variation for component '%s'. Actual: '%s', expected: '%s'", + result = Result.fail( + String.format("Wrong variation for component '%s'. Actual: '%s', expected: '%s'", component.getPageRelativePath(), actualVariation, expectedVariation)); } assertResult(result); } + private IMarkupFragment getMarkupFragment(Component component) + { + IMarkupFragment markup = null; + if (component instanceof MarkupContainer) + { + markup = ((MarkupContainer)component).getAssociatedMarkup(); + } + + if (markup == null) + { + markup = component.getMarkup(); + } + + if (markup == null) + { + throw new AssertionFailedError(String.format("Cannot find the markup of component: %s", + component.getPageRelativePath())); + } + + return markup; + } + /** * Asserts that a component's markup has loaded with the given style. * * @param component - * The component which markup to check + * The component which markup to check * @param expectedStyle - * The expected style of the component's markup. - * For example: <em>green</em> in <code>MyPanel_green.html</code> + * The expected style of the component's markup. For example: <em>green</em> in + * <code>MyPanel_green.html</code> */ public void assertMarkupStyle(Component component, String expectedStyle) { @@ -416,7 +464,8 @@ public class WicketTester extends BaseWicketTester String actualStyle = markup.getMarkupResourceStream().getStyle(); if (Objects.equal(expectedStyle, actualStyle) == false) { - result = Result.fail(String.format("Wrong style for component '%s'. Actual: '%s', expected: '%s'", + result = Result + .fail(String.format("Wrong style for component '%s'. Actual: '%s', expected: '%s'", component.getPageRelativePath(), actualStyle, expectedStyle)); } @@ -427,9 +476,9 @@ public class WicketTester extends BaseWicketTester * Asserts that a component's markup has loaded with the given locale * * @param component - * The component which markup to check + * The component which markup to check * @param expectedLocale - * The expected locale of the component's markup + * The expected locale of the component's markup */ public void assertMarkupLocale(Component component, Locale expectedLocale) { @@ -439,54 +488,24 @@ public class WicketTester extends BaseWicketTester Locale actualLocale = markup.getMarkupResourceStream().getLocale(); if (Objects.equal(expectedLocale, actualLocale) == false) { - result = Result.fail(String.format("Wrong locale for component '%s'. Actual: '%s', expected: '%s'", + result = Result + .fail(String.format("Wrong locale for component '%s'. Actual: '%s', expected: '%s'", component.getPageRelativePath(), actualLocale, expectedLocale)); } assertResult(result); } - private IMarkupFragment getMarkupFragment(Component component) - { - IMarkupFragment markup = null; - if (component instanceof MarkupContainer) - { - markup = ((MarkupContainer) component).getAssociatedMarkup(); - } - - if (markup == null) - { - markup = component.getMarkup(); - } - - if (markup == null) - { - throw new AssertionFailedError(String.format("Cannot find the markup of component: %s", component.getPageRelativePath())); - } - - return markup; - } - /** * Asserts error-level feedback messages. - * + * * @param expectedErrorMessages * expected error messages */ public void assertErrorMessages(Serializable... expectedErrorMessages) { - assertFeedbackMessages(new ExactLevelFeedbackMessageFilter(FeedbackMessage.ERROR), expectedErrorMessages); - } - - /** - * Assert info-level feedback messages. - * - * @param expectedInfoMessages - * expected info messages - */ - public void assertInfoMessages(Serializable... expectedInfoMessages) - { - assertFeedbackMessages(new ExactLevelFeedbackMessageFilter(FeedbackMessage.INFO), expectedInfoMessages); + assertFeedbackMessages(new ExactLevelFeedbackMessageFilter(FeedbackMessage.ERROR), + expectedErrorMessages); } /** @@ -497,7 +516,8 @@ public class WicketTester extends BaseWicketTester * @param expectedMessages * expected feedback messages */ - public void assertFeedbackMessages(IFeedbackMessageFilter filter, Serializable... expectedMessages) + public void assertFeedbackMessages(IFeedbackMessageFilter filter, + Serializable... expectedMessages) { List<FeedbackMessage> feedbackMessages = getFeedbackMessages(filter); List<Serializable> actualMessages = getActualFeedbackMessages(feedbackMessages); @@ -505,34 +525,8 @@ public class WicketTester extends BaseWicketTester } /** - * Asserts that there is a feedback message provided by a given component - * - * @param component - * the component that provided the expected feedback message. Optional. - * @param key - * the resource key for the feedback message. Mandatory. - * @param model - * the model used for interpolating the feedback message. Optional. - * @param filter - * the filter that decides in which messages to look in. E.g. with a specific - * level, rendered or not, etc. - */ - public void assertComponentFeedbackMessage(Component component, String key, IModel<?> model, IFeedbackMessageFilter filter) - { - Args.notNull(key, "key"); - - String expectedMessage = getApplication().getResourceSettings().getLocalizer().getString(key, component, model); - - List<FeedbackMessage> feedbackMessages = getFeedbackMessages(filter); - List<Serializable> actualMessages = getActualFeedbackMessages(feedbackMessages); - - assertTrue(String.format("Feedback message with key '%s' cannot be found in %s", key, actualMessages), - actualMessages.contains(expectedMessage)); - } - - /** - * Extracts the actual messages from the passed feedback messages. - * Specially handles ValidationErrorFeedback messages by extracting their String message + * Extracts the actual messages from the passed feedback messages. Specially handles + * ValidationErrorFeedback messages by extracting their String message * * @param feedbackMessages * the feedback messages @@ -557,12 +551,52 @@ public class WicketTester extends BaseWicketTester } /** + * Assert info-level feedback messages. + * + * @param expectedInfoMessages + * expected info messages + */ + public void assertInfoMessages(Serializable... expectedInfoMessages) + { + assertFeedbackMessages(new ExactLevelFeedbackMessageFilter(FeedbackMessage.INFO), + expectedInfoMessages); + } + + /** + * Asserts that there is a feedback message provided by a given component + * + * @param component + * the component that provided the expected feedback message. Optional. + * @param key + * the resource key for the feedback message. Mandatory. + * @param model + * the model used for interpolating the feedback message. Optional. + * @param filter + * the filter that decides in which messages to look in. E.g. with a specific level, + * rendered or not, etc. + */ + public void assertComponentFeedbackMessage(Component component, String key, IModel<?> model, + IFeedbackMessageFilter filter) + { + Args.notNull(key, "key"); + + String expectedMessage = getApplication().getResourceSettings().getLocalizer().getString( + key, component, model); + + List<FeedbackMessage> feedbackMessages = getFeedbackMessages(filter); + List<Serializable> actualMessages = getActualFeedbackMessages(feedbackMessages); + + assertTrue(actualMessages.contains(expectedMessage), String + .format("Feedback message with key '%s' cannot be found in %s", key, actualMessages)); + } + + /** * Assert that a particular feedback panel is rendering certain messages. - * + * * NOTE: this casts the component at the specified path to a {@link FeedbackPanel}, so it will * not work with custom {@link IFeedback} implementations unless you are subclassing * {@link FeedbackPanel} - * + * * @param path * path to the feedback panel * @param messages @@ -579,8 +613,9 @@ public class WicketTester extends BaseWicketTester } if (messages.length != renderedMessages.size()) { - fail(String.format("you expected '%d' messages for the feedback panel [%s], but there were actually '%d'", - messages.length, path, renderedMessages.size())); + fail(String.format( + "you expected '%d' messages for the feedback panel [%s], but there were actually '%d'", + messages.length, path, renderedMessages.size())); } for (int i = 0; i < messages.length && i < renderedMessages.size(); i++) { @@ -603,7 +638,7 @@ public class WicketTester extends BaseWicketTester /** * Asserts that a <code>Component</code> is invisible. - * + * * @param path * path to <code>Component</code> */ @@ -614,7 +649,7 @@ public class WicketTester extends BaseWicketTester /** * Asserts the text of a <code>Label</code> <code>Component</code>. - * + * * @param path * path to <code>Label</code> <code>Component</code> * @param expectedLabelText @@ -628,7 +663,7 @@ public class WicketTester extends BaseWicketTester /** * Asserts the model value of a component. - * + * * @param path * path to the component on the page * @param expectedValue @@ -642,7 +677,7 @@ public class WicketTester extends BaseWicketTester /** * Asserts the model of a {@link ListView}. - * + * * @param path * path to a {@link ListView} <code>Component</code> * @param expectedList @@ -659,67 +694,56 @@ public class WicketTester extends BaseWicketTester } /** - * Asserts no error-level feedback messages. + * Asserts last-rendered <code>Page</code> against an expected HTML document. + * <p> + * Use <code>-Dwicket.replace.expected.results=true</code> to automatically replace the expected + * output file. + * + * @param clazz + * <code>Class</code> used to load the file (relative to <code>clazz</code> package) + * @param filename + * expected output filename <code>String</code> + * @throws Exception */ - public void assertNoErrorMessage() + @Override + public void assertResultPage(final Class<?> clazz, final String filename) throws Exception { - assertNoFeedbackMessage(FeedbackMessage.ERROR); + String document = getLastResponseAsString(); + DiffUtil.validatePage(document, clazz, filename, true); } /** - * Asserts no info-level feedback messages. + * Asserts no error-level feedback messages. */ - public void assertNoInfoMessage() + public void assertNoErrorMessage() { - assertNoFeedbackMessage(FeedbackMessage.INFO); + assertNoFeedbackMessage(FeedbackMessage.ERROR); } /** * Asserts there are no feedback messages with a certain level. - * + * * @param level * the level to check for */ public void assertNoFeedbackMessage(int level) { Result result = hasNoFeedbackMessage(level); - assertFalse(result.getMessage(), result.wasFailed()); - } - - /** - * Asserts a last-rendered <code>Page</code> class. - * - * @param expectedRenderedPageClass - * expected class of last rendered <code>Page</code> - */ - public void assertRenderedPage(Class<? extends Page> expectedRenderedPageClass) - { - assertResult(isRenderedPage(expectedRenderedPageClass)); + assertFalse(result.wasFailed(), result.getMessage()); } /** - * Asserts last-rendered <code>Page</code> against an expected HTML document. - * <p> - * Use <code>-Dwicket.replace.expected.results=true</code> to automatically replace the expected - * output file. - * - * @param clazz - * <code>Class</code> used to load the file (relative to <code>clazz</code> package) - * @param filename - * expected output filename <code>String</code> - * @throws Exception + * Asserts no info-level feedback messages. */ - @Override - public void assertResultPage(final Class<?> clazz, final String filename) throws Exception + public void assertNoInfoMessage() { - String document = getLastResponseAsString(); - DiffUtil.validatePage(document, clazz, filename, true); + assertNoFeedbackMessage(FeedbackMessage.INFO); } /** * Asserts last-rendered <code>Page</code> against an expected HTML document as a * <code>String</code> - * + * * @param expectedDocument * expected output <code>String</code> * @throws Exception @@ -733,7 +757,7 @@ public class WicketTester extends BaseWicketTester /** * Asserts that a <code>Component</code> is visible. - * + * * @param path * path to a <code>Component</code> */ @@ -744,10 +768,10 @@ public class WicketTester extends BaseWicketTester /** * assert component is enabled. - * + * * @param path * path to component - * + * */ public void assertEnabled(String path) { @@ -756,7 +780,7 @@ public class WicketTester extends BaseWicketTester /** * assert component is enabled. - * + * * @param path * path to component */ @@ -767,7 +791,7 @@ public class WicketTester extends BaseWicketTester /** * assert form component is required. - * + * * @param path * path to form component */ @@ -788,20 +812,8 @@ public class WicketTester extends BaseWicketTester } /** - * - * @param result - */ - private void assertResult(Result result) - { - if (result.wasFailed()) - { - throw new AssertionFailedError(result.getMessage()); - } - } - - /** * Checks whether a component is visible and/or enabled before usage - * + * * @param component */ public void assertUsability(final Component component) @@ -810,7 +822,7 @@ public class WicketTester extends BaseWicketTester } /** - * + * * @param link */ public void clickLink(Component link) @@ -821,7 +833,7 @@ public class WicketTester extends BaseWicketTester /** * Asserts that that the BookmarkablePageLink<?> identified by "id" points to the page as * expected - including parameters. - * + * * @param id * @param pageClass * @param parameters @@ -836,21 +848,22 @@ public class WicketTester extends BaseWicketTester } catch (ClassCastException e) { - throw new IllegalArgumentException("Component with id:" + id + - " is not a BookmarkablePageLink"); + throw new IllegalArgumentException( + "Component with id:" + id + " is not a BookmarkablePageLink"); } - assertEquals("BookmarkablePageLink: " + id + " is pointing to the wrong page", pageClass, - pageLink.getPageClass()); + assertEquals(pageClass, pageLink.getPageClass(), + "BookmarkablePageLink: " + id + " is pointing to the wrong page"); - assertEquals("One or more of the parameters associated with the BookmarkablePageLink: " + - id + " do not match", parameters, pageLink.getPageParameters()); + assertEquals(parameters, pageLink.getPageParameters(), + "One or more of the parameters associated with the BookmarkablePageLink: " + id + + " do not match"); } /** * Use <code>-Dwicket.replace.expected.results=true</code> to automatically replace the expected * output file. - * + * * @param <T> * @param testClass * @param pageClass @@ -868,9 +881,20 @@ public class WicketTester extends BaseWicketTester } /** + * Asserts a last-rendered <code>Page</code> class. + * + * @param expectedRenderedPageClass + * expected class of last rendered <code>Page</code> + */ + public void assertRenderedPage(Class<? extends Page> expectedRenderedPageClass) + { + assertResult(isRenderedPage(expectedRenderedPageClass)); + } + + /** * Use <code>-Dwicket.replace.expected.results=true</code> to automatically replace the expected * output file. - * + * * @param testClass * @param page * @param filename @@ -889,7 +913,7 @@ public class WicketTester extends BaseWicketTester /** * Use <code>-Dwicket.replace.expected.results=true</code> to automatically replace the expected * output file. - * + * * @param testClass * @param component * @param filename @@ -907,7 +931,7 @@ public class WicketTester extends BaseWicketTester /** * Use <code>-Dwicket.replace.expected.results=true</code> to automatically replace the expected * output file. - * + * * @param <T> * @param testClass * @param pageClass @@ -926,7 +950,7 @@ public class WicketTester extends BaseWicketTester } /** - * + * * @param testClass * @param component * @param filename @@ -944,7 +968,7 @@ public class WicketTester extends BaseWicketTester } /** - * + * * @param testClass * @param behavior * @param filename @@ -963,7 +987,7 @@ public class WicketTester extends BaseWicketTester /** * Assert that the last request redirected to the given Url. - * + * * @param expectedRedirectUrl * expected */ @@ -972,24 +996,4 @@ public class WicketTester extends BaseWicketTester String actualRedirectUrl = getLastResponse().getRedirectLocation(); assertEquals(expectedRedirectUrl, actualRedirectUrl); } - - /** - * Returns the current Maven build directory taken from the <tt>basedir</tt> system property, or - * null if not set - * - * @return path with a trailing slash - */ - public static String getBasedir() - { - String basedir = System.getProperty("basedir"); - if (basedir != null) - { - basedir = basedir + "/"; - } - else - { - basedir = ""; - } - return basedir; - } } http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/pom.xml ---------------------------------------------------------------------- diff --git a/wicket-util/pom.xml b/wicket-util/pom.xml index a0ac143..6f71806 100755 --- a/wicket-util/pom.xml +++ b/wicket-util/pom.xml @@ -28,10 +28,9 @@ <name>Wicket Util</name> <dependencies> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>provided</scope> - <optional>true</optional> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <scope>compile</scope> </dependency> <dependency> <groupId>commons-fileupload</groupId> @@ -45,5 +44,11 @@ <groupId>org.apache.commons</groupId> <artifactId>commons-collections4</artifactId> </dependency> + <dependency> + <groupId>org.opentest4j</groupId> + <artifactId>opentest4j</artifactId> + <version>RELEASE</version> + <scope>compile</scope> + </dependency> </dependencies> </project> http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/main/java/org/apache/wicket/util/license/AbstractLicenseHeaderHandler.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/main/java/org/apache/wicket/util/license/AbstractLicenseHeaderHandler.java b/wicket-util/src/main/java/org/apache/wicket/util/license/AbstractLicenseHeaderHandler.java index 74583c2..cbbc934 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/license/AbstractLicenseHeaderHandler.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/license/AbstractLicenseHeaderHandler.java @@ -16,24 +16,18 @@ */ package org.apache.wicket.util.license; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.LineNumberReader; +import java.io.*; import java.util.List; -import org.junit.Assert; import org.apache.wicket.util.io.IOUtils; import org.apache.wicket.util.string.Strings; - +import org.opentest4j.AssertionFailedError; abstract class AbstractLicenseHeaderHandler implements ILicenseHeaderHandler { protected static final String LINE_ENDING = System.getProperty("line.separator"); - private String licenseHeader; private final List<String> ignoreFiles; + private String licenseHeader; /** * Construct. @@ -64,48 +58,6 @@ abstract class AbstractLicenseHeaderHandler implements ILicenseHeaderHandler return null; } - protected abstract String getLicenseHeaderFilename(); - - protected String getLicenseHeader() - { - if (Strings.isEmpty(licenseHeader)) - { - LineNumberReader lineNumberReader = null; - InputStream inputStream = null; - InputStreamReader inputStreamReader = null; - - try - { - inputStream = ApacheLicenseHeaderTestCase.class.getResourceAsStream(getLicenseHeaderFilename()); - inputStreamReader = new InputStreamReader(inputStream); - lineNumberReader = new LineNumberReader(inputStreamReader); - - StringBuilder header = new StringBuilder(); - String line = lineNumberReader.readLine(); - while (line != null) - { - header.append(line); - header.append(LINE_ENDING); - line = lineNumberReader.readLine(); - } - - licenseHeader = header.toString().trim(); - } - catch (Exception e) - { - Assert.fail(e.getMessage()); - } - finally - { - IOUtils.closeQuietly(lineNumberReader); - IOUtils.closeQuietly(inputStream); - IOUtils.closeQuietly(inputStreamReader); - } - } - - return licenseHeader; - } - protected String extractLicenseHeader(final File file, final int start, final int length) { StringBuilder header = new StringBuilder(); @@ -124,7 +76,7 @@ abstract class AbstractLicenseHeaderHandler implements ILicenseHeaderHandler } catch (Exception e) { - Assert.fail(e.getMessage()); + throw new AssertionFailedError(e.getMessage()); } finally { @@ -134,7 +86,7 @@ abstract class AbstractLicenseHeaderHandler implements ILicenseHeaderHandler } catch (IOException e) { - Assert.fail(e.getMessage()); + throw new AssertionFailedError(e.getMessage()); } } @@ -158,7 +110,50 @@ abstract class AbstractLicenseHeaderHandler implements ILicenseHeaderHandler } catch (Exception e) { - Assert.fail(e.getMessage()); + throw new AssertionFailedError(e.getMessage()); } } + + protected String getLicenseHeader() + { + if (Strings.isEmpty(licenseHeader)) + { + LineNumberReader lineNumberReader = null; + InputStream inputStream = null; + InputStreamReader inputStreamReader = null; + + try + { + inputStream = ApacheLicenseHeaderTestCase.class + .getResourceAsStream(getLicenseHeaderFilename()); + inputStreamReader = new InputStreamReader(inputStream); + lineNumberReader = new LineNumberReader(inputStreamReader); + + StringBuilder header = new StringBuilder(); + String line = lineNumberReader.readLine(); + while (line != null) + { + header.append(line); + header.append(LINE_ENDING); + line = lineNumberReader.readLine(); + } + + licenseHeader = header.toString().trim(); + } + catch (Exception e) + { + throw new AssertionFailedError(e.getMessage()); + } + finally + { + IOUtils.closeQuietly(lineNumberReader); + IOUtils.closeQuietly(inputStream); + IOUtils.closeQuietly(inputStreamReader); + } + } + + return licenseHeader; + } + + protected abstract String getLicenseHeaderFilename(); } http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/main/java/org/apache/wicket/util/license/ApacheLicenseHeaderTestCase.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/main/java/org/apache/wicket/util/license/ApacheLicenseHeaderTestCase.java b/wicket-util/src/main/java/org/apache/wicket/util/license/ApacheLicenseHeaderTestCase.java index b39e7c3..8485723 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/license/ApacheLicenseHeaderTestCase.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/license/ApacheLicenseHeaderTestCase.java @@ -16,6 +16,14 @@ */ package org.apache.wicket.util.license; +import org.apache.wicket.util.lang.Generics; +import org.apache.wicket.util.string.Strings; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.opentest4j.AssertionFailedError; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.File; import java.io.FileFilter; import java.util.ArrayList; @@ -24,167 +32,18 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import org.apache.wicket.util.lang.Generics; -import org.apache.wicket.util.string.Strings; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * Testcase used in the different wicket projects for testing for the correct ASL license headers. * Doesn't really make sense outside org.apache.wicket. * * @author Frank Bille Jensen (frankbille) */ -public abstract class ApacheLicenseHeaderTestCase extends Assert +public abstract class ApacheLicenseHeaderTestCase { /** Log. */ private static final Logger log = LoggerFactory.getLogger(ApacheLicenseHeaderTestCase.class); private static final String LINE_ENDING = System.getProperty("line.separator"); - - interface FileVisitor - { - /** - * @param file - */ - void visitFile(File file); - } - - private class SuffixAndIgnoreFileFilter implements FileFilter - { - private final List<String> suffixes; - private final List<String> ignoreFiles; - - private SuffixAndIgnoreFileFilter(final List<String> suffixes, - final List<String> ignoreFiles) - { - this.suffixes = suffixes; - this.ignoreFiles = ignoreFiles; - } - - @Override - public boolean accept(final File pathname) - { - boolean accept = false; - - if (pathname.isFile()) - { - if (ignoreFile(pathname) == false) - { - for (String suffix : suffixes) - { - if (pathname.getName().endsWith("." + suffix)) - { - accept = true; - break; - } - else - { - log.debug("File ignored: '{}'", pathname); - } - } - } - else - { - log.debug("File ignored: '{}'", pathname); - } - } - - return accept; - } - - private boolean ignoreFile(final File pathname) - { - boolean ignore = false; - - if (ignoreFiles != null) - { - String relativePathname = pathname.getAbsolutePath(); - relativePathname = Strings.replaceAll(relativePathname, - baseDirectory.getAbsolutePath() + System.getProperty("file.separator"), "") - .toString(); - - for (String ignorePath : ignoreFiles) - { - // Will convert '/'s to '\\'s on Windows - ignorePath = Strings.replaceAll(ignorePath, "/", - System.getProperty("file.separator")).toString(); - File ignoreFile = new File(baseDirectory, ignorePath); - - // Directory ignore - if (ignoreFile.isDirectory()) - { - if (pathname.getAbsolutePath().startsWith(ignoreFile.getAbsolutePath())) - { - ignore = true; - break; - } - } - // Absolute file - else if (ignoreFile.isFile()) - { - if (relativePathname.equals(ignorePath)) - { - ignore = true; - break; - } - } - else if (pathname.getName().equals(ignorePath)) - { - ignore = true; - break; - } - } - } - - return ignore; - } - } - - private class DirectoryFileFilter implements FileFilter - { - private final String[] ignoreDirectory = new String[] { ".git" }; - - @Override - public boolean accept(final File pathname) - { - boolean accept = false; - - if (pathname.isDirectory()) - { - String relativePathname = pathname.getAbsolutePath(); - relativePathname = Strings.replaceAll(relativePathname, - baseDirectory.getAbsolutePath() + System.getProperty("file.separator"), "") - .toString(); - if ("target".equals(relativePathname) == false) - { - boolean found = false; - for (String ignore : ignoreDirectory) - { - if (pathname.getName().equals(ignore)) - { - found = true; - break; - } - } - if (found == false) - { - accept = true; - } - } - } - - return accept; - } - } - - private ILicenseHeaderHandler[] licenseHeaderHandlers; - - private File baseDirectory = new File("").getAbsoluteFile(); - protected List<String> javaIgnore = Generics.newArrayList(); protected List<String> htmlIgnore = Generics.newArrayList(); protected List<String> xmlPrologIgnore = Generics.newArrayList(); @@ -194,7 +53,8 @@ public abstract class ApacheLicenseHeaderTestCase extends Assert protected List<String> velocityIgnore = Generics.newArrayList(); protected List<String> javaScriptIgnore = Generics.newArrayList(); protected boolean addHeaders = false; - + private ILicenseHeaderHandler[] licenseHeaderHandlers; + private File baseDirectory = new File("").getAbsoluteFile(); /** * Construct. */ @@ -233,9 +93,9 @@ public abstract class ApacheLicenseHeaderTestCase extends Assert } /** - * + * */ - @Before + @BeforeEach public final void before() { // setup the base directory for when running inside maven (building a release @@ -334,7 +194,7 @@ public abstract class ApacheLicenseHeaderTestCase extends Assert } System.out.println(failString); - fail(failString.toString()); + throw new AssertionFailedError(failString.toString()); } } @@ -368,4 +228,143 @@ public abstract class ApacheLicenseHeaderTestCase extends Assert } } } + + interface FileVisitor + { + /** + * @param file + */ + void visitFile(File file); + } + + private class SuffixAndIgnoreFileFilter implements FileFilter + { + private final List<String> suffixes; + private final List<String> ignoreFiles; + + private SuffixAndIgnoreFileFilter(final List<String> suffixes, + final List<String> ignoreFiles) + { + this.suffixes = suffixes; + this.ignoreFiles = ignoreFiles; + } + + @Override + public boolean accept(final File pathname) + { + boolean accept = false; + + if (pathname.isFile()) + { + if (ignoreFile(pathname) == false) + { + for (String suffix : suffixes) + { + if (pathname.getName().endsWith("." + suffix)) + { + accept = true; + break; + } + else + { + log.debug("File ignored: '{}'", pathname); + } + } + } + else + { + log.debug("File ignored: '{}'", pathname); + } + } + + return accept; + } + + private boolean ignoreFile(final File pathname) + { + boolean ignore = false; + + if (ignoreFiles != null) + { + String relativePathname = pathname.getAbsolutePath(); + relativePathname = Strings + .replaceAll(relativePathname, + baseDirectory.getAbsolutePath() + System.getProperty("file.separator"), "") + .toString(); + + for (String ignorePath : ignoreFiles) + { + // Will convert '/'s to '\\'s on Windows + ignorePath = Strings + .replaceAll(ignorePath, "/", System.getProperty("file.separator")) + .toString(); + File ignoreFile = new File(baseDirectory, ignorePath); + + // Directory ignore + if (ignoreFile.isDirectory()) + { + if (pathname.getAbsolutePath().startsWith(ignoreFile.getAbsolutePath())) + { + ignore = true; + break; + } + } + // Absolute file + else if (ignoreFile.isFile()) + { + if (relativePathname.equals(ignorePath)) + { + ignore = true; + break; + } + } + else if (pathname.getName().equals(ignorePath)) + { + ignore = true; + break; + } + } + } + + return ignore; + } + } + + private class DirectoryFileFilter implements FileFilter + { + private final String[] ignoreDirectory = new String[] { ".git" }; + + @Override + public boolean accept(final File pathname) + { + boolean accept = false; + + if (pathname.isDirectory()) + { + String relativePathname = pathname.getAbsolutePath(); + relativePathname = Strings + .replaceAll(relativePathname, + baseDirectory.getAbsolutePath() + System.getProperty("file.separator"), "") + .toString(); + if ("target".equals(relativePathname) == false) + { + boolean found = false; + for (String ignore : ignoreDirectory) + { + if (pathname.getName().equals(ignore)) + { + found = true; + break; + } + } + if (found == false) + { + accept = true; + } + } + } + + return accept; + } + } } http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/main/java/org/apache/wicket/util/license/CssLicenseHeaderHandler.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/main/java/org/apache/wicket/util/license/CssLicenseHeaderHandler.java b/wicket-util/src/main/java/org/apache/wicket/util/license/CssLicenseHeaderHandler.java index 7be607c..eddaaa7 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/license/CssLicenseHeaderHandler.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/license/CssLicenseHeaderHandler.java @@ -20,9 +20,9 @@ import java.io.File; import java.util.Arrays; import java.util.List; -import org.junit.Assert; import org.apache.wicket.util.diff.Diff; import org.apache.wicket.util.diff.Revision; +import org.opentest4j.AssertionFailedError; class CssLicenseHeaderHandler extends AbstractLicenseHeaderHandler { @@ -55,7 +55,7 @@ class CssLicenseHeaderHandler extends AbstractLicenseHeaderHandler } catch (Exception e) { - Assert.fail(e.getMessage()); + throw new AssertionFailedError(e.getMessage()); } return revision.size() == 0; http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/main/java/org/apache/wicket/util/license/JavaLicenseHeaderHandler.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/main/java/org/apache/wicket/util/license/JavaLicenseHeaderHandler.java b/wicket-util/src/main/java/org/apache/wicket/util/license/JavaLicenseHeaderHandler.java index bbc0eac..e88a043 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/license/JavaLicenseHeaderHandler.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/license/JavaLicenseHeaderHandler.java @@ -16,15 +16,15 @@ */ package org.apache.wicket.util.license; +import org.apache.wicket.util.string.Strings; +import org.opentest4j.AssertionFailedError; + import java.io.File; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.junit.Assert; -import org.apache.wicket.util.string.Strings; - class JavaLicenseHeaderHandler extends AbstractLicenseHeaderHandler { private final Pattern javaHeaderPattern = Pattern.compile("^(.*?)package.*$", @@ -64,13 +64,13 @@ class JavaLicenseHeaderHandler extends AbstractLicenseHeaderHandler } else { - Assert.fail(); + throw new AssertionFailedError(); } } catch (Exception e) { e.printStackTrace(); - Assert.fail(e.getMessage()); + throw new AssertionFailedError(e.getMessage()); } return added; http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/main/java/org/apache/wicket/util/license/PropertiesLicenseHeaderHandler.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/main/java/org/apache/wicket/util/license/PropertiesLicenseHeaderHandler.java b/wicket-util/src/main/java/org/apache/wicket/util/license/PropertiesLicenseHeaderHandler.java index 98cbbe3..4a0447d 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/license/PropertiesLicenseHeaderHandler.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/license/PropertiesLicenseHeaderHandler.java @@ -16,14 +16,14 @@ */ package org.apache.wicket.util.license; +import org.apache.wicket.util.diff.Diff; +import org.apache.wicket.util.diff.Revision; +import org.opentest4j.AssertionFailedError; + import java.io.File; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.apache.wicket.util.diff.Diff; -import org.apache.wicket.util.diff.Revision; - class PropertiesLicenseHeaderHandler extends AbstractLicenseHeaderHandler { /** @@ -55,7 +55,7 @@ class PropertiesLicenseHeaderHandler extends AbstractLicenseHeaderHandler } catch (Exception e) { - Assert.fail(e.getMessage()); + throw new AssertionFailedError(e.getMessage()); } return revision.size() == 0; http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/main/java/org/apache/wicket/util/license/VelocityLicenseHeaderHandler.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/main/java/org/apache/wicket/util/license/VelocityLicenseHeaderHandler.java b/wicket-util/src/main/java/org/apache/wicket/util/license/VelocityLicenseHeaderHandler.java index 6e923b9..2d1286b 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/license/VelocityLicenseHeaderHandler.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/license/VelocityLicenseHeaderHandler.java @@ -16,14 +16,14 @@ */ package org.apache.wicket.util.license; +import org.apache.wicket.util.diff.Diff; +import org.apache.wicket.util.diff.Revision; +import org.opentest4j.AssertionFailedError; + import java.io.File; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.apache.wicket.util.diff.Diff; -import org.apache.wicket.util.diff.Revision; - class VelocityLicenseHeaderHandler extends AbstractLicenseHeaderHandler { /** @@ -55,7 +55,7 @@ class VelocityLicenseHeaderHandler extends AbstractLicenseHeaderHandler } catch (Exception e) { - Assert.fail(e.getMessage()); + throw new AssertionFailedError(e.getMessage()); } return revision.size() == 0; http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/main/java/org/apache/wicket/util/license/XmlLicenseHeaderHandler.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/main/java/org/apache/wicket/util/license/XmlLicenseHeaderHandler.java b/wicket-util/src/main/java/org/apache/wicket/util/license/XmlLicenseHeaderHandler.java index 98f1f45..8287622 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/license/XmlLicenseHeaderHandler.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/license/XmlLicenseHeaderHandler.java @@ -16,21 +16,22 @@ */ package org.apache.wicket.util.license; +import org.apache.wicket.util.diff.Diff; +import org.apache.wicket.util.diff.Revision; +import org.apache.wicket.util.string.Strings; +import org.opentest4j.AssertionFailedError; + import java.io.File; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.junit.Assert; -import org.apache.wicket.util.diff.Diff; -import org.apache.wicket.util.diff.Revision; -import org.apache.wicket.util.string.Strings; - class XmlLicenseHeaderHandler extends AbstractLicenseHeaderHandler { - private final Pattern xmlHeader = Pattern.compile("^(\\<\\?xml[^" + LINE_ENDING + "]+?)" + - LINE_ENDING + "(.*)$", Pattern.DOTALL | Pattern.MULTILINE); + private final Pattern xmlHeader = Pattern.compile( + "^(\\<\\?xml[^" + LINE_ENDING + "]+?)" + LINE_ENDING + "(.*)$", + Pattern.DOTALL | Pattern.MULTILINE); /** * Construct. @@ -82,7 +83,7 @@ class XmlLicenseHeaderHandler extends AbstractLicenseHeaderHandler catch (Exception e) { e.printStackTrace(); - Assert.fail(e.getMessage()); + throw new AssertionFailedError(e.getMessage()); } return revision.size() == 0; @@ -125,7 +126,7 @@ class XmlLicenseHeaderHandler extends AbstractLicenseHeaderHandler } catch (Exception e) { - Assert.fail(e.getMessage()); + throw new AssertionFailedError(e.getMessage()); } return added; http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/main/java/org/apache/wicket/util/license/XmlPrologHeaderHandler.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/main/java/org/apache/wicket/util/license/XmlPrologHeaderHandler.java b/wicket-util/src/main/java/org/apache/wicket/util/license/XmlPrologHeaderHandler.java index 083117b..3d652df 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/license/XmlPrologHeaderHandler.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/license/XmlPrologHeaderHandler.java @@ -16,12 +16,12 @@ */ package org.apache.wicket.util.license; +import org.opentest4j.AssertionFailedError; + import java.io.File; import java.util.Arrays; import java.util.List; -import org.junit.Assert; - class XmlPrologHeaderHandler extends XmlLicenseHeaderHandler { /** @@ -34,12 +34,6 @@ class XmlPrologHeaderHandler extends XmlLicenseHeaderHandler super(ignoreFiles); } - @Override - public List<String> getSuffixes() - { - return Arrays.asList("html"); - } - /** * @see org.apache.wicket.util.license.XmlLicenseHeaderHandler#checkLicenseHeader(java.io.File) */ @@ -53,8 +47,13 @@ class XmlPrologHeaderHandler extends XmlLicenseHeaderHandler } catch (Exception e) { - Assert.fail(e.getMessage()); + throw new AssertionFailedError(e.getMessage()); } - return true; + } + + @Override + public List<String> getSuffixes() + { + return Arrays.asList("html"); } } http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/main/java/org/apache/wicket/util/markup/xhtml/WellFormedXmlTestCase.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/main/java/org/apache/wicket/util/markup/xhtml/WellFormedXmlTestCase.java b/wicket-util/src/main/java/org/apache/wicket/util/markup/xhtml/WellFormedXmlTestCase.java index ecdc856..bf330de 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/markup/xhtml/WellFormedXmlTestCase.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/markup/xhtml/WellFormedXmlTestCase.java @@ -16,23 +16,19 @@ */ package org.apache.wicket.util.markup.xhtml; +import org.junit.jupiter.api.Test; +import org.testng.annotations.Test; +import org.xml.sax.*; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; import java.io.File; import java.io.FileFilter; import java.io.IOException; import java.util.HashMap; import java.util.Map; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.Test; -import org.xml.sax.EntityResolver; -import org.xml.sax.ErrorHandler; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - /** * Usable by tests to check that the html markup files are well formed. * http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/LongEncoderTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/LongEncoderTest.java b/wicket-util/src/test/java/org/apache/wicket/util/LongEncoderTest.java index c3731bb..4d5444b 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/LongEncoderTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/LongEncoderTest.java @@ -16,11 +16,13 @@ */ package org.apache.wicket.util; +import org.junit.jupiter.api.Test; + import java.util.HashSet; import java.util.Set; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; /** * Tests {@link LongEncoder} @@ -39,9 +41,9 @@ public class LongEncoderTest for (int i = -10000; i < 10000; i++) { String enc = LongEncoder.encode(i); - Assert.assertFalse("uniqueness: " + i, encoded.contains(enc)); + assertFalse(encoded.contains(enc), "uniqueness: " + i); encoded.add(enc); - Assert.assertEquals("decoding: " + i, i, LongEncoder.decode(enc)); + assertEquals(i, LongEncoder.decode(enc), "decoding: " + i); } } } http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/collections/IntHashMapTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/collections/IntHashMapTest.java b/wicket-util/src/test/java/org/apache/wicket/util/collections/IntHashMapTest.java index b5c7da1..4f8fdca 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/collections/IntHashMapTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/collections/IntHashMapTest.java @@ -16,18 +16,16 @@ */ package org.apache.wicket.util.collections; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.*; +import org.apache.wicket.util.io.ByteArrayOutputStream; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import org.apache.wicket.util.io.ByteArrayOutputStream; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; @SuppressWarnings("javadoc") public class IntHashMapTest @@ -48,9 +46,9 @@ public class IntHashMapTest ByteArrayInputStream bais = new ByteArrayInputStream(serialized); ObjectInputStream ois = new ObjectInputStream(bais); IntHashMap<String> deserialized = (IntHashMap<String>) ois.readObject(); - assertThat(deserialized, is(notNullValue())); - assertThat(deserialized.get(1), is(equalTo("one"))); - assertThat(deserialized.get(2), is(equalTo("two"))); + assertNotNull(deserialized); + assertEquals(deserialized.get(1), "one"); + assertEquals(deserialized.get(2), "two"); // WICKET-5584 deserialized.put(3, "three"); http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/collections/MicroMapTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/collections/MicroMapTest.java b/wicket-util/src/test/java/org/apache/wicket/util/collections/MicroMapTest.java index a26919b..ba7234a 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/collections/MicroMapTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/collections/MicroMapTest.java @@ -16,20 +16,17 @@ */ package org.apache.wicket.util.collections; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; +import org.junit.jupiter.api.Test; + +import java.util.*; import java.util.Map.Entry; -import java.util.NoSuchElementException; -import java.util.Set; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; /** * @author almaw */ -public class MicroMapTest extends Assert +public class MicroMapTest { private static final Object FOO = new Object(); private static final Object BAR = new Object(); http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/collections/MiniMapTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/collections/MiniMapTest.java b/wicket-util/src/test/java/org/apache/wicket/util/collections/MiniMapTest.java index ab0896d..a64c987 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/collections/MiniMapTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/collections/MiniMapTest.java @@ -16,20 +16,17 @@ */ package org.apache.wicket.util.collections; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; +import org.junit.jupiter.api.Test; + +import java.util.*; import java.util.Map.Entry; -import java.util.NoSuchElementException; -import java.util.Set; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; /** * @author almaw */ -public class MiniMapTest extends Assert +public class MiniMapTest { private static final Object FOO = new Object(); private static final Object BAR = new Object(); http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/collections/MostRecentlyUsedMapTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/collections/MostRecentlyUsedMapTest.java b/wicket-util/src/test/java/org/apache/wicket/util/collections/MostRecentlyUsedMapTest.java index 8a95d73..717fd4f 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/collections/MostRecentlyUsedMapTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/collections/MostRecentlyUsedMapTest.java @@ -16,10 +16,10 @@ */ package org.apache.wicket.util.collections; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/collections/ReverseListIteratorTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/collections/ReverseListIteratorTest.java b/wicket-util/src/test/java/org/apache/wicket/util/collections/ReverseListIteratorTest.java index 4fa5695..e4916db 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/collections/ReverseListIteratorTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/collections/ReverseListIteratorTest.java @@ -16,16 +16,17 @@ */ package org.apache.wicket.util.collections; +import org.junit.jupiter.api.Test; + import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for {@link ReverseListIterator} */ -public class ReverseListIteratorTest extends Assert +public class ReverseListIteratorTest { /** http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/BigIntegerConverterTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/BigIntegerConverterTest.java b/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/BigIntegerConverterTest.java index 479be0e..a62f597 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/BigIntegerConverterTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/BigIntegerConverterTest.java @@ -16,15 +16,17 @@ */ package org.apache.wicket.util.convert.converter; +import org.apache.wicket.util.convert.ConversionException; +import org.junit.jupiter.api.Test; + import java.math.BigInteger; import java.util.Locale; -import org.apache.wicket.util.convert.ConversionException; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; @SuppressWarnings("javadoc") -public class BigIntegerConverterTest extends Assert +public class BigIntegerConverterTest { @Test public void positiveInteger() @@ -76,10 +78,13 @@ public class BigIntegerConverterTest extends Assert assertEquals("-1234567890987654321234567890987654321234567890987654321", bigInteger.toString()); } - @Test(expected = ConversionException.class) + @Test public void nan() { - BigIntegerConverter converter = new BigIntegerConverter(); - converter.convertToObject("a12345a", Locale.GERMAN); + assertThrows(ConversionException.class, () -> { + BigIntegerConverter converter = new BigIntegerConverter(); + converter.convertToObject("a12345a", Locale.GERMAN); + }); + } } http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalDateConverterTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalDateConverterTest.java b/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalDateConverterTest.java index 4058e32..f3fc687 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalDateConverterTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalDateConverterTest.java @@ -16,33 +16,31 @@ */ package org.apache.wicket.util.convert.converter; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; +import org.apache.wicket.util.convert.ConversionException; +import org.junit.jupiter.api.Test; import java.time.LocalDate; import java.util.Locale; -import org.apache.wicket.util.convert.ConversionException; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for {@link LocalDateConverter} */ -public class LocalDateConverterTest extends Assert +public class LocalDateConverterTest { @Test public void convertToString() { LocalDateConverter converter = new LocalDateConverter(); String date = converter.convertToString(LocalDate.of(2016, 7, 11), Locale.ENGLISH); - assertThat(date, is(equalTo("7/11/16"))); + assertEquals(date, "7/11/16"); } @Test public void convertToObject() { LocalDateConverter converter = new LocalDateConverter(); LocalDate date = converter.convertToObject("7/11/16", Locale.ENGLISH); - assertThat(date, is(equalTo(LocalDate.of(2016, 7, 11)))); + assertEquals(date, LocalDate.of(2016, 7, 11)); } @Test http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalDateTimeConverterTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalDateTimeConverterTest.java b/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalDateTimeConverterTest.java index 5ca8182..821d469 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalDateTimeConverterTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalDateTimeConverterTest.java @@ -16,33 +16,31 @@ */ package org.apache.wicket.util.convert.converter; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; +import org.apache.wicket.util.convert.ConversionException; +import org.junit.jupiter.api.Test; import java.time.LocalDateTime; import java.util.Locale; -import org.apache.wicket.util.convert.ConversionException; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for {@link LocalDateTimeConverter} */ -public class LocalDateTimeConverterTest extends Assert +public class LocalDateTimeConverterTest { @Test public void convertToString() { LocalDateTimeConverter converter = new LocalDateTimeConverter(); String date = converter.convertToString(LocalDateTime.of(2016, 7, 11, 1, 2, 3), Locale.ENGLISH); - assertThat(date, is(equalTo("Jul 11, 2016, 1:02:03 AM"))); + assertEquals(date, "Jul 11, 2016, 1:02:03 AM"); } @Test public void convertToObject() { LocalDateTimeConverter converter = new LocalDateTimeConverter(); LocalDateTime date = converter.convertToObject("Jul 11, 2016, 1:02:03 AM", Locale.ENGLISH); - assertThat(date, is(equalTo(LocalDateTime.of(2016, 7, 11, 1, 2, 3)))); + assertEquals(date, LocalDateTime.of(2016, 7, 11, 1, 2, 3)); } @Test http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalTimeConverterTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalTimeConverterTest.java b/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalTimeConverterTest.java index 7c36b20..3234e4d 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalTimeConverterTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/LocalTimeConverterTest.java @@ -16,33 +16,31 @@ */ package org.apache.wicket.util.convert.converter; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; +import org.apache.wicket.util.convert.ConversionException; +import org.junit.jupiter.api.Test; import java.time.LocalTime; import java.util.Locale; -import org.apache.wicket.util.convert.ConversionException; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for {@link LocalTimeConverter} */ -public class LocalTimeConverterTest extends Assert +public class LocalTimeConverterTest { @Test public void convertToString() { LocalTimeConverter converter = new LocalTimeConverter(); String time = converter.convertToString(LocalTime.of(1, 2, 3), Locale.ENGLISH); - assertThat(time, is(equalTo("01:02:03"))); + assertEquals(time, "01:02:03"); } @Test public void convertToObject() { LocalTimeConverter converter = new LocalTimeConverter(); LocalTime time = converter.convertToObject("01:02:03", Locale.ENGLISH); - assertThat(time, is(equalTo(LocalTime.of(1, 2, 3)))); + assertEquals(time, LocalTime.of(1, 2, 3)); } @Test http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/ZonedDateTimeConverterTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/ZonedDateTimeConverterTest.java b/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/ZonedDateTimeConverterTest.java index d40a640..0761b85 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/ZonedDateTimeConverterTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/convert/converter/ZonedDateTimeConverterTest.java @@ -16,21 +16,19 @@ */ package org.apache.wicket.util.convert.converter; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; +import org.apache.wicket.util.convert.ConversionException; +import org.junit.jupiter.api.Test; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.Locale; -import org.apache.wicket.util.convert.ConversionException; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for {@link ZonedDateTimeConverter} */ -public class ZonedDateTimeConverterTest extends Assert +public class ZonedDateTimeConverterTest { private ZoneId zone = ZoneId.of("Etc/UCT"); @@ -38,14 +36,14 @@ public class ZonedDateTimeConverterTest extends Assert public void convertToString() { ZonedDateTimeConverter converter = new ZonedDateTimeConverter(); String date = converter.convertToString(ZonedDateTime.of(2016, 7, 11, 1, 2, 3, 0, zone), Locale.ENGLISH); - assertThat(date, is(equalTo("Jul 11, 2016, 1:02:03 AM Coordinated Universal Time"))); + assertEquals(date, "Jul 11, 2016, 1:02:03 AM Coordinated Universal Time"); } @Test public void convertToObject() { ZonedDateTimeConverter converter = new ZonedDateTimeConverter(); ZonedDateTime date = converter.convertToObject("Jul 11, 2016, 1:02:03 AM Coordinated Universal Time", Locale.ENGLISH); - assertThat(date, is(equalTo(ZonedDateTime.of(2016, 7, 11, 1, 2, 3, 0, zone)))); + assertEquals(date, ZonedDateTime.of(2016, 7, 11, 1, 2, 3, 0, zone)); } @Test http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/crypt/Base64Test.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/crypt/Base64Test.java b/wicket-util/src/test/java/org/apache/wicket/util/crypt/Base64Test.java index 708ddc4..15c5a04 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/crypt/Base64Test.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/crypt/Base64Test.java @@ -16,18 +16,19 @@ */ package org.apache.wicket.util.crypt; +import org.junit.jupiter.api.Test; + import java.io.IOException; import java.nio.ByteBuffer; import java.util.Random; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * * @author Juergen Donnerstag */ -public class Base64Test extends Assert +public class Base64Test { /** * @throws IOException http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java b/wicket-util/src/test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java index bd1ffa1..fdd3164 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java @@ -16,20 +16,17 @@ */ package org.apache.wicket.util.crypt; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Test; +import javax.crypto.Cipher; import java.security.GeneralSecurityException; import java.security.NoSuchAlgorithmException; -import javax.crypto.Cipher; - -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; @SuppressWarnings("javadoc") -public class SunJceCryptTest extends Assert +public class SunJceCryptTest { /** * Default encryption uses {@value org.apache.wicket.util.crypt.SunJceCrypt#DEFAULT_CRYPT_METHOD} @@ -42,7 +39,7 @@ public class SunJceCryptTest extends Assert byte[] encrypted = crypt.crypt(input.getBytes(), Cipher.ENCRYPT_MODE); byte[] decrypted = crypt.crypt(encrypted, Cipher.DECRYPT_MODE); - assertThat(new String(decrypted), is(equalTo(input))); + assertEquals(new String(decrypted), input); } /** @@ -52,14 +49,14 @@ public class SunJceCryptTest extends Assert public void customPBEEncryption() throws GeneralSecurityException { boolean unlimitedStrengthJurisdictionPolicyInstalled = isUnlimitedStrengthJurisdictionPolicyInstalled(); - Assume.assumeThat(unlimitedStrengthJurisdictionPolicyInstalled, is(true)); + Assumptions.assumeTrue(unlimitedStrengthJurisdictionPolicyInstalled); SunJceCrypt crypt = new SunJceCrypt("PBEWithMD5AndTripleDES"); String input = "input"; byte[] encrypted = crypt.crypt(input.getBytes(), Cipher.ENCRYPT_MODE); byte[] decrypted = crypt.crypt(encrypted, Cipher.DECRYPT_MODE); - assertThat(new String(decrypted), is(equalTo(input))); + assertEquals(new String(decrypted), input); } /** http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/crypt/UnlimitedStrengthJurisdictionPolicyTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/crypt/UnlimitedStrengthJurisdictionPolicyTest.java b/wicket-util/src/test/java/org/apache/wicket/util/crypt/UnlimitedStrengthJurisdictionPolicyTest.java index 0dfc711..f36e4b8 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/crypt/UnlimitedStrengthJurisdictionPolicyTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/crypt/UnlimitedStrengthJurisdictionPolicyTest.java @@ -16,12 +16,8 @@ */ package org.apache.wicket.util.crypt; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; - -import java.security.AlgorithmParameters; -import java.security.GeneralSecurityException; -import java.security.spec.KeySpec; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Test; import javax.crypto.Cipher; import javax.crypto.SecretKey; @@ -29,23 +25,24 @@ import javax.crypto.SecretKeyFactory; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.SecretKeySpec; +import java.security.AlgorithmParameters; +import java.security.GeneralSecurityException; +import java.security.spec.KeySpec; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * A demo how to create {@link org.apache.wicket.util.crypt.ICrypt} implementation that * uses <em>PBKDF2WithHmacSHA1</em> for encryption */ @SuppressWarnings("javadoc") -public class UnlimitedStrengthJurisdictionPolicyTest extends Assert +public class UnlimitedStrengthJurisdictionPolicyTest { @Test public void unlimitedStrengthJurisdictionEncryption() throws GeneralSecurityException { boolean unlimitedStrengthJurisdictionPolicyInstalled = SunJceCryptTest.isUnlimitedStrengthJurisdictionPolicyInstalled(); - Assume.assumeThat(unlimitedStrengthJurisdictionPolicyInstalled, is(true)); + Assumptions.assumeTrue(unlimitedStrengthJurisdictionPolicyInstalled); AbstractCrypt crypt = new UnlimitedStrenghtJurisdictionPolicyCrypt(); @@ -56,10 +53,10 @@ public class UnlimitedStrengthJurisdictionPolicyTest extends Assert byte[] encrypted2 = crypt.crypt(input2.getBytes(), Cipher.ENCRYPT_MODE); byte[] decrypted = crypt.crypt(encrypted, Cipher.DECRYPT_MODE); - assertThat(new String(decrypted), is(equalTo(input1))); + assertEquals(new String(decrypted), input1); byte[] decrypted2 = crypt.crypt(encrypted2, Cipher.DECRYPT_MODE); - assertThat(new String(decrypted2), is(equalTo(input2))); + assertEquals(new String(decrypted2),input2); } /** http://git-wip-us.apache.org/repos/asf/wicket/blob/978ea5cb/wicket-util/src/test/java/org/apache/wicket/util/encoding/UrlDecoderTest.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/test/java/org/apache/wicket/util/encoding/UrlDecoderTest.java b/wicket-util/src/test/java/org/apache/wicket/util/encoding/UrlDecoderTest.java index 9b01915..2db3f52 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/encoding/UrlDecoderTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/encoding/UrlDecoderTest.java @@ -16,9 +16,9 @@ */ package org.apache.wicket.util.encoding; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; @SuppressWarnings("javadoc") public class UrlDecoderTest
