diff --git a/extensions/quarkus/showcase/pom.xml b/extensions/quarkus/showcase/pom.xml index 30df4ae7ac..c1b38c2648 100644 --- a/extensions/quarkus/showcase/pom.xml +++ b/extensions/quarkus/showcase/pom.xml @@ -30,8 +30,8 @@ Apache MyFaces Core 5.0 - Extensions - Quarkus - Showcase - 3.2.5 - 3.2.5 + 3.6.1 + 3.6.1 UTF-8 17 diff --git a/extensions/quarkus/showcase/src/test/java/org/apache/myfaces/core/extensions/quarkus/showcase/QuarkusMyFacesShowcaseTest.java b/extensions/quarkus/showcase/src/test/java/org/apache/myfaces/core/extensions/quarkus/showcase/QuarkusMyFacesShowcaseTest.java index 86b871165f..d53a5b7bde 100644 --- a/extensions/quarkus/showcase/src/test/java/org/apache/myfaces/core/extensions/quarkus/showcase/QuarkusMyFacesShowcaseTest.java +++ b/extensions/quarkus/showcase/src/test/java/org/apache/myfaces/core/extensions/quarkus/showcase/QuarkusMyFacesShowcaseTest.java @@ -34,7 +34,6 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import java.io.IOException; import java.net.URL; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; @@ -49,7 +48,7 @@ public class QuarkusMyFacesShowcaseTest private static WebClient webClient; @BeforeAll - public static void initWebClient() + static void initWebClient() { webClient = new WebClient(BrowserVersion.CHROME); webClient.getOptions().setJavaScriptEnabled(true); @@ -61,7 +60,7 @@ public static void initWebClient() } @AfterAll - public static void closeWebClient() + static void closeWebClient() { if (webClient != null) { @@ -71,7 +70,7 @@ public static void closeWebClient() @Test - public void shouldOpenIndexPage() throws Exception + void shouldOpenIndexPage() throws Exception { final HtmlPage page = webClient.getPage(url + "/index.xhtml"); final HtmlDivision datatable = (HtmlDivision) page.getElementById("form:carTable"); @@ -81,7 +80,7 @@ public void shouldOpenIndexPage() throws Exception } @Test - public void shouldObserveEvents() throws Exception + void shouldObserveEvents() throws Exception { final HtmlPage page = webClient.getPage(url + "/index.xhtml"); final HtmlInput called = (HtmlInput) page.getElementById("called"); @@ -92,7 +91,7 @@ public void shouldObserveEvents() throws Exception } @Test - public void shouldMapExtensionlessSubFolderView() throws Exception + void shouldMapExtensionlessSubFolderView() throws Exception { // MYFACES-4729: AUTOMATIC_EXTENSIONLESS_MAPPING must also register views in sub-folders final HtmlPage page = webClient.getPage(url + "/test/subFolder/bar"); @@ -109,7 +108,7 @@ public void shouldMapExtensionlessSubFolderView() throws Exception @Test @Disabled("Check HtmlUnit websocket support, for now this test is not working") - public void shouldCallWebSocket() throws IOException + void shouldCallWebSocket() throws Exception { HtmlPage page = webClient.getPage(url + "/socket.xhtml"); final HtmlSubmitInput sendMessageBtn = (HtmlSubmitInput) page.getElementById("form:sendMessage"); diff --git a/impl/src/test/java/jakarta/faces/FacesExceptionTest.java b/impl/src/test/java/jakarta/faces/FacesExceptionTest.java index fce2e6c3bd..620bfe0ad9 100644 --- a/impl/src/test/java/jakarta/faces/FacesExceptionTest.java +++ b/impl/src/test/java/jakarta/faces/FacesExceptionTest.java @@ -19,8 +19,10 @@ package jakarta.faces; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -32,12 +34,12 @@ public FacesExceptionTest() } @BeforeEach - public void setUp() throws Exception + void setUp() throws Exception { } @AfterEach - public void tearDown() throws Exception + void tearDown() throws Exception { } @@ -45,53 +47,53 @@ public void tearDown() throws Exception * Test method for 'jakarta.faces.FacesException.FacesException()' */ @Test - public void testFacesException() + void facesException() { FacesException e = new FacesException(); - Assertions.assertNull(e.getCause()); - Assertions.assertNull(e.getMessage()); + assertNull(e.getCause()); + assertNull(e.getMessage()); } /* * Test method for 'jakarta.faces.FacesException.FacesException(Throwable)' */ @Test - public void testFacesExceptionThrowable() + void facesExceptionThrowable() { Throwable t = new Throwable(); FacesException fe = new FacesException(t); - Assertions.assertEquals(t, fe.getCause()); + assertEquals(t, fe.getCause()); } /* * Test method for 'jakarta.faces.FacesException.FacesException(String)' */ @Test - public void testFacesExceptionString() + void facesExceptionString() { String m = "Message"; FacesException e = new FacesException(m); - Assertions.assertEquals(e.getMessage(), m); + assertEquals(e.getMessage(), m); } /* * Test method for 'jakarta.faces.FacesException.FacesException(String, Throwable)' */ @Test - public void testFacesExceptionStringThrowable() + void facesExceptionStringThrowable() { String m = "Message"; Throwable t = new Throwable(); FacesException fe = new FacesException(m, t); - Assertions.assertEquals(t, fe.getCause()); - Assertions.assertEquals(fe.getMessage(), m); + assertEquals(t, fe.getCause()); + assertEquals(fe.getMessage(), m); } /* * Test method for 'jakarta.faces.FacesException.getCause()' */ @Test - public void testGetCause() + void getCause() { } diff --git a/impl/src/test/java/jakarta/faces/FactoryFinderTest.java b/impl/src/test/java/jakarta/faces/FactoryFinderTest.java index dcfbe69558..f7489f2c97 100644 --- a/impl/src/test/java/jakarta/faces/FactoryFinderTest.java +++ b/impl/src/test/java/jakarta/faces/FactoryFinderTest.java @@ -19,6 +19,8 @@ package jakarta.faces; +import static org.junit.jupiter.api.Assertions.*; + import java.lang.reflect.Field; import java.util.List; import java.util.Map; @@ -37,7 +39,7 @@ public FactoryFinderTest() } @BeforeEach - public void setUp() throws Exception + void setUp() throws Exception { // this needs to be called *before* the first Test test is run, // as there may be left over FactoryFinder configurations from @@ -46,7 +48,7 @@ public void setUp() throws Exception } @AfterEach - public void tearDown() throws Exception + void tearDown() throws Exception { // call this again so there is no possibility of messing up tests that will // run after this one @@ -103,53 +105,43 @@ private Map>> getRegisteredFactoryNames() * Test method for 'jakarta.faces.FactoryFinder.getFactory(String)' */ @Test - public void testGetFactory() throws Exception + void getFactory() throws Exception { // no catch because if this fails the test fails, i.e. not trying to test // setFactory here FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory.class.getName()); - try - { + Assertions.assertDoesNotThrow(() -> { Object factory = FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY); - Assertions.assertNotNull(factory); - Assertions.assertTrue(factory.getClass().equals(MockApplicationFactory.class)); - } - catch (IllegalStateException e) - { - Assertions.fail("Should not throw an illegal state exception"); - } + assertNotNull(factory); + assertEquals(MockApplicationFactory.class, factory.getClass()); + }, "Should not throw an illegal state exception"); } /* * Test method for 'jakarta.faces.FactoryFinder.getFactory(String)' */ @Test - public void testGetFactoryTwice() throws Exception + void getFactoryTwice() throws Exception { // this test just makes sure that things work when the get has been called // more than once FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory.class.getName()); - try - { + Assertions.assertDoesNotThrow(() -> { Object factory1 = FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY); - Assertions.assertNotNull(factory1); - Assertions.assertTrue(factory1.getClass().equals(MockApplicationFactory.class)); + assertNotNull(factory1); + assertEquals(MockApplicationFactory.class, factory1.getClass()); Object factory2 = FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY); - Assertions.assertNotNull(factory2); - Assertions.assertTrue(factory2.getClass().equals(MockApplicationFactory.class)); - Assertions.assertEquals(factory1, factory2); - } - catch (IllegalStateException e) - { - Assertions.fail("Should not throw an illegal state exception"); - } + assertNotNull(factory2); + assertEquals(MockApplicationFactory.class, factory2.getClass()); + assertEquals(factory1, factory2); + }, "Should not throw an illegal state exception"); } /* * Test method for 'jakarta.faces.FactoryFinder.getFactory(String)' */ @Test - public void testGetFactoryNoFactory() throws Exception + void getFactoryNoFactory() throws Exception { // no catch because if this fails the test fails, i.e. not trying to test // setFactory here @@ -157,11 +149,11 @@ public void testGetFactoryNoFactory() throws Exception try { FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); - Assertions.fail("Should have thrown an illegal state exception"); + fail("Should have thrown an illegal state exception"); } catch (IllegalArgumentException e) { - Assertions.assertNotNull(e.getMessage()); + assertNotNull(e.getMessage()); } } @@ -170,17 +162,17 @@ public void testGetFactoryNoFactory() throws Exception * 'jakarta.faces.FactoryFinder.getFactory(String)' */ @Test - public void testGetFactoryNoConfiguration() throws Exception + void getFactoryNoConfiguration() throws Exception { try { FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY); - Assertions.fail("Should have thrown an illegal state exception"); + fail("Should have thrown an illegal state exception"); } catch (IllegalStateException e) { - Assertions.assertNotNull(e.getMessage()); - Assertions.assertTrue(e.getMessage().startsWith("No Factories configured for this Application")); + assertNotNull(e.getMessage()); + assertTrue(e.getMessage().startsWith("No Factories configured for this Application")); } } @@ -188,16 +180,16 @@ public void testGetFactoryNoConfiguration() throws Exception * Bogus factory name test Test method for 'jakarta.faces.FactoryFinder.setFactory(String, String)' */ @Test - public void testSetFactoryBogusName() + void setFactoryBogusName() { try { FactoryFinder.setFactory("BogusFactoryName", MockApplicationFactory.class.getName()); - Assertions.fail("Should have thrown an illegal argument exception"); + fail("Should have thrown an illegal argument exception"); } catch (IllegalArgumentException e) { - Assertions.assertNotNull(e.getMessage()); + assertNotNull(e.getMessage()); } } @@ -205,18 +197,13 @@ public void testSetFactoryBogusName() * Test method for 'jakarta.faces.FactoryFinder.setFactory(String, String)' */ @Test - public void testSetFactory() throws Exception + void setFactory() throws Exception { - try - { + Assertions.assertDoesNotThrow(() -> { FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory.class.getName()); - Assertions.assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( - MockApplicationFactory.class.getName())); - } - catch (IllegalArgumentException e) - { - Assertions.fail("Should not throw an illegal argument exception"); - } + assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( + MockApplicationFactory.class.getName())); + }, "Should not throw an illegal argument exception"); } /* @@ -224,29 +211,24 @@ public void testSetFactory() throws Exception * checks to see if that is true. Test method for 'jakarta.faces.FactoryFinder.setFactory(String, String)' */ @Test - public void testSetFactoryNoEffect() throws Exception + void setFactoryNoEffect() throws Exception { - try - { + Assertions.assertDoesNotThrow(() -> { FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory.class.getName()); - Assertions.assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( - MockApplicationFactory.class.getName())); - Assertions.assertFalse(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( + assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( + MockApplicationFactory.class.getName())); + assertFalse(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( MockApplicationFactory2.class.getName())); // getFactory should cause setFactory to stop changing the // registered classes FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY); // this should essentially be a no-op FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory2.class.getName()); - Assertions.assertFalse(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( + assertFalse(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( MockApplicationFactory2.class.getName())); - Assertions.assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( - MockApplicationFactory.class.getName())); - } - catch (IllegalArgumentException e) - { - Assertions.fail("Should not throw an illegal argument exception"); - } + assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( + MockApplicationFactory.class.getName())); + }, "Should not throw an illegal argument exception"); } /* @@ -254,32 +236,27 @@ public void testSetFactoryNoEffect() throws Exception * 'jakarta.faces.FactoryFinder.setFactory(String, String)' */ @Test - public void testSetFactoryAdditiveClassNames() throws Exception + void setFactoryAdditiveClassNames() throws Exception { - try - { + Assertions.assertDoesNotThrow(() -> { FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory.class.getName()); - Assertions.assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( - MockApplicationFactory.class.getName())); - Assertions.assertFalse(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( + assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( + MockApplicationFactory.class.getName())); + assertFalse(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( MockApplicationFactory2.class.getName())); FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory2.class.getName()); - Assertions.assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( + assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( MockApplicationFactory2.class.getName())); - Assertions.assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( - MockApplicationFactory.class.getName())); - } - catch (IllegalArgumentException e) - { - Assertions.fail("Should not throw an illegal argument exception"); - } + assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains( + MockApplicationFactory.class.getName())); + }, "Should not throw an illegal argument exception"); } /* * Test method for 'jakarta.faces.FactoryFinder.releaseFactories()' */ @Test - public void testReleaseFactories() + void releaseFactories() { } diff --git a/impl/src/test/java/jakarta/faces/application/FacesMessageTest.java b/impl/src/test/java/jakarta/faces/application/FacesMessageTest.java index 931e5aeaab..c2b404fde4 100644 --- a/impl/src/test/java/jakarta/faces/application/FacesMessageTest.java +++ b/impl/src/test/java/jakarta/faces/application/FacesMessageTest.java @@ -20,82 +20,85 @@ package jakarta.faces.application; import jakarta.faces.application.FacesMessage.Severity; + import java.io.ByteArrayInputStream; + +import static org.junit.jupiter.api.Assertions.*; + import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.Map; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class FacesMessageTest +class FacesMessageTest { /* * Test method for 'jakarta.faces.application.FacesMessage.FacesMessage()' */ @Test - public void testFacesMessage() + void facesMessage() { FacesMessage msg = new FacesMessage(); - Assertions.assertEquals(msg.getSeverity(), Severity.INFO); - Assertions.assertNull(msg.getSummary()); - Assertions.assertNull(msg.getDetail()); + assertEquals(Severity.INFO, msg.getSeverity()); + assertNull(msg.getSummary()); + assertNull(msg.getDetail()); } /* * Test method for 'jakarta.faces.application.FacesMessage.FacesMessage(String)' */ @Test - public void testFacesMessageString() + void facesMessageString() { String summary = "summary"; FacesMessage msg = new FacesMessage(summary); - Assertions.assertEquals(msg.getSeverity(), Severity.INFO); - Assertions.assertEquals(msg.getSummary(), summary); - Assertions.assertEquals(msg.getDetail(), summary); + assertEquals(Severity.INFO, msg.getSeverity()); + assertEquals(msg.getSummary(), summary); + assertEquals(msg.getDetail(), summary); } /* * Test method for 'jakarta.faces.application.FacesMessage.FacesMessage(String, String)' */ @Test - public void testFacesMessageStringString() + void facesMessageStringString() { String summary = "summary"; String detail = "detail"; FacesMessage msg = new FacesMessage(summary, detail); - Assertions.assertEquals(msg.getSeverity(), Severity.INFO); - Assertions.assertEquals(msg.getSummary(), summary); - Assertions.assertEquals(msg.getDetail(), detail); + assertEquals(Severity.INFO, msg.getSeverity()); + assertEquals(msg.getSummary(), summary); + assertEquals(msg.getDetail(), detail); } /* * Test method for 'jakarta.faces.application.FacesMessage.FacesMessage(Severity, String, String)' */ @Test - public void testFacesMessageSeverityStringString() + void facesMessageSeverityStringString() { String summary = "summary"; String detail = "detail"; FacesMessage msg = new FacesMessage(Severity.ERROR, summary, detail); - Assertions.assertEquals(msg.getSeverity(), Severity.ERROR); - Assertions.assertEquals(msg.getSummary(), summary); - Assertions.assertEquals(msg.getDetail(), detail); + assertEquals(Severity.ERROR, msg.getSeverity()); + assertEquals(msg.getSummary(), summary); + assertEquals(msg.getDetail(), detail); } /* * Test method for 'jakarta.faces.application.FacesMessage.FacesMessage(Severity, String, String)' */ @Test - public void testFacesMessageNullSeverityStringString() + void facesMessageNullSeverityStringString() { String summary = "summary"; String detail = "detail"; try { new FacesMessage(null, summary, detail); - Assertions.fail("Should have thrown an exception"); + fail("Should have thrown an exception"); } catch (NullPointerException e) { @@ -106,25 +109,25 @@ public void testFacesMessageNullSeverityStringString() * Test method for 'jakarta.faces.application.FacesMessage.setSeverity(Severity)' */ @Test - public void testSetSeverity() + void setSeverity() { FacesMessage msg = new FacesMessage(); - Assertions.assertEquals(msg.getSeverity(), Severity.INFO); + assertEquals(Severity.INFO, msg.getSeverity()); msg.setSeverity(Severity.FATAL); - Assertions.assertEquals(msg.getSeverity(), Severity.FATAL); + assertEquals(Severity.FATAL, msg.getSeverity()); } /* * Test method for 'jakarta.faces.application.FacesMessage.setSeverity(Severity)' */ @Test - public void testSetNullSeverity() + void setNullSeverity() { FacesMessage msg = new FacesMessage(); try { msg.setSeverity(null); - Assertions.fail("Should have thrown an exception"); + fail("Should have thrown an exception"); } catch (NullPointerException e) { @@ -135,86 +138,86 @@ public void testSetNullSeverity() * Test method for 'jakarta.faces.application.FacesMessage.setSummary(String)' */ @Test - public void testSetSummary() + void setSummary() { FacesMessage msg = new FacesMessage(); String summary = "summary"; msg.setSummary(summary); - Assertions.assertEquals(msg.getSummary(), summary); - Assertions.assertEquals(msg.getDetail(), summary); + assertEquals(msg.getSummary(), summary); + assertEquals(msg.getDetail(), summary); } /* * Test method for 'jakarta.faces.application.FacesMessage.setDetail(String)' */ @Test - public void testSetDetail() + void setDetail() { FacesMessage msg = new FacesMessage(); String detail = "detail"; msg.setDetail(detail); - Assertions.assertEquals(msg.getSummary(), null); - Assertions.assertEquals(msg.getDetail(), detail); + assertNull(msg.getSummary()); + assertEquals(msg.getDetail(), detail); } @Test - public void testSeverityOrdering() + void severityOrdering() { // make sure they are ordered correctly from least to worst - Assertions.assertTrue(0 > Severity.INFO.compareTo(Severity.WARN)); - Assertions.assertTrue(0 > Severity.WARN.compareTo(Severity.ERROR)); - Assertions.assertTrue(0 > Severity.ERROR.compareTo(Severity.FATAL)); + assertTrue(0 > Severity.INFO.compareTo(Severity.WARN)); + assertTrue(0 > Severity.WARN.compareTo(Severity.ERROR)); + assertTrue(0 > Severity.ERROR.compareTo(Severity.FATAL)); // make sure they are ordered correctly from worts to least - Assertions.assertTrue(0 < Severity.FATAL.compareTo(Severity.ERROR)); - Assertions.assertTrue(0 < Severity.ERROR.compareTo(Severity.WARN)); - Assertions.assertTrue(0 < Severity.WARN.compareTo(Severity.INFO)); + assertTrue(0 < Severity.FATAL.compareTo(Severity.ERROR)); + assertTrue(0 < Severity.ERROR.compareTo(Severity.WARN)); + assertTrue(0 < Severity.WARN.compareTo(Severity.INFO)); } @Test - public void testSeverityEquality() + void severityEquality() { // make sure they all respond as equals when they should - Assertions.assertEquals(0, Severity.INFO.compareTo(Severity.INFO)); - Assertions.assertEquals(0, Severity.WARN.compareTo(Severity.WARN)); - Assertions.assertEquals(0, Severity.ERROR.compareTo(Severity.ERROR)); - Assertions.assertEquals(0, Severity.FATAL.compareTo(Severity.FATAL)); + assertEquals(0, Severity.INFO.compareTo(Severity.INFO)); + assertEquals(0, Severity.WARN.compareTo(Severity.WARN)); + assertEquals(0, Severity.ERROR.compareTo(Severity.ERROR)); + assertEquals(0, Severity.FATAL.compareTo(Severity.FATAL)); } @Test - public void testSeverityValues() + void severityValues() { // Faces spec requires this list to be sorted by ordinal for (int i = 0, sz = FacesMessage.VALUES.size(); i < sz; i++) { FacesMessage.Severity severity = (Severity) FacesMessage.VALUES.get(i); - Assertions.assertEquals(i, severity.ordinal()); + assertEquals(i, severity.ordinal()); } } @SuppressWarnings("unchecked") @Test - public void testSeverityValuesMap() + void severityValuesMap() { Map severityMap = (Map) FacesMessage.VALUES_MAP; for (Map.Entry e : severityMap.entrySet()) { - Assertions.assertEquals(e.getKey(), e.getValue().toString()); + assertEquals(e.getKey(), e.getValue().toString()); } } @Test - public void testSerialization() throws Exception + void serialization() throws Exception { String summary = "summary"; String detail = "detail"; FacesMessage msg = new FacesMessage(summary, detail); // check if properties are set correctly - Assertions.assertEquals(msg.getSeverity(), Severity.INFO); - Assertions.assertEquals(msg.getSummary(), summary); - Assertions.assertEquals(msg.getDetail(), detail); - Assertions.assertEquals(msg.isRendered(), false); + assertEquals(Severity.INFO, msg.getSeverity()); + assertEquals(msg.getSummary(), summary); + assertEquals(msg.getDetail(), detail); + assertEquals(false, msg.isRendered()); // serialize instance ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -227,10 +230,10 @@ public void testSerialization() throws Exception FacesMessage deserialized = (FacesMessage) in.readObject(); // FacesMessage properties must equal! - Assertions.assertSame(msg.getSeverity(), deserialized.getSeverity()); - Assertions.assertEquals(msg.getSummary(), deserialized.getSummary()); - Assertions.assertEquals(msg.getDetail(), deserialized.getDetail()); - Assertions.assertEquals(msg.isRendered(), deserialized.isRendered()); + assertSame(msg.getSeverity(), deserialized.getSeverity()); + assertEquals(msg.getSummary(), deserialized.getSummary()); + assertEquals(msg.getDetail(), deserialized.getDetail()); + assertEquals(msg.isRendered(), deserialized.isRendered()); } } diff --git a/impl/src/test/java/jakarta/faces/application/StateManagerTest.java b/impl/src/test/java/jakarta/faces/application/StateManagerTest.java index 35c2b3af4a..29ba4dd14e 100644 --- a/impl/src/test/java/jakarta/faces/application/StateManagerTest.java +++ b/impl/src/test/java/jakarta/faces/application/StateManagerTest.java @@ -19,26 +19,27 @@ package jakarta.faces.application; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; import org.apache.myfaces.test.mock.MockStateManager; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -public class StateManagerTest +class StateManagerTest { /* * Test method for 'jakarta.faces.application.StateManager.isSavingStateInClient(FacesContext)' */ @Test - public void testNullThrowsIsSavingStateInClient() + void nullThrowsIsSavingStateInClient() { MockStateManager subject = new MockStateManager(); try { subject.isSavingStateInClient(null); - Assertions.fail("should have thrown an exception"); + fail("should have thrown an exception"); } catch (RuntimeException e) { @@ -49,7 +50,7 @@ public void testNullThrowsIsSavingStateInClient() * Test method for 'jakarta.faces.application.StateManager.isSavingStateInClient(FacesContext)' */ @Test - public void testIsSavingStateInClientTrue() + void isSavingStateInClientTrue() { FacesContext context = Mockito.spy(FacesContext.class); ExternalContext external = Mockito.spy(ExternalContext.class); @@ -59,14 +60,14 @@ public void testIsSavingStateInClientTrue() .thenReturn("client"); MockStateManager subject = new MockStateManager(); - Assertions.assertEquals(true, subject.isSavingStateInClient(context)); + assertTrue(subject.isSavingStateInClient(context)); } /* * Test method for 'jakarta.faces.application.StateManager.isSavingStateInClient(FacesContext)' */ @Test - public void testIsSavingStateInClientFalse() + void isSavingStateInClientFalse() { FacesContext context = Mockito.spy(FacesContext.class); ExternalContext external = Mockito.spy(ExternalContext.class); @@ -76,14 +77,14 @@ public void testIsSavingStateInClientFalse() .thenReturn("server"); MockStateManager subject = new MockStateManager(); - Assertions.assertEquals(false, subject.isSavingStateInClient(context)); + assertFalse(subject.isSavingStateInClient(context)); } /* * Test method for 'jakarta.faces.application.StateManager.isSavingStateInClient(FacesContext)' */ @Test - public void testIsSavingStateInClientBogus() + void isSavingStateInClientBogus() { FacesContext context = Mockito.spy(FacesContext.class); ExternalContext external = Mockito.spy(ExternalContext.class); @@ -93,7 +94,7 @@ public void testIsSavingStateInClientBogus() .thenReturn("blorf"); MockStateManager subject = new MockStateManager(); - Assertions.assertEquals(false, subject.isSavingStateInClient(context)); + assertFalse(subject.isSavingStateInClient(context)); Mockito.verify(external) .log("Illegal state saving method 'blorf', default server state saving will be used"); @@ -103,7 +104,7 @@ public void testIsSavingStateInClientBogus() * Test method for 'jakarta.faces.application.StateManager.isSavingStateInClient(FacesContext)' */ @Test - public void testIsSavingStateInClientNull() + void isSavingStateInClientNull() { FacesContext context = Mockito.spy(FacesContext.class); ExternalContext external = Mockito.spy(ExternalContext.class); @@ -113,7 +114,7 @@ public void testIsSavingStateInClientNull() .thenReturn(null); MockStateManager subject = new MockStateManager(); - Assertions.assertEquals(false, subject.isSavingStateInClient(context)); + assertFalse(subject.isSavingStateInClient(context)); Mockito.verify(external) .log("No state saving method defined, assuming default server state saving"); diff --git a/impl/src/test/java/jakarta/faces/application/ViewHandlerTest.java b/impl/src/test/java/jakarta/faces/application/ViewHandlerTest.java index cf4d9a4d62..fe57302dcb 100644 --- a/impl/src/test/java/jakarta/faces/application/ViewHandlerTest.java +++ b/impl/src/test/java/jakarta/faces/application/ViewHandlerTest.java @@ -19,6 +19,7 @@ package jakarta.faces.application; import static org.easymock.EasyMock.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -35,11 +36,10 @@ import org.apache.myfaces.test.mock.MockFacesContext; import org.easymock.classextension.EasyMock; import org.easymock.classextension.IMocksControl; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class ViewHandlerTest +class ViewHandlerTest { private MockFacesContext _facesContext; private IMocksControl _mocksControl; @@ -47,7 +47,7 @@ public class ViewHandlerTest private TestViewHandler _testimpl; @BeforeEach - public void setUp() throws Exception + void setUp() throws Exception { _mocksControl = EasyMock.createControl(); _externalContext = _mocksControl.createMock(ExternalContext.class); @@ -61,13 +61,13 @@ public void setUp() throws Exception */ @SuppressWarnings("unchecked") @Test - public void testCalculateCharacterEncodingWithRequestHeaderContentType() + void calculateCharacterEncodingWithRequestHeaderContentType() { Map map = _mocksControl.createMock(Map.class); expect(_externalContext.getRequestHeaderMap()).andReturn(map); expect(map.get(eq("Content-Type"))).andReturn("text/html;charset=UTF-8"); _mocksControl.replay(); - Assertions.assertEquals("UTF-8", _testimpl.calculateCharacterEncoding(_facesContext)); + assertEquals("UTF-8", _testimpl.calculateCharacterEncoding(_facesContext)); _mocksControl.verify(); } @@ -76,14 +76,14 @@ public void testCalculateCharacterEncodingWithRequestHeaderContentType() * {@link jakarta.faces.application.ViewHandler#calculateCharacterEncoding(jakarta.faces.context.FacesContext)}. */ @Test - public void testCalculateCharacterEncodingWithNoRequestContentTypeAndNoSession() + void calculateCharacterEncodingWithNoRequestContentTypeAndNoSession() { Map emptyMap = Collections.emptyMap(); expect(_externalContext.getRequestHeaderMap()).andReturn(emptyMap); expect(_externalContext.getSession(eq(false))).andReturn(null); _mocksControl.replay(); - Assertions.assertNull(_testimpl.calculateCharacterEncoding(_facesContext)); + assertNull(_testimpl.calculateCharacterEncoding(_facesContext)); _mocksControl.verify(); } @@ -93,7 +93,7 @@ public void testCalculateCharacterEncodingWithNoRequestContentTypeAndNoSession() */ @Test @SuppressWarnings("unchecked") - public void testCalculateCharacterEncodingWithNoRequestContentTypeAndWithSessionButNoSessionValue() + void calculateCharacterEncodingWithNoRequestContentTypeAndWithSessionButNoSessionValue() { Map emptyMap = Collections.emptyMap(); @@ -103,7 +103,7 @@ public void testCalculateCharacterEncodingWithNoRequestContentTypeAndWithSession expect(_externalContext.getSessionMap()).andReturn(map); expect(map.get(eq(ViewHandler.CHARACTER_ENCODING_KEY))).andReturn(null); _mocksControl.replay(); - Assertions.assertNull(_testimpl.calculateCharacterEncoding(_facesContext)); + assertNull(_testimpl.calculateCharacterEncoding(_facesContext)); _mocksControl.verify(); } @@ -113,7 +113,7 @@ public void testCalculateCharacterEncodingWithNoRequestContentTypeAndWithSession */ @Test @SuppressWarnings("unchecked") - public void testCalculateCharacterEncodingWithNoRequestContentTypeAndWithSessionAndNoSessionValue() + void calculateCharacterEncodingWithNoRequestContentTypeAndWithSessionAndNoSessionValue() { Map emptyMap = Collections.emptyMap(); @@ -123,7 +123,7 @@ public void testCalculateCharacterEncodingWithNoRequestContentTypeAndWithSession expect(_externalContext.getSessionMap()).andReturn(map); expect(map.get(eq(ViewHandler.CHARACTER_ENCODING_KEY))).andReturn("UTF-8"); _mocksControl.replay(); - Assertions.assertEquals("UTF-8", _testimpl.calculateCharacterEncoding(_facesContext)); + assertEquals("UTF-8", _testimpl.calculateCharacterEncoding(_facesContext)); _mocksControl.verify(); } @@ -133,7 +133,7 @@ public void testCalculateCharacterEncodingWithNoRequestContentTypeAndWithSession * @throws Exception */ @Test - public void testInitView() throws Exception + void initView() throws Exception { ViewHandler handler = _mocksControl .createMock( @@ -155,7 +155,7 @@ public void testInitView() throws Exception * @throws Exception */ @Test - public void testInitViewWithUnsupportedEncodingException() throws Exception + void initViewWithUnsupportedEncodingException() throws Exception { final ViewHandler handler = _mocksControl .createMock( @@ -168,7 +168,7 @@ public void testInitViewWithUnsupportedEncodingException() throws Exception _externalContext.setRequestCharacterEncoding(eq("xxx")); expectLastCall().andThrow(new UnsupportedEncodingException()); _mocksControl.replay(); - Assertions.assertThrows(FacesException.class, + assertThrows(FacesException.class, () -> handler.initView(_facesContext)); _mocksControl.verify(); } diff --git a/impl/src/test/java/jakarta/faces/component/AbstractUIComponentPropertyTest.java b/impl/src/test/java/jakarta/faces/component/AbstractUIComponentPropertyTest.java index 1657ef838b..404f6096f8 100644 --- a/impl/src/test/java/jakarta/faces/component/AbstractUIComponentPropertyTest.java +++ b/impl/src/test/java/jakarta/faces/component/AbstractUIComponentPropertyTest.java @@ -23,6 +23,7 @@ import java.beans.PropertyDescriptor; import static org.easymock.EasyMock.eq; import static org.easymock.EasyMock.expect; +import static org.junit.jupiter.api.Assertions.assertEquals; import jakarta.el.ELContext; import jakarta.el.ValueExpression; @@ -31,7 +32,6 @@ import org.easymock.classextension.EasyMock; import org.easymock.classextension.IMocksControl; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -95,15 +95,15 @@ protected PropertyDescriptor getPropertyDescriptor(Class clazz, String proper } @Test - public void testDefaultValue() throws Exception + public void defaultValue() throws Exception { Object val = getPropertyDescriptor(_component.getClass(), _property).getReadMethod() .invoke(_component); - Assertions.assertEquals(_defaultValue, val); + assertEquals(_defaultValue, val); } @Test - public void testExplicitValue() throws Exception + public void explicitValue() throws Exception { for (T testValue : _testValues) { @@ -112,12 +112,12 @@ public void testExplicitValue() throws Exception Object val = getPropertyDescriptor(_component.getClass(), _property).getReadMethod() .invoke(_component); - Assertions.assertEquals(testValue, val); + assertEquals(testValue, val); } } @Test - public void testExpressionWithLiteralTextValue() throws Exception + public void expressionWithLiteralTextValue() throws Exception { for (T testValue : _testValues) { @@ -128,13 +128,13 @@ public void testExpressionWithLiteralTextValue() throws Exception Object val = getPropertyDescriptor(_component.getClass(), _property).getReadMethod() .invoke(_component); - Assertions.assertEquals(testValue, val); + assertEquals(testValue, val); _mocksControl.reset(); } } @Test - public void testExpressionValue() throws Exception + public void expressionValue() throws Exception { for (T testValue : _testValues) { @@ -147,7 +147,7 @@ public void testExpressionValue() throws Exception Object val = getPropertyDescriptor(_component.getClass(), _property).getReadMethod() .invoke(_component); - Assertions.assertEquals(testValue, val); + assertEquals(testValue, val); _mocksControl.reset(); } } diff --git a/impl/src/test/java/jakarta/faces/component/InvokeOnComponentTest.java b/impl/src/test/java/jakarta/faces/component/InvokeOnComponentTest.java index 93e57934aa..4628f5f098 100644 --- a/impl/src/test/java/jakarta/faces/component/InvokeOnComponentTest.java +++ b/impl/src/test/java/jakarta/faces/component/InvokeOnComponentTest.java @@ -18,6 +18,8 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -28,12 +30,11 @@ import org.apache.myfaces.dummy.data.Data; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -public class InvokeOnComponentTest extends AbstractComponentTest +class InvokeOnComponentTest extends AbstractComponentTest { ContextCallback cc = null; @@ -56,7 +57,7 @@ public void tearDown() throws Exception } @Test - public void testInvokeOnFormPrependId() throws Exception + void invokeOnFormPrependId() throws Exception { UIForm form = new UIForm(); form.setId("form"); @@ -69,11 +70,11 @@ public void testInvokeOnFormPrependId() throws Exception val.set(true); }); - Assertions.assertTrue(val.get()); + assertTrue(val.get()); } - + @Test - public void testInvokeOnFormPrependIdFalse() throws Exception + void invokeOnFormPrependIdFalse() throws Exception { UIForm form = new UIForm(); form.setId("form"); @@ -86,11 +87,11 @@ public void testInvokeOnFormPrependIdFalse() throws Exception val.set(true); }); - Assertions.assertTrue(val.get()); + assertTrue(val.get()); } - + @Test - public void testInvokeOnFormPrependIdChild() throws Exception + void invokeOnFormPrependIdChild() throws Exception { UIForm form = new UIForm(); form.setId("form"); @@ -108,11 +109,11 @@ public void testInvokeOnFormPrependIdChild() throws Exception val.set(true); }); - Assertions.assertTrue(val.get()); + assertTrue(val.get()); } - + @Test - public void testInvokeOnFormPrependIdFalseChild() throws Exception + void invokeOnFormPrependIdFalseChild() throws Exception { UIForm form = new UIForm(); form.setId("form"); @@ -130,11 +131,11 @@ public void testInvokeOnFormPrependIdFalseChild() throws Exception val.set(true); }); - Assertions.assertTrue(val.get()); + assertTrue(val.get()); } - + @Test - public void atestInvokeOnComp() throws Exception + void atestInvokeOnComp() throws Exception { UIForm form = new UIForm(); UIInput i1 = new UIInput(); @@ -160,7 +161,7 @@ public void atestInvokeOnComp() throws Exception } @Test - public void btestInvokeOnCompOnUIData() throws Exception + void btestInvokeOnCompOnUIData() throws Exception { // column1 UIColumn c1 = new UIColumn(); @@ -210,7 +211,7 @@ public void btestInvokeOnCompOnUIData() throws Exception } @Test - public void testInvokeOnCompOnUIDataChildren() throws Exception + void invokeOnCompOnUIDataChildren() throws Exception { // column1 UIColumn c1 = new UIColumn(); diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentAttributesTest.java b/impl/src/test/java/jakarta/faces/component/UIComponentAttributesTest.java index 5a81df2724..ff34c8aebd 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentAttributesTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentAttributesTest.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class UIComponentAttributesTest extends AbstractFacesTestCase +class UIComponentAttributesTest extends AbstractFacesTestCase { private HtmlInputText input; @@ -47,7 +47,7 @@ public void tearDown() throws Exception } @Test - public void testSetNullAttributeOnValidProperty() + void setNullAttributeOnValidProperty() { input.getAttributes().put("style", null); } diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentBaseFacesListenerTest.java b/impl/src/test/java/jakarta/faces/component/UIComponentBaseFacesListenerTest.java index 35a6d08804..ba2711e869 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentBaseFacesListenerTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentBaseFacesListenerTest.java @@ -18,6 +18,8 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.*; + import java.util.Arrays; import java.util.Collection; import java.util.Date; @@ -26,7 +28,6 @@ import jakarta.faces.event.FacesListener; import jakarta.faces.event.ValueChangeListener; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -65,55 +66,53 @@ public void tearDown() throws Exception } @Test - public void testArgNPE() throws Exception + void argNPE() throws Exception { - Assertions.assertThrows(NullPointerException.class, () -> { - _testImpl.getFacesListeners(null); - }); + assertThrows(NullPointerException.class, () -> + _testImpl.getFacesListeners(null)); } @Test - public void testEmptyListener() throws Exception + void emptyListener() throws Exception { FacesListener[] listener = _testImpl.getFacesListeners(ActionListener.class); - Assertions.assertNotNull(listener); - Assertions.assertEquals(0, listener.length); + assertNotNull(listener); + assertEquals(0, listener.length); } @Test - public void testGetFacesListeners() + void getFacesListeners() { _testImpl.addFacesListener(_actionListener); FacesListener[] listener = _testImpl.getFacesListeners(ValueChangeListener.class); - Assertions.assertNotNull(listener); - Assertions.assertEquals(0, listener.length); - Assertions.assertTrue(ValueChangeListener.class.equals(listener.getClass().getComponentType())); + assertNotNull(listener); + assertEquals(0, listener.length); + assertEquals(ValueChangeListener.class, listener.getClass().getComponentType()); _testImpl.addFacesListener(_valueChangeListener); listener = _testImpl.getFacesListeners(FacesListener.class); - Assertions.assertNotNull(listener); - Assertions.assertEquals(2, listener.length); + assertNotNull(listener); + assertEquals(2, listener.length); Collection col = Arrays.asList(listener); - Assertions.assertTrue(col.contains(_actionListener)); - Assertions.assertTrue(col.contains(_valueChangeListener)); + assertTrue(col.contains(_actionListener)); + assertTrue(col.contains(_valueChangeListener)); } @Test - public void testRemoveFacesListenerArgNPE() throws Exception + void removeFacesListenerArgNPE() throws Exception { - Assertions.assertThrows(NullPointerException.class, () -> { - _testImpl.removeFacesListener(null); - }); + assertThrows(NullPointerException.class, () -> + _testImpl.removeFacesListener(null)); } @Test - public void testRemoveFacesListener() throws Exception + void removeFacesListener() throws Exception { _testImpl.addFacesListener(_actionListener); - Assertions.assertEquals(_actionListener, _testImpl.getFacesListeners(FacesListener.class)[0]); + assertEquals(_actionListener, _testImpl.getFacesListeners(FacesListener.class)[0]); _testImpl.removeFacesListener(_actionListener); - Assertions.assertEquals(0, _testImpl.getFacesListeners(FacesListener.class).length); + assertEquals(0, _testImpl.getFacesListeners(FacesListener.class).length); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentBaseGetChildrenTest.java b/impl/src/test/java/jakarta/faces/component/UIComponentBaseGetChildrenTest.java index 8534d7b7e5..b21fb86001 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentBaseGetChildrenTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentBaseGetChildrenTest.java @@ -18,17 +18,18 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.*; + import java.util.ArrayList; import java.util.List; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class UIComponentBaseGetChildrenTest extends AbstractFacesTestCase +class UIComponentBaseGetChildrenTest extends AbstractFacesTestCase { @Test - public void testGetChildrenAddAll() + void getChildrenAddAll() { UIInput input0 = new UIInput(); UIInput input1 = new UIInput(); @@ -56,23 +57,23 @@ public void testGetChildrenAddAll() // inserted to the first ones children.addAll(0, list); - Assertions.assertEquals(4, children.size()); - Assertions.assertEquals(input2.getId(), children.get(0).getId()); - Assertions.assertEquals(input3.getId(), children.get(1).getId()); + assertEquals(4, children.size()); + assertEquals(input2.getId(), children.get(0).getId()); + assertEquals(input3.getId(), children.get(1).getId()); } - + @Test - public void testSimpleAddRemove() + void simpleAddRemove() { UIInput input = new UIInput(); input.setId("input0"); UIPanel panel = new UIPanel(); panel.getChildren().add(input); - Assertions.assertEquals(panel, input.getParent()); + assertEquals(panel, input.getParent()); panel.getChildren().remove(input); - Assertions.assertNull(input.getParent()); + assertNull(input.getParent()); } - + /** Whenever a new child component is added, the parent property * of the child must be set to this component instance. * If the parent property of the child was already non-null, @@ -80,7 +81,7 @@ public void testSimpleAddRemove() * (where it may have been either a child or a facet). */ @Test - public void testSetChild1() + void setChild1() { UIInput input = new UIInput(); input.setId("input0"); @@ -90,16 +91,16 @@ public void testSetChild1() UIPanel panel = new UIPanel(); panel.getChildren().add(input); - Assertions.assertEquals(panel, input.getParent()); + assertEquals(panel, input.getParent()); panel.getChildren().set(0, input1); - Assertions.assertEquals(panel, input1.getParent()); - Assertions.assertNull(input.getParent()); + assertEquals(panel, input1.getParent()); + assertNull(input.getParent()); } - + @Test - public void testSetChild2() + void setChild2() { UIInput input = new UIInput(); input.setId("input0"); @@ -109,7 +110,7 @@ public void testSetChild2() UIPanel panel = new UIPanel(); panel.getChildren().add(input); - Assertions.assertEquals(panel, input.getParent()); + assertEquals(panel, input.getParent()); UIViewRoot root = new UIViewRoot(); root.getChildren().add(panel); @@ -117,19 +118,18 @@ public void testSetChild2() panel.getChildren().set(0, input1); - Assertions.assertEquals(panel, input1.getParent()); - Assertions.assertNull(input.getParent()); + assertEquals(panel, input1.getParent()); + assertNull(input.getParent()); - Assertions.assertTrue(root.getFacets().isEmpty()); + assertTrue(root.getFacets().isEmpty()); } - - - + + /** Whenever an existing child component is removed, the parent * property of the child must be set to null. */ @Test - public void testSetFacetClearChild() + void setFacetClearChild() { UIInput input = new UIInput(); input.setId("input0"); @@ -139,22 +139,22 @@ public void testSetFacetClearChild() UIPanel panel = new UIPanel(); panel.getChildren().add(input); - Assertions.assertEquals(panel, input.getParent()); + assertEquals(panel, input.getParent()); UIViewRoot root = new UIViewRoot(); root.getChildren().add(panel); root.getFacets().put("customFacet", input1); root.getFacets().put("customFacet", input); - Assertions.assertEquals(root, input.getParent()); - Assertions.assertNull(input1.getParent()); + assertEquals(root, input.getParent()); + assertNull(input1.getParent()); - Assertions.assertFalse(root.getFacets().isEmpty()); - Assertions.assertTrue(panel.getChildCount() == 0); + assertFalse(root.getFacets().isEmpty()); + assertEquals(0, panel.getChildCount()); } @Test - public void testSetFacetClearFacet() + void setFacetClearFacet() { UIInput input = new UIInput(); input.setId("input0"); @@ -164,17 +164,17 @@ public void testSetFacetClearFacet() UIPanel panel = new UIPanel(); panel.getFacets().put("header", input); - Assertions.assertEquals(panel, input.getParent()); + assertEquals(panel, input.getParent()); UIViewRoot root = new UIViewRoot(); root.getChildren().add(panel); root.getFacets().put("customFacet", input1); root.getFacets().put("customFacet", input); - Assertions.assertEquals(root, input.getParent()); - Assertions.assertNull(input1.getParent()); + assertEquals(root, input.getParent()); + assertNull(input1.getParent()); - Assertions.assertFalse(root.getFacets().isEmpty()); - Assertions.assertTrue(panel.getChildCount() == 0); + assertFalse(root.getFacets().isEmpty()); + assertEquals(0, panel.getChildCount()); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentBaseGetClientIdTest.java b/impl/src/test/java/jakarta/faces/component/UIComponentBaseGetClientIdTest.java index be09c33255..a484adfc5a 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentBaseGetClientIdTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentBaseGetClientIdTest.java @@ -18,10 +18,11 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.faces.FacesException; import jakarta.faces.context.FacesContext; import jakarta.faces.render.Renderer; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -32,7 +33,7 @@ * Time: 01:42:55 * To change this template use File | Settings | File Templates. */ -public class UIComponentBaseGetClientIdTest extends AbstractComponentTest +class UIComponentBaseGetClientIdTest extends AbstractComponentTest { protected UIComponentBase _testImpl; @@ -45,12 +46,12 @@ public void setUp() throws Exception } @Test - public void testNullFacesContext() throws Exception + void nullFacesContext() throws Exception { try { _testImpl.getClientId(null); - Assertions.fail(); + fail(); } catch(NullPointerException e) { @@ -58,22 +59,22 @@ public void testNullFacesContext() throws Exception } catch(Exception e) { - Assertions.fail(); + fail(); } } @Test - public void testWithoutParentAndNoRenderer() throws Exception + void withoutParentAndNoRenderer() throws Exception { String expectedClientId = "testId"; _testImpl.setId(expectedClientId); - Assertions.assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); - Assertions.assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); + assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); + assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); } @Test - public void testWithRenderer() throws Exception + void withRenderer() throws Exception { String id = "testId"; final String expectedClientId = "convertedClientId"; @@ -91,12 +92,12 @@ public String convertClientId(FacesContext context, String clientId) } }; _testImpl.setId(id); - Assertions.assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); - Assertions.assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); + assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); + assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); } @Test - public void testWithParentNamingContainer() throws Exception + void withParentNamingContainer() throws Exception { String id = "testId"; String containerClientId = "containerClientId"; @@ -111,12 +112,12 @@ public void testWithParentNamingContainer() throws Exception parent.getChildren().add(_testImpl); _testImpl.setId(id); - Assertions.assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); - Assertions.assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); + assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); + assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); } @Test - public void testWithParentNamingContainerChanging() throws Exception + void withParentNamingContainerChanging() throws Exception { String id = "testId"; String containerClientId = "containerClientId"; @@ -142,29 +143,29 @@ public String getContainerClientId(FacesContext ctx) parent.setId("parent"); parent.getChildren().add(_testImpl); - Assertions.assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); - Assertions.assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); + assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); + assertEquals(expectedClientId, _testImpl.getClientId(facesContext)); parent.getChildren().remove(_testImpl); } } @Test - public void testWithoutId() throws Exception + void withoutId() throws Exception { UIViewRoot viewRoot = facesContext.getViewRoot(); - Assertions.assertNotNull(viewRoot.createUniqueId()); - Assertions.assertNotNull(_testImpl.getClientId()); - Assertions.assertNotNull(_testImpl.getId()); + assertNotNull(viewRoot.createUniqueId()); + assertNotNull(_testImpl.getClientId()); + assertNotNull(_testImpl.getId()); } @Test - public void testWithoutIdAndNoUIViewRoot() throws Exception + void withoutIdAndNoUIViewRoot() throws Exception { facesContext.setViewRoot(null); try { _testImpl.getClientId(facesContext); - Assertions.fail(); + fail(); } catch(FacesException e) { @@ -172,7 +173,7 @@ public void testWithoutIdAndNoUIViewRoot() throws Exception } catch(Exception e) { - Assertions.fail(); + fail(); } } } diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentBaseProcessSaveRestoreStateTest.java b/impl/src/test/java/jakarta/faces/component/UIComponentBaseProcessSaveRestoreStateTest.java index 305032871f..ebbfbba37c 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentBaseProcessSaveRestoreStateTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentBaseProcessSaveRestoreStateTest.java @@ -29,8 +29,9 @@ import org.easymock.EasyMock; import static org.easymock.EasyMock.*; +import static org.junit.jupiter.api.Assertions.assertThrows; + import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -41,7 +42,7 @@ * Time: 01:14:31 * To change this template use File | Settings | File Templates. */ -public class UIComponentBaseProcessSaveRestoreStateTest extends AbstractUIComponentBaseTest +class UIComponentBaseProcessSaveRestoreStateTest extends AbstractUIComponentBaseTest { private static final String CHILD_STATE = "childState"; private static final String TESTIMPL_STATE = "testimplState"; @@ -82,19 +83,17 @@ protected Collection getMockedMethods() throws Exception } @Test - public void testSaveStateExceptions() throws Exception + void saveStateExceptions() throws Exception { - Assertions.assertThrows(NullPointerException.class, () -> { - _testImpl.processSaveState(null); - }); + assertThrows(NullPointerException.class, () -> + _testImpl.processSaveState(null)); } @Test - public void testRestoreStateExceptions() throws Exception + void restoreStateExceptions() throws Exception { - Assertions.assertThrows(NullPointerException.class, () -> { - _testImpl.processRestoreState(null, null); - }); + assertThrows(NullPointerException.class, () -> + _testImpl.processRestoreState(null, null)); } // FIXME: Need to add some expectation for FacesContext.getAttributes. I'll have to read a bit more about diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentBaseRestoreCollectionTest.java b/impl/src/test/java/jakarta/faces/component/UIComponentBaseRestoreCollectionTest.java index a234a220ed..7143b3017a 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentBaseRestoreCollectionTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentBaseRestoreCollectionTest.java @@ -18,6 +18,8 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.*; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.NotSerializableException; @@ -39,7 +41,6 @@ import jakarta.faces.event.PhaseId; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -52,7 +53,7 @@ * Each case is restored without serialization, as with server side state saving, and after serialization, as with * client side state saving. */ -public class UIComponentBaseRestoreCollectionTest extends AbstractFacesTestCase +class UIComponentBaseRestoreCollectionTest extends AbstractFacesTestCase { @Override @BeforeEach @@ -63,61 +64,61 @@ public void setUp() throws Exception } @Test - public void testListOf() throws Exception + void listOf() throws Exception { assertRestoredWithExactType(List.of("b", "a", "b")); } @Test - public void testListCopyOf() throws Exception + void listCopyOf() throws Exception { assertRestoredWithExactType(List.copyOf(Arrays.asList("b", "a", "b"))); } @Test - public void testArraysAsList() throws Exception + void arraysAsList() throws Exception { assertRestoredWithExactType(Arrays.asList("b", "a", "b")); } @Test - public void testUnmodifiableList() throws Exception + void unmodifiableList() throws Exception { assertRestoredWithExactType(Collections.unmodifiableList(new LinkedList<>(List.of("b", "a", "b")))); } @Test - public void testSingletonList() throws Exception + void singletonList() throws Exception { assertRestoredWithExactType(Collections.singletonList("b")); } @Test - public void testEmptyList() throws Exception + void emptyList() throws Exception { assertRestoredWithExactType(Collections.emptyList()); } @Test - public void testSetOf() throws Exception + void setOf() throws Exception { assertRestoredWithExactType(Set.of("a", "b", "c")); } @Test - public void testUnmodifiableSetKeepsOrder() throws Exception + void unmodifiableSetKeepsOrder() throws Exception { Set set = Collections.unmodifiableSet(new LinkedHashSet<>(List.of("c", "a", "b"))); assertSavedWhole(set); for (Object restored : restore(set)) { - Assertions.assertEquals(set.getClass(), restored.getClass()); - Assertions.assertEquals(List.of("c", "a", "b"), List.copyOf((Set) restored)); + assertEquals(set.getClass(), restored.getClass()); + assertEquals(List.of("c", "a", "b"), List.copyOf((Set) restored)); } } @Test - public void testQueueWithoutNoArgConstructor() throws Exception + void queueWithoutNoArgConstructor() throws Exception { Collection queue = Collections.asLifoQueue(new ArrayDeque<>()); queue.add("a"); @@ -125,8 +126,8 @@ public void testQueueWithoutNoArgConstructor() throws Exception assertSavedWhole(queue); for (Object restored : restore(queue)) { - Assertions.assertEquals(queue.getClass(), restored.getClass()); - Assertions.assertEquals(List.copyOf(queue), List.copyOf((Collection) restored)); + assertEquals(queue.getClass(), restored.getClass()); + assertEquals(List.copyOf(queue), List.copyOf((Collection) restored)); } } @@ -135,23 +136,23 @@ public void testQueueWithoutNoArgConstructor() throws Exception * instance of its class. */ @Test - public void testCollectionWithNoArgConstructorIsRestoredIntoNewInstance() throws Exception + void collectionWithNoArgConstructorIsRestoredIntoNewInstance() throws Exception { LinkedList linkedList = new LinkedList<>(List.of("b", "a", "b")); assertSavedItemByItem(linkedList); for (Object restored : restore(linkedList)) { - Assertions.assertNotSame(linkedList, restored); - Assertions.assertEquals(LinkedList.class, restored.getClass()); - Assertions.assertEquals(linkedList, restored); + assertNotSame(linkedList, restored); + assertEquals(LinkedList.class, restored.getClass()); + assertEquals(linkedList, restored); } TreeSet treeSet = new TreeSet<>(List.of("c", "a", "b")); assertSavedItemByItem(treeSet); for (Object restored : restore(treeSet)) { - Assertions.assertEquals(TreeSet.class, restored.getClass()); - Assertions.assertEquals(treeSet, restored); + assertEquals(TreeSet.class, restored.getClass()); + assertEquals(treeSet, restored); } } @@ -160,7 +161,7 @@ public void testCollectionWithNoArgConstructorIsRestoredIntoNewInstance() throws * zero-argument constructor, the same as for clazz.newInstance() in restoreAttachedState(). */ @Test - public void testPrivateNoArgConstructorIsSavedWhole() throws Exception + void privateNoArgConstructorIsSavedWhole() throws Exception { PrivateConstructorList list = PrivateConstructorList.of("b", "a"); assertSavedWhole(list); @@ -172,7 +173,7 @@ public void testPrivateNoArgConstructorIsSavedWhole() throws Exception * is still saved item by item and restored into a new instance of its class. */ @Test - public void testAccessiblePackagePrivateNoArgConstructorIsSavedItemByItem() throws Exception + void accessiblePackagePrivateNoArgConstructorIsSavedItemByItem() throws Exception { PackagePrivateConstructorList list = new PackagePrivateConstructorList(); list.add("b"); @@ -180,9 +181,9 @@ public void testAccessiblePackagePrivateNoArgConstructorIsSavedItemByItem() thro assertSavedItemByItem(list); for (Object restored : restore(list)) { - Assertions.assertNotSame(list, restored); - Assertions.assertEquals(PackagePrivateConstructorList.class, restored.getClass()); - Assertions.assertEquals(list, restored); + assertNotSame(list, restored); + assertEquals(PackagePrivateConstructorList.class, restored.getClass()); + assertEquals(list, restored); } } @@ -191,25 +192,25 @@ public void testAccessiblePackagePrivateNoArgConstructorIsSavedItemByItem() thro * state fails, while restoring it without serialization works. */ @Test - public void testNotSerializableItemFailsOnlyWhenSerialized() throws Exception + void notSerializableItemFailsOnlyWhenSerialized() throws Exception { Object item = new Object(); List list = List.of(item); Object state = UIComponentBase.saveAttachedState(facesContext, list); - Assertions.assertSame(list, state); - Assertions.assertSame(item, ((List) UIComponentBase.restoreAttachedState(facesContext, state)).get(0)); - Assertions.assertThrows(NotSerializableException.class, () -> serialize(state)); + assertSame(list, state); + assertSame(item, ((List) UIComponentBase.restoreAttachedState(facesContext, state)).get(0)); + assertThrows(NotSerializableException.class, () -> serialize(state)); } /** * A collection whose class cannot be instantiated and which is not Serializable either still cannot be restored. */ @Test - public void testNotSerializableCollectionWithoutNoArgConstructorFails() + void notSerializableCollectionWithoutNoArgConstructorFails() { Map map = new HashMap<>(Map.of("a", 1)); Object state = UIComponentBase.saveAttachedState(facesContext, map.keySet()); - Assertions.assertThrows(RuntimeException.class, () -> UIComponentBase.restoreAttachedState(facesContext, + assertThrows(RuntimeException.class, () -> UIComponentBase.restoreAttachedState(facesContext, state)); } @@ -219,7 +220,7 @@ public void testNotSerializableCollectionWithoutNoArgConstructorFails() * serialization (server side state saving) and with it (client side state saving). */ @Test - public void testUIDataValueSetToListOf() throws Exception + void uIDataValueSetToListOf() throws Exception { List value = List.of("b", "a", "b"); for (boolean delta : new boolean[] {false, true}) @@ -249,20 +250,20 @@ public void testUIDataValueSetToListOf() throws Exception restored.restoreState(facesContext, state); String message = "delta=" + delta + ", serialized=" + serialized; - Assertions.assertEquals(value.getClass(), restored.getValue().getClass(), message); - Assertions.assertEquals(value, restored.getValue(), message); + assertEquals(value.getClass(), restored.getValue().getClass(), message); + assertEquals(value, restored.getValue(), message); } } } private void assertSavedWhole(Collection collection) { - Assertions.assertSame(collection, UIComponentBase.saveAttachedState(facesContext, collection)); + assertSame(collection, UIComponentBase.saveAttachedState(facesContext, collection)); } private void assertSavedItemByItem(Collection collection) { - Assertions.assertInstanceOf(_AttachedCollectionStateWrapper.class, + assertInstanceOf(_AttachedCollectionStateWrapper.class, UIComponentBase.saveAttachedState(facesContext, collection)); } @@ -271,8 +272,8 @@ private void assertRestoredWithExactType(Collection collection) throws Except assertSavedWhole(collection); for (Object restored : restore(collection)) { - Assertions.assertEquals(collection.getClass(), restored.getClass()); - Assertions.assertEquals(collection, restored); + assertEquals(collection.getClass(), restored.getClass()); + assertEquals(collection, restored); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentBaseRestoreEmptyFullStateTest.java b/impl/src/test/java/jakarta/faces/component/UIComponentBaseRestoreEmptyFullStateTest.java index 9abdde4e9f..475c2b38f4 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentBaseRestoreEmptyFullStateTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentBaseRestoreEmptyFullStateTest.java @@ -18,10 +18,11 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.faces.event.PhaseId; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -30,7 +31,7 @@ * was in its state helper when the full state was saved. This is what UIData and UIRepeat with * {@code rowStatePreserved="true"} do when they enter a row without saved state of its own. */ -public class UIComponentBaseRestoreEmptyFullStateTest extends AbstractFacesTestCase +class UIComponentBaseRestoreEmptyFullStateTest extends AbstractFacesTestCase { @Override @BeforeEach @@ -41,7 +42,7 @@ public void setUp() throws Exception } @Test - public void testFullStateWithEmptyStateHelperClearsLocalValue() + void fullStateWithEmptyStateHelperClearsLocalValue() { UIInput input = new UIInput(); input.setId("in"); @@ -50,20 +51,20 @@ public void testFullStateWithEmptyStateHelperClearsLocalValue() // the row before leaves its local value in the component input.setValue("typed"); - Assertions.assertTrue(input.isLocalValueSet()); + assertTrue(input.isLocalValueSet()); // same sequence as UIData.restoreFullDescendantComponentStates() input.clearInitialState(); input.restoreState(facesContext, fullState); input.markInitialState(); - Assertions.assertNull(input.getLocalValue()); - Assertions.assertFalse(input.isLocalValueSet()); - Assertions.assertEquals("in", input.getId()); + assertNull(input.getLocalValue()); + assertFalse(input.isLocalValueSet()); + assertEquals("in", input.getId()); } @Test - public void testFullStateWithEmptyStateHelperClearsAttributes() + void fullStateWithEmptyStateHelperClearsAttributes() { UIOutput output = new UIOutput(); output.setId("out"); @@ -77,15 +78,15 @@ public void testFullStateWithEmptyStateHelperClearsAttributes() output.restoreState(facesContext, fullState); output.markInitialState(); - Assertions.assertNull(output.getAttributes().get("styleClass")); - Assertions.assertTrue(output.isRendered()); + assertNull(output.getAttributes().get("styleClass")); + assertTrue(output.isRendered()); } /** * Control: a full state with something in its state helper already replaces the state helper. */ @Test - public void testFullStateWithStateHelperReplacesLocalValue() + void fullStateWithStateHelperReplacesLocalValue() { UIInput input = new UIInput(); input.setId("in"); @@ -99,16 +100,16 @@ public void testFullStateWithStateHelperReplacesLocalValue() input.restoreState(facesContext, fullState); input.markInitialState(); - Assertions.assertNull(input.getLocalValue()); - Assertions.assertFalse(input.isLocalValueSet()); - Assertions.assertTrue(input.isRequired()); + assertNull(input.getLocalValue()); + assertFalse(input.isLocalValueSet()); + assertTrue(input.isRequired()); } /** * A null delta keeps its meaning: nothing changed, so the current state stays as it is. */ @Test - public void testNullDeltaKeepsLocalValue() + void nullDeltaKeepsLocalValue() { UIInput input = new UIInput(); input.setId("in"); @@ -119,10 +120,10 @@ public void testNullDeltaKeepsLocalValue() other.setId("in"); other.markInitialState(); Object delta = other.saveState(facesContext); - Assertions.assertNull(delta); + assertNull(delta); input.restoreState(facesContext, delta); - Assertions.assertEquals("typed", input.getLocalValue()); - Assertions.assertTrue(input.isLocalValueSet()); + assertEquals("typed", input.getLocalValue()); + assertTrue(input.isLocalValueSet()); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentBaseTest.java b/impl/src/test/java/jakarta/faces/component/UIComponentBaseTest.java index 31919c0f31..2429c1ccfb 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentBaseTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentBaseTest.java @@ -23,6 +23,7 @@ import static org.easymock.EasyMock.expectLastCall; import static org.easymock.EasyMock.same; import static org.easymock.classextension.EasyMock.createControl; +import static org.junit.jupiter.api.Assertions.*; import java.lang.reflect.Method; import java.util.ArrayList; @@ -38,7 +39,6 @@ import org.easymock.classextension.IMocksControl; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -52,16 +52,16 @@ public class UIComponentBaseTest private Renderer _renderer; @BeforeEach - public void setUp() throws Exception + void setUp() throws Exception { _mocksControl = createControl(); _facesContext = _mocksControl.createMock(FacesContext.class); _testImpl = _mocksControl.createMock(UIComponentBase.class, getMockedMethodsArray()); _renderer = _mocksControl.createMock(Renderer.class); } - + @AfterEach - public void tearDown() throws Exception + void tearDown() throws Exception { _mocksControl = null; _facesContext = null; @@ -100,14 +100,14 @@ protected Collection getMockedMethods() * Test method for 'jakarta.faces.component.UIComponentBase.getAttributes()' */ @Test - public void testGetAttributes() + void getAttributes() { // TODO implement tests for _ComponentAttributesMap - Assertions.assertTrue(_testImpl.getAttributes() instanceof _ComponentAttributesMap); + assertInstanceOf(_ComponentAttributesMap.class, _testImpl.getAttributes()); } @Test - public void testGetRendersChildren() + void getRendersChildren() { assertGetRendersChildren(false, null); assertGetRendersChildren(true, _renderer); @@ -123,7 +123,7 @@ private void assertGetRendersChildren(boolean expectedValue, Renderer renderer) expect(renderer.getRendersChildren()).andReturn(expectedValue); } _mocksControl.replay(); - Assertions.assertEquals(expectedValue, _testImpl.getRendersChildren()); + assertEquals(expectedValue, _testImpl.getRendersChildren()); _mocksControl.verify(); _mocksControl.reset(); } @@ -149,15 +149,14 @@ private void assertGetRendersChildren(boolean expectedValue, Renderer renderer) // } @Test - public void testBroadcastArgNPE() throws Exception + void broadcastArgNPE() throws Exception { - Assertions.assertThrows(NullPointerException.class, () -> { - _testImpl.broadcast(null); - }); + assertThrows(NullPointerException.class, () -> + _testImpl.broadcast(null)); } @Test - public void testBroadcast() throws Exception + void broadcast() throws Exception { FacesEvent event = _mocksControl.createMock(FacesEvent.class); _testImpl.broadcast(event); @@ -177,15 +176,14 @@ public void testBroadcast() throws Exception } @Test - public void testDecodeArgNPE() throws Exception + void decodeArgNPE() throws Exception { - Assertions.assertThrows(NullPointerException.class, () -> { - _testImpl.decode(null); - }); + assertThrows(NullPointerException.class, () -> + _testImpl.decode(null)); } @Test - public void testDecode() throws Exception + void decode() throws Exception { expect(_testImpl.getRenderer(same(_facesContext))).andReturn(_renderer); _renderer.decode(same(_facesContext), same(_testImpl)); @@ -195,11 +193,10 @@ public void testDecode() throws Exception } @Test - public void testEncodeBeginArgNPE() throws Exception + void encodeBeginArgNPE() throws Exception { - Assertions.assertThrows(NullPointerException.class, () -> { - _testImpl.encodeBegin(null); - }); + assertThrows(NullPointerException.class, () -> + _testImpl.encodeBegin(null)); } // FIXME: Need to add some expectation for FacesContext.getAttributes. I'll have to read a bit more about @@ -221,15 +218,14 @@ public void testEncodeBeginArgNPE() throws Exception // } @Test - public void testEncodeChildrenArgNPE() throws Exception + void encodeChildrenArgNPE() throws Exception { - Assertions.assertThrows(NullPointerException.class, () -> { - _testImpl.encodeChildren(null); - }); + assertThrows(NullPointerException.class, () -> + _testImpl.encodeChildren(null)); } @Test - public void testEncodeChildren() throws Exception + void encodeChildren() throws Exception { _testImpl.setRendered(false); _mocksControl.replay(); @@ -245,11 +241,10 @@ public void testEncodeChildren() throws Exception } @Test - public void testEncodeEndArgNPE() throws Exception + void encodeEndArgNPE() throws Exception { - Assertions.assertThrows(NullPointerException.class, () -> { - _testImpl.encodeEnd(null); - }); + assertThrows(NullPointerException.class, () -> + _testImpl.encodeEnd(null)); } // FIXME: Need to add some expectation for FacesContext.getAttributes. I'll have to read a bit more about @@ -271,26 +266,24 @@ public void testEncodeEndArgNPE() throws Exception // } @Test - public void testQueueEventArgNPE() throws Exception + void queueEventArgNPE() throws Exception { - Assertions.assertThrows(NullPointerException.class, () -> { - _testImpl.queueEvent(null); - }); + assertThrows(NullPointerException.class, () -> + _testImpl.queueEvent(null)); } @Test - public void testQueueEventWithoutParent() throws Exception + void queueEventWithoutParent() throws Exception { - Assertions.assertThrows(IllegalStateException.class, () -> { - FacesEvent event = _mocksControl.createMock(FacesEvent.class); - expect(_testImpl.getParent()).andReturn(null); - _mocksControl.replay(); - _testImpl.queueEvent(event); - }); + FacesEvent event = _mocksControl.createMock(FacesEvent.class); + expect(_testImpl.getParent()).andReturn(null); + _mocksControl.replay(); + assertThrows(IllegalStateException.class, () -> + _testImpl.queueEvent(event)); } @Test - public void testQueueEvent() throws Exception + void queueEvent() throws Exception { FacesEvent event = _mocksControl.createMock(FacesEvent.class); UIComponent parent = _mocksControl.createMock(UIComponent.class); @@ -302,17 +295,16 @@ public void testQueueEvent() throws Exception } @Test - public void testProcessDecodesArgNPE() throws Exception + void processDecodesArgNPE() throws Exception { - Assertions.assertThrows(NullPointerException.class, () -> { - _testImpl.processDecodes(null); - }); + assertThrows(NullPointerException.class, () -> + _testImpl.processDecodes(null)); } @Test - public void testProcessDecodesCallsRenderResoponseIfDecodeThrowsException() + void processDecodesCallsRenderResoponseIfDecodeThrowsException() { - Assertions.assertThrows(RuntimeException.class, () -> { + assertThrows(RuntimeException.class, () -> { List emptyList = Collections.emptyList(); expect(_testImpl.getFacetsAndChildren()).andReturn(emptyList.iterator()); @@ -358,11 +350,10 @@ public void testProcessDecodesWithRenderedFalse() throws Exception // } @Test - public void testProcessValidatorsArgNPE() throws Exception + void processValidatorsArgNPE() throws Exception { - Assertions.assertThrows(NullPointerException.class, () -> { - _testImpl.processValidators(null); - }); + assertThrows(NullPointerException.class, () -> + _testImpl.processValidators(null)); } //@Test @@ -396,11 +387,10 @@ private UIComponent setupProcessXYZTest() throws Exception } @Test - public void testProcessUpdatesArgNPE() throws Exception + void processUpdatesArgNPE() throws Exception { - Assertions.assertThrows(NullPointerException.class, () -> { - _testImpl.processUpdates(null); - }); + assertThrows(NullPointerException.class, () -> + _testImpl.processUpdates(null)); } //@Test diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentEncodeAllTest.java b/impl/src/test/java/jakarta/faces/component/UIComponentEncodeAllTest.java index 0146c0959e..21519f2d5b 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentEncodeAllTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentEncodeAllTest.java @@ -22,20 +22,22 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.easymock.classextension.EasyMock; import org.easymock.classextension.IMocksControl; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.List; /** - * Tests for {@link UIComponent#encodeAll(jakarta.faces.context.FacesContext)}. + * Tests for {@link UIComponent#encodeAll(jakarta.faces.context.FacesContext)}. */ -public class UIComponentEncodeAllTest extends AbstractFacesTestCase +class UIComponentEncodeAllTest extends AbstractFacesTestCase { protected IMocksControl _mocksControl; private UIComponent _testimpl; @@ -64,14 +66,14 @@ public void setUp() throws Exception } @Test - public void testEncodeAllNullContext() throws Exception + void encodeAllNullContext() throws Exception { - Assertions.assertThrows(NullPointerException.class, + assertThrows(NullPointerException.class, () -> _testimpl.encodeAll(null)); } @Test - public void testEncodeAllNotRendered() throws Exception + void encodeAllNotRendered() throws Exception { /*TODO: implement me EasyMock.expect(_testimpl.isRendered()).andReturn(false); @@ -82,7 +84,7 @@ public void testEncodeAllNotRendered() throws Exception } @Test - public void testEncodeAllRenderesChildren() throws Exception + void encodeAllRenderesChildren() throws Exception { /*TODO: implement me EasyMock.expect(_testimpl.isRendered()).andReturn(true); @@ -97,7 +99,7 @@ public void testEncodeAllRenderesChildren() throws Exception } @Test - public void testEncodeAllNotRenderesChildren() throws Exception + void encodeAllNotRenderesChildren() throws Exception { /*TODO: implement me EasyMock.expect(_testimpl.isRendered()).andReturn(true); @@ -128,7 +130,7 @@ public void testEncodeAllNotRenderesChildren() throws Exception * silently dropping any children added mid-iteration. */ @Test - public void testEncodeAllChildAppendedDuringParentEncodeIsVisited() throws Exception + void encodeAllChildAppendedDuringParentEncodeIsVisited() throws Exception { List encoded = new ArrayList<>(); @@ -169,7 +171,7 @@ public void encodeEnd(FacesContext ctx) throws IOException { } parent.getChildren().add(firstChild); parent.encodeAll(facesContext); - Assertions.assertEquals(List.of("first", "late"), encoded, + assertEquals(List.of("first", "late"), encoded, "A child appended to the parent during encodeAll must be visited in the same pass"); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentEventListenerWrapperTest.java b/impl/src/test/java/jakarta/faces/component/UIComponentEventListenerWrapperTest.java index 00ee7ac74f..24f23d582b 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentEventListenerWrapperTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentEventListenerWrapperTest.java @@ -18,17 +18,18 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.faces.context.FacesContext; import jakarta.faces.event.ComponentSystemEvent; import jakarta.faces.event.ComponentSystemEventListener; import jakarta.faces.render.Renderer; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class UIComponentEventListenerWrapperTest extends AbstractComponentTest +class UIComponentEventListenerWrapperTest extends AbstractComponentTest { @Test - public void testUIComponentListenerNormalState() + void uIComponentListenerNormalState() { UIComponent component = new UIOutput(); //This case happens when @ListenerFor is attached on the component class @@ -37,7 +38,7 @@ public void testUIComponentListenerNormalState() Object state = wrapper.saveState(facesContext); //In this case state should not be null, because state should be saved fully - Assertions.assertNotNull(state); + assertNotNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(); //For restore we need to setup the context first @@ -45,12 +46,12 @@ public void testUIComponentListenerNormalState() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } - + @Test - public void testUIComponentListenerWithPSS() + void uIComponentListenerWithPSS() { UIComponent component = new UIOutput(); //This case happens when @ListenerFor is attached on the component class @@ -60,7 +61,7 @@ public void testUIComponentListenerWithPSS() Object state = wrapper.saveState(facesContext); //In this case state should be null - Assertions.assertNull(state); + assertNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(component, component); wrapper.markInitialState(); @@ -69,12 +70,12 @@ public void testUIComponentListenerWithPSS() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } - + @Test - public void testUIComponentListenerWithPSSFull() + void uIComponentListenerWithPSSFull() { UIComponent component = new UIOutput(); //This case happens when @ListenerFor is attached on the component class @@ -86,7 +87,7 @@ public void testUIComponentListenerWithPSSFull() Object state = wrapper.saveState(facesContext); //In this case state should not be null, because state should be saved fully - Assertions.assertNotNull(state); + assertNotNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(component, component); wrapper.markInitialState(); @@ -95,8 +96,8 @@ public void testUIComponentListenerWithPSSFull() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } public static class MyCustomRenderer extends Renderer implements ComponentSystemEventListener { @@ -106,9 +107,9 @@ public void processEvent(ComponentSystemEvent event) } } - + @Test - public void testRendererListenerNormalState() + void rendererListenerNormalState() { UIComponent component = new UIOutput(); MyCustomRenderer renderer = new MyCustomRenderer(); @@ -120,7 +121,7 @@ public void testRendererListenerNormalState() Object state = wrapper.saveState(facesContext); //In this case state should not be null, because state should be saved fully - Assertions.assertNotNull(state); + assertNotNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(); //For restore we need to setup the context first @@ -128,12 +129,12 @@ public void testRendererListenerNormalState() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } - + @Test - public void testRendererListenerWithPSS() + void rendererListenerWithPSS() { UIComponent component = new UIOutput(); MyCustomRenderer renderer = new MyCustomRenderer(); @@ -146,7 +147,7 @@ public void testRendererListenerWithPSS() Object state = wrapper.saveState(facesContext); //In this case state should be null - Assertions.assertNull(state); + assertNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(component, renderer); wrapper.markInitialState(); @@ -155,12 +156,12 @@ public void testRendererListenerWithPSS() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } - + @Test - public void testRendererListenerWithPSSFull() + void rendererListenerWithPSSFull() { UIComponent component = new UIOutput(); MyCustomRenderer renderer = new MyCustomRenderer(); @@ -175,7 +176,7 @@ public void testRendererListenerWithPSSFull() Object state = wrapper.saveState(facesContext); //In this case state should not be null, because state should be saved fully - Assertions.assertNotNull(state); + assertNotNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(component, renderer); wrapper.markInitialState(); @@ -184,8 +185,8 @@ public void testRendererListenerWithPSSFull() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } public static class MyNonSerializableListener implements ComponentSystemEventListener { @@ -203,9 +204,9 @@ public boolean equals(Object obj) } } - + @Test - public void testNonSerializableListenerNormalState() + void nonSerializableListenerNormalState() { UIComponent component = new UIOutput(); ComponentSystemEventListener listener = new MyNonSerializableListener(); @@ -215,7 +216,7 @@ public void testNonSerializableListenerNormalState() Object state = wrapper.saveState(facesContext); //In this case state should not be null, because state should be saved fully - Assertions.assertNotNull(state); + assertNotNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(); //For restore we need to setup the context first @@ -223,12 +224,12 @@ public void testNonSerializableListenerNormalState() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } - + @Test - public void testNonSerializableListenerWithPSS() + void nonSerializableListenerWithPSS() { UIComponent component = new UIOutput(); ComponentSystemEventListener listener = new MyNonSerializableListener(); @@ -239,7 +240,7 @@ public void testNonSerializableListenerWithPSS() Object state = wrapper.saveState(facesContext); //In this case state should be null - Assertions.assertNull(state); + assertNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(component, listener); wrapper.markInitialState(); @@ -248,12 +249,12 @@ public void testNonSerializableListenerWithPSS() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } - + @Test - public void testNonSerializableListenerWithPSSFull() + void nonSerializableListenerWithPSSFull() { UIComponent component = new UIOutput(); ComponentSystemEventListener listener = new MyNonSerializableListener(); @@ -266,7 +267,7 @@ public void testNonSerializableListenerWithPSSFull() Object state = wrapper.saveState(facesContext); //In this case state should not be null, because state should be saved fully - Assertions.assertNotNull(state); + assertNotNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(component, listener); wrapper.markInitialState(); @@ -275,8 +276,8 @@ public void testNonSerializableListenerWithPSSFull() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } public static class MySerializableListener implements ComponentSystemEventListener { @@ -294,9 +295,9 @@ public boolean equals(Object obj) } } - + @Test - public void testSerializableListenerNormalState() + void serializableListenerNormalState() { UIComponent component = new UIOutput(); ComponentSystemEventListener listener = new MySerializableListener(); @@ -306,7 +307,7 @@ public void testSerializableListenerNormalState() Object state = wrapper.saveState(facesContext); //In this case state should not be null, because state should be saved fully - Assertions.assertNotNull(state); + assertNotNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(); //For restore we need to setup the context first @@ -314,12 +315,12 @@ public void testSerializableListenerNormalState() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } - + @Test - public void testSerializableListenerWithPSS() + void serializableListenerWithPSS() { UIComponent component = new UIOutput(); ComponentSystemEventListener listener = new MySerializableListener(); @@ -330,7 +331,7 @@ public void testSerializableListenerWithPSS() Object state = wrapper.saveState(facesContext); //In this case state should be null - Assertions.assertNull(state); + assertNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(component, listener); wrapper.markInitialState(); @@ -339,12 +340,12 @@ public void testSerializableListenerWithPSS() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } - + @Test - public void testSerializableListenerWithPSSFull() + void serializableListenerWithPSSFull() { UIComponent component = new UIOutput(); ComponentSystemEventListener listener = new MySerializableListener(); @@ -357,7 +358,7 @@ public void testSerializableListenerWithPSSFull() Object state = wrapper.saveState(facesContext); //In this case state should not be null, because state should be saved fully - Assertions.assertNotNull(state); + assertNotNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(component, listener); wrapper.markInitialState(); @@ -366,8 +367,8 @@ public void testSerializableListenerWithPSSFull() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } public static class MyStateHolderListener implements ComponentSystemEventListener, StateHolder { @@ -420,9 +421,9 @@ public void setTransient(boolean newTransientValue) } } - + @Test - public void testStateHolderListenerNormalState() + void stateHolderListenerNormalState() { UIComponent component = new UIOutput(); MyStateHolderListener listener = new MyStateHolderListener(); @@ -433,7 +434,7 @@ public void testStateHolderListenerNormalState() Object state = wrapper.saveState(facesContext); //In this case state should not be null, because state should be saved fully - Assertions.assertNotNull(state); + assertNotNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(); //For restore we need to setup the context first @@ -441,12 +442,12 @@ public void testStateHolderListenerNormalState() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } - + @Test - public void testStateHolderListenerWithPSS() + void stateHolderListenerWithPSS() { UIComponent component = new UIOutput(); ComponentSystemEventListener listener = new MyStateHolderListener(); @@ -457,7 +458,7 @@ public void testStateHolderListenerWithPSS() Object state = wrapper.saveState(facesContext); //In this case state should be not null, because it implements StateHolder - Assertions.assertNotNull(state); + assertNotNull(state); MyStateHolderListener listener2 = new MyStateHolderListener(); listener2.setI(2); @@ -468,12 +469,12 @@ public void testStateHolderListenerWithPSS() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } - + @Test - public void testStateHolderListenerWithPSSFull() + void stateHolderListenerWithPSSFull() { UIComponent component = new UIOutput(); ComponentSystemEventListener listener = new MyStateHolderListener(); @@ -486,7 +487,7 @@ public void testStateHolderListenerWithPSSFull() Object state = wrapper.saveState(facesContext); //In this case state should not be null, because state should be saved fully - Assertions.assertNotNull(state); + assertNotNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(component, listener); wrapper.markInitialState(); @@ -495,8 +496,8 @@ public void testStateHolderListenerWithPSSFull() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } public static class MyPartialStateHolderListener implements ComponentSystemEventListener, PartialStateHolder { @@ -584,9 +585,9 @@ public void markInitialState() } } - + @Test - public void testPartialStateHolderListenerNormalState() + void partialStateHolderListenerNormalState() { UIComponent component = new UIOutput(); ComponentSystemEventListener listener = new MyPartialStateHolderListener(); @@ -596,7 +597,7 @@ public void testPartialStateHolderListenerNormalState() Object state = wrapper.saveState(facesContext); //In this case state should not be null, because state should be saved fully - Assertions.assertNotNull(state); + assertNotNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(); //For restore we need to setup the context first @@ -604,12 +605,12 @@ public void testPartialStateHolderListenerNormalState() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } - + @Test - public void testPartialStateHolderListenerWithPSS() + void partialStateHolderListenerWithPSS() { UIComponent component = new UIOutput(); ComponentSystemEventListener listener = new MyPartialStateHolderListener(); @@ -620,7 +621,7 @@ public void testPartialStateHolderListenerWithPSS() Object state = wrapper.saveState(facesContext); //In this case state should be null - Assertions.assertNull(state); + assertNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(component, listener); wrapper.markInitialState(); @@ -629,12 +630,12 @@ public void testPartialStateHolderListenerWithPSS() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } @Test - public void testPartialStateHolderListenerWithPSS2() + void partialStateHolderListenerWithPSS2() { UIComponent component = new UIOutput(); MyPartialStateHolderListener listener = new MyPartialStateHolderListener(); @@ -647,7 +648,7 @@ public void testPartialStateHolderListenerWithPSS2() Object state = wrapper.saveState(facesContext); //In this case state should be not null, because something changed inside the listener - Assertions.assertNotNull(state); + assertNotNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(component, new MyPartialStateHolderListener()); wrapper.markInitialState(); @@ -656,12 +657,12 @@ public void testPartialStateHolderListenerWithPSS2() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } - + @Test - public void testPartialStateHolderListenerWithPSSFull() + void partialStateHolderListenerWithPSSFull() { UIComponent component = new UIOutput(); ComponentSystemEventListener listener = new MyPartialStateHolderListener(); @@ -674,7 +675,7 @@ public void testPartialStateHolderListenerWithPSSFull() Object state = wrapper.saveState(facesContext); //In this case state should not be null, because state should be saved fully - Assertions.assertNotNull(state); + assertNotNull(state); _EventListenerWrapper wrapper2 = new _EventListenerWrapper(component, listener); wrapper.markInitialState(); @@ -683,7 +684,7 @@ public void testPartialStateHolderListenerWithPSSFull() wrapper2.restoreState(facesContext, state); component.popComponentFromEL(facesContext); - Assertions.assertNotNull(wrapper2.getComponentSystemEventListener()); - Assertions.assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); + assertNotNull(wrapper2.getComponentSystemEventListener()); + assertEquals(wrapper.getComponentSystemEventListener(), wrapper2.getComponentSystemEventListener()); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentFindComponentTest.java b/impl/src/test/java/jakarta/faces/component/UIComponentFindComponentTest.java index f7d122f38e..661c6bdd17 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentFindComponentTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentFindComponentTest.java @@ -18,7 +18,8 @@ */ package jakarta.faces.component; -import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.*; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -30,7 +31,7 @@ * Time: 01:19:19 * To change this template use File | Settings | File Templates. */ -public class UIComponentFindComponentTest extends AbstractComponentTest +class UIComponentFindComponentTest extends AbstractComponentTest { protected UIComponentBase _testImpl; @@ -43,13 +44,13 @@ public void setUp() throws Exception } @Test - public void testWithNullExpression() throws Exception + void withNullExpression() throws Exception { try { _testImpl.findComponent(null); - Assertions.assertNull(_testImpl.findComponent("")); - Assertions.fail(); + assertNull(_testImpl.findComponent("")); + fail(); } catch(NullPointerException e) { @@ -57,18 +58,18 @@ public void testWithNullExpression() throws Exception } catch(Exception e) { - Assertions.fail(); + fail(); } } @Test - public void testWithEmptyExpression() throws Exception + void withEmptyExpression() throws Exception { - Assertions.assertNull(_testImpl.findComponent("")); + assertNull(_testImpl.findComponent("")); } @Test - public void testRootExpression() throws Exception + void rootExpression() throws Exception { String expression = ":parent"; UIComponent root = new UIViewRoot(); @@ -80,11 +81,11 @@ public void testRootExpression() throws Exception parent.getChildren().add(_testImpl); _testImpl.setId("testimpl"); - Assertions.assertEquals(parent, _testImpl.findComponent(expression)); + assertEquals(parent, _testImpl.findComponent(expression)); } @Test - public void testRelativeExpression() throws Exception + void relativeExpression() throws Exception { String expression = "testimpl"; @@ -97,11 +98,11 @@ public void testRelativeExpression() throws Exception parent.getChildren().add(_testImpl); _testImpl.setId("testimpl"); - Assertions.assertEquals(_testImpl, _testImpl.findComponent(expression)); + assertEquals(_testImpl, _testImpl.findComponent(expression)); } @Test - public void testComplexRelativeExpression() throws Exception + void complexRelativeExpression() throws Exception { String expression = "child1_1:testimpl"; @@ -114,11 +115,11 @@ public void testComplexRelativeExpression() throws Exception child1_1.getChildren().add(_testImpl); _testImpl.setId("testimpl"); - Assertions.assertEquals(_testImpl, namingContainer.findComponent(expression)); + assertEquals(_testImpl, namingContainer.findComponent(expression)); } @Test - public void testOverriddenFindComponent() { + void overriddenFindComponent() { UIViewRoot viewRoot = new UIViewRoot(); UIData uiData = new UIData() { @@ -157,16 +158,16 @@ public String stripRowIndex(String searchId) { uiData.getChildren().add(column); column.getChildren().add(command); - Assertions.assertNull(viewRoot.findComponent(":xx")); - Assertions.assertEquals(uiData, viewRoot.findComponent(":data")); - Assertions.assertEquals(column, viewRoot.findComponent(":data:column")); - Assertions.assertEquals(command, viewRoot.findComponent(":data:command")); - Assertions.assertEquals(command, viewRoot.findComponent("data:1:command")); - Assertions.assertEquals(command, viewRoot.findComponent(":data:1:command")); + assertNull(viewRoot.findComponent(":xx")); + assertEquals(uiData, viewRoot.findComponent(":data")); + assertEquals(column, viewRoot.findComponent(":data:column")); + assertEquals(command, viewRoot.findComponent(":data:command")); + assertEquals(command, viewRoot.findComponent("data:1:command")); + assertEquals(command, viewRoot.findComponent(":data:1:command")); } @Test - public void testXXFindComponent() { + void xXFindComponent() { UIViewRoot viewRoot = new UIViewRoot(); UIData uiData = new UIData(); uiData.setId("x"); @@ -178,14 +179,14 @@ public void testXXFindComponent() { uiData.getChildren().add(column); column.getChildren().add(command); - Assertions.assertNull(viewRoot.findComponent(":xx")); - Assertions.assertNotNull(viewRoot.findComponent(":x")); - Assertions.assertNotNull(viewRoot.findComponent(":x:column")); - Assertions.assertNotNull(viewRoot.findComponent(":x:x")); + assertNull(viewRoot.findComponent(":xx")); + assertNotNull(viewRoot.findComponent(":x")); + assertNotNull(viewRoot.findComponent(":x:column")); + assertNotNull(viewRoot.findComponent(":x:x")); } @Test - public void testWithRelativeExpressionNamingContainer() throws Exception + void withRelativeExpressionNamingContainer() throws Exception { String expression = "testimpl"; @@ -198,7 +199,7 @@ public void testWithRelativeExpressionNamingContainer() throws Exception parent.getChildren().add(_testImpl); _testImpl.setId("testimpl"); - Assertions.assertEquals(_testImpl, namingContainer.findComponent(expression)); + assertEquals(_testImpl, namingContainer.findComponent(expression)); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentInvokeOnComponentTest.java b/impl/src/test/java/jakarta/faces/component/UIComponentInvokeOnComponentTest.java index 0c7c76036a..8c3d4520cd 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentInvokeOnComponentTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentInvokeOnComponentTest.java @@ -23,19 +23,21 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.easymock.classextension.EasyMock; import org.easymock.classextension.IMocksControl; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.lang.reflect.Method; + +import static org.junit.jupiter.api.Assertions.*; + import java.util.ArrayList; import java.util.Collection; /** - * Tests for + * Tests for * {@link UIComponent#invokeOnComponent(jakarta.faces.context.FacesContext, String, ContextCallback)}. */ -public class UIComponentInvokeOnComponentTest extends AbstractFacesTestCase +class UIComponentInvokeOnComponentTest extends AbstractFacesTestCase { protected IMocksControl _mocksControl; private UIComponent _testimpl; @@ -58,7 +60,7 @@ public void setUp() throws Exception } @Test - public void testInvokeOnComponentWithSameClientId() throws Exception + void invokeOnComponentWithSameClientId() throws Exception { UIComponent testimpl = new UIOutput(); testimpl.setId("xxxId"); @@ -66,12 +68,12 @@ public void testInvokeOnComponentWithSameClientId() throws Exception //EasyMock.expect(_testimpl.getClientId(EasyMock.same(facesContext))).andReturn("xxxId"); _contextCallback.invokeContextCallback(EasyMock.same(facesContext), EasyMock.same(testimpl)); _mocksControl.replay(); - Assertions.assertTrue(testimpl.invokeOnComponent(facesContext, "xxxId", _contextCallback)); + assertTrue(testimpl.invokeOnComponent(facesContext, "xxxId", _contextCallback)); _mocksControl.verify(); } @Test - public void testInvokeOnComponentWithException() throws Exception + void invokeOnComponentWithException() throws Exception { final UIComponent testimpl = new UIOutput(); testimpl.setId("xxxId"); @@ -81,12 +83,12 @@ public void testInvokeOnComponentWithException() throws Exception EasyMock.expectLastCall().andThrow(new RuntimeException()); _mocksControl.replay(); - Assertions.assertThrows(FacesException.class, + assertThrows(FacesException.class, () -> testimpl.invokeOnComponent(facesContext, "xxxId", _contextCallback)); } @Test - public void testInvokeOnComponentAndNotFindComponentWithClientId() throws Exception + void invokeOnComponentAndNotFindComponentWithClientId() throws Exception { //List emptyList = Collections.emptyList(); UIComponent testimpl = new UIPanel(); @@ -95,12 +97,12 @@ public void testInvokeOnComponentAndNotFindComponentWithClientId() throws Except //EasyMock.expect(_testimpl.getClientId(EasyMock.same(facesContext))).andReturn("xxxId"); //EasyMock.expect(_testimpl.getFacetsAndChildren()).andReturn(emptyList.iterator()); //_mocksControl.replay(); - Assertions.assertFalse(testimpl.invokeOnComponent(facesContext, "xxId", _contextCallback)); + assertFalse(testimpl.invokeOnComponent(facesContext, "xxId", _contextCallback)); //_mocksControl.verify(); } @Test - public void testInvokeOnComponentOnChild() throws Exception + void invokeOnComponentOnChild() throws Exception { UIComponent testimpl = new UIPanel(); testimpl.setId("xxxId"); @@ -113,20 +115,20 @@ public void testInvokeOnComponentOnChild() throws Exception //EasyMock.expect(child.invokeOnComponent(EasyMock.same(facesContext), EasyMock.eq(childId), EasyMock.same(_contextCallback))).andReturn(true); _contextCallback.invokeContextCallback(EasyMock.same(facesContext), EasyMock.same(child)); _mocksControl.replay(); - Assertions.assertTrue(testimpl.invokeOnComponent(facesContext, "childId", _contextCallback)); + assertTrue(testimpl.invokeOnComponent(facesContext, "childId", _contextCallback)); _mocksControl.verify(); } @Test - public void testInvokeOnComponentExceptions() throws Exception + void invokeOnComponentExceptions() throws Exception { - Assertions.assertThrows(NullPointerException.class, + assertThrows(NullPointerException.class, () -> _testimpl.invokeOnComponent(null, "xxx", _contextCallback)); - Assertions.assertThrows(NullPointerException.class, + assertThrows(NullPointerException.class, () -> _testimpl.invokeOnComponent(facesContext, null, _contextCallback)); - Assertions.assertThrows(NullPointerException.class, + assertThrows(NullPointerException.class, () -> _testimpl.invokeOnComponent(facesContext, "xxx", null)); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentTest.java b/impl/src/test/java/jakarta/faces/component/UIComponentTest.java index debf3c6ea6..333a837e8f 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentTest.java @@ -19,7 +19,6 @@ package jakarta.faces.component; import jakarta.faces.context.FacesContext; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.lang.reflect.Method; @@ -30,14 +29,16 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.same; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; -public class UIComponentTest extends UIComponentTestBase +class UIComponentTest extends UIComponentTestBase { /** * Test method for {@link jakarta.faces.component.UIComponent#getFacetCount()}. */ @Test - public void testGetFacetCount() throws Exception + void getFacetCount() throws Exception { Method[] methods = {UIComponent.class.getDeclaredMethod("getFacets", (Class[])null)}; UIComponent component = _mocksControl.createMock(UIComponent.class, methods); @@ -47,13 +48,13 @@ public void testGetFacetCount() throws Exception map.put("xxx3", new UIInput()); expect(component.getFacets()).andReturn(map); _mocksControl.replay(); - Assertions.assertEquals(3, component.getFacetCount()); + assertEquals(3, component.getFacetCount()); _mocksControl.verify(); _mocksControl.reset(); expect(component.getFacets()).andReturn(null); _mocksControl.replay(); - Assertions.assertEquals(0, component.getFacetCount()); + assertEquals(0, component.getFacetCount()); _mocksControl.verify(); } @@ -64,7 +65,7 @@ public void testGetFacetCount() throws Exception * @throws Exception */ @Test - public void testGetContainerClientId() throws Exception + void getContainerClientId() throws Exception { Collection mockedMethods = new ArrayList(); Class clazz = UIComponent.class; @@ -73,12 +74,12 @@ public void testGetContainerClientId() throws Exception .size()])); _mocksControl.checkOrder(true); - Assertions.assertThrows(NullPointerException.class, + assertThrows(NullPointerException.class, () -> testimpl.getContainerClientId(null)); expect(testimpl.getClientId(same(_facesContext))).andReturn("xyz"); _mocksControl.replay(); - Assertions.assertEquals("xyz", testimpl.getContainerClientId(_facesContext)); + assertEquals("xyz", testimpl.getContainerClientId(_facesContext)); _mocksControl.verify(); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentValueExpressionTest.java b/impl/src/test/java/jakarta/faces/component/UIComponentValueExpressionTest.java index db696fa74e..54219f5732 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentValueExpressionTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentValueExpressionTest.java @@ -18,6 +18,7 @@ */ package jakarta.faces.component; import static org.easymock.EasyMock.expect; +import static org.junit.jupiter.api.Assertions.*; import java.lang.reflect.Method; import java.util.ArrayList; @@ -31,7 +32,6 @@ import jakarta.faces.FacesException; import org.easymock.EasyMock; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -39,7 +39,7 @@ * Test for {@link UIComponent#getValueExpression(String)}. and * {@link UIComponent#setValueExpression(String, jakarta.el.ValueExpression)}. */ -public class UIComponentValueExpressionTest extends UIComponentTestBase +class UIComponentValueExpressionTest extends UIComponentTestBase { private UIComponent _testimpl; private ValueExpression _expression; @@ -62,60 +62,56 @@ public void setUp() throws Exception } @Test - public void testValueExpressionArgumentNPE() throws Exception + void valueExpressionArgumentNPE() throws Exception { - Assertions.assertThrows(NullPointerException.class, () -> { - _testimpl.setValueExpression(null, _expression); - }); + assertThrows(NullPointerException.class, () -> + _testimpl.setValueExpression(null, _expression)); } @Test - public void testValueExpressionArgumentId() throws Exception + void valueExpressionArgumentId() throws Exception { - Assertions.assertThrows(IllegalArgumentException.class, () -> { - _testimpl.setValueExpression("id", _expression); - }); + assertThrows(IllegalArgumentException.class, () -> + _testimpl.setValueExpression("id", _expression)); } @Test - public void testValueExpressionArgumentsParent() throws Exception + void valueExpressionArgumentsParent() throws Exception { - Assertions.assertThrows(IllegalArgumentException.class, () -> { - _testimpl.setValueExpression("parent", _expression); - }); + assertThrows(IllegalArgumentException.class, () -> + _testimpl.setValueExpression("parent", _expression)); } @Test - public void testValueExpression() throws Exception + void valueExpression() throws Exception { expect(_expression.isLiteralText()).andReturn(false); _mocksControl.replay(); _testimpl.setValueExpression("xxx", _expression); _mocksControl.verify(); - Assertions.assertEquals(_expression, _testimpl.getValueExpression("xxx")); + assertEquals(_expression, _testimpl.getValueExpression("xxx")); _testimpl.setValueExpression("xxx", null); _mocksControl.verify(); - Assertions.assertNull(_testimpl.getValueExpression("xxx")); + assertNull(_testimpl.getValueExpression("xxx")); } @Test - public void testValueExpressionWithExceptionOnGetValue() throws Exception + void valueExpressionWithExceptionOnGetValue() throws Exception { - Assertions.assertThrows(FacesException.class, () -> { - expect(_expression.isLiteralText()).andReturn(true); - expect(_testimpl.getFacesContext()).andReturn(_facesContext); - expect(_facesContext.getELContext()).andReturn(_elContext); - expect(_expression.getValue(EasyMock.eq(_elContext))).andThrow(new ELException()); - Map map = new HashMap(); - expect(_testimpl.getAttributes()).andReturn(map); - _mocksControl.replay(); - _testimpl.setValueExpression("xxx", _expression); - }); + expect(_expression.isLiteralText()).andReturn(true); + expect(_testimpl.getFacesContext()).andReturn(_facesContext); + expect(_facesContext.getELContext()).andReturn(_elContext); + expect(_expression.getValue(EasyMock.eq(_elContext))).andThrow(new ELException()); + Map map = new HashMap(); + expect(_testimpl.getAttributes()).andReturn(map); + _mocksControl.replay(); + assertThrows(FacesException.class, () -> + _testimpl.setValueExpression("xxx", _expression)); } @Test - public void testValueExpressionWithLiteralText() throws Exception + void valueExpressionWithLiteralText() throws Exception { expect(_expression.isLiteralText()).andReturn(true); expect(_testimpl.getFacesContext()).andReturn(_facesContext); @@ -125,9 +121,9 @@ public void testValueExpressionWithLiteralText() throws Exception expect(_testimpl.getAttributes()).andReturn(map); _mocksControl.replay(); _testimpl.setValueExpression("xxx", _expression); - Assertions.assertEquals("abc", map.get("xxx")); + assertEquals("abc", map.get("xxx")); _mocksControl.verify(); - Assertions.assertNull(_testimpl.getValueExpression("xxx")); + assertNull(_testimpl.getValueExpression("xxx")); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIDataRowStateTest.java b/impl/src/test/java/jakarta/faces/component/UIDataRowStateTest.java index 964db63dfc..4e8c4b8ccd 100644 --- a/impl/src/test/java/jakarta/faces/component/UIDataRowStateTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIDataRowStateTest.java @@ -15,6 +15,8 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.ArrayList; import java.util.List; import jakarta.faces.component.html.HtmlColumn; @@ -23,11 +25,10 @@ import jakarta.faces.component.html.HtmlOutputText; import jakarta.faces.model.ListDataModel; import jakarta.faces.render.Renderer; -import org.junit.jupiter.api.Assertions; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.junit.jupiter.api.Test; -public class UIDataRowStateTest extends AbstractFacesTestCase +class UIDataRowStateTest extends AbstractFacesTestCase { public static class Item @@ -93,12 +94,12 @@ protected void setUpRenderKit() throws Exception { renderKit.addRenderer(HtmlOutputText.COMPONENT_FAMILY, new HtmlOutputText().getRendererType(), new Renderer(){}); renderKit.addRenderer(HtmlInputText.COMPONENT_FAMILY, new HtmlInputText().getRendererType(), new Renderer(){}); } - + /** * */ @Test - public void testChangeIdsAfterSetRowIndex() + void changeIdsAfterSetRowIndex() { List list = new ArrayList(); int rowCount = 10; @@ -130,14 +131,14 @@ public void testChangeIdsAfterSetRowIndex() for (int i = 0; i < rowCount ; i++) { data.setRowIndex(i); - Assertions.assertEquals(data.getId()+":"+i+":"+text.getId(), text.getClientId()); + assertEquals(data.getId()+":"+i+":"+text.getId(), text.getClientId()); } data.setRowIndex(-1); - Assertions.assertEquals(data.getId()+":"+text.getId(), text.getClientId()); + assertEquals(data.getId()+":"+text.getId(), text.getClientId()); } - + @Test - public void testChangeIdsAfterSetRowIndex2() + void changeIdsAfterSetRowIndex2() { List list = new ArrayList(); int rowCount = 10; @@ -176,16 +177,16 @@ public void testChangeIdsAfterSetRowIndex2() for (int i = 0; i < rowCount ; i++) { data.setRowIndex(i); - Assertions.assertEquals(data.getId()+":"+i+":"+text.getId(), text.getClientId()); - Assertions.assertEquals(data.getId()+":"+i+":"+inputText.getId(), inputText.getClientId()); + assertEquals(data.getId()+":"+i+":"+text.getId(), text.getClientId()); + assertEquals(data.getId()+":"+i+":"+inputText.getId(), inputText.getClientId()); } data.setRowIndex(-1); - Assertions.assertEquals(data.getId()+":"+text.getId(), text.getClientId()); - Assertions.assertEquals(data.getId()+":"+inputText.getId(), inputText.getClientId()); + assertEquals(data.getId()+":"+text.getId(), text.getClientId()); + assertEquals(data.getId()+":"+inputText.getId(), inputText.getClientId()); } - + @Test - public void testAddRowAfterSetRowIndex() + void addRowAfterSetRowIndex() { List list = new ArrayList(); int rowCount = 10; @@ -221,12 +222,12 @@ public void testAddRowAfterSetRowIndex() data.processDecodes(facesContext); } - + /** * Check if EditableValueHolder is being saved and restored. */ @Test - public void testEditableValueHolderState() + void editableValueHolderState() { List list = new ArrayList(); int rowCount = 10; @@ -272,7 +273,7 @@ public void testEditableValueHolderState() for (int i = 0; i < rowCount ; i++) { data.setRowIndex(i); - Assertions.assertEquals("someString"+i, inputText.getSubmittedValue()); + assertEquals("someString"+i, inputText.getSubmittedValue()); } } } diff --git a/impl/src/test/java/jakarta/faces/component/UIDataTest.java b/impl/src/test/java/jakarta/faces/component/UIDataTest.java index 8e331b050c..36ba4dd66b 100644 --- a/impl/src/test/java/jakarta/faces/component/UIDataTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIDataTest.java @@ -34,11 +34,13 @@ import org.apache.myfaces.test.mock.visit.MockVisitContext; import org.easymock.classextension.EasyMock; import org.easymock.classextension.IMocksControl; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.*; + +import static org.junit.jupiter.api.Assertions.*; + import java.util.*; public class UIDataTest extends AbstractFacesTestCase @@ -60,7 +62,7 @@ public void setUp() throws Exception * {@link jakarta.faces.component.UIData#setValueExpression(java.lang.String, jakarta.el.ValueExpression)}. */ @Test - public void testValueExpression() + void valueExpression() { assertSetValueExpressionException(IllegalArgumentException.class, "rowIndex"); assertSetValueExpressionException(NullPointerException.class, null); @@ -68,7 +70,7 @@ public void testValueExpression() private void assertSetValueExpressionException(Class expected, final String name) { - Assertions.assertThrows(expected, + assertThrows(expected, () -> _testImpl.setValueExpression(name, null)); } @@ -76,16 +78,16 @@ private void assertSetValueExpressionException(Class expect * Test method for {@link jakarta.faces.component.UIData#getClientId(jakarta.faces.context.FacesContext)}. */ @Test - public void testGetClientId() + void getClientId() { _testImpl.setId("xxx"); Renderer renderer = _mocksControl.createMock(Renderer.class); renderKit.addRenderer(UIData.COMPONENT_FAMILY, UIData.COMPONENT_TYPE, renderer); - Assertions.assertEquals("xxx", _testImpl.getClientId(facesContext)); + assertEquals("xxx", _testImpl.getClientId(facesContext)); _testImpl.setRowIndex(99); //MYFACES-2744 UIData.getClientId() should not append rowIndex, instead use UIData.getContainerClientId() - Assertions.assertEquals("xxx", _testImpl.getClientId(facesContext)); - Assertions.assertEquals("xxx:99", _testImpl.getContainerClientId(facesContext)); + assertEquals("xxx", _testImpl.getClientId(facesContext)); + assertEquals("xxx:99", _testImpl.getContainerClientId(facesContext)); } /** @@ -95,7 +97,7 @@ public void testGetClientId() * Tests, if invokeOnComponent also checks the facets of the h:column children (MYFACES-2370) */ @Test - public void testInvokeOnComponentFacesContextStringContextCallback() + void invokeOnComponentFacesContextStringContextCallback() { /** * Concrete class of ContextCallback needed to test invokeOnComponent. @@ -124,14 +126,14 @@ public void invokeContextCallback(FacesContext context, MyContextCallback callback = new MyContextCallback(); _testImpl.invokeOnComponent(facesContext, facet.getClientId(facesContext), callback); // the callback should have been invoked - Assertions.assertTrue(callback.invoked); + assertTrue(callback.invoked); } /** * Test method for {@link jakarta.faces.component.UIData#broadcast(jakarta.faces.event.FacesEvent)}. */ @Test - public void testBroadcastFacesEvent() + void broadcastFacesEvent() { // create event mock final FacesEvent originalEvent = _mocksControl.createMock(FacesEvent.class); @@ -145,13 +147,13 @@ public void broadcast(FacesEvent event) throws AbortProcessingException { // the event must be the originalEvent - Assertions.assertEquals(originalEvent, event); + assertEquals(originalEvent, event); // the current row index must be the row index from the time the event was queued - Assertions.assertEquals(5, _testImpl.getRowIndex()); + assertEquals(5, _testImpl.getRowIndex()); // the current component must be this (pushComponentToEL() must have happened) - Assertions.assertEquals(this, UIComponent.getCurrentComponent(facesContext)); + assertEquals(this, UIComponent.getCurrentComponent(facesContext)); // to be able to verify that broadcast() really has been called getAttributes().put("broadcastCalled", Boolean.TRUE); @@ -181,23 +183,23 @@ public void broadcast(FacesEvent event) // -= Assertions =- // the current component must be null (popComponentFromEL() must have happened) - Assertions.assertNull(UIComponent.getCurrentComponent(facesContext)); + assertNull(UIComponent.getCurrentComponent(facesContext)); // the row index must now be 0 (at broadcast() it must be 5) - Assertions.assertEquals(0, _testImpl.getRowIndex()); + assertEquals(0, _testImpl.getRowIndex()); // verify mock behavior _mocksControl.verify(); // verify that broadcast() really has been called - Assertions.assertEquals(Boolean.TRUE, eventComponent.getAttributes().get("broadcastCalled")); + assertEquals(Boolean.TRUE, eventComponent.getAttributes().get("broadcastCalled")); } /** * Test method for {@link jakarta.faces.component.UIData#encodeBegin(jakarta.faces.context.FacesContext)}. */ @Test - public void testEncodeBeginFacesContext() + void encodeBeginFacesContext() { // TODO } @@ -206,7 +208,7 @@ public void testEncodeBeginFacesContext() * Test method for {@link jakarta.faces.component.UIData#encodeEnd(jakarta.faces.context.FacesContext)}. */ @Test - public void testEncodeEndFacesContext() + void encodeEndFacesContext() { // TODO } @@ -215,7 +217,7 @@ public void testEncodeEndFacesContext() * Test method for {@link jakarta.faces.component.UIData#queueEvent(jakarta.faces.event.FacesEvent)}. */ @Test - public void testQueueEventFacesEvent() + void queueEventFacesEvent() { // TODO } @@ -224,7 +226,7 @@ public void testQueueEventFacesEvent() * Test method for {@link jakarta.faces.component.UIData#processDecodes(jakarta.faces.context.FacesContext)}. */ @Test - public void testProcessDecodesFacesContext() + void processDecodesFacesContext() { // TODO } @@ -233,7 +235,7 @@ public void testProcessDecodesFacesContext() * Test method for {@link jakarta.faces.component.UIData#processValidators(jakarta.faces.context.FacesContext)}. */ @Test - public void testProcessValidatorsFacesContext() + void processValidatorsFacesContext() { // TODO } @@ -242,7 +244,7 @@ public void testProcessValidatorsFacesContext() * Test method for {@link jakarta.faces.component.UIData#processUpdates(jakarta.faces.context.FacesContext)}. */ @Test - public void testProcessUpdatesFacesContext() + void processUpdatesFacesContext() { // TODO } @@ -251,7 +253,7 @@ public void testProcessUpdatesFacesContext() * Test method for {@link jakarta.faces.component.UIData#saveState(jakarta.faces.context.FacesContext)}. */ @Test - public void testSaveState() + void saveState() { // TODO } @@ -261,7 +263,7 @@ public void testSaveState() * {@link jakarta.faces.component.UIData#restoreState(jakarta.faces.context.FacesContext, java.lang.Object)}. */ @Test - public void testRestoreState() + void restoreState() { // TODO } @@ -270,7 +272,7 @@ public void testRestoreState() * Test method for {@link jakarta.faces.component.UIData#UIData()}. */ @Test - public void testUIData() + void uIData() { // TODO } @@ -279,7 +281,7 @@ public void testUIData() * Test method for {@link jakarta.faces.component.UIData#setFooter(jakarta.faces.component.UIComponent)}. */ @Test - public void testSetFooter() + void setFooter() { // TODO } @@ -288,7 +290,7 @@ public void testSetFooter() * Test method for {@link jakarta.faces.component.UIData#getFooter()}. */ @Test - public void testGetFooter() + void getFooter() { // TODO } @@ -297,7 +299,7 @@ public void testGetFooter() * Test method for {@link jakarta.faces.component.UIData#setHeader(jakarta.faces.component.UIComponent)}. */ @Test - public void testSetHeader() + void setHeader() { // TODO } @@ -306,7 +308,7 @@ public void testSetHeader() * Test method for {@link jakarta.faces.component.UIData#getHeader()}. */ @Test - public void testGetHeader() + void getHeader() { // TODO } @@ -315,7 +317,7 @@ public void testGetHeader() * Test method for {@link jakarta.faces.component.UIData#isRowAvailable()}. */ @Test - public void testIsRowAvailable() + void isRowAvailable() { // TODO } @@ -324,7 +326,7 @@ public void testIsRowAvailable() * Test method for {@link jakarta.faces.component.UIData#getRowCount()}. */ @Test - public void testGetRowCount() + void getRowCount() { // TODO } @@ -333,7 +335,7 @@ public void testGetRowCount() * Test method for {@link jakarta.faces.component.UIData#getRowData()}. */ @Test - public void testGetRowData() + void getRowData() { // TODO } @@ -342,7 +344,7 @@ public void testGetRowData() * Test method for {@link jakarta.faces.component.UIData#getRowIndex()}. */ @Test - public void testGetRowIndex() + void getRowIndex() { // TODO } @@ -351,7 +353,7 @@ public void testGetRowIndex() * Test method for {@link jakarta.faces.component.UIData#setRowIndex(int)}. */ @Test - public void testSetRowIndex() + void setRowIndex() { // TODO } @@ -360,7 +362,7 @@ public void testSetRowIndex() * Test method for {@link jakarta.faces.component.UIData#getDataModel()}. */ @Test - public void testGetDataModel() + void getDataModel() { // TODO } @@ -369,7 +371,7 @@ public void testGetDataModel() * Test method for {@link jakarta.faces.component.UIData#setDataModel(jakarta.faces.model.DataModel)}. */ @Test - public void testSetDataModel() + void setDataModel() { // TODO } @@ -378,7 +380,7 @@ public void testSetDataModel() * Test method for {@link jakarta.faces.component.UIData#setValue(java.lang.Object)}. */ @Test - public void testSetValue() + void setValue() { // TODO } @@ -387,7 +389,7 @@ public void testSetValue() * Test method for {@link jakarta.faces.component.UIData#setRows(int)}. */ @Test - public void testSetRows() + void setRows() { // TODO } @@ -396,7 +398,7 @@ public void testSetRows() * Test method for {@link jakarta.faces.component.UIData#setFirst(int)}. */ @Test - public void testSetFirst() + void setFirst() { // TODO } @@ -405,7 +407,7 @@ public void testSetFirst() * Test method for {@link jakarta.faces.component.UIData#getValue()}. */ @Test - public void testGetValue() + void getValue() { // TODO } @@ -414,7 +416,7 @@ public void testGetValue() * Test method for {@link jakarta.faces.component.UIData#getVar()}. */ @Test - public void testGetVar() + void getVar() { // TODO } @@ -423,7 +425,7 @@ public void testGetVar() * Test method for {@link jakarta.faces.component.UIData#setVar(java.lang.String)}. */ @Test - public void testSetVar() + void setVar() { // TODO } @@ -432,7 +434,7 @@ public void testSetVar() * Test method for {@link jakarta.faces.component.UIData#getRows()}. */ @Test - public void testGetRows() + void getRows() { // TODO } @@ -441,7 +443,7 @@ public void testGetRows() * Test method for {@link jakarta.faces.component.UIData#getFirst()}. */ @Test - public void testGetFirst() + void getFirst() { // TODO } @@ -450,17 +452,17 @@ public void testGetFirst() * Test method for {@link jakarta.faces.component.UIData#getFamily()}. */ @Test - public void testGetFamily() + void getFamily() { // TODO } - + /** * Test method for * {@link jakarta.faces.component.UIData#visitTree(jakarta.faces.component.visit.VisitContext, jakarta.faces.component.visit.VisitCallback)}. */ @Test - public void testVisitTree() { + void visitTree() { UIData uidata = new UIData(); // value Collection value = new ArrayList(); @@ -577,9 +579,9 @@ public void setStyle(String style) this.style = style; } } - + @Test - public void testPreserveRowComponentState1() throws Exception + void preserveRowComponentState1() throws Exception { List model = new ArrayList(); model.add(new RowData("text1","style1")); @@ -628,7 +630,7 @@ public void testPreserveRowComponentState1() throws Exception { RowData rowData = model.get(i); table.setRowIndex(i); - Assertions.assertEquals(rowData.getText(), text.getValue()); + assertEquals(rowData.getText(), text.getValue()); text.getAttributes().put("style", rowData.getStyle()); } @@ -639,13 +641,13 @@ public void testPreserveRowComponentState1() throws Exception for (int i = 0; i < model.size(); i++) { table.setRowIndex(i); - Assertions.assertEquals(model.get(i).getStyle(), text.getAttributes().get("style")); + assertEquals(model.get(i).getStyle(), text.getAttributes().get("style")); } } - + @Test - public void testCollectionDataModel() throws Exception + void collectionDataModel() throws Exception { SimpleCollection model = new SimpleCollection(); model.add(new RowData("text1","style1")); @@ -687,7 +689,7 @@ public void testCollectionDataModel() throws Exception { RowData rowData = it.next(); table.setRowIndex(i); - Assertions.assertEquals(rowData.getText(), text.getValue()); + assertEquals(rowData.getText(), text.getValue()); i++; } @@ -744,75 +746,75 @@ public VisitResult visit(VisitContext context, UIComponent target) { } public void verify() { - Assertions.assertEquals(1, headerFacetVisits); - Assertions.assertEquals(1, footerFacetVisits); - Assertions.assertEquals(expectedVisits, rowVisits); + assertEquals(1, headerFacetVisits); + assertEquals(1, footerFacetVisits); + assertEquals(expectedVisits, rowVisits); } } - + @Test - public void testProcessDecodesRenderedFalse() throws Exception { + void processDecodesRenderedFalse() throws Exception { UIData uiData = new VerifyNoLifecycleMethodComponent(); UIComponent parent = MockRenderedValueExpression.setUpComponentStack(facesContext, uiData, false); uiData.processDecodes(facesContext); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processDecodes must not change currentComponent"); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processDecodes must not change currentComponent"); } - + @Test - public void testProcessDecodesRenderedTrue() throws Exception { + void processDecodesRenderedTrue() throws Exception { UIComponent parent = MockRenderedValueExpression.setUpComponentStack(facesContext, _testImpl, true); _addColumn(); _testImpl.processDecodes(facesContext); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processDecodes must not change currentComponent"); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processDecodes must not change currentComponent"); } - + @Test - public void testProcessValidatorsRenderedFalse() throws Exception { + void processValidatorsRenderedFalse() throws Exception { UIData uiData = new VerifyNoLifecycleMethodComponent(); UIComponent parent = MockRenderedValueExpression.setUpComponentStack(facesContext, uiData, false); uiData.processValidators(facesContext); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processDecodes must not change currentComponent"); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processDecodes must not change currentComponent"); } - + @Test - public void testProcessValidatorsRenderedTrue() throws Exception { + void processValidatorsRenderedTrue() throws Exception { UIComponent parent = MockRenderedValueExpression.setUpComponentStack(facesContext, _testImpl, true); _addColumn(); _testImpl.processValidators(facesContext); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processValidators must not change currentComponent"); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processValidators must not change currentComponent"); } - + @Test - public void testProcessUpdatesRenderedFalse() throws Exception { + void processUpdatesRenderedFalse() throws Exception { UIData uiData = new VerifyNoLifecycleMethodComponent(); UIComponent parent = MockRenderedValueExpression.setUpComponentStack(facesContext, uiData, false); uiData.processUpdates(facesContext); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processUpdates must not change currentComponent"); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processUpdates must not change currentComponent"); } - + @Test - public void testProcessUpdatesRenderedTrue() throws Exception { + void processUpdatesRenderedTrue() throws Exception { UIComponent parent = MockRenderedValueExpression.setUpComponentStack(facesContext, _testImpl, true); _addColumn(); _testImpl.processUpdates(facesContext); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processUpdates must not change currentComponent"); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processUpdates must not change currentComponent"); } private void _addColumn() { @@ -829,33 +831,33 @@ public class VerifyNoLifecycleMethodComponent extends UIData { @Override public void setRowIndex(int rowIndex) { - Assertions.fail(); + fail(); } @Override public void decode(FacesContext context) { - Assertions.fail(); + fail(); } public void validate(FacesContext context) { - Assertions.fail(); + fail(); } public void updateModel(FacesContext context) { - Assertions.fail(); + fail(); } @Override public void encodeBegin(FacesContext context) throws IOException { - Assertions.fail(); + fail(); } @Override public void encodeChildren(FacesContext context) throws IOException { - Assertions.fail(); + fail(); } @Override public void encodeEnd(FacesContext context) throws IOException { - Assertions.fail(); + fail(); } - } - - + } + + /** * Test state save and restore cycle taking in consideration portlet case. * @@ -867,7 +869,7 @@ public void encodeEnd(FacesContext context) throws IOException { * @throws Exception */ @Test - public void testSaveAndRestorePortletLifecycleWithoutPss1() throws Exception + void saveAndRestorePortletLifecycleWithoutPss1() throws Exception { List model = new ArrayList(); model.add(new RowData("text1","style1")); @@ -891,7 +893,7 @@ public void testSaveAndRestorePortletLifecycleWithoutPss1() throws Exception { RowData rowData = model.get(i); table.setRowIndex(i); - Assertions.assertEquals(rowData.getText(), text.getValue()); + assertEquals(rowData.getText(), text.getValue()); text.setSubmittedValue("value"+(i+1)); //text.getAttributes().put("style", rowData.getStyle()); } @@ -930,11 +932,11 @@ public void testSaveAndRestorePortletLifecycleWithoutPss1() throws Exception { RowData rowData = model.get(i); table.setRowIndex(i); - Assertions.assertEquals("value"+(i+1), text.getSubmittedValue()); + assertEquals("value"+(i+1), text.getSubmittedValue()); //assertEquals(model.get(i).getStyle(), text.getAttributes().get("style")); } } - + // ------------------------------------------------------------------------- // Stateful (EVH) flat-list save / restore — UIData-specific // ------------------------------------------------------------------------- @@ -947,7 +949,7 @@ public void testSaveAndRestorePortletLifecycleWithoutPss1() throws Exception * {@code saveChildStates} / {@code restoreChildStates}. */ @Test - public void testStatefulRowStateIsPreservedOnRevisit() + void statefulRowStateIsPreservedOnRevisit() { UIViewRoot root = facesContext.getViewRoot(); UIData table = new UIData(); @@ -976,7 +978,7 @@ public void testStatefulRowStateIsPreservedOnRevisit() for (int i = 0; i < 3; i++) { table.setRowIndex(i); - Assertions.assertEquals("submitted_" + i, input.getSubmittedValue(), + assertEquals("submitted_" + i, input.getSubmittedValue(), "Row " + i + ": submitted value should be restored from Integer row-index-keyed _rowStates"); } table.setRowIndex(-1); @@ -987,7 +989,7 @@ public void testStatefulRowStateIsPreservedOnRevisit() * components to their initial (empty) state. */ @Test - public void testStatefulResetToInitialStateAtIndexMinusOne() + void statefulResetToInitialStateAtIndexMinusOne() { UIViewRoot root = facesContext.getViewRoot(); UIData table = new UIData(); @@ -1011,9 +1013,9 @@ public void testStatefulResetToInitialStateAtIndexMinusOne() // Reset to -1: components must be in their clean template state. table.setRowIndex(-1); - Assertions.assertNull(input.getSubmittedValue(), + assertNull(input.getSubmittedValue(), "After reset to -1, submitted value must be cleared to initial state"); - Assertions.assertTrue(input.isValid(), + assertTrue(input.isValid(), "After reset to -1, valid flag must be restored to true"); } @@ -1021,7 +1023,7 @@ public void testStatefulResetToInitialStateAtIndexMinusOne() * Multiple UIColumn/UIInput siblings must each have independent per-row state. */ @Test - public void testStatefulMultipleEVHColumnsHaveIndependentState() + void statefulMultipleEVHColumnsHaveIndependentState() { UIViewRoot root = facesContext.getViewRoot(); UIData table = new UIData(); @@ -1058,13 +1060,13 @@ public void testStatefulMultipleEVHColumnsHaveIndependentState() // Revisit row 0 — both inputs must have their row-0 values. table.setRowIndex(0); - Assertions.assertEquals("a0", inputA.getSubmittedValue()); - Assertions.assertEquals("b0", inputB.getSubmittedValue()); + assertEquals("a0", inputA.getSubmittedValue()); + assertEquals("b0", inputB.getSubmittedValue()); // Revisit row 1 — both inputs must have their row-1 values. table.setRowIndex(1); - Assertions.assertEquals("a1", inputA.getSubmittedValue()); - Assertions.assertEquals("b1", inputB.getSubmittedValue()); + assertEquals("a1", inputA.getSubmittedValue()); + assertEquals("b1", inputB.getSubmittedValue()); } /** @@ -1072,7 +1074,7 @@ public void testStatefulMultipleEVHColumnsHaveIndependentState() * found in {@code _iterationEVHList} via depth-first traversal. */ @Test - public void testStatefulNestedEVHStateIsPreserved() + void statefulNestedEVHStateIsPreserved() { UIViewRoot root = facesContext.getViewRoot(); UIData table = new UIData(); @@ -1101,11 +1103,11 @@ public void testStatefulNestedEVHStateIsPreserved() table.setRowIndex(-1); table.setRowIndex(0); - Assertions.assertEquals("nested_0", input.getSubmittedValue(), + assertEquals("nested_0", input.getSubmittedValue(), "Nested UIInput row-0 state must be restored"); table.setRowIndex(1); - Assertions.assertEquals("nested_1", input.getSubmittedValue(), + assertEquals("nested_1", input.getSubmittedValue(), "Nested UIInput row-1 state must be restored"); } @@ -1116,7 +1118,7 @@ public void testStatefulNestedEVHStateIsPreserved() * values of every enclosing row but the last. */ @Test - public void testNestedTableRowStateIsScopedPerOuterRow() + void nestedTableRowStateIsScopedPerOuterRow() { UIViewRoot root = facesContext.getViewRoot(); @@ -1166,7 +1168,7 @@ public void testNestedTableRowStateIsScopedPerOuterRow() for (int innerRow = 0; innerRow < 2; innerRow++) { inner.setRowIndex(innerRow); - Assertions.assertEquals("v" + outerRow + innerRow, input.getSubmittedValue(), + assertEquals("v" + outerRow + innerRow, input.getSubmittedValue(), "outer row " + outerRow + ", inner row " + innerRow + " must keep the value submitted into it"); } @@ -1184,7 +1186,7 @@ public void testNestedTableRowStateIsScopedPerOuterRow() * reset clientIds correctly so each row produces unique clientIds. */ @Test - public void testReadOnlyClientIdResetPerRow() + void readOnlyClientIdResetPerRow() { UIViewRoot root = facesContext.getViewRoot(); UIData table = new UIData(); @@ -1208,13 +1210,13 @@ public void testReadOnlyClientIdResetPerRow() table.setRowIndex(2); String clientId2 = out.getClientId(facesContext); - Assertions.assertNotEquals(clientId0, clientId1, "ClientIds must differ between rows"); - Assertions.assertNotEquals(clientId1, clientId2, "ClientIds must differ between rows"); + assertNotEquals(clientId0, clientId1, "ClientIds must differ between rows"); + assertNotEquals(clientId1, clientId2, "ClientIds must differ between rows"); // After resetting, the IDs must match the first pass. table.setRowIndex(-1); table.setRowIndex(0); - Assertions.assertEquals(clientId0, out.getClientId(facesContext), + assertEquals(clientId0, out.getClientId(facesContext), "ClientId for row 0 must be stable across iteration sequences"); } @@ -1223,7 +1225,7 @@ public void testReadOnlyClientIdResetPerRow() * state is not saved ({@code _iterationResetList} includes them). */ @Test - public void testReadOnlyTransientComponentClientIdIsReset() + void readOnlyTransientComponentClientIdIsReset() { UIViewRoot root = facesContext.getViewRoot(); UIData table = new UIData(); @@ -1245,7 +1247,7 @@ public void testReadOnlyTransientComponentClientIdIsReset() table.setRowIndex(1); String id1 = transientOut.getClientId(facesContext); - Assertions.assertNotEquals(id0, id1, + assertNotEquals(id0, id1, "Transient component clientId must be reset per row"); } @@ -1258,7 +1260,7 @@ public void testReadOnlyTransientComponentClientIdIsReset() * iteration sequence must still work correctly (no NPE, correct clientIds). */ @Test - public void testIterationListsAreRebuiltAfterEncodeBegin() throws Exception + void iterationListsAreRebuiltAfterEncodeBegin() throws Exception { UIViewRoot root = facesContext.getViewRoot(); root.setRenderKitId("HTML_BASIC"); @@ -1290,11 +1292,11 @@ public void testIterationListsAreRebuiltAfterEncodeBegin() throws Exception // Second iteration sequence (simulates RENDER_RESPONSE row walk) // must rebuild lists without NPE and show clean initial state table.setRowIndex(0); - Assertions.assertNull(input.getSubmittedValue(), + assertNull(input.getSubmittedValue(), "After encodeBegin, _rowStates is cleared and initial state is clean"); table.setRowIndex(1); - Assertions.assertNull(input.getSubmittedValue()); + assertNull(input.getSubmittedValue()); table.setRowIndex(-1); } @@ -1333,7 +1335,7 @@ private void createSimpleTable(UIViewRoot root, boolean rowStatePreserved) table.getChildren().add(column); column.getChildren().add(text); } - + /** * Test state save and restore cycle taking in consideration portlet case. * @@ -1345,7 +1347,7 @@ private void createSimpleTable(UIViewRoot root, boolean rowStatePreserved) * @throws Exception */ @Test - public void testSaveAndRestorePortletLifecycleWithPss1() throws Exception + void saveAndRestorePortletLifecycleWithPss1() throws Exception { facesContext.getRenderKit().addRenderer("jakarta.faces.Data", "jakarta.faces.Table",new Renderer(){}); @@ -1379,7 +1381,7 @@ public void testSaveAndRestorePortletLifecycleWithPss1() throws Exception { RowData rowData = model.get(i); table.setRowIndex(i); - Assertions.assertEquals(rowData.getText(), text.getValue()); + assertEquals(rowData.getText(), text.getValue()); text.setSubmittedValue("value"+(i+1)); //text.getAttributes().put("style", rowData.getStyle()); } @@ -1428,12 +1430,12 @@ public void testSaveAndRestorePortletLifecycleWithPss1() throws Exception { RowData rowData = model.get(i); table.setRowIndex(i); - Assertions.assertEquals("value"+(i+1), text.getSubmittedValue()); + assertEquals("value"+(i+1), text.getSubmittedValue()); //assertEquals(model.get(i).getStyle(), text.getAttributes().get("style")); } } - + /** * Test state save and restore cycle taking in consideration portlet case. * @@ -1445,7 +1447,7 @@ public void testSaveAndRestorePortletLifecycleWithPss1() throws Exception * @throws Exception */ @Test - public void testSaveAndRestorePortletLifecycleWithPss2() throws Exception + void saveAndRestorePortletLifecycleWithPss2() throws Exception { facesContext.getRenderKit().addRenderer("jakarta.faces.Data", "jakarta.faces.Table",new Renderer(){}); @@ -1479,7 +1481,7 @@ public void testSaveAndRestorePortletLifecycleWithPss2() throws Exception { RowData rowData = model.get(i); table.setRowIndex(i); - Assertions.assertEquals(rowData.getText(), text.getValue()); + assertEquals(rowData.getText(), text.getValue()); text.setSubmittedValue("value"+(i+1)); text.getTransientStateHelper().putTransient("key", "value"+(i+1)); //text.getAttributes().put("style", rowData.getStyle()); @@ -1529,8 +1531,8 @@ public void testSaveAndRestorePortletLifecycleWithPss2() throws Exception { RowData rowData = model.get(i); table.setRowIndex(i); - Assertions.assertEquals("value"+(i+1), text.getSubmittedValue()); - Assertions.assertEquals("value"+(i+1), text.getTransientStateHelper().getTransient("key")); + assertEquals("value"+(i+1), text.getSubmittedValue()); + assertEquals("value"+(i+1), text.getTransientStateHelper().getTransient("key")); //assertEquals(model.get(i).getStyle(), text.getAttributes().get("style")); } diff --git a/impl/src/test/java/jakarta/faces/component/UIGraphicTest.java b/impl/src/test/java/jakarta/faces/component/UIGraphicTest.java index 73c52a7741..fd1ff4dfb2 100644 --- a/impl/src/test/java/jakarta/faces/component/UIGraphicTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIGraphicTest.java @@ -18,37 +18,39 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; + import jakarta.el.ValueExpression; import org.easymock.classextension.EasyMock; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @SuppressWarnings("deprecation") -public class UIGraphicTest +class UIGraphicTest { @Test - public void testUrlValue() + void urlValue() { UIGraphic graphic = new UIGraphic(); graphic.setValue("xxx"); - Assertions.assertEquals(graphic.getUrl(), "xxx"); + assertEquals("xxx", graphic.getUrl()); graphic.setUrl("xyz"); - Assertions.assertEquals(graphic.getValue(), "xyz"); + assertEquals("xyz", graphic.getValue()); } @Test - public void testUrlValueExpression() + void urlValueExpression() { UIGraphic graphic = new UIGraphic(); ValueExpression expression = EasyMock.createMock(ValueExpression.class); graphic.setValueExpression("url", expression); - Assertions.assertSame(graphic.getValueExpression("value"), expression); + assertSame(graphic.getValueExpression("value"), expression); expression = EasyMock.createMock(ValueExpression.class); graphic.setValueExpression("value", expression); - Assertions.assertSame(graphic.getValueExpression("url"), expression); + assertSame(graphic.getValueExpression("url"), expression); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIInputPSSTest.java b/impl/src/test/java/jakarta/faces/component/UIInputPSSTest.java index 5fe2e437db..48f8933d87 100644 --- a/impl/src/test/java/jakarta/faces/component/UIInputPSSTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIInputPSSTest.java @@ -18,12 +18,13 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.el.ValueExpression; import jakarta.faces.event.PhaseId; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.apache.myfaces.test.el.MockValueExpression; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -34,7 +35,7 @@ * The state is saved during Render Response, as it is for the view state, because outside that phase * {@link UIComponentBase#saveState} also saves the transient state. */ -public class UIInputPSSTest extends AbstractFacesTestCase +class UIInputPSSTest extends AbstractFacesTestCase { @Override @@ -50,33 +51,33 @@ public void setUp() throws Exception * of a later request, so that the model value is rendered afterwards. */ @Test - public void testLocalValueSetIsSavedWithTheLocalValue() + void localValueSetIsSavedWithTheLocalValue() { UIInput input = createInput(); input.setValue("stale"); UIInput restored = restore(input.saveState(facesContext)); - Assertions.assertTrue(restored.isLocalValueSet()); + assertTrue(restored.isLocalValueSet()); restored.updateModel(facesContext); - Assertions.assertFalse(restored.isLocalValueSet()); - Assertions.assertEquals("stale", facesContext.getExternalContext().getRequestMap().get("value")); - Assertions.assertEquals("stale", restored.getValue()); - Assertions.assertNull(restored.saveState(facesContext)); + assertFalse(restored.isLocalValueSet()); + assertEquals("stale", facesContext.getExternalContext().getRequestMap().get("value")); + assertEquals("stale", restored.getValue()); + assertNull(restored.saveState(facesContext)); } @Test - public void testInvalidIsSaved() + void invalidIsSaved() { UIInput input = createInput(); input.setValid(false); UIInput restored = restore(input.saveState(facesContext)); - Assertions.assertFalse(restored.isValid()); + assertFalse(restored.isValid()); } @Test - public void testFlagsBackAtTheirDefaultsAddNothingToTheSavedState() + void flagsBackAtTheirDefaultsAddNothingToTheSavedState() { UIInput input = createInput(); input.setValid(false); @@ -84,17 +85,17 @@ public void testFlagsBackAtTheirDefaultsAddNothingToTheSavedState() input.setLocalValueSet(true); input.setLocalValueSet(false); - Assertions.assertNull(input.saveState(facesContext)); + assertNull(input.saveState(facesContext)); } @Test - public void testSubmittedValueIsNotSaved() + void submittedValueIsNotSaved() { UIInput input = createInput(); input.setSubmittedValue("submitted"); UIInput restored = restore(input.saveState(facesContext)); - Assertions.assertNull(restored.getSubmittedValue()); + assertNull(restored.getSubmittedValue()); } private UIInput createInput() diff --git a/impl/src/test/java/jakarta/faces/component/UIInputTest.java b/impl/src/test/java/jakarta/faces/component/UIInputTest.java index d54a73d222..a99f6f10bc 100644 --- a/impl/src/test/java/jakarta/faces/component/UIInputTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIInputTest.java @@ -23,6 +23,7 @@ import static org.easymock.EasyMock.expectLastCall; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; +import static org.junit.jupiter.api.Assertions.*; import java.io.IOException; import java.util.EnumSet; @@ -49,11 +50,10 @@ import org.apache.myfaces.test.el.MockValueExpression; import org.apache.myfaces.test.mock.visit.MockVisitCallback; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class UIInputTest extends AbstractFacesTestCase +class UIInputTest extends AbstractFacesTestCase { private Converter mockConverter; @@ -99,7 +99,7 @@ public void validate(FacesContext context, UIComponent component, } @Test - public void testWhenSpecifiedConverterMessageIsUsedInCaseConverterExceptionOccurs() + void whenSpecifiedConverterMessageIsUsedInCaseConverterExceptionOccurs() { input.setConverterMessage("Cannot convert"); @@ -112,16 +112,16 @@ public void testWhenSpecifiedConverterMessageIsUsedInCaseConverterExceptionOccur input.validate(facesContext); verify(mockConverter); - Assertions.assertFalse(input.isValid()); - Assertions.assertNotNull(facesContext.getMessages("testId")); + assertFalse(input.isValid()); + assertNotNull(facesContext.getMessages("testId")); FacesMessage message = (FacesMessage) facesContext.getMessages("testId").next(); - Assertions.assertEquals(message.getDetail(), "Cannot convert"); - Assertions.assertEquals(message.getSummary(), "Cannot convert"); + assertEquals("Cannot convert", message.getDetail()); + assertEquals("Cannot convert", message.getSummary()); } @Test - public void testWhenSpecifiedValidatorMessageIsUsedInCaseValidatorExceptionOccurs() + void whenSpecifiedValidatorMessageIsUsedInCaseValidatorExceptionOccurs() { input.setValidatorMessage("Cannot validate"); @@ -133,16 +133,16 @@ public void testWhenSpecifiedValidatorMessageIsUsedInCaseValidatorExceptionOccur input.validateValue(facesContext, "xxx"); verify(mockValidator); - Assertions.assertFalse(input.isValid()); - Assertions.assertNotNull(facesContext.getMessages("testId")); + assertFalse(input.isValid()); + assertNotNull(facesContext.getMessages("testId")); FacesMessage message = (FacesMessage) facesContext.getMessages("testId").next(); - Assertions.assertEquals(message.getDetail(), "Cannot validate"); - Assertions.assertEquals(message.getSummary(), "Cannot validate"); + assertEquals("Cannot validate", message.getDetail()); + assertEquals("Cannot validate", message.getSummary()); } @Test - public void testUpdateModelSetsTheLocalValueToModelValue() + void updateModelSetsTheLocalValueToModelValue() { input.setValue("testValue"); @@ -152,11 +152,11 @@ public void testUpdateModelSetsTheLocalValueToModelValue() input.updateModel(facesContext); String updatedValue = expression.getValue(facesContext.getELContext()).toString(); - Assertions.assertEquals("testValue", updatedValue); + assertEquals("testValue", updatedValue); } @Test - public void testValidateWithEmptyStringWithEmptyStringAsNullEnabled() + void validateWithEmptyStringWithEmptyStringAsNullEnabled() { try { @@ -174,7 +174,7 @@ public void validate(FacesContext context, throws ValidatorException { // the value must be null - Assertions.assertNull(value); + assertNull(value); } @@ -183,16 +183,16 @@ public void validate(FacesContext context, input.setSubmittedValue(""); input.validate(facesContext); - Assertions.assertEquals(null, input.getSubmittedValue()); + assertNull(input.getSubmittedValue()); } finally { facesContext.setExternalContext(externalContext); } } - + @Test - public void testValidateWithNonStringWithEmptyStringAsNullEnabled() + void validateWithNonStringWithEmptyStringAsNullEnabled() { try { @@ -209,7 +209,7 @@ public void validate(FacesContext context, throws ValidatorException { // the value must not be null - Assertions.assertNotNull(value); + assertNotNull(value); // throw Exception to ensure this was called throw new RuntimeException(); @@ -234,7 +234,7 @@ public String toString() { input.validate(facesContext); - Assertions.fail(); // validate() was not called --> fail! + fail(); // validate() was not called --> fail! } catch (RuntimeException e) { @@ -248,7 +248,7 @@ public String toString() } @Test - public void testValidateWithNonEmptyStringWithEmptyStringAsNullEnabled() + void validateWithNonEmptyStringWithEmptyStringAsNullEnabled() { try { @@ -260,8 +260,8 @@ public void testValidateWithNonEmptyStringWithEmptyStringAsNullEnabled() input.setSubmittedValue("asd"); input.validate(facesContext); - Assertions.assertEquals(null, input.getSubmittedValue()); - Assertions.assertEquals("asd", input.getValue()); + assertNull(input.getSubmittedValue()); + assertEquals("asd", input.getValue()); } finally { @@ -270,7 +270,7 @@ public void testValidateWithNonEmptyStringWithEmptyStringAsNullEnabled() } @Test - public void testValidateWithEmptyStringWithEmptyStringAsNullDisabled() + void validateWithEmptyStringWithEmptyStringAsNullDisabled() { try { @@ -282,7 +282,7 @@ public void testValidateWithEmptyStringWithEmptyStringAsNullDisabled() input.setSubmittedValue(""); input.validate(facesContext); - Assertions.assertEquals("", input.getValue()); + assertEquals("", input.getValue()); } finally { @@ -291,7 +291,7 @@ public void testValidateWithEmptyStringWithEmptyStringAsNullDisabled() } @Test - public void testValidateWithEmptyStringWithEmptyStringAsNullNotSpecified() + void validateWithEmptyStringWithEmptyStringAsNullNotSpecified() { try { @@ -303,20 +303,20 @@ public void testValidateWithEmptyStringWithEmptyStringAsNullNotSpecified() input.setSubmittedValue(""); input.validate(facesContext); - Assertions.assertEquals("", input.getValue()); + assertEquals("", input.getValue()); } finally { facesContext.setExternalContext(externalContext); } } - + /** * Tests if UIInput.processValidators() correctly calls FacesContext.validationFailed() * if a validation error occurs. */ @Test - public void testValidationErrorTriggersFacesContextValidationFailed() + void validationErrorTriggersFacesContextValidationFailed() { LengthValidator validator = new LengthValidator(); validator.setMinimum(5); @@ -324,9 +324,9 @@ public void testValidationErrorTriggersFacesContextValidationFailed() input.setSubmittedValue("123"); - Assertions.assertFalse(facesContext.isValidationFailed()); + assertFalse(facesContext.isValidationFailed()); input.processValidators(facesContext); - Assertions.assertTrue(facesContext.isValidationFailed()); + assertTrue(facesContext.isValidationFailed()); } static public class InitParameterMockExternalContext extends org.apache.myfaces.test.mock.MockExternalContext { @@ -352,82 +352,82 @@ public Map getInitParameterMap() { return initParameters; } } - + @Test - public void testProcessDecodesRenderedFalse() throws Exception { + void processDecodesRenderedFalse() throws Exception { input = new VerifyNoLifecycleMethodComponent(); UIComponent parent = MockRenderedValueExpression.setUpComponentStack(facesContext, input, false); input.processDecodes(facesContext); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processDecodes must not change currentComponent"); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processDecodes must not change currentComponent"); } - + @Test - public void testProcessDecodesRenderedTrue() throws Exception { + void processDecodesRenderedTrue() throws Exception { UIComponent parent = MockRenderedValueExpression.setUpComponentStack(facesContext, input, true); _setUpValueExpressionForImmediate(); input.processDecodes(facesContext); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processDecodes must not change currentComponent"); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processDecodes must not change currentComponent"); } - + @Test - public void testProcessValidatorsRenderedFalse() throws Exception { + void processValidatorsRenderedFalse() throws Exception { input = new VerifyNoLifecycleMethodComponent(); UIComponent parent = MockRenderedValueExpression.setUpComponentStack(facesContext, input, false); input.processValidators(facesContext); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processValidators must not change currentComponent"); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processValidators must not change currentComponent"); } - + @Test - public void testProcessValidatorsRenderedTrue() throws Exception { + void processValidatorsRenderedTrue() throws Exception { UIComponent parent = MockRenderedValueExpression.setUpComponentStack(facesContext, input, true); _setUpValueExpressionForImmediate(); input.processValidators(facesContext); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processValidators must not change currentComponent"); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processValidators must not change currentComponent"); } - + @Test - public void testProcessUpdatesRenderedFalse() throws Exception { + void processUpdatesRenderedFalse() throws Exception { input = new VerifyNoLifecycleMethodComponent(); UIComponent parent = MockRenderedValueExpression.setUpComponentStack(facesContext,input, false); input.processUpdates(facesContext); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processValidators must not change currentComponent"); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processValidators must not change currentComponent"); } - + @Test - public void testProcessUpdatesRenderedTrue() throws Exception { + void processUpdatesRenderedTrue() throws Exception { UIComponent parent = MockRenderedValueExpression.setUpComponentStack(facesContext, input, true); _setUpValueExpressionForImmediate(); input.processUpdates(facesContext); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processValidators must not change currentComponent"); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "processValidators must not change currentComponent"); } - + @Test - public void testVisitTree() throws Exception { + void visitTree() throws Exception { UIComponent parent = MockRenderedValueExpression.setUpComponentStack(facesContext, input, true); VisitContext visitContext = VisitContext.createVisitContext(facesContext, null, EnumSet.of(VisitHint.SKIP_UNRENDERED)); MockVisitCallback mockVisitCallback = new MockVisitCallback(); input.visitTree(visitContext, mockVisitCallback); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "visitTree must not change currentComponent"); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "visitTree must not change currentComponent"); } /** Verifies no call to encode* and process* methods */ @@ -435,27 +435,27 @@ public class VerifyNoLifecycleMethodComponent extends UIInput { @Override public void decode(FacesContext context) { - Assertions.fail(); + fail(); } @Override public void validate(FacesContext context) { - Assertions.fail(); + fail(); } @Override public void updateModel(FacesContext context) { - Assertions.fail(); + fail(); } @Override public void encodeBegin(FacesContext context) throws IOException { - Assertions.fail(); + fail(); } @Override public void encodeChildren(FacesContext context) throws IOException { - Assertions.fail(); + fail(); } @Override public void encodeEnd(FacesContext context) throws IOException { - Assertions.fail(); + fail(); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIOutputPSSTest.java b/impl/src/test/java/jakarta/faces/component/UIOutputPSSTest.java index abc2dc40fb..7ede96a123 100644 --- a/impl/src/test/java/jakarta/faces/component/UIOutputPSSTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIOutputPSSTest.java @@ -15,24 +15,25 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.*; + import java.io.Serializable; import jakarta.faces.context.FacesContext; import jakarta.faces.convert.Converter; import jakarta.faces.convert.LongConverter; -import org.junit.jupiter.api.Assertions; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.junit.jupiter.api.Test; -public class UIOutputPSSTest extends AbstractFacesTestCase +class UIOutputPSSTest extends AbstractFacesTestCase { - + /** * Check null delta when converter only implements Converter interface. * * @throws Exception */ @Test - public void testConverterDeltaState1() throws Exception + void converterDeltaState1() throws Exception { UIOutput output = new UIOutput(); output.setId("output1"); @@ -42,7 +43,7 @@ public void testConverterDeltaState1() throws Exception Object state1 = output.saveState(facesContext); // null delta expected - Assertions.assertNull(state1); + assertNull(state1); UIOutput output2 = new UIOutput(); output2.setId("output1"); @@ -53,11 +54,11 @@ public void testConverterDeltaState1() throws Exception output2.restoreState(facesContext, state1); // Check converter is not replaced, because it is not necessary - Assertions.assertEquals(converter2, output2.getConverter()); + assertEquals(converter2, output2.getConverter()); } - + @Test - public void testConverterDeltaState2() throws Exception + void converterDeltaState2() throws Exception { UIOutput output = new UIOutput(); output.setId("output1"); @@ -67,7 +68,7 @@ public void testConverterDeltaState2() throws Exception Object state1 = output.saveState(facesContext); // null delta expected - Assertions.assertNull(state1); + assertNull(state1); UIOutput output2 = new UIOutput(); output2.setId("output1"); @@ -78,11 +79,11 @@ public void testConverterDeltaState2() throws Exception output2.restoreState(facesContext, state1); // Check converter is not replaced, because it is not necessary - Assertions.assertEquals(converter2, output2.getConverter()); + assertEquals(converter2, output2.getConverter()); } - + @Test - public void testConverterDeltaState3() throws Exception + void converterDeltaState3() throws Exception { UIOutput output = new UIOutput(); output.setId("output1"); @@ -92,7 +93,7 @@ public void testConverterDeltaState3() throws Exception Object state1 = output.saveState(facesContext); // StateHolder only force always to save the state - Assertions.assertNotNull(state1); + assertNotNull(state1); UIOutput output2 = new UIOutput(); output2.setId("output1"); @@ -103,11 +104,11 @@ public void testConverterDeltaState3() throws Exception output2.restoreState(facesContext, state1); // Check converter IS replaced, because it should be always stored into the state - Assertions.assertNotSame(converter2, output2.getConverter()); + assertNotSame(converter2, output2.getConverter()); } - + @Test - public void testConverterDeltaState4() throws Exception + void converterDeltaState4() throws Exception { UIOutput output = new UIOutput(); output.setId("output1"); @@ -117,7 +118,7 @@ public void testConverterDeltaState4() throws Exception Object state1 = output.saveState(facesContext); // PartialStateHolder only save state if delta is null - Assertions.assertNull(state1); + assertNull(state1); UIOutput output2 = new UIOutput(); output2.setId("output1"); @@ -128,11 +129,11 @@ public void testConverterDeltaState4() throws Exception output2.restoreState(facesContext, state1); // Check converter is not replaced, because it is not necessary - Assertions.assertEquals(converter2, output2.getConverter()); + assertEquals(converter2, output2.getConverter()); } - + @Test - public void testConverterDeltaState5() throws Exception + void converterDeltaState5() throws Exception { UIOutput output = new UIOutput(); output.setId("output1"); @@ -142,7 +143,7 @@ public void testConverterDeltaState5() throws Exception Object state1 = output.saveState(facesContext); // PartialStateHolder only save state if delta is null - Assertions.assertNotNull(state1); + assertNotNull(state1); UIOutput output2 = new UIOutput(); output2.setId("output1"); @@ -153,11 +154,11 @@ public void testConverterDeltaState5() throws Exception output2.restoreState(facesContext, state1); // Check converter is not replaced, because it is not necessary (delta change) - Assertions.assertEquals(converter2, output2.getConverter()); + assertEquals(converter2, output2.getConverter()); } - + @Test - public void testConverterDeltaState6() throws Exception + void converterDeltaState6() throws Exception { UIOutput output = new UIOutput(); output.setId("output1"); @@ -170,8 +171,8 @@ public void testConverterDeltaState6() throws Exception Object[] state1 = (Object[])output.saveState(facesContext); // null delta expected - Assertions.assertNotNull(state1); - Assertions.assertEquals(state1.length, 1); + assertNotNull(state1); + assertEquals(1, state1.length); UIOutput output2 = new UIOutput(); output2.setId("output1"); @@ -182,14 +183,14 @@ public void testConverterDeltaState6() throws Exception output2.restoreState(facesContext, state1); // Check converter is not replaced, because it is not necessary - Assertions.assertEquals(converter2, output2.getConverter()); + assertEquals(converter2, output2.getConverter()); // Check parentDelta works - Assertions.assertEquals("style1", output2.getAttributes().get("style")); + assertEquals("style1", output2.getAttributes().get("style")); } @Test - public void testConverterDeltaState7() throws Exception + void converterDeltaState7() throws Exception { UIOutput output = new UIOutput(); output.setId("output1"); @@ -202,8 +203,8 @@ public void testConverterDeltaState7() throws Exception Object[] state1 = (Object[])output.saveState(facesContext); // null delta expected - Assertions.assertNotNull(state1); - Assertions.assertEquals(state1.length, 1); + assertNotNull(state1); + assertEquals(1, state1.length); UIOutput output2 = new UIOutput(); output2.setId("output1"); @@ -214,14 +215,14 @@ public void testConverterDeltaState7() throws Exception output2.restoreState(facesContext, state1); // Check converter is not replaced, because it is not necessary - Assertions.assertEquals(converter2, output2.getConverter()); + assertEquals(converter2, output2.getConverter()); // Check parentDelta works - Assertions.assertEquals("style1", output2.getAttributes().get("style")); + assertEquals("style1", output2.getAttributes().get("style")); } - + @Test - public void testConverterDeltaState8() throws Exception + void converterDeltaState8() throws Exception { UIOutput output = new UIOutput(); output.setId("output1"); @@ -234,10 +235,10 @@ public void testConverterDeltaState8() throws Exception Object[] state1 = (Object[])output.saveState(facesContext); // StateHolder force state - Assertions.assertNotNull(state1); - Assertions.assertEquals(state1.length, 2); - Assertions.assertNotNull(state1[1]); - Assertions.assertNotNull(state1[0]); + assertNotNull(state1); + assertEquals(2, state1.length); + assertNotNull(state1[1]); + assertNotNull(state1[0]); UIOutput output2 = new UIOutput(); output2.setId("output1"); @@ -248,14 +249,14 @@ public void testConverterDeltaState8() throws Exception output2.restoreState(facesContext, state1); // Check converter IS replaced, because it should be always stored into the state - Assertions.assertNotSame(converter2, output2.getConverter()); + assertNotSame(converter2, output2.getConverter()); // Check parentDelta works - Assertions.assertEquals("style1", output2.getAttributes().get("style")); + assertEquals("style1", output2.getAttributes().get("style")); } @Test - public void testConverterDeltaState9() throws Exception + void converterDeltaState9() throws Exception { UIOutput output = new UIOutput(); output.setId("output1"); @@ -268,8 +269,8 @@ public void testConverterDeltaState9() throws Exception Object[] state1 = (Object[])output.saveState(facesContext); // null delta expected - Assertions.assertNotNull(state1); - Assertions.assertEquals(state1.length, 1); + assertNotNull(state1); + assertEquals(1, state1.length); UIOutput output2 = new UIOutput(); output2.setId("output1"); @@ -280,14 +281,14 @@ public void testConverterDeltaState9() throws Exception output2.restoreState(facesContext, state1); // Check converter is not replaced, because it is not necessary - Assertions.assertEquals(converter2, output2.getConverter()); + assertEquals(converter2, output2.getConverter()); // Check parentDelta works - Assertions.assertEquals("style1", output2.getAttributes().get("style")); + assertEquals("style1", output2.getAttributes().get("style")); } - + @Test - public void testConverterDeltaState10() throws Exception + void converterDeltaState10() throws Exception { UIOutput output = new UIOutput(); output.setId("output1"); @@ -300,10 +301,10 @@ public void testConverterDeltaState10() throws Exception Object[] state1 = (Object[])output.saveState(facesContext); // PartialStateHolder force state only when there is delta - Assertions.assertNotNull(state1); - Assertions.assertEquals(state1.length, 2); - Assertions.assertNotNull(state1[1]); - Assertions.assertNotNull(state1[0]); + assertNotNull(state1); + assertEquals(2, state1.length); + assertNotNull(state1[1]); + assertNotNull(state1[0]); UIOutput output2 = new UIOutput(); output2.setId("output1"); @@ -314,19 +315,19 @@ public void testConverterDeltaState10() throws Exception output2.restoreState(facesContext, state1); // Check converter is not replaced, because it is not necessary (delta change) - Assertions.assertEquals(converter2, output2.getConverter()); + assertEquals(converter2, output2.getConverter()); // Check parentDelta works - Assertions.assertEquals("style1", output2.getAttributes().get("style")); + assertEquals("style1", output2.getAttributes().get("style")); } - + /** * Check set null converter after markInitialState case * * @throws Exception */ @Test - public void testConverterDeltaState11() throws Exception + void converterDeltaState11() throws Exception { Converter[] converters = new Converter[]{ new LongConverter(), @@ -354,10 +355,10 @@ public void testConverterDeltaState11() throws Exception Object[] state1 = (Object[])output.saveState(facesContext); // The null spot force state to be set. - Assertions.assertNotNull(state1); - Assertions.assertEquals(state1.length, 2); - Assertions.assertNull(state1[1]); // null spot in state means null Converter - Assertions.assertNotNull(state1[0]); //because _isConverterSet() + assertNotNull(state1); + assertEquals(2, state1.length); + assertNull(state1[1]); // null spot in state means null Converter + assertNotNull(state1[0]); //because _isConverterSet() UIOutput output2 = new UIOutput(); output2.setId("output1"); @@ -368,12 +369,12 @@ public void testConverterDeltaState11() throws Exception output2.restoreState(facesContext, state1); // Check converter is set to null - Assertions.assertNull(output2.getConverter()); + assertNull(output2.getConverter()); } } @Test - public void testConverterDeltaState12() throws Exception + void converterDeltaState12() throws Exception { UIOutput output = new UIOutput(); output.setId("output1"); @@ -384,7 +385,7 @@ public void testConverterDeltaState12() throws Exception // Transient means no state, but the effect is the converter disappear // (because is transient, and in Faces 1.2/1.1 that was the effect). - Assertions.assertNotNull(state1); + assertNotNull(state1); UIOutput output2 = new UIOutput(); output2.setId("output1"); @@ -395,11 +396,11 @@ public void testConverterDeltaState12() throws Exception output2.restoreState(facesContext, state1); // Check no converter should be found - Assertions.assertNull(output2.getConverter()); + assertNull(output2.getConverter()); } - + @Test - public void testConverterDeltaState13() throws Exception + void converterDeltaState13() throws Exception { UIOutput output = new UIOutput(); output.setId("output1"); @@ -410,7 +411,7 @@ public void testConverterDeltaState13() throws Exception // Transient means no state, but the effect is the converter disappear // (because is transient, and in Faces 1.2/1.1 that was the effect). - Assertions.assertNotNull(state1); + assertNotNull(state1); UIOutput output2 = new UIOutput(); output2.setId("output1"); @@ -421,7 +422,7 @@ public void testConverterDeltaState13() throws Exception output2.restoreState(facesContext, state1); // Check no converter should be found - Assertions.assertNull(output2.getConverter()); + assertNull(output2.getConverter()); } public static class LongSerializableConverter extends LongConverter implements Serializable diff --git a/impl/src/test/java/jakarta/faces/component/UISelectItemsTest.java b/impl/src/test/java/jakarta/faces/component/UISelectItemsTest.java index b01128d76a..fc0404fd49 100644 --- a/impl/src/test/java/jakarta/faces/component/UISelectItemsTest.java +++ b/impl/src/test/java/jakarta/faces/component/UISelectItemsTest.java @@ -19,24 +19,26 @@ package jakarta.faces.component; import org.apache.myfaces.core.api.shared.SelectItemsIterator; + import java.util.ArrayList; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.List; import jakarta.el.ValueExpression; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.apache.myfaces.test.el.MockValueExpression; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * Tests for UISelectItems. */ -public class UISelectItemsTest extends AbstractFacesTestCase +class UISelectItemsTest extends AbstractFacesTestCase { @Test - public void testStringListAsValue() + void stringListAsValue() { List value = new ArrayList(); value.add("#1"); @@ -59,11 +61,11 @@ public void testStringListAsValue() options.add((String) iter.next().getValue()); } - Assertions.assertEquals(value, options); + assertEquals(value, options); } - + @Test - public void testPrimitiveArrayAsValue() + void primitiveArrayAsValue() { int[] value = new int[3]; value[0] = 1; @@ -86,7 +88,7 @@ public void testPrimitiveArrayAsValue() options[i] = (Integer) iter.next().getValue(); // test equality - Assertions.assertEquals(value[i], options[i]); + assertEquals(value[i], options[i]); } } } diff --git a/impl/src/test/java/jakarta/faces/component/UISelectManyTest.java b/impl/src/test/java/jakarta/faces/component/UISelectManyTest.java index 84eebd8673..2a5d293e6d 100644 --- a/impl/src/test/java/jakarta/faces/component/UISelectManyTest.java +++ b/impl/src/test/java/jakarta/faces/component/UISelectManyTest.java @@ -18,13 +18,15 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Locale; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class UISelectManyTest extends AbstractFacesTestCase @@ -35,7 +37,7 @@ public UISelectManyTest() } @Test - public void testValidateRequiredNull() + void validateRequiredNull() { facesContext.getViewRoot().setLocale(_TEST_LOCALE); @@ -60,11 +62,11 @@ public void testValidateRequiredNull() selectMany.validateValue(facesContext, null); - Assertions.assertFalse(selectMany.isValid()); + assertFalse(selectMany.isValid()); } @Test - public void testValidateRequiredEmptyList() + void validateRequiredEmptyList() { facesContext.getViewRoot().setLocale(_TEST_LOCALE); @@ -89,11 +91,11 @@ public void testValidateRequiredEmptyList() selectMany.validateValue(facesContext, Collections.EMPTY_LIST); - Assertions.assertFalse(selectMany.isValid()); + assertFalse(selectMany.isValid()); } @Test - public void testValidateIntArray() + void validateIntArray() { facesContext.getViewRoot().setLocale(_TEST_LOCALE); @@ -117,11 +119,11 @@ public void testValidateIntArray() selectMany.validateValue(facesContext, new int[] { 2, 3 }); - Assertions.assertTrue(selectMany.isValid()); + assertTrue(selectMany.isValid()); } @Test - public void testValidateStringArray() + void validateStringArray() { facesContext.getViewRoot().setLocale(_TEST_LOCALE); @@ -145,11 +147,11 @@ public void testValidateStringArray() selectMany.validateValue(facesContext, new String[] { "2", "3" }); - Assertions.assertTrue(selectMany.isValid()); + assertTrue(selectMany.isValid()); } @Test - public void testValidateStringList() + void validateStringList() { facesContext.getViewRoot().setLocale(_TEST_LOCALE); @@ -173,7 +175,7 @@ public void testValidateStringList() selectMany.validateValue(facesContext, Arrays.asList("2", "3")); - Assertions.assertTrue(selectMany.isValid()); + assertTrue(selectMany.isValid()); } static private final Locale _TEST_LOCALE = new Locale("xx", "TEST"); diff --git a/impl/src/test/java/jakarta/faces/component/UISelectOneTest.java b/impl/src/test/java/jakarta/faces/component/UISelectOneTest.java index 72f06a018b..e6b032cbe1 100644 --- a/impl/src/test/java/jakarta/faces/component/UISelectOneTest.java +++ b/impl/src/test/java/jakarta/faces/component/UISelectOneTest.java @@ -18,18 +18,19 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.*; + import java.util.List; import java.util.Locale; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class UISelectOneTest extends AbstractFacesTestCase +class UISelectOneTest extends AbstractFacesTestCase { - + @Test - public void testValidateRequiredNull() + void validateRequiredNull() { facesContext.getViewRoot().setLocale(_TEST_LOCALE); @@ -54,12 +55,12 @@ public void testValidateRequiredNull() selectOne.validateValue(facesContext, null); - Assertions.assertFalse(selectOne.isValid()); - Assertions.assertEquals(1, facesContext.getMessageList().size()); + assertFalse(selectOne.isValid()); + assertEquals(1, facesContext.getMessageList().size()); } - + @Test - public void testValidateNotRequiredValid() + void validateNotRequiredValid() { facesContext.getViewRoot().setLocale(_TEST_LOCALE); @@ -84,12 +85,12 @@ public void testValidateNotRequiredValid() selectOne.validateValue(facesContext, 1); - Assertions.assertTrue(selectOne.isValid()); - Assertions.assertEquals(0, facesContext.getMessageList().size()); + assertTrue(selectOne.isValid()); + assertEquals(0, facesContext.getMessageList().size()); } - + @Test - public void testValidateNotRequiredNotValid() + void validateNotRequiredNotValid() { facesContext.getViewRoot().setLocale(_TEST_LOCALE); @@ -114,12 +115,12 @@ public void testValidateNotRequiredNotValid() selectOne.validateValue(facesContext, 4); - Assertions.assertFalse(selectOne.isValid()); - Assertions.assertEquals(1, facesContext.getMessageList().size()); + assertFalse(selectOne.isValid()); + assertEquals(1, facesContext.getMessageList().size()); } - + @Test - public void testValidateRequiredNotSelectOption() + void validateRequiredNotSelectOption() { facesContext.getViewRoot().setLocale(_TEST_LOCALE); @@ -145,12 +146,12 @@ public void testValidateRequiredNotSelectOption() selectOne.validateValue(facesContext, 3); - Assertions.assertFalse(selectOne.isValid()); - Assertions.assertEquals(1, facesContext.getMessageList().size()); + assertFalse(selectOne.isValid()); + assertEquals(1, facesContext.getMessageList().size()); } - + @Test - public void testValidateNotRequiredNotSelectOption() + void validateNotRequiredNotSelectOption() { facesContext.getViewRoot().setLocale(_TEST_LOCALE); @@ -176,15 +177,15 @@ public void testValidateNotRequiredNotSelectOption() selectOne.validateValue(facesContext, 3); - Assertions.assertTrue(selectOne.isValid()); - Assertions.assertEquals(0, facesContext.getMessageList().size()); + assertTrue(selectOne.isValid()); + assertEquals(0, facesContext.getMessageList().size()); } - + /** * MYFACES-4783: a grouped radio next to a UISelectOne without a group must not throw a NPE. */ @Test - public void testGroupedRadioNextToUngroupedSelectOne() + void groupedRadioNextToUngroupedSelectOne() { facesContext.getViewRoot().setLocale(_TEST_LOCALE); @@ -209,11 +210,11 @@ public void testGroupedRadioNextToUngroupedSelectOne() radio.getChildren().add(radioItem); form.getChildren().add(radio); - Assertions.assertDoesNotThrow(() -> radio.processValidators(facesContext)); + assertDoesNotThrow(() -> radio.processValidators(facesContext)); radio.validateValue(facesContext, "a"); - Assertions.assertTrue(radio.isValid()); - Assertions.assertEquals(0, facesContext.getMessageList().size()); + assertTrue(radio.isValid()); + assertEquals(0, facesContext.getMessageList().size()); } static private final Locale _TEST_LOCALE = new Locale("xx", "TEST"); diff --git a/impl/src/test/java/jakarta/faces/component/UIViewParameterTest.java b/impl/src/test/java/jakarta/faces/component/UIViewParameterTest.java index 4ef07e8715..a2f95c842f 100644 --- a/impl/src/test/java/jakarta/faces/component/UIViewParameterTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIViewParameterTest.java @@ -19,8 +19,11 @@ package jakarta.faces.component; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; + import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; + +import static org.junit.jupiter.api.Assertions.*; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -29,7 +32,7 @@ * * @since 2.0 */ -public class UIViewParameterTest extends AbstractFacesTestCase +class UIViewParameterTest extends AbstractFacesTestCase { private UIViewParameter viewParameter = null; @@ -59,21 +62,21 @@ public void tearDown() throws Exception * This is a special validation case only for UIViewParameter, so this has to be tested here. */ @Test - public void testValidationErrorTriggersFacesContextValidationFailed() + void validationErrorTriggersFacesContextValidationFailed() { viewParameter.setRequired(true); viewParameter.setSubmittedValue(null); - Assertions.assertFalse(facesContext.isValidationFailed()); + assertFalse(facesContext.isValidationFailed()); viewParameter.processValidators(facesContext); - Assertions.assertTrue(facesContext.isValidationFailed()); + assertTrue(facesContext.isValidationFailed()); } - + /** * Tests if UIViewParameter.decode() sets the submitted value only if it is not null. */ @Test - public void testDecodeSetOnlyNonNullSubmittedValue() + void decodeSetOnlyNonNullSubmittedValue() { String notNull = "not null"; viewParameter.setSubmittedValue(notNull); @@ -83,7 +86,7 @@ public void testDecodeSetOnlyNonNullSubmittedValue() viewParameter.decode(facesContext); - Assertions.assertEquals(viewParameter.getSubmittedValue(), notNull); + assertEquals(viewParameter.getSubmittedValue(), notNull); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIViewRootTest.java b/impl/src/test/java/jakarta/faces/component/UIViewRootTest.java index 0de4481b08..dccd732197 100644 --- a/impl/src/test/java/jakarta/faces/component/UIViewRootTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIViewRootTest.java @@ -21,6 +21,7 @@ import static org.easymock.EasyMock.aryEq; import static org.easymock.EasyMock.eq; import static org.easymock.EasyMock.expect; +import static org.junit.jupiter.api.Assertions.*; import java.lang.reflect.Method; import java.util.Collection; @@ -52,12 +53,11 @@ import org.easymock.classextension.EasyMock; import org.easymock.classextension.IMocksControl; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; -public class UIViewRootTest extends AbstractFacesTestCase +class UIViewRootTest extends AbstractFacesTestCase { private Map> phaseListenerClasses; private IMocksControl _mocksControl; @@ -110,28 +110,28 @@ public void tearDown() throws Exception } @Test - public void testSuperClass() throws Exception + void superClass() throws Exception { - Assertions.assertEquals(UIComponentBase.class, UIViewRoot.class.getSuperclass()); + assertEquals(UIComponentBase.class, UIViewRoot.class.getSuperclass()); } @Test - public void testComponentType() throws Exception + void componentType() throws Exception { - Assertions.assertEquals("jakarta.faces.ViewRoot", UIViewRoot.COMPONENT_TYPE); + assertEquals("jakarta.faces.ViewRoot", UIViewRoot.COMPONENT_TYPE); } @Test - public void testLocale() throws Exception + void locale() throws Exception { expect(_application.getViewHandler()).andReturn(_viewHandler).anyTimes(); expect(_viewHandler.calculateLocale(_facesContext)).andReturn(null).anyTimes(); _mocksControl.replay(); _facesContext.setApplication(_application); - Assertions.assertNull(_testimpl.getLocale()); + assertNull(_testimpl.getLocale()); _testimpl.setLocale(Locale.JAPANESE); - Assertions.assertEquals(Locale.JAPANESE, _testimpl.getLocale()); + assertEquals(Locale.JAPANESE, _testimpl.getLocale()); _mocksControl.verify(); } @@ -139,7 +139,7 @@ public void testLocale() throws Exception * Test method for {@link jakarta.faces.component.UIViewRoot#createUniqueId()}. */ @Test - public void testCreateUniqueId() + void createUniqueId() { /* expect(_externalContext.encodeNamespace((String) anyObject())).andAnswer(new IAnswer() @@ -155,7 +155,7 @@ public String answer() throws Throwable { if (!createdIds.add(_testimpl.createUniqueId())) { - Assertions.fail("duplicate id created"); + fail("duplicate id created"); } } _mocksControl.verify(); @@ -564,7 +564,7 @@ public PhaseId getPhaseId() } @Test - public void testBroadcastEvents() + void broadcastEvents() { UICommand uiCommand = new UICommand(); @@ -596,7 +596,7 @@ public void testBroadcastEvents() // listener itself queues new event facesContext.getViewRoot().broadcastEvents(facesContext, PhaseId.INVOKE_APPLICATION); - Assertions.assertEquals(15, actionListener.invocationCount); + assertEquals(15, actionListener.invocationCount); org.easymock.EasyMock.verify(differentActionListener); } diff --git a/impl/src/test/java/jakarta/faces/component/_AttachedListStateWrapperTest.java b/impl/src/test/java/jakarta/faces/component/_AttachedListStateWrapperTest.java index b5737bba19..d3c1887756 100644 --- a/impl/src/test/java/jakarta/faces/component/_AttachedListStateWrapperTest.java +++ b/impl/src/test/java/jakarta/faces/component/_AttachedListStateWrapperTest.java @@ -19,6 +19,8 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.*; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; @@ -26,25 +28,24 @@ import java.util.ArrayList; import java.util.List; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class _AttachedListStateWrapperTest +class _AttachedListStateWrapperTest { /* * Test method for 'jakarta.faces.component._AttachedListStateWrapper._AttachedListStateWrapper(List)' */ @Test - public void test_AttachedListStateWrapper() + void attached_list_state_wrapper() { List foo = new ArrayList(); _AttachedListStateWrapper subject = new _AttachedListStateWrapper(foo); - Assertions.assertNotNull(subject.getWrappedStateList()); - Assertions.assertTrue(subject.getWrappedStateList() == foo); + assertNotNull(subject.getWrappedStateList()); + assertSame(subject.getWrappedStateList(), foo); } @Test - public void testSerialize() throws Exception + void serialize() throws Exception { String foo = "foo"; List list = new ArrayList(); @@ -58,7 +59,7 @@ public void testSerialize() throws Exception ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); _AttachedListStateWrapper blorg = (_AttachedListStateWrapper) ois.readObject(); - Assertions.assertEquals(blorg.getWrappedStateList(), subject.getWrappedStateList()); + assertEquals(blorg.getWrappedStateList(), subject.getWrappedStateList()); oos.close(); ois.close(); } diff --git a/impl/src/test/java/jakarta/faces/component/_AttachedStateWrapperTest.java b/impl/src/test/java/jakarta/faces/component/_AttachedStateWrapperTest.java index 9f8b5b51e4..143dd033b7 100644 --- a/impl/src/test/java/jakarta/faces/component/_AttachedStateWrapperTest.java +++ b/impl/src/test/java/jakarta/faces/component/_AttachedStateWrapperTest.java @@ -19,49 +19,51 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class _AttachedStateWrapperTest +class _AttachedStateWrapperTest { /* * Test method for 'jakarta.faces.component._AttachedStateWrapper._AttachedStateWrapper(Class, Object)' */ @Test - public void test_AttachedStateWrapper() + void attached_state_wrapper() { _AttachedStateWrapper subject = new _AttachedStateWrapper(null, null); - Assertions.assertNull(subject.getWrappedStateObject()); - Assertions.assertNull(subject.getClazz()); + assertNull(subject.getWrappedStateObject()); + assertNull(subject.getClazz()); } /* * Test method for 'jakarta.faces.component._AttachedStateWrapper.getClazz()' */ @Test - public void testGetClazz() + void getClazz() { _AttachedStateWrapper subject = new _AttachedStateWrapper(String.class, "foo"); - Assertions.assertEquals(subject.getClazz(), String.class); + assertEquals(String.class, subject.getClazz()); } /* * Test method for 'jakarta.faces.component._AttachedStateWrapper.getWrappedStateObject()' */ @Test - public void testGetWrappedStateObject() + void getWrappedStateObject() { _AttachedStateWrapper subject = new _AttachedStateWrapper(String.class, "foo"); - Assertions.assertEquals(subject.getClazz(), String.class); + assertEquals(String.class, subject.getClazz()); } @Test - public void testSerialize() throws Exception + void serialize() throws Exception { String foo = "foo"; _AttachedStateWrapper subject = new _AttachedStateWrapper(String.class, foo); @@ -73,7 +75,7 @@ public void testSerialize() throws Exception ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); _AttachedStateWrapper blorg = (_AttachedStateWrapper) ois.readObject(); - Assertions.assertEquals(blorg.getWrappedStateObject(), subject.getWrappedStateObject()); + assertEquals(blorg.getWrappedStateObject(), subject.getWrappedStateObject()); oos.close(); ois.close(); } diff --git a/impl/src/test/java/jakarta/faces/component/_ComponentUtilsTest.java b/impl/src/test/java/jakarta/faces/component/_ComponentUtilsTest.java index 23d0e2a42c..774df09727 100644 --- a/impl/src/test/java/jakarta/faces/component/_ComponentUtilsTest.java +++ b/impl/src/test/java/jakarta/faces/component/_ComponentUtilsTest.java @@ -22,26 +22,28 @@ import org.apache.myfaces.test.mock.MockRenderedValueExpression; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; + import org.junit.jupiter.api.Test; -public class _ComponentUtilsTest extends AbstractFacesTestCase { +import static org.junit.jupiter.api.Assertions.*; + +class _ComponentUtilsTest extends AbstractFacesTestCase { @Test - public void testIsRendered() { + void isRendered() { UIComponent uiComponent = new UIOutput(); boolean rendered = ComponentUtils.isRendered(facesContext, uiComponent); - Assertions.assertTrue(rendered); + assertTrue(rendered); uiComponent.setRendered(false); rendered = ComponentUtils.isRendered(facesContext, uiComponent); - Assertions.assertFalse(rendered); + assertFalse(rendered); UIOutput uiOutput = new UIOutput(); UIComponent parent = MockRenderedValueExpression.setUpComponentStack(facesContext, uiOutput, false); rendered = ComponentUtils.isRendered(facesContext, uiComponent); - Assertions.assertFalse(rendered); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "isRendered must not change current component"); + assertFalse(rendered); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext), "isRendered must not change current component"); } } diff --git a/impl/src/test/java/jakarta/faces/component/_Delta2StateHelperTest.java b/impl/src/test/java/jakarta/faces/component/_Delta2StateHelperTest.java index 164324098a..0ae30e9319 100644 --- a/impl/src/test/java/jakarta/faces/component/_Delta2StateHelperTest.java +++ b/impl/src/test/java/jakarta/faces/component/_Delta2StateHelperTest.java @@ -18,6 +18,8 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.*; + import java.util.List; import java.util.Map; @@ -27,11 +29,10 @@ import jakarta.faces.event.PhaseId; import jakarta.faces.event.PhaseListener; import org.apache.myfaces.test.el.MockValueExpression; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class _Delta2StateHelperTest extends AbstractComponentTest +class _Delta2StateHelperTest extends AbstractComponentTest { public static class UITestComponent extends UIComponentBase @@ -121,18 +122,18 @@ public Object saveState(FacesContext context) } @Test - public void testSimpleGetterSetter() throws Exception + void simpleGetterSetter() throws Exception { UITestComponent a = new UITestComponent(); - Assertions.assertNull(a.getTestProperty1()); + assertNull(a.getTestProperty1()); a.setTestProperty1("testProperty1"); - Assertions.assertEquals("testProperty1", a.getTestProperty1()); + assertEquals("testProperty1", a.getTestProperty1()); a.setTestProperty1(null); - Assertions.assertNull(a.getTestProperty1()); + assertNull(a.getTestProperty1()); } - + @Test - public void testEmptySaveRestore() throws Exception + void emptySaveRestore() throws Exception { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -143,12 +144,12 @@ public void testEmptySaveRestore() throws Exception Object state2 = b.saveState(facesContext); - Assertions.assertEquals(a.getTestProperty1(), b.getTestProperty1()); - Assertions.assertEquals(a.getTestProperty2(), b.getTestProperty2()); + assertEquals(a.getTestProperty1(), b.getTestProperty1()); + assertEquals(a.getTestProperty2(), b.getTestProperty2()); } - + @Test - public void testSimpleSaveRestore() throws Exception + void simpleSaveRestore() throws Exception { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -161,12 +162,12 @@ public void testSimpleSaveRestore() throws Exception Object state2 = b.saveState(facesContext); - Assertions.assertEquals(a.getTestProperty1(), b.getTestProperty1()); - Assertions.assertEquals(a.getTestProperty2(), b.getTestProperty2()); + assertEquals(a.getTestProperty1(), b.getTestProperty1()); + assertEquals(a.getTestProperty2(), b.getTestProperty2()); } - + @Test - public void testDeltaStateSaveRestore() + void deltaStateSaveRestore() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -190,14 +191,14 @@ public void testDeltaStateSaveRestore() Object state2 = b.saveState(facesContext); - Assertions.assertNull(a.getTestProperty1()); - Assertions.assertNull(b.getTestProperty1()); - Assertions.assertEquals("testProperty2", a.getTestProperty2()); - Assertions.assertEquals("testProperty2", b.getTestProperty2()); + assertNull(a.getTestProperty1()); + assertNull(b.getTestProperty1()); + assertEquals("testProperty2", a.getTestProperty2()); + assertEquals("testProperty2", b.getTestProperty2()); } - + @Test - public void testPutPropertyStateHelper1() + void putPropertyStateHelper1() { UITestComponent a = new UITestComponent(); @@ -205,32 +206,32 @@ public void testPutPropertyStateHelper1() Object retValue = helper.put("someProperty", "someValue"); //No value previously set - Assertions.assertNull(retValue); + assertNull(retValue); a.markInitialState(); retValue = helper.put("someProperty", "someOtherValue"); - Assertions.assertEquals("someValue",retValue); + assertEquals("someValue",retValue); retValue = helper.put("someProperty", "someOtherOtherValue"); - Assertions.assertEquals("someOtherValue",retValue); + assertEquals("someOtherValue",retValue); a.clearInitialState(); retValue = helper.put("someProperty", "someOtherOtherOtherValue"); - Assertions.assertEquals("someOtherOtherValue",retValue); + assertEquals("someOtherOtherValue",retValue); } - @Test // https://issues.apache.org/jira/browse/MYFACES-4590 - public void testPropertyWithDefault() + @Test + void propertyWithDefault() { UITestComponent a = new UITestComponent(); - Assertions.assertEquals(Long.MAX_VALUE, a.getTestPropertyWithDefault(), + assertEquals(Long.MAX_VALUE, a.getTestPropertyWithDefault(), "Property should be Long.MAX_VALUE from default)"); ValueExpression valueExpression = new MockValueExpression("#{testPropertyWithDefault}", Object.class); @@ -238,22 +239,22 @@ public void testPropertyWithDefault() Map applicationMap = externalContext.getApplicationMap(); applicationMap.put("testPropertyWithDefault", 100L); - Assertions.assertEquals(100L, a.getTestPropertyWithDefault(), + assertEquals(100L, a.getTestPropertyWithDefault(), "Property should be 100L from expression"); applicationMap.remove("testPropertyWithDefault"); - Assertions.assertEquals(Long.MAX_VALUE, a.getStateHelper().eval("testPropertyWithDefault", Long.MAX_VALUE), + assertEquals(Long.MAX_VALUE, a.getStateHelper().eval("testPropertyWithDefault", Long.MAX_VALUE), "Value from stateHelper should be Long.MAX_VALUE from default"); - Assertions.assertEquals(Long.MAX_VALUE, a.getStateHelper().eval("testPropertyWithDefault", () -> Long.MAX_VALUE), + assertEquals(Long.MAX_VALUE, a.getStateHelper().eval("testPropertyWithDefault", () -> Long.MAX_VALUE), "Value from stateHelper should be Long.MAX_VALUE from default"); - Assertions.assertEquals(Long.MAX_VALUE, a.getTestPropertyWithDefault(), + assertEquals(Long.MAX_VALUE, a.getTestPropertyWithDefault(), "Property should be Long.MAX_VALUE from default"); } - + @Test - public void testPutPropertyStateHelper2() + void putPropertyStateHelper2() { UITestComponent a = new UITestComponent(); @@ -261,27 +262,27 @@ public void testPutPropertyStateHelper2() Object retValue = helper.put("someProperty", "someValue"); //No value previously set - Assertions.assertNull(retValue); + assertNull(retValue); a.markInitialState(); retValue = helper.put("someProperty", null); - Assertions.assertEquals("someValue",retValue); + assertEquals("someValue",retValue); retValue = helper.put("someProperty", "someOtherOtherValue"); - Assertions.assertNull(retValue); + assertNull(retValue); a.clearInitialState(); retValue = helper.put("someProperty", null); - Assertions.assertEquals("someOtherOtherValue",retValue); + assertEquals("someOtherOtherValue",retValue); } - + @Test - public void testRemovePropertyStateHelper1() + void removePropertyStateHelper1() { UITestComponent a = new UITestComponent(); @@ -289,27 +290,27 @@ public void testRemovePropertyStateHelper1() Object retValue = helper.put("someProperty", "someValue"); //No value previously set - Assertions.assertNull(retValue); + assertNull(retValue); a.markInitialState(); retValue = helper.remove("someProperty"); - Assertions.assertEquals("someValue",retValue); + assertEquals("someValue",retValue); retValue = helper.put("someProperty", "someOtherOtherValue"); - Assertions.assertNull(retValue); + assertNull(retValue); a.clearInitialState(); retValue = helper.remove("someProperty"); - Assertions.assertEquals("someOtherOtherValue",retValue); + assertEquals("someOtherOtherValue",retValue); } - + @Test - public void testAddItemOnList1() + void addItemOnList1() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -329,19 +330,19 @@ public void testAddItemOnList1() List listA = (List) helperA.get("somePropertyList"); - Assertions.assertEquals("someValue1",listA.get(0)); - Assertions.assertEquals("someValue2",listA.get(1)); - Assertions.assertEquals("someValue3",listA.get(2)); + assertEquals("someValue1",listA.get(0)); + assertEquals("someValue2",listA.get(1)); + assertEquals("someValue3",listA.get(2)); List listB = (List) helperB.get("somePropertyList"); - Assertions.assertEquals("someValue1",listB.get(0)); - Assertions.assertEquals("someValue2",listB.get(1)); - Assertions.assertEquals("someValue3",listB.get(2)); + assertEquals("someValue1",listB.get(0)); + assertEquals("someValue2",listB.get(1)); + assertEquals("someValue3",listB.get(2)); } - + @Test - public void testAddItemOnList2() + void addItemOnList2() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -366,21 +367,21 @@ public void testAddItemOnList2() if (listA != null) { - Assertions.assertFalse(listA.contains("someValue1")); - Assertions.assertFalse(listA.contains("someValue2")); + assertFalse(listA.contains("someValue1")); + assertFalse(listA.contains("someValue2")); } List listB = (List) helperB.get("somePropertyList"); if (listB != null) { - Assertions.assertFalse(listB.contains("someValue2")); - Assertions.assertFalse(listB.contains("someValue1")); + assertFalse(listB.contains("someValue2")); + assertFalse(listB.contains("someValue1")); } } - + @Test - public void testAddItemOnList3() + void addItemOnList3() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -403,19 +404,19 @@ public void testAddItemOnList3() List listA = (List) helperA.get("somePropertyList"); - Assertions.assertTrue(listA.contains("someValue3")); - Assertions.assertFalse(listA.contains("someValue1")); - Assertions.assertFalse(listA.contains("someValue2")); + assertTrue(listA.contains("someValue3")); + assertFalse(listA.contains("someValue1")); + assertFalse(listA.contains("someValue2")); List listB = (List) helperB.get("somePropertyList"); - Assertions.assertTrue(listB.contains("someValue3")); - Assertions.assertFalse(listB.contains("someValue2")); - Assertions.assertFalse(listB.contains("someValue1")); - } - + assertTrue(listB.contains("someValue3")); + assertFalse(listB.contains("someValue2")); + assertFalse(listB.contains("someValue1")); + } + @Test - public void testPutItemOnMap1() + void putItemOnMap1() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -435,19 +436,19 @@ public void testPutItemOnMap1() Map mapA = (Map) helperA.get("somePropertyMap"); - Assertions.assertEquals("someValue1",mapA.get("key1")); - Assertions.assertEquals("someValue2",mapA.get("key2")); - Assertions.assertEquals("someValue3",mapA.get("key3")); + assertEquals("someValue1",mapA.get("key1")); + assertEquals("someValue2",mapA.get("key2")); + assertEquals("someValue3",mapA.get("key3")); Map mapB = (Map) helperB.get("somePropertyMap"); - Assertions.assertEquals("someValue1",mapB.get("key1")); - Assertions.assertEquals("someValue2",mapB.get("key2")); - Assertions.assertEquals("someValue3",mapB.get("key3")); + assertEquals("someValue1",mapB.get("key1")); + assertEquals("someValue2",mapB.get("key2")); + assertEquals("someValue3",mapB.get("key3")); } - + @Test - public void testPutRemoveItemOnMap2() + void putRemoveItemOnMap2() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -471,21 +472,21 @@ public void testPutRemoveItemOnMap2() if (mapA != null) { - Assertions.assertNull(mapA.get("key2")); - Assertions.assertNull(mapA.get("key1")); + assertNull(mapA.get("key2")); + assertNull(mapA.get("key1")); } Map mapB = (Map) helperB.get("somePropertyMap"); if (mapB != null) { - Assertions.assertNull(mapB.get("key2")); - Assertions.assertNull(mapB.get("key1")); + assertNull(mapB.get("key2")); + assertNull(mapB.get("key1")); } } - + @Test - public void testPutRemoveItemOnMap3() + void putRemoveItemOnMap3() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -510,16 +511,16 @@ public void testPutRemoveItemOnMap3() if (mapA != null) { - Assertions.assertNull(mapA.get("key2")); - Assertions.assertNull(mapA.get("key1")); + assertNull(mapA.get("key2")); + assertNull(mapA.get("key1")); } Map mapB = (Map) helperB.get("somePropertyMap"); if (mapB != null) { - Assertions.assertNull(mapB.get("key2")); - Assertions.assertNull(mapB.get("key1")); + assertNull(mapB.get("key2")); + assertNull(mapB.get("key1")); } } @@ -575,10 +576,10 @@ public boolean equals(Object obj) } return false; } - } - + } + @Test - public void testUIViewRootPhaseListener1() throws Exception + void uIViewRootPhaseListener1() throws Exception { UIViewRoot a = new UIViewRoot(); UIViewRoot b = new UIViewRoot(); @@ -589,12 +590,12 @@ public void testUIViewRootPhaseListener1() throws Exception b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(a.getPhaseListeners().contains(phaseListener1)); - Assertions.assertTrue(b.getPhaseListeners().contains(phaseListener1)); + assertTrue(a.getPhaseListeners().contains(phaseListener1)); + assertTrue(b.getPhaseListeners().contains(phaseListener1)); } - + @Test - public void testUIViewRootPhaseListener2() throws Exception + void uIViewRootPhaseListener2() throws Exception { UIViewRoot a = new UIViewRoot(); UIViewRoot b = new UIViewRoot(); @@ -608,12 +609,12 @@ public void testUIViewRootPhaseListener2() throws Exception b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(a.getPhaseListeners().contains(phaseListener1)); - Assertions.assertTrue(b.getPhaseListeners().contains(phaseListener1)); + assertTrue(a.getPhaseListeners().contains(phaseListener1)); + assertTrue(b.getPhaseListeners().contains(phaseListener1)); } - + @Test - public void testUIViewRootPhaseListener3() throws Exception + void uIViewRootPhaseListener3() throws Exception { UIViewRoot a = new UIViewRoot(); UIViewRoot b = new UIViewRoot(); @@ -634,19 +635,19 @@ public void testUIViewRootPhaseListener3() throws Exception b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(a.getPhaseListeners().contains(phaseListener1)); - Assertions.assertTrue(b.getPhaseListeners().contains(phaseListener1)); - Assertions.assertTrue(a.getPhaseListeners().contains(phaseListener2)); - Assertions.assertTrue(b.getPhaseListeners().contains(phaseListener2)); + assertTrue(a.getPhaseListeners().contains(phaseListener1)); + assertTrue(b.getPhaseListeners().contains(phaseListener1)); + assertTrue(a.getPhaseListeners().contains(phaseListener2)); + assertTrue(b.getPhaseListeners().contains(phaseListener2)); a.removePhaseListener(phaseListener1); a.removePhaseListener(phaseListener2); c.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertFalse(a.getPhaseListeners().contains(phaseListener1)); - Assertions.assertFalse(c.getPhaseListeners().contains(phaseListener1)); - Assertions.assertFalse(a.getPhaseListeners().contains(phaseListener2)); - Assertions.assertFalse(c.getPhaseListeners().contains(phaseListener2)); + assertFalse(a.getPhaseListeners().contains(phaseListener1)); + assertFalse(c.getPhaseListeners().contains(phaseListener1)); + assertFalse(a.getPhaseListeners().contains(phaseListener2)); + assertFalse(c.getPhaseListeners().contains(phaseListener2)); } } diff --git a/impl/src/test/java/jakarta/faces/component/_DeltaFacesListenerListTest.java b/impl/src/test/java/jakarta/faces/component/_DeltaFacesListenerListTest.java index acd0926d96..9b26c2e9cb 100644 --- a/impl/src/test/java/jakarta/faces/component/_DeltaFacesListenerListTest.java +++ b/impl/src/test/java/jakarta/faces/component/_DeltaFacesListenerListTest.java @@ -18,13 +18,14 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.*; + import java.util.Arrays; import jakarta.faces.context.FacesContext; import jakarta.faces.event.FacesListener; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class _DeltaFacesListenerListTest extends AbstractComponentTest +class _DeltaFacesListenerListTest extends AbstractComponentTest { public static class UITestComponent extends UIComponentBase @@ -179,18 +180,18 @@ public void markInitialState() } @Test - public void testSimpleAddRemove() + void simpleAddRemove() { UITestComponent a = new UITestComponent(); FacesListener listener1 = new NoStateFacesListener(); a.addFacesListener(listener1); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); a.removeFacesListener(listener1); - Assertions.assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); } - + @Test - public void testSimpleSaveRestore1() + void simpleSaveRestore1() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -198,16 +199,16 @@ public void testSimpleSaveRestore1() a.addFacesListener(listener1); b.addFacesListener(listener1); b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); a.removeFacesListener(listener1); b.removeFacesListener(listener1); - Assertions.assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); } - + @Test - public void testSimpleSaveRestore2() + void simpleSaveRestore2() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -217,16 +218,16 @@ public void testSimpleSaveRestore2() a.addFacesListener(listener1); Object [] savedState1 = (Object[]) a.saveState(facesContext); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); a.removeFacesListener(listener1); b.removeFacesListener(listener1); - Assertions.assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); } - + @Test - public void testSimpleSaveRestore3() + void simpleSaveRestore3() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -237,18 +238,18 @@ public void testSimpleSaveRestore3() a.markInitialState(); b.markInitialState(); Object [] savedState1 = (Object[]) a.saveState(facesContext); - Assertions.assertNull(savedState1 == null ? null : savedState1[1]); + assertNull(savedState1 == null ? null : savedState1[1]); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); a.removeFacesListener(listener1); b.removeFacesListener(listener1); - Assertions.assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); } - + @Test - public void testSimpleSaveRestore4() + void simpleSaveRestore4() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -260,22 +261,22 @@ public void testSimpleSaveRestore4() b.markInitialState(); a.addFacesListener(listener2); b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); a.removeFacesListener(listener1); b.removeFacesListener(listener1); a.removeFacesListener(listener2); b.removeFacesListener(listener2); - Assertions.assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); + assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); } - + @Test - public void testSimpleSaveRestore5() + void simpleSaveRestore5() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -288,29 +289,29 @@ public void testSimpleSaveRestore5() b.markInitialState(); a.addFacesListener(listener2); b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); a.removeFacesListener(listener1); b.removeFacesListener(listener1); a.removeFacesListener(listener2); b.removeFacesListener(listener2); - Assertions.assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); + assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); //Save fully b.clearInitialState(); c.restoreState(facesContext, b.saveState(facesContext)); //c._facesListeners should be empty - Assertions.assertFalse(Arrays.asList(c.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(c.getFacesListeners(FacesListener.class)).contains(listener2)); + assertFalse(Arrays.asList(c.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(c.getFacesListeners(FacesListener.class)).contains(listener2)); } - + @Test - public void testSimpleSaveRestore6() + void simpleSaveRestore6() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -325,18 +326,18 @@ public void testSimpleSaveRestore6() Object [] savedState1 = (Object[]) a.saveState(facesContext); // This is not null because StateFacesListener is instance of StateHolder // and always needs to be saved and restored! - Assertions.assertNotNull(savedState1[0]); + assertNotNull(savedState1[0]); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); a.removeFacesListener(listener1); b.removeFacesListener(listener1); - Assertions.assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); } - + @Test - public void testSimpleSaveRestore7() + void simpleSaveRestore7() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -351,29 +352,29 @@ public void testSimpleSaveRestore7() b.markInitialState(); a.addFacesListener(listener2); b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); a.removeFacesListener(listener1); b.removeFacesListener(listener1); a.removeFacesListener(listener2); b.removeFacesListener(listener2); - Assertions.assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); + assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); //Save fully b.clearInitialState(); c.restoreState(facesContext, b.saveState(facesContext)); //c._facesListeners should be empty - Assertions.assertFalse(Arrays.asList(c.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(c.getFacesListeners(FacesListener.class)).contains(listener2)); + assertFalse(Arrays.asList(c.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(c.getFacesListeners(FacesListener.class)).contains(listener2)); } - + @Test - public void testSimpleSaveRestore8() + void simpleSaveRestore8() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -385,18 +386,18 @@ public void testSimpleSaveRestore8() b.markInitialState(); Object [] savedState1 = (Object[]) a.saveState(facesContext); // This is null because StateFacesListener is instance of PartialStateHolder - Assertions.assertNull(savedState1 == null ? null : savedState1[1]); + assertNull(savedState1 == null ? null : savedState1[1]); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); a.removeFacesListener(listener1); b.removeFacesListener(listener1); - Assertions.assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); } - + @Test - public void testSimpleSaveRestore9() + void simpleSaveRestore9() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -412,22 +413,22 @@ public void testSimpleSaveRestore9() Object [] savedState1 = (Object[]) a.saveState(facesContext); // This is null because StateFacesListener is instance of PartialStateHolder but a // listener was added after markInitialState - Assertions.assertNotNull(savedState1[0]); + assertNotNull(savedState1[0]); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); a.removeFacesListener(listener1); b.removeFacesListener(listener1); - Assertions.assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); - } - + assertFalse(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); + } + @Test - public void testSimpleSaveRestoreTransient1() + void simpleSaveRestoreTransient1() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -436,12 +437,12 @@ public void testSimpleSaveRestoreTransient1() listener1.setValue("value"); a.addFacesListener(listener1); b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); } - + @Test - public void testSimpleSaveRestoreTransient2() + void simpleSaveRestoreTransient2() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -452,12 +453,12 @@ public void testSimpleSaveRestoreTransient2() listener1.setValue("value"); a.addFacesListener(listener1); b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); } - + @Test - public void testSimpleSaveRestoreTransient3() + void simpleSaveRestoreTransient3() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -471,12 +472,12 @@ public void testSimpleSaveRestoreTransient3() listener1.setValue("value"); a.addFacesListener(listener1); b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); } - + @Test - public void testSimpleSaveRestoreTransient4() + void simpleSaveRestoreTransient4() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -490,12 +491,12 @@ public void testSimpleSaveRestoreTransient4() //Since listener1 is transient Object [] savedState1 = (Object[]) a.saveState(facesContext); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertFalse(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); } - + @Test - public void testComplexSaveRestore1() + void complexSaveRestore1() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -513,11 +514,11 @@ public void testComplexSaveRestore1() //Since listener1 is transient Object [] savedState1 = (Object[]) a.saveState(facesContext); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); - Assertions.assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener3)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); - Assertions.assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener3)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener2)); + assertTrue(Arrays.asList(a.getFacesListeners(FacesListener.class)).contains(listener3)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener1)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener2)); + assertTrue(Arrays.asList(b.getFacesListeners(FacesListener.class)).contains(listener3)); } } diff --git a/impl/src/test/java/jakarta/faces/component/_DeltaListTest.java b/impl/src/test/java/jakarta/faces/component/_DeltaListTest.java index 717745587c..517fb9e653 100644 --- a/impl/src/test/java/jakarta/faces/component/_DeltaListTest.java +++ b/impl/src/test/java/jakarta/faces/component/_DeltaListTest.java @@ -18,6 +18,8 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.*; + import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Iterator; @@ -25,10 +27,9 @@ import jakarta.faces.context.FacesContext; import jakarta.faces.event.FacesListener; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class _DeltaListTest extends AbstractComponentTest +class _DeltaListTest extends AbstractComponentTest { public static class UITestComponent extends UIComponentBase @@ -47,7 +48,7 @@ public String getFamily() public void addTestFacesListener(FacesListener listener) { - Assertions.assertNotNull(listener); + assertNotNull(listener); if (_facesListeners == null) { @@ -58,7 +59,7 @@ public void addTestFacesListener(FacesListener listener) public FacesListener[] getTestFacesListeners(Class clazz) { - Assertions.assertNotNull(clazz); + assertNotNull(clazz); if (!FacesListener.class.isAssignableFrom(clazz)) { @@ -387,18 +388,18 @@ public void markInitialState() } @Test - public void testSimpleAddRemove() + void simpleAddRemove() { UITestComponent a = new UITestComponent(); FacesListener listener1 = new NoStateFacesListener(); a.addTestFacesListener(listener1); - Assertions.assertTrue(a._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener1)); a.removeTestFacesListener(listener1); - Assertions.assertFalse(a._facesListeners.contains(listener1)); + assertFalse(a._facesListeners.contains(listener1)); } - + @Test - public void testSimpleSaveRestore1() + void simpleSaveRestore1() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -406,16 +407,16 @@ public void testSimpleSaveRestore1() a.addTestFacesListener(listener1); b.addTestFacesListener(listener1); b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertTrue(b._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener1)); + assertTrue(b._facesListeners.contains(listener1)); a.removeTestFacesListener(listener1); b.removeTestFacesListener(listener1); - Assertions.assertFalse(a._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); + assertFalse(a._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener1)); } - + @Test - public void testSimpleSaveRestore2() + void simpleSaveRestore2() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -425,16 +426,16 @@ public void testSimpleSaveRestore2() a.addTestFacesListener(listener1); Object [] savedState1 = (Object[]) a.saveState(facesContext); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertTrue(b._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener1)); + assertTrue(b._facesListeners.contains(listener1)); a.removeTestFacesListener(listener1); b.removeTestFacesListener(listener1); - Assertions.assertFalse(a._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); + assertFalse(a._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener1)); } - + @Test - public void testSimpleSaveRestore3() + void simpleSaveRestore3() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -446,16 +447,16 @@ public void testSimpleSaveRestore3() b.markInitialState(); Object [] savedState1 = (Object[]) a.saveState(facesContext); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertTrue(b._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener1)); + assertTrue(b._facesListeners.contains(listener1)); a.removeTestFacesListener(listener1); b.removeTestFacesListener(listener1); - Assertions.assertFalse(a._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); + assertFalse(a._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener1)); } - + @Test - public void testSimpleSaveRestore4() + void simpleSaveRestore4() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -467,22 +468,22 @@ public void testSimpleSaveRestore4() b.markInitialState(); a.addTestFacesListener(listener2); b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertTrue(a._facesListeners.contains(listener2)); - Assertions.assertTrue(b._facesListeners.contains(listener1)); - Assertions.assertTrue(b._facesListeners.contains(listener2)); + assertTrue(a._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener2)); + assertTrue(b._facesListeners.contains(listener1)); + assertTrue(b._facesListeners.contains(listener2)); a.removeTestFacesListener(listener1); b.removeTestFacesListener(listener1); a.removeTestFacesListener(listener2); b.removeTestFacesListener(listener2); - Assertions.assertFalse(a._facesListeners.contains(listener1)); - Assertions.assertFalse(a._facesListeners.contains(listener2)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener2)); + assertFalse(a._facesListeners.contains(listener1)); + assertFalse(a._facesListeners.contains(listener2)); + assertFalse(b._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener2)); } - + @Test - public void testSimpleSaveRestore5() + void simpleSaveRestore5() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -495,29 +496,29 @@ public void testSimpleSaveRestore5() b.markInitialState(); a.addTestFacesListener(listener2); b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertTrue(a._facesListeners.contains(listener2)); - Assertions.assertTrue(b._facesListeners.contains(listener1)); - Assertions.assertTrue(b._facesListeners.contains(listener2)); + assertTrue(a._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener2)); + assertTrue(b._facesListeners.contains(listener1)); + assertTrue(b._facesListeners.contains(listener2)); a.removeTestFacesListener(listener1); b.removeTestFacesListener(listener1); a.removeTestFacesListener(listener2); b.removeTestFacesListener(listener2); - Assertions.assertFalse(a._facesListeners.contains(listener1)); - Assertions.assertFalse(a._facesListeners.contains(listener2)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener2)); + assertFalse(a._facesListeners.contains(listener1)); + assertFalse(a._facesListeners.contains(listener2)); + assertFalse(b._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener2)); //Save fully b.clearInitialState(); c.restoreState(facesContext, b.saveState(facesContext)); //c._facesListeners should be empty - Assertions.assertFalse(c._facesListeners.contains(listener1)); - Assertions.assertFalse(c._facesListeners.contains(listener2)); + assertFalse(c._facesListeners.contains(listener1)); + assertFalse(c._facesListeners.contains(listener2)); } - + @Test - public void testSimpleSaveRestore6() + void simpleSaveRestore6() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -532,18 +533,18 @@ public void testSimpleSaveRestore6() Object [] savedState1 = (Object[]) a.saveState(facesContext); // This is not null because StateFacesListener is instance of StateHolder // and always needs to be saved and restored! - Assertions.assertNotNull(savedState1[1]); + assertNotNull(savedState1[1]); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertTrue(b._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener1)); + assertTrue(b._facesListeners.contains(listener1)); a.removeTestFacesListener(listener1); b.removeTestFacesListener(listener1); - Assertions.assertFalse(a._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); + assertFalse(a._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener1)); } - + @Test - public void testSimpleSaveRestore7() + void simpleSaveRestore7() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -558,29 +559,29 @@ public void testSimpleSaveRestore7() b.markInitialState(); a.addTestFacesListener(listener2); b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertTrue(a._facesListeners.contains(listener2)); - Assertions.assertTrue(b._facesListeners.contains(listener1)); - Assertions.assertTrue(b._facesListeners.contains(listener2)); + assertTrue(a._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener2)); + assertTrue(b._facesListeners.contains(listener1)); + assertTrue(b._facesListeners.contains(listener2)); a.removeTestFacesListener(listener1); b.removeTestFacesListener(listener1); a.removeTestFacesListener(listener2); b.removeTestFacesListener(listener2); - Assertions.assertFalse(a._facesListeners.contains(listener1)); - Assertions.assertFalse(a._facesListeners.contains(listener2)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener2)); + assertFalse(a._facesListeners.contains(listener1)); + assertFalse(a._facesListeners.contains(listener2)); + assertFalse(b._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener2)); //Save fully b.clearInitialState(); c.restoreState(facesContext, b.saveState(facesContext)); //c._facesListeners should be empty - Assertions.assertFalse(c._facesListeners.contains(listener1)); - Assertions.assertFalse(c._facesListeners.contains(listener2)); + assertFalse(c._facesListeners.contains(listener1)); + assertFalse(c._facesListeners.contains(listener2)); } - + @Test - public void testSimpleSaveRestore8() + void simpleSaveRestore8() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -592,18 +593,18 @@ public void testSimpleSaveRestore8() b.markInitialState(); Object [] savedState1 = (Object[]) a.saveState(facesContext); // This is null because StateFacesListener is instance of PartialStateHolder - Assertions.assertNull(savedState1 == null ? null : savedState1[1]); + assertNull(savedState1 == null ? null : savedState1[1]); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertTrue(b._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener1)); + assertTrue(b._facesListeners.contains(listener1)); a.removeTestFacesListener(listener1); b.removeTestFacesListener(listener1); - Assertions.assertFalse(a._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); + assertFalse(a._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener1)); } - + @Test - public void testSimpleSaveRestore9() + void simpleSaveRestore9() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -619,22 +620,22 @@ public void testSimpleSaveRestore9() Object [] savedState1 = (Object[]) a.saveState(facesContext); // This is null because StateFacesListener is instance of PartialStateHolder but a // listener was added after markInitialState - Assertions.assertNotNull(savedState1[1]); + assertNotNull(savedState1[1]); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertTrue(b._facesListeners.contains(listener1)); - Assertions.assertTrue(a._facesListeners.contains(listener2)); - Assertions.assertTrue(b._facesListeners.contains(listener2)); + assertTrue(a._facesListeners.contains(listener1)); + assertTrue(b._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener2)); + assertTrue(b._facesListeners.contains(listener2)); a.removeTestFacesListener(listener1); b.removeTestFacesListener(listener1); - Assertions.assertFalse(a._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); - Assertions.assertTrue(a._facesListeners.contains(listener2)); - Assertions.assertTrue(b._facesListeners.contains(listener2)); - } - + assertFalse(a._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener2)); + assertTrue(b._facesListeners.contains(listener2)); + } + @Test - public void testSimpleSaveRestoreTransient1() + void simpleSaveRestoreTransient1() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -643,13 +644,13 @@ public void testSimpleSaveRestoreTransient1() listener1.setValue("value"); a.addTestFacesListener(listener1); b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); - Assertions.assertTrue(b._facesListeners.isEmpty()); + assertTrue(a._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener1)); + assertTrue(b._facesListeners.isEmpty()); } - + @Test - public void testSimpleSaveRestoreTransient2() + void simpleSaveRestoreTransient2() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -660,12 +661,12 @@ public void testSimpleSaveRestoreTransient2() listener1.setValue("value"); a.addTestFacesListener(listener1); b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener1)); } - + @Test - public void testSimpleSaveRestoreTransient3() + void simpleSaveRestoreTransient3() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -679,12 +680,12 @@ public void testSimpleSaveRestoreTransient3() listener1.setValue("value"); a.addTestFacesListener(listener1); b.restoreState(facesContext, a.saveState(facesContext)); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener1)); } - + @Test - public void testSimpleSaveRestoreTransient4() + void simpleSaveRestoreTransient4() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -698,12 +699,12 @@ public void testSimpleSaveRestoreTransient4() //Since listener1 is transient Object [] savedState1 = (Object[]) a.saveState(facesContext); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener1)); } - + @Test - public void testSimpleSaveRestoreTransient5() + void simpleSaveRestoreTransient5() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -722,15 +723,15 @@ public void testSimpleSaveRestoreTransient5() //Since listener1 is transient Object [] savedState1 = (Object[]) a.saveState(facesContext); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); - Assertions.assertTrue(a._facesListeners.contains(listener2)); - Assertions.assertTrue(b._facesListeners.contains(listener2)); - Assertions.assertEquals("value2", ((StateFacesListener)b._facesListeners.get(b._facesListeners.indexOf(listener2))).getValue()); + assertTrue(a._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener2)); + assertTrue(b._facesListeners.contains(listener2)); + assertEquals("value2", ((StateFacesListener)b._facesListeners.get(b._facesListeners.indexOf(listener2))).getValue()); } - + @Test - public void testSimpleSaveRestoreTransient6() + void simpleSaveRestoreTransient6() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -743,12 +744,12 @@ public void testSimpleSaveRestoreTransient6() //Since listener1 is transient Object [] savedState1 = (Object[]) a.saveState(facesContext); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener1)); } @Test - public void testSimpleSaveRestoreTransient7() + void simpleSaveRestoreTransient7() { UITestComponent a = new UITestComponent(); UITestComponent b = new UITestComponent(); @@ -767,10 +768,10 @@ public void testSimpleSaveRestoreTransient7() //Since listener1 is transient Object [] savedState1 = (Object[]) a.saveState(facesContext); b.restoreState(facesContext, savedState1); - Assertions.assertTrue(a._facesListeners.contains(listener1)); - Assertions.assertFalse(b._facesListeners.contains(listener1)); - Assertions.assertTrue(a._facesListeners.contains(listener2)); - Assertions.assertTrue(b._facesListeners.contains(listener2)); - Assertions.assertEquals("value2", ((StateFacesListener)b._facesListeners.get(b._facesListeners.indexOf(listener2))).getValue()); + assertTrue(a._facesListeners.contains(listener1)); + assertFalse(b._facesListeners.contains(listener1)); + assertTrue(a._facesListeners.contains(listener2)); + assertTrue(b._facesListeners.contains(listener2)); + assertEquals("value2", ((StateFacesListener)b._facesListeners.get(b._facesListeners.indexOf(listener2))).getValue()); } } diff --git a/impl/src/test/java/jakarta/faces/component/_DeltaStateHelperTest.java b/impl/src/test/java/jakarta/faces/component/_DeltaStateHelperTest.java index c069786ff2..80a0d8d810 100644 --- a/impl/src/test/java/jakarta/faces/component/_DeltaStateHelperTest.java +++ b/impl/src/test/java/jakarta/faces/component/_DeltaStateHelperTest.java @@ -18,17 +18,18 @@ */ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.*; + import java.util.List; import java.util.Map; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; /** * A generic framework less testcase for our _DeltaStateHelper class! */ -public class _DeltaStateHelperTest extends AbstractComponentTest +class _DeltaStateHelperTest extends AbstractComponentTest { private static final String KEY3 = "key3"; @@ -45,13 +46,13 @@ public class _DeltaStateHelperTest extends AbstractComponentTest private void assertStructure() { - Assertions.assertTrue( _instance.get(KEY1).equals(VAL1)); - Assertions.assertTrue( _instance.get(KEY2) instanceof Map); - Assertions.assertTrue( _instance.get(KEY3) instanceof List); + assertEquals(VAL1, _instance.get(KEY1)); + assertInstanceOf(Map.class, _instance.get(KEY2)); + assertInstanceOf(List.class, _instance.get(KEY3)); - Assertions.assertTrue(((List) _instance.get(KEY3)).size() >= 1); - Assertions.assertTrue(((Map) _instance.get(KEY2)).get(KEY_2_2).equals(VAL3)); - Assertions.assertTrue(((Map) _instance.get(KEY2)).get(KEY_2_1).equals(VAL2)); + assertTrue(((List) _instance.get(KEY3)).size() >= 1); + assertEquals(VAL3, ((Map) _instance.get(KEY2)).get(KEY_2_2)); + assertEquals(VAL2, ((Map) _instance.get(KEY2)).get(KEY_2_1)); } @@ -104,38 +105,38 @@ public void tearDown() throws Exception * Test of isInitalStateMarked method, of class _DeltaStateHelper. */ @Test - public void testIsInitalStateMarked() + void isInitalStateMarked() { - Assertions.assertTrue(_instance.isInitialStateMarked()); + assertTrue(_instance.isInitialStateMarked()); _instance.setInitialStateMarked(false); - Assertions.assertFalse(_instance.isInitialStateMarked()); + assertFalse(_instance.isInitialStateMarked()); } /** * Test of add method, of class _DeltaStateHelper. */ @Test - public void testAdd() + void add() { _instance.add(KEY1, VAL1); Object val = _instance.get(KEY1); - Assertions.assertTrue(val instanceof List); - Assertions.assertTrue(((List) val).size() == 1); + assertInstanceOf(List.class, val); + assertEquals(1, ((List) val).size()); _instance.add(KEY1, new Integer(2)); _instance.add(KEY2, new Integer(2)); val = _instance.get(KEY1); - Assertions.assertTrue(val instanceof List); - Assertions.assertTrue(((List) val).size() == 2); + assertInstanceOf(List.class, val); + assertEquals(2, ((List) val).size()); - Assertions.assertTrue(((List) val).get(0).equals(VAL1)); + assertEquals(VAL1, ((List) val).get(0)); - Assertions.assertTrue(((List) val).get(1).equals(new Integer(2))); + assertEquals(((List) val).get(1), new Integer(2)); val = _instance.get(KEY2); - Assertions.assertTrue(val instanceof List); - Assertions.assertTrue(((List) val).size() == 1); + assertInstanceOf(List.class, val); + assertEquals(1, ((List) val).size()); } /** @@ -155,7 +156,7 @@ private void _setupGetTests() * Test of get method, of class _DeltaStateHelper. */ @Test - public void testGet() + void get() { _setupGetTests(); assertStructure(); @@ -165,48 +166,48 @@ public void testGet() * Test of put method, of class _DeltaStateHelper. */ @Test - public void testPut_Serializable_Object() + void putSerializableObject() { _setupGetTests(); - Assertions.assertTrue(_instance.get(KEY1).equals(VAL1)); + assertEquals(VAL1, _instance.get(KEY1)); Map entry = (Map) _instance.get(KEY2); - Assertions.assertTrue(_instance.get(KEY2) instanceof Map); + assertInstanceOf(Map.class, _instance.get(KEY2)); - Assertions.assertTrue(entry.size() == 2 + assertTrue(entry.size() == 2 && entry.get(KEY_2_1).equals(VAL2) && entry.get(KEY_2_2).equals(VAL3)); } @Test - public void testPut_null() + void putNull() { _instance.put(KEY1, null); _instance.put(KEY2, null); - Assertions.assertNull(_instance.get(KEY1)); - Assertions.assertNull(_instance.get(KEY2)); + assertNull(_instance.get(KEY1)); + assertNull(_instance.get(KEY2)); _setupGetTests(); - Assertions.assertTrue(_instance.get(KEY1).equals(VAL1)); + assertEquals(VAL1, _instance.get(KEY1)); Map entry = (Map) _instance.get(KEY2); - Assertions.assertTrue(_instance.get(KEY2) instanceof Map); + assertInstanceOf(Map.class, _instance.get(KEY2)); - Assertions.assertTrue(entry.size() == 2 + assertTrue(entry.size() == 2 && entry.get(KEY_2_1).equals(VAL2) && entry.get(KEY_2_2).equals(VAL3)); _instance.put(KEY1, null); - Assertions.assertNull(_instance.get(KEY1)); + assertNull(_instance.get(KEY1)); } /** * Test of put method, of class _DeltaStateHelper. */ @Test - public void testPut_3args() + void put3args() { //covered already by testPut_Serializable_Object() } @@ -215,11 +216,11 @@ public void testPut_3args() * Test of remove method, of class _DeltaStateHelper. */ @Test - public void testRemove_Serializable() + void removeSerializable() { _setupGetTests(); _instance.remove(KEY1); - Assertions.assertTrue(_instance.get(KEY1) == null); + assertNull(_instance.get(KEY1)); //TODO check the deleted data structure for further internal structural tests } @@ -227,7 +228,7 @@ public void testRemove_Serializable() * Test of remove method, of class _DeltaStateHelper. */ @Test - public void testRemove_Serializable_Object() + void removeSerializableObject() { _setupGetTests(); _instance.remove(KEY2, KEY_2_1); @@ -235,15 +236,15 @@ public void testRemove_Serializable_Object() _instance.remove(KEY3, VAL3); - Assertions.assertTrue(_instance.get(KEY2) == null); - Assertions.assertTrue(_instance.get(KEY3) == null); + assertNull(_instance.get(KEY2)); + assertNull(_instance.get(KEY3)); } /** * Test of saveState method, of class _DeltaStateHelper. */ @Test - public void testSaveState() + void saveState() { _instance.setInitialStateMarked(false); @@ -252,8 +253,8 @@ public void testSaveState() //save stating does not need a facesContext for now! Object retVal = _instance.saveState(facesContext); - Assertions.assertTrue(retVal instanceof Object[]); - Assertions.assertTrue(((Object[]) retVal).length > 0); + assertInstanceOf(Object[].class, retVal); + assertTrue(((Object[]) retVal).length > 0); //only basic structural tests are done here //the more important ones are the ones in restorestate @@ -263,7 +264,7 @@ public void testSaveState() _instance.put(KEY5, VAL5); Object[] deltaSaveState = (Object[]) _instance.saveState(facesContext); //only the new value should be saved as delta - Assertions.assertTrue(deltaSaveState.length == 2 + assertTrue(deltaSaveState.length == 2 && deltaSaveState[0].equals(KEY5) && deltaSaveState[1].equals(VAL5)); @@ -273,7 +274,7 @@ public void testSaveState() * Test of restoreState method, of class _DeltaStateHelper. */ @Test - public void testRestoreState() + void restoreState() { _setupGetTests(); _instance.setInitialStateMarked(false); @@ -298,9 +299,9 @@ public void testRestoreState() * Test of isTransient method, of class _DeltaStateHelper. */ @Test - public void testIsTransient() + void isTransient() { _instance.setTransient(true); - Assertions.assertTrue(_instance.isTransient()); + assertTrue(_instance.isTransient()); } } diff --git a/impl/src/test/java/jakarta/faces/component/_SelectItemsUtilTest.java b/impl/src/test/java/jakarta/faces/component/_SelectItemsUtilTest.java index 723af1b847..9decf3c6e8 100644 --- a/impl/src/test/java/jakarta/faces/component/_SelectItemsUtilTest.java +++ b/impl/src/test/java/jakarta/faces/component/_SelectItemsUtilTest.java @@ -20,7 +20,11 @@ import jakarta.el.ValueExpression; import jakarta.faces.model.SelectItem; + import java.util.ArrayList; + +import static org.junit.jupiter.api.Assertions.*; + import java.util.List; import java.util.stream.Collectors; import org.apache.myfaces.core.api.shared.SelectItemsIterator; @@ -29,11 +33,10 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.apache.myfaces.test.el.MockValueExpression; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class _SelectItemsUtilTest extends AbstractFacesTestCase +class _SelectItemsUtilTest extends AbstractFacesTestCase { private static final String NO_SELECTION_ITEM_VALUE = "1.0"; @@ -88,20 +91,20 @@ public void tearDown() throws Exception } @Test - public void testMatchValue() + void matchValue() { boolean matchValue = SelectItemsUtil.matchValue(facesContext, uiComponent, value, iterator, null); - Assertions.assertTrue(matchValue, "Value Float 1.2 must match SelectItem.value \"1.2\" (type of String)"); + assertTrue(matchValue, "Value Float 1.2 must match SelectItem.value \"1.2\" (type of String)"); Float valueNotInSelectItems = Float.valueOf("2.0"); matchValue = SelectItemsUtil.matchValue(facesContext, uiComponent, valueNotInSelectItems, iterator, null); - Assertions.assertFalse(matchValue); + assertFalse(matchValue); } - + @Test - public void testMatchValueWithEnums() throws Exception + void matchValueWithEnums() throws Exception { noSelectionOption.setItemValue("NONE"); selectItem1.setItemValue("ONE"); @@ -112,15 +115,15 @@ public void testMatchValueWithEnums() throws Exception Object enumValue = MockEnum.THREE; boolean matchValue = SelectItemsUtil.matchValue(facesContext, uiComponent, enumValue, iterator, null); - Assertions.assertTrue(matchValue, "Value Enum THREE must match SelectItem.value \"THREE\" (type of String)"); + assertTrue(matchValue, "Value Enum THREE must match SelectItem.value \"THREE\" (type of String)"); enumValue = MockEnum.FOUR; matchValue = SelectItemsUtil.matchValue(facesContext, uiComponent, enumValue, iterator, null); - Assertions.assertFalse(matchValue); + assertFalse(matchValue); } - - @Test - public void testMatchValueWithEnumsNoExtends() throws Exception + + @Test + void matchValueWithEnumsNoExtends() throws Exception { noSelectionOption.setItemValue("NONE"); selectItem1.setItemValue("ONE"); @@ -131,7 +134,7 @@ public void testMatchValueWithEnumsNoExtends() throws Exception Object enumValue = MockEnum.TWO; boolean matchValue = SelectItemsUtil.matchValue(facesContext, uiComponent, enumValue, iterator, null); - Assertions.assertTrue(matchValue, "Value Enum TWO must match SelectItem.value \"TWO\" (type of String)"); + assertTrue(matchValue, "Value Enum TWO must match SelectItem.value \"TWO\" (type of String)"); } private static enum MockEnum { @@ -157,20 +160,20 @@ public String toString() } @Test - public void testIsNoSelectionOption() + void isNoSelectionOption() { Float value = Float.parseFloat(NO_SELECTION_ITEM_VALUE); boolean noSelectionOption = SelectItemsUtil.isNoSelectionOption(facesContext, uiComponent, value, iterator, null); - Assertions.assertTrue(noSelectionOption); + assertTrue(noSelectionOption); Float valueNotInSelectItems = Float.valueOf("2.0"); noSelectionOption = SelectItemsUtil.isNoSelectionOption(facesContext, uiComponent, valueNotInSelectItems, iterator, null); - Assertions.assertFalse(noSelectionOption); + assertFalse(noSelectionOption); } @Test - public void testSelectListAsValue() + void selectListAsValue() { List values = new ArrayList<>(); @@ -202,9 +205,9 @@ public void testSelectListAsValue() labels.add(next.getLabel()); descriptions.add(next.getDescription()); } - Assertions.assertAll( - () -> Assertions.assertEquals(values.stream().map(SelectItem::getLabel).collect(Collectors.toList()), options), - () -> Assertions.assertEquals(values.stream().map(SelectItem::getValue).collect(Collectors.toList()), labels), - () -> Assertions.assertEquals(values.stream().map(SelectItem::getValue).collect(Collectors.toList()), descriptions)); + assertAll( + () -> assertEquals(values.stream().map(SelectItem::getLabel).collect(Collectors.toList()), options), + () -> assertEquals(values.stream().map(SelectItem::getValue).collect(Collectors.toList()), labels), + () -> assertEquals(values.stream().map(SelectItem::getValue).collect(Collectors.toList()), descriptions)); } } diff --git a/impl/src/test/java/jakarta/faces/component/_SharedRendererUtilsTest.java b/impl/src/test/java/jakarta/faces/component/_SharedRendererUtilsTest.java index 4d4c495e03..4b1c85d1fc 100644 --- a/impl/src/test/java/jakarta/faces/component/_SharedRendererUtilsTest.java +++ b/impl/src/test/java/jakarta/faces/component/_SharedRendererUtilsTest.java @@ -19,7 +19,11 @@ package jakarta.faces.component; import org.apache.myfaces.core.api.shared.SharedRendererUtils; + import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; + import java.util.Collection; import java.util.HashSet; @@ -32,11 +36,10 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.apache.myfaces.test.el.MockValueExpression; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class _SharedRendererUtilsTest extends AbstractFacesTestCase +class _SharedRendererUtilsTest extends AbstractFacesTestCase { /** * A POJO used for testing. @@ -201,69 +204,69 @@ public void tearDown() throws Exception * In this scenario it stores the values of submittedValue in a new object array. */ @Test - public void testGetConvertedUISelectManyValueNoConverterNoValueExpression() + void getConvertedUISelectManyValueNoConverterNoValueExpression() { Object target = SharedRendererUtils.getConvertedUISelectManyValue(facesContext, uiSelectMany, submittedValue); - Assertions.assertTrue(target instanceof Object[]); - Assertions.assertTrue(Arrays.deepEquals((Object[]) target, submittedValue)); + assertInstanceOf(Object[].class, target); + assertTrue(Arrays.deepEquals((Object[]) target, submittedValue)); } - + /** * Test case for the case that UISelectMany has a ValueExpression pointing to a primitive * integer array and uses a standard jsf converter. */ @SuppressWarnings("unchecked") @Test - public void testGetConvertedUISelectManyValuePrimitiveIntArray() + void getConvertedUISelectManyValuePrimitiveIntArray() { externalContext.getApplicationMap().put("bean", new Bean()); ValueExpression expr = new MockValueExpression("#{bean.intArrayValue}", int[].class); uiSelectMany.setValueExpression("value", expr); Object target = SharedRendererUtils.getConvertedUISelectManyValue(facesContext, uiSelectMany, submittedValue); - Assertions.assertTrue(target instanceof int[]); + assertInstanceOf(int[].class, target); int[] array = (int[]) target; - Assertions.assertTrue(new Integer(submittedValue[0]).equals(array[0])); - Assertions.assertTrue(new Integer(submittedValue[0]).equals(array[0])); + assertEquals(new Integer(submittedValue[0]), array[0]); + assertEquals(new Integer(submittedValue[0]), array[0]); } - + /** * Test case for the case that UISelectMany has a ValueExpression pointing to a non-primitive * Float array and uses a standard jsf converter. */ @SuppressWarnings("unchecked") @Test - public void testGetConvertedUISelectManyValueNonPrimitiveFloatArray() + void getConvertedUISelectManyValueNonPrimitiveFloatArray() { externalContext.getApplicationMap().put("bean", new Bean()); ValueExpression expr = new MockValueExpression("#{bean.floatArrayValue}", Float[].class); uiSelectMany.setValueExpression("value", expr); Object target = SharedRendererUtils.getConvertedUISelectManyValue(facesContext, uiSelectMany, submittedValue); - Assertions.assertTrue(target instanceof Float[]); + assertInstanceOf(Float[].class, target); Float[] array = (Float[]) target; - Assertions.assertTrue(new Float(submittedValue[0]).equals(array[0])); - Assertions.assertTrue(new Float(submittedValue[1]).equals(array[1])); + assertEquals(new Float(submittedValue[0]), array[0]); + assertEquals(new Float(submittedValue[1]), array[1]); } - + /** * Test case for the case that UISelectMany has a ValueExpression pointing to a * POJO array and uses a provided converter. */ @SuppressWarnings("unchecked") @Test - public void testGetConvertedUISelectManyValuePOJOArray() + void getConvertedUISelectManyValuePOJOArray() { externalContext.getApplicationMap().put("bean", new Bean()); ValueExpression expr = new MockValueExpression("#{bean.pojoArrayValue}", POJO[].class); uiSelectMany.setValueExpression("value", expr); uiSelectMany.setConverter(pojoConverter); Object target = SharedRendererUtils.getConvertedUISelectManyValue(facesContext, uiSelectMany, submittedValue); - Assertions.assertTrue(target instanceof POJO[]); + assertInstanceOf(POJO[].class, target); POJO[] array = (POJO[]) target; - Assertions.assertTrue(pojoConverter.getAsObject(facesContext, uiSelectMany, submittedValue[0]).equals(array[0])); - Assertions.assertTrue(pojoConverter.getAsObject(facesContext, uiSelectMany, submittedValue[1]).equals(array[1])); + assertEquals(pojoConverter.getAsObject(facesContext, uiSelectMany, submittedValue[0]), array[0]); + assertEquals(pojoConverter.getAsObject(facesContext, uiSelectMany, submittedValue[1]), array[1]); } - + /** * Test case for the case that UISelectMany has a ValueExpression pointing to a * Collection of POJOs and uses a provided converter. @@ -272,19 +275,19 @@ public void testGetConvertedUISelectManyValuePOJOArray() */ @SuppressWarnings("unchecked") @Test - public void testGetConvertedUISelectManyValuePOJOCollectionWithoutCollectionType() + void getConvertedUISelectManyValuePOJOCollectionWithoutCollectionType() { externalContext.getApplicationMap().put("bean", new Bean()); ValueExpression expr = new MockValueExpression("#{bean.pojoCollectionValue}", Collection.class); uiSelectMany.setValueExpression("value", expr); uiSelectMany.setConverter(pojoConverter); Object target = SharedRendererUtils.getConvertedUISelectManyValue(facesContext, uiSelectMany, submittedValue); - Assertions.assertTrue(target instanceof Collection); + assertInstanceOf(Collection.class, target); Collection collection = (Collection) target; - Assertions.assertTrue(collection.contains(pojoConverter.getAsObject(facesContext, uiSelectMany, submittedValue[0]))); - Assertions.assertTrue(collection.contains(pojoConverter.getAsObject(facesContext, uiSelectMany, submittedValue[1]))); + assertTrue(collection.contains(pojoConverter.getAsObject(facesContext, uiSelectMany, submittedValue[0]))); + assertTrue(collection.contains(pojoConverter.getAsObject(facesContext, uiSelectMany, submittedValue[1]))); } - + /** * Test case for the case that UISelectMany has a ValueExpression pointing to a * Collection of POJOs and uses a provided converter. @@ -294,7 +297,7 @@ public void testGetConvertedUISelectManyValuePOJOCollectionWithoutCollectionType */ @SuppressWarnings("unchecked") @Test - public void testGetConvertedUISelectManyValuePOJOCollectionWithCollectionType() + void getConvertedUISelectManyValuePOJOCollectionWithCollectionType() { externalContext.getApplicationMap().put("bean", new Bean()); ValueExpression expr = new MockValueExpression("#{bean.pojoCollectionValue}", Collection.class); @@ -302,19 +305,19 @@ public void testGetConvertedUISelectManyValuePOJOCollectionWithCollectionType() uiSelectMany.setConverter(pojoConverter); uiSelectMany.getAttributes().put("collectionType", "java.util.HashSet"); Object target = SharedRendererUtils.getConvertedUISelectManyValue(facesContext, uiSelectMany, submittedValue); - Assertions.assertTrue(target instanceof HashSet); + assertInstanceOf(HashSet.class, target); HashSet hashSet = (HashSet) target; - Assertions.assertTrue(hashSet.contains(pojoConverter.getAsObject(facesContext, uiSelectMany, submittedValue[0]))); - Assertions.assertTrue(hashSet.contains(pojoConverter.getAsObject(facesContext, uiSelectMany, submittedValue[1]))); + assertTrue(hashSet.contains(pojoConverter.getAsObject(facesContext, uiSelectMany, submittedValue[0]))); + assertTrue(hashSet.contains(pojoConverter.getAsObject(facesContext, uiSelectMany, submittedValue[1]))); } - + /** * In this test case the method can not proceed, because it is not able to * obtain a converter. So it throws a ConverterException. */ @SuppressWarnings("unchecked") @Test - public void testGetConvertedUISelectManyValueNoConverter() + void getConvertedUISelectManyValueNoConverter() { externalContext.getApplicationMap().put("bean", new Bean()); ValueExpression expr = new MockValueExpression("#{bean.pojoArrayValue}", POJO[].class); @@ -322,21 +325,21 @@ public void testGetConvertedUISelectManyValueNoConverter() try { SharedRendererUtils.getConvertedUISelectManyValue(facesContext, uiSelectMany, submittedValue); - Assertions.fail(); + fail(); } catch (ConverterException ce) { // success } } - + /** * In this test case the method gets a wrong hint for a collection type * (java.util.Collection can not be instantiated). So it throws a FacesException. */ @SuppressWarnings("unchecked") @Test - public void testGetConvertedUISelectManyValueWrongCollectionType() + void getConvertedUISelectManyValueWrongCollectionType() { externalContext.getApplicationMap().put("bean", new Bean()); ValueExpression expr = new MockValueExpression("#{bean.pojoCollectionValue}", Collection.class); @@ -346,7 +349,7 @@ public void testGetConvertedUISelectManyValueWrongCollectionType() try { SharedRendererUtils.getConvertedUISelectManyValue(facesContext, uiSelectMany, submittedValue); - Assertions.fail(); + fail(); } catch (FacesException fe) { diff --git a/impl/src/test/java/jakarta/faces/component/behavior/BehaviorRestoreCollectionTest.java b/impl/src/test/java/jakarta/faces/component/behavior/BehaviorRestoreCollectionTest.java index 724c0cc9bf..12443936bd 100644 --- a/impl/src/test/java/jakarta/faces/component/behavior/BehaviorRestoreCollectionTest.java +++ b/impl/src/test/java/jakarta/faces/component/behavior/BehaviorRestoreCollectionTest.java @@ -18,6 +18,8 @@ */ package jakarta.faces.component.behavior; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -28,7 +30,6 @@ import jakarta.faces.event.PhaseId; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -37,7 +38,7 @@ * _DeltaStateHelper), which restores every List as an ArrayList and keeps any other Serializable collection as it is. * So collections without a zero-argument constructor, such as List.of() (MYFACES-4776), are restored there too. */ -public class BehaviorRestoreCollectionTest extends AbstractFacesTestCase +class BehaviorRestoreCollectionTest extends AbstractFacesTestCase { @Override @BeforeEach @@ -48,14 +49,14 @@ public void setUp() throws Exception } @Test - public void testFullState() + void fullState() { assertRoundTrip(false, List.of("a", "b"), Arrays.asList("c", "d")); assertRoundTrip(false, Collections.unmodifiableList(new ArrayList<>(List.of("a"))), Set.of("c")); } @Test - public void testDeltaState() + void deltaState() { assertRoundTrip(true, List.of("a", "b"), Arrays.asList("c", "d")); assertRoundTrip(true, Collections.singletonList("a"), Set.of("c")); @@ -80,7 +81,7 @@ private void assertRoundTrip(boolean delta, Collection execute, Collecti } restored.restoreState(facesContext, state); - Assertions.assertEquals(new ArrayList<>(execute), new ArrayList<>(restored.getExecute())); - Assertions.assertEquals(new ArrayList<>(render), new ArrayList<>(restored.getRender())); + assertEquals(new ArrayList<>(execute), new ArrayList<>(restored.getExecute())); + assertEquals(new ArrayList<>(render), new ArrayList<>(restored.getRender())); } } diff --git a/impl/src/test/java/jakarta/faces/component/html/HtmlOutputLinkTest.java b/impl/src/test/java/jakarta/faces/component/html/HtmlOutputLinkTest.java index 9d9e6adec3..63b01335d6 100644 --- a/impl/src/test/java/jakarta/faces/component/html/HtmlOutputLinkTest.java +++ b/impl/src/test/java/jakarta/faces/component/html/HtmlOutputLinkTest.java @@ -18,20 +18,21 @@ */ package jakarta.faces.component.html; -import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.Test; -public class HtmlOutputLinkTest +class HtmlOutputLinkTest { /** * Test method for {@link jakarta.faces.component.UIComponentBase#getRendererType()}. */ @Test - public void testRendererType() + void rendererType() { - Assertions.assertEquals("jakarta.faces.Link", new HtmlOutputLink().getRendererType()); + assertEquals("jakarta.faces.Link", new HtmlOutputLink().getRendererType()); } } diff --git a/impl/src/test/java/jakarta/faces/convert/DateTimeConverterTest.java b/impl/src/test/java/jakarta/faces/convert/DateTimeConverterTest.java index a72074d4cc..ce288b977b 100644 --- a/impl/src/test/java/jakarta/faces/convert/DateTimeConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/DateTimeConverterTest.java @@ -19,6 +19,8 @@ package jakarta.faces.convert; +import static org.junit.jupiter.api.Assertions.*; + import java.text.SimpleDateFormat; import java.time.Instant; import java.time.LocalDate; @@ -39,7 +41,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class DateTimeConverterTest extends AbstractFacesTestCase +class DateTimeConverterTest extends AbstractFacesTestCase { private DateTimeConverter mock; @@ -68,7 +70,7 @@ public void tearDown() throws Exception * Test method for 'jakarta.faces.component.UIComponentBase.getAsObject()' */ @Test - public void testGetAsObject() + void getAsObject() { UIInput input = new UIInput(); @@ -80,7 +82,7 @@ public void testGetAsObject() { mock.getAsObject(FacesContext.getCurrentInstance(), input, "15/15/15"); - Assertions.assertTrue(false, "this date should not be parsable - and it is, so this is wrong."); + fail("this date should not be parsable - and it is, so this is wrong."); } catch (ConverterException e) { @@ -88,8 +90,7 @@ public void testGetAsObject() } // should not trow a ConverterException - try - { + Assertions.assertDoesNotThrow(() -> { Date date = (Date) mock.getAsObject(FacesContext.getCurrentInstance(), input, "12/01/01"); SimpleDateFormat format = new SimpleDateFormat("MM/dd/yy"); @@ -97,23 +98,19 @@ public void testGetAsObject() String str = format.format(date); - Assertions.assertEquals("12/01/01", str); + assertEquals("12/01/01", str); format = new SimpleDateFormat("MM/dd/yyyy"); format.setTimeZone(TimeZone.getDefault()); str = format.format(date); - Assertions.assertEquals("12/01/0001", str); - } - catch (ConverterException e) - { - Assertions.assertTrue(false, "this date should not be parsable - and it is, so this is wrong."); - } + assertEquals("12/01/0001", str); + }, "this date should not be parsable - and it is, so this is wrong."); } @Test - public void testLocalDateParsesRegularSpacesWhenLocaleUsesFixedWidthWhitespace() + void localDateParsesRegularSpacesWhenLocaleUsesFixedWidthWhitespace() { UIInput input = new UIInput(); mock.setType("localDate"); @@ -123,11 +120,11 @@ public void testLocalDateParsesRegularSpacesWhenLocaleUsesFixedWidthWhitespace() String formatted = mock.getAsString(facesContext, input, expected); String withAsciiSpaces = formatted.replace('\u202f', ' ').replace('\u00a0', ' '); Object parsed = mock.getAsObject(facesContext, input, withAsciiSpaces); - Assertions.assertEquals(expected, parsed); + assertEquals(expected, parsed); } @Test - public void testLocalTimeStripsZeroWidthWhitespaceFromInput() + void localTimeStripsZeroWidthWhitespaceFromInput() { UIInput input = new UIInput(); mock.setType("localTime"); @@ -135,98 +132,98 @@ public void testLocalTimeStripsZeroWidthWhitespaceFromInput() mock.setTimeStyle("short"); LocalTime expected = LocalTime.of(14, 30); String formatted = mock.getAsString(facesContext, input, expected); - Assertions.assertFalse(formatted.isEmpty()); + assertFalse(formatted.isEmpty()); String withZw = formatted.charAt(0) + "\u200b" + formatted.substring(1); Object parsed = mock.getAsObject(facesContext, input, withZw); - Assertions.assertEquals(expected, parsed); + assertEquals(expected, parsed); } @Test - public void testYearIsoRoundTrip() + void yearIsoRoundTrip() { UIInput input = new UIInput(); mock.setType("year"); Year expected = Year.of(2011); - Assertions.assertEquals("2011", mock.getAsString(facesContext, input, expected)); - Assertions.assertEquals(expected, mock.getAsObject(facesContext, input, "2011")); + assertEquals("2011", mock.getAsString(facesContext, input, expected)); + assertEquals(expected, mock.getAsObject(facesContext, input, "2011")); } @Test - public void testYearMonthIsoRoundTrip() + void yearMonthIsoRoundTrip() { UIInput input = new UIInput(); mock.setType("yearMonth"); YearMonth expected = YearMonth.of(2011, 12); - Assertions.assertEquals("2011-12", mock.getAsString(facesContext, input, expected)); - Assertions.assertEquals(expected, mock.getAsObject(facesContext, input, "2011-12")); + assertEquals("2011-12", mock.getAsString(facesContext, input, expected)); + assertEquals(expected, mock.getAsObject(facesContext, input, "2011-12")); } @Test - public void testMonthDayIsoRoundTrip() + void monthDayIsoRoundTrip() { UIInput input = new UIInput(); mock.setType("monthDay"); MonthDay expected = MonthDay.of(12, 3); - Assertions.assertEquals("--12-03", mock.getAsString(facesContext, input, expected)); - Assertions.assertEquals(expected, mock.getAsObject(facesContext, input, "--12-03")); + assertEquals("--12-03", mock.getAsString(facesContext, input, expected)); + assertEquals(expected, mock.getAsObject(facesContext, input, "--12-03")); } @Test - public void testMonthDayAcceptsLeapDay() + void monthDayAcceptsLeapDay() { UIInput input = new UIInput(); mock.setType("monthDay"); MonthDay leapDay = MonthDay.of(2, 29); - Assertions.assertEquals("--02-29", mock.getAsString(facesContext, input, leapDay)); - Assertions.assertEquals(leapDay, mock.getAsObject(facesContext, input, "--02-29")); + assertEquals("--02-29", mock.getAsString(facesContext, input, leapDay)); + assertEquals(leapDay, mock.getAsObject(facesContext, input, "--02-29")); } @Test - public void testInstantIsoRoundTrip() + void instantIsoRoundTrip() { UIInput input = new UIInput(); mock.setType("instant"); Instant expected = Instant.parse("2011-12-03T10:15:30Z"); - Assertions.assertEquals("2011-12-03T10:15:30Z", mock.getAsString(facesContext, input, expected)); - Assertions.assertEquals(expected, mock.getAsObject(facesContext, input, "2011-12-03T10:15:30Z")); + assertEquals("2011-12-03T10:15:30Z", mock.getAsString(facesContext, input, expected)); + assertEquals(expected, mock.getAsObject(facesContext, input, "2011-12-03T10:15:30Z")); } @Test - public void testInstantWithCustomPatternUsesTimeZone() + void instantWithCustomPatternUsesTimeZone() { UIInput input = new UIInput(); mock.setType("instant"); mock.setPattern("yyyy-MM-dd HH:mm:ss"); mock.setTimeZone(TimeZone.getTimeZone("GMT")); Instant expected = Instant.parse("2011-12-03T10:15:30Z"); - Assertions.assertEquals("2011-12-03 10:15:30", mock.getAsString(facesContext, input, expected)); - Assertions.assertEquals(expected, mock.getAsObject(facesContext, input, "2011-12-03 10:15:30")); + assertEquals("2011-12-03 10:15:30", mock.getAsString(facesContext, input, expected)); + assertEquals(expected, mock.getAsObject(facesContext, input, "2011-12-03 10:15:30")); } @Test - public void testYearWithExplicitPattern() + void yearWithExplicitPattern() { UIInput input = new UIInput(); mock.setType("year"); mock.setPattern("yy"); - Assertions.assertEquals("11", mock.getAsString(facesContext, input, Year.of(2011))); + assertEquals("11", mock.getAsString(facesContext, input, Year.of(2011))); } @Test - public void testYearRejectsUnparseableInput() + void yearRejectsUnparseableInput() { UIInput input = new UIInput(); mock.setType("year"); - Assertions.assertThrows(ConverterException.class, + assertThrows(ConverterException.class, () -> mock.getAsObject(facesContext, input, "not-a-year")); } @Test - public void testMonthDayRejectsInvalidInput() + void monthDayRejectsInvalidInput() { UIInput input = new UIInput(); mock.setType("monthDay"); - Assertions.assertThrows(ConverterException.class, + assertThrows(ConverterException.class, () -> mock.getAsObject(facesContext, input, "--13-40")); } } diff --git a/impl/src/test/java/jakarta/faces/convert/DoubleConverterTest.java b/impl/src/test/java/jakarta/faces/convert/DoubleConverterTest.java index f2db6ba21d..d002be2541 100644 --- a/impl/src/test/java/jakarta/faces/convert/DoubleConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/DoubleConverterTest.java @@ -23,15 +23,18 @@ import jakarta.faces.component.UIInput; import jakarta.faces.context.FacesContext; + import java.util.Locale; + +import static org.junit.jupiter.api.Assertions.*; + import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; /** * Test the {@link DoubleConverter}. */ -public class DoubleConverterTest extends AbstractFacesTestCase { +class DoubleConverterTest extends AbstractFacesTestCase { private DoubleConverter mock; @@ -57,28 +60,28 @@ public void tearDown() throws Exception * the focus here is on the comma separator ',' in germany. */ @Test - public void testDoubleParsingGermany() + void doubleParsingGermany() { FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMANY); UIInput input = new UIInput(); { Double d = (Double) mock.getAsObject(FacesContext.getCurrentInstance(), input, "47,3443"); - Assertions.assertNotNull(d); - Assertions.assertEquals(47.3443d, d.doubleValue(), 0); + assertNotNull(d); + assertEquals(47.3443d, d.doubleValue(), 0); } { Double d = (Double) mock.getAsObject(FacesContext.getCurrentInstance(), input, "0,3443e3"); - Assertions.assertNotNull(d); - Assertions.assertEquals(344.3d, d.doubleValue(), 0); + assertNotNull(d); + assertEquals(344.3d, d.doubleValue(), 0); } { // values with a dot as decimal separator should still work... Double d = (Double) mock.getAsObject(FacesContext.getCurrentInstance(), input, "0.3443e3"); - Assertions.assertNotNull(d); - Assertions.assertEquals(344.3d, d.doubleValue(), 0); + assertNotNull(d); + assertEquals(344.3d, d.doubleValue(), 0); } } @@ -87,15 +90,15 @@ public void testDoubleParsingGermany() * the focus here is on the comma separator '.' in the US. */ @Test - public void testDoubleParsingUS() + void doubleParsingUS() { FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.US); UIInput input = new UIInput(); { Double d = (Double) mock.getAsObject(FacesContext.getCurrentInstance(), input, "47.3443"); - Assertions.assertNotNull(d); - Assertions.assertEquals(47.3443d, d.doubleValue(), 0); + assertNotNull(d); + assertEquals(47.3443d, d.doubleValue(), 0); } { @@ -103,7 +106,7 @@ public void testDoubleParsingUS() try { Double d = (Double) mock.getAsObject(FacesContext.getCurrentInstance(), input, "47,3443"); - Assertions.fail(); + fail(); } catch (ConverterException cev) { diff --git a/impl/src/test/java/jakarta/faces/convert/EnumConverterTest.java b/impl/src/test/java/jakarta/faces/convert/EnumConverterTest.java index af1036f182..4a1d5b498f 100644 --- a/impl/src/test/java/jakarta/faces/convert/EnumConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/EnumConverterTest.java @@ -19,19 +19,20 @@ package jakarta.faces.convert; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.faces.component.UIInput; import jakarta.faces.context.FacesContext; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; /** * This testcase test jakarta.faces.convert.EnumConverter. */ -public class EnumConverterTest extends AbstractFacesTestCase +class EnumConverterTest extends AbstractFacesTestCase { private enum testEnum { @@ -70,11 +71,11 @@ public void tearDown() throws Exception * {@link jakarta.faces.convert.EnumConverter#getAsObject(FacesContext, jakarta.faces.component.UIComponent, String)}. */ @Test - public void testGetAsObject() + void getAsObject() { UIInput input = new UIInput(); Object convertedObj = converter.getAsObject(FacesContext.getCurrentInstance(), input, "ITEM2"); - Assertions.assertEquals(convertedObj, testEnum.ITEM2); + assertEquals(testEnum.ITEM2, convertedObj); } /** @@ -82,11 +83,11 @@ public void testGetAsObject() * {@link jakarta.faces.convert.EnumConverter#getAsObject(FacesContext, jakarta.faces.component.UIComponent, String)}. */ @Test - public void testGetAsObjectNull() + void getAsObjectNull() { UIInput input = new UIInput(); Object convertedObj = converter.getAsObject(FacesContext.getCurrentInstance(), input, null); - Assertions.assertNull(convertedObj); + assertNull(convertedObj); } /** @@ -94,13 +95,13 @@ public void testGetAsObjectNull() * {@link jakarta.faces.convert.EnumConverter#getAsObject(FacesContext, jakarta.faces.component.UIComponent, String)}. */ @Test - public void testGetAsObjectNoEnum() + void getAsObjectNoEnum() { UIInput input = new UIInput(); try { converter.getAsObject(FacesContext.getCurrentInstance(), input, "NO_ENUM_CONST"); - Assertions.fail("Converter exception should be thrown"); + fail("Converter exception should be thrown"); } catch (ConverterException e) { @@ -113,14 +114,14 @@ public void testGetAsObjectNoEnum() * {@link jakarta.faces.convert.EnumConverter#getAsObject(FacesContext, jakarta.faces.component.UIComponent, String)}. */ @Test - public void testGetAsObjectNoClassSet() + void getAsObjectNoClassSet() { Converter testConverter = new EnumConverter(); UIInput input = new UIInput(); try { testConverter.getAsObject(FacesContext.getCurrentInstance(), input, "ITEM2"); - Assertions.fail("Converter exception should be thrown"); + fail("Converter exception should be thrown"); } catch (ConverterException e) { @@ -133,11 +134,11 @@ public void testGetAsObjectNoClassSet() * {@link jakarta.faces.convert.EnumConverter#getAsString(FacesContext, jakarta.faces.component.UIComponent, Enum)}. */ @Test - public void testGetAsString() + void getAsString() { UIInput input = new UIInput(); String convertedStr = converter.getAsString(FacesContext.getCurrentInstance(), input, testEnum.ITEM1); - Assertions.assertEquals(convertedStr, testEnum.ITEM1.name()); + assertEquals(convertedStr, testEnum.ITEM1.name()); } /** @@ -145,11 +146,11 @@ public void testGetAsString() * {@link jakarta.faces.convert.EnumConverter#getAsString(FacesContext, jakarta.faces.component.UIComponent, Enum)}. */ @Test - public void testGetAsStringNull() + void getAsStringNull() { UIInput input = new UIInput(); String convertedStr = converter.getAsString(FacesContext.getCurrentInstance(), input, null); - Assertions.assertEquals(convertedStr, ""); + assertEquals("", convertedStr); } /** @@ -157,14 +158,14 @@ public void testGetAsStringNull() * {@link jakarta.faces.convert.EnumConverter#getAsString(FacesContext, jakarta.faces.component.UIComponent, Enum)}. */ @Test - public void testGetAsStringNoClassSet() + void getAsStringNoClassSet() { Converter testConverter = new EnumConverter(); UIInput input = new UIInput(); try { testConverter.getAsString(FacesContext.getCurrentInstance(), input, testEnum.ITEM1); - Assertions.fail("Converter exception should be thrown"); + fail("Converter exception should be thrown"); } catch (ConverterException e) { diff --git a/impl/src/test/java/jakarta/faces/convert/MessageUtilsTest.java b/impl/src/test/java/jakarta/faces/convert/MessageUtilsTest.java index b6bf7a4a9e..4a5a8e5928 100644 --- a/impl/src/test/java/jakarta/faces/convert/MessageUtilsTest.java +++ b/impl/src/test/java/jakarta/faces/convert/MessageUtilsTest.java @@ -18,29 +18,30 @@ */ package jakarta.faces.convert; +import static org.junit.jupiter.api.Assertions.assertEquals; + import jakarta.el.ValueExpression; import jakarta.faces.component.html.HtmlInputText; import org.apache.myfaces.core.api.shared.MessageUtils; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.apache.myfaces.test.el.MockValueExpression; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class MessageUtilsTest extends AbstractFacesTestCase +class MessageUtilsTest extends AbstractFacesTestCase { @Test - public void testGetLabelFromAttributesMap() + void getLabelFromAttributesMap() { HtmlInputText inputText = new HtmlInputText(); inputText.getAttributes().put("label", "testLabel"); Object label = MessageUtils.getLabel(facesContext, inputText); - Assertions.assertEquals("testLabel", label); + assertEquals("testLabel", label); } @Test - public void testGetLabelFromValueExpression() + void getLabelFromValueExpression() { facesContext.getExternalContext().getRequestMap().put("lbl", "testLabel"); HtmlInputText inputText = new HtmlInputText(); @@ -48,15 +49,15 @@ public void testGetLabelFromValueExpression() inputText.setValueExpression("label", expression); Object label = MessageUtils.getLabel(facesContext, inputText); - Assertions.assertEquals("testLabel", label); + assertEquals("testLabel", label); } @Test - public void testGetLabelReturnsClientIdWhenLabelIsNotSpecified() + void getLabelReturnsClientIdWhenLabelIsNotSpecified() { HtmlInputText inputText = new HtmlInputText(); inputText.setId("testId"); Object label = MessageUtils.getLabel(facesContext, inputText); - Assertions.assertEquals("testId", label); + assertEquals("testId", label); } } \ No newline at end of file diff --git a/impl/src/test/java/jakarta/faces/convert/NumberConverterTest.java b/impl/src/test/java/jakarta/faces/convert/NumberConverterTest.java index 066f8883ba..394ac9fe77 100644 --- a/impl/src/test/java/jakarta/faces/convert/NumberConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/NumberConverterTest.java @@ -19,19 +19,17 @@ package jakarta.faces.convert; +import static org.junit.jupiter.api.Assertions.*; + import java.math.BigInteger; import java.util.Locale; import jakarta.el.ValueExpression; import jakarta.faces.component.UIInput; import jakarta.faces.context.FacesContext; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.*; -public class NumberConverterTest extends AbstractFacesTestCase +class NumberConverterTest extends AbstractFacesTestCase { private NumberConverter mock; @@ -59,7 +57,7 @@ public void tearDown() throws Exception */ @Test @Disabled("French currency input vs JDK locale data; enable when expectations match the runtime") - public void testFranceLocaleWithNonBreakingSpace() + void franceLocaleWithNonBreakingSpace() { mock.setLocale(Locale.FRANCE); FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMANY); @@ -67,26 +65,26 @@ public void testFranceLocaleWithNonBreakingSpace() mock.setType("currency"); String stringValue = mock.getAsString(facesContext, input, new Double(12345.68d)); Number number = (Number) mock.getAsObject(FacesContext.getCurrentInstance(), input, "12\u00a0345,68 \u20AC"); - Assertions.assertNotNull(number); + assertNotNull(number); } @Test @Disabled("French currency input vs JDK locale data; enable when expectations match the runtime") - public void testFranceLocaleWithoutNonBreakingSpace() + void franceLocaleWithoutNonBreakingSpace() { mock.setLocale(Locale.FRANCE); FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMANY); UIInput input = new UIInput(); mock.setType("currency"); Number number = (Number) mock.getAsObject(FacesContext.getCurrentInstance(), input, "12 345,68 \u20AC"); - Assertions.assertNotNull(number); + assertNotNull(number); } - + /** * EUR12,345.68 */ @Test - public void testUSLocaleUsingEURCurrencyCode() + void uSLocaleUsingEURCurrencyCode() { facesContext.getViewRoot().setLocale(Locale.US); mock.setLocale(Locale.US); @@ -96,15 +94,15 @@ public void testUSLocaleUsingEURCurrencyCode() Number testValue = 12345.68d; String stringValue = mock.getAsString(facesContext, input, testValue); Number number = (Number) mock.getAsObject(facesContext, input, stringValue); - Assertions.assertNotNull(number); - Assertions.assertEquals(testValue, number); + assertNotNull(number); + assertEquals(testValue, number); } /** * 12,345.68 */ @Test - public void testUKLocaleUsingEURCurrencyCode() + void uKLocaleUsingEURCurrencyCode() { facesContext.getViewRoot().setLocale(Locale.US); mock.setLocale(Locale.UK); @@ -114,15 +112,15 @@ public void testUKLocaleUsingEURCurrencyCode() Number testValue = 12345.68d; String stringValue = mock.getAsString(facesContext, input, testValue); Number number = (Number) mock.getAsObject(facesContext, input, stringValue); - Assertions.assertNotNull(number); - Assertions.assertEquals(testValue, number); + assertNotNull(number); + assertEquals(testValue, number); } - + /** * 12.345,68 */ @Test - public void testGermanyLocaleUsingEURCurrencyCode() + void germanyLocaleUsingEURCurrencyCode() { facesContext.getViewRoot().setLocale(Locale.US); mock.setLocale(Locale.GERMANY); @@ -132,12 +130,12 @@ public void testGermanyLocaleUsingEURCurrencyCode() Number testValue = 12345.68d; String stringValue = mock.getAsString(facesContext, input, testValue); Number number = (Number) mock.getAsObject(facesContext, input, stringValue); - Assertions.assertNotNull(number); - Assertions.assertEquals(testValue, number); + assertNotNull(number); + assertEquals(testValue, number); } - + @Test - public void testCurrencyPattern() + void currencyPattern() { facesContext.getViewRoot().setLocale(Locale.US); mock.setLocale(Locale.US); @@ -146,12 +144,12 @@ public void testCurrencyPattern() Number testValue = 12345.68d; String stringValue = mock.getAsString(facesContext, input, testValue); Number number = (Number) mock.getAsObject(facesContext, input, stringValue); - Assertions.assertNotNull(number); - Assertions.assertEquals(testValue, number); + assertNotNull(number); + assertEquals(testValue, number); } @Test - public void testCurrencyPattern2() + void currencyPattern2() { facesContext.getViewRoot().setLocale(Locale.US); mock.setLocale(Locale.GERMANY); @@ -161,12 +159,12 @@ public void testCurrencyPattern2() Number testValue = 12345.68d; String stringValue = mock.getAsString(facesContext, input, testValue); Number number = (Number) mock.getAsObject(facesContext, input, stringValue); - Assertions.assertNotNull(number); - Assertions.assertEquals(testValue, number); + assertNotNull(number); + assertEquals(testValue, number); } - + @Test - public void testCzechLocaleWithNonBreakingSpace() + void czechLocaleWithNonBreakingSpace() { mock.setLocale(new Locale("cs")); mock.setIntegerOnly(true); @@ -174,15 +172,15 @@ public void testCzechLocaleWithNonBreakingSpace() FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale("cs")); UIInput input = new UIInput(); String stringValue = mock.getAsString(facesContext, input, new Long(7000)); - Assertions.assertEquals("7\u00a0000", stringValue, "must return 7&NBSP000"); + assertEquals("7\u00a0000", stringValue, "must return 7&NBSP000"); Number number = (Number) mock.getAsObject(FacesContext.getCurrentInstance(), input, stringValue); - Assertions.assertNotNull(number); - Assertions.assertEquals(new Long(7000), number); + assertNotNull(number); + assertEquals(new Long(7000), number); } @Test - public void testGetAsObjectWithBigInteger() + void getAsObjectWithBigInteger() { facesContext.getViewRoot().setLocale(Locale.US); mock.setLocale(Locale.GERMANY); @@ -198,13 +196,13 @@ public void testGetAsObjectWithBigInteger() Number number = (Number) mock.getAsObject(FacesContext.getCurrentInstance(), input, "1"); - Assertions.assertNotNull(number); - Assertions.assertTrue(number instanceof BigInteger); - Assertions.assertEquals(BigInteger.ONE, number); + assertNotNull(number); + assertInstanceOf(BigInteger.class, number); + assertEquals(BigInteger.ONE, number); } - + @Test - public void testGetAsObjectWithBigIntegerAndParsePosition() + void getAsObjectWithBigIntegerAndParsePosition() { facesContext.getViewRoot().setLocale(Locale.US); mock.setLocale(Locale.GERMANY); @@ -221,7 +219,7 @@ public void testGetAsObjectWithBigIntegerAndParsePosition() try { Number number = (Number) mock.getAsObject(FacesContext.getCurrentInstance(), input, "1,0.0,00.00"); - Assertions.fail(); + fail(); } catch (ConverterException e) { @@ -230,7 +228,7 @@ public void testGetAsObjectWithBigIntegerAndParsePosition() } @Test - public void testCzechLocaleNbspGroupingStripsZeroWidthWhitespace() + void czechLocaleNbspGroupingStripsZeroWidthWhitespace() { mock.setLocale(new Locale("cs")); mock.setIntegerOnly(true); @@ -239,25 +237,20 @@ public void testCzechLocaleNbspGroupingStripsZeroWidthWhitespace() UIInput input = new UIInput(); Number number = (Number) mock.getAsObject(FacesContext.getCurrentInstance(), input, "7\u200b\u00a0000"); - Assertions.assertNotNull(number); - Assertions.assertEquals(7000L, number.longValue()); + assertNotNull(number); + assertEquals(7000L, number.longValue()); } @Test - public void testGetAsObjectParseIntOnly(){ + void getAsObjectParseIntOnly(){ facesContext.getViewRoot().setLocale(Locale.US); mock.setLocale(Locale.US); mock.setIntegerOnly(true); UIInput input = new UIInput(); - - try - { + + Assertions.assertDoesNotThrow(() -> { Number number = (Number) mock.getAsObject(FacesContext.getCurrentInstance(), input, "1,234.56"); - Assertions.assertEquals(number.intValue(), 1234); - } - catch (ConverterException e) - { - Assertions.fail(); - } + assertEquals(1234, number.intValue()); + }); } } diff --git a/impl/src/test/java/jakarta/faces/event/MethodExpressionActionListenerTest.java b/impl/src/test/java/jakarta/faces/event/MethodExpressionActionListenerTest.java index 7eb9cc6a20..12529739f6 100644 --- a/impl/src/test/java/jakarta/faces/event/MethodExpressionActionListenerTest.java +++ b/impl/src/test/java/jakarta/faces/event/MethodExpressionActionListenerTest.java @@ -18,6 +18,8 @@ */ package jakarta.faces.event; +import static org.junit.jupiter.api.Assertions.*; + import java.lang.reflect.Field; import java.util.Arrays; @@ -28,14 +30,13 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.easymock.classextension.EasyMock; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; /** * Tests for {@link MethodExpressionActionListener} */ -public class MethodExpressionActionListenerTest extends AbstractFacesTestCase +class MethodExpressionActionListenerTest extends AbstractFacesTestCase { private MethodExpression methodExpressionOneArg; @@ -74,20 +75,20 @@ public void tearDown() throws Exception } @Test - public void testMethodExpressionActionListener() + void methodExpressionActionListener() { methodExpressionActionListener = new MethodExpressionActionListener(); } @Test - public void testMethodExpressionActionListenerMethodExpression() + void methodExpressionActionListenerMethodExpression() { EasyMock.replay(methodExpressionOneArg); methodExpressionActionListener = new MethodExpressionActionListener(methodExpressionOneArg); } @Test - public void testMethodExpressionActionListenerMethodExpressionMethodExpression() + void methodExpressionActionListenerMethodExpressionMethodExpression() { EasyMock.replay(methodExpressionOneArg); EasyMock.replay(methodExpressionZeroArg); @@ -99,7 +100,7 @@ public void testMethodExpressionActionListenerMethodExpressionMethodExpression() * Test for case: method with ActionEvent param exists (pre-Faces 2.0 case) */ @Test - public void testProcessAction() + void processAction() { // First, try to invoke the MethodExpression passed to the constructor of this instance, // passing the argument ActionEvent as the argument: @@ -117,7 +118,7 @@ public void testProcessAction() * Test for case: method exists but has no ActionEvent param (new possibility in Faces 2.0) */ @Test - public void testProcessAction2() throws Exception + void processAction2() throws Exception { // First, try to invoke the MethodExpression passed to the constructor of this instance, // passing the argument ActionEvent as the argument @@ -140,16 +141,16 @@ public void testProcessAction2() throws Exception } @Test - public void testSaveState() + void saveState() { methodExpressionActionListener = new MethodExpressionActionListener(methodExpressionOneArg, methodExpressionZeroArg); Object[] expectedState = new Object [] {methodExpressionOneArg, methodExpressionZeroArg}; - Assertions.assertTrue(Arrays.deepEquals(expectedState, (Object[]) methodExpressionActionListener.saveState(facesContext)), + assertTrue(Arrays.deepEquals(expectedState, (Object[]) methodExpressionActionListener.saveState(facesContext)), "Both MethodExpression instances described in the constructor must be saved."); } @Test - public void testRestoreState() throws IllegalAccessException, NoSuchFieldException + void restoreState() throws Exception { // State saving always call JavaBean constructor: methodExpressionActionListener = new MethodExpressionActionListener(); @@ -160,31 +161,31 @@ public void testRestoreState() throws IllegalAccessException, NoSuchFieldExcepti // Test if the instance variables are set to the right values via reflection Field oneArgField = MethodExpressionActionListener.class.getDeclaredField("methodExpressionOneArg"); oneArgField.setAccessible(true); - Assertions.assertEquals(methodExpressionOneArg, oneArgField.get(methodExpressionActionListener)); + assertEquals(methodExpressionOneArg, oneArgField.get(methodExpressionActionListener)); Field zeroArgField = MethodExpressionActionListener.class.getDeclaredField("methodExpressionZeroArg"); zeroArgField.setAccessible(true); - Assertions.assertEquals(methodExpressionZeroArg, zeroArgField.get(methodExpressionActionListener)); + assertEquals(methodExpressionZeroArg, zeroArgField.get(methodExpressionActionListener)); } @Test - public void testSaveStateWhileInitialStateMarked() + void saveStateWhileInitialStateMarked() { methodExpressionActionListener = new MethodExpressionActionListener(methodExpressionOneArg, methodExpressionZeroArg); methodExpressionActionListener.markInitialState(); - Assertions.assertTrue(methodExpressionActionListener.initialStateMarked()); - Assertions.assertNull(methodExpressionActionListener.saveState(facesContext), + assertTrue(methodExpressionActionListener.initialStateMarked()); + assertNull(methodExpressionActionListener.saveState(facesContext), "No state must be saved while the initial state is marked."); methodExpressionActionListener.clearInitialState(); - Assertions.assertFalse(methodExpressionActionListener.initialStateMarked()); + assertFalse(methodExpressionActionListener.initialStateMarked()); Object[] expectedState = new Object [] {methodExpressionOneArg, methodExpressionZeroArg}; - Assertions.assertTrue(Arrays.deepEquals(expectedState, (Object[]) methodExpressionActionListener.saveState(facesContext)), + assertTrue(Arrays.deepEquals(expectedState, (Object[]) methodExpressionActionListener.saveState(facesContext)), "Both MethodExpression instances must be saved after clearInitialState()."); } @Test - public void testRestoreNullState() throws IllegalAccessException, NoSuchFieldException + void restoreNullState() throws Exception { methodExpressionActionListener = new MethodExpressionActionListener(methodExpressionOneArg, methodExpressionZeroArg); methodExpressionActionListener.markInitialState(); @@ -192,11 +193,11 @@ public void testRestoreNullState() throws IllegalAccessException, NoSuchFieldExc Field oneArgField = MethodExpressionActionListener.class.getDeclaredField("methodExpressionOneArg"); oneArgField.setAccessible(true); - Assertions.assertEquals(methodExpressionOneArg, oneArgField.get(methodExpressionActionListener)); + assertEquals(methodExpressionOneArg, oneArgField.get(methodExpressionActionListener)); Field zeroArgField = MethodExpressionActionListener.class.getDeclaredField("methodExpressionZeroArg"); zeroArgField.setAccessible(true); - Assertions.assertEquals(methodExpressionZeroArg, zeroArgField.get(methodExpressionActionListener)); + assertEquals(methodExpressionZeroArg, zeroArgField.get(methodExpressionActionListener)); } } diff --git a/impl/src/test/java/jakarta/faces/event/MethodExpressionPartialStateHolderTest.java b/impl/src/test/java/jakarta/faces/event/MethodExpressionPartialStateHolderTest.java index b5c6383ed5..68d988c0e7 100644 --- a/impl/src/test/java/jakarta/faces/event/MethodExpressionPartialStateHolderTest.java +++ b/impl/src/test/java/jakarta/faces/event/MethodExpressionPartialStateHolderTest.java @@ -18,6 +18,7 @@ */ package jakarta.faces.event; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.mock; import jakarta.el.MethodExpression; @@ -31,7 +32,6 @@ import jakarta.faces.validator.Validator; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -39,22 +39,22 @@ * {@link MethodExpressionValidator} leave no state in a component whose initial state is marked, and keep their full * state whenever the component saves its full state. */ -public class MethodExpressionPartialStateHolderTest extends AbstractFacesTestCase +class MethodExpressionPartialStateHolderTest extends AbstractFacesTestCase { @Test - public void testMarkedCommandSavesNoActionListenerState() + void markedCommandSavesNoActionListenerState() { UICommand command = new UICommand(); command.addActionListener(new MethodExpressionActionListener(mock(MethodExpression.class), mock(MethodExpression.class))); command.markInitialState(); - Assertions.assertNull(command.saveState(facesContext)); + assertNull(command.saveState(facesContext)); } @Test - public void testMarkedInputSavesNoValueChangeListenerNorValidatorState() + void markedInputSavesNoValueChangeListenerNorValidatorState() { UIInput input = new UIInput(); input.addValueChangeListener(new MethodExpressionValueChangeListener(mock(MethodExpression.class), @@ -62,11 +62,11 @@ public void testMarkedInputSavesNoValueChangeListenerNorValidatorState() input.addValidator(new MethodExpressionValidator(mock(MethodExpression.class))); input.markInitialState(); - Assertions.assertNull(input.saveState(facesContext)); + assertNull(input.saveState(facesContext)); } @Test - public void testActionListenerAddedAfterMarkingIsRestoredFromFullState() + void actionListenerAddedAfterMarkingIsRestoredFromFullState() { MethodExpression oneArg = mock(MethodExpression.class); MethodExpression zeroArg = mock(MethodExpression.class); @@ -74,20 +74,20 @@ public void testActionListenerAddedAfterMarkingIsRestoredFromFullState() command.markInitialState(); command.addActionListener(new MethodExpressionActionListener(oneArg, zeroArg)); Object state = command.saveState(facesContext); - Assertions.assertNotNull(state); + assertNotNull(state); UICommand restored = new UICommand(); restored.restoreState(facesContext, state); ActionListener[] listeners = restored.getActionListeners(); - Assertions.assertEquals(1, listeners.length); - MethodExpressionActionListener listener = Assertions.assertInstanceOf(MethodExpressionActionListener.class, + assertEquals(1, listeners.length); + MethodExpressionActionListener listener = assertInstanceOf(MethodExpressionActionListener.class, listeners[0]); - Assertions.assertArrayEquals(new Object[] { oneArg, zeroArg }, (Object[]) listener.saveState(facesContext)); + assertArrayEquals(new Object[] { oneArg, zeroArg }, (Object[]) listener.saveState(facesContext)); } @Test - public void testValueChangeListenerAddedAfterMarkingIsRestoredFromFullState() + void valueChangeListenerAddedAfterMarkingIsRestoredFromFullState() { MethodExpression oneArg = mock(MethodExpression.class); MethodExpression zeroArg = mock(MethodExpression.class); @@ -95,20 +95,20 @@ public void testValueChangeListenerAddedAfterMarkingIsRestoredFromFullState() input.markInitialState(); input.addValueChangeListener(new MethodExpressionValueChangeListener(oneArg, zeroArg)); Object state = input.saveState(facesContext); - Assertions.assertNotNull(state); + assertNotNull(state); UIInput restored = new UIInput(); restored.restoreState(facesContext, state); ValueChangeListener[] listeners = restored.getValueChangeListeners(); - Assertions.assertEquals(1, listeners.length); - MethodExpressionValueChangeListener listener = Assertions.assertInstanceOf( + assertEquals(1, listeners.length); + MethodExpressionValueChangeListener listener = assertInstanceOf( MethodExpressionValueChangeListener.class, listeners[0]); - Assertions.assertArrayEquals(new Object[] { oneArg, zeroArg }, (Object[]) listener.saveState(facesContext)); + assertArrayEquals(new Object[] { oneArg, zeroArg }, (Object[]) listener.saveState(facesContext)); } @Test - public void testTransientActionListenerIsNotRestored() + void transientActionListenerIsNotRestored() { UICommand command = new UICommand(); MethodExpressionActionListener listener = new MethodExpressionActionListener(mock(MethodExpression.class), @@ -120,11 +120,11 @@ public void testTransientActionListenerIsNotRestored() UICommand restored = new UICommand(); restored.restoreState(facesContext, state); - Assertions.assertEquals(0, restored.getActionListeners().length); + assertEquals(0, restored.getActionListeners().length); } @Test - public void testClearedListenerRoundTripsThroughAttachedState() + void clearedListenerRoundTripsThroughAttachedState() { MethodExpression oneArg = mock(MethodExpression.class); MethodExpression zeroArg = mock(MethodExpression.class); @@ -135,28 +135,28 @@ public void testClearedListenerRoundTripsThroughAttachedState() Object restored = UIComponentBase.restoreAttachedState(facesContext, UIComponentBase.saveAttachedState(facesContext, listener)); - MethodExpressionActionListener restoredListener = Assertions.assertInstanceOf( + MethodExpressionActionListener restoredListener = assertInstanceOf( MethodExpressionActionListener.class, restored); - Assertions.assertArrayEquals(new Object[] { oneArg, zeroArg }, + assertArrayEquals(new Object[] { oneArg, zeroArg }, (Object[]) restoredListener.saveState(facesContext)); } @Test - public void testMarkedValidatorKeepsItsExpressionWhenSiblingStateIsRestored() + void markedValidatorKeepsItsExpressionWhenSiblingStateIsRestored() { MethodExpression expression = mock(MethodExpression.class); Object state = buildMarkedInput(expression, "changed").saveState(facesContext); - Assertions.assertNotNull(state); + assertNotNull(state); UIInput rebuilt = buildMarkedInput(expression, "built"); rebuilt.restoreState(facesContext, state); Validator[] validators = rebuilt.getValidators(); - MethodExpressionValidator validator = Assertions.assertInstanceOf(MethodExpressionValidator.class, + MethodExpressionValidator validator = assertInstanceOf(MethodExpressionValidator.class, validators[0]); validator.clearInitialState(); - Assertions.assertSame(expression, validator.saveState(facesContext)); - Assertions.assertEquals("changed", ((StatefulValidator) validators[1]).config); + assertSame(expression, validator.saveState(facesContext)); + assertEquals("changed", ((StatefulValidator) validators[1]).config); } private static UIInput buildMarkedInput(MethodExpression expression, String siblingConfig) diff --git a/impl/src/test/java/jakarta/faces/event/MethodExpressionValueChangeListenerTest.java b/impl/src/test/java/jakarta/faces/event/MethodExpressionValueChangeListenerTest.java index 22a44f0477..ad0b4e9223 100644 --- a/impl/src/test/java/jakarta/faces/event/MethodExpressionValueChangeListenerTest.java +++ b/impl/src/test/java/jakarta/faces/event/MethodExpressionValueChangeListenerTest.java @@ -18,6 +18,8 @@ */ package jakarta.faces.event; +import static org.junit.jupiter.api.Assertions.*; + import java.lang.reflect.Field; import java.util.Arrays; @@ -28,14 +30,13 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.easymock.classextension.EasyMock; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; /** * Tests for {@link MethodExpressionValueChangeListener} */ -public class MethodExpressionValueChangeListenerTest extends AbstractFacesTestCase +class MethodExpressionValueChangeListenerTest extends AbstractFacesTestCase { private MethodExpression methodExpressionOneArg; @@ -74,20 +75,20 @@ public void tearDown() throws Exception } @Test - public void testMethodExpressionValueChangeListener() + void methodExpressionValueChangeListener() { methodExpressionValueChangeListener = new MethodExpressionValueChangeListener(); } @Test - public void testMethodExpressionValueChangeListenerMethodExpression() + void methodExpressionValueChangeListenerMethodExpression() { EasyMock.replay(methodExpressionOneArg); methodExpressionValueChangeListener = new MethodExpressionValueChangeListener(methodExpressionOneArg); } @Test - public void testMethodExpressionValueChangeListenerMethodExpressionMethodExpression() + void methodExpressionValueChangeListenerMethodExpressionMethodExpression() { EasyMock.replay(methodExpressionOneArg); EasyMock.replay(methodExpressionZeroArg); @@ -99,7 +100,7 @@ public void testMethodExpressionValueChangeListenerMethodExpressionMethodExpress * Test for case: method with ValueChangeEvent param exists (pre-Faces 2.0 case) */ @Test - public void testProcessValueChange() + void processValueChange() { // First, try to invoke the MethodExpression passed to the constructor of this instance, // passing the argument ValueChangeEvent as the argument: @@ -117,7 +118,7 @@ public void testProcessValueChange() * Test for case: method exists but has no ValueChangeEvent param (new possibility in Faces 2.0) */ @Test - public void testProcessValueChange2() throws Exception + void processValueChange2() throws Exception { // First, try to invoke the MethodExpression passed to the constructor of this instance, // passing the argument ValueChangeEvent as the argument @@ -140,16 +141,16 @@ public void testProcessValueChange2() throws Exception } @Test - public void testSaveState() + void saveState() { methodExpressionValueChangeListener = new MethodExpressionValueChangeListener(methodExpressionOneArg, methodExpressionZeroArg); Object[] expectedState = new Object [] {methodExpressionOneArg, methodExpressionZeroArg}; - Assertions.assertTrue(Arrays.deepEquals(expectedState, (Object[]) methodExpressionValueChangeListener.saveState(facesContext)), + assertTrue(Arrays.deepEquals(expectedState, (Object[]) methodExpressionValueChangeListener.saveState(facesContext)), "Both MethodExpression instances described in the constructor must be saved."); } @Test - public void testRestoreState() throws IllegalAccessException, NoSuchFieldException + void restoreState() throws Exception { // State saving always call JavaBean constructor: methodExpressionValueChangeListener = new MethodExpressionValueChangeListener(); @@ -160,31 +161,31 @@ public void testRestoreState() throws IllegalAccessException, NoSuchFieldExcepti // Test if the instance variables are set to the right values via reflection Field oneArgField = MethodExpressionValueChangeListener.class.getDeclaredField("methodExpressionOneArg"); oneArgField.setAccessible(true); - Assertions.assertEquals(methodExpressionOneArg, oneArgField.get(methodExpressionValueChangeListener)); + assertEquals(methodExpressionOneArg, oneArgField.get(methodExpressionValueChangeListener)); Field zeroArgField = MethodExpressionValueChangeListener.class.getDeclaredField("methodExpressionZeroArg"); zeroArgField.setAccessible(true); - Assertions.assertEquals(methodExpressionZeroArg, zeroArgField.get(methodExpressionValueChangeListener)); + assertEquals(methodExpressionZeroArg, zeroArgField.get(methodExpressionValueChangeListener)); } @Test - public void testSaveStateWhileInitialStateMarked() + void saveStateWhileInitialStateMarked() { methodExpressionValueChangeListener = new MethodExpressionValueChangeListener(methodExpressionOneArg, methodExpressionZeroArg); methodExpressionValueChangeListener.markInitialState(); - Assertions.assertTrue(methodExpressionValueChangeListener.initialStateMarked()); - Assertions.assertNull(methodExpressionValueChangeListener.saveState(facesContext), + assertTrue(methodExpressionValueChangeListener.initialStateMarked()); + assertNull(methodExpressionValueChangeListener.saveState(facesContext), "No state must be saved while the initial state is marked."); methodExpressionValueChangeListener.clearInitialState(); - Assertions.assertFalse(methodExpressionValueChangeListener.initialStateMarked()); + assertFalse(methodExpressionValueChangeListener.initialStateMarked()); Object[] expectedState = new Object [] {methodExpressionOneArg, methodExpressionZeroArg}; - Assertions.assertTrue(Arrays.deepEquals(expectedState, (Object[]) methodExpressionValueChangeListener.saveState(facesContext)), + assertTrue(Arrays.deepEquals(expectedState, (Object[]) methodExpressionValueChangeListener.saveState(facesContext)), "Both MethodExpression instances must be saved after clearInitialState()."); } @Test - public void testRestoreNullState() throws IllegalAccessException, NoSuchFieldException + void restoreNullState() throws Exception { methodExpressionValueChangeListener = new MethodExpressionValueChangeListener(methodExpressionOneArg, methodExpressionZeroArg); methodExpressionValueChangeListener.markInitialState(); @@ -192,11 +193,11 @@ public void testRestoreNullState() throws IllegalAccessException, NoSuchFieldExc Field oneArgField = MethodExpressionValueChangeListener.class.getDeclaredField("methodExpressionOneArg"); oneArgField.setAccessible(true); - Assertions.assertEquals(methodExpressionOneArg, oneArgField.get(methodExpressionValueChangeListener)); + assertEquals(methodExpressionOneArg, oneArgField.get(methodExpressionValueChangeListener)); Field zeroArgField = MethodExpressionValueChangeListener.class.getDeclaredField("methodExpressionZeroArg"); zeroArgField.setAccessible(true); - Assertions.assertEquals(methodExpressionZeroArg, zeroArgField.get(methodExpressionValueChangeListener)); + assertEquals(methodExpressionZeroArg, zeroArgField.get(methodExpressionValueChangeListener)); } } diff --git a/impl/src/test/java/jakarta/faces/validator/MethodExpressionValidatorTest.java b/impl/src/test/java/jakarta/faces/validator/MethodExpressionValidatorTest.java index 31b69fece6..8a19463087 100644 --- a/impl/src/test/java/jakarta/faces/validator/MethodExpressionValidatorTest.java +++ b/impl/src/test/java/jakarta/faces/validator/MethodExpressionValidatorTest.java @@ -18,6 +18,8 @@ */ package jakarta.faces.validator; +import static org.junit.jupiter.api.Assertions.*; + import java.lang.reflect.Field; import jakarta.el.MethodExpression; @@ -25,14 +27,13 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.easymock.classextension.EasyMock; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; /** * Tests for {@link MethodExpressionValidator} */ -public class MethodExpressionValidatorTest extends AbstractFacesTestCase +class MethodExpressionValidatorTest extends AbstractFacesTestCase { private MethodExpression methodExpression; @@ -47,52 +48,52 @@ public void setUp() throws Exception } @Test - public void testSaveAndRestoreState() throws Exception + void saveAndRestoreState() throws Exception { MethodExpressionValidator validator = new MethodExpressionValidator(methodExpression); Object state = validator.saveState(facesContext); - Assertions.assertNotNull(state); + assertNotNull(state); MethodExpressionValidator restored = new MethodExpressionValidator(); restored.restoreState(facesContext, state); - Assertions.assertSame(methodExpression, getMethodExpression(restored)); + assertSame(methodExpression, getMethodExpression(restored)); } @Test - public void testSaveStateWhileInitialStateMarked() + void saveStateWhileInitialStateMarked() { MethodExpressionValidator validator = new MethodExpressionValidator(methodExpression); validator.markInitialState(); - Assertions.assertTrue(validator.initialStateMarked()); - Assertions.assertNull(validator.saveState(facesContext), + assertTrue(validator.initialStateMarked()); + assertNull(validator.saveState(facesContext), "No state must be saved while the initial state is marked."); validator.clearInitialState(); - Assertions.assertFalse(validator.initialStateMarked()); - Assertions.assertSame(methodExpression, validator.saveState(facesContext), + assertFalse(validator.initialStateMarked()); + assertSame(methodExpression, validator.saveState(facesContext), "The MethodExpression must be saved after clearInitialState()."); } @Test - public void testRestoreNullState() throws Exception + void restoreNullState() throws Exception { MethodExpressionValidator validator = new MethodExpressionValidator(methodExpression); validator.markInitialState(); validator.restoreState(facesContext, null); - Assertions.assertSame(methodExpression, getMethodExpression(validator)); + assertSame(methodExpression, getMethodExpression(validator)); } /** * The view state of an unchanged component holds no state for its MethodExpressionValidator. */ @Test - public void testUnchangedComponentHasNoState() + void unchangedComponentHasNoState() { UIInput input = new UIInput(); input.addValidator(new MethodExpressionValidator(methodExpression)); input.markInitialState(); - Assertions.assertNull(input.saveState(facesContext)); + assertNull(input.saveState(facesContext)); } /** @@ -100,7 +101,7 @@ public void testUnchangedComponentHasNoState() * holds a null state for the MethodExpressionValidator, which must keep the MethodExpression of the build. */ @Test - public void testDeltaRestoreKeepsMethodExpression() throws Exception + void deltaRestoreKeepsMethodExpression() throws Exception { UIInput input = new UIInput(); LengthValidator lengthValidator = new LengthValidator(); @@ -110,7 +111,7 @@ public void testDeltaRestoreKeepsMethodExpression() throws Exception lengthValidator.setMaximum(5); Object state = input.saveState(facesContext); - Assertions.assertNotNull(state); + assertNotNull(state); // rebuild the view UIInput rebuilt = new UIInput(); @@ -120,9 +121,9 @@ public void testDeltaRestoreKeepsMethodExpression() throws Exception rebuilt.restoreState(facesContext, state); Validator[] validators = rebuilt.getValidators(); - Assertions.assertEquals(2, validators.length); - Assertions.assertEquals(5, ((LengthValidator) validators[0]).getMaximum()); - Assertions.assertSame(methodExpression, getMethodExpression((MethodExpressionValidator) validators[1])); + assertEquals(2, validators.length); + assertEquals(5, ((LengthValidator) validators[0]).getMaximum()); + assertSame(methodExpression, getMethodExpression((MethodExpressionValidator) validators[1])); } private static MethodExpression getMethodExpression(MethodExpressionValidator validator) throws Exception diff --git a/impl/src/test/java/jakarta/faces/validator/ValidatorExceptionTest.java b/impl/src/test/java/jakarta/faces/validator/ValidatorExceptionTest.java index 9af186b43a..c961422bee 100644 --- a/impl/src/test/java/jakarta/faces/validator/ValidatorExceptionTest.java +++ b/impl/src/test/java/jakarta/faces/validator/ValidatorExceptionTest.java @@ -26,10 +26,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class ValidatorExceptionTest +class ValidatorExceptionTest { @Test - public void singleFacesMessageNullSummary() + void singleFacesMessageNullSummary() { FacesMessage message = new FacesMessage(null, null); @@ -38,7 +38,7 @@ public void singleFacesMessageNullSummary() } @Test - public void singleFacesMessageWithDetail() + void singleFacesMessageWithDetail() { FacesMessage message = new FacesMessage("summary", "detail"); @@ -47,7 +47,7 @@ public void singleFacesMessageWithDetail() } @Test - public void singleFacesMessageEmptyDetail() + void singleFacesMessageEmptyDetail() { FacesMessage message = new FacesMessage("summary", ""); @@ -57,7 +57,7 @@ public void singleFacesMessageEmptyDetail() } @Test - public void singleFacesMaessageNullDetail() + void singleFacesMaessageNullDetail() { FacesMessage message = new FacesMessage("summary", null); @@ -66,7 +66,7 @@ public void singleFacesMaessageNullDetail() } @Test - public void multipleFacesMessagesSummaryNull() + void multipleFacesMessagesSummaryNull() { List messages = List.of( new FacesMessage(null, null), @@ -78,7 +78,7 @@ public void multipleFacesMessagesSummaryNull() @Test - public void multipleFacesMessagesWithDetail() + void multipleFacesMessagesWithDetail() { List messages = List.of( new FacesMessage("summary1", "detail1"), @@ -89,7 +89,7 @@ public void multipleFacesMessagesWithDetail() } @Test - public void multipleFacesMessagesEmptyDetail() + void multipleFacesMessagesEmptyDetail() { List messages = List.of( new FacesMessage("summary1", ""), @@ -101,7 +101,7 @@ public void multipleFacesMessagesEmptyDetail() } @Test - public void multipleFacesMessagesNullDetail() + void multipleFacesMessagesNullDetail() { List messages = List.of( new FacesMessage("summary1", null), diff --git a/impl/src/test/java/jakarta/faces/validator/_MessageUtilsTest.java b/impl/src/test/java/jakarta/faces/validator/_MessageUtilsTest.java index 2094aff954..12c7481243 100644 --- a/impl/src/test/java/jakarta/faces/validator/_MessageUtilsTest.java +++ b/impl/src/test/java/jakarta/faces/validator/_MessageUtilsTest.java @@ -21,6 +21,7 @@ import org.apache.myfaces.core.api.shared.MessageUtils; import java.util.HashMap; import static org.easymock.EasyMock.expect; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Locale; @@ -34,10 +35,9 @@ import org.apache.myfaces.test.mock.MockFacesContext; import org.easymock.classextension.EasyMock; import org.easymock.classextension.IMocksControl; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class _MessageUtilsTest +class _MessageUtilsTest { /** @@ -45,7 +45,7 @@ public class _MessageUtilsTest * {@link jakarta.faces.validator._MessageUtils#getErrorMessage(jakarta.faces.context.FacesContext, java.lang.String, java.lang.Object[])}. */ @Test - public void testErrorMessage() + void errorMessage() { UIViewRoot root = new UIViewRoot(); MockFacesContext facesContext = new MockFacesContext(); @@ -71,9 +71,9 @@ public void testErrorMessage() expect(valueExpression.getValue(elContext)).andReturn(s); mocksControl.replay(); - Assertions.assertEquals(MessageUtils.getErrorMessage(facesContext, "jakarta.faces.validator.DoubleRangeValidator.MAXIMUM", - new Object[] { "xyz", "xxx" }).getDetail(), - "xxx: Validation Error: Value is greater than allowable maximum of 'xyz'"); + assertEquals( + "xxx: Validation Error: Value is greater than allowable maximum of 'xyz'", MessageUtils.getErrorMessage(facesContext, "jakarta.faces.validator.DoubleRangeValidator.MAXIMUM", + new Object[]{"xyz", "xxx"}).getDetail()); } } diff --git a/impl/src/test/java/org/apache/myfaces/application/ApplicationImplAnnotationTest.java b/impl/src/test/java/org/apache/myfaces/application/ApplicationImplAnnotationTest.java index fee9a43470..7ca5bd2b8c 100644 --- a/impl/src/test/java/org/apache/myfaces/application/ApplicationImplAnnotationTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/ApplicationImplAnnotationTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.application; +import static org.junit.jupiter.api.Assertions.*; + import java.util.List; import java.util.Map; import java.util.TimeZone; @@ -48,7 +50,6 @@ import org.apache.myfaces.test.mock.MockRenderKit; import org.apache.myfaces.test.mock.MockRenderKitFactory; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class ApplicationImplAnnotationTest extends AbstractFacesConfigurableMockTestCase @@ -215,7 +216,7 @@ public Renderer getWrapped() @Test - public void testCreateComponentRenderer() throws Exception + void createComponentRenderer() throws Exception { facesContext.getViewRoot().setRenderKitId( MockRenderKitFactory.HTML_BASIC_RENDER_KIT); @@ -231,12 +232,12 @@ public void testCreateComponentRenderer() throws Exception UITestComponentA.DEFAULT_RENDERER_TYPE); List componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(1,componentResources.size()); + assertEquals(1,componentResources.size()); Map attrMap = componentResources.get(0).getAttributes(); - Assertions.assertEquals("testResource.js",attrMap.get("name")); - Assertions.assertEquals("testLib",attrMap.get("library")); + assertEquals("testResource.js",attrMap.get("name")); + assertEquals("testLib",attrMap.get("library")); } - + /** * This test has a RendererWrapper that implement ComponentSystemEventListener, but it does not * have a @ListenerFor annotation, in this case the listener that receive the event is the @@ -245,7 +246,7 @@ public void testCreateComponentRenderer() throws Exception * @throws Exception */ @Test - public void testCreateComponentRendererWrapper1() throws Exception + void createComponentRendererWrapper1() throws Exception { facesContext.getViewRoot().setRenderKitId( MockRenderKitFactory.HTML_BASIC_RENDER_KIT); @@ -261,16 +262,16 @@ public void testCreateComponentRendererWrapper1() throws Exception UITestComponentA.DEFAULT_RENDERER_TYPE); List componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(1,componentResources.size()); + assertEquals(1,componentResources.size()); Map attrMap = componentResources.get(0).getAttributes(); - Assertions.assertEquals("testResource.js",attrMap.get("name")); - Assertions.assertEquals("testLib",attrMap.get("library")); + assertEquals("testResource.js",attrMap.get("name")); + assertEquals("testLib",attrMap.get("library")); // Invoke PostAddToViewEvent facesContext.getViewRoot().getChildren().add(comp); - Assertions.assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper")); - Assertions.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); + assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper")); + assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); facesContext.getAttributes().remove("oam.test.TestRendererWrapper"); facesContext.getAttributes().remove("oam.test.TestRendererA"); @@ -294,10 +295,10 @@ public void testCreateComponentRendererWrapper1() throws Exception // Invoke PostAddToViewEvent facesContext.getViewRoot().getChildren().add(comp2); - Assertions.assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper")); - Assertions.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); + assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper")); + assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); } - + /** * This test has a RendererWrapper that does not implement ComponentSystemEventListener, in this case * the listener is the wrapped Renderer (TestRendererA). @@ -305,7 +306,7 @@ public void testCreateComponentRendererWrapper1() throws Exception * @throws Exception */ @Test - public void testCreateComponentRendererWrapper2() throws Exception + void createComponentRendererWrapper2() throws Exception { facesContext.getViewRoot().setRenderKitId( MockRenderKitFactory.HTML_BASIC_RENDER_KIT); @@ -321,15 +322,15 @@ public void testCreateComponentRendererWrapper2() throws Exception UITestComponentA.DEFAULT_RENDERER_TYPE); List componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(1,componentResources.size()); + assertEquals(1,componentResources.size()); Map attrMap = componentResources.get(0).getAttributes(); - Assertions.assertEquals("testResource.js",attrMap.get("name")); - Assertions.assertEquals("testLib",attrMap.get("library")); + assertEquals("testResource.js",attrMap.get("name")); + assertEquals("testLib",attrMap.get("library")); // Invoke PostAddToViewEvent facesContext.getViewRoot().getChildren().add(comp); - Assertions.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); + assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); facesContext.getAttributes().remove("oam.test.TestRendererA"); @@ -352,15 +353,15 @@ public void testCreateComponentRendererWrapper2() throws Exception // Invoke PostAddToViewEvent facesContext.getViewRoot().getChildren().add(comp2); - Assertions.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); + assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); } - + /** * * @throws Exception */ @Test - public void testCreateComponentRendererWrapper3() throws Exception + void createComponentRendererWrapper3() throws Exception { facesContext.getViewRoot().setRenderKitId( MockRenderKitFactory.HTML_BASIC_RENDER_KIT); @@ -377,16 +378,16 @@ public void testCreateComponentRendererWrapper3() throws Exception UITestComponentA.DEFAULT_RENDERER_TYPE); List componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(1,componentResources.size()); + assertEquals(1,componentResources.size()); Map attrMap = componentResources.get(0).getAttributes(); - Assertions.assertEquals("testResource.js",attrMap.get("name")); - Assertions.assertEquals("testLib",attrMap.get("library")); + assertEquals("testResource.js",attrMap.get("name")); + assertEquals("testLib",attrMap.get("library")); // Invoke PostAddToViewEvent facesContext.getViewRoot().getChildren().add(comp); - Assertions.assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper")); - Assertions.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); + assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper")); + assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); facesContext.getAttributes().remove("oam.test.TestRendererWrapper"); facesContext.getAttributes().remove("oam.test.TestRendererA"); @@ -410,16 +411,16 @@ public void testCreateComponentRendererWrapper3() throws Exception // Invoke PostAddToViewEvent facesContext.getViewRoot().getChildren().add(comp2); - Assertions.assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper")); - Assertions.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); + assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper")); + assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); } - + /** * * @throws Exception */ @Test - public void testCreateComponentRendererWrapper4() throws Exception + void createComponentRendererWrapper4() throws Exception { facesContext.getViewRoot().setRenderKitId( MockRenderKitFactory.HTML_BASIC_RENDER_KIT); @@ -437,17 +438,17 @@ public void testCreateComponentRendererWrapper4() throws Exception UITestComponentA.DEFAULT_RENDERER_TYPE); List componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(1,componentResources.size()); + assertEquals(1,componentResources.size()); Map attrMap = componentResources.get(0).getAttributes(); - Assertions.assertEquals("testResource.js",attrMap.get("name")); - Assertions.assertEquals("testLib",attrMap.get("library")); + assertEquals("testResource.js",attrMap.get("name")); + assertEquals("testLib",attrMap.get("library")); // Invoke PostAddToViewEvent facesContext.getViewRoot().getChildren().add(comp); - Assertions.assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper")); - Assertions.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererWrapper")); - Assertions.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); + assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper")); + assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererWrapper")); + assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); facesContext.getAttributes().remove("oam.test.TestRendererWrapper"); facesContext.getAttributes().remove("oam.test.TestRendererA"); @@ -471,9 +472,9 @@ public void testCreateComponentRendererWrapper4() throws Exception // Invoke PostAddToViewEvent facesContext.getViewRoot().getChildren().add(comp2); - Assertions.assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper")); - Assertions.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererWrapper")); - Assertions.assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); + assertFalse(facesContext.getAttributes().containsKey("oam.test.FakeTestRendererWrapper")); + assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererWrapper")); + assertTrue(facesContext.getAttributes().containsKey("oam.test.TestRendererA")); } @ResourceDependency(name = "testResource.js") @@ -496,7 +497,7 @@ public String getFamily() } @Test - public void testCreateComponentAnnotation() throws Exception + void createComponentAnnotation() throws Exception { application.addComponent(UITestComponentB.COMPONENT_TYPE, UITestComponentB.class.getName()); @@ -504,13 +505,13 @@ public void testCreateComponentAnnotation() throws Exception UITestComponentB comp = (UITestComponentB) application.createComponent(UITestComponentB.COMPONENT_TYPE); List componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(1,componentResources.size()); + assertEquals(1,componentResources.size()); Map attrMap = componentResources.get(0).getAttributes(); - Assertions.assertEquals("testResource.js",attrMap.get("name")); + assertEquals("testResource.js",attrMap.get("name")); } - + @Test - public void testCreateComponentRendererAnnotation() throws Exception + void createComponentRendererAnnotation() throws Exception { facesContext.getViewRoot().setRenderKitId( MockRenderKitFactory.HTML_BASIC_RENDER_KIT); @@ -526,7 +527,7 @@ public void testCreateComponentRendererAnnotation() throws Exception UITestComponentB.DEFAULT_RENDERER_TYPE); List componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(2,componentResources.size()); + assertEquals(2,componentResources.size()); for (UIComponent component : componentResources) { if ("testResource.js".equals(component.getAttributes().get("name"))) @@ -535,13 +536,13 @@ public void testCreateComponentRendererAnnotation() throws Exception } else { - Assertions.fail("Not expected resource found"+component.getAttributes().get("name")); + fail("Not expected resource found"+component.getAttributes().get("name")); } } } - + @Test - public void testCreateComponentValueExpression1() throws Exception + void createComponentValueExpression1() throws Exception { ValueExpression expr = application.getExpressionFactory().createValueExpression( @@ -555,13 +556,13 @@ public void testCreateComponentValueExpression1() throws Exception List componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(1,componentResources.size()); + assertEquals(1,componentResources.size()); Map attrMap = componentResources.get(0).getAttributes(); - Assertions.assertEquals("testResource.js",attrMap.get("name")); + assertEquals("testResource.js",attrMap.get("name")); } - + @Test - public void testCreateComponentValueExpression2() throws Exception + void createComponentValueExpression2() throws Exception { ValueExpression expr = application.getExpressionFactory().createValueExpression( @@ -576,13 +577,13 @@ public void testCreateComponentValueExpression2() throws Exception List componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(1,componentResources.size()); + assertEquals(1,componentResources.size()); Map attrMap = componentResources.get(0).getAttributes(); - Assertions.assertEquals("testResource.js",attrMap.get("name")); + assertEquals("testResource.js",attrMap.get("name")); } @Test - public void testCreateComponentValueExpression3() throws Exception + void createComponentValueExpression3() throws Exception { ValueExpression expr = application.getExpressionFactory().createValueExpression( @@ -602,7 +603,7 @@ public void testCreateComponentValueExpression3() throws Exception UITestComponentB.DEFAULT_RENDERER_TYPE); List componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(2,componentResources.size()); + assertEquals(2,componentResources.size()); for (UIComponent component : componentResources) { if ("testResource.js".equals(component.getAttributes().get("name"))) @@ -611,13 +612,13 @@ public void testCreateComponentValueExpression3() throws Exception } else { - Assertions.fail("Not expected resource found"+component.getAttributes().get("name")); + fail("Not expected resource found"+component.getAttributes().get("name")); } } } - + @Test - public void testCreateComponentValueExpression4() throws Exception + void createComponentValueExpression4() throws Exception { ValueExpression expr = application.getExpressionFactory().createValueExpression( @@ -639,7 +640,7 @@ public void testCreateComponentValueExpression4() throws Exception UITestComponentB.DEFAULT_RENDERER_TYPE); List componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(2,componentResources.size()); + assertEquals(2,componentResources.size()); for (UIComponent component : componentResources) { if ("testResource.js".equals(component.getAttributes().get("name"))) @@ -648,17 +649,17 @@ public void testCreateComponentValueExpression4() throws Exception } else { - Assertions.fail("Not expected resource found"+component.getAttributes().get("name")); + fail("Not expected resource found"+component.getAttributes().get("name")); } } } - + @Test - public void testDatetimeconverterDefaultTimezoneIsSystemTimezoneInitParameter() + void datetimeconverterDefaultTimezoneIsSystemTimezoneInitParameter() { application.addConverter(java.util.Date.class, "jakarta.faces.convert.DateTimeConverter"); Converter converter = application.createConverter(java.util.Date.class); - Assertions.assertEquals(((DateTimeConverter) converter).getTimeZone(), TimeZone.getDefault()); + assertEquals(((DateTimeConverter) converter).getTimeZone(), TimeZone.getDefault()); } } diff --git a/impl/src/test/java/org/apache/myfaces/application/ApplicationImplJsfTest.java b/impl/src/test/java/org/apache/myfaces/application/ApplicationImplJsfTest.java index de5b1b31a1..2719ef5207 100644 --- a/impl/src/test/java/org/apache/myfaces/application/ApplicationImplJsfTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/ApplicationImplJsfTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.application; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.beans.BeanInfo; import jakarta.el.ExpressionFactory; @@ -36,7 +38,6 @@ import org.easymock.classextension.EasyMock; import org.easymock.classextension.IMocksControl; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -46,7 +47,7 @@ * @author Jakob Korherr (latest modification by $Author$) * @version $Revisio$ $Date$ */ -public class ApplicationImplJsfTest extends AbstractFacesTestCase +class ApplicationImplJsfTest extends AbstractFacesTestCase { private static final String RESOURCE_MSG = "The Resource must be stored in the component's attribute " + @@ -100,9 +101,9 @@ public ExpressionFactory getExpressionFactory() */ private static void assertRendererTypeResourceBeanInfo(UIComponent component, Resource resource, BeanInfo metadata) { - Assertions.assertEquals(COMPOSITE_RENDERER_MSG, "jakarta.faces.Composite", component.getRendererType()); - Assertions.assertEquals(resource, component.getAttributes().get(Resource.COMPONENT_RESOURCE_KEY), RESOURCE_MSG); - Assertions.assertEquals(metadata, component.getAttributes().get(UIComponent.BEANINFO_KEY), BEANINFO_MSG); + assertEquals(COMPOSITE_RENDERER_MSG, "jakarta.faces.Composite", component.getRendererType()); + assertEquals(resource, component.getAttributes().get(Resource.COMPONENT_RESOURCE_KEY), RESOURCE_MSG); + assertEquals(metadata, component.getAttributes().get(UIComponent.BEANINFO_KEY), BEANINFO_MSG); } private TestApplicationWrapper _testApplication; @@ -147,7 +148,7 @@ public void tearDown() throws Exception * Application.createComponent(FacesContext context, Resource componentResource) */ @Test - public void testCreateComponentFromResource() + void createComponentFromResource() { /* TODO: Make it work again // we need a UINamingContainer for this test diff --git a/impl/src/test/java/org/apache/myfaces/application/ApplicationImplTest.java b/impl/src/test/java/org/apache/myfaces/application/ApplicationImplTest.java index 051c1f50dc..e150fe86c6 100644 --- a/impl/src/test/java/org/apache/myfaces/application/ApplicationImplTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/ApplicationImplTest.java @@ -30,7 +30,6 @@ import jakarta.faces.convert.EnumConverter; import org.apache.myfaces.config.RuntimeConfig; import org.apache.myfaces.test.mock.MockFacesContext; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -41,12 +40,13 @@ import static org.easymock.EasyMock.*; import static org.easymock.classextension.EasyMock.createMock; import static org.easymock.classextension.EasyMock.replay; +import static org.junit.jupiter.api.Assertions.*; /** * @author Mathias Broekelmann (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class ApplicationImplTest +class ApplicationImplTest { //TODO: need mock objects for VDL/VDLFactory //remove from excludes list in pom.xml after complete @@ -55,7 +55,7 @@ public class ApplicationImplTest protected MockFacesContext facesContext; @BeforeEach - public void setUp() throws Exception + void setUp() throws Exception { application = new ApplicationImpl(new RuntimeConfig()); facesContext = new MockFacesContext(); @@ -66,12 +66,12 @@ public void setUp() throws Exception * {@link org.apache.myfaces.application.ApplicationImpl#getResourceBundle(jakarta.faces.context.FacesContext, java.lang.String)}. */ @Test - public void testGetResourceBundleNPE() + void getResourceBundleNPE() { - Assertions.assertThrows(NullPointerException.class, + assertThrows(NullPointerException.class, () -> application.getResourceBundle(null, "xxx")); - Assertions.assertThrows(NullPointerException.class, + assertThrows(NullPointerException.class, () -> application.getResourceBundle(facesContext, null)); } @@ -83,7 +83,7 @@ public void testGetResourceBundleNPE() * {@link org.apache.myfaces.application.ApplicationImpl#getResourceBundle(jakarta.faces.context.FacesContext, java.lang.String)}. */ @Test - public void testGetResourceBundleFacesException() + void getResourceBundleFacesException() { final ApplicationImpl myApp = new ApplicationImpl(new RuntimeConfig()) { @@ -94,7 +94,7 @@ String getBundleName(FacesContext facesContext, String name) } }; - Assertions.assertThrows(FacesException.class, + assertThrows(FacesException.class, () -> myApp.getResourceBundle(facesContext, "xxx")); } @@ -103,7 +103,7 @@ String getBundleName(FacesContext facesContext, String name) * {@link org.apache.myfaces.application.ApplicationImpl#getResourceBundle(jakarta.faces.context.FacesContext, java.lang.String)}. */ @Test - public void testGetResourceBundleWithDefaultLocale() + void getResourceBundleWithDefaultLocale() { assertGetResourceBundleWithLocale(Locale.getDefault()); } @@ -113,7 +113,7 @@ public void testGetResourceBundleWithDefaultLocale() * {@link org.apache.myfaces.application.ApplicationImpl#getResourceBundle(jakarta.faces.context.FacesContext, java.lang.String)}. */ @Test - public void testGetResourceBundleWithUIViewRootLocale() + void getResourceBundleWithUIViewRootLocale() { Locale locale = new Locale("xx"); UIViewRoot viewRoot = new UIViewRoot(); @@ -123,7 +123,7 @@ public void testGetResourceBundleWithUIViewRootLocale() } @Test - public void testCreateComponentCallSetValueOnExpressionIfValueNull() throws Exception + void createComponentCallSetValueOnExpressionIfValueNull() throws Exception { ValueExpression expr = createMock(ValueExpression.class); FacesContext context = createMock(FacesContext.class); @@ -134,11 +134,11 @@ public void testCreateComponentCallSetValueOnExpressionIfValueNull() throws Exce application.addComponent("testComponent", UIOutput.class.getName()); replay(context); replay(expr); - Assertions.assertTrue(UIOutput.class.isAssignableFrom(application.createComponent(expr, context, "testComponent").getClass())); + assertTrue(UIOutput.class.isAssignableFrom(application.createComponent(expr, context, "testComponent").getClass())); } @Test - public void testCreateComponentExpressionFacesExceptionTest() throws Exception + void createComponentExpressionFacesExceptionTest() throws Exception { ValueExpression expr = createMock(ValueExpression.class); FacesContext context = createMock(FacesContext.class); @@ -157,7 +157,7 @@ public void testCreateComponentExpressionFacesExceptionTest() throws Exception } catch (Throwable e) { - Assertions.fail("FacesException expected: " + e.getMessage()); + fail("FacesException expected: " + e.getMessage()); } } @@ -178,20 +178,20 @@ protected Object[][] getContents() @Override String getBundleName(FacesContext facesContext, String name) { - Assertions.assertEquals(var, name); + assertEquals(var, name); return bundleName; } @Override ResourceBundle getResourceBundle(String name, Locale locale, ClassLoader loader) { - Assertions.assertEquals(Thread.currentThread().getContextClassLoader(), loader); - Assertions.assertEquals(bundleName, name); - Assertions.assertEquals(expectedLocale, locale); + assertEquals(Thread.currentThread().getContextClassLoader(), loader); + assertEquals(bundleName, name); + assertEquals(expectedLocale, locale); return bundle; } }; - Assertions.assertSame(bundle, myapp.getResourceBundle(facesContext, var)); + assertSame(bundle, myapp.getResourceBundle(facesContext, var)); } private enum MyEnum {VALUE1, VALUE2} @@ -201,17 +201,18 @@ private enum MyEnum {VALUE1, VALUE2} * {@link jakarta.faces.application.Application#createConverter(java.lang.Class)}. */ @Test - public void testCreateEnumConverter() throws Exception + void createEnumConverter() throws Exception { application.addConverter(Enum.class, EnumConverter.class.getName()); Converter converter = application.createConverter(MyEnum.class); - Assertions.assertNotNull(converter); - Assertions.assertEquals(converter.getClass(), EnumConverter.class); + assertNotNull(converter); + assertEquals(EnumConverter.class, converter.getClass()); } private interface EnumCoded { public int getCode(); } + private enum AnotherEnum implements EnumCoded { VALUE1, VALUE2; public int getCode() {return 0;} @@ -236,7 +237,7 @@ public String getAsString(FacesContext context, UIComponent component, return null; } } - + /** * Test method for * {@link jakarta.faces.application.Application#createConverter(java.lang.Class)}. @@ -247,13 +248,13 @@ public String getAsString(FacesContext context, UIComponent component, * an enum. */ @Test - public void testCreateConverterForInterface() throws Exception + void createConverterForInterface() throws Exception { application.addConverter(Enum.class, EnumConverter.class.getName()); application.addConverter(EnumCoded.class, EnumCodedTestConverter.class.getName()); Converter converter = application.createConverter(AnotherEnum.class); - Assertions.assertNotNull(converter); - Assertions.assertEquals(converter.getClass(), EnumCodedTestConverter.class); + assertNotNull(converter); + assertEquals(EnumCodedTestConverter.class, converter.getClass()); } } diff --git a/impl/src/test/java/org/apache/myfaces/application/ClientBehaviorTestCase.java b/impl/src/test/java/org/apache/myfaces/application/ClientBehaviorTestCase.java index 6809c0a918..ff2f29aabf 100644 --- a/impl/src/test/java/org/apache/myfaces/application/ClientBehaviorTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/application/ClientBehaviorTestCase.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.application; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; import java.util.Map; @@ -37,7 +40,6 @@ import org.apache.myfaces.test.base.junit.AbstractFacesConfigurableMockTestCase; import org.apache.myfaces.test.el.MockExpressionFactory; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class ClientBehaviorTestCase extends AbstractFacesConfigurableMockTestCase @@ -127,7 +129,7 @@ public java.util.Collection getEventNames() } @Test - public void testAddBehaviorWithResourceDependencies() throws Exception + void addBehaviorWithResourceDependencies() throws Exception { application.addComponent(UITestComponentWithBehavior.COMPONENT_TYPE, @@ -144,12 +146,12 @@ public void testAddBehaviorWithResourceDependencies() throws Exception comp.addClientBehavior("click", behavior); // verify that method still works - Assertions.assertTrue(comp.getClientBehaviors().get("click").contains(behavior)); + assertTrue(comp.getClientBehaviors().get("click").contains(behavior)); // get behavior resource List resources = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(1, resources.size()); + assertEquals(1, resources.size()); Map attrMap = resources.get(0).getAttributes(); - Assertions.assertEquals("test.js", attrMap.get("name")); + assertEquals("test.js", attrMap.get("name")); } } diff --git a/impl/src/test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java b/impl/src/test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java index 8e4548a7f1..898d521a5e 100644 --- a/impl/src/test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.application; +import static org.junit.jupiter.api.Assertions.*; + import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -36,12 +38,11 @@ import org.apache.myfaces.config.impl.FacesConfigUnmarshallerImpl; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; -public class NavigationHandlerImplTest extends AbstractFacesTestCase +class NavigationHandlerImplTest extends AbstractFacesTestCase { private FacesConfigUnmarshallerImpl _facesConfigUnmarshaller; @@ -87,7 +88,7 @@ private void loadTextFacesConfig(String file) throws SAXException, } @Test - public void testGetSimpleExactMatchRule() throws Exception + void getSimpleExactMatchRule() throws Exception { loadTextFacesConfig("simple-rules-config.xml"); @@ -96,11 +97,11 @@ public void testGetSimpleExactMatchRule() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, null, "go"); - Assertions.assertEquals("/b.jsp", nc.getToViewId(facesContext)); + assertEquals("/b.jsp", nc.getToViewId(facesContext)); } @Test - public void testHandleSimpleExactMatchRule() throws Exception + void handleSimpleExactMatchRule() throws Exception { loadTextFacesConfig("simple-rules-config.xml"); @@ -109,11 +110,11 @@ public void testHandleSimpleExactMatchRule() throws Exception nh.handleNavigation(facesContext, null, "go"); - Assertions.assertEquals("/b.jsp", facesContext.getViewRoot().getViewId()); + assertEquals("/b.jsp", facesContext.getViewRoot().getViewId()); } @Test - public void testGetSimpleGlobalExactMatchRule() throws Exception + void getSimpleGlobalExactMatchRule() throws Exception { loadTextFacesConfig("simple-global-rules-config.xml"); @@ -122,11 +123,11 @@ public void testGetSimpleGlobalExactMatchRule() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, null, "go"); - Assertions.assertEquals("/b.jsp", nc.getToViewId(facesContext)); + assertEquals("/b.jsp", nc.getToViewId(facesContext)); } @Test - public void testHandleSimpleGlobalExactMatchRule() throws Exception + void handleSimpleGlobalExactMatchRule() throws Exception { loadTextFacesConfig("simple-global-rules-config.xml"); @@ -135,11 +136,11 @@ public void testHandleSimpleGlobalExactMatchRule() throws Exception nh.handleNavigation(facesContext, null, "go"); - Assertions.assertEquals("/b.jsp", facesContext.getViewRoot().getViewId()); + assertEquals("/b.jsp", facesContext.getViewRoot().getViewId()); } - + @Test - public void testGetSimpleMixExactMatchRule() throws Exception + void getSimpleMixExactMatchRule() throws Exception { loadTextFacesConfig("simple-mix-rules-config.xml"); @@ -148,17 +149,17 @@ public void testGetSimpleMixExactMatchRule() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, null, "go"); - Assertions.assertEquals("/c.jsp", nc.getToViewId(facesContext)); + assertEquals("/c.jsp", nc.getToViewId(facesContext)); facesContext.getViewRoot().setViewId("/z.jsp"); nc = nh.getNavigationCase(facesContext, null, "go"); - Assertions.assertEquals("/b.jsp", nc.getToViewId(facesContext)); + assertEquals("/b.jsp", nc.getToViewId(facesContext)); } @Test - public void testHandleSimpleMixExactMatchRule() throws Exception + void handleSimpleMixExactMatchRule() throws Exception { loadTextFacesConfig("simple-mix-rules-config.xml"); @@ -167,17 +168,17 @@ public void testHandleSimpleMixExactMatchRule() throws Exception nh.handleNavigation(facesContext, null, "go"); - Assertions.assertEquals("/c.jsp", facesContext.getViewRoot().getViewId()); + assertEquals("/c.jsp", facesContext.getViewRoot().getViewId()); facesContext.getViewRoot().setViewId("/z.jsp"); nh.handleNavigation(facesContext, null, "go"); - Assertions.assertEquals("/b.jsp", facesContext.getViewRoot().getViewId()); + assertEquals("/b.jsp", facesContext.getViewRoot().getViewId()); } - + @Test - public void testGetSimplePartialExactMatchRule() throws Exception + void getSimplePartialExactMatchRule() throws Exception { loadTextFacesConfig("simple-partial-rules-config.xml"); @@ -186,17 +187,17 @@ public void testGetSimplePartialExactMatchRule() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, null, "go"); - Assertions.assertEquals("/cars/b.jsp", nc.getToViewId(facesContext)); + assertEquals("/cars/b.jsp", nc.getToViewId(facesContext)); facesContext.getViewRoot().setViewId("/cars/z.jsp"); nc = nh.getNavigationCase(facesContext, null, "go"); - Assertions.assertEquals("/cars/c.jsp", nc.getToViewId(facesContext)); + assertEquals("/cars/c.jsp", nc.getToViewId(facesContext)); } @Test - public void testHandleSimplePartialExactMatchRule() throws Exception + void handleSimplePartialExactMatchRule() throws Exception { loadTextFacesConfig("simple-partial-rules-config.xml"); @@ -205,17 +206,17 @@ public void testHandleSimplePartialExactMatchRule() throws Exception nh.handleNavigation(facesContext, null, "go"); - Assertions.assertEquals("/cars/b.jsp", facesContext.getViewRoot().getViewId()); + assertEquals("/cars/b.jsp", facesContext.getViewRoot().getViewId()); facesContext.getViewRoot().setViewId("/cars/z.jsp"); nh.handleNavigation(facesContext, null, "go"); - Assertions.assertEquals("/cars/c.jsp", facesContext.getViewRoot().getViewId()); + assertEquals("/cars/c.jsp", facesContext.getViewRoot().getViewId()); } - + @Test - public void testGetSimpleELExactMatchRule() throws Exception + void getSimpleELExactMatchRule() throws Exception { loadTextFacesConfig("simple-el-rules-config.xml"); @@ -225,11 +226,11 @@ public void testGetSimpleELExactMatchRule() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", "go"); - Assertions.assertEquals("/b.jsp", nc.getToViewId(facesContext)); + assertEquals("/b.jsp", nc.getToViewId(facesContext)); } - + @Test - public void testGetSimpleELExactMatchRuleFailNullOutcome() throws Exception + void getSimpleELExactMatchRuleFailNullOutcome() throws Exception { loadTextFacesConfig("simple-el-rules-config.xml"); @@ -239,7 +240,7 @@ public void testGetSimpleELExactMatchRuleFailNullOutcome() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", null); - Assertions.assertNull(nc); + assertNull(nc); } public static class TestBean @@ -254,9 +255,9 @@ public boolean isFalse() return false; } } - + @Test - public void testGetSimpleIfExactMatchRule() throws Exception + void getSimpleIfExactMatchRule() throws Exception { loadTextFacesConfig("simple-if-rules-config.xml"); @@ -268,11 +269,11 @@ public void testGetSimpleIfExactMatchRule() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, null, "go"); - Assertions.assertEquals("/b.jsp", nc.getToViewId(facesContext)); + assertEquals("/b.jsp", nc.getToViewId(facesContext)); } - + @Test - public void testGetSimpleIfPreferMathRule() throws Exception + void getSimpleIfPreferMathRule() throws Exception { loadTextFacesConfig("simple-if-rules-config-2.xml"); @@ -284,11 +285,11 @@ public void testGetSimpleIfPreferMathRule() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, null, "go"); - Assertions.assertEquals("/b.jsp", nc.getToViewId(facesContext)); + assertEquals("/b.jsp", nc.getToViewId(facesContext)); } - + @Test - public void testGetSimpleIfPreferMathRule2() throws Exception + void getSimpleIfPreferMathRule2() throws Exception { loadTextFacesConfig("simple-if-rules-config-3.xml"); @@ -300,15 +301,15 @@ public void testGetSimpleIfPreferMathRule2() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, "go", null); - Assertions.assertEquals("/b.jsp", nc.getToViewId(facesContext)); + assertEquals("/b.jsp", nc.getToViewId(facesContext)); nc = nh.getNavigationCase(facesContext, "go", "xx"); - Assertions.assertEquals("/b.jsp", nc.getToViewId(facesContext)); + assertEquals("/b.jsp", nc.getToViewId(facesContext)); } @Test - public void testGetSimpleNotIfExactMatchRule() throws Exception + void getSimpleNotIfExactMatchRule() throws Exception { loadTextFacesConfig("simple-if-rules-config.xml"); @@ -320,11 +321,11 @@ public void testGetSimpleNotIfExactMatchRule() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, null, "go"); - Assertions.assertEquals("/d.jsp", nc.getToViewId(facesContext)); + assertEquals("/d.jsp", nc.getToViewId(facesContext)); } - + @Test - public void testGetSimplePreemptiveIfExactMatchRule() throws Exception + void getSimplePreemptiveIfExactMatchRule() throws Exception { loadTextFacesConfig("simple-if-rules-config.xml"); @@ -336,11 +337,11 @@ public void testGetSimplePreemptiveIfExactMatchRule() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, null, "go"); - Assertions.assertEquals("/go.jsp", nc.getToViewId(facesContext)); - } - + assertEquals("/go.jsp", nc.getToViewId(facesContext)); + } + @Test - public void testGetSimpleGlobalPreemptiveMatchRule() throws Exception + void getSimpleGlobalPreemptiveMatchRule() throws Exception { loadTextFacesConfig("simple-global-preemptive-rules-config.xml"); @@ -352,11 +353,11 @@ public void testGetSimpleGlobalPreemptiveMatchRule() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, null, "go"); - Assertions.assertEquals("/a.jsp", nc.getToViewId(facesContext)); + assertEquals("/a.jsp", nc.getToViewId(facesContext)); } - + @Test - public void testGetSimpleELNoCondMatchRule() throws Exception + void getSimpleELNoCondMatchRule() throws Exception { loadTextFacesConfig("simple-el-nocond-rules-config.xml"); @@ -366,11 +367,11 @@ public void testGetSimpleELNoCondMatchRule() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", "go"); - Assertions.assertEquals("/b.jsp", nc.getToViewId(facesContext)); + assertEquals("/b.jsp", nc.getToViewId(facesContext)); } - + @Test - public void testGetSimpleELNoCondNullOutcomeMatchRule() throws Exception + void getSimpleELNoCondNullOutcomeMatchRule() throws Exception { loadTextFacesConfig("simple-el-nocond-rules-config.xml"); @@ -380,11 +381,11 @@ public void testGetSimpleELNoCondNullOutcomeMatchRule() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", null); - Assertions.assertNull(nc); + assertNull(nc); } - + @Test - public void testActionOutcomePrecedenceMachRule() throws Exception + void actionOutcomePrecedenceMachRule() throws Exception { loadTextFacesConfig("simple-action-outcome-precedence-config.xml"); @@ -418,12 +419,12 @@ public Map> getNavigationCases() NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", "go"); - Assertions.assertEquals("/b.jsp", nc.getToViewId(facesContext)); + assertEquals("/b.jsp", nc.getToViewId(facesContext)); } } - + @Test - public void testActionOutcomePrecedenceAlternateOutcomeMachRule() throws Exception + void actionOutcomePrecedenceAlternateOutcomeMachRule() throws Exception { loadTextFacesConfig("simple-action-outcome-precedence-config.xml"); @@ -457,12 +458,12 @@ public Map> getNavigationCases() NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", "nogo"); - Assertions.assertEquals("/c.jsp", nc.getToViewId(facesContext)); + assertEquals("/c.jsp", nc.getToViewId(facesContext)); } } @Test - public void testActionOutcomePrecedenceNoOutcomeMachRule() throws Exception + void actionOutcomePrecedenceNoOutcomeMachRule() throws Exception { loadTextFacesConfig("simple-action-outcome-precedence-config.xml"); @@ -497,12 +498,12 @@ public Map> getNavigationCases() NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", null); //If the element is absent, only match a non-null outcome - Assertions.assertNull(nc); + assertNull(nc); } } - + @Test - public void testActionOutcomePrecedence2MachRule() throws Exception + void actionOutcomePrecedence2MachRule() throws Exception { loadTextFacesConfig("simple-action-outcome-precedence-2-config.xml"); @@ -536,16 +537,16 @@ public Map> getNavigationCases() NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", "go"); - Assertions.assertEquals("/b.jsp", nc.getToViewId(facesContext)); + assertEquals("/b.jsp", nc.getToViewId(facesContext)); } } - + /** * Tests if the URL parameters of an outcome are correctly * added to the NavigationCase. */ @Test - public void testFacesRedirectAddsUrlParameters() + void facesRedirectAddsUrlParameters() { NavigationHandlerImpl nh = new NavigationHandlerImpl(); @@ -562,11 +563,11 @@ public void testFacesRedirectAddsUrlParameters() // note that faces-redirect and includeViewParams // should not be added as a parameter - Assertions.assertEquals(expected, navigationCase.getParameters()); - Assertions.assertTrue(navigationCase.isIncludeViewParams()); - Assertions.assertTrue(navigationCase.isRedirect()); + assertEquals(expected, navigationCase.getParameters()); + assertTrue(navigationCase.isIncludeViewParams()); + assertTrue(navigationCase.isRedirect()); } - + /** * Tests if the URL parameters of an outcome are correctly * added to the NavigationCase. @@ -574,7 +575,7 @@ public void testFacesRedirectAddsUrlParameters() * it uses faces-include-view-params=true instead of includeViewParams=true. */ @Test - public void testFacesRedirectAddsUrlParametersFacesIncludeViewParams() + void facesRedirectAddsUrlParametersFacesIncludeViewParams() { NavigationHandlerImpl nh = new NavigationHandlerImpl(); @@ -591,16 +592,16 @@ public void testFacesRedirectAddsUrlParametersFacesIncludeViewParams() // note that faces-redirect and faces-include-view-params // should not be added as a parameter - Assertions.assertEquals(expected, navigationCase.getParameters()); - Assertions.assertTrue(navigationCase.isIncludeViewParams()); - Assertions.assertTrue(navigationCase.isRedirect()); + assertEquals(expected, navigationCase.getParameters()); + assertTrue(navigationCase.isIncludeViewParams()); + assertTrue(navigationCase.isRedirect()); } - + /** * Test for MYFACES-3101 */ @Test - public void testHandleViewExpiredExpcetion() throws Exception { + void handleViewExpiredExpcetion() throws Exception { NavigationHandlerImpl underTest = new NavigationHandlerImpl(); // simulate no available ViewRoot (in case of VEE) facesContext.setViewRoot(null); @@ -610,12 +611,12 @@ public void testHandleViewExpiredExpcetion() throws Exception { // http://www.nfjsone.com/blog/ed_burns/2009/09/dealing_gracefully_with_viewexpiredexception_in_jsf2 underTest.handleNavigation(facesContext, null, "viewExpired"); - Assertions.assertNotNull(facesContext.getViewRoot()); - Assertions.assertEquals("/viewExpired.xhtml", facesContext.getViewRoot().getViewId()); + assertNotNull(facesContext.getViewRoot()); + assertEquals("/viewExpired.xhtml", facesContext.getViewRoot().getViewId()); } - + @Test - public void testHandleViewExpiredExpcetion2() throws Exception { + void handleViewExpiredExpcetion2() throws Exception { NavigationHandlerImpl underTest = new NavigationHandlerImpl(); // simulate no available ViewRoot (in case of VEE) facesContext.setViewRoot(null); @@ -625,13 +626,13 @@ public void testHandleViewExpiredExpcetion2() throws Exception { // http://www.nfjsone.com/blog/ed_burns/2009/09/dealing_gracefully_with_viewexpiredexception_in_jsf2 underTest.handleNavigation(facesContext, null, "viewExpired.xhtml"); - Assertions.assertNotNull(facesContext.getViewRoot()); - Assertions.assertEquals("/viewExpired.xhtml", facesContext.getViewRoot().getViewId()); + assertNotNull(facesContext.getViewRoot()); + assertEquals("/viewExpired.xhtml", facesContext.getViewRoot().getViewId()); } - + @Test - public void testHandleViewExpiredExpcetion3() throws Exception { + void handleViewExpiredExpcetion3() throws Exception { NavigationHandlerImpl underTest = new NavigationHandlerImpl(); // simulate no available ViewRoot (in case of VEE) facesContext.setViewRoot(null); @@ -641,16 +642,16 @@ public void testHandleViewExpiredExpcetion3() throws Exception { // http://www.nfjsone.com/blog/ed_burns/2009/09/dealing_gracefully_with_viewexpiredexception_in_jsf2 underTest.handleNavigation(facesContext, null, "viewExpired"); - Assertions.assertNotNull(facesContext.getViewRoot()); + assertNotNull(facesContext.getViewRoot()); // In this case, we have /viewExpired.jsf, but note the default ViewHandlerImpl converts the viewId // from /viewExpired.jsf to /viewExpired.xhtml, when deriveViewId() is called. - Assertions.assertEquals("/viewExpired.jsf", facesContext.getViewRoot().getViewId()); + assertEquals("/viewExpired.jsf", facesContext.getViewRoot().getViewId()); } - @Test - public void testHandleViewExpiredExpcetion4() throws Exception { + @Test + void handleViewExpiredExpcetion4() throws Exception { NavigationHandlerImpl underTest = new NavigationHandlerImpl(); // simulate no available ViewRoot (in case of VEE) facesContext.setViewRoot(null); @@ -658,16 +659,16 @@ public void testHandleViewExpiredExpcetion4() throws Exception { // http://www.nfjsone.com/blog/ed_burns/2009/09/dealing_gracefully_with_viewexpiredexception_in_jsf2 underTest.handleNavigation(facesContext, null, "viewExpired.xhtml"); - Assertions.assertNotNull(facesContext.getViewRoot()); - Assertions.assertEquals("/viewExpired.xhtml", facesContext.getViewRoot().getViewId()); + assertNotNull(facesContext.getViewRoot()); + assertEquals("/viewExpired.xhtml", facesContext.getViewRoot().getViewId()); - } - + } + /** * Test for MYFACES-3101 - partial request (without redirect) */ @Test - public void testHandleViewExpiredExpcetionForPartial() throws Exception { + void handleViewExpiredExpcetionForPartial() throws Exception { NavigationHandlerImpl underTest = new NavigationHandlerImpl(); // simulate no available ViewRoot (in case of VEE) facesContext.setViewRoot(null); @@ -675,12 +676,12 @@ public void testHandleViewExpiredExpcetionForPartial() throws Exception { underTest.handleNavigation(facesContext, null, "/viewExpired.xhtml"); - Assertions.assertNotNull(facesContext.getViewRoot()); - Assertions.assertEquals("/viewExpired.xhtml", facesContext.getViewRoot().getViewId()); + assertNotNull(facesContext.getViewRoot()); + assertEquals("/viewExpired.xhtml", facesContext.getViewRoot().getViewId()); } - + @Test - public void testIfDoNotMatchWhenOutcomeNull() throws Exception + void ifDoNotMatchWhenOutcomeNull() throws Exception { loadTextFacesConfig("simple-if-rules-config-4.xml"); @@ -692,16 +693,16 @@ public void testIfDoNotMatchWhenOutcomeNull() throws Exception NavigationCase nc = nh.getNavigationCase(facesContext, null, null); - Assertions.assertNull(nc); + assertNull(nc); nc = nh.getNavigationCase(facesContext, null, "go"); - Assertions.assertEquals("/b.jsp", nc.getToViewId(facesContext)); + assertEquals("/b.jsp", nc.getToViewId(facesContext)); } @Test - public void testFragment() + void fragment() { NavigationHandlerImpl nh = new NavigationHandlerImpl(); @@ -718,14 +719,14 @@ public void testFragment() // note that faces-redirect and includeViewParams // should not be added as a parameter - Assertions.assertEquals(expected, navigationCase.getParameters()); - Assertions.assertTrue(navigationCase.isIncludeViewParams()); - Assertions.assertTrue(navigationCase.isRedirect()); - Assertions.assertEquals("myFragment", navigationCase.getFragment()); + assertEquals(expected, navigationCase.getParameters()); + assertTrue(navigationCase.isIncludeViewParams()); + assertTrue(navigationCase.isRedirect()); + assertEquals("myFragment", navigationCase.getFragment()); } @Test - public void testFragmentNavigation() throws Exception { + void fragmentNavigation() throws Exception { NavigationHandlerImpl underTest = new NavigationHandlerImpl(); // simulate no available ViewRoot (in case of VEE) facesContext.setViewRoot(null); @@ -733,7 +734,7 @@ public void testFragmentNavigation() throws Exception { underTest.handleNavigation(facesContext, null, "/viewExpired.xhtml#test"); - Assertions.assertNotNull(facesContext.getViewRoot()); - Assertions.assertEquals("/viewExpired.xhtml", facesContext.getViewRoot().getViewId()); + assertNotNull(facesContext.getViewRoot()); + assertEquals("/viewExpired.xhtml", facesContext.getViewRoot().getViewId()); } } diff --git a/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplContractTest.java b/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplContractTest.java index 4343368ded..6dfee3e027 100644 --- a/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplContractTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplContractTest.java @@ -22,11 +22,11 @@ * * @author lu4242 */ -public class ResourceHandlerImplContractTest extends AbstractFaceletTestCase +class ResourceHandlerImplContractTest extends AbstractFaceletTestCase { - + @Test - public void testSimpleContract() throws Exception + void simpleContract() throws Exception { } diff --git a/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplTest.java b/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplTest.java index c4d916bd8d..9dab90aefa 100644 --- a/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplTest.java @@ -18,10 +18,11 @@ */ package org.apache.myfaces.application; +import static org.junit.jupiter.api.Assertions.*; + import java.io.InputStream; import java.net.MalformedURLException; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import jakarta.faces.application.Resource; @@ -44,7 +45,7 @@ * * @author Jakob Korherr */ -public class ResourceHandlerImplTest extends AbstractFacesTestCase +class ResourceHandlerImplTest extends AbstractFacesTestCase { private ResourceHandlerImpl resourceHandler; @@ -69,15 +70,15 @@ public void tearDown() throws Exception } @Test - public void testCreateResource_ResourceNotNull() throws Exception + void createResourceResourceNotNull() throws Exception { Resource resource = resourceHandler.createResource("testResource.xhtml"); - Assertions.assertNotNull(resource); + assertNotNull(resource); } @Test - public void testCreateResource_cacheHonorsLocale() throws Exception + void createResourceCacheHonorsLocale() throws Exception { // setup message bundle to use application.setMessageBundle("org/apache/myfaces/application/resourcehandler/messages"); @@ -93,11 +94,11 @@ public void testCreateResource_cacheHonorsLocale() throws Exception URL urlDe = resourceDe.getURL(); // URLs MUST be different, since there is an english and a german version of the resource - Assertions.assertFalse(urlEn.equals(urlDe)); + assertNotEquals(urlEn, urlDe); } @Test - public void testDeriveResourceMeta1() throws Exception + void deriveResourceMeta1() throws Exception { application.setMessageBundle("org/apache/myfaces/application/resourcehandler/messages"); @@ -165,64 +166,64 @@ public boolean libraryExists(String libraryName) application.setDefaultLocale(Locale.ENGLISH); ResourceMeta resource = resourceHandler.deriveResourceMeta(facesContext, loader, "en/mylib/1_0_2/myres.js/1_3.js"); - Assertions.assertNotNull(resource); - Assertions.assertEquals("en", resource.getLocalePrefix()); - Assertions.assertEquals("mylib", resource.getLibraryName()); - Assertions.assertEquals("1_0_2", resource.getLibraryVersion()); - Assertions.assertEquals("myres.js", resource.getResourceName()); - Assertions.assertEquals("1_3", resource.getResourceVersion()); + assertNotNull(resource); + assertEquals("en", resource.getLocalePrefix()); + assertEquals("mylib", resource.getLibraryName()); + assertEquals("1_0_2", resource.getLibraryVersion()); + assertEquals("myres.js", resource.getResourceName()); + assertEquals("1_3", resource.getResourceVersion()); resource = resourceHandler.deriveResourceMeta(facesContext, loader, "en/mylib/1_0_2/myres.js"); - Assertions.assertNotNull(resource); - Assertions.assertEquals("en", resource.getLocalePrefix()); - Assertions.assertEquals("mylib", resource.getLibraryName()); - Assertions.assertEquals("1_0_2", resource.getLibraryVersion()); - Assertions.assertEquals("myres.js", resource.getResourceName()); - Assertions.assertNull(resource.getResourceVersion()); + assertNotNull(resource); + assertEquals("en", resource.getLocalePrefix()); + assertEquals("mylib", resource.getLibraryName()); + assertEquals("1_0_2", resource.getLibraryVersion()); + assertEquals("myres.js", resource.getResourceName()); + assertNull(resource.getResourceVersion()); resource = resourceHandler.deriveResourceMeta(facesContext, loader, "en/mylib/myres.js/1_3.js"); - Assertions.assertNotNull(resource); - Assertions.assertEquals("en", resource.getLocalePrefix()); - Assertions.assertEquals("mylib", resource.getLibraryName()); - Assertions.assertNull(resource.getLibraryVersion()); - Assertions.assertEquals("myres.js", resource.getResourceName()); - Assertions.assertEquals("1_3", resource.getResourceVersion()); + assertNotNull(resource); + assertEquals("en", resource.getLocalePrefix()); + assertEquals("mylib", resource.getLibraryName()); + assertNull(resource.getLibraryVersion()); + assertEquals("myres.js", resource.getResourceName()); + assertEquals("1_3", resource.getResourceVersion()); resource = resourceHandler.deriveResourceMeta(facesContext, loader, "en/mylib/myres.js"); - Assertions.assertNotNull(resource); - Assertions.assertEquals("en", resource.getLocalePrefix()); - Assertions.assertEquals("mylib", resource.getLibraryName()); - Assertions.assertEquals("myres.js", resource.getResourceName()); - Assertions.assertNull(resource.getLibraryVersion()); - Assertions.assertNull(resource.getResourceVersion()); + assertNotNull(resource); + assertEquals("en", resource.getLocalePrefix()); + assertEquals("mylib", resource.getLibraryName()); + assertEquals("myres.js", resource.getResourceName()); + assertNull(resource.getLibraryVersion()); + assertNull(resource.getResourceVersion()); resource = resourceHandler.deriveResourceMeta(facesContext, loader, "en/myres.js"); - Assertions.assertNotNull(resource); - Assertions.assertNull(resource.getLibraryName()); - Assertions.assertNull(resource.getLibraryVersion()); - Assertions.assertNull(resource.getResourceVersion()); - Assertions.assertEquals("en", resource.getLocalePrefix()); - Assertions.assertEquals("myres.js", resource.getResourceName()); + assertNotNull(resource); + assertNull(resource.getLibraryName()); + assertNull(resource.getLibraryVersion()); + assertNull(resource.getResourceVersion()); + assertEquals("en", resource.getLocalePrefix()); + assertEquals("myres.js", resource.getResourceName()); resource = resourceHandler.deriveResourceMeta(facesContext, loader, "mylib/myres.js"); - Assertions.assertNotNull(resource); - Assertions.assertNull(resource.getLocalePrefix()); - Assertions.assertNull(resource.getLibraryVersion()); - Assertions.assertNull(resource.getResourceVersion()); - Assertions.assertEquals("mylib", resource.getLibraryName()); - Assertions.assertEquals("myres.js", resource.getResourceName()); + assertNotNull(resource); + assertNull(resource.getLocalePrefix()); + assertNull(resource.getLibraryVersion()); + assertNull(resource.getResourceVersion()); + assertEquals("mylib", resource.getLibraryName()); + assertEquals("myres.js", resource.getResourceName()); resource = resourceHandler.deriveResourceMeta(facesContext, loader, "myres.js"); - Assertions.assertNotNull(resource); - Assertions.assertNull(resource.getLocalePrefix()); - Assertions.assertNull(resource.getLibraryName()); - Assertions.assertNull(resource.getLibraryVersion()); - Assertions.assertNull(resource.getResourceVersion()); - Assertions.assertEquals("myres.js", resource.getResourceName()); + assertNotNull(resource); + assertNull(resource.getLocalePrefix()); + assertNull(resource.getLibraryName()); + assertNull(resource.getLibraryVersion()); + assertNull(resource.getResourceVersion()); + assertEquals("myres.js", resource.getResourceName()); } @Test - public void testCreateResourceNullResourceName() throws Exception + void createResourceNullResourceName() throws Exception { boolean didNPEOccur = false; try @@ -233,11 +234,11 @@ public void testCreateResourceNullResourceName() throws Exception didNPEOccur = true; } - Assertions.assertTrue(didNPEOccur); + assertTrue(didNPEOccur); } @Test - public void testCache() + void cache() { ResourceLoader loader = Mockito.spy(new ClassLoaderResourceLoader(null)); Mockito.when(loader.resourceExists(Mockito.any())).thenReturn(true); @@ -263,9 +264,9 @@ public void testCache() Mockito.verify(loader, Mockito.times(1)).createResourceMeta( Mockito.any(), Mockito.eq("test"), Mockito.any(), Mockito.eq("test.png"), Mockito.any()); } - + @Test - public void testDisabledCache() + void disabledCache() { ResourceLoader loader = Mockito.spy(new ClassLoaderResourceLoader(null)); Mockito.when(loader.resourceExists(Mockito.any())).thenReturn(true); @@ -294,7 +295,7 @@ public void testDisabledCache() } @Test - public void testResourceExistsCache() + void resourceExistsCache() { ResourceLoader loader = Mockito.spy(new ClassLoaderResourceLoader(null)); diff --git a/impl/src/test/java/org/apache/myfaces/application/ViewHandlerImplTest.java b/impl/src/test/java/org/apache/myfaces/application/ViewHandlerImplTest.java index 471b7187b3..a470f53efc 100644 --- a/impl/src/test/java/org/apache/myfaces/application/ViewHandlerImplTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/ViewHandlerImplTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.application; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -33,14 +35,13 @@ import jakarta.faces.view.ViewDeclarationLanguage; import jakarta.faces.view.ViewMetadata; -import org.junit.jupiter.api.Assertions; - import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.apache.myfaces.test.el.MockValueExpression; import org.apache.myfaces.view.ViewDeclarationLanguageFactoryImpl; import org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage; import org.apache.myfaces.view.facelets.impl.FaceletCacheFactoryImpl; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -50,7 +51,7 @@ * @author Jakob Korherr (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class ViewHandlerImplTest extends AbstractFacesTestCase +class ViewHandlerImplTest extends AbstractFacesTestCase { private ViewHandlerImpl _viewHandler; @@ -95,7 +96,7 @@ public void tearDown() throws Exception */ @Test @SuppressWarnings("unchecked") - public void testGetBookmarkableURLDoesNotChangeParametersMap() + void getBookmarkableURLDoesNotChangeParametersMap() { // set the required path elements request.setPathElements("/", null, "/newview.jsf", null); @@ -109,27 +110,20 @@ public void testGetBookmarkableURLDoesNotChangeParametersMap() parameters.put("key2", Collections.unmodifiableList(Arrays.asList("value2"))); parameters = Collections.unmodifiableMap(parameters); - String url = null; - try - { - url = _viewHandler.getBookmarkableURL(facesContext, "/newview.xhtml", parameters, true); - } - catch (UnsupportedOperationException uoe) - { - // an UnsupportedOperationException occurred, which means getBookmarkableURL() - // wanted to change the Map or any of the Lists and this is not allowed! - Assertions.fail("ViewHandler.getBookmarkableURL() must not change the parameter Map!"); - } + final Map> finalParameters = parameters; + String url = Assertions.assertDoesNotThrow( + () -> _viewHandler.getBookmarkableURL(facesContext, "/newview.xhtml", finalParameters, true), + "ViewHandler.getBookmarkableURL() must not change the parameter Map!"); // additional checks: // the URL must contain all params from the parameters map // and from the components of the target view - Assertions.assertTrue(url.contains("key1=value11")); - Assertions.assertTrue(url.contains("key1=value12")); - Assertions.assertTrue(url.contains("key2=value2")); - Assertions.assertTrue(url.contains("myparam=paramvalue")); + assertTrue(url.contains("key1=value11")); + assertTrue(url.contains("key1=value12")); + assertTrue(url.contains("key2=value2")); + assertTrue(url.contains("myparam=paramvalue")); } - + /** * Checks if ViewHandler.getRedirectURL() wants to change the parameter Map, * which is not allowed, because this Map comes from the NavigationCase and @@ -139,7 +133,7 @@ public void testGetBookmarkableURLDoesNotChangeParametersMap() */ @Test @SuppressWarnings("unchecked") - public void testGetRedirectURLDoesNotChangeParametersMap() + void getRedirectURLDoesNotChangeParametersMap() { // set the required path elements request.setPathElements("/", null, "/newview.jsf", null); @@ -153,25 +147,18 @@ public void testGetRedirectURLDoesNotChangeParametersMap() parameters.put("key2", Collections.unmodifiableList(Arrays.asList("value2"))); parameters = Collections.unmodifiableMap(parameters); - String url = null; - try - { - url = _viewHandler.getRedirectURL(facesContext, "/newview.xhtml", parameters, true); - } - catch (UnsupportedOperationException uoe) - { - // an UnsupportedOperationException occurred, which means getRedirectURL() - // wanted to change the Map or any of the Lists and this is not allowed! - Assertions.fail("ViewHandler.getRedirectURL() must not change the parameter Map!"); - } + final Map> finalParameters = parameters; + String url = Assertions.assertDoesNotThrow( + () -> _viewHandler.getRedirectURL(facesContext, "/newview.xhtml", finalParameters, true), + "ViewHandler.getRedirectURL() must not change the parameter Map!"); // additional checks: // the URL must contain all params from the parameters map // and from the components of the target view - Assertions.assertTrue(url.contains("key1=value11")); - Assertions.assertTrue(url.contains("key1=value12")); - Assertions.assertTrue(url.contains("key2=value2")); - Assertions.assertTrue(url.contains("myparam=paramvalue")); + assertTrue(url.contains("key1=value11")); + assertTrue(url.contains("key1=value12")); + assertTrue(url.contains("key2=value2")); + assertTrue(url.contains("myparam=paramvalue")); } /** diff --git a/impl/src/test/java/org/apache/myfaces/application/ViewIdSupportMockTest.java b/impl/src/test/java/org/apache/myfaces/application/ViewIdSupportMockTest.java index 83657116cd..9a14a22ac3 100644 --- a/impl/src/test/java/org/apache/myfaces/application/ViewIdSupportMockTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/ViewIdSupportMockTest.java @@ -20,17 +20,20 @@ import jakarta.faces.FacesException; import org.apache.myfaces.test.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.Collections; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -public class ViewIdSupportMockTest extends AbstractFacesTestCase +class ViewIdSupportMockTest extends AbstractFacesTestCase { private ViewIdSupport viewIdSupport; @@ -47,29 +50,29 @@ public void setUp() throws Exception } @Test - public void testCalculateViewIdFromRequestAttributeIncludePathInfo() + void calculateViewIdFromRequestAttributeIncludePathInfo() { Map map = new HashMap(); String expectedValue = "jakarta.servlet.include.path_info_VIEWID"; map.put("jakarta.servlet.include.path_info", expectedValue); Mockito.when(_externalContext.getRequestMap()).thenReturn(map); - Assertions.assertEquals(expectedValue, viewIdSupport.calculateViewId(_facesContext)); + assertEquals(expectedValue, viewIdSupport.calculateViewId(_facesContext)); } @Test - public void testCalculateViewIdFromRequestPathInfo() + void calculateViewIdFromRequestPathInfo() { Mockito.when(_externalContext.getRequestMap()).thenReturn(Collections.emptyMap()); String expectedValue = "requestPathInfo_VIEWID"; Mockito.when(_externalContext.getRequestPathInfo()).thenReturn(expectedValue); - Assertions.assertEquals(expectedValue, viewIdSupport.calculateViewId(_facesContext)); + assertEquals(expectedValue, viewIdSupport.calculateViewId(_facesContext)); } - + @Test - public void testCalculateViewIdFromRequestAttributeIncludeServletPath() + void calculateViewIdFromRequestAttributeIncludeServletPath() { Map map = new HashMap(); String expectedValue = "jakarta.servlet.include.servlet_path_VIEWID"; @@ -78,28 +81,28 @@ public void testCalculateViewIdFromRequestAttributeIncludeServletPath() Mockito.when(_externalContext.getRequestPathInfo()).thenReturn(null); - Assertions.assertEquals(expectedValue, viewIdSupport.calculateViewId(_facesContext)); + assertEquals(expectedValue, viewIdSupport.calculateViewId(_facesContext)); } @Test - public void testCalculateViewIdFromRequestServletPath() + void calculateViewIdFromRequestServletPath() { Mockito.when(_externalContext.getRequestMap()).thenReturn(Collections.emptyMap()); Mockito.when(_externalContext.getRequestPathInfo()).thenReturn(null); String expectedValue = "RequestServletPath_VIEWID"; Mockito.when(_externalContext.getRequestServletPath()).thenReturn(expectedValue); - Assertions.assertEquals(expectedValue, viewIdSupport.calculateViewId(_facesContext)); + assertEquals(expectedValue, viewIdSupport.calculateViewId(_facesContext)); } @Test - public void testCalculateViewIdFacesException() + void calculateViewIdFacesException() { Mockito.when(_externalContext.getRequestMap()).thenReturn(Collections.emptyMap()); Mockito.when(_externalContext.getRequestPathInfo()).thenReturn(null); Mockito.when(_externalContext.getRequestServletPath()).thenReturn(null); - Assertions.assertThrows(FacesException.class, + assertThrows(FacesException.class, () -> viewIdSupport.calculateViewId(_facesContext)); } } diff --git a/impl/src/test/java/org/apache/myfaces/application/ViewIdSupportTest.java b/impl/src/test/java/org/apache/myfaces/application/ViewIdSupportTest.java index 8591cd3931..07159843e7 100644 --- a/impl/src/test/java/org/apache/myfaces/application/ViewIdSupportTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/ViewIdSupportTest.java @@ -18,17 +18,18 @@ */ package org.apache.myfaces.application; +import static org.junit.jupiter.api.Assertions.*; + import java.io.File; import java.io.FileNotFoundException; import java.net.URI; import java.net.URL; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class ViewIdSupportTest extends AbstractFacesTestCase +class ViewIdSupportTest extends AbstractFacesTestCase { private final String filePath = this.getDirectory(); private ViewIdSupport viewHandlerSupport; @@ -79,72 +80,72 @@ protected URI getContext() throw new RuntimeException("Error Initializing Context", e); } } - + @Test - public void testDeriveViewId2() throws Exception + void deriveViewId2() throws Exception { request.setPathElements("/testwebapp", "/faces", "/view1.jsp" , null); String derivedViewId = viewHandlerSupport.deriveViewId(facesContext, "/view1.jsp"); - Assertions.assertNotNull(derivedViewId); + assertNotNull(derivedViewId); } - + @Test - public void testDeriveViewId21() throws Exception + void deriveViewId21() throws Exception { request.setPathElements("/testwebapp", "/faces", "/faces/view1.jsp" , null); String derivedViewId = viewHandlerSupport.deriveViewId(facesContext, "/faces/view1.jsp"); - Assertions.assertNotNull(derivedViewId); - } - + assertNotNull(derivedViewId); + } + @Test - public void testDeriveViewId3() throws Exception + void deriveViewId3() throws Exception { request.setPathElements("/testwebapp", "/view2.jsf", null , null); String derivedViewId = viewHandlerSupport.deriveViewId(facesContext, "/view2.jsf"); - Assertions.assertNotNull(derivedViewId); + assertNotNull(derivedViewId); } - + @Test - public void testDeriveViewId4() throws Exception + void deriveViewId4() throws Exception { request.setPathElements("/testwebapp", "/faces", "/view2.xhtml" , null); String derivedViewId = viewHandlerSupport.deriveViewId(facesContext, "/view2.xhtml"); - Assertions.assertNotNull(derivedViewId); + assertNotNull(derivedViewId); } @Test - public void testDeriveViewId5() throws Exception + void deriveViewId5() throws Exception { request.setPathElements("/testwebapp", "/noview1.jsf", null , null); String derivedViewId = viewHandlerSupport.deriveViewId(facesContext, "/noview1.jsf"); - Assertions.assertNull(derivedViewId); + assertNull(derivedViewId); } - + /** * An empty prefix mapping can occur in Spring environments. * @throws Exception */ @Test - public void testEmptyPrefixMapping() throws Exception + void emptyPrefixMapping() throws Exception { request.setPathElements("/testwebapp", "", "/view2.xhtml" , null); String derivedViewId = viewHandlerSupport.deriveViewId(facesContext, "/view2.xhtml"); - Assertions.assertEquals("/view2.xhtml", derivedViewId); + assertEquals("/view2.xhtml", derivedViewId); } - + /** * An empty prefix mapping can occur in Spring environments. * However this should not only return the viewId, but also remove any @@ -152,13 +153,13 @@ public void testEmptyPrefixMapping() throws Exception * @throws Exception */ @Test - public void testEmptyPrefixMappingDoubleSlash() throws Exception + void emptyPrefixMappingDoubleSlash() throws Exception { request.setPathElements("/testwebapp", "", "//view2.xhtml" , null); String derivedViewId = viewHandlerSupport.deriveViewId(facesContext, "//view2.xhtml"); - Assertions.assertEquals("/view2.xhtml", derivedViewId); + assertEquals("/view2.xhtml", derivedViewId); } } diff --git a/impl/src/test/java/org/apache/myfaces/application/contracts/ContractsCreateResourceMyFacesRequestTestCase.java b/impl/src/test/java/org/apache/myfaces/application/contracts/ContractsCreateResourceMyFacesRequestTestCase.java index 3ab962c0a7..1a0d8992f1 100644 --- a/impl/src/test/java/org/apache/myfaces/application/contracts/ContractsCreateResourceMyFacesRequestTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/application/contracts/ContractsCreateResourceMyFacesRequestTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.application.contracts; +import static org.junit.jupiter.api.Assertions.*; + import java.util.List; import java.util.Set; import jakarta.faces.application.Resource; @@ -29,10 +31,9 @@ import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.test.core.AbstractMyFacesRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class ContractsCreateResourceMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase +class ContractsCreateResourceMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase { @Override protected void setUpWebConfigParams() throws Exception @@ -43,9 +44,9 @@ protected void setUpWebConfigParams() throws Exception servletContext.addInitParameter(MyfacesConfig.REFRESH_TRANSIENT_BUILD_ON_PSS, "auto"); servletContext.addInitParameter("jakarta.faces.CONFIG_FILES", "/blue-faces-config.xml"); } - + @Test - public void testDefaultConfiguration() throws Exception + void defaultConfiguration() throws Exception { startViewRequest("/index.xhtml"); RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext); @@ -54,39 +55,39 @@ public void testDefaultConfiguration() throws Exception Set externalContextContracts = runtimeConfig.getExternalContextResourceLibraryContracts(); Set classloaderContracts = runtimeConfig.getClassLoaderResourceLibraryContracts(); - Assertions.assertTrue(allContracts.contains("yellow")); - Assertions.assertTrue(allContracts.contains("blue")); - Assertions.assertTrue(allContracts.contains("red")); + assertTrue(allContracts.contains("yellow")); + assertTrue(allContracts.contains("blue")); + assertTrue(allContracts.contains("red")); - Assertions.assertTrue(classloaderContracts.contains("yellow")); - Assertions.assertTrue(classloaderContracts.contains("blue")); - Assertions.assertTrue(externalContextContracts.contains("red")); + assertTrue(classloaderContracts.contains("yellow")); + assertTrue(classloaderContracts.contains("blue")); + assertTrue(externalContextContracts.contains("red")); List defaultContracts = runtimeConfig.getContractMappings().get("*"); - Assertions.assertFalse(defaultContracts.contains("yellow")); - Assertions.assertTrue(defaultContracts.contains("blue")); - Assertions.assertFalse(defaultContracts.contains("red")); + assertFalse(defaultContracts.contains("yellow")); + assertTrue(defaultContracts.contains("blue")); + assertFalse(defaultContracts.contains("red")); processLifecycleExecute(); executeBuildViewCycle(); List contractsList = facesContext.getResourceLibraryContracts(); - Assertions.assertFalse(contractsList.contains("yellow")); - Assertions.assertTrue(contractsList.contains("blue")); - Assertions.assertFalse(contractsList.contains("red")); + assertFalse(contractsList.contains("yellow")); + assertTrue(contractsList.contains("blue")); + assertFalse(contractsList.contains("red")); ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler(); ViewResource resource1 = resourceHandler.createViewResource(facesContext, "/panel.xhtml"); - Assertions.assertNotNull(resource1); - Assertions.assertTrue(resource1.getURL().toString().contains("panel.xhtml")); + assertNotNull(resource1); + assertTrue(resource1.getURL().toString().contains("panel.xhtml")); Resource resource2 = resourceHandler.createResource("myjs.js", "mylib"); - Assertions.assertNotNull(resource2); + assertNotNull(resource2); boolean libraryFound = resourceHandler.libraryExists("mylib"); - Assertions.assertTrue(libraryFound); + assertTrue(libraryFound); endRequest(); } diff --git a/impl/src/test/java/org/apache/myfaces/application/contracts/DefaultContractsConfigMyFacesRequestTestCase.java b/impl/src/test/java/org/apache/myfaces/application/contracts/DefaultContractsConfigMyFacesRequestTestCase.java index 89b55ade0a..0288452df6 100644 --- a/impl/src/test/java/org/apache/myfaces/application/contracts/DefaultContractsConfigMyFacesRequestTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/application/contracts/DefaultContractsConfigMyFacesRequestTestCase.java @@ -18,18 +18,19 @@ */ package org.apache.myfaces.application.contracts; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; import java.util.Set; import jakarta.faces.application.StateManager; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.apache.myfaces.config.RuntimeConfig; import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.test.core.AbstractMyFacesRequestTestCase; import org.junit.jupiter.api.Test; -public class DefaultContractsConfigMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase +class DefaultContractsConfigMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase { @Override @@ -40,9 +41,9 @@ protected void setUpWebConfigParams() throws Exception servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.StateSavingMethod.CLIENT.name()); servletContext.addInitParameter(MyfacesConfig.REFRESH_TRANSIENT_BUILD_ON_PSS, "auto"); } - + @Test - public void testDefaultConfiguration() throws Exception + void defaultConfiguration() throws Exception { startViewRequest("/index.xhtml"); RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext); @@ -51,27 +52,27 @@ public void testDefaultConfiguration() throws Exception Set externalContextContracts = runtimeConfig.getExternalContextResourceLibraryContracts(); Set classloaderContracts = runtimeConfig.getClassLoaderResourceLibraryContracts(); - Assertions.assertTrue(allContracts.contains("yellow")); - Assertions.assertTrue(allContracts.contains("blue")); - Assertions.assertTrue(allContracts.contains("red")); + assertTrue(allContracts.contains("yellow")); + assertTrue(allContracts.contains("blue")); + assertTrue(allContracts.contains("red")); - Assertions.assertTrue(classloaderContracts.contains("yellow")); - Assertions.assertTrue(classloaderContracts.contains("blue")); - Assertions.assertTrue(externalContextContracts.contains("red")); + assertTrue(classloaderContracts.contains("yellow")); + assertTrue(classloaderContracts.contains("blue")); + assertTrue(externalContextContracts.contains("red")); List defaultContracts = runtimeConfig.getContractMappings().get("*"); - Assertions.assertTrue(defaultContracts.contains("yellow")); - Assertions.assertTrue(defaultContracts.contains("blue")); - Assertions.assertTrue(defaultContracts.contains("red")); + assertTrue(defaultContracts.contains("yellow")); + assertTrue(defaultContracts.contains("blue")); + assertTrue(defaultContracts.contains("red")); processLifecycleExecute(); executeBuildViewCycle(); List contractsList = facesContext.getResourceLibraryContracts(); - Assertions.assertTrue(contractsList.contains("yellow")); - Assertions.assertTrue(contractsList.contains("blue")); - Assertions.assertTrue(contractsList.contains("red")); + assertTrue(contractsList.contains("yellow")); + assertTrue(contractsList.contains("blue")); + assertTrue(contractsList.contains("red")); endRequest(); } diff --git a/impl/src/test/java/org/apache/myfaces/application/contracts/SingleContractMyFacesRequestTestCase.java b/impl/src/test/java/org/apache/myfaces/application/contracts/SingleContractMyFacesRequestTestCase.java index 6ac1284767..132ab62b69 100644 --- a/impl/src/test/java/org/apache/myfaces/application/contracts/SingleContractMyFacesRequestTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/application/contracts/SingleContractMyFacesRequestTestCase.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.application.contracts; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Iterator; import java.util.List; import java.util.Set; @@ -33,10 +36,9 @@ import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.test.core.AbstractMyFacesRequestTestCase; import org.apache.myfaces.test.mock.MockPrintWriter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class SingleContractMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase +class SingleContractMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase { @Override protected void setUpWebConfigParams() throws Exception @@ -48,9 +50,9 @@ protected void setUpWebConfigParams() throws Exception servletContext.addInitParameter("jakarta.faces.CONFIG_FILES", "/no-contract-faces-config.xml"); servletContext.addInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME, ProjectStage.Production.toString()); } - + @Test - public void testDefaultConfiguration() throws Exception + void defaultConfiguration() throws Exception { startViewRequest("/index.xhtml"); RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext); @@ -59,19 +61,19 @@ public void testDefaultConfiguration() throws Exception Set externalContextContracts = runtimeConfig.getExternalContextResourceLibraryContracts(); Set classloaderContracts = runtimeConfig.getClassLoaderResourceLibraryContracts(); - Assertions.assertTrue(allContracts.contains("yellow")); - Assertions.assertTrue(allContracts.contains("blue")); - Assertions.assertTrue(allContracts.contains("red")); + assertTrue(allContracts.contains("yellow")); + assertTrue(allContracts.contains("blue")); + assertTrue(allContracts.contains("red")); - Assertions.assertTrue(classloaderContracts.contains("yellow")); - Assertions.assertTrue(classloaderContracts.contains("blue")); - Assertions.assertTrue(externalContextContracts.contains("red")); + assertTrue(classloaderContracts.contains("yellow")); + assertTrue(classloaderContracts.contains("blue")); + assertTrue(externalContextContracts.contains("red")); processLifecycleExecute(); executeBuildViewCycle(); List contractsList = facesContext.getResourceLibraryContracts(); - Assertions.assertTrue(contractsList == null || contractsList.isEmpty()); + assertTrue(contractsList == null || contractsList.isEmpty()); executeViewHandlerRender(); executeAfterRender(); @@ -80,7 +82,7 @@ public void testDefaultConfiguration() throws Exception } @Test - public void testView1() throws Exception + void view1() throws Exception { startViewRequest("/view_1.xhtml"); @@ -88,7 +90,7 @@ public void testView1() throws Exception executeBuildViewCycle(); List contractsList = facesContext.getResourceLibraryContracts(); - Assertions.assertTrue(contractsList.contains("yellow")); + assertTrue(contractsList.contains("yellow")); executeViewHandlerRender(); executeAfterRender(); @@ -99,18 +101,18 @@ public void testView1() throws Exception processLifecycleExecute(); List contractsList2 = facesContext.getResourceLibraryContracts(); - Assertions.assertTrue(contractsList2.contains("yellow")); + assertTrue(contractsList2.contains("yellow")); } - + @Test - public void testView2() throws Exception + void view2() throws Exception { startViewRequest("/view_2.xhtml"); processLifecycleExecute(); executeBuildViewCycle(); List contractsList = facesContext.getResourceLibraryContracts(); - Assertions.assertTrue(contractsList.contains("blue")); + assertTrue(contractsList.contains("blue")); executeViewHandlerRender(); executeAfterRender(); @@ -121,18 +123,18 @@ public void testView2() throws Exception processLifecycleExecute(); List contractsList2 = facesContext.getResourceLibraryContracts(); - Assertions.assertTrue(contractsList2.contains("blue")); + assertTrue(contractsList2.contains("blue")); } @Test - public void testView3() throws Exception + void view3() throws Exception { startViewRequest("/view_3.xhtml"); processLifecycleExecute(); executeBuildViewCycle(); List contractsList = facesContext.getResourceLibraryContracts(); - Assertions.assertTrue(contractsList.contains("red")); + assertTrue(contractsList.contains("red")); executeViewHandlerRender(); executeAfterRender(); @@ -143,25 +145,25 @@ public void testView3() throws Exception processLifecycleExecute(); List contractsList2 = facesContext.getResourceLibraryContracts(); - Assertions.assertTrue(contractsList2.contains("red")); + assertTrue(contractsList2.contains("red")); } - + @Test - public void testView1_3() throws Exception + void view13() throws Exception { startViewRequest("/view_1.xhtml"); processLifecycleExecute(); executeBuildViewCycle(); List contractsList = facesContext.getResourceLibraryContracts(); - Assertions.assertTrue(contractsList.contains("yellow")); + assertTrue(contractsList.contains("yellow")); executeViewHandlerRender(); executeAfterRender(); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("header_yellow")); + assertTrue(content1.contains("header_yellow")); endRequest(); @@ -170,21 +172,21 @@ public void testView1_3() throws Exception executeBuildViewCycle(); contractsList = facesContext.getResourceLibraryContracts(); - Assertions.assertTrue(contractsList.contains("red")); + assertTrue(contractsList.contains("red")); executeViewHandlerRender(); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("header_red")); + assertTrue(content2.contains("header_red")); executeAfterRender(); endRequest(); - } + } @Test - public void testGetViewResourcesYellow() + void getViewResourcesYellow() { startViewRequest("/view_1.xhtml"); processLifecycleExecute(); @@ -210,14 +212,14 @@ public void testGetViewResourcesYellow() hasRedPage = true; } } - Assertions.assertTrue(hasYellowPage); - Assertions.assertFalse(hasBluePage); - Assertions.assertFalse(hasRedPage); + assertTrue(hasYellowPage); + assertFalse(hasBluePage); + assertFalse(hasRedPage); } - + @Test - public void testGetViewResourcesBlue() + void getViewResourcesBlue() { startViewRequest("/view_2.xhtml"); processLifecycleExecute(); @@ -243,13 +245,13 @@ public void testGetViewResourcesBlue() hasRedPage = true; } } - Assertions.assertFalse(hasYellowPage); - Assertions.assertTrue(hasBluePage); - Assertions.assertFalse(hasRedPage); + assertFalse(hasYellowPage); + assertTrue(hasBluePage); + assertFalse(hasRedPage); } @Test - public void testGetTopLevelViewResourcesBlue() + void getTopLevelViewResourcesBlue() { startViewRequest("/view_2.xhtml"); processLifecycleExecute(); @@ -276,9 +278,9 @@ public void testGetTopLevelViewResourcesBlue() } //System.out.println(s); } - Assertions.assertFalse(hasYellowPage); - Assertions.assertTrue(hasBluePage); - Assertions.assertFalse(hasRedPage); + assertFalse(hasYellowPage); + assertTrue(hasBluePage); + assertFalse(hasRedPage); } } diff --git a/impl/src/test/java/org/apache/myfaces/application/flow/FlowMyFacesCDIRequestTestCase.java b/impl/src/test/java/org/apache/myfaces/application/flow/FlowMyFacesCDIRequestTestCase.java index 6acbeb24b4..514f608539 100644 --- a/impl/src/test/java/org/apache/myfaces/application/flow/FlowMyFacesCDIRequestTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/application/flow/FlowMyFacesCDIRequestTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.application.flow; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.enterprise.context.ContextNotActiveException; import jakarta.faces.application.NavigationCase; import jakarta.faces.application.NavigationHandler; @@ -27,14 +29,13 @@ import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * This test is the same as FlowMyFacesRequestTestCase with the difference that * in this case CDI is enabled and the other alternative is used. */ -public class FlowMyFacesCDIRequestTestCase extends AbstractMyFacesCDIRequestTestCase +class FlowMyFacesCDIRequestTestCase extends AbstractMyFacesCDIRequestTestCase { @Override protected void setUpWebConfigParams() throws Exception @@ -46,9 +47,9 @@ protected void setUpWebConfigParams() throws Exception servletContext.addInitParameter("jakarta.faces.CONFIG_FILES", "/WEB-INF/flow1-flow.xml"); servletContext.addInitParameter("jakarta.faces.CLIENT_WINDOW_MODE", "url"); } - + @Test - public void testFlow1_1() throws Exception + void flow11() throws Exception { startViewRequest("/flow1_1.xhtml"); processLifecycleExecute(); @@ -57,14 +58,14 @@ public void testFlow1_1() throws Exception NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1"); - Assertions.assertNotNull(navCase); + assertNotNull(navCase); NavigationCase contentCase = handler.getNavigationCase(facesContext, null, "flow1_content"); - Assertions.assertNull(contentCase); + assertNull(contentCase); // Check begin view node - Assertions.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); + assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); renderResponse(); @@ -75,21 +76,21 @@ public void testFlow1_1() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); + assertNotNull(currentFlow); // Check Flow1Bean can be created Flow1Bean bean1 = facesContext.getApplication().evaluateExpressionGet( facesContext, "#{flow1Bean}", Flow1Bean.class); - Assertions.assertNotNull(bean1); - Assertions.assertEquals(bean1.getPostConstructCalled(), "true"); + assertNotNull(bean1); + assertEquals("true", bean1.getPostConstructCalled()); contentCase = handler.getNavigationCase(facesContext, null, "flow1_content"); - Assertions.assertNotNull(contentCase); + assertNotNull(contentCase); } - + @Test - public void testFlow1_2() throws Exception + void flow12() throws Exception { startViewRequest("/flow1_2.xhtml"); processLifecycleExecute(); @@ -98,14 +99,14 @@ public void testFlow1_2() throws Exception NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1"); - Assertions.assertNotNull(navCase); + assertNotNull(navCase); NavigationCase contentCase = handler.getNavigationCase(facesContext, null, "flow1_content"); - Assertions.assertNull(contentCase); + assertNull(contentCase); // Check begin view node - Assertions.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); + assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); renderResponse(); @@ -116,16 +117,16 @@ public void testFlow1_2() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow1", currentFlow.getId()); + assertNotNull(currentFlow); + assertEquals("flow1", currentFlow.getId()); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow1","value1"); // Check the bean with @FlowScoped annotation can be instantiated Flow1Bean bean1 = facesContext.getApplication().evaluateExpressionGet( facesContext, "#{flow1Bean}", Flow1Bean.class); - Assertions.assertNotNull(bean1); - Assertions.assertEquals(bean1.getPostConstructCalled(), "true"); + assertNotNull(bean1); + assertEquals("true", bean1.getPostConstructCalled()); bean1.setName("John"); renderResponse(); @@ -136,30 +137,30 @@ public void testFlow1_2() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow2", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); + assertNotNull(currentFlow); + assertEquals("flow2", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow2","value2"); Flow2Bean bean2 = facesContext.getApplication().evaluateExpressionGet( facesContext, "#{flow2Bean}", Flow2Bean.class); - Assertions.assertNotNull(bean2); - Assertions.assertEquals(bean2.getPostConstructCalled(), "true"); + assertNotNull(bean2); + assertEquals("true", bean2.getPostConstructCalled()); Flow1Bean bean1_1 = facesContext.getApplication().evaluateExpressionGet( facesContext, "#{flow1Bean}", Flow1Bean.class); - Assertions.assertEquals(bean1_1.getName(), "John"); + assertEquals("John", bean1_1.getName()); Flow21Bean bean2_1 = facesContext.getApplication().evaluateExpressionGet( facesContext, "#{flow21Bean}", Flow21Bean.class); - Assertions.assertNotNull(bean2_1); - Assertions.assertEquals(bean2_1.getPostConstructCalled(), "true"); - Assertions.assertNotNull(bean2_1.getFlow1Bean()); + assertNotNull(bean2_1); + assertEquals("true", bean2_1.getPostConstructCalled()); + assertNotNull(bean2_1.getFlow1Bean()); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId()); UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:content"); client.submit(button3); @@ -167,11 +168,11 @@ public void testFlow1_2() throws Exception renderResponse(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow2", currentFlow.getId()); + assertNotNull(currentFlow); + assertEquals("flow2", currentFlow.getId()); NavigationCase endCase = handler.getNavigationCase(facesContext, null, "end"); - Assertions.assertNotNull(endCase); + assertNotNull(endCase); UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow"); client.submit(button4); @@ -182,15 +183,15 @@ public void testFlow1_2() throws Exception // to chain all commands. The difficulty here resides in the context should be resolved properly, and // there are a couple of recursive calls that needs to be solved. currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNull(currentFlow); - Assertions.assertEquals("/flow1_end.xhtml", facesContext.getViewRoot().getViewId()); + assertNull(currentFlow); + assertEquals("/flow1_end.xhtml", facesContext.getViewRoot().getViewId()); try { Flow1Bean bean1_2 = facesContext.getApplication().evaluateExpressionGet( facesContext, "#{flow1Bean}", Flow1Bean.class); bean1_2.getName(); - Assertions.fail("Invocation show throw NullPointerException or ContextNotActiveException"); + fail("Invocation show throw NullPointerException or ContextNotActiveException"); } catch (ContextNotActiveException e) { @@ -206,7 +207,7 @@ public void testFlow1_2() throws Exception * @throws Exception */ @Test - public void testFlow1_12() throws Exception + void flow112() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -221,27 +222,27 @@ public void testFlow1_12() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow4/flow4.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow4/flow4.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flow4"); + assertNotNull(currentFlow); + assertEquals("flow4", currentFlow.getId()); renderResponse(); NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "call_flow5_4"); - Assertions.assertNotNull(goFlowBase); + assertNotNull(goFlowBase); UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow5"); client.submit(button2); processLifecycleExecute(); - Assertions.assertEquals("/flow5/flow5.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow5/flow5.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); } - + /** * This tests do the following: * @@ -254,7 +255,7 @@ public void testFlow1_12() throws Exception * - Return from Flow B */ @Test - public void testFlowA_1() throws Exception + void flowA1() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -270,11 +271,11 @@ public void testFlowA_1() throws Exception processLifecycleExecute(); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowA","valueA_1"); - Assertions.assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flowA"); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); renderResponse(); @@ -284,15 +285,15 @@ public void testFlowA_1() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowB", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA")); + assertNotNull(currentFlow); + assertEquals("flowB", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowB","valueB_1"); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow_A"); client.submit(button3); @@ -300,15 +301,15 @@ public void testFlowA_1() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowA", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowB")); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowB")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowA","valueA_2"); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow_B"); client.submit(button4); @@ -316,15 +317,15 @@ public void testFlowA_1() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowB", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA")); + assertNotNull(currentFlow); + assertEquals("flowB", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowB","valueB_2"); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow"); client.submit(button5); @@ -332,9 +333,9 @@ public void testFlowA_1() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowA", currentFlow.getId()); - Assertions.assertEquals("valueA_2", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); + assertEquals("valueA_2", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); renderResponse(); @@ -344,9 +345,9 @@ public void testFlowA_1() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowB", currentFlow.getId()); - Assertions.assertEquals("valueB_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowB")); + assertNotNull(currentFlow); + assertEquals("flowB", currentFlow.getId()); + assertEquals("valueB_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowB")); renderResponse(); @@ -356,15 +357,15 @@ public void testFlowA_1() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowA", currentFlow.getId()); - Assertions.assertEquals("valueA_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); + assertEquals("valueA_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); renderResponse(); } - + @Test - public void testFlowA_2() throws Exception + void flowA2() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -380,11 +381,11 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowA","valueA_1"); - Assertions.assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flowA"); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); renderResponse(); @@ -395,9 +396,9 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); + assertNotNull(currentFlow); // We are still on flowA, just returned to base - Assertions.assertEquals("flowA", currentFlow.getId()); + assertEquals("flowA", currentFlow.getId()); renderResponse(); @@ -408,11 +409,11 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowB","valueB_1"); - Assertions.assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flowB"); + assertNotNull(currentFlow); + assertEquals("flowB", currentFlow.getId()); renderResponse(); @@ -423,15 +424,15 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowA", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowB")); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowB")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowA","valueA_2"); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); // Call flow B through flow call UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow_B"); @@ -440,15 +441,15 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowB", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA")); + assertNotNull(currentFlow); + assertEquals("flowB", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowB","valueB_2"); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); UICommand button6 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow"); client.submit(button6); @@ -456,9 +457,9 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowA", currentFlow.getId()); - Assertions.assertEquals("valueA_2", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); + assertEquals("valueA_2", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); renderResponse(); @@ -468,9 +469,9 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowB", currentFlow.getId()); - Assertions.assertEquals("valueB_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowB")); + assertNotNull(currentFlow); + assertEquals("flowB", currentFlow.getId()); + assertEquals("valueB_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowB")); renderResponse(); @@ -480,9 +481,9 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowA", currentFlow.getId()); - Assertions.assertEquals("valueA_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); + assertEquals("valueA_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); renderResponse(); diff --git a/impl/src/test/java/org/apache/myfaces/application/flow/FlowMyFacesRequestTestCase.java b/impl/src/test/java/org/apache/myfaces/application/flow/FlowMyFacesRequestTestCase.java index e3e4954c97..8ecbb49a52 100644 --- a/impl/src/test/java/org/apache/myfaces/application/flow/FlowMyFacesRequestTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/application/flow/FlowMyFacesRequestTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.application.flow; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.el.ExpressionFactory; import jakarta.faces.application.NavigationCase; import jakarta.faces.application.NavigationHandler; @@ -30,14 +32,13 @@ import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.test.core.AbstractMyFacesRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * * @author Leonardo Uribe */ -public class FlowMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase +class FlowMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase { @Override protected void setUpWebConfigParams() throws Exception @@ -49,9 +50,9 @@ protected void setUpWebConfigParams() throws Exception servletContext.addInitParameter("jakarta.faces.CONFIG_FILES", "/WEB-INF/flow1-flow.xml"); servletContext.addInitParameter("jakarta.faces.CLIENT_WINDOW_MODE", "url"); } - + @Test - public void testFlow1_1() throws Exception + void flow11() throws Exception { startViewRequest("/flow1_1.xhtml"); processLifecycleExecute(); @@ -60,14 +61,14 @@ public void testFlow1_1() throws Exception NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1"); - Assertions.assertNotNull(navCase); + assertNotNull(navCase); NavigationCase contentCase = handler.getNavigationCase(facesContext, null, "flow1_content"); - Assertions.assertNull(contentCase); + assertNull(contentCase); // Check begin view node - Assertions.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); + assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); renderResponse(); @@ -78,15 +79,15 @@ public void testFlow1_1() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); + assertNotNull(currentFlow); contentCase = handler.getNavigationCase(facesContext, null, "flow1_content"); - Assertions.assertNotNull(contentCase); + assertNotNull(contentCase); } - + @Test - public void testFlow1_2() throws Exception + void flow12() throws Exception { startViewRequest("/flow1_2.xhtml"); processLifecycleExecute(); @@ -95,14 +96,14 @@ public void testFlow1_2() throws Exception NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1"); - Assertions.assertNotNull(navCase); + assertNotNull(navCase); NavigationCase contentCase = handler.getNavigationCase(facesContext, null, "flow1_content"); - Assertions.assertNull(contentCase); + assertNull(contentCase); // Check begin view node - Assertions.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); + assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); renderResponse(); @@ -113,8 +114,8 @@ public void testFlow1_2() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow1", currentFlow.getId()); + assertNotNull(currentFlow); + assertEquals("flow1", currentFlow.getId()); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow1","value1"); @@ -126,15 +127,15 @@ public void testFlow1_2() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow2", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); + assertNotNull(currentFlow); + assertEquals("flow2", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow2","value2"); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId()); UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:content"); client.submit(button3); @@ -142,11 +143,11 @@ public void testFlow1_2() throws Exception renderResponse(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow2", currentFlow.getId()); + assertNotNull(currentFlow); + assertEquals("flow2", currentFlow.getId()); NavigationCase endCase = handler.getNavigationCase(facesContext, null, "end"); - Assertions.assertNotNull(endCase); + assertNotNull(endCase); UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow"); client.submit(button4); @@ -157,12 +158,12 @@ public void testFlow1_2() throws Exception // to chain all commands. The difficulty here resides in the context should be resolved properly, and // there are a couple of recursive calls that needs to be solved. currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNull(currentFlow); - Assertions.assertEquals("/flow1_end.xhtml", facesContext.getViewRoot().getViewId()); + assertNull(currentFlow); + assertEquals("/flow1_end.xhtml", facesContext.getViewRoot().getViewId()); } - + @Test - public void testFlow1_3() throws Exception + void flow13() throws Exception { startViewRequest("/flow1_2.xhtml"); processLifecycleExecute(); @@ -171,14 +172,14 @@ public void testFlow1_3() throws Exception NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1"); - Assertions.assertNotNull(navCase); + assertNotNull(navCase); NavigationCase contentCase = handler.getNavigationCase(facesContext, null, "flow1_content"); - Assertions.assertNull(contentCase); + assertNull(contentCase); // Check begin view node - Assertions.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); + assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); renderResponse(); @@ -189,8 +190,8 @@ public void testFlow1_3() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow1", currentFlow.getId()); + assertNotNull(currentFlow); + assertEquals("flow1", currentFlow.getId()); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow1","value1"); @@ -202,15 +203,15 @@ public void testFlow1_3() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow2", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); + assertNotNull(currentFlow); + assertEquals("flow2", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow2","value2"); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId()); UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:content"); client.submit(button3); @@ -218,11 +219,11 @@ public void testFlow1_3() throws Exception renderResponse(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow2", currentFlow.getId()); + assertNotNull(currentFlow); + assertEquals("flow2", currentFlow.getId()); NavigationCase endCase = handler.getNavigationCase(facesContext, null, "back"); - Assertions.assertNotNull(endCase); + assertNotNull(endCase); UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:back_flow"); client.submit(button4); @@ -231,16 +232,16 @@ public void testFlow1_3() throws Exception // Check it should go back to flow1 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow1", currentFlow.getId()); - Assertions.assertTrue(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); + assertNotNull(currentFlow); + assertEquals("flow1", currentFlow.getId()); + assertTrue(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); // Check lastDisplayedViewId - Assertions.assertEquals("/flow1/begin.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow1/begin.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); endCase = handler.getNavigationCase(facesContext, null, "back"); - Assertions.assertNotNull(endCase); + assertNotNull(endCase); UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:back_flow"); client.submit(button5); @@ -248,13 +249,13 @@ public void testFlow1_3() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNull(currentFlow); - Assertions.assertEquals("/flow1_2.xhtml", facesContext.getViewRoot().getViewId()); + assertNull(currentFlow); + assertEquals("/flow1_2.xhtml", facesContext.getViewRoot().getViewId()); } @Test - public void testFlow1_4() throws Exception + void flow14() throws Exception { startViewRequest("/flow1_2.xhtml"); processLifecycleExecute(); @@ -263,10 +264,10 @@ public void testFlow1_4() throws Exception NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1"); - Assertions.assertNotNull(navCase); + assertNotNull(navCase); // Check begin view node - Assertions.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); + assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); renderResponse(); @@ -277,8 +278,8 @@ public void testFlow1_4() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow1", currentFlow.getId()); + assertNotNull(currentFlow); + assertEquals("flow1", currentFlow.getId()); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow1","value1"); @@ -290,15 +291,15 @@ public void testFlow1_4() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow2", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); + assertNotNull(currentFlow); + assertEquals("flow2", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow2","value2"); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId()); UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:content"); client.submit(button3); @@ -306,11 +307,11 @@ public void testFlow1_4() throws Exception renderResponse(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow2", currentFlow.getId()); + assertNotNull(currentFlow); + assertEquals("flow2", currentFlow.getId()); NavigationCase endCase = handler.getNavigationCase(facesContext, null, "back"); - Assertions.assertNotNull(endCase); + assertNotNull(endCase); String toViewId = endCase.getToViewId(facesContext); String fromOutcome = endCase.getFromOutcome(); String clientWindowId = facesContext.getExternalContext().getClientWindow().getId(); @@ -325,16 +326,16 @@ public void testFlow1_4() throws Exception // Check it should go back to flow1 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow1", currentFlow.getId()); - Assertions.assertTrue(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); + assertNotNull(currentFlow); + assertEquals("flow1", currentFlow.getId()); + assertTrue(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); // Check lastDisplayedViewId //Assertions.assertEquals("/flow1/begin.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); endCase = handler.getNavigationCase(facesContext, null, "back"); - Assertions.assertNotNull(endCase); + assertNotNull(endCase); toViewId = endCase.getToViewId(facesContext); fromOutcome = endCase.getFromOutcome(); @@ -349,12 +350,12 @@ public void testFlow1_4() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNull(currentFlow); - Assertions.assertEquals("/flow1_2.xhtml", facesContext.getViewRoot().getViewId()); - } - + assertNull(currentFlow); + assertEquals("/flow1_2.xhtml", facesContext.getViewRoot().getViewId()); + } + @Test - public void testFlow1_5() throws Exception + void flow15() throws Exception { startViewRequest("/flow1_2.xhtml"); processLifecycleExecute(); @@ -363,10 +364,10 @@ public void testFlow1_5() throws Exception NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow3"); - Assertions.assertNotNull(navCase); + assertNotNull(navCase); // Check begin view node - Assertions.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); + assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); renderResponse(); String clientWindowId = facesContext.getExternalContext().getClientWindow().getId(); @@ -383,8 +384,8 @@ public void testFlow1_5() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow1", currentFlow.getId()); + assertNotNull(currentFlow); + assertEquals("flow1", currentFlow.getId()); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow1","value1"); @@ -404,15 +405,15 @@ public void testFlow1_5() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow2", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); + assertNotNull(currentFlow); + assertEquals("flow2", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow2","value2"); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId()); UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:content"); client.submit(button3); @@ -420,11 +421,11 @@ public void testFlow1_5() throws Exception renderResponse(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow2", currentFlow.getId()); + assertNotNull(currentFlow); + assertEquals("flow2", currentFlow.getId()); NavigationCase endCase = handler.getNavigationCase(facesContext, null, "back"); - Assertions.assertNotNull(endCase); + assertNotNull(endCase); String toViewId = endCase.getToViewId(facesContext); String fromOutcome = endCase.getFromOutcome(); clientWindowId = facesContext.getExternalContext().getClientWindow().getId(); @@ -439,20 +440,20 @@ public void testFlow1_5() throws Exception // Check it should go back to flow1 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flow1", currentFlow.getId()); - Assertions.assertTrue(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); + assertNotNull(currentFlow); + assertEquals("flow1", currentFlow.getId()); + assertTrue(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1")); // Check lastDisplayedViewId (since it was GET, it should be the start viewId) - Assertions.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); endCase = handler.getNavigationCase(facesContext, null, "switchBack"); - Assertions.assertNotNull(endCase); + assertNotNull(endCase); toViewId = endCase.getToViewId(facesContext); // Check if the dynamic outcome return hack has been correctly resolved. - Assertions.assertEquals(toViewId, "/flow3/content.xhtml"); + assertEquals("/flow3/content.xhtml", toViewId); fromOutcome = endCase.getFromOutcome(); clientWindowId = facesContext.getExternalContext().getClientWindow().getId(); @@ -465,7 +466,7 @@ public void testFlow1_5() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); + assertNotNull(currentFlow); //Assertions.assertEquals("/flow1_2.xhtml", facesContext.getViewRoot().getViewId()); } @@ -474,7 +475,7 @@ protected ExpressionFactory createExpressionFactory() { return new org.apache.el.ExpressionFactoryImpl(); } - + /** * This tests do the following: * @@ -488,7 +489,7 @@ protected ExpressionFactory createExpressionFactory() * @throws Exception */ @Test - public void testFlow1_6() throws Exception + void flow16() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -497,10 +498,10 @@ public void testFlow1_6() throws Exception NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1"); - Assertions.assertNotNull(navCase); + assertNotNull(navCase); // Check begin view node - Assertions.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); + assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); renderResponse(); @@ -511,20 +512,20 @@ public void testFlow1_6() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flow1"); + assertNotNull(currentFlow); + assertEquals("flow1", currentFlow.getId()); renderResponse(); NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base"); - Assertions.assertNotNull(goFlowBase); + assertNotNull(goFlowBase); UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base"); client.submit(button2); processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -534,8 +535,8 @@ public void testFlow1_6() throws Exception processLifecycleExecute(); Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow2); - Assertions.assertEquals(currentFlow2.getId(), "flow2"); + assertNotNull(currentFlow2); + assertEquals("flow2", currentFlow2.getId()); renderResponse(); @@ -544,7 +545,7 @@ public void testFlow1_6() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -553,11 +554,11 @@ public void testFlow1_6() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow3); - Assertions.assertEquals(currentFlow3.getId(), "flow2"); + assertNotNull(currentFlow3); + assertEquals("flow2", currentFlow3.getId()); renderResponse(); @@ -567,11 +568,11 @@ public void testFlow1_6() throws Exception processLifecycleExecute(); Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNull(currentFlow4); + assertNull(currentFlow4); renderResponse(); } - + /** * This tests do the following: * @@ -584,7 +585,7 @@ public void testFlow1_6() throws Exception * @throws Exception */ @Test - public void testFlow1_7() throws Exception + void flow17() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -593,10 +594,10 @@ public void testFlow1_7() throws Exception NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1"); - Assertions.assertNotNull(navCase); + assertNotNull(navCase); // Check begin view node - Assertions.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); + assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext)); renderResponse(); @@ -607,8 +608,8 @@ public void testFlow1_7() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flow1"); + assertNotNull(currentFlow); + assertEquals("flow1", currentFlow.getId()); renderResponse(); @@ -618,8 +619,8 @@ public void testFlow1_7() throws Exception processLifecycleExecute(); Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow2); - Assertions.assertEquals(currentFlow2.getId(), "flow2"); + assertNotNull(currentFlow2); + assertEquals("flow2", currentFlow2.getId()); renderResponse(); @@ -628,7 +629,7 @@ public void testFlow1_7() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -637,10 +638,10 @@ public void testFlow1_7() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNull(currentFlow3); + assertNull(currentFlow3); } /** @@ -657,7 +658,7 @@ public void testFlow1_7() throws Exception * @throws Exception */ @Test - public void testFlow1_8() throws Exception + void flow18() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -673,8 +674,8 @@ public void testFlow1_8() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flow1"); + assertNotNull(currentFlow); + assertEquals("flow1", currentFlow.getId()); renderResponse(); @@ -684,8 +685,8 @@ public void testFlow1_8() throws Exception processLifecycleExecute(); Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow2); - Assertions.assertEquals(currentFlow2.getId(), "flow2"); + assertNotNull(currentFlow2); + assertEquals("flow2", currentFlow2.getId()); renderResponse(); @@ -694,7 +695,7 @@ public void testFlow1_8() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -703,11 +704,11 @@ public void testFlow1_8() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow3); - Assertions.assertEquals(currentFlow3.getId(), "flow3"); + assertNotNull(currentFlow3); + assertEquals("flow3", currentFlow3.getId()); } /** @@ -721,7 +722,7 @@ public void testFlow1_8() throws Exception * @throws Exception */ @Test - public void testFlow1_9() throws Exception + void flow19() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -737,20 +738,20 @@ public void testFlow1_9() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flow2"); + assertNotNull(currentFlow); + assertEquals("flow2", currentFlow.getId()); renderResponse(); NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base"); - Assertions.assertNotNull(goFlowBase); + assertNotNull(goFlowBase); UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base"); client.submit(button2); processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -760,8 +761,8 @@ public void testFlow1_9() throws Exception processLifecycleExecute(); Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow2); - Assertions.assertEquals(currentFlow2.getId(), "flow1"); + assertNotNull(currentFlow2); + assertEquals("flow1", currentFlow2.getId()); renderResponse(); @@ -770,7 +771,7 @@ public void testFlow1_9() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -779,11 +780,11 @@ public void testFlow1_9() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow3); - Assertions.assertEquals(currentFlow3.getId(), "flow2"); + assertNotNull(currentFlow3); + assertEquals("flow2", currentFlow3.getId()); renderResponse(); @@ -793,11 +794,11 @@ public void testFlow1_9() throws Exception processLifecycleExecute(); Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNull(currentFlow4); + assertNull(currentFlow4); renderResponse(); } - + /** * This tests do the following: * @@ -809,7 +810,7 @@ public void testFlow1_9() throws Exception * @throws Exception */ @Test - public void testFlow1_9_1() throws Exception + void flow191() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -825,20 +826,20 @@ public void testFlow1_9_1() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flow2"); + assertNotNull(currentFlow); + assertEquals("flow2", currentFlow.getId()); renderResponse(); NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base"); - Assertions.assertNotNull(goFlowBase); + assertNotNull(goFlowBase); UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base"); client.submit(button2); processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -848,8 +849,8 @@ public void testFlow1_9_1() throws Exception processLifecycleExecute(); Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow2); - Assertions.assertEquals(currentFlow2.getId(), "flow1"); + assertNotNull(currentFlow2); + assertEquals("flow1", currentFlow2.getId()); renderResponse(); @@ -858,7 +859,7 @@ public void testFlow1_9_1() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -866,11 +867,11 @@ public void testFlow1_9_1() throws Exception //submit(button5); NavigationCase endCase = handler.getNavigationCase(facesContext, null, "back_flow_1_3"); - Assertions.assertNotNull(endCase); + assertNotNull(endCase); String toViewId = endCase.getToViewId(facesContext); // Check if the dynamic outcome return hack has been correctly resolved. - Assertions.assertEquals(toViewId, "/flow_base.xhtml"); + assertEquals("/flow_base.xhtml", toViewId); String fromOutcome = endCase.getFromOutcome(); String clientWindowId = facesContext.getExternalContext().getClientWindow().getId(); @@ -882,11 +883,11 @@ public void testFlow1_9_1() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow3); - Assertions.assertEquals(currentFlow3.getId(), "flow2"); + assertNotNull(currentFlow3); + assertEquals("flow2", currentFlow3.getId()); renderResponse(); @@ -896,11 +897,11 @@ public void testFlow1_9_1() throws Exception processLifecycleExecute(); Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNull(currentFlow4); + assertNull(currentFlow4); renderResponse(); } - + /** * This tests do the following: @@ -913,7 +914,7 @@ public void testFlow1_9_1() throws Exception * @throws Exception */ @Test - public void testFlow1_10() throws Exception + void flow110() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -929,20 +930,20 @@ public void testFlow1_10() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flow1"); + assertNotNull(currentFlow); + assertEquals("flow1", currentFlow.getId()); renderResponse(); NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base"); - Assertions.assertNotNull(goFlowBase); + assertNotNull(goFlowBase); UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base"); client.submit(button2); processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -952,8 +953,8 @@ public void testFlow1_10() throws Exception processLifecycleExecute(); Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow2); - Assertions.assertEquals(currentFlow2.getId(), "flow2"); + assertNotNull(currentFlow2); + assertEquals("flow2", currentFlow2.getId()); renderResponse(); @@ -962,7 +963,7 @@ public void testFlow1_10() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -971,11 +972,11 @@ public void testFlow1_10() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow3); - Assertions.assertEquals(currentFlow3.getId(), "flow1"); + assertNotNull(currentFlow3); + assertEquals("flow1", currentFlow3.getId()); renderResponse(); @@ -985,11 +986,11 @@ public void testFlow1_10() throws Exception processLifecycleExecute(); Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNull(currentFlow4); + assertNull(currentFlow4); renderResponse(); } - + /** * This tests do the following: * @@ -1001,7 +1002,7 @@ public void testFlow1_10() throws Exception * @throws Exception */ @Test - public void testFlow1_10_1() throws Exception + void flow1101() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -1017,20 +1018,20 @@ public void testFlow1_10_1() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flow1"); + assertNotNull(currentFlow); + assertEquals("flow1", currentFlow.getId()); renderResponse(); NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base"); - Assertions.assertNotNull(goFlowBase); + assertNotNull(goFlowBase); UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base"); client.submit(button2); processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -1040,8 +1041,8 @@ public void testFlow1_10_1() throws Exception processLifecycleExecute(); Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow2); - Assertions.assertEquals(currentFlow2.getId(), "flow2"); + assertNotNull(currentFlow2); + assertEquals("flow2", currentFlow2.getId()); renderResponse(); @@ -1050,7 +1051,7 @@ public void testFlow1_10_1() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -1059,11 +1060,11 @@ public void testFlow1_10_1() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow3); - Assertions.assertEquals(currentFlow3.getId(), "flow2"); + assertNotNull(currentFlow3); + assertEquals("flow2", currentFlow3.getId()); renderResponse(); @@ -1073,7 +1074,7 @@ public void testFlow1_10_1() throws Exception processLifecycleExecute(); Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNull(currentFlow4); + assertNull(currentFlow4); renderResponse(); } @@ -1089,7 +1090,7 @@ public void testFlow1_10_1() throws Exception * @throws Exception */ @Test - public void testFlow1_10_2() throws Exception + void flow1102() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -1105,20 +1106,20 @@ public void testFlow1_10_2() throws Exception processLifecycleExecute(); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flow1"); + assertNotNull(currentFlow); + assertEquals("flow1", currentFlow.getId()); renderResponse(); NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base"); - Assertions.assertNotNull(goFlowBase); + assertNotNull(goFlowBase); UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base"); client.submit(button2); processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -1128,8 +1129,8 @@ public void testFlow1_10_2() throws Exception processLifecycleExecute(); Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow2); - Assertions.assertEquals(currentFlow2.getId(), "flow2"); + assertNotNull(currentFlow2); + assertEquals("flow2", currentFlow2.getId()); renderResponse(); @@ -1138,18 +1139,18 @@ public void testFlow1_10_2() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); //UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow1_3"); //submit(button5); NavigationCase endCase = handler.getNavigationCase(facesContext, null, "back_flow_1_3"); - Assertions.assertNotNull(endCase); + assertNotNull(endCase); String toViewId = endCase.getToViewId(facesContext); // Check if the dynamic outcome return hack has been correctly resolved. - Assertions.assertEquals(toViewId, "/flow_base.xhtml"); + assertEquals("/flow_base.xhtml", toViewId); String fromOutcome = endCase.getFromOutcome(); String clientWindowId = facesContext.getExternalContext().getClientWindow().getId(); @@ -1161,11 +1162,11 @@ public void testFlow1_10_2() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow3); - Assertions.assertEquals(currentFlow3.getId(), "flow2"); + assertNotNull(currentFlow3); + assertEquals("flow2", currentFlow3.getId()); renderResponse(); @@ -1175,11 +1176,11 @@ public void testFlow1_10_2() throws Exception processLifecycleExecute(); Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNull(currentFlow4); + assertNull(currentFlow4); renderResponse(); } - + /** * This tests do the following: * @@ -1192,7 +1193,7 @@ public void testFlow1_10_2() throws Exception * @throws Exception */ @Test - public void testFlow1_11() throws Exception + void flow111() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -1207,23 +1208,23 @@ public void testFlow1_11() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow4/flow4.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow4/flow4.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flow4"); + assertNotNull(currentFlow); + assertEquals("flow4", currentFlow.getId()); renderResponse(); NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base"); - Assertions.assertNotNull(goFlowBase); + assertNotNull(goFlowBase); UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base"); client.submit(button2); processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -1233,8 +1234,8 @@ public void testFlow1_11() throws Exception processLifecycleExecute(); Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow2); - Assertions.assertEquals(currentFlow2.getId(), "flow2"); + assertNotNull(currentFlow2); + assertEquals("flow2", currentFlow2.getId()); renderResponse(); @@ -1243,7 +1244,7 @@ public void testFlow1_11() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -1253,8 +1254,8 @@ public void testFlow1_11() throws Exception processLifecycleExecute(); Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow3); - Assertions.assertEquals(currentFlow3.getId(), "flow1"); + assertNotNull(currentFlow3); + assertEquals("flow1", currentFlow3.getId()); renderResponse(); @@ -1263,7 +1264,7 @@ public void testFlow1_11() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -1273,11 +1274,11 @@ public void testFlow1_11() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow4); - Assertions.assertEquals(currentFlow4.getId(), "flow2"); + assertNotNull(currentFlow4); + assertEquals("flow2", currentFlow4.getId()); renderResponse(); @@ -1287,12 +1288,12 @@ public void testFlow1_11() throws Exception processLifecycleExecute(); Flow currentFlow5 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNull(currentFlow5); + assertNull(currentFlow5); renderResponse(); } - + /** * This tests do the following: * @@ -1305,7 +1306,7 @@ public void testFlow1_11() throws Exception * @throws Exception */ @Test - public void testFlow1_11_1() throws Exception + void flow1111() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -1320,23 +1321,23 @@ public void testFlow1_11_1() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow4/flow4.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow4/flow4.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flow4"); + assertNotNull(currentFlow); + assertEquals("flow4", currentFlow.getId()); renderResponse(); NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base"); - Assertions.assertNotNull(goFlowBase); + assertNotNull(goFlowBase); UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base"); client.submit(button2); processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -1346,8 +1347,8 @@ public void testFlow1_11_1() throws Exception processLifecycleExecute(); Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow2); - Assertions.assertEquals(currentFlow2.getId(), "flow2"); + assertNotNull(currentFlow2); + assertEquals("flow2", currentFlow2.getId()); renderResponse(); @@ -1356,7 +1357,7 @@ public void testFlow1_11_1() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -1366,8 +1367,8 @@ public void testFlow1_11_1() throws Exception processLifecycleExecute(); Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow3); - Assertions.assertEquals(currentFlow3.getId(), "flow1"); + assertNotNull(currentFlow3); + assertEquals("flow1", currentFlow3.getId()); renderResponse(); @@ -1376,7 +1377,7 @@ public void testFlow1_11_1() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); renderResponse(); @@ -1384,11 +1385,11 @@ public void testFlow1_11_1() throws Exception //submit(button7); NavigationCase endCase = handler.getNavigationCase(facesContext, null, "back_flow_1_4"); - Assertions.assertNotNull(endCase); + assertNotNull(endCase); String toViewId = endCase.getToViewId(facesContext); // Check if the dynamic outcome return hack has been correctly resolved. - Assertions.assertEquals(toViewId, "/flow_base.xhtml"); + assertEquals("/flow_base.xhtml", toViewId); String fromOutcome = endCase.getFromOutcome(); String clientWindowId = facesContext.getExternalContext().getClientWindow().getId(); @@ -1400,11 +1401,11 @@ public void testFlow1_11_1() throws Exception processLifecycleExecute(); - Assertions.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow4); - Assertions.assertEquals(currentFlow4.getId(), "flow2"); + assertNotNull(currentFlow4); + assertEquals("flow2", currentFlow4.getId()); renderResponse(); @@ -1414,7 +1415,7 @@ public void testFlow1_11_1() throws Exception processLifecycleExecute(); Flow currentFlow5 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNull(currentFlow5); + assertNull(currentFlow5); renderResponse(); @@ -1432,7 +1433,7 @@ public void testFlow1_11_1() throws Exception * - Return from Flow B */ @Test - public void testFlowA_1() throws Exception + void flowA1() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -1448,11 +1449,11 @@ public void testFlowA_1() throws Exception processLifecycleExecute(); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowA","valueA_1"); - Assertions.assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flowA"); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); renderResponse(); @@ -1462,15 +1463,15 @@ public void testFlowA_1() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowB", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA")); + assertNotNull(currentFlow); + assertEquals("flowB", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowB","valueB_1"); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow_A"); client.submit(button3); @@ -1478,15 +1479,15 @@ public void testFlowA_1() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowA", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowB")); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowB")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowA","valueA_2"); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow_B"); client.submit(button4); @@ -1494,15 +1495,15 @@ public void testFlowA_1() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowB", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA")); + assertNotNull(currentFlow); + assertEquals("flowB", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowB","valueB_2"); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow"); client.submit(button5); @@ -1510,9 +1511,9 @@ public void testFlowA_1() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowA", currentFlow.getId()); - Assertions.assertEquals("valueA_2", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); + assertEquals("valueA_2", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); renderResponse(); @@ -1522,9 +1523,9 @@ public void testFlowA_1() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowB", currentFlow.getId()); - Assertions.assertEquals("valueB_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowB")); + assertNotNull(currentFlow); + assertEquals("flowB", currentFlow.getId()); + assertEquals("valueB_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowB")); renderResponse(); @@ -1534,15 +1535,15 @@ public void testFlowA_1() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowA", currentFlow.getId()); - Assertions.assertEquals("valueA_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); + assertEquals("valueA_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); renderResponse(); } - + @Test - public void testFlowA_2() throws Exception + void flowA2() throws Exception { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -1558,11 +1559,11 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowA","valueA_1"); - Assertions.assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flowA"); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); renderResponse(); @@ -1573,9 +1574,9 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); + assertNotNull(currentFlow); // We are still on flowA, just returned to base - Assertions.assertEquals("flowA", currentFlow.getId()); + assertEquals("flowA", currentFlow.getId()); renderResponse(); @@ -1586,11 +1587,11 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowB","valueB_1"); - Assertions.assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals(currentFlow.getId(), "flowB"); + assertNotNull(currentFlow); + assertEquals("flowB", currentFlow.getId()); renderResponse(); @@ -1601,15 +1602,15 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowA", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowB")); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowB")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowA","valueA_2"); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId()); // Call flow B through flow call UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow_B"); @@ -1618,15 +1619,15 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowB", currentFlow.getId()); - Assertions.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA")); + assertNotNull(currentFlow); + assertEquals("flowB", currentFlow.getId()); + assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA")); facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowB","valueB_2"); renderResponse(); //Check current view is the begin of flow2 - Assertions.assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); + assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId()); UICommand button6 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow"); client.submit(button6); @@ -1634,9 +1635,9 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowA", currentFlow.getId()); - Assertions.assertEquals("valueA_2", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); + assertEquals("valueA_2", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); renderResponse(); @@ -1646,9 +1647,9 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowB", currentFlow.getId()); - Assertions.assertEquals("valueB_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowB")); + assertNotNull(currentFlow); + assertEquals("flowB", currentFlow.getId()); + assertEquals("valueB_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowB")); renderResponse(); @@ -1658,9 +1659,9 @@ public void testFlowA_2() throws Exception processLifecycleExecute(); currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext); - Assertions.assertNotNull(currentFlow); - Assertions.assertEquals("flowA", currentFlow.getId()); - Assertions.assertEquals("valueA_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); + assertNotNull(currentFlow); + assertEquals("flowA", currentFlow.getId()); + assertEquals("valueA_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA")); renderResponse(); diff --git a/impl/src/test/java/org/apache/myfaces/application/flow/FlowResourceHandlerMyFacesRequestTestCase.java b/impl/src/test/java/org/apache/myfaces/application/flow/FlowResourceHandlerMyFacesRequestTestCase.java index e7b1c6f7fa..bb8643c30f 100644 --- a/impl/src/test/java/org/apache/myfaces/application/flow/FlowResourceHandlerMyFacesRequestTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/application/flow/FlowResourceHandlerMyFacesRequestTestCase.java @@ -32,7 +32,7 @@ * * @author lu4242 */ -public class FlowResourceHandlerMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase +class FlowResourceHandlerMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase { @Override @@ -45,9 +45,9 @@ protected void setUpWebConfigParams() throws Exception servletContext.addInitParameter("jakarta.faces.CONFIG_FILES", "/WEB-INF/flow1-flow.xml"); servletContext.addInitParameter("jakarta.faces.CLIENT_WINDOW_MODE", "url"); } - + @Test - public void testClassLoaderResourceLoader() + void classLoaderResourceLoader() { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -60,9 +60,9 @@ public void testClassLoaderResourceLoader() //System.out.println(path); } } - + @Test - public void testExternalContextResourceLoader() + void externalContextResourceLoader() { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); @@ -75,9 +75,9 @@ public void testExternalContextResourceLoader() //System.out.println(path); } } - + @Test - public void testGetViewResources() + void getViewResources() { startViewRequest("/flow_base.xhtml"); processLifecycleExecute(); diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/AbstractStateUtilsTest.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/AbstractStateUtilsTest.java index c31b7f24c0..bfd0b0e6cb 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/AbstractStateUtilsTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/AbstractStateUtilsTest.java @@ -24,9 +24,11 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import java.io.Serializable; + +import static org.junit.jupiter.api.Assertions.*; + import java.util.Arrays; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -63,13 +65,13 @@ public void tearDown() throws Exception * Test for Restore View phase. */ @Test - public void testConstructionString() + public void constructionString() { String constructed = StateUtils.construct(sensitiveString, externalContext); Object object = StateUtils.reconstruct(constructed, externalContext); - Assertions.assertTrue(object instanceof String); + assertInstanceOf(String.class, object); String string = (String) object; - Assertions.assertEquals(string, sensitiveString); + assertEquals(string, sensitiveString); } /** @@ -77,65 +79,65 @@ public void testConstructionString() * StateUtilsTestCase through the construct/reconstruct process. */ @Test - public void testConstruction() + public void construction() { String constructed = StateUtils.construct(TEST_DATA, externalContext); Object object = org.apache.myfaces.application.viewstate.StateUtils.reconstruct(constructed, externalContext); - Assertions.assertTrue(TEST_DATA.equals(object)); + assertEquals(TEST_DATA, object); } @Test - public void testSerialization() + public void serialization() { byte[] bytes = StateUtils.getAsByteArray(TEST_DATA, externalContext); Object object = StateUtils.getAsObject(bytes, externalContext); - Assertions.assertTrue(TEST_DATA.equals(object)); + assertEquals(TEST_DATA, object); } @Test - public void testCryptography() + public void cryptography() { byte[] sensitiveBytes = sensitiveString.getBytes(); byte[] secure = StateUtils.encrypt(sensitiveBytes, externalContext); byte[] insecure = StateUtils.decrypt(secure, externalContext); secure = StateUtils.encrypt(insecure, externalContext); // * 2 insecure = StateUtils.decrypt(secure, externalContext); - Assertions.assertTrue(Arrays.equals(insecure, sensitiveBytes)); + assertTrue(Arrays.equals(insecure, sensitiveBytes)); } @Test - public void testCompression() + public void compression() { int size = 2049; byte[] originalBytes = new byte[size]; byte[] lessBytes = StateUtils.compress(originalBytes); - Assertions.assertTrue(lessBytes.length < originalBytes.length); + assertTrue(lessBytes.length < originalBytes.length); byte[] moreBytes = StateUtils.decompress(lessBytes); - Assertions.assertTrue(moreBytes.length > lessBytes.length); - Assertions.assertTrue(Arrays.equals(moreBytes, originalBytes)); + assertTrue(moreBytes.length > lessBytes.length); + assertTrue(Arrays.equals(moreBytes, originalBytes)); } @Test - public void testEncoding() + public void encoding() { byte[] originalBytes = sensitiveString.getBytes(); byte[] encoded = StateUtils.encode(originalBytes); byte[] decoded = StateUtils.decode(encoded); - Assertions.assertTrue(Arrays.equals(decoded, originalBytes)); + assertTrue(Arrays.equals(decoded, originalBytes)); } /** * Simulates testConstruction w/ corrupt data. */ @Test - public void testConstructionNegative() + public void constructionNegative() { String constructed = StateUtils.construct(TEST_DATA, externalContext); constructed = constructed.substring(1); try { Object object = StateUtils.reconstruct(constructed, externalContext); - Assertions.assertFalse(TEST_DATA.equals(object)); + assertNotEquals(TEST_DATA, object); } catch (Exception e) { @@ -147,14 +149,14 @@ public void testConstructionNegative() * Simulates testSerialization w/ corrput data. */ @Test - public void testSerializationNegative() + public void serializationNegative() { byte[] bytes = StateUtils.getAsByteArray(TEST_DATA, externalContext); bytes[1] = (byte) 3; try { Object object = StateUtils.getAsObject(bytes, externalContext); - Assertions.assertFalse(TEST_DATA.equals(object)); + assertNotEquals(TEST_DATA, object); } catch (Exception e) { @@ -167,7 +169,7 @@ public void testSerializationNegative() * Simulates testCryptography w/ corrupt data. */ @Test - public void testCryptographyNegative() + public void cryptographyNegative() { byte[] sensitiveBytes = sensitiveString.getBytes(); byte[] secure = StateUtils.encrypt(sensitiveBytes, externalContext); @@ -176,7 +178,7 @@ public void testCryptographyNegative() try { byte[] insecure = StateUtils.decrypt(secure, externalContext); - Assertions.assertFalse(Arrays.equals(insecure, sensitiveBytes)); + assertFalse(Arrays.equals(insecure, sensitiveBytes)); } catch (Exception e) { @@ -188,7 +190,7 @@ public void testCryptographyNegative() * Simulates testCompression w/ corrupt data. */ @Test - public void testCompressionNegative() + public void compressionNegative() { int size = 2049; byte[] originalBytes = new byte[size]; @@ -197,7 +199,7 @@ public void testCompressionNegative() try { byte[] moreBytes = StateUtils.decompress(lessBytes); - Assertions.assertFalse(Arrays.equals(moreBytes, originalBytes)); + assertFalse(Arrays.equals(moreBytes, originalBytes)); } catch (Exception e) { @@ -209,7 +211,7 @@ public void testCompressionNegative() * Simulates testEncoding w/ corrupt data. */ @Test - public void testEncodingNegative() + public void encodingNegative() { byte[] originalBytes = sensitiveString.getBytes(); byte[] encoded = StateUtils.encode(originalBytes); @@ -217,7 +219,7 @@ public void testEncodingNegative() try { byte[] decoded = StateUtils.decode(encoded); - Assertions.assertFalse(Arrays.equals(decoded, originalBytes)); + assertFalse(Arrays.equals(decoded, originalBytes)); } catch (Exception e) { diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsAES_CBCTest.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsAES_CBCTest.java index 51e2290f78..946e592557 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsAES_CBCTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsAES_CBCTest.java @@ -35,7 +35,7 @@ * @see pom.xml */ -public class CachedStateUtilsAES_CBCTest extends AbstractStateUtilsTest +class CachedStateUtilsAES_CBCTest extends AbstractStateUtilsTest { @Override @BeforeEach diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsBlowfish_ECBTest.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsBlowfish_ECBTest.java index e57eb09791..4f2de3512a 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsBlowfish_ECBTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsBlowfish_ECBTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.BeforeEach; -public class CachedStateUtilsBlowfish_ECBTest extends AbstractStateUtilsTest +class CachedStateUtilsBlowfish_ECBTest extends AbstractStateUtilsTest { @Override @BeforeEach diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsDefaultTest.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsDefaultTest.java index 03726289c3..f1a9c82133 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsDefaultTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsDefaultTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.BeforeEach; -public class CachedStateUtilsDefaultTest extends AbstractStateUtilsTest +class CachedStateUtilsDefaultTest extends AbstractStateUtilsTest { @Override @BeforeEach diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsTripleDES_ECBTest.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsTripleDES_ECBTest.java index 6295900bb1..49f7335644 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsTripleDES_ECBTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/CachedStateUtilsTripleDES_ECBTest.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.BeforeEach; -public class CachedStateUtilsTripleDES_ECBTest extends AbstractStateUtilsTest +class CachedStateUtilsTripleDES_ECBTest extends AbstractStateUtilsTest { @Override @BeforeEach diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/ClientSideStateCacheTest.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/ClientSideStateCacheTest.java index 3564190f51..0ff731ef17 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/ClientSideStateCacheTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/ClientSideStateCacheTest.java @@ -18,24 +18,26 @@ */ package org.apache.myfaces.application.viewstate; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + import jakarta.faces.application.StateManager; import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.test.base.junit.AbstractFacesConfigurableMultipleRequestsTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * * @author lu4242 */ -public class ClientSideStateCacheTest extends AbstractFacesConfigurableMultipleRequestsTestCase +class ClientSideStateCacheTest extends AbstractFacesConfigurableMultipleRequestsTestCase { private static final int TIMESTAMP_PARAM = 2; - + @Test - public void testSaveRestoreState() throws Exception + void saveRestoreState() throws Exception { servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.StateSavingMethod.CLIENT.name()); @@ -66,7 +68,7 @@ public void testSaveRestoreState() throws Exception Object value = stateCache.restoreSerializedView(facesContext, "view1.xhtml", savedToken); - Assertions.assertEquals(1, value); + assertEquals(1, value); facesContext.getViewRoot().setViewId("view2.xhtml"); savedToken = stateCache.saveSerializedView(facesContext, 2); @@ -82,7 +84,7 @@ public void testSaveRestoreState() throws Exception Object value = stateCache.restoreSerializedView(facesContext, "view2.xhtml", savedToken); - Assertions.assertEquals(2, value); + assertEquals(2, value); facesContext.getViewRoot().setViewId("view2.xhtml"); savedToken = stateCache.saveSerializedView(facesContext, 3); @@ -98,16 +100,16 @@ public void testSaveRestoreState() throws Exception Object value = stateCache.restoreSerializedView(facesContext, "view1.xhtml", firstSavedToken); - Assertions.assertEquals(1, value); + assertEquals(1, value); } finally { tearDownRequest(); } } - + @Test - public void testSaveRestoreStateWrongViewId() throws Exception + void saveRestoreStateWrongViewId() throws Exception { servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.StateSavingMethod.CLIENT.name()); @@ -142,7 +144,7 @@ public void testSaveRestoreStateWrongViewId() throws Exception // as parameter. Object value = stateCache.restoreSerializedView(facesContext, "/view2.xhtml", firstSavedToken); - Assertions.assertNull(value); + assertNull(value); } finally { @@ -156,7 +158,7 @@ public void testSaveRestoreStateWrongViewId() throws Exception // It should restore this: Object value = stateCache.restoreSerializedView(facesContext, "/view1.xhtml", firstSavedToken); - Assertions.assertEquals(1, value); + assertEquals(1, value); } finally { @@ -166,7 +168,7 @@ public void testSaveRestoreStateWrongViewId() throws Exception } @Test - public void testSaveRestoreStateClientTimeout() throws Exception + void saveRestoreStateClientTimeout() throws Exception { servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.StateSavingMethod.CLIENT.name()); servletContext.addInitParameter(MyfacesConfig.CLIENT_VIEW_STATE_TIMEOUT, "2"); @@ -203,7 +205,7 @@ public void testSaveRestoreStateClientTimeout() throws Exception // It should return null, because the timeStamp was changed to a previous date Object value = stateCache.restoreSerializedView(facesContext, "/view1.xhtml", firstSavedToken); - Assertions.assertNull(value); + assertNull(value); } finally { diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/InitVector_CBCTestCase.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/InitVector_CBCTestCase.java index 87298dcab7..a38c281dc8 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/InitVector_CBCTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/InitVector_CBCTestCase.java @@ -20,11 +20,12 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import jakarta.faces.FacesException; -import org.junit.jupiter.api.Assertions; + +import static org.junit.jupiter.api.Assertions.fail; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class InitVector_CBCTestCase extends AbstractFacesTestCase +class InitVector_CBCTestCase extends AbstractFacesTestCase { @Override @BeforeEach @@ -43,7 +44,7 @@ public void setUp() throws Exception } @Test - public void testDecryption() + void decryption() { byte[] sensitiveBytes = "bound to fail".getBytes(); @@ -51,7 +52,7 @@ public void testDecryption() StateUtils.decrypt(sensitiveBytes, externalContext); - Assertions.fail("MyFaces should throw a meaningful " + + fail("MyFaces should throw a meaningful " + "exception when users opt for CBC mode " + "encryption w/out an initialization vector."); @@ -59,9 +60,9 @@ public void testDecryption() } } - + @Test - public void testEncryption() { + void encryption() { byte[] sensitiveBytes = "bound to fail".getBytes(); @@ -69,7 +70,7 @@ public void testEncryption() { StateUtils.encrypt(sensitiveBytes, externalContext); - Assertions.fail("MyFaces should throw a meaningful " + + fail("MyFaces should throw a meaningful " + "exception when users opt for CBC mode " + "encryption w/out an initialization vector."); diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/SecretKeyCacheTest.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/SecretKeyCacheTest.java index 95d3faac82..599dcdba15 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/SecretKeyCacheTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/SecretKeyCacheTest.java @@ -20,11 +20,13 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import javax.crypto.SecretKey; -import org.junit.jupiter.api.Assertions; + +import static org.junit.jupiter.api.Assertions.*; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class SecretKeyCacheTest extends AbstractFacesTestCase +class SecretKeyCacheTest extends AbstractFacesTestCase { @Override @BeforeEach @@ -38,19 +40,18 @@ public void setUp() throws Exception } @Test - public void testDefaultAlgorithmUse(){ + void defaultAlgorithmUse(){ StateUtils.initSecret(servletContext); SecretKey secretKey = (SecretKey) servletContext.getAttribute(StateUtils.INIT_SECRET_KEY_CACHE); - - Assertions.assertTrue(StateUtils.DEFAULT_ALGORITHM.equals(secretKey.getAlgorithm()), - "Making sure MyFaces uses the default algorithm when one is not specified"); + + assertEquals(StateUtils.DEFAULT_ALGORITHM, secretKey.getAlgorithm(), "Making sure MyFaces uses the default algorithm when one is not specified"); } - + @Test - public void testInitFacesWithoutCache(){ + void initFacesWithoutCache(){ servletContext.addInitParameter(StateUtils.INIT_SECRET_KEY_CACHE, "false"); @@ -58,20 +59,20 @@ public void testInitFacesWithoutCache(){ Object object = servletContext.getAttribute(StateUtils.INIT_SECRET_KEY_CACHE); - Assertions.assertNull(object, "Making sure StateUtils.initSecret does not create a SecretKey"); + assertNull(object, "Making sure StateUtils.initSecret does not create a SecretKey"); } - + @Test - public void testInitFacesWithCache(){ + void initFacesWithCache(){ StateUtils.initSecret(servletContext); Object object = servletContext.getAttribute(StateUtils.INIT_SECRET_KEY_CACHE); - - Assertions.assertFalse(object == null, "Making sure StateUtils.initSecret() puts an object in application scope"); - - Assertions.assertTrue(object instanceof SecretKey, "Making sure StateUtils.initSecret() is creating a SecretKey"); + + assertNotNull(object, "Making sure StateUtils.initSecret() puts an object in application scope"); + + assertInstanceOf(SecretKey.class, object, "Making sure StateUtils.initSecret() is creating a SecretKey"); } diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/SecretKeyConfigurationTest.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/SecretKeyConfigurationTest.java index 98240bd7a1..7bc2793a77 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/SecretKeyConfigurationTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/SecretKeyConfigurationTest.java @@ -15,13 +15,15 @@ */ package org.apache.myfaces.application.viewstate; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; + import jakarta.faces.FacesException; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class SecretKeyConfigurationTest extends AbstractFacesTestCase +class SecretKeyConfigurationTest extends AbstractFacesTestCase { @Override @BeforeEach @@ -34,49 +36,48 @@ public void setUp() throws Exception } @Test - public void testMissingSecretKeyEncrypt(){ + void missingSecretKeyEncrypt(){ try{ StateUtils.encrypt("serialized objects".getBytes(), externalContext); - Assertions.fail("An exception should be thrown if there" + + fail("An exception should be thrown if there" + " is no SecretKey in application scope and caching is enabled "); }catch(Exception e){ } } - + @Test - public void testNonSecretKeyEncrypt(){ + void nonSecretKeyEncrypt(){ servletContext.setAttribute(StateUtils.INIT_SECRET_KEY_CACHE, new Integer(8)); try{ StateUtils.encrypt("serialized objects".getBytes(), externalContext); - Assertions.fail("An exception should be thrown if there" + + fail("An exception should be thrown if there" + " is no SecretKey in application scope and caching is enabled "); }catch(Exception cce){ } } - + @Test - public void testMissingSecretKeyDecrypt(){ + void missingSecretKeyDecrypt(){ - Assertions.assertThrows(FacesException.class, () -> { - StateUtils.decrypt("serialized objects".getBytes(), externalContext); - }); + assertThrows(FacesException.class, () -> + StateUtils.decrypt("serialized objects".getBytes(), externalContext)); } - + @Test - public void testNonSecretKeyDecrypt(){ + void nonSecretKeyDecrypt(){ servletContext.setAttribute(StateUtils.INIT_SECRET_KEY_CACHE, new Integer(8)); try{ StateUtils.decrypt("serialized objects".getBytes(), externalContext); - Assertions.fail("An exception should be thrown if there" + + fail("An exception should be thrown if there" + " is no SecretKey in application scope and caching is enabled "); }catch(Exception cce){ } diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/SerializedViewCollectionTestCase.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/SerializedViewCollectionTestCase.java index 76cc920788..80a185f212 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/SerializedViewCollectionTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/SerializedViewCollectionTestCase.java @@ -16,21 +16,22 @@ package org.apache.myfaces.application.viewstate; +import static org.junit.jupiter.api.Assertions.*; + import java.util.concurrent.atomic.AtomicInteger; import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * */ -public class SerializedViewCollectionTestCase extends AbstractFacesTestCase +class SerializedViewCollectionTestCase extends AbstractFacesTestCase { - + @Test - public void testSerializedViewCollection1() + void serializedViewCollection1() { servletContext.addInitParameter(MyfacesConfig.NUMBER_OF_VIEWS_IN_SESSION, "1"); @@ -42,16 +43,16 @@ public void testSerializedViewCollection1() AtomicInteger destroyed = new AtomicInteger(); collection.put(facesContext, new Object[]{null,null,2}, key1, null, "1", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key1)); collection.put(facesContext, new Object[]{null,null,2}, key2, null, "2", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key2)); - Assertions.assertNull(collection.get(key1)); - Assertions.assertEquals(destroyed.get(), 1); + assertNotNull(collection.get(key2)); + assertNull(collection.get(key1)); + assertEquals(1, destroyed.get()); } - + @Test - public void testSerializedViewCollection2() + void serializedViewCollection2() { servletContext.addInitParameter(MyfacesConfig.NUMBER_OF_VIEWS_IN_SESSION, "2"); servletContext.addInitParameter(MyfacesConfig.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION, "1"); @@ -65,20 +66,20 @@ public void testSerializedViewCollection2() AtomicInteger destroyed = new AtomicInteger(); collection.put(facesContext, new Object[]{null,null,2}, key1, null, "1", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key1)); collection.put(facesContext, new Object[]{null,null,2}, key3, null, "3", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); - Assertions.assertNotNull(collection.get(key3)); + assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key3)); collection.put(facesContext, new Object[]{null,null,2}, key2, key1, "2", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key2)); - Assertions.assertNotNull(collection.get(key3)); - Assertions.assertNull(collection.get(key1)); - Assertions.assertEquals(destroyed.get(), 1); + assertNotNull(collection.get(key2)); + assertNotNull(collection.get(key3)); + assertNull(collection.get(key1)); + assertEquals(1, destroyed.get()); - } - + } + @Test - public void testSerializedViewCollection3() + void serializedViewCollection3() { servletContext.addInitParameter(MyfacesConfig.NUMBER_OF_VIEWS_IN_SESSION, "1"); @@ -91,21 +92,21 @@ public void testSerializedViewCollection3() AtomicInteger destroyed = new AtomicInteger(); collection.put(facesContext, new Object[]{null,null,2}, key1, null, "1", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key1)); collection.put(facesContext, new Object[]{null,null,2}, key2, null, "1", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key2)); - Assertions.assertNull(collection.get(key1)); + assertNotNull(collection.get(key2)); + assertNull(collection.get(key1)); // Destroy should not happen, because there is still one view holding the viewScopeId. - Assertions.assertEquals(destroyed.get(), 0); + assertEquals(0, destroyed.get()); collection.put(facesContext, new Object[]{null,null,2}, key3, null, "2", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key3)); - Assertions.assertNull(collection.get(key2)); + assertNotNull(collection.get(key3)); + assertNull(collection.get(key2)); // Now it should be destroyed the view 1 - Assertions.assertEquals(destroyed.get(), 1); + assertEquals(1, destroyed.get()); } - + @Test - public void testSerializedViewCollection4() + void serializedViewCollection4() { servletContext.addInitParameter(MyfacesConfig.NUMBER_OF_VIEWS_IN_SESSION, "2"); servletContext.addInitParameter(MyfacesConfig.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION, "1"); @@ -119,20 +120,20 @@ public void testSerializedViewCollection4() AtomicInteger destroyed = new AtomicInteger(); collection.put(facesContext, new Object[]{null,null,2}, key1, null, "1", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key1)); collection.put(facesContext, new Object[]{null,null,2}, key3, null, "3", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); - Assertions.assertNotNull(collection.get(key3)); + assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key3)); collection.put(facesContext, new Object[]{null,null,2}, key2, key1, "1", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key2)); - Assertions.assertNotNull(collection.get(key3)); - Assertions.assertNull(collection.get(key1)); - Assertions.assertEquals(destroyed.get(), 0); + assertNotNull(collection.get(key2)); + assertNotNull(collection.get(key3)); + assertNull(collection.get(key1)); + assertEquals(0, destroyed.get()); - } - + } + @Test - public void testSerializedViewCollection5() + void serializedViewCollection5() { servletContext.addInitParameter(MyfacesConfig.NUMBER_OF_VIEWS_IN_SESSION, "3"); servletContext.addInitParameter(MyfacesConfig.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION, "1"); @@ -147,33 +148,33 @@ public void testSerializedViewCollection5() AtomicInteger destroyed = new AtomicInteger(); collection.put(facesContext, new Object[]{null,null,2}, key1, null, "1", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key1)); collection.put(facesContext, new Object[]{null,null,2}, key2, null, "2", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); - Assertions.assertNotNull(collection.get(key2)); + assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key2)); collection.put(facesContext, new Object[]{null,null,2}, key3, null, "3", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); - Assertions.assertNotNull(collection.get(key2)); - Assertions.assertNotNull(collection.get(key3)); + assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key2)); + assertNotNull(collection.get(key3)); collection.put(facesContext, new Object[]{null,null,2}, key1, null, "1", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); - Assertions.assertNotNull(collection.get(key2)); - Assertions.assertNotNull(collection.get(key3)); + assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key2)); + assertNotNull(collection.get(key3)); // The are 3 slots, and when enters key4 the algorithm should not discard the most // recently used, so key1 and key3 should be preserved and key2 discarded. collection.put(facesContext, new Object[]{null,null,2}, key4, null, "4", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); - Assertions.assertNull(collection.get(key2)); - Assertions.assertNotNull(collection.get(key3)); - Assertions.assertNotNull(collection.get(key4)); - + assertNotNull(collection.get(key1)); + assertNull(collection.get(key2)); + assertNotNull(collection.get(key3)); + assertNotNull(collection.get(key4)); + - Assertions.assertEquals(destroyed.get(), 1); + assertEquals(1, destroyed.get()); } - + @Test - public void testSerializedViewCollection6() + void serializedViewCollection6() { servletContext.addInitParameter(MyfacesConfig.NUMBER_OF_VIEWS_IN_SESSION, "4"); servletContext.addInitParameter(MyfacesConfig.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION, "2"); @@ -193,77 +194,77 @@ public void testSerializedViewCollection6() AtomicInteger destroyed = new AtomicInteger(); collection.put(facesContext, new Object[]{null,null,2}, key1, null, "1", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key1)); collection.put(facesContext, new Object[]{null,null,2}, key2, key1, "2", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); - Assertions.assertNotNull(collection.get(key2)); + assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key2)); collection.put(facesContext, new Object[]{null,null,2}, key3, null, "3", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); - Assertions.assertNotNull(collection.get(key2)); - Assertions.assertNotNull(collection.get(key3)); + assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key2)); + assertNotNull(collection.get(key3)); collection.put(facesContext, new Object[]{null,null,2}, key4, key3, "4", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); - Assertions.assertNotNull(collection.get(key2)); - Assertions.assertNotNull(collection.get(key3)); - Assertions.assertNotNull(collection.get(key4)); + assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key2)); + assertNotNull(collection.get(key3)); + assertNotNull(collection.get(key4)); collection.put(facesContext, new Object[]{null,null,2}, key2, null, "2", (id) -> destroyed.incrementAndGet()); - Assertions.assertNotNull(collection.get(key1)); - Assertions.assertNotNull(collection.get(key2)); - Assertions.assertNotNull(collection.get(key3)); - Assertions.assertNotNull(collection.get(key4)); + assertNotNull(collection.get(key1)); + assertNotNull(collection.get(key2)); + assertNotNull(collection.get(key3)); + assertNotNull(collection.get(key4)); // The collection is full, but under a new key should remove key1 collection.put(facesContext, new Object[]{null,null,2}, key5, null, "5", (id) -> destroyed.incrementAndGet()); - Assertions.assertNull(collection.get(key1)); - Assertions.assertNotNull(collection.get(key2)); - Assertions.assertNotNull(collection.get(key3)); - Assertions.assertNotNull(collection.get(key4)); - Assertions.assertNotNull(collection.get(key5)); + assertNull(collection.get(key1)); + assertNotNull(collection.get(key2)); + assertNotNull(collection.get(key3)); + assertNotNull(collection.get(key4)); + assertNotNull(collection.get(key5)); // The next oldest is key2, but it was refreshed, so the next one in age is key3 collection.put(facesContext, new Object[]{null,null,2}, key6, null, "6", (id) -> destroyed.incrementAndGet()); - Assertions.assertNull(collection.get(key1)); - Assertions.assertNotNull(collection.get(key2)); - Assertions.assertNull(collection.get(key3)); - Assertions.assertNotNull(collection.get(key4)); - Assertions.assertNotNull(collection.get(key5)); - Assertions.assertNotNull(collection.get(key6)); + assertNull(collection.get(key1)); + assertNotNull(collection.get(key2)); + assertNull(collection.get(key3)); + assertNotNull(collection.get(key4)); + assertNotNull(collection.get(key5)); + assertNotNull(collection.get(key6)); // There is a sequential view for key6, destroy the oldest one, which is key4 collection.put(facesContext, new Object[]{null,null,2}, key7, key6, "7", (id) -> destroyed.incrementAndGet()); - Assertions.assertNull(collection.get(key1)); - Assertions.assertNotNull(collection.get(key2)); - Assertions.assertNull(collection.get(key3)); - Assertions.assertNull(collection.get(key4)); - Assertions.assertNotNull(collection.get(key5)); - Assertions.assertNotNull(collection.get(key6)); - Assertions.assertNotNull(collection.get(key7)); + assertNull(collection.get(key1)); + assertNotNull(collection.get(key2)); + assertNull(collection.get(key3)); + assertNull(collection.get(key4)); + assertNotNull(collection.get(key5)); + assertNotNull(collection.get(key6)); + assertNotNull(collection.get(key7)); // Since org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION is 2, and we have // the sequence [key6, key7, key8] , the one to destroy is key6. collection.put(facesContext, new Object[]{null,null,2}, key8, key7, "8", (id) -> destroyed.incrementAndGet()); - Assertions.assertNull(collection.get(key1)); - Assertions.assertNotNull(collection.get(key2)); - Assertions.assertNull(collection.get(key3)); - Assertions.assertNull(collection.get(key4)); - Assertions.assertNotNull(collection.get(key5)); - Assertions.assertNull(collection.get(key6)); - Assertions.assertNotNull(collection.get(key7)); - Assertions.assertNotNull(collection.get(key8)); + assertNull(collection.get(key1)); + assertNotNull(collection.get(key2)); + assertNull(collection.get(key3)); + assertNull(collection.get(key4)); + assertNotNull(collection.get(key5)); + assertNull(collection.get(key6)); + assertNotNull(collection.get(key7)); + assertNotNull(collection.get(key8)); // This is a sequence [key2, key9], but the oldest one is key2, so in this case // key2 should be removed. collection.put(facesContext, new Object[]{null,null,2}, key9, key2, "9", (id) -> destroyed.incrementAndGet()); - Assertions.assertNull(collection.get(key1)); - Assertions.assertNull(collection.get(key2)); - Assertions.assertNull(collection.get(key3)); - Assertions.assertNull(collection.get(key4)); - Assertions.assertNotNull(collection.get(key5)); - Assertions.assertNull(collection.get(key6)); - Assertions.assertNotNull(collection.get(key7)); - Assertions.assertNotNull(collection.get(key8)); - Assertions.assertNotNull(collection.get(key9)); - - Assertions.assertEquals(destroyed.get(), 5); + assertNull(collection.get(key1)); + assertNull(collection.get(key2)); + assertNull(collection.get(key3)); + assertNull(collection.get(key4)); + assertNotNull(collection.get(key5)); + assertNull(collection.get(key6)); + assertNotNull(collection.get(key7)); + assertNotNull(collection.get(key8)); + assertNotNull(collection.get(key9)); + + assertEquals(5, destroyed.get()); } } diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheTest.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheTest.java index 34d3c8552c..4d7e928663 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheTest.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.application.viewstate; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; @@ -27,14 +30,13 @@ import jakarta.faces.application.StateManager; import org.apache.myfaces.test.base.junit.AbstractFacesConfigurableMultipleRequestsTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class ServerSideStateCacheTest extends AbstractFacesConfigurableMultipleRequestsTestCase { @Test - public void testNumberOfSequentialViewsInSession() throws Exception + void numberOfSequentialViewsInSession() throws Exception { servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.StateSavingMethod.SERVER.name()); servletContext.addInitParameter("org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION", "5"); @@ -68,7 +70,7 @@ public void testNumberOfSequentialViewsInSession() throws Exception Object value = stateCache.restoreSerializedView(facesContext, "view1.xhtml", savedToken); - Assertions.assertEquals(1, value); + assertEquals(1, value); facesContext.getViewRoot().setViewId("view2.xhtml"); savedToken = stateCache.saveSerializedView(facesContext, 2); @@ -84,7 +86,7 @@ public void testNumberOfSequentialViewsInSession() throws Exception Object value = stateCache.restoreSerializedView(facesContext, "view2.xhtml", savedToken); - Assertions.assertEquals(2, value); + assertEquals(2, value); facesContext.getViewRoot().setViewId("view2.xhtml"); savedToken = stateCache.saveSerializedView(facesContext, 3); @@ -101,16 +103,16 @@ public void testNumberOfSequentialViewsInSession() throws Exception Object value = stateCache.restoreSerializedView(facesContext, "view1.xhtml", firstSavedToken); // Since org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION is 2, the first one was already discarded - Assertions.assertNull(value); + assertNull(value); } finally { tearDownRequest(); } } - + @Test - public void testSaveRestoreStateWrongViewId() throws Exception + void saveRestoreStateWrongViewId() throws Exception { servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.StateSavingMethod.SERVER.name()); @@ -145,7 +147,7 @@ public void testSaveRestoreStateWrongViewId() throws Exception // the state, along with a counter. Object value = stateCache.restoreSerializedView(facesContext, "/view2.xhtml", firstSavedToken); - Assertions.assertNull(value); + assertNull(value); } finally { @@ -159,7 +161,7 @@ public void testSaveRestoreStateWrongViewId() throws Exception // It should restore this: Object value = stateCache.restoreSerializedView(facesContext, "/view1.xhtml", firstSavedToken); - Assertions.assertEquals(1, value); + assertEquals(1, value); } finally { @@ -169,7 +171,7 @@ public void testSaveRestoreStateWrongViewId() throws Exception } @Test - public void testNonExistingViewId() throws Exception + void nonExistingViewId() throws Exception { servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.StateSavingMethod.SERVER.name()); servletContext.addInitParameter("org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION", "5"); @@ -233,7 +235,7 @@ public void tryStateKeySerialization() throws Exception } @Test - public void testStateKeySerialization1() throws Exception + void stateKeySerialization1() throws Exception { servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.StateSavingMethod.SERVER.name()); servletContext.addInitParameter("org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION", "5"); @@ -242,9 +244,9 @@ public void testStateKeySerialization1() throws Exception tryStateKeySerialization(); } - + @Test - public void testStateKeySerialization2() throws Exception + void stateKeySerialization2() throws Exception { servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.StateSavingMethod.SERVER.name()); servletContext.addInitParameter("org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION", "5"); @@ -254,9 +256,9 @@ public void testStateKeySerialization2() throws Exception tryStateKeySerialization(); } - + @Test - public void testStateKeySerialization3() throws Exception + void stateKeySerialization3() throws Exception { servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.StateSavingMethod.SERVER.name()); servletContext.addInitParameter("org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION", "5"); diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsAES_CBCTest.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsAES_CBCTest.java index 3ff5136eab..dbc3a43b6b 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsAES_CBCTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsAES_CBCTest.java @@ -30,7 +30,7 @@ * @see pom.xml */ -public class StateUtilsAES_CBCTest extends AbstractStateUtilsTest +class StateUtilsAES_CBCTest extends AbstractStateUtilsTest { @Override @BeforeEach diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsBlowfish_ECBTest.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsBlowfish_ECBTest.java index b8fc167c3b..46d0b26c07 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsBlowfish_ECBTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsBlowfish_ECBTest.java @@ -28,7 +28,7 @@ *

*/ -public class StateUtilsBlowfish_ECBTest extends AbstractStateUtilsTest +class StateUtilsBlowfish_ECBTest extends AbstractStateUtilsTest { @Override @BeforeEach diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsDefaultTest.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsDefaultTest.java index 5c4a0fe0ff..cbb03f72e7 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsDefaultTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsDefaultTest.java @@ -22,7 +22,7 @@ * StateUtils. */ -public class StateUtilsDefaultTest extends AbstractStateUtilsTest +class StateUtilsDefaultTest extends AbstractStateUtilsTest { @Override @BeforeEach diff --git a/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsTripleDES_ECBTest.java b/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsTripleDES_ECBTest.java index 89860a1fac..c42c61ad0b 100644 --- a/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsTripleDES_ECBTest.java +++ b/impl/src/test/java/org/apache/myfaces/application/viewstate/StateUtilsTripleDES_ECBTest.java @@ -28,7 +28,7 @@ *

*/ -public class StateUtilsTripleDES_ECBTest extends AbstractStateUtilsTest +class StateUtilsTripleDES_ECBTest extends AbstractStateUtilsTest { @Override @BeforeEach diff --git a/impl/src/test/java/org/apache/myfaces/cdi/bean/CDIGenericConverterValidatorTest.java b/impl/src/test/java/org/apache/myfaces/cdi/bean/CDIGenericConverterValidatorTest.java index b2ddb30d08..1417632713 100644 --- a/impl/src/test/java/org/apache/myfaces/cdi/bean/CDIGenericConverterValidatorTest.java +++ b/impl/src/test/java/org/apache/myfaces/cdi/bean/CDIGenericConverterValidatorTest.java @@ -19,6 +19,9 @@ package org.apache.myfaces.cdi.bean; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import jakarta.el.ExpressionFactory; import jakarta.faces.component.UIInput; import jakarta.faces.component.UIOutput; @@ -26,16 +29,15 @@ import jakarta.faces.validator.ValidatorException; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * Unit tests to ensure that Generics work with CDI Converters and Validators */ -public class CDIGenericConverterValidatorTest extends AbstractMyFacesCDIRequestTestCase { +class CDIGenericConverterValidatorTest extends AbstractMyFacesCDIRequestTestCase { @Test - public void testConverter() throws Exception { + void converter() throws Exception { String expectedValue = "zero"; String result = ""; @@ -50,13 +52,12 @@ public void testConverter() throws Exception { result = converter.getAsString(facesContext, out, bean); - Assertions.assertTrue(result.equals(expectedValue), - "The value output should have matched: " + expectedValue + " but was : " + result); + assertEquals(result, expectedValue, "The value output should have matched: " + expectedValue + " but was : " + result); } @Test - public void testValidator() throws Exception { + void validator() throws Exception { startViewRequest("/CDIGenericValidatorTest.xhtml"); application.addValidator("customValidator", "org.apache.myfaces.cdi.bean.CustomValidator"); @@ -68,7 +69,7 @@ public void testValidator() throws Exception { //Expects a ValidatorException try { out.getValidators()[0].validate(facesContext, out, r); - Assertions.fail("ValidatorException was not thrown. Custom Generic validator failed."); + fail("ValidatorException was not thrown. Custom Generic validator failed."); } catch (ValidatorException e) { //Ignored } diff --git a/impl/src/test/java/org/apache/myfaces/cdi/bean/DynamicManagedPropertyProducerTest.java b/impl/src/test/java/org/apache/myfaces/cdi/bean/DynamicManagedPropertyProducerTest.java index 17fbee7051..ee60de3012 100644 --- a/impl/src/test/java/org/apache/myfaces/cdi/bean/DynamicManagedPropertyProducerTest.java +++ b/impl/src/test/java/org/apache/myfaces/cdi/bean/DynamicManagedPropertyProducerTest.java @@ -19,20 +19,21 @@ package org.apache.myfaces.cdi.bean; +import static org.junit.jupiter.api.Assertions.assertEquals; + import jakarta.el.ExpressionFactory; import jakarta.faces.component.UIOutput; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * A unit test to test the CDI @ManagedProperty */ -public class DynamicManagedPropertyProducerTest extends AbstractMyFacesCDIRequestTestCase +class DynamicManagedPropertyProducerTest extends AbstractMyFacesCDIRequestTestCase { @Test - public void testCDIManagedProperty() throws Exception { + void cdiManagedProperty() throws Exception { String expectedValue = "numberManagedProperty=0textManagedProperty=zerolistManagedProperty" + "=zerostringArrayManagedProperty=zerobean=org.apache.myfaces.cdi.bean.TestBean"; String result; @@ -46,8 +47,7 @@ public void testCDIManagedProperty() throws Exception { result = result.substring(0, result.indexOf('@')); result = result.replaceAll("\\s",""); - Assertions.assertTrue(result.equals(expectedValue), - "The value output should have matched: " + expectedValue + " but was : " + result); + assertEquals(result, expectedValue, "The value output should have matched: " + expectedValue + " but was : " + result); } @Override diff --git a/impl/src/test/java/org/apache/myfaces/cdi/view/ViewScopeCDIMapTest.java b/impl/src/test/java/org/apache/myfaces/cdi/view/ViewScopeCDIMapTest.java index 7fc2487c7b..721697ca2f 100644 --- a/impl/src/test/java/org/apache/myfaces/cdi/view/ViewScopeCDIMapTest.java +++ b/impl/src/test/java/org/apache/myfaces/cdi/view/ViewScopeCDIMapTest.java @@ -18,26 +18,27 @@ */ package org.apache.myfaces.cdi.view; +import static org.junit.jupiter.api.Assertions.*; + import java.util.Map; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.view.ViewScopeProxyMap; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class ViewScopeCDIMapTest extends AbstractMyFacesCDIRequestTestCase +class ViewScopeCDIMapTest extends AbstractMyFacesCDIRequestTestCase { @Test - public void testPutReturnsPreviousValue() throws Exception + void putReturnsPreviousValue() throws Exception { startViewRequest("/viewScopeCDIMap.xhtml"); processLifecycleExecuteAndRender(); Map viewMap = facesContext.getViewRoot().getViewMap(); - Assertions.assertInstanceOf(ViewScopeCDIMap.class, ((ViewScopeProxyMap) viewMap).getDelegate()); + assertInstanceOf(ViewScopeCDIMap.class, ((ViewScopeProxyMap) viewMap).getDelegate()); - Assertions.assertNull(viewMap.put("key", "first")); - Assertions.assertEquals("first", viewMap.put("key", "second")); - Assertions.assertEquals("second", viewMap.get("key")); + assertNull(viewMap.put("key", "first")); + assertEquals("first", viewMap.put("key", "second")); + assertEquals("second", viewMap.get("key")); } } diff --git a/impl/src/test/java/org/apache/myfaces/component/search/SearchExpressionImplTest.java b/impl/src/test/java/org/apache/myfaces/component/search/SearchExpressionImplTest.java index ae956a87e1..8120cc604b 100644 --- a/impl/src/test/java/org/apache/myfaces/component/search/SearchExpressionImplTest.java +++ b/impl/src/test/java/org/apache/myfaces/component/search/SearchExpressionImplTest.java @@ -19,6 +19,8 @@ package org.apache.myfaces.component.search; +import static org.junit.jupiter.api.Assertions.*; + import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -34,13 +36,12 @@ import jakarta.faces.component.search.SearchExpressionHint; import jakarta.faces.context.FacesContext; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * */ -public class SearchExpressionImplTest extends AbstractMyFacesCDIRequestTestCase +class SearchExpressionImplTest extends AbstractMyFacesCDIRequestTestCase { @Override protected void setUpWebConfigParams() throws Exception @@ -51,7 +52,7 @@ protected void setUpWebConfigParams() throws Exception } @Test - public void testSearchExpression1() throws Exception + void searchExpression1() throws Exception { startViewRequest("/search1.xhtml"); processLifecycleExecute(); @@ -70,60 +71,58 @@ public void testSearchExpression1() throws Exception //System.out.println(clientId); found = true; } - Assertions.assertTrue(found); + assertTrue(found); String componentId = facesContext.getApplication().getSearchExpressionHandler().resolveClientIds( searchContext, "@this").get(0); - Assertions.assertEquals("mainForm:showName", componentId); + assertEquals("mainForm:showName", componentId); componentId = facesContext.getApplication().getSearchExpressionHandler().resolveClientIds( searchContext, "@this:@parent:showName").get(0); - Assertions.assertEquals("mainForm:showName", componentId); + assertEquals("mainForm:showName", componentId); componentId = facesContext.getApplication().getSearchExpressionHandler().resolveClientIds( searchContext, "@form:inputOutsideForm").get(0); - Assertions.assertEquals("mainForm:inputOutsideForm", componentId); + assertEquals("mainForm:inputOutsideForm", componentId); final SearchExpressionContext currentSearchContext = searchContext; - Assertions.assertThrows(ComponentNotFoundException.class, () -> - { - facesContext.getApplication().getSearchExpressionHandler().resolveClientIds(currentSearchContext, ":inputOutsideForm"); - }); + assertThrows(ComponentNotFoundException.class, () -> + facesContext.getApplication().getSearchExpressionHandler().resolveClientIds(currentSearchContext, ":inputOutsideForm")); componentId = facesContext.getApplication().getSearchExpressionHandler().resolveClientIds( searchContext, "mainForm:table:0:baseText").get(0); - Assertions.assertEquals("mainForm:table:0:baseText", componentId); + assertEquals("mainForm:table:0:baseText", componentId); componentId = facesContext.getApplication().getSearchExpressionHandler().resolveClientIds( searchContext, "@parent:showName:@parent:showName").get(0); - Assertions.assertEquals("mainForm:showName", componentId); + assertEquals("mainForm:showName", componentId); componentId = facesContext.getApplication().getSearchExpressionHandler().resolveClientIds( searchContext, "@form:showName").get(0); - Assertions.assertEquals("mainForm:showName", componentId); + assertEquals("mainForm:showName", componentId); componentId = facesContext.getApplication().getSearchExpressionHandler().resolveClientIds( searchContext, " @namingcontainer:showName ").get(0); - Assertions.assertEquals("mainForm:showName", componentId); + assertEquals("mainForm:showName", componentId); UIOutput name = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:name"); searchContext = SearchExpressionContext.createSearchExpressionContext(facesContext, name); componentId = facesContext.getApplication().getSearchExpressionHandler().resolveClientIds( searchContext, "@previous").get(0); - Assertions.assertEquals("mainForm:labelName", componentId); + assertEquals("mainForm:labelName", componentId); componentId = facesContext.getApplication().getSearchExpressionHandler().resolveClientIds( searchContext, "@next").get(0); - Assertions.assertEquals("mainForm:msgName", componentId); + assertEquals("mainForm:msgName", componentId); componentId = facesContext.getApplication().getSearchExpressionHandler().resolveClientIds( searchContext, "@parent:@id(msgName)").get(0); - Assertions.assertEquals("mainForm:msgName", componentId); + assertEquals("mainForm:msgName", componentId); componentId = facesContext.getApplication().getSearchExpressionHandler().resolveClientIds( searchContext, "topLevelOutputText").get(0); - Assertions.assertEquals("topLevelOutputText", componentId); + assertEquals("topLevelOutputText", componentId); facesContext.getViewRoot().invokeOnComponent(facesContext, "mainForm:table:3:nested:1:nestedButton", new ContextCallback() @@ -135,25 +134,25 @@ public void invokeContextCallback(FacesContext context, UIComponent target) SearchExpressionContext searchContext = SearchExpressionContext.createSearchExpressionContext(context, target); String componentId = handler.resolveClientIds(searchContext, "mainForm:showName").get(0); - Assertions.assertEquals("mainForm:showName", componentId); + assertEquals("mainForm:showName", componentId); componentId = handler.resolveClientIds(searchContext, "nested:nestedText").get(0); - Assertions.assertEquals("mainForm:table:3:nested:1:nestedText", componentId); + assertEquals("mainForm:table:3:nested:1:nestedText", componentId); componentId = handler.resolveClientIds(searchContext, "table:baseText").get(0); - Assertions.assertEquals("mainForm:table:3:baseText", componentId); + assertEquals("mainForm:table:3:baseText", componentId); componentId = handler.resolveClientIds(searchContext, "table:0:baseText").get(0); - Assertions.assertEquals("mainForm:table:0:baseText", componentId); + assertEquals("mainForm:table:0:baseText", componentId); componentId = handler.resolveClientIds(searchContext, "nested:0:nestedText").get(0); - Assertions.assertEquals("mainForm:table:3:nested:0:nestedText", componentId); + assertEquals("mainForm:table:3:nested:0:nestedText", componentId); componentId = handler.resolveClientIds(searchContext, "table:nested").get(0); - Assertions.assertEquals("mainForm:table:3:nested", componentId); + assertEquals("mainForm:table:3:nested", componentId); componentId = handler.resolveClientIds(searchContext, "table:1:nested:0:nestedText").get(0); - Assertions.assertEquals("mainForm:table:1:nested:0:nestedText", componentId); + assertEquals("mainForm:table:1:nested:0:nestedText", componentId); //System.out.println(componentId); } @@ -168,7 +167,7 @@ public void invokeContextCallback(FacesContext context, UIComponent target) SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler(); SearchExpressionContext searchContext = SearchExpressionContext.createSearchExpressionContext(context, target); - Assertions.assertEquals(handler.resolveClientId(searchContext, "@next"), "mainForm:table:3:nestedText"); + assertEquals("mainForm:table:3:nestedText", handler.resolveClientId(searchContext, "@next")); } }); @@ -176,7 +175,7 @@ public void invokeContextCallback(FacesContext context, UIComponent target) } @Test - public void testSearchExpressionIdKeyword() throws Exception + void searchExpressionIdKeyword() throws Exception { startViewRequest("/search1.xhtml"); processLifecycleExecute(); @@ -188,13 +187,13 @@ public void testSearchExpressionIdKeyword() throws Exception SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler(); - Assertions.assertEquals("panelGridId", handler.resolveClientId(searchContext, "mainForm:@parent")); + assertEquals("panelGridId", handler.resolveClientId(searchContext, "mainForm:@parent")); processRemainingPhases(); } - + @Test - public void testResolveComponent() throws Exception + void resolveComponent() throws Exception { startViewRequest("/search1.xhtml"); processLifecycleExecute(); @@ -208,13 +207,13 @@ public void testResolveComponent() throws Exception facesContext.getApplication().getSearchExpressionHandler().resolveComponent( searchContext, "@id(name)", callback); - Assertions.assertEquals(1, callback.getComponents().size()); + assertEquals(1, callback.getComponents().size()); processRemainingPhases(); } - + @Test - public void testResolveComponents() throws Exception + void resolveComponents() throws Exception { startViewRequest("/search1.xhtml"); processLifecycleExecute(); @@ -228,7 +227,7 @@ public void testResolveComponents() throws Exception facesContext.getApplication().getSearchExpressionHandler().resolveComponents( searchContext, " @id(name) @none ", callback); - Assertions.assertEquals(2, callback.getComponents().size()); + assertEquals(2, callback.getComponents().size()); processRemainingPhases(); } @@ -248,9 +247,9 @@ public ArrayList getComponents() return components; } } - + @Test - public void testResolveClientId1() throws Exception + void resolveClientId1() throws Exception { startViewRequest("/search1.xhtml"); processLifecycleExecute(); @@ -267,7 +266,7 @@ public void testResolveClientId1() throws Exception SearchExpressionContext.createSearchExpressionContext(facesContext, out, expressionHints, null); String clientId = handler.resolveClientId(searchContextWithIgnoreNoResult, "@none"); - Assertions.assertNull(clientId); + assertNull(clientId); SearchExpressionContext searchContext = SearchExpressionContext.createSearchExpressionContext(facesContext, out); @@ -275,16 +274,16 @@ public void testResolveClientId1() throws Exception try { clientId = handler.resolveClientId(searchContext, "@none"); - Assertions.fail(); + fail(); } catch (ComponentNotFoundException e) { //No op } } - + @Test - public void testResolveClientIds1() throws Exception + void resolveClientIds1() throws Exception { startViewRequest("/search1.xhtml"); processLifecycleExecute(); @@ -300,7 +299,7 @@ public void testResolveClientIds1() throws Exception SearchExpressionContext.createSearchExpressionContext(facesContext, out, expressionHints, null); List clientId = handler.resolveClientIds(searchContextWithIgnoreNoResult, "@none"); - Assertions.assertTrue(clientId.isEmpty()); + assertTrue(clientId.isEmpty()); SearchExpressionContext searchContext = SearchExpressionContext.createSearchExpressionContext(facesContext, out); @@ -308,7 +307,7 @@ public void testResolveClientIds1() throws Exception try { clientId = handler.resolveClientIds(searchContext, "@none"); - Assertions.fail(); + fail(); } catch (ComponentNotFoundException e) { @@ -317,7 +316,7 @@ public void testResolveClientIds1() throws Exception } @Test - public void testIsValid() throws Exception + void isValid() throws Exception { startViewRequest("/search1.xhtml"); processLifecycleExecute(); @@ -328,35 +327,35 @@ public void testIsValid() throws Exception SearchExpressionContext.createSearchExpressionContext(facesContext, null); SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler(); - Assertions.assertTrue(handler.isValidExpression(searchContext, "mainForm:showName")); - Assertions.assertTrue(handler.isValidExpression(searchContext, "mainForm:table:3:nested:1:nestedText")); - Assertions.assertTrue(handler.isValidExpression(searchContext, "mainForm:table:3:baseText")); - Assertions.assertTrue(handler.isValidExpression(searchContext, " mainForm:table:0:baseText")); - Assertions.assertTrue(handler.isValidExpression(searchContext, "mainForm:table:3:nested:0:nestedText")); - Assertions.assertTrue(handler.isValidExpression(searchContext, "mainForm:table:3:nested")); - Assertions.assertTrue(handler.isValidExpression(searchContext, "mainForm:table:1:nested:0:nestedText")); - - Assertions.assertTrue(handler.isValidExpression(searchContext, " ")); - Assertions.assertTrue(handler.isValidExpression(searchContext, "@this")); - Assertions.assertTrue(handler.isValidExpression(searchContext, "@this:@parent:showName")); - Assertions.assertTrue(handler.isValidExpression(searchContext, "@parent:showName:@parent:showName ")); - Assertions.assertTrue(handler.isValidExpression(searchContext, "@form:showName")); - Assertions.assertTrue(handler.isValidExpression(searchContext, "@namingcontainer:showName")); - Assertions.assertTrue(handler.isValidExpression(searchContext, "@previous")); - Assertions.assertTrue(handler.isValidExpression(searchContext, "@next")); - Assertions.assertTrue(handler.isValidExpression(searchContext, "@parent:@id(msgName)")); - - Assertions.assertFalse(handler.isValidExpression(searchContext, "@whoNows")); - Assertions.assertFalse(handler.isValidExpression(searchContext, "@parent:@whoNows")); - Assertions.assertFalse(handler.isValidExpression(searchContext, "mainForm:@whoNows")); - Assertions.assertFalse(handler.isValidExpression(searchContext, "!whoNows")); - - Assertions.assertFalse(handler.isValidExpression(searchContext, "@none:@parent")); - Assertions.assertFalse(handler.isValidExpression(searchContext, "@all:@parent")); + assertTrue(handler.isValidExpression(searchContext, "mainForm:showName")); + assertTrue(handler.isValidExpression(searchContext, "mainForm:table:3:nested:1:nestedText")); + assertTrue(handler.isValidExpression(searchContext, "mainForm:table:3:baseText")); + assertTrue(handler.isValidExpression(searchContext, " mainForm:table:0:baseText")); + assertTrue(handler.isValidExpression(searchContext, "mainForm:table:3:nested:0:nestedText")); + assertTrue(handler.isValidExpression(searchContext, "mainForm:table:3:nested")); + assertTrue(handler.isValidExpression(searchContext, "mainForm:table:1:nested:0:nestedText")); + + assertTrue(handler.isValidExpression(searchContext, " ")); + assertTrue(handler.isValidExpression(searchContext, "@this")); + assertTrue(handler.isValidExpression(searchContext, "@this:@parent:showName")); + assertTrue(handler.isValidExpression(searchContext, "@parent:showName:@parent:showName ")); + assertTrue(handler.isValidExpression(searchContext, "@form:showName")); + assertTrue(handler.isValidExpression(searchContext, "@namingcontainer:showName")); + assertTrue(handler.isValidExpression(searchContext, "@previous")); + assertTrue(handler.isValidExpression(searchContext, "@next")); + assertTrue(handler.isValidExpression(searchContext, "@parent:@id(msgName)")); + + assertFalse(handler.isValidExpression(searchContext, "@whoNows")); + assertFalse(handler.isValidExpression(searchContext, "@parent:@whoNows")); + assertFalse(handler.isValidExpression(searchContext, "mainForm:@whoNows")); + assertFalse(handler.isValidExpression(searchContext, "!whoNows")); + + assertFalse(handler.isValidExpression(searchContext, "@none:@parent")); + assertFalse(handler.isValidExpression(searchContext, "@all:@parent")); } - + @Test - public void testIsPassthroughExpression() throws Exception + void isPassthroughExpression() throws Exception { startViewRequest("/search1.xhtml"); processLifecycleExecute(); @@ -367,41 +366,41 @@ public void testIsPassthroughExpression() throws Exception SearchExpressionContext.createSearchExpressionContext(facesContext, null); SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler(); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:showName")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:table:3:nested:1:nestedText")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:table:3:baseText")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:table:0:baseText")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:table:3:nested:0:nestedText")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:table:3:nested")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:table:1:nested:0:nestedText")); - - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "@this")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "@this:@parent:showName")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "@parent:showName:@parent:showName")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "@form")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "@form:showName")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "@namingcontainer:showName")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "@previous")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "@next")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "@parent:@id(msgName)")); - - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "@whoNows")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "@parent:@whoNows")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:@whoNows")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContext, "!whoNows")); + assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:showName")); + assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:table:3:nested:1:nestedText")); + assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:table:3:baseText")); + assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:table:0:baseText")); + assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:table:3:nested:0:nestedText")); + assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:table:3:nested")); + assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:table:1:nested:0:nestedText")); + + assertFalse(handler.isPassthroughExpression(searchContext, "@this")); + assertFalse(handler.isPassthroughExpression(searchContext, "@this:@parent:showName")); + assertFalse(handler.isPassthroughExpression(searchContext, "@parent:showName:@parent:showName")); + assertFalse(handler.isPassthroughExpression(searchContext, "@form")); + assertFalse(handler.isPassthroughExpression(searchContext, "@form:showName")); + assertFalse(handler.isPassthroughExpression(searchContext, "@namingcontainer:showName")); + assertFalse(handler.isPassthroughExpression(searchContext, "@previous")); + assertFalse(handler.isPassthroughExpression(searchContext, "@next")); + assertFalse(handler.isPassthroughExpression(searchContext, "@parent:@id(msgName)")); + + assertFalse(handler.isPassthroughExpression(searchContext, "@whoNows")); + assertFalse(handler.isPassthroughExpression(searchContext, "@parent:@whoNows")); + assertFalse(handler.isPassthroughExpression(searchContext, "mainForm:@whoNows")); + assertFalse(handler.isPassthroughExpression(searchContext, "!whoNows")); Set expressionHints = new HashSet<>(); expressionHints.add(SearchExpressionHint.RESOLVE_CLIENT_SIDE); SearchExpressionContext searchContextWithAjaxResolve = SearchExpressionContext.createSearchExpressionContext(facesContext, null, expressionHints, null); - Assertions.assertTrue(handler.isPassthroughExpression(searchContextWithAjaxResolve, "@form")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContextWithAjaxResolve, "@form:showName")); - Assertions.assertFalse(handler.isPassthroughExpression(searchContextWithAjaxResolve, "@form:@child(0)")); + assertTrue(handler.isPassthroughExpression(searchContextWithAjaxResolve, "@form")); + assertFalse(handler.isPassthroughExpression(searchContextWithAjaxResolve, "@form:showName")); + assertFalse(handler.isPassthroughExpression(searchContextWithAjaxResolve, "@form:@child(0)")); } @Test - public void testMyFaces4695() throws Exception + void myFaces4695() throws Exception { startViewRequest("/search2.xhtml"); processLifecycleExecute(); @@ -413,7 +412,7 @@ public void testMyFaces4695() throws Exception SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler(); - Assertions.assertEquals("form1:one", handler.resolveClientId(searchContext, "form1:one")); + assertEquals("form1:one", handler.resolveClientId(searchContext, "form1:one")); processRemainingPhases(); } @@ -422,7 +421,7 @@ public void testMyFaces4695() throws Exception * Regression test for MYFACES-4764. */ @Test - public void testMyFaces4764() throws Exception + void myFaces4764() throws Exception { startViewRequest("/search_myfaces4764.xhtml"); processLifecycleExecute(); @@ -432,11 +431,11 @@ public void testMyFaces4764() throws Exception SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler(); UIComponent body = facesContext.getViewRoot().findComponent("body"); - Assertions.assertNotNull(body, "body component must exist"); + assertNotNull(body, "body component must exist"); SearchExpressionContext ctx1 = SearchExpressionContext.createSearchExpressionContext(facesContext, body); - Assertions.assertEquals("first", handler.resolveClientId(ctx1, "@child(1)"), + assertEquals("first", handler.resolveClientId(ctx1, "@child(1)"), "@child(1) must resolve to 'first'"); processRemainingPhases(); diff --git a/impl/src/test/java/org/apache/myfaces/component/visit/PartialVisitContextTest.java b/impl/src/test/java/org/apache/myfaces/component/visit/PartialVisitContextTest.java index 573ea2197f..64a63fe552 100644 --- a/impl/src/test/java/org/apache/myfaces/component/visit/PartialVisitContextTest.java +++ b/impl/src/test/java/org/apache/myfaces/component/visit/PartialVisitContextTest.java @@ -28,19 +28,22 @@ import jakarta.faces.component.visit.VisitResult; import jakarta.faces.context.FacesContext; import org.apache.myfaces.test.base.junit.AbstractFacesConfigurableMockTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.util.ArrayList; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Arrays; import java.util.EnumSet; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -public class PartialVisitContextTest extends AbstractFacesConfigurableMockTestCase { +class PartialVisitContextTest extends AbstractFacesConfigurableMockTestCase { @Test - public void test() { + void test() { PartialVisitContext visitContext = new PartialVisitContext(facesContext, Arrays.asList("form", "form:input", "form"), @@ -81,9 +84,9 @@ public VisitResult visit(VisitContext context, UIComponent target) { }); // only the the form is visited and only once, it will itself visit the child input - Assertions.assertEquals(1, visitedComponents.size()); - Assertions.assertTrue(visitedComponents.contains(form)); + assertEquals(1, visitedComponents.size()); + assertTrue(visitedComponents.contains(form)); - Assertions.assertTrue(processValidatorsOfInputInvoked.get()); + assertTrue(processValidatorsOfInputInvoked.get()); } } diff --git a/impl/src/test/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtilsTestCase.java b/impl/src/test/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtilsTestCase.java index 6a75193b10..5e6ae957e1 100644 --- a/impl/src/test/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtilsTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtilsTestCase.java @@ -19,9 +19,10 @@ package org.apache.myfaces.config; +import static org.junit.jupiter.api.Assertions.fail; + import java.net.URL; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; @@ -29,11 +30,11 @@ * * @author lu4242 */ -public class ConfigFilesXmlValidationUtilsTestCase extends AbstractFacesTestCase +class ConfigFilesXmlValidationUtilsTestCase extends AbstractFacesTestCase { @Test - public void testCurrentStandardJSFFacesConfig() throws Exception + void currentStandardJSFFacesConfig() throws Exception { URL url = getClass().getResource("/META-INF/standard-faces-config.xml"); ConfigFilesXmlValidationUtils.validateFacesConfigFile( @@ -41,7 +42,7 @@ public void testCurrentStandardJSFFacesConfig() throws Exception } @Test - public void testJSF11Config1() throws Exception + void jsf11Config1() throws Exception { URL url = getClass().getResource("a-config.xml"); ConfigFilesXmlValidationUtils.validateFacesConfigFile( @@ -49,14 +50,14 @@ public void testJSF11Config1() throws Exception } @Test - public void testJSFInvalidConfig1() throws Exception + void jsfInvalidConfig1() throws Exception { try { URL url = getClass().getResource("invalid-config_1.xml"); ConfigFilesXmlValidationUtils.validateFacesConfigFile( url , externalContext, ConfigFilesXmlValidationUtils.getFacesConfigVersion(url)); - Assertions.fail(); + fail(); } catch (SAXException e) { @@ -67,32 +68,32 @@ public void testJSFInvalidConfig1() throws Exception /* * The four testJSFXXConfig tests below were added under MYFACES-4363 */ - @Test - public void testJSF22Config() throws Exception + @Test + void jsf22Config() throws Exception { URL url = getClass().getResource("jsf22-faces-config.xml"); ConfigFilesXmlValidationUtils.validateFacesConfigFile( url , externalContext, ConfigFilesXmlValidationUtils.getFacesConfigVersion(url)); } - @Test - public void testJSF23Config() throws Exception + @Test + void jsf23Config() throws Exception { URL url = getClass().getResource("jsf23-faces-config.xml"); ConfigFilesXmlValidationUtils.validateFacesConfigFile( url , externalContext, ConfigFilesXmlValidationUtils.getFacesConfigVersion(url)); } - @Test - public void testJSF30Config() throws Exception + @Test + void jsf30Config() throws Exception { URL url = getClass().getResource("jsf30-faces-config.xml"); ConfigFilesXmlValidationUtils.validateFacesConfigFile( url , externalContext, ConfigFilesXmlValidationUtils.getFacesConfigVersion(url)); } - @Test - public void testJSF40Config() throws Exception + @Test + void jsf40Config() throws Exception { URL url = getClass().getResource("jsf40-faces-config.xml"); ConfigFilesXmlValidationUtils.validateFacesConfigFile( diff --git a/impl/src/test/java/org/apache/myfaces/config/FacesConfigValidatorTestCase.java b/impl/src/test/java/org/apache/myfaces/config/FacesConfigValidatorTestCase.java index 8844140a81..4dd1469e67 100644 --- a/impl/src/test/java/org/apache/myfaces/config/FacesConfigValidatorTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/config/FacesConfigValidatorTestCase.java @@ -17,6 +17,8 @@ package org.apache.myfaces.config; +import static org.junit.jupiter.api.Assertions.assertSame; + import java.io.ByteArrayInputStream; import java.util.Collection; import java.util.List; @@ -26,11 +28,10 @@ import org.apache.myfaces.config.impl.FacesConfigUnmarshallerImpl; import org.apache.myfaces.config.impl.element.FacesConfigImpl; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class FacesConfigValidatorTestCase extends AbstractFacesTestCase +class FacesConfigValidatorTestCase extends AbstractFacesTestCase { private FacesConfigDispenser dispenser; private FacesConfigUnmarshaller unmarshaller; @@ -54,15 +55,15 @@ public void setUp() throws Exception } } - + @Test - public void testVerifyExistence(){ + void verifyExistence(){ Collection navRules = dispenser.getNavigationRules(); List list = FacesConfigValidator.validate(navRules, externalContext); - Assertions.assertSame(2, list.size()); + assertSame(2, list.size()); } diff --git a/impl/src/test/java/org/apache/myfaces/config/FacesConfiguratorDefaultValidatorsTestCase.java b/impl/src/test/java/org/apache/myfaces/config/FacesConfiguratorDefaultValidatorsTestCase.java index da87b480f0..85028353a3 100644 --- a/impl/src/test/java/org/apache/myfaces/config/FacesConfiguratorDefaultValidatorsTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/config/FacesConfiguratorDefaultValidatorsTestCase.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.config; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import java.lang.reflect.Field; import java.util.HashMap; @@ -37,7 +40,6 @@ import org.apache.myfaces.util.lang.Lazy; import org.apache.myfaces.view.ViewDeclarationLanguageFactoryImpl; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -132,7 +134,7 @@ private void _setBeanValidationAvailable(boolean available) * In this case the bean validator should be installed as a default validator. */ @Test - public void testDefaultBeanValidatorDisabledButPresentInFacesConfig() + void defaultBeanValidatorDisabledButPresentInFacesConfig() { // remove existing RenderKit installations _cleanRenderKits(); @@ -158,10 +160,10 @@ public void testDefaultBeanValidatorDisabledButPresentInFacesConfig() // the bean validator has to be installed, because // of the entry in default-bean-validator.xml - Assertions.assertTrue(application.getDefaultValidatorInfo() + assertTrue(application.getDefaultValidatorInfo() .containsKey(BeanValidator.VALIDATOR_ID)); } - + /** * Tests the case when bean validation is available, but adding the BeanValidator * as a default validator has been disabled via the config parameter and there @@ -169,7 +171,7 @@ public void testDefaultBeanValidatorDisabledButPresentInFacesConfig() * In this case the BeanValidator mustn't be installed. */ @Test - public void testDefaultBeanValidatorDisabled() + void defaultBeanValidatorDisabled() { // remove existing RenderKit installations _cleanRenderKits(); @@ -192,16 +194,16 @@ public void testDefaultBeanValidatorDisabled() // the bean validator must not be installed, because it // has been disabled and there is no entry in the faces-config // that would install it manually. - Assertions.assertFalse(application.getDefaultValidatorInfo() + assertFalse(application.getDefaultValidatorInfo() .containsKey(BeanValidator.VALIDATOR_ID)); } - + /** * Tests the case that bean validation is not available in the classpath. * In this case the BeanValidator must not be installed. */ @Test - public void testBeanValidationNotAvailable() + void beanValidationNotAvailable() { // remove existing RenderKit installations _cleanRenderKits(); @@ -218,10 +220,10 @@ public void testBeanValidationNotAvailable() // the bean validator mustn't be installed, because // bean validation is not available in the classpath - Assertions.assertFalse(application.getDefaultValidatorInfo() + assertFalse(application.getDefaultValidatorInfo() .containsKey(BeanValidator.VALIDATOR_ID)); } - + /** * Tests the case with two config files. The first one would install the a * default validator (in this case the RequiredValidator), but the second one @@ -231,7 +233,7 @@ public void testBeanValidationNotAvailable() * has to be installed (automatically) since bean validation is available. */ @Test - public void testDefaultValidatorsClearedByLatterConfigFileWithEmptyElement() + void defaultValidatorsClearedByLatterConfigFileWithEmptyElement() { // remove existing RenderKit installations _cleanRenderKits(); @@ -257,12 +259,12 @@ public void testDefaultValidatorsClearedByLatterConfigFileWithEmptyElement() // the required validator must not be installed, because the latter config file // (empty-default-validators.xml) has an empty default validators element // and this clears all existing default-validators. - Assertions.assertFalse(application.getDefaultValidatorInfo().containsKey(RequiredValidator.VALIDATOR_ID)); + assertFalse(application.getDefaultValidatorInfo().containsKey(RequiredValidator.VALIDATOR_ID)); // and since bean validation is available, the BeanValidator has to be installed - Assertions.assertTrue(application.getDefaultValidatorInfo().containsKey(BeanValidator.VALIDATOR_ID)); + assertTrue(application.getDefaultValidatorInfo().containsKey(BeanValidator.VALIDATOR_ID)); } - + /** * Tests the case with two config files. The first one installs a * default validator (in this case the RequiredValidator), and the @@ -272,7 +274,7 @@ public void testDefaultValidatorsClearedByLatterConfigFileWithEmptyElement() * BeanValidator must also be installed since bean validation is available. */ @Test - public void testDefaultValidatorsNotClearedByLatterConfigFileWithNoElement() + void defaultValidatorsNotClearedByLatterConfigFileWithNoElement() { // remove existing RenderKit installations _cleanRenderKits(); @@ -297,12 +299,12 @@ public void testDefaultValidatorsNotClearedByLatterConfigFileWithNoElement() // the required validator must be installed, because the latter config file // (no-default-validators.xml) has not got a default validators element. - Assertions.assertTrue(application.getDefaultValidatorInfo().containsKey(RequiredValidator.VALIDATOR_ID)); + assertTrue(application.getDefaultValidatorInfo().containsKey(RequiredValidator.VALIDATOR_ID)); // and since bean validation is available, the BeanValidator has to be installed - Assertions.assertTrue(application.getDefaultValidatorInfo().containsKey(BeanValidator.VALIDATOR_ID)); + assertTrue(application.getDefaultValidatorInfo().containsKey(BeanValidator.VALIDATOR_ID)); } - + /** * Tests the case with two config files. The first one would install a * default validator (in this case the RequiredValidator), but the second one @@ -313,7 +315,7 @@ public void testDefaultValidatorsNotClearedByLatterConfigFileWithNoElement() * since bean validation is not available). */ @Test - public void testDefaultValidatorsOverwrittenByLatterConfigFile() + void defaultValidatorsOverwrittenByLatterConfigFile() { // remove existing RenderKit installations _cleanRenderKits(); @@ -339,14 +341,14 @@ public void testDefaultValidatorsOverwrittenByLatterConfigFile() // the required validator must not be installed, because the latter config file // (default-length-validator.xml) specifies a default validators element // and this clears all existing default-validators. - Assertions.assertFalse(application.getDefaultValidatorInfo().containsKey(RequiredValidator.VALIDATOR_ID)); + assertFalse(application.getDefaultValidatorInfo().containsKey(RequiredValidator.VALIDATOR_ID)); // the length validator has to be installed, because it was installed // by the latter config file - Assertions.assertTrue(application.getDefaultValidatorInfo().containsKey(LengthValidator.VALIDATOR_ID)); + assertTrue(application.getDefaultValidatorInfo().containsKey(LengthValidator.VALIDATOR_ID)); // and since bean validation is not available, the BeanValidator must not be installed - Assertions.assertFalse(application.getDefaultValidatorInfo().containsKey(BeanValidator.VALIDATOR_ID)); + assertFalse(application.getDefaultValidatorInfo().containsKey(BeanValidator.VALIDATOR_ID)); } } diff --git a/impl/src/test/java/org/apache/myfaces/config/LogMetaInfUtilsTestCase.java b/impl/src/test/java/org/apache/myfaces/config/LogMetaInfUtilsTestCase.java index e61aadeb43..0b30d1906a 100644 --- a/impl/src/test/java/org/apache/myfaces/config/LogMetaInfUtilsTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/config/LogMetaInfUtilsTestCase.java @@ -22,16 +22,19 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import java.net.URL; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class LogMetaInfUtilsTestCase extends AbstractFacesTestCase +class LogMetaInfUtilsTestCase extends AbstractFacesTestCase { @Test - public void testVersionNumber() throws Exception + void versionNumber() throws Exception { // tests single digits @@ -52,27 +55,27 @@ public void testVersionNumber() throws Exception LogMetaInfUtils.addJarInfo(libs, new URL("file:/opt/project/tobago/tobago-example/tobago-example-demo/target/tobago-example-demo/WEB-INF/lib/slf4j-log4j12-1.6.1.jar")); final List mf = libs.get("myfaces-api"); - Assertions.assertEquals(2, mf.size()); - Assertions.assertEquals("1.2.11-SNAPSHOT", mf.get(0).getVersion()); - Assertions.assertEquals("2", mf.get(1).getVersion()); + assertEquals(2, mf.size()); + assertEquals("1.2.11-SNAPSHOT", mf.get(0).getVersion()); + assertEquals("2", mf.get(1).getVersion()); final List tk12 = libs.get("tomahawk12"); - Assertions.assertEquals(1, tk12.size()); - Assertions.assertEquals("1.1.10-SNAPSHOT", tk12.get(0).getVersion()); + assertEquals(1, tk12.size()); + assertEquals("1.1.10-SNAPSHOT", tk12.get(0).getVersion()); final List tksb = libs.get("tomahawk-sandbox12"); - Assertions.assertEquals(1, tksb.size()); - Assertions.assertEquals("1.1.10", tksb.get(0).getVersion()); + assertEquals(1, tksb.size()); + assertEquals("1.1.10", tksb.get(0).getVersion()); final List tobago = libs.get("tobago-core"); - Assertions.assertEquals(2, tobago.size()); - Assertions.assertEquals("1.5.0-alpha-3-SNAPSHOT", tobago.get(0).getVersion()); - Assertions.assertEquals("1.0.35", tobago.get(1).getVersion()); + assertEquals(2, tobago.size()); + assertEquals("1.5.0-alpha-3-SNAPSHOT", tobago.get(0).getVersion()); + assertEquals("1.0.35", tobago.get(1).getVersion()); final List other = libs.get("other"); - Assertions.assertNull(other); + assertNull(other); final List slf = libs.get("slf4j-log4j12"); - Assertions.assertNull(slf); + assertNull(slf); } } diff --git a/impl/src/test/java/org/apache/myfaces/config/OrderingFacesConfigTest.java b/impl/src/test/java/org/apache/myfaces/config/OrderingFacesConfigTest.java index 259ee66f39..c0b5d47ca6 100644 --- a/impl/src/test/java/org/apache/myfaces/config/OrderingFacesConfigTest.java +++ b/impl/src/test/java/org/apache/myfaces/config/OrderingFacesConfigTest.java @@ -24,13 +24,17 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import jakarta.faces.FacesException; + import java.util.ArrayList; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Collections; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.myfaces.config.impl.FacesConfigUnmarshallerImpl; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -66,7 +70,7 @@ public void printFacesConfigList(String label, List appConfigResour System.out.println("]"); } - + /** * A before others * B after C @@ -79,7 +83,7 @@ public void printFacesConfigList(String label, List appConfigResour * @throws Exception */ @Test - public void testSimpleOrdering() throws Exception + void simpleOrdering() throws Exception { FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream( "empty-config.xml"), "empty-config.xml"); @@ -105,7 +109,7 @@ public void testSimpleOrdering() throws Exception applyAlgorithm(appConfigResources); } } - + /** * A before B * A before E @@ -123,7 +127,7 @@ public void testSimpleOrdering() throws Exception * @throws Exception */ @Test - public void testMiddleOrdering() throws Exception + void middleOrdering() throws Exception { FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream( "empty-config.xml"), "empty-config.xml"); @@ -184,7 +188,7 @@ public void testMiddleOrdering() throws Exception applyAlgorithm(appConfigResources); } } - + /** * A before B * A before C @@ -200,7 +204,7 @@ public void testMiddleOrdering() throws Exception * @throws Exception */ @Test - public void testMaxConditionsOrdering() throws Exception + void maxConditionsOrdering() throws Exception { org.apache.myfaces.config.impl.element.FacesConfigImpl cfg = _impl.getFacesConfig(getClass().getResourceAsStream( "empty-config.xml"), "empty-config.xml"); @@ -248,9 +252,9 @@ public void testMaxConditionsOrdering() throws Exception applyAlgorithm(appConfigResources); } } - + @Test - public void testEx1() + void ex1() { org.apache.myfaces.config.impl.element.FacesConfigImpl cfgA = new org.apache.myfaces.config.impl.element.FacesConfigImpl(); org.apache.myfaces.config.impl.element.FacesConfigImpl cfgB = new org.apache.myfaces.config.impl.element.FacesConfigImpl(); @@ -300,9 +304,9 @@ public void testEx1() applyAlgorithm(appConfigResources); } } - + @Test - public void testEx2() + void ex2() { org.apache.myfaces.config.impl.element.FacesConfigImpl cfg = new org.apache.myfaces.config.impl.element.FacesConfigImpl(); org.apache.myfaces.config.impl.element.FacesConfigImpl cfgB = new org.apache.myfaces.config.impl.element.FacesConfigImpl(); @@ -347,9 +351,9 @@ public void testEx2() applyAlgorithm(appConfigResources); } } - + @Test - public void testEx3() + void ex3() { org.apache.myfaces.config.impl.element.FacesConfigImpl cfgA = new org.apache.myfaces.config.impl.element.FacesConfigImpl(); org.apache.myfaces.config.impl.element.FacesConfigImpl cfgB = new org.apache.myfaces.config.impl.element.FacesConfigImpl(); @@ -383,9 +387,9 @@ public void testEx3() applyAlgorithm(appConfigResources); } } - + @Test - public void testEx4() throws Exception + void ex4() throws Exception { FacesConfig cfgA = _impl.getFacesConfig(getClass().getResourceAsStream( "transitive-a-config.xml"), "transitive-a-config.xml"); @@ -425,7 +429,7 @@ public void applyAlgorithm(List appConfigResources) throws FacesExc } @Test - public void testBeforeOthers1() throws Exception + void beforeOthers1() throws Exception { FacesConfig cfgA = _impl.getFacesConfig(getClass().getResourceAsStream( "no-name-config.xml"), "no-name-config.xml"); @@ -451,12 +455,12 @@ public void testBeforeOthers1() throws Exception Collections.shuffle(appConfigResources); List sortedList = applyFullAlgorithm(appConfigResources); - Assertions.assertEquals(cfgC, sortedList.get(0)); + assertEquals(cfgC, sortedList.get(0)); } } @Test - public void testAfterOthers1() throws Exception + void afterOthers1() throws Exception { FacesConfig cfgA = _impl.getFacesConfig(getClass().getResourceAsStream( "no-name-config.xml"), "no-name-config.xml"); @@ -482,12 +486,12 @@ public void testAfterOthers1() throws Exception Collections.shuffle(appConfigResources); List sortedList = applyFullAlgorithm(appConfigResources); - Assertions.assertEquals(cfgC, sortedList.get(sortedList.size()-1)); + assertEquals(cfgC, sortedList.get(sortedList.size()-1)); } } - + @Test - public void testBeforeOthers2() throws Exception + void beforeOthers2() throws Exception { FacesConfig cfg1 = _impl.getFacesConfig(getClass().getResourceAsStream( "no-name-config.xml"), "no-name-config.xml"); @@ -526,9 +530,9 @@ public void testBeforeOthers2() throws Exception Collections.shuffle(appConfigResources); List sortedList = applyFullAlgorithm(appConfigResources); - Assertions.assertEquals(cfg3, sortedList.get(0)); + assertEquals(cfg3, sortedList.get(0)); - Assertions.assertEquals(cfg6, sortedList.get(sortedList.size()-1)); + assertEquals(cfg6, sortedList.get(sortedList.size()-1)); } } @@ -863,9 +867,9 @@ public void applyAlgorithm2(List appConfigResources) throws FacesEx } System.out.println("]"); } - + @Test - public void testAbsoluteOrdering1() throws Exception + void absoluteOrdering1() throws Exception { org.apache.myfaces.config.impl.element.FacesConfigImpl cfgAbs = new org.apache.myfaces.config.impl.element.FacesConfigImpl(); org.apache.myfaces.config.impl.element.FacesConfigImpl cfgMK = new org.apache.myfaces.config.impl.element.FacesConfigImpl(); @@ -891,7 +895,7 @@ public void testAbsoluteOrdering1() throws Exception //printFacesConfigList("Sorted-List: [", sortedResources); - Assertions.assertTrue(sortedResources.containsAll(appConfigResources)); + assertTrue(sortedResources.containsAll(appConfigResources)); appConfigResources = new ArrayList(); appConfigResources.add(cfgOWB); @@ -903,7 +907,7 @@ public void testAbsoluteOrdering1() throws Exception //printFacesConfigList("Sorted-List: [", sortedResources); - Assertions.assertTrue(sortedResources.containsAll(appConfigResources)); + assertTrue(sortedResources.containsAll(appConfigResources)); } diff --git a/impl/src/test/java/org/apache/myfaces/config/impl/FacesConfigUnmarshallerImplTest.java b/impl/src/test/java/org/apache/myfaces/config/impl/FacesConfigUnmarshallerImplTest.java index ae1e8a2b71..033cdb42f3 100644 --- a/impl/src/test/java/org/apache/myfaces/config/impl/FacesConfigUnmarshallerImplTest.java +++ b/impl/src/test/java/org/apache/myfaces/config/impl/FacesConfigUnmarshallerImplTest.java @@ -15,6 +15,8 @@ */ package org.apache.myfaces.config.impl; +import static org.junit.jupiter.api.Assertions.*; + import java.util.List; import org.apache.myfaces.config.element.Application; @@ -24,7 +26,6 @@ import org.apache.myfaces.config.element.LocaleConfig; import org.apache.myfaces.config.element.OrderSlot; import org.apache.myfaces.config.impl.element.ConfigOthersSlotImpl; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -32,69 +33,69 @@ * @author Mathias Broekelmann (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class FacesConfigUnmarshallerImplTest +class FacesConfigUnmarshallerImplTest { private FacesConfigUnmarshallerImpl _impl; @BeforeEach - public void setUp() throws Exception + void setUp() throws Exception { _impl = new FacesConfigUnmarshallerImpl(null); } @Test - public void testEmptyConfig() throws Exception + void emptyConfig() throws Exception { FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream( "empty-config.xml"), "empty-config.xml"); - Assertions.assertNotNull(cfg); - Assertions.assertTrue(cfg.getApplications().isEmpty()); - Assertions.assertTrue(cfg.getComponents().isEmpty()); - Assertions.assertTrue(cfg.getConverters().isEmpty()); - Assertions.assertTrue(cfg.getFactories().isEmpty()); - Assertions.assertTrue(cfg.getLifecyclePhaseListener().isEmpty()); - Assertions.assertTrue(cfg.getNavigationRules().isEmpty()); - Assertions.assertTrue(cfg.getRenderKits().isEmpty()); - Assertions.assertTrue(cfg.getValidators().isEmpty()); + assertNotNull(cfg); + assertTrue(cfg.getApplications().isEmpty()); + assertTrue(cfg.getComponents().isEmpty()); + assertTrue(cfg.getConverters().isEmpty()); + assertTrue(cfg.getFactories().isEmpty()); + assertTrue(cfg.getLifecyclePhaseListener().isEmpty()); + assertTrue(cfg.getNavigationRules().isEmpty()); + assertTrue(cfg.getRenderKits().isEmpty()); + assertTrue(cfg.getValidators().isEmpty()); } @Test - public void testApplicationConfig() throws Exception + void applicationConfig() throws Exception { FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream( "application-config.xml"), "application-config.xml"); - Assertions.assertNotNull(cfg); - Assertions.assertEquals(1, cfg.getApplications().size()); + assertNotNull(cfg); + assertEquals(1, cfg.getApplications().size()); Application app = cfg.getApplications().get(0); - Assertions.assertEquals(2, app.getActionListener().size()); - Assertions.assertEquals("action-listener1", app.getActionListener().get(0)); - Assertions.assertEquals("action-listener2", app.getActionListener().get(1)); - Assertions.assertEquals(1, app.getDefaultRenderkitId().size()); - Assertions.assertEquals("default-render-kit-id", app.getDefaultRenderkitId() + assertEquals(2, app.getActionListener().size()); + assertEquals("action-listener1", app.getActionListener().get(0)); + assertEquals("action-listener2", app.getActionListener().get(1)); + assertEquals(1, app.getDefaultRenderkitId().size()); + assertEquals("default-render-kit-id", app.getDefaultRenderkitId() .get(0)); assertLocaleConfig(app.getLocaleConfig()); - Assertions.assertEquals(1, app.getMessageBundle().size()); - Assertions.assertEquals("message-bundle", app.getMessageBundle().get(0)); - Assertions.assertEquals(1, app.getNavigationHandler().size()); - Assertions.assertEquals("navigation-handler", app.getNavigationHandler().get(0)); - Assertions.assertEquals(1, app.getPropertyResolver().size()); - Assertions.assertEquals("property-resolver", app.getPropertyResolver().get(0)); + assertEquals(1, app.getMessageBundle().size()); + assertEquals("message-bundle", app.getMessageBundle().get(0)); + assertEquals(1, app.getNavigationHandler().size()); + assertEquals("navigation-handler", app.getNavigationHandler().get(0)); + assertEquals(1, app.getPropertyResolver().size()); + assertEquals("property-resolver", app.getPropertyResolver().get(0)); - Assertions.assertEquals(1, app.getStateManager().size()); - Assertions.assertEquals("state-manager", app.getStateManager().get(0)); + assertEquals(1, app.getStateManager().size()); + assertEquals("state-manager", app.getStateManager().get(0)); - Assertions.assertEquals(1, app.getVariableResolver().size()); - Assertions.assertEquals("variable-resolver", app.getVariableResolver().get(0)); + assertEquals(1, app.getVariableResolver().size()); + assertEquals("variable-resolver", app.getVariableResolver().get(0)); - Assertions.assertEquals(1, app.getViewHandler().size()); - Assertions.assertEquals("view-handler", app.getViewHandler().get(0)); + assertEquals(1, app.getViewHandler().size()); + assertEquals("view-handler", app.getViewHandler().get(0)); - Assertions.assertEquals(1, app.getElResolver().size()); - Assertions.assertEquals("el-resolver", app.getElResolver().get(0)); + assertEquals(1, app.getElResolver().size()); + assertEquals("el-resolver", app.getElResolver().get(0)); - Assertions.assertEquals(1, app.getResourceBundle().size()); - Assertions.assertEquals("base-name", app.getResourceBundle().get(0).getBaseName()); - Assertions.assertEquals("var", app.getResourceBundle().get(0).getVar()); + assertEquals(1, app.getResourceBundle().size()); + assertEquals("base-name", app.getResourceBundle().get(0).getBaseName()); + assertEquals("var", app.getResourceBundle().get(0).getVar()); } /** @@ -102,68 +103,68 @@ public void testApplicationConfig() throws Exception */ private void assertLocaleConfig(List localeConfig) { - Assertions.assertEquals(1, localeConfig.size()); + assertEquals(1, localeConfig.size()); LocaleConfig cfg = localeConfig.get(0); - Assertions.assertEquals("aa", cfg.getDefaultLocale()); - Assertions.assertEquals(2, cfg.getSupportedLocales().size()); - Assertions.assertEquals("aa", cfg.getSupportedLocales().get(0)); - Assertions.assertEquals("bb", cfg.getSupportedLocales().get(1)); + assertEquals("aa", cfg.getDefaultLocale()); + assertEquals(2, cfg.getSupportedLocales().size()); + assertEquals("aa", cfg.getSupportedLocales().get(0)); + assertEquals("bb", cfg.getSupportedLocales().get(1)); } - + @Test - public void testAbsoluteOrderingConfig() throws Exception + void absoluteOrderingConfig() throws Exception { FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream( "absolute-ordering-config.xml"), "absolute-ordering-config.xml"); - Assertions.assertNotNull(cfg); - Assertions.assertEquals("true", cfg.getMetadataComplete()); - Assertions.assertEquals("a",cfg.getName()); + assertNotNull(cfg); + assertEquals("true", cfg.getMetadataComplete()); + assertEquals("a",cfg.getName()); List orderList = cfg.getAbsoluteOrdering().getOrderList(); - Assertions.assertEquals("b", ((FacesConfigNameSlot) orderList.get(0)).getName()); - Assertions.assertEquals("c", ((FacesConfigNameSlot) orderList.get(1)).getName()); - Assertions.assertEquals(ConfigOthersSlotImpl.class, orderList.get(2).getClass()); - Assertions.assertEquals("d", ((FacesConfigNameSlot) orderList.get(3)).getName()); + assertEquals("b", ((FacesConfigNameSlot) orderList.get(0)).getName()); + assertEquals("c", ((FacesConfigNameSlot) orderList.get(1)).getName()); + assertEquals(ConfigOthersSlotImpl.class, orderList.get(2).getClass()); + assertEquals("d", ((FacesConfigNameSlot) orderList.get(3)).getName()); - Assertions.assertTrue(cfg.getApplications().isEmpty()); - Assertions.assertTrue(cfg.getComponents().isEmpty()); - Assertions.assertTrue(cfg.getConverters().isEmpty()); - Assertions.assertTrue(cfg.getFactories().isEmpty()); - Assertions.assertTrue(cfg.getLifecyclePhaseListener().isEmpty()); - Assertions.assertTrue(cfg.getNavigationRules().isEmpty()); - Assertions.assertTrue(cfg.getRenderKits().isEmpty()); - Assertions.assertTrue(cfg.getValidators().isEmpty()); + assertTrue(cfg.getApplications().isEmpty()); + assertTrue(cfg.getComponents().isEmpty()); + assertTrue(cfg.getConverters().isEmpty()); + assertTrue(cfg.getFactories().isEmpty()); + assertTrue(cfg.getLifecyclePhaseListener().isEmpty()); + assertTrue(cfg.getNavigationRules().isEmpty()); + assertTrue(cfg.getRenderKits().isEmpty()); + assertTrue(cfg.getValidators().isEmpty()); } - + @Test - public void testOrderingConfig() throws Exception + void orderingConfig() throws Exception { FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream( "ordering-config.xml"), "ordering-config.xml"); - Assertions.assertNotNull(cfg); - Assertions.assertEquals("a",cfg.getName()); + assertNotNull(cfg); + assertEquals("a",cfg.getName()); List orderList = cfg.getOrdering().getBeforeList(); - Assertions.assertEquals("b", ((FacesConfigNameSlot) orderList.get(0)).getName()); - Assertions.assertEquals("c", ((FacesConfigNameSlot) orderList.get(1)).getName()); - Assertions.assertEquals(org.apache.myfaces.config.impl.element.ConfigOthersSlotImpl.class, orderList.get(2).getClass()); + assertEquals("b", ((FacesConfigNameSlot) orderList.get(0)).getName()); + assertEquals("c", ((FacesConfigNameSlot) orderList.get(1)).getName()); + assertEquals(org.apache.myfaces.config.impl.element.ConfigOthersSlotImpl.class, orderList.get(2).getClass()); orderList = cfg.getOrdering().getAfterList(); - Assertions.assertEquals("d", ((FacesConfigNameSlot) orderList.get(0)).getName()); + assertEquals("d", ((FacesConfigNameSlot) orderList.get(0)).getName()); - Assertions.assertTrue(cfg.getApplications().isEmpty()); - Assertions.assertTrue(cfg.getComponents().isEmpty()); - Assertions.assertTrue(cfg.getConverters().isEmpty()); - Assertions.assertTrue(cfg.getFactories().isEmpty()); - Assertions.assertTrue(cfg.getLifecyclePhaseListener().isEmpty()); - Assertions.assertTrue(cfg.getNavigationRules().isEmpty()); - Assertions.assertTrue(cfg.getRenderKits().isEmpty()); - Assertions.assertTrue(cfg.getValidators().isEmpty()); + assertTrue(cfg.getApplications().isEmpty()); + assertTrue(cfg.getComponents().isEmpty()); + assertTrue(cfg.getConverters().isEmpty()); + assertTrue(cfg.getFactories().isEmpty()); + assertTrue(cfg.getLifecyclePhaseListener().isEmpty()); + assertTrue(cfg.getNavigationRules().isEmpty()); + assertTrue(cfg.getRenderKits().isEmpty()); + assertTrue(cfg.getValidators().isEmpty()); } - + @Test - public void testFacesFlowConfig() throws Exception + void facesFlowConfig() throws Exception {/* FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream( "faces-flow.xml"), "faces-flow.xml"); @@ -231,54 +232,54 @@ public void testFacesFlowConfig() throws Exception Assertions.assertEquals("name1", facesFlowParameter.getName()); Assertions.assertEquals("value1", facesFlowParameter.getValue());*/ } - + @Test - public void testCsrf() throws Exception + void csrf() throws Exception { FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream( "csrf-and-contracts.xml"), "csrf-and-contracts.xml"); - Assertions.assertNotNull(cfg); - Assertions.assertEquals(2, cfg.getProtectedViewsUrlPatternList().size()); - Assertions.assertEquals("/files/*.xhtml", cfg.getProtectedViewsUrlPatternList().get(0)); - Assertions.assertEquals("/files2/*.xhtml", cfg.getProtectedViewsUrlPatternList().get(1)); + assertNotNull(cfg); + assertEquals(2, cfg.getProtectedViewsUrlPatternList().size()); + assertEquals("/files/*.xhtml", cfg.getProtectedViewsUrlPatternList().get(0)); + assertEquals("/files2/*.xhtml", cfg.getProtectedViewsUrlPatternList().get(1)); } - + @Test - public void testContracts() throws Exception + void contracts() throws Exception { FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream( "csrf-and-contracts.xml"), "csrf-and-contracts.xml"); - Assertions.assertNotNull(cfg); + assertNotNull(cfg); Application app = cfg.getApplications().get(0); - Assertions.assertNotNull(app); - Assertions.assertEquals(1, app.getResourceLibraryContractMappings().size()); + assertNotNull(app); + assertEquals(1, app.getResourceLibraryContractMappings().size()); ContractMapping mapping = app.getResourceLibraryContractMappings().get(0); - Assertions.assertEquals("/files/*.xhtml", mapping.getUrlPatternList().get(0)); - Assertions.assertEquals("contractA contractB", mapping.getContractList().get(0)); + assertEquals("/files/*.xhtml", mapping.getUrlPatternList().get(0)); + assertEquals("contractA contractB", mapping.getContractList().get(0)); } - + @Test - public void testContracts2() throws Exception + void contracts2() throws Exception { FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream( "contracts2.xml"), "contracts2.xml"); - Assertions.assertNotNull(cfg); + assertNotNull(cfg); Application app = cfg.getApplications().get(0); - Assertions.assertNotNull(app); - Assertions.assertEquals(1, app.getResourceLibraryContractMappings().size()); + assertNotNull(app); + assertEquals(1, app.getResourceLibraryContractMappings().size()); ContractMapping mapping = app.getResourceLibraryContractMappings().get(0); - Assertions.assertTrue(mapping.getUrlPatternList().contains("/files/*.xhtml")); - Assertions.assertTrue(mapping.getUrlPatternList().contains("/files2/*.xhtml")); - Assertions.assertTrue(mapping.getContractList().contains("contractA")); - Assertions.assertTrue(mapping.getContractList().contains("contractB")); + assertTrue(mapping.getUrlPatternList().contains("/files/*.xhtml")); + assertTrue(mapping.getUrlPatternList().contains("/files2/*.xhtml")); + assertTrue(mapping.getContractList().contains("contractA")); + assertTrue(mapping.getContractList().contains("contractB")); } } diff --git a/impl/src/test/java/org/apache/myfaces/context/ContextRegexpTest.java b/impl/src/test/java/org/apache/myfaces/context/ContextRegexpTest.java index 6dd8de4580..5d5f3c5dbe 100644 --- a/impl/src/test/java/org/apache/myfaces/context/ContextRegexpTest.java +++ b/impl/src/test/java/org/apache/myfaces/context/ContextRegexpTest.java @@ -15,7 +15,9 @@ */ package org.apache.myfaces.context; -import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.junit.jupiter.api.Test; /** @@ -24,29 +26,26 @@ * @author Werner Punz(latest modification by $Author$) * @version $Revision$ $Date$ */ -public class ContextRegexpTest { +class ContextRegexpTest { static final String RE_SPLITTER = "[\\s\\t\\r\\n]*\\,[\\s\\t\\r\\n]*"; - - - /** * condition valid string */ @Test - public void testCondition1() { + void condition1() { String[] splitted = " hello ,world \n ,bla ".split(RE_SPLITTER); splitted[0] = splitted[0].trim(); int len = splitted.length-1; if(len > 0) {//all others trimmed by the re splitted[len] = splitted[len].trim(); } - Assertions.assertTrue(splitted.length == 3); - Assertions.assertTrue(splitted[0].trim().equals("hello")); - Assertions.assertTrue(splitted[1].trim().equals("world")); - Assertions.assertTrue(splitted[2].trim().equals("bla")); + assertEquals(3, splitted.length); + assertEquals("hello", splitted[0].trim()); + assertEquals("world", splitted[1].trim()); + assertEquals("bla", splitted[2].trim()); } /** @@ -54,10 +53,10 @@ public void testCondition1() { * empty string */ @Test - public void testCondition2() { + void condition2() { String[] splitted = " ".split(RE_SPLITTER); - Assertions.assertTrue(splitted.length == 1); - Assertions.assertTrue(splitted[0] != null); + assertEquals(1, splitted.length); + assertTrue(splitted[0] != null); } /** @@ -65,9 +64,9 @@ public void testCondition2() { * empty string no blanks */ @Test - public void testCondition3() { + void condition3() { String[] splitted = "".split(RE_SPLITTER); - Assertions.assertTrue(splitted.length == 1); - Assertions.assertTrue(splitted[0] != null); + assertEquals(1, splitted.length); + assertTrue(splitted[0] != null); } } diff --git a/impl/src/test/java/org/apache/myfaces/context/ExecutePhaseClientIdsTest.java b/impl/src/test/java/org/apache/myfaces/context/ExecutePhaseClientIdsTest.java index d724a92859..5cf2504e8b 100644 --- a/impl/src/test/java/org/apache/myfaces/context/ExecutePhaseClientIdsTest.java +++ b/impl/src/test/java/org/apache/myfaces/context/ExecutePhaseClientIdsTest.java @@ -16,6 +16,9 @@ package org.apache.myfaces.context; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.HashMap; import java.util.Map; @@ -25,7 +28,6 @@ import org.apache.myfaces.context.servlet.FacesContextImpl; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -34,7 +36,7 @@ * @author Werner Punz(latest modification by $Author$) * @version $Revision$ $Date$ */ -public class ExecutePhaseClientIdsTest extends AbstractFacesTestCase { +class ExecutePhaseClientIdsTest extends AbstractFacesTestCase { @Override @BeforeEach @@ -50,8 +52,8 @@ public void setUp() throws Exception { * Empty String as request param * has to result in an empty list */ - @Test - public void testRequestParams1() { + @Test + void requestParams1() { String empty = " \n \t "; Map requestParamMap = new HashMap(); requestParamMap.put(PartialViewContext.PARTIAL_EXECUTE_PARAM_NAME, empty); @@ -61,14 +63,14 @@ public void testRequestParams1() { PartialViewContext pprContext = context.getPartialViewContext(); - Assertions.assertTrue(pprContext.getExecuteIds().isEmpty()); + assertTrue(pprContext.getExecuteIds().isEmpty()); } /** * no request param, has to result in an empty list */ @Test - public void testRequestParams2() { + void requestParams2() { Map requestParamMap = new HashMap(); ContextTestRequestWrapper wrapper = new ContextTestRequestWrapper(request, requestParamMap); @@ -76,7 +78,7 @@ public void testRequestParams2() { PartialViewContext pprContext = context.getPartialViewContext(); - Assertions.assertTrue(pprContext.getExecuteIds().isEmpty()); + assertTrue(pprContext.getExecuteIds().isEmpty()); } /** @@ -100,7 +102,7 @@ public void testRequestParams4() { * list with one element has to result in a list with one element */ @Test - public void testRequestParams5() { + void requestParams5() { String params = " view1:panel1:_component1 "; Map requestParamMap = new HashMap(); requestParamMap.put(PartialViewContext.PARTIAL_EXECUTE_PARAM_NAME, params); @@ -110,8 +112,8 @@ public void testRequestParams5() { PartialViewContext pprContext = context.getPartialViewContext(); - Assertions.assertTrue(pprContext.getExecuteIds().size() == 1); - Assertions.assertTrue(pprContext.getExecuteIds().iterator().next().equals("view1:panel1:_component1")); + assertEquals(1, pprContext.getExecuteIds().size()); + assertEquals("view1:panel1:_component1", pprContext.getExecuteIds().iterator().next()); } /** @@ -119,7 +121,7 @@ public void testRequestParams5() { * blank chars */ @Test - public void testRequestParams6() { + void requestParams6() { String params = " view1:panel1:_component1 view1:panel1:_component2 \n component3 component4 "; Map requestParamMap = new HashMap(); requestParamMap.put(PartialViewContext.PARTIAL_EXECUTE_PARAM_NAME, params); @@ -128,8 +130,8 @@ public void testRequestParams6() { FacesContext context = new FacesContextImpl(servletContext, wrapper, response); PartialViewContext pprContext = context.getPartialViewContext(); - - Assertions.assertTrue(pprContext.getExecuteIds().size() == 4); + + assertEquals(4, pprContext.getExecuteIds().size()); // FIXME: Latest spec uses a Collection so order is not guaranteed // Assertions.assertTrue("Value match", pprContext.getExecuteIds().get(0).equals("view1:panel1:_component1")); @@ -143,7 +145,7 @@ public void testRequestParams6() { * a single, implausibly long execute id must not be expanded. */ @Test - public void testOverlongClientIdIsRejected() { + void overlongClientIdIsRejected() { StringBuilder colons = new StringBuilder(); for (int i = 0; i < 100000; i++) { colons.append(':'); @@ -156,7 +158,7 @@ public void testOverlongClientIdIsRejected() { PartialViewContext pprContext = context.getPartialViewContext(); - Assertions.assertTrue(pprContext.getExecuteIds().isEmpty()); + assertTrue(pprContext.getExecuteIds().isEmpty()); } /** @@ -164,7 +166,7 @@ public void testOverlongClientIdIsRejected() { * length-bounded too, otherwise it bypasses the execute-id cap. */ @Test - public void testOverlongSourceIsRejected() { + void overlongSourceIsRejected() { StringBuilder colons = new StringBuilder(); for (int i = 0; i < 100000; i++) { colons.append(':'); @@ -179,7 +181,7 @@ public void testOverlongSourceIsRejected() { PartialViewContext pprContext = context.getPartialViewContext(); // only the valid execute id survives; the oversized source is dropped - Assertions.assertEquals(1, pprContext.getExecuteIds().size()); - Assertions.assertTrue(pprContext.getExecuteIds().contains("form:input")); + assertEquals(1, pprContext.getExecuteIds().size()); + assertTrue(pprContext.getExecuteIds().contains("form:input")); } } diff --git a/impl/src/test/java/org/apache/myfaces/context/IsRenderedTest.java b/impl/src/test/java/org/apache/myfaces/context/IsRenderedTest.java index b31f070290..18042cb9be 100644 --- a/impl/src/test/java/org/apache/myfaces/context/IsRenderedTest.java +++ b/impl/src/test/java/org/apache/myfaces/context/IsRenderedTest.java @@ -15,13 +15,15 @@ */ package org.apache.myfaces.context; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import jakarta.faces.FactoryFinder; import jakarta.faces.context.FacesContext; import jakarta.faces.context.PartialViewContext; import org.apache.myfaces.context.servlet.FacesContextImpl; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -32,7 +34,7 @@ * @author Werner Punz(latest modification by $Author$) * @version $Revision$ $Date$ */ -public class IsRenderedTest extends AbstractFacesTestCase { +class IsRenderedTest extends AbstractFacesTestCase { @Override @BeforeEach @@ -50,17 +52,17 @@ public void setUp() throws Exception { * or a renderAll which */ @Test - public void testRenderAll1() { + void renderAll1() { FacesContext context = new FacesContextImpl(servletContext, request, response); PartialViewContext pprContext = context.getPartialViewContext(); pprContext.setRenderAll(true); - Assertions.assertTrue(pprContext.isRenderAll(), "override should trigger no matter which condition we have"); + assertTrue(pprContext.isRenderAll(), "override should trigger no matter which condition we have"); context = new FacesContextImpl(servletContext, request, response); pprContext.setRenderAll(false); - Assertions.assertFalse(pprContext.isRenderAll(), "override should trigger no matter which condition we have"); + assertFalse(pprContext.isRenderAll(), "override should trigger no matter which condition we have"); } diff --git a/impl/src/test/java/org/apache/myfaces/context/PartialResponseWriterImplTest.java b/impl/src/test/java/org/apache/myfaces/context/PartialResponseWriterImplTest.java index 8bcff2c75d..932b8f40eb 100644 --- a/impl/src/test/java/org/apache/myfaces/context/PartialResponseWriterImplTest.java +++ b/impl/src/test/java/org/apache/myfaces/context/PartialResponseWriterImplTest.java @@ -19,6 +19,8 @@ package org.apache.myfaces.context; +import static org.junit.jupiter.api.Assertions.*; + import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -33,7 +35,6 @@ import org.apache.myfaces.renderkit.html.HtmlResponseWriterImpl; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.w3c.dom.Document; @@ -85,7 +86,7 @@ private void checkOutput(File expected, String output) throws Exception is2.setCharacterStream(new StringReader(output)); Document doc2 = db.parse(is2); doc2.normalizeDocument(); - Assertions.assertTrue(doc1.isEqualNode(doc2)); + assertTrue(doc1.isEqualNode(doc2)); } /** @@ -124,9 +125,9 @@ protected String getDirectory() this.getClass().getName().lastIndexOf('.')).replace('.', '/') + "/"; } - + @Test - public void testNestedScriptCDATA() throws Exception { + void nestedScriptCDATA() throws Exception { _writer = createTestProbe(); try { _writer.startDocument(); @@ -142,12 +143,12 @@ public void testNestedScriptCDATA() throws Exception { checkOutput(new File(getLocalFile("nestedScriptCDATA.xml").toURI()), _contentCollector.toString()); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } - + @Test - public void testBasicWriteTest() { + void basicWriteTest() { _writer = createTestProbe(); try { //_writer.startCDATA(); @@ -157,14 +158,14 @@ public void testBasicWriteTest() { // _writer.endCDATA(); _writer.flush(); _writer.close(); - Assertions.assertTrue(_contentCollector.toString().equals("testing")); + assertEquals("testing", _contentCollector.toString()); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } @Test - public void teststandardNestingTest() { + void teststandardNestingTest() { _writer = createTestProbe(); try { //_writer.startCDATA(); @@ -174,14 +175,14 @@ public void teststandardNestingTest() { // _writer.endCDATA(); _writer.flush(); _writer.close(); - Assertions.assertTrue(_contentCollector.toString().equals("")); + assertEquals("", _contentCollector.toString()); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } @Test - public void testIllegalNestingResolvementTest() { + void illegalNestingResolvementTest() { _writer = createTestProbe(); try { _writer.startCDATA(); @@ -191,14 +192,14 @@ public void testIllegalNestingResolvementTest() { _writer.endCDATA(); _writer.flush(); _writer.close(); - Assertions.assertTrue(_contentCollector.toString().equals("]]>")); + assertEquals("]]>", _contentCollector.toString()); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } @Test - public void testIllegalNestingResolvementTest2() { + void illegalNestingResolvementTest2() { _writer = createTestProbe(); try { _writer.startCDATA(); @@ -206,28 +207,28 @@ public void testIllegalNestingResolvementTest2() { _writer.write("testing"); _writer.flush(); _writer.close(); - Assertions.assertTrue(_contentCollector.toString().equals("")); + assertEquals("", _contentCollector.toString()); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } @Test - public void testStandardUpdate() { + void standardUpdate() { _writer = createTestProbe(); try { _writer.startUpdate("blaId"); _writer.write("testing"); _writer.endUpdate(); - Assertions.assertTrue(_contentCollector.toString().equals(STD_UPDATE_RESULT)); + assertEquals(STD_UPDATE_RESULT, _contentCollector.toString()); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } @Test - public void testStandardUpdateNestedCDATA() { + void standardUpdateNestedCDATA() { _writer = createTestProbe(); try { _writer.startUpdate("blaId"); @@ -235,14 +236,14 @@ public void testStandardUpdateNestedCDATA() { _writer.write("testing"); _writer.endCDATA(); _writer.endUpdate(); - Assertions.assertTrue(_contentCollector.toString().equals("]]>")); + assertEquals("]]>", _contentCollector.toString()); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } @Test - public void testComponentAuthorNestingFailureTest() { + void componentAuthorNestingFailureTest() { _writer = createTestProbe(); try { _writer.startUpdate("blaId"); @@ -250,40 +251,40 @@ public void testComponentAuthorNestingFailureTest() { _writer.startCDATA(); _writer.write("testing"); _writer.endUpdate(); - Assertions.assertTrue(_contentCollector.toString().equals("")); + assertEquals("", _contentCollector.toString()); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } @Test - public void testStandardInsertAfter() { + void standardInsertAfter() { _writer = createTestProbe(); try { _writer.startInsertAfter("blaId"); _writer.write("testing"); _writer.endInsert(); - Assertions.assertTrue(_contentCollector.toString().equals("")); + assertEquals("", _contentCollector.toString()); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } @Test - public void testStandardInsertBefore() { + void standardInsertBefore() { _writer = createTestProbe(); try { _writer.startInsertBefore("blaId"); _writer.write("testing"); _writer.endInsert(); - Assertions.assertTrue(_contentCollector.toString().equals("")); + assertEquals("", _contentCollector.toString()); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } @Test - public void testBrokenUserInput() { + void brokenUserInput() { _writer = createTestProbe(); try { _writer.startInsertBefore("blaId"); @@ -292,56 +293,56 @@ public void testBrokenUserInput() { _writer.writeAttribute("value","]]>", null); _writer.endElement("input"); _writer.endInsert(); - Assertions.assertTrue(_contentCollector.toString().contains("value=\"]]>\"")); + assertTrue(_contentCollector.toString().contains("value=\"]]>\"")); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } @Test - public void testDelete() { + void delete() { _writer = createTestProbe(); try { _writer.delete("blaId"); - Assertions.assertTrue(_contentCollector.toString().equals("")); + assertEquals("", _contentCollector.toString()); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } @Test - public void testWriteIllegalXmlUnicodeCharacters() { + void writeIllegalXmlUnicodeCharacters() { _writer = createTestProbe(); try { String illegalChars = "\u0001\u0002\u0003\u0004\u0005\u0006\u000B\f\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F\uDBFF\uDC00"; String legalChars = "foo"; _writer.write(illegalChars + legalChars); - Assertions.assertEquals(legalChars, _contentCollector.toString().trim(), + assertEquals(legalChars, _contentCollector.toString().trim(), "All illegal XML unicode characters should have been replaced by spaces"); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } @Test - public void testWriteTextIllegalXmlUnicodeCharacters() { + void writeTextIllegalXmlUnicodeCharacters() { _writer = createTestProbe(); try { String illegalChars = "\u0001\u0002\u0003\u0004\u0005\u0006\u000B\f\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F\uDBFF\uDC00"; String legalChars = "foo"; _writer.writeText(illegalChars + legalChars, null); - Assertions.assertEquals(legalChars, _contentCollector.toString().trim(), + assertEquals(legalChars, _contentCollector.toString().trim(), "All illegal XML unicode characters should have been replaced by spaces"); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } @Test - public void testWriteAttributeIllegalXmlUnicodeCharacters() { + void writeAttributeIllegalXmlUnicodeCharacters() { _writer = createTestProbe(); try { String illegalChars = "\u0001\u0002\u0003\u0004\u0005\u0006\u000B\f\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F\uDBFF\uDC00"; @@ -349,16 +350,16 @@ public void testWriteAttributeIllegalXmlUnicodeCharacters() { _writer.startElement(legalChars, null); _writer.writeAttribute(legalChars, illegalChars + legalChars, null); _writer.endElement(legalChars); - Assertions.assertTrue(_contentCollector.toString().matches("<:X: :X:=\"[ ]+:X:\">".replace(":X:", legalChars)), + assertTrue(_contentCollector.toString().matches("<:X: :X:=\"[ ]+:X:\">".replace(":X:", legalChars)), "All illegal XML unicode characters should have been replaced by spaces"); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } - + @Test - public void testWriteSkipEmoji() { + void writeSkipEmoji() { _writer = createTestProbe(); try { String input = "foo😀"; @@ -366,16 +367,16 @@ public void testWriteSkipEmoji() { String escaped = _contentCollector.toString(); - Assertions.assertEquals(input, escaped.trim(), + assertEquals(input, escaped.trim(), "All illegal XML unicode characters should have been replaced by spaces"); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } - + @Test - public void testWriteSkipPictographs() { + void writeSkipPictographs() { _writer = createTestProbe(); try { String input = "foo🏺"; @@ -383,11 +384,11 @@ public void testWriteSkipPictographs() { String escaped = _contentCollector.toString(); - Assertions.assertEquals(input, escaped.trim(), + assertEquals(input, escaped.trim(), "All illegal XML unicode characters should have been replaced by spaces"); } catch (IOException e) { - Assertions.fail(e.toString()); + fail(e.toString()); } } diff --git a/impl/src/test/java/org/apache/myfaces/context/RenderPhaseClientIdsTest.java b/impl/src/test/java/org/apache/myfaces/context/RenderPhaseClientIdsTest.java index 20de58179e..86d97b27dd 100644 --- a/impl/src/test/java/org/apache/myfaces/context/RenderPhaseClientIdsTest.java +++ b/impl/src/test/java/org/apache/myfaces/context/RenderPhaseClientIdsTest.java @@ -15,6 +15,9 @@ */ package org.apache.myfaces.context; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.HashMap; import java.util.Map; @@ -24,7 +27,6 @@ import org.apache.myfaces.context.servlet.FacesContextImpl; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -36,7 +38,7 @@ * @author Werner Punz(latest modification by $Author$) * @version $Revision$ $Date$ */ -public class RenderPhaseClientIdsTest extends AbstractFacesTestCase { +class RenderPhaseClientIdsTest extends AbstractFacesTestCase { @Override @BeforeEach @@ -47,13 +49,13 @@ public void setUp() throws Exception { FactoryFinder.setFactory (FactoryFinder.EXCEPTION_HANDLER_FACTORY, "org.apache.myfaces.context.ExceptionHandlerFactoryImpl"); } - + /** * Empty String as request param * has to result in an empty list */ @Test - public void testRequestParams1() { + void requestParams1() { String empty = " \n \t "; Map requestParamMap = new HashMap(); requestParamMap.put(PartialViewContext.PARTIAL_RENDER_PARAM_NAME, empty); @@ -63,14 +65,14 @@ public void testRequestParams1() { PartialViewContext pprContext = context.getPartialViewContext(); - Assertions.assertTrue(pprContext.getRenderIds().isEmpty()); + assertTrue(pprContext.getRenderIds().isEmpty()); } /** * no request param, has to result in an empty list */ @Test - public void testRequestParams2() { + void requestParams2() { Map requestParamMap = new HashMap(); ContextTestRequestWrapper wrapper = new ContextTestRequestWrapper(request, requestParamMap); @@ -78,7 +80,7 @@ public void testRequestParams2() { PartialViewContext pprContext = context.getPartialViewContext(); - Assertions.assertTrue(pprContext.getRenderIds().isEmpty()); + assertTrue(pprContext.getRenderIds().isEmpty()); } /** @@ -102,7 +104,7 @@ public void testRequestParams4() { * list with one element has to result in a list with one element */ @Test - public void testRequestParams5() { + void requestParams5() { String params = " view1:panel1:_component1 "; Map requestParamMap = new HashMap(); requestParamMap.put(PartialViewContext.PARTIAL_RENDER_PARAM_NAME, params); @@ -112,8 +114,8 @@ public void testRequestParams5() { PartialViewContext pprContext = context.getPartialViewContext(); - Assertions.assertTrue(pprContext.getRenderIds().size() == 1); - Assertions.assertTrue(pprContext.getRenderIds().iterator().next().equals("view1:panel1:_component1")); + assertEquals(1, pprContext.getRenderIds().size()); + assertEquals("view1:panel1:_component1", pprContext.getRenderIds().iterator().next()); } /** @@ -121,7 +123,7 @@ public void testRequestParams5() { * blank chars */ @Test - public void testRequestParams6() { + void requestParams6() { String params = " view1:panel1:_component1 view1:panel1:_component2 \n component3 component4 "; Map requestParamMap = new HashMap(); requestParamMap.put(PartialViewContext.PARTIAL_RENDER_PARAM_NAME, params); @@ -131,7 +133,7 @@ public void testRequestParams6() { PartialViewContext pprContext = context.getPartialViewContext(); - Assertions.assertTrue(pprContext.getRenderIds().size() == 4); + assertEquals(4, pprContext.getRenderIds().size()); // FIXME: Latest spec uses a Collection so order is not guaranteed // Assertions.assertTrue("Value match",pprContext.getRenderIds().get(0).equals("view1:panel1:_component1")); @@ -146,7 +148,7 @@ public void testRequestParams6() { * cannot be inflated with repeated ids. */ @Test - public void testDuplicateClientIdsAreCollapsed() { + void duplicateClientIdsAreCollapsed() { String params = "form:input form:input form:input"; Map requestParamMap = new HashMap(); requestParamMap.put(PartialViewContext.PARTIAL_RENDER_PARAM_NAME, params); @@ -156,8 +158,8 @@ public void testDuplicateClientIdsAreCollapsed() { PartialViewContext pprContext = context.getPartialViewContext(); - Assertions.assertEquals(1, pprContext.getRenderIds().size()); - Assertions.assertTrue(pprContext.getRenderIds().contains("form:input")); + assertEquals(1, pprContext.getRenderIds().size()); + assertTrue(pprContext.getRenderIds().contains("form:input")); } /** @@ -165,7 +167,7 @@ public void testDuplicateClientIdsAreCollapsed() { * of NamingContainer separators) must not be expanded into a PartialVisitContext. */ @Test - public void testOverlongClientIdIsRejected() { + void overlongClientIdIsRejected() { StringBuilder colons = new StringBuilder(); for (int i = 0; i < 100000; i++) { colons.append(':'); @@ -178,14 +180,14 @@ public void testOverlongClientIdIsRejected() { PartialViewContext pprContext = context.getPartialViewContext(); - Assertions.assertTrue(pprContext.getRenderIds().isEmpty()); + assertTrue(pprContext.getRenderIds().isEmpty()); } /** * the number of client ids read from the request is capped. */ @Test - public void testClientIdCountIsCapped() { + void clientIdCountIsCapped() { StringBuilder params = new StringBuilder(); for (int i = 0; i < 5000; i++) { params.append("id").append(i).append(' '); @@ -198,6 +200,6 @@ public void testClientIdCountIsCapped() { PartialViewContext pprContext = context.getPartialViewContext(); - Assertions.assertEquals(256, pprContext.getRenderIds().size()); + assertEquals(256, pprContext.getRenderIds().size()); } } diff --git a/impl/src/test/java/org/apache/myfaces/context/ResponseWrapperSwitchTest.java b/impl/src/test/java/org/apache/myfaces/context/ResponseWrapperSwitchTest.java index cc31b49262..96311c67ed 100644 --- a/impl/src/test/java/org/apache/myfaces/context/ResponseWrapperSwitchTest.java +++ b/impl/src/test/java/org/apache/myfaces/context/ResponseWrapperSwitchTest.java @@ -15,6 +15,8 @@ */ package org.apache.myfaces.context; +import static org.junit.jupiter.api.Assertions.*; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -42,7 +44,7 @@ * @author Werner Punz(latest modification by $Author$) * @version $Revision$ $Date$ */ -public class ResponseWrapperSwitchTest extends AbstractFacesTestCase { +class ResponseWrapperSwitchTest extends AbstractFacesTestCase { @Override @BeforeEach @@ -155,7 +157,7 @@ public void setWriteListener(WriteListener wl) * response */ @Test - public void testSwitchOnWriter() { + void switchOnWriter() { ByteArrayOutputStream ostr = new ByteArrayOutputStream(); ByteArrayOutputStream ostrWriter = new ByteArrayOutputStream(); @@ -166,30 +168,23 @@ public void testSwitchOnWriter() { FacesContext context = new FacesContextImpl(servletContext, request, resp); - ResponseWriter responseWriter = context.getResponseWriter(); - if (responseWriter == null) { - try { - responseWriter = new MockResponseWriter(((ServletResponse) context.getExternalContext().getResponse()).getWriter(), null, null); - } catch (IOException ex) { - Assertions.fail(ex.getMessage()); - } - context.setResponseWriter(responseWriter); + if (context.getResponseWriter() == null) { + ResponseWriter newResponseWriter = Assertions.assertDoesNotThrow(() -> + new MockResponseWriter(((ServletResponse) context.getExternalContext().getResponse()).getWriter(), null, null)); + context.setResponseWriter(newResponseWriter); } + ResponseWriter responseWriter = context.getResponseWriter(); + assertTrue(responseWriter != null); - - Assertions.assertTrue(responseWriter != null); - - try { + Assertions.assertDoesNotThrow(() -> { responseWriter.append("hello world"); responseWriter.flush(); responseWriter.close(); - } catch (IOException ex) { - Assertions.fail(ex.getMessage()); - } + }); - Assertions.assertTrue(ostrWriter.toString().trim().equals("hello world")); + assertEquals("hello world", ostrWriter.toString().trim()); } diff --git a/impl/src/test/java/org/apache/myfaces/context/TestIsAjaxRequest.java b/impl/src/test/java/org/apache/myfaces/context/TestIsAjaxRequest.java index 10903e9430..0e70a9c23c 100644 --- a/impl/src/test/java/org/apache/myfaces/context/TestIsAjaxRequest.java +++ b/impl/src/test/java/org/apache/myfaces/context/TestIsAjaxRequest.java @@ -16,13 +16,15 @@ package org.apache.myfaces.context; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Map; import jakarta.faces.FactoryFinder; import jakarta.faces.context.FacesContext; import org.apache.myfaces.context.servlet.FacesContextImpl; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -52,15 +54,15 @@ public void setUp() throws Exception { } @Test - public void testNoEntry() { + void noEntry() { - Assertions.assertFalse(context.getPartialViewContext().isAjaxRequest()); + assertFalse(context.getPartialViewContext().isAjaxRequest()); } public void testEntry() { request.addHeader("Faces-Request", "partial/ajax"); request.addParameter("jakarta.faces.partial.ajax","true"); - Assertions.assertTrue(context.getPartialViewContext().isAjaxRequest()); + assertTrue(context.getPartialViewContext().isAjaxRequest()); } } diff --git a/impl/src/test/java/org/apache/myfaces/context/flash/FlashImplTest.java b/impl/src/test/java/org/apache/myfaces/context/flash/FlashImplTest.java index 854d7ccc4b..7d8e6101fd 100644 --- a/impl/src/test/java/org/apache/myfaces/context/flash/FlashImplTest.java +++ b/impl/src/test/java/org/apache/myfaces/context/flash/FlashImplTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.context.flash; +import static org.junit.jupiter.api.Assertions.*; + import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -33,7 +35,6 @@ import org.apache.myfaces.test.mock.MockHttpServletRequest; import org.apache.myfaces.test.mock.MockHttpServletResponse; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -83,7 +84,7 @@ public void tearDown() throws Exception * @throws Exception */ @Test - public void testSessionMapWrapperSubKeyMap() throws Exception + void sessionMapWrapperSubKeyMap() throws Exception { // set phase to RESTORE_VIEW to create the flash tokens on doPrePhaseActions() facesContext.setCurrentPhaseId(PhaseId.RESTORE_VIEW); @@ -103,16 +104,16 @@ public void testSessionMapWrapperSubKeyMap() throws Exception FlashImpl.SEPARATOR_CHAR + renderToken + FlashImpl.SEPARATOR_CHAR + "testkey1"; // Assertion - Assertions.assertEquals("testvalue1", session.getAttribute(sessionMapKey)); + assertEquals("testvalue1", session.getAttribute(sessionMapKey)); } - + /** * Tests the functionality of keep() in a normal postback scenario. * @throws Exception */ @SuppressWarnings("unchecked") @Test - public void testKeepValueNormalPostback() throws Exception + void keepValueNormalPostback() throws Exception { // simulate Faces lifecycle: // note that doPrePhaseActions() only performs tasks on RESTORE_VIEW @@ -172,7 +173,7 @@ public void testKeepValueNormalPostback() throws Exception // _flash.get() will ask the execute FlashMap for the value // and this must be the render FlashMap of the previous request, // thus it must contain the value from the previous request. - Assertions.assertEquals("flashvalue", _flash.get("flashkey")); + assertEquals("flashvalue", _flash.get("flashkey")); // simulate Faces lifecycle facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE); @@ -180,23 +181,23 @@ public void testKeepValueNormalPostback() throws Exception // _flash.get() also references to the execute FlashMap, but // this one has to be cleared by now, thus it must be null. - Assertions.assertNull(_flash.get("flashkey")); + assertNull(_flash.get("flashkey")); // get the execute Map of the second postback (FlashImpl internals) Map executeMap = (Map) externalContext .getRequestMap().get(FlashImpl.FLASH_EXECUTE_MAP); // must be empty - Assertions.assertTrue(executeMap.isEmpty(), "The execute Map of the second postback must have been cleared"); + assertTrue(executeMap.isEmpty(), "The execute Map of the second postback must have been cleared"); } - + /** * Tests the functionality of keep() in a POST-REDIRECT-GET scenario. * @throws Exception */ @SuppressWarnings("unchecked") @Test - public void testKeepValuePostRedirectGet() throws Exception + void keepValuePostRedirectGet() throws Exception { // simulate Faces lifecycle: // note that doPrePhaseActions() only performs tasks on RESTORE_VIEW @@ -237,7 +238,7 @@ public void testKeepValuePostRedirectGet() throws Exception // set redirect to true, this happens by the NavigationHandler in phase 5 _flash.setRedirect(true); - Assertions.assertTrue(_flash.isRedirect()); + assertTrue(_flash.isRedirect()); // note that setRedirect(true) was called, thus the cleanup happens // in phase 5, because doPostPhaseActions() won't be called on phase 6. @@ -258,7 +259,7 @@ public void testKeepValuePostRedirectGet() throws Exception _flash.doPrePhaseActions(facesContext); // check isRedirect(); - Assertions.assertTrue(_flash.isRedirect(), "setRedirect(true) was called on the previous request, " + assertTrue(_flash.isRedirect(), "setRedirect(true) was called on the previous request, " + " and we are in the execute portion of the lifecycle, " + " thus isRedirect() must be true."); @@ -266,13 +267,13 @@ public void testKeepValuePostRedirectGet() throws Exception facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE); // check isRedirect(); - Assertions.assertFalse(_flash.isRedirect(), "setRedirect(true) was called on the previous request, " + assertFalse(_flash.isRedirect(), "setRedirect(true) was called on the previous request, " + " but we are already in the render portion of the lifecycle, " + " thus isRedirect() must be false."); // _flash.get() will ask the execute FlashMap and this one // must contain the key used in keep() - Assertions.assertEquals("flashvalue", _flash.get("flashkey")); + assertEquals("flashvalue", _flash.get("flashkey")); _flash.doPostPhaseActions(facesContext); @@ -292,7 +293,7 @@ public void testKeepValuePostRedirectGet() throws Exception facesContext.setCurrentPhaseId(PhaseId.INVOKE_APPLICATION); // check isRedirect(); - Assertions.assertFalse(_flash.isRedirect(), "setRedirect(true) was called on the pre-previous request, " + assertFalse(_flash.isRedirect(), "setRedirect(true) was called on the pre-previous request, " + " thus isRedirect() must be false again."); // _flash.get() will ask the execute FlashMap for the value @@ -300,7 +301,7 @@ public void testKeepValuePostRedirectGet() throws Exception // thus it must not contain the value from the previous request, // because the value was on the previous request's execute FlashMap // and not on the previous request's render FlashMap. - Assertions.assertNull(_flash.get("flashkey")); + assertNull(_flash.get("flashkey")); // simulate Faces lifecycle facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE); @@ -311,15 +312,15 @@ public void testKeepValuePostRedirectGet() throws Exception .getRequestMap().get(FlashImpl.FLASH_EXECUTE_MAP); // must be empty - Assertions.assertTrue(executeMap.isEmpty(), "The execute Map of the second postback must have been cleared"); + assertTrue(executeMap.isEmpty(), "The execute Map of the second postback must have been cleared"); } - + /** * Tests the functionality of keepMessages in a normal postback scenario. * @throws Exception */ @Test - public void testKeepMessagesNormalPostback() throws Exception + void keepMessagesNormalPostback() throws Exception { // simulate Faces lifecycle: // note that doPrePhaseActions() only performs tasks on RESTORE_VIEW @@ -360,12 +361,12 @@ public void testKeepMessagesNormalPostback() throws Exception facesContext.addMessage(null, messageNoClientId); // now the FacesContext must contain 2 messages - Assertions.assertEquals(2, facesContext.getMessageList().size()); + assertEquals(2, facesContext.getMessageList().size()); // keep messages _flash.setKeepMessages(true); - Assertions.assertTrue(_flash.isKeepMessages(), "setKeepMessages(true) was just called, thus isKeepMessages() " + assertTrue(_flash.isKeepMessages(), "setKeepMessages(true) was just called, thus isKeepMessages() " + "must be true."); // simulate Faces lifecycle @@ -381,18 +382,18 @@ public void testKeepMessagesNormalPostback() throws Exception facesContext.setPostback(true); // now the FacesContext must contain 0 messages (new request, new FacesContext) - Assertions.assertEquals(0, facesContext.getMessageList().size()); + assertEquals(0, facesContext.getMessageList().size()); // simulate Faces lifecycle facesContext.setCurrentPhaseId(PhaseId.RESTORE_VIEW); _flash.doPrePhaseActions(facesContext); // now the messages must be here again - Assertions.assertEquals(2, facesContext.getMessageList().size()); - Assertions.assertEquals(Arrays.asList(messageClientId), facesContext.getMessageList("clientId")); - Assertions.assertEquals(Arrays.asList(messageNoClientId), facesContext.getMessageList(null)); + assertEquals(2, facesContext.getMessageList().size()); + assertEquals(Arrays.asList(messageClientId), facesContext.getMessageList("clientId")); + assertEquals(Arrays.asList(messageNoClientId), facesContext.getMessageList(null)); - Assertions.assertFalse(_flash.isKeepMessages(), "setKeepMessages(true) was not called on this request, thus " + assertFalse(_flash.isKeepMessages(), "setKeepMessages(true) was not called on this request, thus " + "isKeepMessages() must be false."); // simulate Faces lifecycle @@ -408,7 +409,7 @@ public void testKeepMessagesNormalPostback() throws Exception facesContext.setPostback(true); // now the FacesContext must contain 0 messages (new request, new FacesContext) - Assertions.assertEquals(0, facesContext.getMessageList().size()); + assertEquals(0, facesContext.getMessageList().size()); // simulate Faces lifecycle facesContext.setCurrentPhaseId(PhaseId.RESTORE_VIEW); @@ -416,13 +417,13 @@ public void testKeepMessagesNormalPostback() throws Exception // the messages must still be gone here, because setKeepMessages(true) // was not called on the previous request - Assertions.assertEquals(0, facesContext.getMessageList().size()); + assertEquals(0, facesContext.getMessageList().size()); // simulate Faces lifecycle facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE); _flash.doPostPhaseActions(facesContext); } - + /** * Tests the functionality of keepMessages in a POST-REDIRECT-GET scenario. * In this test case the messages are only shipped from the POST to the GET and @@ -430,7 +431,7 @@ public void testKeepMessagesNormalPostback() throws Exception * @throws Exception */ @Test - public void testKeepMessagesPostRedirectGet() throws Exception + void keepMessagesPostRedirectGet() throws Exception { // simulate Faces lifecycle: // note that doPrePhaseActions() only performs tasks on RESTORE_VIEW @@ -471,16 +472,16 @@ public void testKeepMessagesPostRedirectGet() throws Exception facesContext.addMessage(null, messageNoClientId); // now the FacesContext must contain 2 messages - Assertions.assertEquals(2, facesContext.getMessageList().size()); + assertEquals(2, facesContext.getMessageList().size()); // keep messages _flash.setKeepMessages(true); - Assertions.assertTrue(_flash.isKeepMessages(), "setKeepMessages(true) was just called, thus isKeepMessages() " + assertTrue(_flash.isKeepMessages(), "setKeepMessages(true) was just called, thus isKeepMessages() " + "must be true."); // set redirect to true, this happens by the NavigationHandler in phase 5 _flash.setRedirect(true); - Assertions.assertTrue(_flash.isRedirect(), "setRedirect(true) was just called, thus isRedirect() must be true"); + assertTrue(_flash.isRedirect(), "setRedirect(true) was just called, thus isRedirect() must be true"); // The redirect cause responseComplete() method to be called. facesContext.responseComplete(); // note that setRedirect(true) was called, thus the cleanup happens @@ -496,7 +497,7 @@ public void testKeepMessagesPostRedirectGet() throws Exception facesContext.setPostback(false); // now the FacesContext must contain 0 messages (new request, new FacesContext) - Assertions.assertEquals(0, facesContext.getMessageList().size()); + assertEquals(0, facesContext.getMessageList().size()); // simulate Faces lifecycle // Note that doPrePhaseActions() is called on RESTORE_VIEW even @@ -508,12 +509,12 @@ public void testKeepMessagesPostRedirectGet() throws Exception facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE); // now the messages must be here again - Assertions.assertEquals(2, facesContext.getMessageList().size()); - Assertions.assertEquals(Arrays.asList(messageClientId), facesContext.getMessageList("clientId")); - Assertions.assertEquals(Arrays.asList(messageNoClientId), facesContext.getMessageList(null)); + assertEquals(2, facesContext.getMessageList().size()); + assertEquals(Arrays.asList(messageClientId), facesContext.getMessageList("clientId")); + assertEquals(Arrays.asList(messageNoClientId), facesContext.getMessageList(null)); // check isKeepMessages() - Assertions.assertFalse(_flash.isKeepMessages()); + assertFalse(_flash.isKeepMessages()); _flash.doPostPhaseActions(facesContext); @@ -526,7 +527,7 @@ public void testKeepMessagesPostRedirectGet() throws Exception facesContext.setPostback(true); // now the FacesContext must contain 0 messages (new request, new FacesContext) - Assertions.assertEquals(0, facesContext.getMessageList().size()); + assertEquals(0, facesContext.getMessageList().size()); // simulate Faces lifecycle facesContext.setCurrentPhaseId(PhaseId.RESTORE_VIEW); @@ -537,13 +538,13 @@ public void testKeepMessagesPostRedirectGet() throws Exception // now the FacesContext must contain 0 messages, because // setKeepMessages(true) was not called on the GET-request - Assertions.assertEquals(0, facesContext.getMessageList().size()); + assertEquals(0, facesContext.getMessageList().size()); // simulate Faces lifecycle facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE); _flash.doPostPhaseActions(facesContext); } - + /** * Tests the functionality of keepMessages in a POST-REDIRECT-GET scenario. * In this test case the messages are shipped from the POST to the GET and @@ -551,7 +552,7 @@ public void testKeepMessagesPostRedirectGet() throws Exception * @throws Exception */ @Test - public void testKeepMessagesPostRedirectGetTwoTimes() throws Exception + void keepMessagesPostRedirectGetTwoTimes() throws Exception { // simulate Faces lifecycle: // note that doPrePhaseActions() only performs tasks on RESTORE_VIEW @@ -592,15 +593,15 @@ public void testKeepMessagesPostRedirectGetTwoTimes() throws Exception facesContext.addMessage(null, messageNoClientId); // now the FacesContext must contain 2 messages - Assertions.assertEquals(2, facesContext.getMessageList().size()); + assertEquals(2, facesContext.getMessageList().size()); // keep messages _flash.setKeepMessages(true); - Assertions.assertTrue(_flash.isKeepMessages()); + assertTrue(_flash.isKeepMessages()); // set redirect to true, this happens by the NavigationHandler in phase 5 _flash.setRedirect(true); - Assertions.assertTrue(_flash.isRedirect()); + assertTrue(_flash.isRedirect()); // The redirect cause responseComplete() method to be called. facesContext.responseComplete(); @@ -617,7 +618,7 @@ public void testKeepMessagesPostRedirectGetTwoTimes() throws Exception facesContext.setPostback(false); // now the FacesContext must contain 0 messages (new request, new FacesContext) - Assertions.assertEquals(0, facesContext.getMessageList().size()); + assertEquals(0, facesContext.getMessageList().size()); // simulate Faces lifecycle // Note that doPrePhaseActions() is called on RESTORE_VIEW even @@ -629,17 +630,17 @@ public void testKeepMessagesPostRedirectGetTwoTimes() throws Exception facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE); // now the messages must be here again - Assertions.assertEquals(2, facesContext.getMessageList().size()); - Assertions.assertEquals(Arrays.asList(messageClientId), facesContext.getMessageList("clientId")); - Assertions.assertEquals(Arrays.asList(messageNoClientId), facesContext.getMessageList(null)); + assertEquals(2, facesContext.getMessageList().size()); + assertEquals(Arrays.asList(messageClientId), facesContext.getMessageList("clientId")); + assertEquals(Arrays.asList(messageNoClientId), facesContext.getMessageList(null)); // check isKeepMessages() - Assertions.assertFalse(_flash.isKeepMessages(), "setKeepMessages(true) was not called on this request, thus " + assertFalse(_flash.isKeepMessages(), "setKeepMessages(true) was not called on this request, thus " + "isKeepMessages() must be false."); // keep messages - again _flash.setKeepMessages(true); - Assertions.assertTrue(_flash.isKeepMessages(), "setKeepMessages(true) was just called, thus isKeepMessages() " + assertTrue(_flash.isKeepMessages(), "setKeepMessages(true) was just called, thus isKeepMessages() " + "must be true."); // The redirect cause responseComplete() method to be called. facesContext.responseComplete(); @@ -655,7 +656,7 @@ public void testKeepMessagesPostRedirectGetTwoTimes() throws Exception facesContext.setPostback(true); // now the FacesContext must contain 0 messages (new request, new FacesContext) - Assertions.assertEquals(0, facesContext.getMessageList().size()); + assertEquals(0, facesContext.getMessageList().size()); // simulate Faces lifecycle facesContext.setCurrentPhaseId(PhaseId.RESTORE_VIEW); @@ -665,9 +666,9 @@ public void testKeepMessagesPostRedirectGetTwoTimes() throws Exception facesContext.setCurrentPhaseId(PhaseId.INVOKE_APPLICATION); // now the messages must be here again - Assertions.assertEquals(2, facesContext.getMessageList().size()); - Assertions.assertEquals(Arrays.asList(messageClientId), facesContext.getMessageList("clientId")); - Assertions.assertEquals(Arrays.asList(messageNoClientId), facesContext.getMessageList(null)); + assertEquals(2, facesContext.getMessageList().size()); + assertEquals(Arrays.asList(messageClientId), facesContext.getMessageList("clientId")); + assertEquals(Arrays.asList(messageNoClientId), facesContext.getMessageList(null)); // simulate Faces lifecycle facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE); @@ -682,7 +683,7 @@ public void testKeepMessagesPostRedirectGetTwoTimes() throws Exception facesContext.setPostback(true); // now the FacesContext must contain 0 messages (new request, new FacesContext) - Assertions.assertEquals(0, facesContext.getMessageList().size()); + assertEquals(0, facesContext.getMessageList().size()); // simulate Faces lifecycle facesContext.setCurrentPhaseId(PhaseId.RESTORE_VIEW); @@ -693,69 +694,69 @@ public void testKeepMessagesPostRedirectGetTwoTimes() throws Exception // now the FacesContext must contain 0 messages, because // setKeepMessages(true) was not called on the previous postback - Assertions.assertEquals(0, facesContext.getMessageList().size()); + assertEquals(0, facesContext.getMessageList().size()); // simulate Faces lifecycle facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE); _flash.doPostPhaseActions(facesContext); } - + /** * Test if setRedirect(true) works via _flash.put("redirect", true) * and if isRedirect() is equal to _flash.get("redirect"). */ @Test - public void testSetRedirect() + void setRedirect() { - Assertions.assertFalse(_flash.isRedirect()); - Assertions.assertFalse((Boolean) _flash.get("redirect")); + assertFalse(_flash.isRedirect()); + assertFalse((Boolean) _flash.get("redirect")); _flash.put("redirect", true); - Assertions.assertTrue(_flash.isRedirect()); - Assertions.assertTrue((Boolean) _flash.get("redirect")); + assertTrue(_flash.isRedirect()); + assertTrue((Boolean) _flash.get("redirect")); } - + /** * Test if setKeepMessages(true) works via _flash.put("keepMessages", true) * and if isKeepMessages() is equal to _flash.get("keepMessages"). */ @Test - public void testSetKeepMessages() + void setKeepMessages() { - Assertions.assertFalse(_flash.isKeepMessages()); - Assertions.assertFalse((Boolean) _flash.get("keepMessages")); + assertFalse(_flash.isKeepMessages()); + assertFalse((Boolean) _flash.get("keepMessages")); _flash.put("keepMessages", true); - Assertions.assertTrue(_flash.isKeepMessages()); - Assertions.assertTrue((Boolean) _flash.get("keepMessages")); + assertTrue(_flash.isKeepMessages()); + assertTrue((Boolean) _flash.get("keepMessages")); } - + /** * Tests the functionality of putNow(). */ @SuppressWarnings("unchecked") @Test - public void testPutNow() + void putNow() { Map requestMap = externalContext.getRequestMap(); // requestMap must NOT contain the key - Assertions.assertNull(requestMap.get("flashkey")); + assertNull(requestMap.get("flashkey")); _flash.putNow("flashkey", "flashvalue"); // requestMap must contain the key - Assertions.assertEquals("flashvalue", requestMap.get("flashkey")); + assertEquals("flashvalue", requestMap.get("flashkey")); } - + /** * Tests keep() * @throws Exception */ @Test - public void testKeep() throws Exception + void keep() throws Exception { // simulate Faces lifecycle: // note that doPrePhaseActions() only performs tasks on RESTORE_VIEW @@ -817,7 +818,7 @@ public void testKeep() throws Exception facesContext.setCurrentPhaseId(PhaseId.INVOKE_APPLICATION); // the value must be in the executeMap - Assertions.assertEquals("flashvalue", _flash.get("flashkey")); + assertEquals("flashvalue", _flash.get("flashkey")); // simulate Faces lifecycle facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE); @@ -825,13 +826,13 @@ public void testKeep() throws Exception // cleanup flash _flash.doPostPhaseActions(facesContext); } - + /** * Like testKeep(), but without calling keep() to keep the value. * @throws Exception */ @Test - public void testNotKeep() throws Exception + void notKeep() throws Exception { // simulate Faces lifecycle: // note that doPrePhaseActions() only performs tasks on RESTORE_VIEW @@ -891,7 +892,7 @@ public void testNotKeep() throws Exception facesContext.setCurrentPhaseId(PhaseId.INVOKE_APPLICATION); // render FlashMap must be empty - Assertions.assertNull(_flash.get("flashkey")); + assertNull(_flash.get("flashkey")); // simulate Faces lifecycle facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE); @@ -899,13 +900,13 @@ public void testNotKeep() throws Exception // cleanup flash _flash.doPostPhaseActions(facesContext); } - + /** * Tests if the reading functions use _getFlashMapForReading() * and if the writing functions use _getFlashMapForWriting(). */ @Test - public void testMapMethodsUseDifferentMaps() throws Exception + void mapMethodsUseDifferentMaps() throws Exception { // simulate Faces lifecycle: // note that doPrePhaseActions() only performs tasks on RESTORE_VIEW @@ -942,7 +943,7 @@ public void testMapMethodsUseDifferentMaps() throws Exception // in this configuration put() and get() are executed on different maps // there must not be a value with the key "flashkey" - Assertions.assertNull(_flash.get("flashkey")); + assertNull(_flash.get("flashkey")); // put() always references the active FlashMap, // which is the render FlashMap in this case (phase is render response) @@ -950,16 +951,16 @@ public void testMapMethodsUseDifferentMaps() throws Exception // there must still not be a value with the key "flashkey" // NOTE that get still references the execute FlashMap - Assertions.assertNull(_flash.get("flashkey")); + assertNull(_flash.get("flashkey")); _flash.doPostPhaseActions(facesContext); } - + /** * Tests the implementation of the methods from the java.util.Map interface. */ @Test - public void testMapMethods() + void mapMethods() { // ensure that _getActiveFlashMap() returns the execute FlashMap facesContext.setCurrentPhaseId(PhaseId.RESTORE_VIEW); @@ -1006,13 +1007,13 @@ public void testMapMethods() */ private void _noElementAssertions() { - Assertions.assertTrue(_flash.isEmpty()); - Assertions.assertEquals(0, _flash.size()); - Assertions.assertFalse(_flash.containsKey("flashkey")); - Assertions.assertFalse(_flash.containsValue("flashvalue")); - Assertions.assertEquals(Collections.emptySet(), _flash.keySet()); - Assertions.assertNull(_flash.get("flashkey")); - Assertions.assertTrue(_flash.values().isEmpty()); + assertTrue(_flash.isEmpty()); + assertEquals(0, _flash.size()); + assertFalse(_flash.containsKey("flashkey")); + assertFalse(_flash.containsValue("flashvalue")); + assertEquals(Collections.emptySet(), _flash.keySet()); + assertNull(_flash.get("flashkey")); + assertTrue(_flash.values().isEmpty()); } /** @@ -1020,13 +1021,13 @@ private void _noElementAssertions() */ private void _oneElementAssertions() { - Assertions.assertFalse(_flash.isEmpty()); - Assertions.assertEquals(1, _flash.size()); - Assertions.assertTrue(_flash.containsKey("flashkey")); - Assertions.assertTrue(_flash.containsValue("flashvalue")); - Assertions.assertEquals(new HashSet(Arrays.asList("flashkey")), _flash.keySet()); - Assertions.assertEquals("flashvalue", _flash.get("flashkey")); - Assertions.assertTrue(_flash.containsValue("flashvalue")); + assertFalse(_flash.isEmpty()); + assertEquals(1, _flash.size()); + assertTrue(_flash.containsKey("flashkey")); + assertTrue(_flash.containsValue("flashvalue")); + assertEquals(new HashSet(Arrays.asList("flashkey")), _flash.keySet()); + assertEquals("flashvalue", _flash.get("flashkey")); + assertTrue(_flash.containsValue("flashvalue")); } /** @@ -1042,7 +1043,7 @@ private void _simulateNewRequest() throws Exception Cookie renderTokenCookie = response.getCookie(FlashImpl.FLASH_RENDER_MAP_TOKEN); // the Cookie must exist - Assertions.assertNotNull(renderTokenCookie); + assertNotNull(renderTokenCookie); // check for the redirect-cookie Cookie redirectCookie = response.getCookie(FlashImpl.FLASH_REDIRECT); diff --git a/impl/src/test/java/org/apache/myfaces/context/servlet/FacesContextImplBaseTest.java b/impl/src/test/java/org/apache/myfaces/context/servlet/FacesContextImplBaseTest.java index 6ea3270d32..03e596ae8c 100644 --- a/impl/src/test/java/org/apache/myfaces/context/servlet/FacesContextImplBaseTest.java +++ b/impl/src/test/java/org/apache/myfaces/context/servlet/FacesContextImplBaseTest.java @@ -18,11 +18,12 @@ */ package org.apache.myfaces.context.servlet; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.util.Map; +import static org.junit.jupiter.api.Assertions.assertEquals; + import jakarta.faces.component.UIViewRoot; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; @@ -34,14 +35,14 @@ * @author Bill Lucy (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class FacesContextImplBaseTest extends AbstractFaceletTestCase { +class FacesContextImplBaseTest extends AbstractFaceletTestCase { /** * Verify that the Map returned by UIViewRoot.getViewMap() is cleared when a new view root is set, * as required in 4.1.19.2 */ @Test - public void testViewMapCleared() throws Exception + void viewMapCleared() throws Exception { // don't use MockFacesServletContext here FacesContextImpl fci = new FacesContextImpl(facesContext.getExternalContext(), null, null); @@ -53,7 +54,7 @@ public void testViewMapCleared() throws Exception // set a new view root, which will cause the old view root's ViewMap to be cleared if BUILDING_VIEW_METADATA is not set fci.setViewRoot(secondRoot); - Assertions.assertEquals(0, viewMap.size(), "The ViewMap was not cleared as expected"); + assertEquals(0, viewMap.size(), "The ViewMap was not cleared as expected"); } /** @@ -61,7 +62,7 @@ public void testViewMapCleared() throws Exception * BUILDING_VIEW_METADATA attribute is set. See MYFACES-4282. */ @Test - public void testViewMapNotClearedWhileBuildingViewMetadata() throws Exception + void viewMapNotClearedWhileBuildingViewMetadata() throws Exception { FacesContextImpl fci = new FacesContextImpl(facesContext.getExternalContext(), null, null); UIViewRoot firstRoot = new UIViewRoot(); @@ -73,6 +74,6 @@ public void testViewMapNotClearedWhileBuildingViewMetadata() throws Exception // set a new view root - the old view root's ViewMap should NOT be cleared fci.setViewRoot(secondRoot); - Assertions.assertEquals(1, viewMap.size(), "The ViewMap was incorrectly cleared while the BUILDING_VIEW_METADATA attribute was set"); + assertEquals(1, viewMap.size(), "The ViewMap was incorrectly cleared while the BUILDING_VIEW_METADATA attribute was set"); } } diff --git a/impl/src/test/java/org/apache/myfaces/context/servlet/ServletExternalContextImplTest.java b/impl/src/test/java/org/apache/myfaces/context/servlet/ServletExternalContextImplTest.java index 0d1dd4a67c..ff83a1a4a6 100644 --- a/impl/src/test/java/org/apache/myfaces/context/servlet/ServletExternalContextImplTest.java +++ b/impl/src/test/java/org/apache/myfaces/context/servlet/ServletExternalContextImplTest.java @@ -18,13 +18,14 @@ */ package org.apache.myfaces.context.servlet; -import java.io.IOException; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.Writer; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.apache.myfaces.test.mock.MockPrintWriter; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -35,7 +36,7 @@ * @author Jakob Korherr (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class ServletExternalContextImplTest extends AbstractFacesTestCase +class ServletExternalContextImplTest extends AbstractFacesTestCase { private ServletExternalContextImpl _testExternalContext; @@ -57,7 +58,7 @@ public void tearDown() throws Exception super.tearDown(); } - + /** * Tests if encodeRedirectURL() and encodeBookmarkableURL() correctly * evaluate ValueExpressions as parameters values. @@ -95,7 +96,7 @@ public void testEncodeURLHandlesValueExpressionParameters() }*/ @Test - public void testEncodeRedirectUrlWithEmptyParamInBaseUrl() + void encodeRedirectUrlWithEmptyParamInBaseUrl() { // query parameter p1 has an empty value String baseUrl = "/test?p1=&p2=test"; @@ -104,13 +105,13 @@ public void testEncodeRedirectUrlWithEmptyParamInBaseUrl() final String redirectUrl = _testExternalContext.encodeRedirectURL(baseUrl, null); // the URL should not change - Assertions.assertTrue(redirectUrl.contains("p1=")); - Assertions.assertTrue(redirectUrl.contains("p2=test")); + assertTrue(redirectUrl.contains("p1=")); + assertTrue(redirectUrl.contains("p2=test")); } @Test - public void testEncodedSpaceInExistingQueryParameter() + void encodedSpaceInExistingQueryParameter() { // the base URL with an existing encoded query parameter String baseUrl = "/test?p1=a+b"; @@ -119,12 +120,12 @@ public void testEncodedSpaceInExistingQueryParameter() final String redirectUrl = _testExternalContext.encodeRedirectURL(baseUrl, null); // the URL should not change - Assertions.assertEquals(baseUrl, redirectUrl); + assertEquals(baseUrl, redirectUrl); } - + @Test - public void testEncodedAmpersandInExistingQueryParameter() + void encodedAmpersandInExistingQueryParameter() { // the base URL with an existing encoded query parameter String baseUrl = "/test?p1=a%26b"; @@ -133,12 +134,12 @@ public void testEncodedAmpersandInExistingQueryParameter() final String redirectUrl = _testExternalContext.encodeRedirectURL(baseUrl, null); // the URL should not change - Assertions.assertEquals(baseUrl, redirectUrl); + assertEquals(baseUrl, redirectUrl); } @Test - public void testSameParameterNames() + void sameParameterNames() { String baseUrl = "/test?par=test1&par=test2"; @@ -146,8 +147,8 @@ public void testSameParameterNames() final String redirectUrl = _testExternalContext.encodeRedirectURL(baseUrl, null); // the URL should not change - Assertions.assertTrue(redirectUrl.contains("par=test1")); - Assertions.assertTrue(redirectUrl.contains("par=test2")); + assertTrue(redirectUrl.contains("par=test1")); + assertTrue(redirectUrl.contains("par=test2")); } @@ -157,7 +158,7 @@ public void testSameParameterNames() * discarded, everything written after it must still reach the container writer. */ @Test - public void testResponseResetDiscardsBufferedOutputButKeepsWriterUsable() throws IOException + void responseResetDiscardsBufferedOutputButKeepsWriterUsable() throws Exception { Writer writer = _testExternalContext.getResponseOutputWriter(); writer.write("aborted response"); @@ -166,6 +167,6 @@ public void testResponseResetDiscardsBufferedOutputButKeepsWriterUsable() throws writer.write("error page"); writer.flush(); - Assertions.assertEquals("error page", String.valueOf(((MockPrintWriter) response.getWriter()).content())); + assertEquals("error page", String.valueOf(((MockPrintWriter) response.getWriter()).content())); } } diff --git a/impl/src/test/java/org/apache/myfaces/core/api/shared/ParametrizableFacesMessageTest.java b/impl/src/test/java/org/apache/myfaces/core/api/shared/ParametrizableFacesMessageTest.java index db8c4ffb78..1ab4fbee1e 100644 --- a/impl/src/test/java/org/apache/myfaces/core/api/shared/ParametrizableFacesMessageTest.java +++ b/impl/src/test/java/org/apache/myfaces/core/api/shared/ParametrizableFacesMessageTest.java @@ -18,19 +18,21 @@ */ package org.apache.myfaces.core.api.shared; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + import java.util.LinkedHashSet; import java.util.Locale; import java.util.Set; import jakarta.faces.application.FacesMessage; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class ParametrizableFacesMessageTest +class ParametrizableFacesMessageTest { @Test - public void testMessagesWithDifferentParametersAreNotEqual() + void messagesWithDifferentParametersAreNotEqual() { FacesMessage firstMessage = new ParametrizableFacesMessage( FacesMessage.Severity.ERROR, @@ -49,12 +51,12 @@ public void testMessagesWithDifferentParametersAreNotEqual() messages.add(firstMessage); messages.add(secondMessage); - Assertions.assertNotEquals(firstMessage, secondMessage); - Assertions.assertEquals(2, messages.size()); + assertNotEquals(firstMessage, secondMessage); + assertEquals(2, messages.size()); } @Test - public void testMessagesWithSameParametersAreEqual() + void messagesWithSameParametersAreEqual() { FacesMessage firstMessage = new ParametrizableFacesMessage( FacesMessage.Severity.ERROR, @@ -69,12 +71,12 @@ public void testMessagesWithSameParametersAreEqual() new Object[] { "input", "should be uppercase" }, Locale.ENGLISH); - Assertions.assertEquals(firstMessage, secondMessage); - Assertions.assertEquals(firstMessage.hashCode(), secondMessage.hashCode()); + assertEquals(firstMessage, secondMessage); + assertEquals(firstMessage.hashCode(), secondMessage.hashCode()); } @Test - public void testMessageParametersAreUsedForFormatting() + void messageParametersAreUsedForFormatting() { FacesMessage message = new ParametrizableFacesMessage( FacesMessage.Severity.ERROR, @@ -83,7 +85,7 @@ public void testMessageParametersAreUsedForFormatting() new Object[] { "input", "should be uppercase" }, Locale.ENGLISH); - Assertions.assertEquals("input: should be uppercase", message.getSummary()); - Assertions.assertEquals("Detail for input: should be uppercase", message.getDetail()); + assertEquals("input: should be uppercase", message.getSummary()); + assertEquals("Detail for input: should be uppercase", message.getDetail()); } } \ No newline at end of file diff --git a/impl/src/test/java/org/apache/myfaces/el/ResolverBuilderBaseTest.java b/impl/src/test/java/org/apache/myfaces/el/ResolverBuilderBaseTest.java index fb0a278faa..354ef874d7 100644 --- a/impl/src/test/java/org/apache/myfaces/el/ResolverBuilderBaseTest.java +++ b/impl/src/test/java/org/apache/myfaces/el/ResolverBuilderBaseTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.el; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -27,7 +29,6 @@ import org.apache.myfaces.config.RuntimeConfig; import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -36,7 +37,7 @@ * @author Mathias Broekelmann (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class ResolverBuilderBaseTest extends AbstractFacesTestCase +class ResolverBuilderBaseTest extends AbstractFacesTestCase { private RuntimeConfig runtimeConfig; private MyfacesConfig myfacesConfig; @@ -55,25 +56,25 @@ public void setUp() throws Exception } @Test - public void testGetFacesConfigElResolvers() throws Exception + void getFacesConfigElResolvers() throws Exception { ELResolver resolver = Mockito.mock(ELResolver.class); Mockito.when(runtimeConfig.getFacesConfigElResolvers()).thenReturn(Arrays.asList(resolver)); resolverBuilder.addFromRuntimeConfig(resolvers); - Assertions.assertEquals(Arrays.asList(resolver), resolvers); + assertEquals(Arrays.asList(resolver), resolvers); } - + @Test - public void testGetApplicationElResolvers() throws Exception + void getApplicationElResolvers() throws Exception { ELResolver resolver = Mockito.mock(ELResolver.class); Mockito.when(runtimeConfig.getApplicationElResolvers()).thenReturn(Arrays.asList(resolver)); resolverBuilder.addFromRuntimeConfig(resolvers); - Assertions.assertEquals(Arrays.asList(resolver), resolvers); + assertEquals(Arrays.asList(resolver), resolvers); } } diff --git a/impl/src/test/java/org/apache/myfaces/event/GlobalPostAddToViewEventTest.java b/impl/src/test/java/org/apache/myfaces/event/GlobalPostAddToViewEventTest.java index 589af5472e..62d698d939 100644 --- a/impl/src/test/java/org/apache/myfaces/event/GlobalPostAddToViewEventTest.java +++ b/impl/src/test/java/org/apache/myfaces/event/GlobalPostAddToViewEventTest.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.event; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import jakarta.faces.component.UIComponent; import jakarta.faces.component.UIOutput; import jakarta.faces.component.html.HtmlHead; @@ -28,10 +31,9 @@ import org.apache.myfaces.application.ApplicationImplEventManager; import org.apache.myfaces.test.base.junit.AbstractFacesConfigurableMockTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class GlobalPostAddToViewEventTest extends AbstractFacesConfigurableMockTestCase +class GlobalPostAddToViewEventTest extends AbstractFacesConfigurableMockTestCase { public class HeadResourceListener implements SystemEventListener { @@ -49,7 +51,7 @@ public void processEvent(SystemEvent event) } @Test - public void testPostAddToViewSourceNull() throws Exception + void postAddToViewSourceNull() throws Exception { ApplicationImplEventManager eventManager = new ApplicationImplEventManager(); @@ -57,11 +59,11 @@ public void testPostAddToViewSourceNull() throws Exception eventManager.publishEvent(facesContext, PostAddToViewEvent.class, HtmlHead.class, new HtmlHead()); - Assertions.assertTrue(facesContext.getAttributes().containsKey("SystemEventListenerInvokedForHead")); + assertTrue(facesContext.getAttributes().containsKey("SystemEventListenerInvokedForHead")); } - + @Test - public void testPostAddToViewSourceSuperClass() throws Exception + void postAddToViewSourceSuperClass() throws Exception { ApplicationImplEventManager eventManager = new ApplicationImplEventManager(); @@ -69,11 +71,11 @@ public void testPostAddToViewSourceSuperClass() throws Exception eventManager.publishEvent(facesContext, PostAddToViewEvent.class, HtmlHead.class, new HtmlHead()); - Assertions.assertTrue(facesContext.getAttributes().containsKey("SystemEventListenerInvokedForHead")); + assertTrue(facesContext.getAttributes().containsKey("SystemEventListenerInvokedForHead")); } - + @Test - public void testPostAddToViewSourceDirect() throws Exception + void postAddToViewSourceDirect() throws Exception { ApplicationImplEventManager eventManager = new ApplicationImplEventManager(); @@ -81,11 +83,11 @@ public void testPostAddToViewSourceDirect() throws Exception eventManager.publishEvent(facesContext, PostAddToViewEvent.class, HtmlHead.class, new HtmlHead()); - Assertions.assertTrue(facesContext.getAttributes().containsKey("SystemEventListenerInvokedForHead")); + assertTrue(facesContext.getAttributes().containsKey("SystemEventListenerInvokedForHead")); } - + @Test - public void testPostAddToViewSourceUnmatching() throws Exception + void postAddToViewSourceUnmatching() throws Exception { ApplicationImplEventManager eventManager = new ApplicationImplEventManager(); @@ -93,6 +95,6 @@ public void testPostAddToViewSourceUnmatching() throws Exception eventManager.publishEvent(facesContext, PostAddToViewEvent.class, HtmlHead.class, new HtmlHead()); - Assertions.assertFalse(facesContext.getAttributes().containsKey("SystemEventListenerInvokedForHead")); + assertFalse(facesContext.getAttributes().containsKey("SystemEventListenerInvokedForHead")); } } diff --git a/impl/src/test/java/org/apache/myfaces/event/PostAddToViewEventTest.java b/impl/src/test/java/org/apache/myfaces/event/PostAddToViewEventTest.java index db8122e850..b7fd2e09e8 100644 --- a/impl/src/test/java/org/apache/myfaces/event/PostAddToViewEventTest.java +++ b/impl/src/test/java/org/apache/myfaces/event/PostAddToViewEventTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.event; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.faces.application.StateManager; import jakarta.faces.component.UICommand; import jakarta.faces.component.UIForm; @@ -32,10 +34,9 @@ import org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage; import org.easymock.EasyMock; import org.easymock.IAnswer; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class PostAddToViewEventTest extends AbstractMyFacesCDIRequestTestCase +class PostAddToViewEventTest extends AbstractMyFacesCDIRequestTestCase { @@ -54,7 +55,7 @@ protected void setUpWebConfigParams() throws Exception * @throws Exception */ @Test - public void testPostAddToViewOnViewRoot() throws Exception + void postAddToViewOnViewRoot() throws Exception { startViewRequest("/postAddToViewEvent_1.xhtml"); @@ -62,8 +63,8 @@ public void testPostAddToViewOnViewRoot() throws Exception bean.invokePostAddToViewEvent(EasyMock.isA(ComponentSystemEvent.class)); EasyMock.expectLastCall().andAnswer(() -> { ComponentSystemEvent e = (ComponentSystemEvent) EasyMock.getCurrentArguments()[0]; - Assertions.assertTrue(e.getComponent() instanceof UIViewRoot); - Assertions.assertEquals(PhaseId.RENDER_RESPONSE, facesContext.getCurrentPhaseId()); + assertInstanceOf(UIViewRoot.class, e.getComponent()); + assertEquals(PhaseId.RENDER_RESPONSE, facesContext.getCurrentPhaseId()); return null; }).once(); EasyMock.replay(bean); @@ -81,10 +82,10 @@ public void testPostAddToViewOnViewRoot() throws Exception // but when building initial state. EasyMock.expectLastCall().andAnswer(() -> { ComponentSystemEvent e = (ComponentSystemEvent) EasyMock.getCurrentArguments()[0]; - Assertions.assertTrue(e.getComponent() instanceof UIViewRoot); - Assertions.assertEquals(PhaseId.RESTORE_VIEW, facesContext.getCurrentPhaseId()); - Assertions.assertTrue(facesContext.getAttributes().containsKey("jakarta.faces.IS_BUILDING_INITIAL_STATE")); - Assertions.assertFalse(FaceletViewDeclarationLanguage.isRefreshingTransientBuild(facesContext)); + assertInstanceOf(UIViewRoot.class, e.getComponent()); + assertEquals(PhaseId.RESTORE_VIEW, facesContext.getCurrentPhaseId()); + assertTrue(facesContext.getAttributes().containsKey("jakarta.faces.IS_BUILDING_INITIAL_STATE")); + assertFalse(FaceletViewDeclarationLanguage.isRefreshingTransientBuild(facesContext)); return null; }).once(); @@ -99,14 +100,14 @@ public static interface PostAddToViewEventBean { public void invokePostAddToViewEvent(ComponentSystemEvent e); } - + /** * Test a component receive PostAddToViewEvent * * @throws Exception */ @Test - public void testPostAddToViewOnComponent() throws Exception + void postAddToViewOnComponent() throws Exception { startViewRequest("/postAddToViewEvent_2.xhtml"); @@ -118,8 +119,8 @@ public Object answer() { ComponentSystemEvent e = (ComponentSystemEvent) EasyMock .getCurrentArguments()[0]; - Assertions.assertTrue(e.getComponent() instanceof UIForm); - Assertions.assertEquals(PhaseId.RENDER_RESPONSE, facesContext.getCurrentPhaseId()); + assertInstanceOf(UIForm.class, e.getComponent()); + assertEquals(PhaseId.RENDER_RESPONSE, facesContext.getCurrentPhaseId()); return null; } }).once(); @@ -142,10 +143,10 @@ public Object answer() { ComponentSystemEvent e = (ComponentSystemEvent) EasyMock .getCurrentArguments()[0]; - Assertions.assertTrue(e.getComponent() instanceof UIForm); - Assertions.assertEquals(PhaseId.RESTORE_VIEW, facesContext.getCurrentPhaseId()); - Assertions.assertTrue(facesContext.getAttributes().containsKey("jakarta.faces.IS_BUILDING_INITIAL_STATE")); - Assertions.assertFalse(FaceletViewDeclarationLanguage.isRefreshingTransientBuild(facesContext)); + assertInstanceOf(UIForm.class, e.getComponent()); + assertEquals(PhaseId.RESTORE_VIEW, facesContext.getCurrentPhaseId()); + assertTrue(facesContext.getAttributes().containsKey("jakarta.faces.IS_BUILDING_INITIAL_STATE")); + assertFalse(FaceletViewDeclarationLanguage.isRefreshingTransientBuild(facesContext)); return null; } }).once(); @@ -163,14 +164,14 @@ public Object answer() * @throws Exception */ @Test - public void testPostAddToViewOnComponentCif() throws Exception + void postAddToViewOnComponentCif() throws Exception { startViewRequest("/postAddToViewEvent_3.xhtml"); PostAddToViewEventBean bean = EasyMock.createMock(PostAddToViewEventBean.class); bean.invokePostAddToViewEvent(EasyMock.isA(ComponentSystemEvent.class)); EasyMock.expectLastCall().andAnswer(() -> { - Assertions.fail(); + fail(); return null; }).anyTimes(); EasyMock.replay(bean); @@ -187,7 +188,7 @@ public void testPostAddToViewOnComponentCif() throws Exception bean = EasyMock.createMock(PostAddToViewEventBean.class); bean.invokePostAddToViewEvent(EasyMock.isA(ComponentSystemEvent.class)); EasyMock.expectLastCall().andAnswer(() -> { - Assertions.fail(); + fail(); return null; }).anyTimes(); @@ -201,8 +202,8 @@ public void testPostAddToViewOnComponentCif() throws Exception bean.invokePostAddToViewEvent(EasyMock.isA(ComponentSystemEvent.class)); EasyMock.expectLastCall().andAnswer(() -> { ComponentSystemEvent e = (ComponentSystemEvent) EasyMock.getCurrentArguments()[0]; - Assertions.assertTrue(e.getComponent() instanceof UIPanel); - Assertions.assertEquals(PhaseId.RENDER_RESPONSE, facesContext.getCurrentPhaseId()); + assertInstanceOf(UIPanel.class, e.getComponent()); + assertEquals(PhaseId.RENDER_RESPONSE, facesContext.getCurrentPhaseId()); return null; }).once(); EasyMock.replay(bean); @@ -212,10 +213,10 @@ public void testPostAddToViewOnComponentCif() throws Exception renderResponse(); EasyMock.verify(bean); } - - + + @Test - public void testPostAddToViewOnComponentHead() throws Exception + void postAddToViewOnComponentHead() throws Exception { startViewRequest("/postAddToViewEvent_4.xhtml"); @@ -223,8 +224,8 @@ public void testPostAddToViewOnComponentHead() throws Exception bean.invokePostAddToViewEvent(EasyMock.isA(ComponentSystemEvent.class)); EasyMock.expectLastCall().andAnswer(() -> { ComponentSystemEvent e = (ComponentSystemEvent) EasyMock.getCurrentArguments()[0]; - Assertions.assertTrue(e.getComponent() instanceof UIOutput); - Assertions.assertTrue(e.getComponent().getRendererType().equals("jakarta.faces.Head")); + assertInstanceOf(UIOutput.class, e.getComponent()); + assertEquals("jakarta.faces.Head", e.getComponent().getRendererType()); return null; }).once(); EasyMock.replay(bean); @@ -242,8 +243,8 @@ public void testPostAddToViewOnComponentHead() throws Exception // but when building initial state. EasyMock.expectLastCall().andAnswer(() -> { ComponentSystemEvent e = (ComponentSystemEvent) EasyMock.getCurrentArguments()[0]; - Assertions.assertTrue(e.getComponent() instanceof UIOutput); - Assertions.assertTrue(e.getComponent().getRendererType().equals("jakarta.faces.Head")); + assertInstanceOf(UIOutput.class, e.getComponent()); + assertEquals("jakarta.faces.Head", e.getComponent().getRendererType()); return null; }).once(); diff --git a/impl/src/test/java/org/apache/myfaces/flow/FlowBuilderTest.java b/impl/src/test/java/org/apache/myfaces/flow/FlowBuilderTest.java index 018bb67b20..90627b62b9 100644 --- a/impl/src/test/java/org/apache/myfaces/flow/FlowBuilderTest.java +++ b/impl/src/test/java/org/apache/myfaces/flow/FlowBuilderTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.flow; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.faces.context.FacesContext; import jakarta.faces.flow.Flow; import jakarta.faces.flow.FlowCallNode; @@ -31,50 +33,49 @@ import jakarta.faces.flow.builder.SwitchCaseBuilder; import org.apache.myfaces.flow.builder.FlowBuilderImpl; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * * @author lu4242 */ -public class FlowBuilderTest extends AbstractFacesTestCase +class FlowBuilderTest extends AbstractFacesTestCase { - + @Test - public void testFlowBuilderSimple() + void flowBuilderSimple() { FlowBuilder flowBuilder = new FlowBuilderImpl(); flowBuilder.id("faces-flow1.xhtml", "flow1"). initializer("#{bean.init}").finalizer("#{bean.destroy}"); Flow flow = flowBuilder.getFlow(); - Assertions.assertNotNull(flow); - Assertions.assertEquals("flow1", flow.getId()); - Assertions.assertEquals("faces-flow1.xhtml", flow.getDefiningDocumentId()); - Assertions.assertEquals("#{bean.init}", flow.getInitializer().getExpressionString()); - Assertions.assertEquals("#{bean.destroy}", flow.getFinalizer().getExpressionString()); + assertNotNull(flow); + assertEquals("flow1", flow.getId()); + assertEquals("faces-flow1.xhtml", flow.getDefiningDocumentId()); + assertEquals("#{bean.init}", flow.getInitializer().getExpressionString()); + assertEquals("#{bean.destroy}", flow.getFinalizer().getExpressionString()); } - + @Test - public void testFlowBuilderReturn() + void flowBuilderReturn() { FlowBuilder flowBuilder = new FlowBuilderImpl(); flowBuilder.id("faces-flow1.xhtml", "flow1"); flowBuilder.returnNode("returnNode").markAsStartNode().fromOutcome("mynode"); Flow flow = flowBuilder.getFlow(); - Assertions.assertNotNull(flow); - Assertions.assertEquals("returnNode", flow.getStartNodeId()); + assertNotNull(flow); + assertEquals("returnNode", flow.getStartNodeId()); ReturnNode returnNode = flow.getReturns().get("returnNode"); - Assertions.assertNotNull(returnNode); - Assertions.assertEquals("returnNode", returnNode.getId()); - Assertions.assertEquals("mynode", returnNode.getFromOutcome(facesContext)); - } + assertNotNull(returnNode); + assertEquals("returnNode", returnNode.getId()); + assertEquals("mynode", returnNode.getFromOutcome(facesContext)); + } @Test - public void testFlowBuilderSwitch() + void flowBuilderSwitch() { externalContext.getRequestMap().put("bean", new SimpleBean()); FlowBuilder flowBuilder = new FlowBuilderImpl(); @@ -91,24 +92,24 @@ public void testFlowBuilderSwitch() .fromOutcome("caseC"); Flow flow = flowBuilder.getFlow(); - Assertions.assertNotNull(flow); - Assertions.assertEquals("switch1", flow.getStartNodeId()); + assertNotNull(flow); + assertEquals("switch1", flow.getStartNodeId()); SwitchNode switchNode = flow.getSwitches().get("switch1"); - Assertions.assertNotNull(switchNode); - Assertions.assertEquals("exit", switchNode.getDefaultOutcome(facesContext)); + assertNotNull(switchNode); + assertEquals("exit", switchNode.getDefaultOutcome(facesContext)); SwitchCase scn = switchNode.getCases().get(0); - Assertions.assertTrue(scn.getCondition(facesContext)); - Assertions.assertEquals("case1", scn.getFromOutcome()); + assertTrue(scn.getCondition(facesContext)); + assertEquals("case1", scn.getFromOutcome()); scn = switchNode.getCases().get(1); - Assertions.assertTrue(scn.getCondition(facesContext)); - Assertions.assertEquals("caseB", scn.getFromOutcome()); + assertTrue(scn.getCondition(facesContext)); + assertEquals("caseB", scn.getFromOutcome()); scn = switchNode.getCases().get(2); - Assertions.assertTrue(scn.getCondition(facesContext)); - Assertions.assertEquals("caseC", scn.getFromOutcome()); + assertTrue(scn.getCondition(facesContext)); + assertEquals("caseC", scn.getFromOutcome()); } public static class SimpleBean { @@ -131,9 +132,9 @@ public void checkTo(FacesContext context) { } } - + @Test - public void testFlowBuilderView() + void flowBuilderView() { FlowBuilder flowBuilder = new FlowBuilderImpl(); flowBuilder.id("faces-flow1.xhtml", "flow1"); @@ -141,20 +142,20 @@ public void testFlowBuilderView() flowBuilder.viewNode("y", "y.xhtml").markAsStartNode(); Flow flow = flowBuilder.getFlow(); - Assertions.assertNotNull(flow); - Assertions.assertEquals("y", flow.getStartNodeId()); + assertNotNull(flow); + assertEquals("y", flow.getStartNodeId()); ViewNode viewNode = flow.getViews().get(0); - Assertions.assertEquals("x", viewNode.getId()); - Assertions.assertEquals("x.xhtml", viewNode.getVdlDocumentId()); + assertEquals("x", viewNode.getId()); + assertEquals("x.xhtml", viewNode.getVdlDocumentId()); viewNode = flow.getViews().get(1); - Assertions.assertEquals("y", viewNode.getId()); - Assertions.assertEquals("y.xhtml", viewNode.getVdlDocumentId()); + assertEquals("y", viewNode.getId()); + assertEquals("y.xhtml", viewNode.getVdlDocumentId()); } - + @Test - public void testFlowBuilderInboundParameter() + void flowBuilderInboundParameter() { externalContext.getRequestMap().put("bean", new SimpleBean()); FlowBuilder flowBuilder = new FlowBuilderImpl(); @@ -165,23 +166,23 @@ public void testFlowBuilderInboundParameter() application.getExpressionFactory().createValueExpression("value3", String.class)); Flow flow = flowBuilder.getFlow(); - Assertions.assertNotNull(flow); + assertNotNull(flow); Parameter param = flow.getInboundParameters().get("name1"); - Assertions.assertEquals("name1", param.getName()); - Assertions.assertEquals("value1", param.getValue().getValue(facesContext.getELContext())); + assertEquals("name1", param.getName()); + assertEquals("value1", param.getValue().getValue(facesContext.getELContext())); param = flow.getInboundParameters().get("name2"); - Assertions.assertEquals("name2", param.getName()); - Assertions.assertEquals("asdf", param.getValue().getValue(facesContext.getELContext())); + assertEquals("name2", param.getName()); + assertEquals("asdf", param.getValue().getValue(facesContext.getELContext())); param = flow.getInboundParameters().get("name3"); - Assertions.assertEquals("name3", param.getName()); - Assertions.assertEquals("value3", param.getValue().getValue(facesContext.getELContext())); + assertEquals("name3", param.getName()); + assertEquals("value3", param.getValue().getValue(facesContext.getELContext())); } @Test - public void testFlowBuilderMethodCall() + void flowBuilderMethodCall() { FlowBuilder flowBuilder = new FlowBuilderImpl(); flowBuilder.id("faces-flow1.xhtml", "flow1"); @@ -190,22 +191,22 @@ public void testFlowBuilderMethodCall() new Class[]{FacesContext.class}).defaultOutcome("case2"); Flow flow = flowBuilder.getFlow(); - Assertions.assertNotNull(flow); - Assertions.assertEquals("method1", flow.getStartNodeId()); + assertNotNull(flow); + assertEquals("method1", flow.getStartNodeId()); MethodCallNode mcn = flow.getMethodCalls().get(0); - Assertions.assertEquals("method1", mcn.getId()); - Assertions.assertEquals("case1", mcn.getOutcome().getValue(facesContext.getELContext())); - Assertions.assertEquals("#{bean.check}", mcn.getMethodExpression().getExpressionString()); + assertEquals("method1", mcn.getId()); + assertEquals("case1", mcn.getOutcome().getValue(facesContext.getELContext())); + assertEquals("#{bean.check}", mcn.getMethodExpression().getExpressionString()); mcn = flow.getMethodCalls().get(1); - Assertions.assertEquals("method2", mcn.getId()); - Assertions.assertEquals("case2", mcn.getOutcome().getValue(facesContext.getELContext())); - Assertions.assertEquals("#{bean.checkTo}", mcn.getMethodExpression().getExpressionString()); + assertEquals("method2", mcn.getId()); + assertEquals("case2", mcn.getOutcome().getValue(facesContext.getELContext())); + assertEquals("#{bean.checkTo}", mcn.getMethodExpression().getExpressionString()); } - + @Test - public void testFlowBuilderFlowCall() + void flowBuilderFlowCall() { FlowBuilder flowBuilder = new FlowBuilderImpl(); flowBuilder.id("faces-flow1.xhtml", "flow1"); @@ -214,17 +215,17 @@ public void testFlowBuilderFlowCall() flowReference("faces-flow2.xhtml", "flow2").markAsStartNode(); Flow flow = flowBuilder.getFlow(); - Assertions.assertNotNull(flow); - Assertions.assertEquals("goToFlow2", flow.getStartNodeId()); + assertNotNull(flow); + assertEquals("goToFlow2", flow.getStartNodeId()); FlowCallNode flowCallNode = flow.getFlowCalls().get("goToFlow2"); - Assertions.assertNotNull(flowCallNode); - Assertions.assertEquals("flow2", flowCallNode.getCalledFlowId(facesContext)); - Assertions.assertEquals("faces-flow2.xhtml", flowCallNode.getCalledFlowDocumentId(facesContext)); + assertNotNull(flowCallNode); + assertEquals("flow2", flowCallNode.getCalledFlowId(facesContext)); + assertEquals("faces-flow2.xhtml", flowCallNode.getCalledFlowDocumentId(facesContext)); Parameter param = flowCallNode.getOutboundParameters().get("name1"); - Assertions.assertEquals("name1", param.getName()); - Assertions.assertEquals("value1", param.getValue().getValue(facesContext.getELContext())); + assertEquals("name1", param.getName()); + assertEquals("value1", param.getValue().getValue(facesContext.getELContext())); } } diff --git a/impl/src/test/java/org/apache/myfaces/lifecycle/RedirectTest.java b/impl/src/test/java/org/apache/myfaces/lifecycle/RedirectTest.java index d74f8ad22a..606ef598ba 100644 --- a/impl/src/test/java/org/apache/myfaces/lifecycle/RedirectTest.java +++ b/impl/src/test/java/org/apache/myfaces/lifecycle/RedirectTest.java @@ -20,16 +20,18 @@ import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.test.core.AbstractMyFacesRequestTestCase; -import org.junit.jupiter.api.Assertions; + import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * This class test */ -public class RedirectTest extends AbstractMyFacesCDIRequestTestCase +class RedirectTest extends AbstractMyFacesCDIRequestTestCase { @Test - public void testRedirect1() throws Exception + void redirect1() throws Exception { startViewRequest("/redirect1.xhtml"); processLifecycleExecute(); @@ -39,6 +41,6 @@ public void testRedirect1() throws Exception client.processRedirect(); processLifecycleExecuteAndRender(); String redirectedContent = getRenderedContent(); - Assertions.assertTrue(redirectedContent.contains("Redirected Page")); + assertTrue(redirectedContent.contains("Redirected Page")); } } diff --git a/impl/src/test/java/org/apache/myfaces/lifecycle/RenderResponseExecutorTest.java b/impl/src/test/java/org/apache/myfaces/lifecycle/RenderResponseExecutorTest.java index 409543eb06..069dbcecf6 100644 --- a/impl/src/test/java/org/apache/myfaces/lifecycle/RenderResponseExecutorTest.java +++ b/impl/src/test/java/org/apache/myfaces/lifecycle/RenderResponseExecutorTest.java @@ -18,18 +18,19 @@ */ package org.apache.myfaces.lifecycle; -import jakarta.faces.component.UIViewRoot; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.jupiter.api.Assertions; +import jakarta.faces.component.UIViewRoot; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.junit.jupiter.api.Test; -public class RenderResponseExecutorTest extends AbstractFacesTestCase +class RenderResponseExecutorTest extends AbstractFacesTestCase { @Test - public void testNavigationCondition() throws Exception + void navigationCondition() throws Exception { UIViewRoot a = new UIViewRoot(); UIViewRoot b = new UIViewRoot(); @@ -40,22 +41,22 @@ public void testNavigationCondition() throws Exception c.setViewId("/c.xhtml"); //If the view was not changed continue (return false) - Assertions.assertFalse(checkCondition(a, a)); + assertFalse(checkCondition(a, a)); //If the view is different instance but same viewId iterate again (return true) - Assertions.assertTrue(checkCondition(a, b)); + assertTrue(checkCondition(a, b)); //If the view is different instance and different id iterate again - Assertions.assertTrue(checkCondition(a, c)); + assertTrue(checkCondition(a, c)); //If the view is different instance and id is null iterate again - Assertions.assertTrue(checkCondition(a, d)); + assertTrue(checkCondition(a, d)); //If the view is different instance and id is not null iterate again - Assertions.assertTrue(checkCondition(d, a)); + assertTrue(checkCondition(d, a)); //If the view was not change continue (return false) - Assertions.assertFalse(checkCondition(d, d)); + assertFalse(checkCondition(d, d)); } protected boolean checkCondition(UIViewRoot previousRoot, UIViewRoot root) diff --git a/impl/src/test/java/org/apache/myfaces/lifecycle/RestoreViewExecutorTest.java b/impl/src/test/java/org/apache/myfaces/lifecycle/RestoreViewExecutorTest.java index 28c13328ea..dc1e948c0c 100644 --- a/impl/src/test/java/org/apache/myfaces/lifecycle/RestoreViewExecutorTest.java +++ b/impl/src/test/java/org/apache/myfaces/lifecycle/RestoreViewExecutorTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.lifecycle; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.Locale; import jakarta.faces.application.ViewHandler; @@ -26,7 +28,6 @@ import org.apache.myfaces.application.ViewIdSupport; import org.apache.myfaces.test.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -60,7 +61,7 @@ public void setUp() throws Exception * {@link org.apache.myfaces.lifecycle.RestoreViewExecutor#execute(jakarta.faces.context.FacesContext)}. */ @Test - public void testExecuteWithExistingViewRoot() + void executeWithExistingViewRoot() { Mockito.when(_facesContext.getApplication()).thenReturn(_application); Mockito.when(_application.getViewHandler()).thenReturn(_viewHandler); @@ -83,7 +84,7 @@ public void testExecuteWithExistingViewRoot() */ public void testGetPhase() { - Assertions.assertEquals(PhaseId.RESTORE_VIEW, _testimpl.getPhase()); + assertEquals(PhaseId.RESTORE_VIEW, _testimpl.getPhase()); } } diff --git a/impl/src/test/java/org/apache/myfaces/push/JsonEncodingTest.java b/impl/src/test/java/org/apache/myfaces/push/JsonEncodingTest.java index 78aab2f408..7ce69953eb 100644 --- a/impl/src/test/java/org/apache/myfaces/push/JsonEncodingTest.java +++ b/impl/src/test/java/org/apache/myfaces/push/JsonEncodingTest.java @@ -25,14 +25,14 @@ import org.junit.jupiter.api.Test; -public class JsonEncodingTest +class JsonEncodingTest { /* * Ensure JSON.encode can encode record objects. */ @Test - public void testRecordEncoding() + void recordEncoding() { String expected = "{name:\"Chikorita\",type:\"Grass\",itemHeld:false,moves:[\"Tackle\",\"Growl\",\"Razor Leaf\"]}"; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/ContentTypeUtilsTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/ContentTypeUtilsTest.java index af4183480f..6ff36f63df 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/ContentTypeUtilsTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/ContentTypeUtilsTest.java @@ -19,63 +19,65 @@ package org.apache.myfaces.renderkit; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; + import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class ContentTypeUtilsTest extends AbstractFacesTestCase { @Test - public void testContainsContentType() throws Exception + void containsContentType() throws Exception { - Assertions.assertTrue(ContentTypeUtils.containsContentType( + assertTrue(ContentTypeUtils.containsContentType( ContentTypeUtils.HTML_CONTENT_TYPE, ContentTypeUtils.HTML_ALLOWED_CONTENT_TYPES)); - Assertions.assertTrue(ContentTypeUtils.containsContentType( + assertTrue(ContentTypeUtils.containsContentType( ContentTypeUtils.ANY_CONTENT_TYPE, ContentTypeUtils.HTML_ALLOWED_CONTENT_TYPES)); - Assertions.assertTrue(ContentTypeUtils.containsContentType( + assertTrue(ContentTypeUtils.containsContentType( ContentTypeUtils.TEXT_ANY_CONTENT_TYPE, ContentTypeUtils.HTML_ALLOWED_CONTENT_TYPES)); - Assertions.assertTrue(ContentTypeUtils.containsContentType( + assertTrue(ContentTypeUtils.containsContentType( ContentTypeUtils.XHTML_CONTENT_TYPE, ContentTypeUtils.XHTML_ALLOWED_CONTENT_TYPES)); - Assertions.assertTrue(ContentTypeUtils.containsContentType( + assertTrue(ContentTypeUtils.containsContentType( ContentTypeUtils.APPLICATION_XML_CONTENT_TYPE, ContentTypeUtils.XHTML_ALLOWED_CONTENT_TYPES)); - Assertions.assertTrue(ContentTypeUtils.containsContentType( + assertTrue(ContentTypeUtils.containsContentType( ContentTypeUtils.TEXT_XML_CONTENT_TYPE, ContentTypeUtils.XHTML_ALLOWED_CONTENT_TYPES)); } - + @Test - public void testSplitContentTypeListString() throws Exception + void splitContentTypeListString() throws Exception { String [] splittedArray = ContentTypeUtils.splitContentTypeListString("text/*, text/html "); - Assertions.assertTrue(ContentTypeUtils.containsContentType( + assertTrue(ContentTypeUtils.containsContentType( ContentTypeUtils.HTML_CONTENT_TYPE, splittedArray)); - Assertions.assertTrue(ContentTypeUtils.containsContentType( + assertTrue(ContentTypeUtils.containsContentType( ContentTypeUtils.TEXT_ANY_CONTENT_TYPE, splittedArray)); splittedArray = ContentTypeUtils.splitContentTypeListString(" text/x-dvi; q=.8; mxb=100000; mxt=5.0, text/x-c"); - Assertions.assertTrue(ContentTypeUtils.containsContentType( + assertTrue(ContentTypeUtils.containsContentType( "text/x-dvi", splittedArray)); - Assertions.assertTrue(ContentTypeUtils.containsContentType( + assertTrue(ContentTypeUtils.containsContentType( "text/x-c", splittedArray)); } public void testChooseWriterContentType() throws Exception { - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, ContentTypeUtils.chooseWriterContentType( "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", ContentTypeUtils.HTML_ALLOWED_CONTENT_TYPES, ContentTypeUtils.XHTML_ALLOWED_CONTENT_TYPES)); - Assertions.assertEquals(ContentTypeUtils.XHTML_CONTENT_TYPE, + assertEquals(ContentTypeUtils.XHTML_CONTENT_TYPE, ContentTypeUtils.chooseWriterContentType( "application/xml, text/xml , */*; q=0.01", ContentTypeUtils.HTML_ALLOWED_CONTENT_TYPES, ContentTypeUtils.XHTML_ALLOWED_CONTENT_TYPES)); //In ajax request application/xml and text/xml does not match. - Assertions.assertNull(ContentTypeUtils.chooseWriterContentType( + assertNull(ContentTypeUtils.chooseWriterContentType( "application/xml, text/xml, */*; q=0.01", ContentTypeUtils.HTML_ALLOWED_CONTENT_TYPES, ContentTypeUtils.AJAX_XHTML_ALLOWED_CONTENT_TYPES)); diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/ErrorPageWriterTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/ErrorPageWriterTest.java index 88e035dbf2..878a92a39c 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/ErrorPageWriterTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/ErrorPageWriterTest.java @@ -18,7 +18,8 @@ */ package org.apache.myfaces.renderkit; -import java.io.IOException; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import jakarta.el.ValueExpression; @@ -35,7 +36,6 @@ import org.apache.myfaces.test.mock.MockRenderKitFactory; import org.apache.myfaces.test.mock.MockResponseWriter; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -43,7 +43,7 @@ * @author Bruno Aranda (latest modification by $Author: struberg $) * @version $Revision: 1188235 $ $Date: 2011-10-24 13:09:33 -0400 (Mon, 24 Oct 2011) $ */ -public class ErrorPageWriterTest extends AbstractFacesTestCase +class ErrorPageWriterTest extends AbstractFacesTestCase { private MockResponseWriter writer ; private HtmlOutputText outputText; @@ -79,7 +79,7 @@ public void tearDown() throws Exception } @Test - public void testValueExpressionGetExpressionStringReturnsNull() throws IOException + void valueExpressionGetExpressionStringReturnsNull() throws Exception { //See MYFACES-3413 for details UIViewRoot root = facesContext.getViewRoot(); @@ -106,7 +106,7 @@ public void testValueExpressionGetExpressionStringReturnsNull() throws IOExcepti } int indexOfHasRenderedAttribute = output.indexOf("rendered=\"\""); boolean hasRenderedAttribute = (-1 != indexOfHasRenderedAttribute); - Assertions.assertTrue(hasRenderedAttribute, "rendered attribute wasn't written correctly: " + surroundingText); + assertTrue(hasRenderedAttribute, "rendered attribute wasn't written correctly: " + surroundingText); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/HtmlRenderKitImplTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/HtmlRenderKitImplTest.java index 804b6d75a4..75878b09c7 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/HtmlRenderKitImplTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/HtmlRenderKitImplTest.java @@ -18,32 +18,33 @@ */ package org.apache.myfaces.renderkit; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.StringWriter; -import org.junit.jupiter.api.Assertions; import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.renderkit.html.HtmlRenderKitImpl; import org.apache.myfaces.renderkit.html.HtmlResponseWriterImpl; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.junit.jupiter.api.Test; -public class HtmlRenderKitImplTest extends AbstractFacesTestCase +class HtmlRenderKitImplTest extends AbstractFacesTestCase { @Test - public void testCreateResponseWriterContentType1() + void createResponseWriterContentType1() { MyfacesConfig config = new MyfacesConfig(); facesContext.getExternalContext().getApplicationMap().put(MyfacesConfig.class.getName(), config); HtmlRenderKitImpl renderKit = new HtmlRenderKitImpl(); StringWriter writer = new StringWriter(); HtmlResponseWriterImpl responseWriter = (HtmlResponseWriterImpl) renderKit.createResponseWriter(writer, null, null); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); } - + @Test - public void testCreateResponseWriterContentType2() + void createResponseWriterContentType2() { servletContext.setInitParameter(MyfacesConfig.DEFAULT_RESPONSE_WRITER_CONTENT_TYPE_MODE, ContentTypeUtils.XHTML_CONTENT_TYPE); @@ -53,12 +54,12 @@ public void testCreateResponseWriterContentType2() HtmlRenderKitImpl renderKit = new HtmlRenderKitImpl(); StringWriter writer = new StringWriter(); HtmlResponseWriterImpl responseWriter = (HtmlResponseWriterImpl) renderKit.createResponseWriter(writer, null, null); - Assertions.assertEquals(ContentTypeUtils.XHTML_CONTENT_TYPE, responseWriter.getContentType()); - Assertions.assertEquals(ContentTypeUtils.XHTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); + assertEquals(ContentTypeUtils.XHTML_CONTENT_TYPE, responseWriter.getContentType()); + assertEquals(ContentTypeUtils.XHTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); } - + @Test - public void testCreateResponseWriterContentType3() + void createResponseWriterContentType3() { MyfacesConfig config = new MyfacesConfig(); facesContext.getExternalContext().getApplicationMap().put(MyfacesConfig.class.getName(), config); @@ -67,12 +68,12 @@ public void testCreateResponseWriterContentType3() HtmlRenderKitImpl renderKit = new HtmlRenderKitImpl(); StringWriter writer = new StringWriter(); HtmlResponseWriterImpl responseWriter = (HtmlResponseWriterImpl) renderKit.createResponseWriter(writer, null, null); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); } - + @Test - public void testCreateResponseWriterContentType4() + void createResponseWriterContentType4() { MyfacesConfig config = new MyfacesConfig(); facesContext.getExternalContext().getApplicationMap().put(MyfacesConfig.class.getName(), config); @@ -81,12 +82,12 @@ public void testCreateResponseWriterContentType4() HtmlRenderKitImpl renderKit = new HtmlRenderKitImpl(); StringWriter writer = new StringWriter(); HtmlResponseWriterImpl responseWriter = (HtmlResponseWriterImpl) renderKit.createResponseWriter(writer, null, null); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); } - + @Test - public void testCreateResponseWriterContentType5() + void createResponseWriterContentType5() { MyfacesConfig config = new MyfacesConfig(); facesContext.getExternalContext().getApplicationMap().put(MyfacesConfig.class.getName(), config); @@ -94,12 +95,12 @@ public void testCreateResponseWriterContentType5() HtmlRenderKitImpl renderKit = new HtmlRenderKitImpl(); StringWriter writer = new StringWriter(); HtmlResponseWriterImpl responseWriter = (HtmlResponseWriterImpl) renderKit.createResponseWriter(writer, null, null); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); } - + @Test - public void testCreateResponseWriterContentType6() + void createResponseWriterContentType6() { MyfacesConfig config = new MyfacesConfig(); facesContext.getExternalContext().getApplicationMap().put(MyfacesConfig.class.getName(), config); @@ -107,12 +108,12 @@ public void testCreateResponseWriterContentType6() HtmlRenderKitImpl renderKit = new HtmlRenderKitImpl(); StringWriter writer = new StringWriter(); HtmlResponseWriterImpl responseWriter = (HtmlResponseWriterImpl) renderKit.createResponseWriter(writer, null, null); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); } - + @Test - public void testCreateResponseWriterContentType7() + void createResponseWriterContentType7() { MyfacesConfig config = new MyfacesConfig(); facesContext.getExternalContext().getApplicationMap().put(MyfacesConfig.class.getName(), config); @@ -121,12 +122,12 @@ public void testCreateResponseWriterContentType7() HtmlRenderKitImpl renderKit = new HtmlRenderKitImpl(); StringWriter writer = new StringWriter(); HtmlResponseWriterImpl responseWriter = (HtmlResponseWriterImpl) renderKit.createResponseWriter(writer, null, null); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); } - + @Test - public void testCreateResponseWriterContentType8() + void createResponseWriterContentType8() { MyfacesConfig config = new MyfacesConfig(); facesContext.getExternalContext().getApplicationMap().put(MyfacesConfig.class.getName(), config); @@ -135,12 +136,12 @@ public void testCreateResponseWriterContentType8() HtmlRenderKitImpl renderKit = new HtmlRenderKitImpl(); StringWriter writer = new StringWriter(); HtmlResponseWriterImpl responseWriter = (HtmlResponseWriterImpl) renderKit.createResponseWriter(writer, null, null); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); } @Test - public void testCreateResponseWriterContentType9() + void createResponseWriterContentType9() { MyfacesConfig config = new MyfacesConfig(); facesContext.getExternalContext().getApplicationMap().put(MyfacesConfig.class.getName(), config); @@ -153,7 +154,7 @@ public void testCreateResponseWriterContentType9() HtmlRenderKitImpl renderKit = new HtmlRenderKitImpl(); StringWriter writer = new StringWriter(); HtmlResponseWriterImpl responseWriter = (HtmlResponseWriterImpl) renderKit.createResponseWriter(writer, null, null); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); - Assertions.assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getContentType()); + assertEquals(ContentTypeUtils.HTML_CONTENT_TYPE, responseWriter.getWriterContentTypeMode()); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/JavascriptUtilsTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/JavascriptUtilsTest.java index a3ae128efb..3921af4ec2 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/JavascriptUtilsTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/JavascriptUtilsTest.java @@ -32,12 +32,12 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; -public class JavascriptUtilsTest { +class JavascriptUtilsTest { private MockedStatic javascriptUtilsMockedStatic; @BeforeEach - public void setUp() { + void setUp() { javascriptUtilsMockedStatic = mockStatic(JavascriptUtils.class); javascriptUtilsMockedStatic.when(() -> getValidJavascriptName(anyString(), anyBoolean(), anyBoolean())) @@ -47,13 +47,13 @@ public void setUp() { } @AfterEach - public void tearDown() { + void tearDown() { javascriptUtilsMockedStatic.close(); } @Test @DisplayName("Passes namespaces without namespace encoding when allowNamespaces is true") - public void testGetValidJavascriptNameWithNamespaces() { + void getValidJavascriptNameWithNamespaces() { // WHEN String result = getValidJavascriptName("testName.testname2", true, true); @@ -64,7 +64,7 @@ public void testGetValidJavascriptNameWithNamespaces() { @Test @DisplayName("Returns input name without modifications when no namespace is provided") - public void testGetValidJavascriptNameWithoutNamespace() { + void getValidJavascriptNameWithoutNamespace() { // WHEN String result = getValidJavascriptName("testName", true, true); @@ -75,7 +75,7 @@ public void testGetValidJavascriptNameWithoutNamespace() { @Test @DisplayName("Handles namespaced input correctly without modification when allowNamespaces is false") - public void testGetValidJavascriptNameWithNamespacedInput() { + void getValidJavascriptNameWithNamespacedInput() { // WHEN String result = getValidJavascriptName("testName.namespace", false, true); diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/RendererUtilsTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/RendererUtilsTest.java index f3c83fbf9c..08a503ebba 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/RendererUtilsTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/RendererUtilsTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit; +import static org.junit.jupiter.api.Assertions.*; + import java.io.IOException; import java.io.StringWriter; @@ -34,7 +36,6 @@ import jakarta.faces.context.FacesContext; import org.apache.myfaces.core.api.shared.ComponentUtils; -import org.junit.jupiter.api.Assertions; import org.apache.myfaces.renderkit.html.util.HTML; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.apache.myfaces.test.mock.MockResponseWriter; @@ -43,7 +44,7 @@ import org.apache.myfaces.renderkit.html.util.ComponentAttrs; import org.junit.jupiter.api.BeforeEach; -public class RendererUtilsTest extends AbstractFacesTestCase { +class RendererUtilsTest extends AbstractFacesTestCase { private MockResponseWriter writer; @@ -103,7 +104,7 @@ public void setUp() throws Exception { } @Test - public void testGetIconSrc() { + void getIconSrc() { // Training a mock: resourceHandlerMock.createResource(resourceName, libraryName); @@ -117,13 +118,13 @@ public void testGetIconSrc() { String iconSrc = RendererUtils.getIconSrc(facesContext, graphicImage, HTML.IMG_ELEM); - Assertions.assertEquals(requestPath, iconSrc, + assertEquals(requestPath, iconSrc, "If name or name/library present, source must be obtained from ResourceHandler"); } @Test - public void testGetIconSrcResourceNotFound() throws Exception { + void getIconSrcResourceNotFound() throws Exception { // Training a mock: EasyMock.reset(resourceHandlerMock); resourceHandlerMock.createResource(resourceName, libraryName); @@ -134,48 +135,48 @@ public void testGetIconSrcResourceNotFound() throws Exception { String iconSrc = RendererUtils.getIconSrc(facesContext, graphicImage, HTML.IMG_ELEM); - Assertions.assertEquals("RES_NOT_FOUND", iconSrc); - Assertions.assertTrue(facesContext.getMessages(graphicImage.getClientId(facesContext)).hasNext()); + assertEquals("RES_NOT_FOUND", iconSrc); + assertTrue(facesContext.getMessages(graphicImage.getClientId(facesContext)).hasNext()); } @Test - public void testGetStringValue() { + void getStringValue() { // Test for situation where submittedValue IS NOT String: UIInput uiInput = new UIInput(); Object submittedValue = new Object(); uiInput.setSubmittedValue(submittedValue); String stringValue = RendererUtils.getStringValue(facesContext, uiInput); - Assertions.assertNotNull(stringValue); - Assertions.assertEquals(submittedValue.toString(), stringValue, + assertNotNull(stringValue); + assertEquals(submittedValue.toString(), stringValue, "If submittedvalue is not String, toString() must be used"); } @Test - public void testGetConvertedUIOutputValue() { + void getConvertedUIOutputValue() { UIInput uiInput = new UIInput(); StringBuilder submittedValue = new StringBuilder("submittedValue"); uiInput.setSubmittedValue(submittedValue); Object convertedUIOutputValue = RendererUtils.getConvertedUIOutputValue(facesContext, uiInput, submittedValue); - Assertions.assertEquals(submittedValue.toString(), convertedUIOutputValue); + assertEquals(submittedValue.toString(), convertedUIOutputValue); } @Test - public void testIsRendered() { + void isRendered() { UIComponent uiComponent = new UIOutput(); boolean rendered = ComponentUtils.isRendered(facesContext, uiComponent); - Assertions.assertTrue(rendered); + assertTrue(rendered); uiComponent.setRendered(false); rendered = ComponentUtils.isRendered(facesContext, uiComponent); - Assertions.assertFalse(rendered); + assertFalse(rendered); uiComponent = _setUpComponentStack(); rendered = ComponentUtils.isRendered(facesContext, uiComponent); - Assertions.assertFalse(rendered); - Assertions.assertEquals(parent, UIComponent.getCurrentComponent(facesContext)); + assertFalse(rendered); + assertEquals(parent, UIComponent.getCurrentComponent(facesContext)); } /** @@ -193,7 +194,7 @@ public MockRenderedValueExpression(String expression, Class expectedType, UIC @Override public Object getValue(ELContext elContext) { UIComponent currentComponent = UIComponent.getCurrentComponent(facesContext); - Assertions.assertEquals(currentComponent, toVerify); + assertEquals(currentComponent, toVerify); return false; } } @@ -210,17 +211,17 @@ public boolean isRendered() { @Override public void encodeBegin(FacesContext context) throws IOException { - Assertions.fail(); + fail(); } @Override public void encodeChildren(FacesContext context) throws IOException { - Assertions.fail(); + fail(); } @Override public void encodeEnd(FacesContext context) throws IOException { - Assertions.fail(); + fail(); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/ClientBehaviorRendererUtilsTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/ClientBehaviorRendererUtilsTest.java index 8e548ff25f..2c54099f32 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/ClientBehaviorRendererUtilsTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/ClientBehaviorRendererUtilsTest.java @@ -22,7 +22,6 @@ import jakarta.faces.component.behavior.ClientBehavior; import jakarta.faces.component.behavior.ClientBehaviorHint; import jakarta.faces.component.behavior.ClientBehaviorBase; -import org.junit.jupiter.api.Assertions; import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.renderkit.ClientBehaviorEvents; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; @@ -32,12 +31,14 @@ import java.util.*; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.apache.myfaces.renderkit.html.util.ClientBehaviorRendererUtils; import org.apache.myfaces.test.mock.MockFacesContext; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class ClientBehaviorRendererUtilsTest extends AbstractFacesTestCase +class ClientBehaviorRendererUtilsTest extends AbstractFacesTestCase { @Override @@ -50,7 +51,7 @@ public void setUp() throws Exception } @Test - public void testBuildBehaviorChain() + void buildBehaviorChain() { Map> behaviors = new HashMap>(); @@ -58,12 +59,12 @@ public void testBuildBehaviorChain() Collection params = new ArrayList(); UIComponent component = new HtmlInputText(); - Assertions.assertEquals("", ClientBehaviorRendererUtils.buildBehaviorChain(facesContext, component, + assertEquals("", ClientBehaviorRendererUtils.buildBehaviorChain(facesContext, component, component.getClientId(facesContext), ClientBehaviorEvents.CLICK, params, ClientBehaviorEvents.ACTION, params, behaviors, null, null)); - Assertions.assertEquals("return faces.util.chain(document.getElementById('j_id__v_0'), event,'huhn', 'suppe');", + assertEquals("return faces.util.chain(document.getElementById('j_id__v_0'), event,'huhn', 'suppe');", ClientBehaviorRendererUtils.buildBehaviorChain(facesContext, component, component.getClientId(facesContext), ClientBehaviorEvents.CLICK, params, ClientBehaviorEvents.ACTION, params, behaviors, "huhn", @@ -86,16 +87,16 @@ public Set getHints() behaviors.put(ClientBehaviorEvents.CLICK, Arrays.asList(submittingBehavior)); - Assertions.assertEquals("faces.util.chain(document.getElementById('j_id__v_0'), event,'huhn', 'script()', 'suppe'); return false;", + assertEquals("faces.util.chain(document.getElementById('j_id__v_0'), event,'huhn', 'script()', 'suppe'); return false;", ClientBehaviorRendererUtils.buildBehaviorChain(facesContext, component, component.getClientId(facesContext), ClientBehaviorEvents.CLICK, params, ClientBehaviorEvents.ACTION, params, behaviors, "huhn", "suppe")); } - + @Test - public void testBuildBehaviorChain2() + void buildBehaviorChain2() { Map> behaviors = new HashMap>(); @@ -103,11 +104,11 @@ public void testBuildBehaviorChain2() Collection params = new ArrayList(); UIComponent component = new HtmlInputText(); - Assertions.assertEquals("", ClientBehaviorRendererUtils.buildBehaviorChain(facesContext, component, + assertEquals("", ClientBehaviorRendererUtils.buildBehaviorChain(facesContext, component, ClientBehaviorEvents.CLICK, params, ClientBehaviorEvents.ACTION, params, behaviors, null, null)); - Assertions.assertEquals("return faces.util.chain(this, event,'huhn', 'suppe');", + assertEquals("return faces.util.chain(this, event,'huhn', 'suppe');", ClientBehaviorRendererUtils.buildBehaviorChain(facesContext, component, ClientBehaviorEvents.CLICK, params, ClientBehaviorEvents.ACTION, params, behaviors, "huhn", "suppe")); @@ -129,26 +130,26 @@ public Set getHints() behaviors.put(ClientBehaviorEvents.CLICK, Arrays.asList(submittingBehavior)); - Assertions.assertEquals("faces.util.chain(this, event,'huhn', 'script()', 'suppe'); return false;", + assertEquals("faces.util.chain(this, event,'huhn', 'script()', 'suppe'); return false;", ClientBehaviorRendererUtils.buildBehaviorChain(facesContext, component, ClientBehaviorEvents.CLICK, params, ClientBehaviorEvents.ACTION, params, behaviors, "huhn", "suppe")); - } - + } + @Test - public void testEscapeJavaScriptForChain() + void escapeJavaScriptForChain() { MockFacesContext facesContext = new MockFacesContext(); - Assertions.assertEquals("var foo = " \\\\" test "; alert(foo);", + assertEquals("var foo = " \\\\" test "; alert(foo);", ClientBehaviorRendererUtils.escapeJavaScriptForChain(facesContext, "var foo = " \\" test "; alert(foo);")); - Assertions.assertEquals("var foo = \\'bar \\'", + assertEquals("var foo = \\'bar \\'", ClientBehaviorRendererUtils.escapeJavaScriptForChain(facesContext, "var foo = 'bar '")); - Assertions.assertEquals("var foo = \\'bar \\\\\\' \\'", + assertEquals("var foo = \\'bar \\\\\\' \\'", ClientBehaviorRendererUtils.escapeJavaScriptForChain(facesContext, "var foo = 'bar \\' '")); } } \ No newline at end of file diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlBodyRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlBodyRendererTest.java index 9d7e38a4e0..832f43099f 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlBodyRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlBodyRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.StringWriter; import jakarta.faces.component.html.HtmlBody; @@ -31,14 +33,13 @@ import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil; import org.apache.myfaces.test.utils.HtmlRenderedAttr; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; /** * @author Leonardo Uribe */ -public class HtmlBodyRendererTest extends AbstractFacesTestCase +class HtmlBodyRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer ; @@ -71,9 +72,9 @@ public void tearDown() throws Exception super.tearDown(); writer = null; } - + @Test - public void testHtmlPropertyPassTru2() throws Exception + void htmlPropertyPassTru2() throws Exception { HtmlRenderedAttr[] attrs = { new HtmlRenderedAttr("xmlns") @@ -82,19 +83,19 @@ public void testHtmlPropertyPassTru2() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( body, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs(); HtmlCheckAttributesUtil.checkRenderedAttributes( body, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlButtonRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlButtonRendererTest.java index 82cda028f1..b8d2bbfb3a 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlButtonRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlButtonRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.*; + import java.io.StringWriter; import jakarta.faces.component.UIParameter; @@ -40,7 +42,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class HtmlButtonRendererTest extends AbstractFacesTestCase { +class HtmlButtonRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer; private HtmlCommandButton commandButton; @@ -81,7 +83,7 @@ public void tearDown() throws Exception { } @Test - public void testJSNotAllowedHtmlPropertyPassTru() throws Exception { + void jSNotAllowedHtmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = { //_AccesskeyProperty new HtmlRenderedAttr("accesskey"), @@ -127,12 +129,12 @@ public void testJSNotAllowedHtmlPropertyPassTru() throws Exception { HtmlCheckAttributesUtil.checkRenderedAttributes( commandButton, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testAllowedHtmlPropertyPassTru() throws Exception { + void allowedHtmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = { //_AccesskeyProperty new HtmlRenderedAttr("accesskey"), @@ -175,32 +177,27 @@ public void testAllowedHtmlPropertyPassTru() throws Exception { HtmlCheckAttributesUtil.checkRenderedAttributes( commandButton, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndName() + void clientBehaviorHolderRendersIdAndName() { commandButton.addClientBehavior("focus", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { commandButton.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } - + /** * If a h:commandButton has any UIParameter children, he should * render them with a renderer of family jakarta.faces.Input and @@ -210,7 +207,7 @@ public void testClientBehaviorHolderRendersIdAndName() * @throws Exception */ @Test - public void testCommandButtonRendersNotDisabledUIParameters() throws Exception + void commandButtonRendersNotDisabledUIParameters() throws Exception { UIParameter param1 = new UIParameter(); param1.setName("param1"); @@ -226,10 +223,10 @@ public void testCommandButtonRendersNotDisabledUIParameters() throws Exception commandButton.encodeAll(facesContext); String output = writer.getWriter().toString(); - Assertions.assertFalse(output.contains("param1")); - Assertions.assertFalse(output.contains("value1")); - Assertions.assertTrue(output.contains("param2")); - Assertions.assertTrue(output.contains("value2")); + assertFalse(output.contains("param1")); + assertFalse(output.contains("value1")); + assertTrue(output.contains("param2")); + assertTrue(output.contains("value2")); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlCheckboxRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlCheckboxRendererTest.java index 678c016692..9e303cfba3 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlCheckboxRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlCheckboxRendererTest.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.StringWriter; import jakarta.faces.component.UISelectItem; @@ -39,7 +42,7 @@ * @author Bruno Aranda (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlCheckboxRendererTest extends AbstractFacesTestCase +class HtmlCheckboxRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer ; private HtmlSelectManyCheckbox selectManyCheckbox; @@ -81,7 +84,7 @@ public void tearDown() throws Exception } @Test - public void testSelectManyHtmlPropertyPassTru() throws Exception + void selectManyHtmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = { //_AccesskeyProperty @@ -123,12 +126,12 @@ public void testSelectManyHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( selectManyCheckbox, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testSelectBooleanHtmlPropertyPasstru() throws Exception + void selectBooleanHtmlPropertyPasstru() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs(); @@ -137,37 +140,32 @@ public void testSelectBooleanHtmlPropertyPasstru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( selectBooleanCheckbox, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } - } - + } + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndNameSelectBooleanCheckbox() + void clientBehaviorHolderRendersIdAndNameSelectBooleanCheckbox() { selectBooleanCheckbox.addClientBehavior("focus", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { selectBooleanCheckbox.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndNameSelectManyCheckbox() + void clientBehaviorHolderRendersIdAndNameSelectManyCheckbox() { UISelectItem item1 = new UISelectItem(); item1.setItemLabel("#1"); @@ -178,19 +176,14 @@ public void testClientBehaviorHolderRendersIdAndNameSelectManyCheckbox() item2.setItemValue("#2"); selectManyCheckbox.addClientBehavior("focus", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { selectManyCheckbox.getChildren().add(item1); selectManyCheckbox.getChildren().add(item2); selectManyCheckbox.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlDoctypeRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlDoctypeRendererTest.java index b015edb3e7..173c068b0e 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlDoctypeRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlDoctypeRendererTest.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.StringWriter; import jakarta.faces.component.html.HtmlDoctype; @@ -31,7 +34,6 @@ import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil; import org.apache.myfaces.test.utils.HtmlRenderedAttr; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -70,9 +72,9 @@ public void tearDown() throws Exception super.tearDown(); writer = null; } - + @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = { new HtmlRenderedAttr("rootElement","rootElement", "rootElement"), @@ -83,10 +85,10 @@ public void testHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( doctype, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } - Assertions.assertTrue( + assertTrue( writer.getWriter().toString().contains("")); } @@ -97,7 +99,7 @@ public void testHtml5Doctype() throws Exception doctype.encodeAll(facesContext); facesContext.renderResponse(); - Assertions.assertTrue(writer.getWriter().toString().contains("")); + assertTrue(writer.getWriter().toString().contains("")); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlEscapeRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlEscapeRendererTest.java index 47a29bb60f..78094b4433 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlEscapeRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlEscapeRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import jakarta.faces.component.UIComponent; @@ -35,7 +37,6 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.apache.myfaces.test.mock.MockRenderKitFactory; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -126,7 +127,7 @@ public void tearDown() throws Exception } @Test - public void testOutputTextEscapeValue() throws Exception + void outputTextEscapeValue() throws Exception { for (String contentType: CONTENT_TYPES) { @@ -143,13 +144,13 @@ public void testOutputTextEscapeValue() throws Exception outputText.encodeEnd(facesContext); facesContext.renderResponse(); String output = swriter.toString(); - Assertions.assertTrue(output.contains(TEST_STRING_ESCAPED)); + assertTrue(output.contains(TEST_STRING_ESCAPED)); } } } @Test - public void testOutputTextNoEscapeValue() throws Exception + void outputTextNoEscapeValue() throws Exception { for (String contentType: CONTENT_TYPES) @@ -164,13 +165,13 @@ public void testOutputTextNoEscapeValue() throws Exception outputText.encodeEnd(facesContext); facesContext.renderResponse(); String output = swriter.toString(); - Assertions.assertTrue(output.contains(TEST_STRING)); + assertTrue(output.contains(TEST_STRING)); } } } - + @Test - public void testOutputLabelEscapeValue() throws Exception + void outputLabelEscapeValue() throws Exception { for (String contentType: CONTENT_TYPES) { @@ -187,13 +188,13 @@ public void testOutputLabelEscapeValue() throws Exception outputLabel.encodeAll(facesContext); facesContext.renderResponse(); String output = swriter.toString(); - Assertions.assertTrue(output.contains(TEST_STRING_ESCAPED)); + assertTrue(output.contains(TEST_STRING_ESCAPED)); } } } - + @Test - public void testOutputLabelNoEscapeValue() throws Exception + void outputLabelNoEscapeValue() throws Exception { for (String contentType: CONTENT_TYPES) @@ -208,13 +209,13 @@ public void testOutputLabelNoEscapeValue() throws Exception outputLabel.encodeAll(facesContext); facesContext.renderResponse(); String output = swriter.toString(); - Assertions.assertTrue(output.contains(TEST_STRING)); + assertTrue(output.contains(TEST_STRING)); } } } - + @Test - public void testUISelectOneEscapeValue() throws Exception + void uISelectOneEscapeValue() throws Exception { for (String contentType: CONTENT_TYPES) { @@ -242,11 +243,11 @@ public void tryUISelectEscapeValue(UIComponent component, String contentType, St component.encodeAll(facesContext); facesContext.renderResponse(); String output = swriter.toString(); - Assertions.assertTrue(output.contains(TEST_STRING_ESCAPED)); + assertTrue(output.contains(TEST_STRING_ESCAPED)); } - + @Test - public void testUISelectNoEscapeValue() throws Exception + void uISelectNoEscapeValue() throws Exception { for (String contentType: CONTENT_TYPES) { @@ -274,6 +275,6 @@ public void tryUISelectNoEscapeValue(UIComponent component, String contentType, component.encodeAll(facesContext); facesContext.renderResponse(); String output = swriter.toString(); - Assertions.assertTrue(output.contains(TEST_STRING)); + assertTrue(output.contains(TEST_STRING)); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormRendererTest.java index b3e6be5b5c..99ed506088 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormRendererTest.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.PrintWriter; import java.io.StringWriter; @@ -35,7 +38,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class HtmlFormRendererTest extends AbstractFacesTestCase +class HtmlFormRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer ; private HtmlForm form; @@ -71,7 +74,7 @@ public void tearDown() throws Exception } @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs(); @@ -81,15 +84,15 @@ public void testHtmlPropertyPassTru() throws Exception } catch(Exception e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); - Assertions.fail(sw.toString() + "\nHTML.FORM_PASSTHROUGH_ATTRIBUTES: " + printHTMLAttrs(HTML.FORM_PASSTHROUGH_ATTRIBUTES)); + fail(sw.toString() + "\nHTML.FORM_PASSTHROUGH_ATTRIBUTES: " + printHTMLAttrs(HTML.FORM_PASSTHROUGH_ATTRIBUTES)); } if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testHtmlPropertyPassTruNotRendered() throws Exception + void htmlPropertyPassTruNotRendered() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateAttrsNotRenderedForReadOnlyButBehaviorEvents(); @@ -99,10 +102,10 @@ public void testHtmlPropertyPassTruNotRendered() throws Exception } catch(Exception e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); - Assertions.fail(sw.toString() + "\nHTML.FORM_PASSTHROUGH_ATTRIBUTES: " + printHTMLAttrs(HTML.FORM_PASSTHROUGH_ATTRIBUTES)); + fail(sw.toString() + "\nHTML.FORM_PASSTHROUGH_ATTRIBUTES: " + printHTMLAttrs(HTML.FORM_PASSTHROUGH_ATTRIBUTES)); } if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } @@ -116,25 +119,20 @@ private String printHTMLAttrs(String[] attrs) { } return buffer.toString(); } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndName() + void clientBehaviorHolderRendersIdAndName() { form.addClientBehavior("focus", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { form.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormatRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormatRendererTest.java index 539c0267c8..6a5e1354e3 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormatRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormatRendererTest.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.StringWriter; import jakarta.faces.component.UIParameter; @@ -28,11 +31,10 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.apache.myfaces.test.mock.MockRenderKitFactory; import org.apache.myfaces.test.mock.MockResponseWriter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class HtmlFormatRendererTest extends AbstractFacesTestCase +class HtmlFormatRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer; private HtmlOutputFormat outputFormat; @@ -55,7 +57,7 @@ public void setUp() throws Exception { } @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = { //_UniversalProperties @@ -72,12 +74,12 @@ public void testHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( outputFormat, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testHtmlPropertyPassTruNotRendered() throws Exception + void htmlPropertyPassTruNotRendered() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateAttrsNotRenderedForReadOnly(); @@ -85,17 +87,17 @@ public void testHtmlPropertyPassTruNotRendered() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( outputFormat, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + /** * If the disable attribute of a child UIParameter is true, * he should be ignored. * @throws Exception */ @Test - public void testDisabledUIParameterNotRendered() throws Exception + void disabledUIParameterNotRendered() throws Exception { UIParameter param1 = new UIParameter(); param1.setValue("value1"); @@ -109,6 +111,6 @@ public void testDisabledUIParameterNotRendered() throws Exception outputFormat.encodeAll(facesContext); String output = writer.getWriter().toString(); - Assertions.assertEquals("prefixvalue2-{1}suffix", output); + assertEquals("prefixvalue2-{1}suffix", output); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGridRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGridRendererTest.java index d00c639d78..b555ad2d8d 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGridRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGridRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.*; + import java.io.StringWriter; import jakarta.faces.component.UIColumn; @@ -39,7 +41,7 @@ * @author Bruno Aranda (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlGridRendererTest extends AbstractFacesTestCase +class HtmlGridRendererTest extends AbstractFacesTestCase { private static final String LINE_SEPARATOR = System.getProperty( "line.separator", "\r\n"); @@ -83,7 +85,7 @@ public void tearDown() throws Exception } @Test - public void testRenderTable() throws Exception + void renderTable() throws Exception { UIColumn col1 = new UIColumn(); HtmlOutputText col1Text = new HtmlOutputText(); @@ -104,54 +106,49 @@ public void testRenderTable() throws Exception facesContext.renderResponse(); String output = writer.getWriter().toString(); - Assertions.assertEquals(""+ + assertEquals("
"+ ""+ ""+ ""+"
col1Text
col2Text
", output); } @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs(); HtmlCheckAttributesUtil.checkRenderedAttributes( panelGrid, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testHtmlPropertyPassTruNotRendered() throws Exception + void htmlPropertyPassTruNotRendered() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateAttrsNotRenderedForReadOnlyButBehaviorEvents(); HtmlCheckAttributesUtil.checkRenderedAttributes( panelGrid, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndName() + void clientBehaviorHolderRendersIdAndName() { panelGrid.addClientBehavior("click", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { panelGrid.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java index d27ea90c11..8e5963b31a 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlGroupRendererTest.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.StringWriter; import jakarta.faces.component.behavior.AjaxBehavior; @@ -31,7 +34,6 @@ import org.apache.myfaces.test.mock.MockRenderKitFactory; import org.apache.myfaces.test.mock.MockResponseWriter; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -39,7 +41,7 @@ * @author Bruno Aranda (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlGroupRendererTest extends AbstractFacesTestCase +class HtmlGroupRendererTest extends AbstractFacesTestCase { private static String PANEL_CHILD_TEXT = "PANEL"; @@ -85,9 +87,9 @@ public void tearDown()throws Exception super.tearDown(); writer = null; } - + @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = { //_EventProperties @@ -110,37 +112,37 @@ public void testHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( panelGroup, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testHtmlPropertyPassTruNotRendered() throws Exception + void htmlPropertyPassTruNotRendered() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateAttrsNotRenderedForReadOnlyButBehaviorEvents(); HtmlCheckAttributesUtil.checkRenderedAttributes( panelGroup, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testClientBehaviorHolderRendersIdAndNameOutputLink() + void clientBehaviorHolderRendersIdAndNameOutputLink() { panelGroup.addClientBehavior("keypress", new AjaxBehavior()); try { panelGroup.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.contains("myfaces.ab")); + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.contains("myfaces.ab")); } catch (Exception e) { e.printStackTrace(); - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlHeadRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlHeadRendererTest.java index b9bf56ac45..83e94a7b69 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlHeadRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlHeadRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.StringWriter; import jakarta.faces.component.html.HtmlHead; @@ -28,14 +30,13 @@ import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil; import org.apache.myfaces.test.utils.HtmlRenderedAttr; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; /** * @author Leonardo Uribe */ -public class HtmlHeadRendererTest extends AbstractFacesTestCase +class HtmlHeadRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer ; @@ -68,9 +69,9 @@ public void tearDown()throws Exception super.tearDown(); writer = null; } - + @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = { new HtmlRenderedAttr("xmlns"), @@ -81,7 +82,7 @@ public void testHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( head, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlImageRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlImageRendererTest.java index 8216210f9e..cac97641f3 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlImageRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlImageRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.*; + import java.io.StringWriter; import jakarta.faces.component.behavior.AjaxBehavior; @@ -37,7 +39,7 @@ * @author Bruno Aranda (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlImageRendererTest extends AbstractFacesTestCase +class HtmlImageRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer ; private HtmlGraphicImage graphicImage; @@ -71,7 +73,7 @@ public void tearDown() throws Exception } @Test - public void testRenderDefault() throws Exception + void renderDefault() throws Exception { String imgUrl = "http://www.apache.org/images/feather.gif"; String src = facesContext.getApplication().getViewHandler().getResourceURL(facesContext, imgUrl); @@ -84,11 +86,11 @@ public void testRenderDefault() throws Exception facesContext.renderResponse(); String output = writer.getWriter().toString(); - Assertions.assertEquals("", output); + assertEquals("", output); } @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs(); @@ -98,12 +100,12 @@ public void testHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( graphicImage, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testHtmlPropertyPassTruNotRendered() throws Exception + void htmlPropertyPassTruNotRendered() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateAttrsNotRenderedForReadOnlyButBehaviorEvents(); @@ -113,28 +115,23 @@ public void testHtmlPropertyPassTruNotRendered() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( graphicImage, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndName() + void clientBehaviorHolderRendersIdAndName() { graphicImage.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { graphicImage.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlLabelRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlLabelRendererTest.java index 8c3c2bedba..6c014347b3 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlLabelRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlLabelRendererTest.java @@ -18,7 +18,8 @@ */ package org.apache.myfaces.renderkit.html; -import java.io.IOException; +import static org.junit.jupiter.api.Assertions.*; + import java.io.StringWriter; import jakarta.faces.FactoryFinder; @@ -91,7 +92,7 @@ public void tearDown() throws Exception { } @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = { //_AccesskeyProperty @@ -127,7 +128,7 @@ public void testHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( label, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } @@ -139,9 +140,9 @@ protected String getPageContents() { return writer.getWriter().toString(); } - + @Test - public void testEscapeUntouched() throws IOException + void escapeUntouched() throws Exception { label.setId("labelId"); label.setValue("field label"); @@ -150,11 +151,11 @@ public void testEscapeUntouched() throws IOException label.encodeAll(facesContext); String page = getPageContents(); - Assertions.assertEquals("", page); + assertEquals("", page); } @Test - public void testEscapeSetToFalse() throws IOException + void escapeSetToFalse() throws Exception { label.setId("labelId"); label.setValue("field label"); @@ -164,27 +165,22 @@ public void testEscapeSetToFalse() throws IOException label.encodeAll(facesContext); String page = getPageContents(); - Assertions.assertEquals("", page); + assertEquals("", page); } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndName() + void clientBehaviorHolderRendersIdAndName() { label.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { label.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.contains("id=\"j_id__")); - Assertions.assertTrue(output.contains("name=\"j_id__")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.contains("id=\"j_id__")); + assertTrue(output.contains("name=\"j_id__")); + }); } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlLinkRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlLinkRendererTest.java index fbee2f438a..b9f9bde533 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlLinkRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlLinkRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.*; + import java.io.StringWriter; import jakarta.faces.component.UIForm; @@ -42,7 +44,7 @@ * @author Bruno Aranda (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlLinkRendererTest extends AbstractFacesTestCase +class HtmlLinkRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer; @@ -99,9 +101,9 @@ public void tearDown() throws Exception super.tearDown(); writer = null; } - + @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = { //_AccesskeyProperty @@ -135,12 +137,12 @@ public void testHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( commandLink, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testOutputLink() throws Exception + void outputLink() throws Exception { HtmlRenderedAttr[] attrs = { //_AccesskeyProperty @@ -173,74 +175,59 @@ public void testOutputLink() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( outputLink, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndNameOutputLink() + void clientBehaviorHolderRendersIdAndNameOutputLink() { outputLink.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { outputLink.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndNameCommandLink() + void clientBehaviorHolderRendersIdAndNameCommandLink() { commandLink.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { commandLink.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); //System.out.println("----OUTPUT----"+output); - Assertions.assertTrue(output.matches("(?s).+id=\".+\".+")); - Assertions.assertTrue(output.matches("(?s).+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches("(?s).+id=\".+\".+")); + assertTrue(output.matches("(?s).+name=\".+\".+")); + }); } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndNameOutcomeTargetLink() + void clientBehaviorHolderRendersIdAndNameOutcomeTargetLink() { outcomeTargetLink.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { outcomeTargetLink.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } - + /** * Tests if h:link correctly includes all parameters of the implicit * navigation case created from the outcome. @@ -248,7 +235,7 @@ public void testClientBehaviorHolderRendersIdAndNameOutcomeTargetLink() * @throws Exception */ @Test - public void testOutcomeTargetRendersNavigationCaseParameters() throws Exception + void outcomeTargetRendersNavigationCaseParameters() throws Exception { // configure the link outcomeTargetLink.getAttributes().put("includeViewParams", false); @@ -260,16 +247,16 @@ public void testOutcomeTargetRendersNavigationCaseParameters() throws Exception String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); // make sure the parameters are rendered - Assertions.assertTrue(output.contains("param1=value1")); - Assertions.assertTrue(output.contains("param2=value2")); + assertTrue(output.contains("param1=value1")); + assertTrue(output.contains("param2=value2")); } - + /** * Tests if the fragment attribute is correctly rendered. * @throws Exception */ @Test - public void testOutcomeTargetLinkFragment() throws Exception + void outcomeTargetLinkFragment() throws Exception { // configure the link final String fragment = "end"; @@ -282,31 +269,31 @@ public void testOutcomeTargetLinkFragment() throws Exception String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); // make sure the fragment is rendered - Assertions.assertTrue(output.contains("param1=value1#" + fragment)); + assertTrue(output.contains("param1=value1#" + fragment)); } - + /** * Test for the right use of the fragment attribute. * The value of the fragment attribute is appended to the end of target URL following a hash (#) mark. * @throws Exception */ @Test - public void testOutputLinkFragment() throws Exception + void outputLinkFragment() throws Exception { outputLink.setFragment("fragment"); outputLink.setValue("http://www.irian.at"); outputLink.encodeAll(facesContext); String output = writer.getWriter().toString(); - Assertions.assertEquals("", output); + assertEquals("", output); } - + /** * If the disable attribute of a child UIParameter is true, * he should be ignored. * @throws Exception */ @Test - public void testDisabledUIParameterNotRenderedCommandLink() throws Exception + void disabledUIParameterNotRenderedCommandLink() throws Exception { UIParameter param1 = new UIParameter(); param1.setName("param1"); @@ -320,19 +307,19 @@ public void testDisabledUIParameterNotRenderedCommandLink() throws Exception commandLink.encodeAll(facesContext); String output = writer.getWriter().toString(); - Assertions.assertFalse(output.contains("param1")); - Assertions.assertFalse(output.contains("value1")); - Assertions.assertTrue(output.contains("param2")); - Assertions.assertTrue(output.contains("value2")); + assertFalse(output.contains("param1")); + assertFalse(output.contains("value1")); + assertTrue(output.contains("param2")); + assertTrue(output.contains("value2")); } - + /** * If the disable attribute of a child UIParameter is true, * he should be ignored. * @throws Exception */ @Test - public void testDisabledUIParameterNotRenderedOutputLink() throws Exception + void disabledUIParameterNotRenderedOutputLink() throws Exception { UIParameter param1 = new UIParameter(); param1.setName("param1"); @@ -346,60 +333,50 @@ public void testDisabledUIParameterNotRenderedOutputLink() throws Exception outputLink.encodeAll(facesContext); String output = writer.getWriter().toString(); - Assertions.assertFalse(output.contains("param1")); - Assertions.assertFalse(output.contains("value1")); - Assertions.assertTrue(output.contains("param2")); - Assertions.assertTrue(output.contains("value2")); + assertFalse(output.contains("param1")); + assertFalse(output.contains("value1")); + assertTrue(output.contains("param2")); + assertTrue(output.contains("value2")); } - + /** * Tests if the h:link correctly includes an UIParameter * with a non-null-name when creating the URL. */ @Test - public void testOutcomeTargetLinkIncludesUIParameterInURL() + void outcomeTargetLinkIncludesUIParameterInURL() { // create the UIParameter and attach it UIParameter param = new UIParameter(); param.setName("myParameter"); param.setValue("myValue"); outcomeTargetLink.getChildren().add(param); - - try - { + + Assertions.assertDoesNotThrow(() -> { outcomeTargetLink.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.contains("myParameter=myValue")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.contains("myParameter=myValue")); + }); } - + /** * Tests if the h:link correctly skips an UIParameter * with a null-name when creating the URL. */ @Test - public void testOutcomeTargetLinkSkipsNullValueOfUIParameterInURL() + void outcomeTargetLinkSkipsNullValueOfUIParameterInURL() { // create the UIParameter with value = null and attach it UIParameter param = new UIParameter(); param.setName("myNullParameter"); param.setValue(null); outcomeTargetLink.getChildren().add(param); - - try - { + + Assertions.assertDoesNotThrow(() -> { outcomeTargetLink.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertFalse(output.contains("myNullParameter")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertFalse(output.contains("myNullParameter")); + }); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlListboxRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlListboxRendererTest.java index 902dd80053..89eb05f272 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlListboxRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlListboxRendererTest.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.StringWriter; import java.util.ArrayList; import java.util.List; @@ -43,7 +46,7 @@ * @author Bruno Aranda (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlListboxRendererTest extends AbstractFacesTestCase +class HtmlListboxRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer ; private HtmlSelectOneListbox selectOneListbox; @@ -83,7 +86,7 @@ public void tearDown() throws Exception } @Test - public void testSelectOneHtmlPropertyPassTru() throws Exception + void selectOneHtmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs(false); @@ -98,12 +101,12 @@ public void testSelectOneHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( selectOneListbox, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testSelectManyHtmlPropertyPassTru() throws Exception + void selectManyHtmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs(false); @@ -118,15 +121,15 @@ public void testSelectManyHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( selectManyListbox, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndNameSelectOneListbox() + void clientBehaviorHolderRendersIdAndNameSelectOneListbox() { UISelectItem item1 = new UISelectItem(); item1.setItemLabel("#1"); @@ -137,27 +140,22 @@ public void testClientBehaviorHolderRendersIdAndNameSelectOneListbox() item2.setItemValue("#2"); selectOneListbox.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { selectOneListbox.getChildren().add(item1); selectOneListbox.getChildren().add(item2); selectOneListbox.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndNameSelectManyListbox() + void clientBehaviorHolderRendersIdAndNameSelectManyListbox() { UISelectItem item1 = new UISelectItem(); item1.setItemLabel("#1"); @@ -168,19 +166,14 @@ public void testClientBehaviorHolderRendersIdAndNameSelectManyListbox() item2.setItemValue("#2"); selectManyListbox.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { selectManyListbox.getChildren().add(item1); selectManyListbox.getChildren().add(item2); selectManyListbox.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMenuRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMenuRendererTest.java index 4a06ae7c56..31ed6eab64 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMenuRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMenuRendererTest.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.StringWriter; import java.util.ArrayList; import java.util.List; @@ -43,7 +46,7 @@ * @author Bruno Aranda (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlMenuRendererTest extends AbstractFacesTestCase +class HtmlMenuRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer ; private HtmlSelectOneMenu selectOneMenu; @@ -84,7 +87,7 @@ public void tearDown() throws Exception } @Test - public void testSelectOneHtmlPropertyPassTru() throws Exception + void selectOneHtmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs(false); @@ -99,12 +102,12 @@ public void testSelectOneHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( selectOneMenu, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testSelectManyHtmlPropertyPassTru() throws Exception + void selectManyHtmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs(false); @@ -119,15 +122,15 @@ public void testSelectManyHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( selectManyMenu, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndNameSelectOneMenu() + void clientBehaviorHolderRendersIdAndNameSelectOneMenu() { UISelectItem item1 = new UISelectItem(); item1.setItemLabel("#1"); @@ -138,27 +141,22 @@ public void testClientBehaviorHolderRendersIdAndNameSelectOneMenu() item2.setItemValue("#2"); selectOneMenu.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { selectOneMenu.getChildren().add(item1); selectOneMenu.getChildren().add(item2); selectOneMenu.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndNameSelectManyMenu() + void clientBehaviorHolderRendersIdAndNameSelectManyMenu() { UISelectItem item1 = new UISelectItem(); item1.setItemLabel("#1"); @@ -169,19 +167,14 @@ public void testClientBehaviorHolderRendersIdAndNameSelectManyMenu() item2.setItemValue("#2"); selectManyMenu.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { selectManyMenu.getChildren().add(item1); selectManyMenu.getChildren().add(item2); selectManyMenu.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMessageRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMessageRendererTest.java index 4c3793e7f9..3ffd9480e8 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMessageRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMessageRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.StringWriter; import jakarta.faces.FactoryFinder; @@ -31,7 +33,6 @@ import org.apache.myfaces.test.base.junit.AbstractFacesConfigurableMockTestCase; import org.apache.myfaces.test.mock.MockRenderKitFactory; import org.apache.myfaces.test.mock.MockResponseWriter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -105,7 +106,7 @@ public void setUp() throws Exception } @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = { //_UniversalProperties @@ -142,12 +143,12 @@ public void testHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( message, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testRenderSpanOnlyWhenNecessary() throws Exception + void renderSpanOnlyWhenNecessary() throws Exception { facesContext.addMessage(inputText.getClientId(), new FacesMessage(FacesMessage.Severity.WARN, "warnSummary", "detailWarnSummary")); message.setFor("myInputId"); @@ -156,9 +157,9 @@ public void testRenderSpanOnlyWhenNecessary() throws Exception String output = writer.getWriter().toString(); //System.out.println(output); } - + @Test - public void testHtmlPropertyPassTruNotRendered() throws Exception + void htmlPropertyPassTruNotRendered() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateAttrsNotRenderedForReadOnly(); @@ -175,7 +176,7 @@ public void testHtmlPropertyPassTruNotRendered() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( message, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMessagesRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMessagesRendererTest.java index 4d7c5b9513..f620558d67 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMessagesRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMessagesRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.*; + import java.io.StringWriter; import jakarta.faces.FactoryFinder; @@ -30,7 +32,6 @@ import org.apache.myfaces.test.mock.MockRenderKitFactory; import org.apache.myfaces.test.mock.MockResponseWriter; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -95,7 +96,7 @@ public void tearDown() throws Exception } @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = { //_EventProperties @@ -132,51 +133,51 @@ public void testHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( messages, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testRenderSpanOnlyWhenNecessary1() throws Exception + void renderSpanOnlyWhenNecessary1() throws Exception { facesContext.addMessage("test1", new FacesMessage(FacesMessage.Severity.WARN, "warnSummary", "detailWarnSummary")); messages.encodeEnd(facesContext); facesContext.renderResponse(); String output = writer.getWriter().toString(); - Assertions.assertTrue(output.contains("warnSummary")); - Assertions.assertTrue(!output.contains("span")); + assertTrue(output.contains("warnSummary")); + assertFalse(output.contains("span")); } - + @Test - public void testRenderSpanOnlyWhenNecessary2() throws Exception + void renderSpanOnlyWhenNecessary2() throws Exception { facesContext.addMessage("test1", new FacesMessage(FacesMessage.Severity.WARN, "warnSummary", "detailWarnSummary")); messages.setLayout("table"); messages.encodeEnd(facesContext); facesContext.renderResponse(); String output = writer.getWriter().toString(); - Assertions.assertTrue(output.contains("warnSummary")); - Assertions.assertTrue(!output.contains("span")); + assertTrue(output.contains("warnSummary")); + assertFalse(output.contains("span")); } - + @Test - public void testRenderSpanOnlyWhenNecessary3() throws Exception + void renderSpanOnlyWhenNecessary3() throws Exception { facesContext.addMessage("test1", new FacesMessage(FacesMessage.Severity.WARN, "warnSummary", "detailWarnSummary")); messages.setId("msgPanel"); messages.encodeEnd(facesContext); facesContext.renderResponse(); String output = writer.getWriter().toString(); - Assertions.assertTrue(output.contains("warnSummary")); - Assertions.assertTrue(!output.contains("span")); + assertTrue(output.contains("warnSummary")); + assertFalse(output.contains("span")); } - + /** * It should output the class on li * @throws Exception */ @Test - public void testRenderSpanOnlyWhenNecessary4() throws Exception + void renderSpanOnlyWhenNecessary4() throws Exception { facesContext.addMessage("test1", new FacesMessage(FacesMessage.Severity.FATAL, "fatalSummary", "detailFatalSummary")); messages.setId("msgPanel"); @@ -184,17 +185,17 @@ public void testRenderSpanOnlyWhenNecessary4() throws Exception messages.encodeEnd(facesContext); facesContext.renderResponse(); String output = writer.getWriter().toString(); - Assertions.assertTrue(output.contains("fatalSummary")); - Assertions.assertTrue(output.contains("li class=\"fatalClass\"")); - Assertions.assertTrue(!output.contains("span")); + assertTrue(output.contains("fatalSummary")); + assertTrue(output.contains("li class=\"fatalClass\"")); + assertFalse(output.contains("span")); } - + /** * It should output the class on td * @throws Exception */ @Test - public void testRenderSpanOnlyWhenNecessary5() throws Exception + void renderSpanOnlyWhenNecessary5() throws Exception { facesContext.addMessage("test1", new FacesMessage(FacesMessage.Severity.FATAL, "fatalSummary", "detailFatalSummary")); messages.setId("msgPanel"); @@ -203,13 +204,13 @@ public void testRenderSpanOnlyWhenNecessary5() throws Exception messages.encodeEnd(facesContext); facesContext.renderResponse(); String output = writer.getWriter().toString(); - Assertions.assertTrue(output.contains("fatalSummary")); - Assertions.assertTrue(output.contains("td class=\"fatalClass\"")); - Assertions.assertTrue(!output.contains("span")); + assertTrue(output.contains("fatalSummary")); + assertTrue(output.contains("td class=\"fatalClass\"")); + assertFalse(output.contains("span")); } - + @Test - public void testHtmlPropertyPassTruNotRendered() throws Exception + void htmlPropertyPassTruNotRendered() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateAttrsNotRenderedForReadOnly(); @@ -227,7 +228,7 @@ public void testHtmlPropertyPassTruNotRendered() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( messages, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlOutcomeTargetButtonRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlOutcomeTargetButtonRendererTest.java index 2403027c8c..a5dc05e760 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlOutcomeTargetButtonRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlOutcomeTargetButtonRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.*; + import java.io.StringWriter; import jakarta.faces.component.UIParameter; @@ -30,9 +32,9 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.apache.myfaces.test.mock.MockRenderKitFactory; import org.apache.myfaces.test.mock.MockResponseWriter; -import org.junit.jupiter.api.Assertions; import org.apache.myfaces.renderkit.html.util.ComponentAttrs; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -42,7 +44,7 @@ * @author Jakob Korherr (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlOutcomeTargetButtonRendererTest extends AbstractFacesTestCase +class HtmlOutcomeTargetButtonRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer; @@ -83,28 +85,23 @@ public void tearDown() throws Exception form = null; outcomeTargetButton = null; } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndName() + void clientBehaviorHolderRendersIdAndName() { outcomeTargetButton.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { outcomeTargetButton.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } - + /** * Tests if h:button correctly includes all parameters of the implicit * navigation case created from the outcome. @@ -112,7 +109,7 @@ public void testClientBehaviorHolderRendersIdAndName() * @throws Exception */ @Test - public void testOutcomeTargetRendersNavigationCaseParameters() throws Exception + void outcomeTargetRendersNavigationCaseParameters() throws Exception { // configure the button outcomeTargetButton.getAttributes().put("includeViewParams", false); @@ -124,16 +121,16 @@ public void testOutcomeTargetRendersNavigationCaseParameters() throws Exception String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); // make sure the parameters are rendered - Assertions.assertTrue(output.contains("param1=value1")); - Assertions.assertTrue(output.contains("param2=value2")); + assertTrue(output.contains("param1=value1")); + assertTrue(output.contains("param2=value2")); } - + /** * Tests if the fragment attribute is correctly rendered. * @throws Exception */ @Test - public void testFragment() throws Exception + void fragment() throws Exception { // configure the button final String fragment = "end"; @@ -146,79 +143,64 @@ public void testFragment() throws Exception String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); // make sure the fragment is rendered - Assertions.assertTrue(output.contains("param1=value1#" + fragment)); + assertTrue(output.contains("param1=value1#" + fragment)); } - + /** * Tests if the h:button correctly includes an UIParameter * with a non-null-name when creating the URL. */ @Test - public void testIncludesUIParameterInURL() + void includesUIParameterInURL() { // create the UIParameter and attach it UIParameter param = new UIParameter(); param.setName("myParameter"); param.setValue("myValue"); outcomeTargetButton.getChildren().add(param); - - try - { + + Assertions.assertDoesNotThrow(() -> { outcomeTargetButton.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.contains("myParameter=myValue")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.contains("myParameter=myValue")); + }); } - + /** * Tests if the h:button correctly skips an UIParameter * with a null-name when creating the URL. */ @Test - public void testSkipsNullValueOfUIParameterInURL() + void skipsNullValueOfUIParameterInURL() { // create the UIParameter with value = null and attach it UIParameter param = new UIParameter(); param.setName("myNullParameter"); param.setValue(null); outcomeTargetButton.getChildren().add(param); - - try - { + + Assertions.assertDoesNotThrow(() -> { outcomeTargetButton.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertFalse(output.contains("myNullParameter")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertFalse(output.contains("myNullParameter")); + }); } - + /** * Tests if the h:button is rendered accordingly if disabled is true. */ @Test - public void testDisabledAttribute() + void disabledAttribute() { outcomeTargetButton.getAttributes().put(ComponentAttrs.DISABLED_ATTR, Boolean.TRUE); - try - { + Assertions.assertDoesNotThrow(() -> { outcomeTargetButton.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - + // Assertions - Assertions.assertFalse(output.contains(HTML.ONCLICK_ATTR)); // the output must not contain onclick - Assertions.assertTrue(output.contains(HTML.DISABLED_ATTR)); // the output must contain disabled - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertFalse(output.contains(HTML.ONCLICK_ATTR)); // the output must not contain onclick + assertTrue(output.contains(HTML.DISABLED_ATTR)); // the output must contain disabled + }); } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlRadioRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlRadioRendererTest.java index 86ab8dd6d9..c26d962f15 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlRadioRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlRadioRendererTest.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.StringWriter; import java.util.ArrayList; import java.util.List; @@ -42,7 +45,7 @@ * @author Bruno Aranda (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlRadioRendererTest extends AbstractFacesTestCase +class HtmlRadioRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer ; private HtmlSelectOneRadio selectOneRadio; @@ -75,9 +78,9 @@ public void tearDown() throws Exception selectOneRadio = null; writer = null; } - + @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = { //_AccesskeyProperty @@ -123,15 +126,15 @@ public void testHtmlPropertyPassTru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( selectOneRadio, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndName() + void clientBehaviorHolderRendersIdAndName() { UISelectItem item1 = new UISelectItem(); item1.setItemLabel("#1"); @@ -142,19 +145,14 @@ public void testClientBehaviorHolderRendersIdAndName() item2.setItemValue("#2"); selectOneRadio.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { selectOneRadio.getChildren().add(item1); selectOneRadio.getChildren().add(item2); selectOneRadio.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManagerTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManagerTest.java index 378a1d2117..7397aac01f 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManagerTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManagerTest.java @@ -18,19 +18,21 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import jakarta.faces.render.ResponseStateManager; import org.apache.myfaces.test.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -public class HtmlResponseStateManagerTest extends AbstractFacesTestCase +class HtmlResponseStateManagerTest extends AbstractFacesTestCase { @Test - public void testIsPostback() + void isPostback() { Mockito.when(_facesContext.getExternalContext()).thenReturn(_externalContext); Mockito.when(_externalContext.getApplicationMap()).thenReturn(new ConcurrentHashMap<>()); @@ -41,11 +43,11 @@ public void testIsPostback() map.put(ResponseStateManager.VIEW_STATE_PARAM, "seomthing"); Mockito.when(_externalContext.getRequestParameterMap()).thenReturn(map); - Assertions.assertEquals(true, hrsm.isPostback(_facesContext)); + assertTrue(hrsm.isPostback(_facesContext)); } - + @Test - public void testIsNoPostback() + void isNoPostback() { Mockito.when(_facesContext.getExternalContext()).thenReturn(_externalContext); Mockito.when(_externalContext.getApplicationMap()).thenReturn(new ConcurrentHashMap<>()); @@ -53,6 +55,6 @@ public void testIsNoPostback() HtmlResponseStateManager hrsm = Mockito.spy(HtmlResponseStateManager.class); - Assertions.assertEquals(false, hrsm.isPostback(_facesContext)); + assertFalse(hrsm.isPostback(_facesContext)); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlResponseWriterImplTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlResponseWriterImplTest.java index 3133df1de9..0b843b390e 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlResponseWriterImplTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlResponseWriterImplTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.*; + import java.io.IOException; import java.io.StringWriter; import java.lang.reflect.Field; @@ -26,14 +28,13 @@ import org.apache.myfaces.renderkit.html.util.HTML; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; /** * Test class for HtmlResponseWriterImpl. */ -public class HtmlResponseWriterImplTest extends AbstractFacesTestCase +class HtmlResponseWriterImplTest extends AbstractFacesTestCase { private static final String COMMENT_START = " "); + assertNotNull(output); + assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); + assertTrue(output.contains(CommentUtils.COMMENT_SIMPLE_START), "script does not have start comment "); } - + @Test - public void testScriptOnHtmlIsoEncodingAndNoScriptXhmlComments() throws IOException + void scriptOnHtmlIsoEncodingAndNoScriptXhmlComments() throws Exception { _writer = new HtmlResponseWriterImpl(_stringWriter, "text/html", "ISO-8859-1", false); String innerScript = "document.write('HELLO');"; @@ -177,14 +177,14 @@ public void testScriptOnHtmlIsoEncodingAndNoScriptXhmlComments() throws IOExcept _writer.endDocument(); String output = _stringWriter.toString(); - Assertions.assertNotNull(output); - Assertions.assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); - Assertions.assertFalse(output.contains(CommentUtils.COMMENT_SIMPLE_START), "script have start comment "); + assertNotNull(output); + assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); + assertFalse(output.contains(CommentUtils.COMMENT_SIMPLE_START), "script have start comment "); } @Test - public void testScriptOnHtmlUTF8AndScriptXhmlComments() throws IOException + void scriptOnHtmlUTF8AndScriptXhmlComments() throws Exception { _writer = new HtmlResponseWriterImpl(_stringWriter, "text/html", "UTF-8", true); String innerScript = "document.write('HELLO');"; @@ -195,14 +195,14 @@ public void testScriptOnHtmlUTF8AndScriptXhmlComments() throws IOException _writer.endDocument(); String output = _stringWriter.toString(); - Assertions.assertNotNull(output); - Assertions.assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); - Assertions.assertTrue(output.contains(CommentUtils.COMMENT_SIMPLE_START), "script does not have start comment "); + assertNotNull(output); + assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); + assertTrue(output.contains(CommentUtils.COMMENT_SIMPLE_START), "script does not have start comment "); } - + @Test - public void testScriptOnHtmlUTF8AndNoScriptXhmlComments() throws IOException + void scriptOnHtmlUTF8AndNoScriptXhmlComments() throws Exception { _writer = new HtmlResponseWriterImpl(_stringWriter, "text/html", "UTF-8", false); String innerScript = "document.write('HELLO');"; @@ -213,14 +213,14 @@ public void testScriptOnHtmlUTF8AndNoScriptXhmlComments() throws IOException _writer.endDocument(); String output = _stringWriter.toString(); - Assertions.assertNotNull(output); - Assertions.assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); - Assertions.assertFalse(output.contains(CommentUtils.COMMENT_SIMPLE_START), "script have start comment "); + assertNotNull(output); + assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); + assertFalse(output.contains(CommentUtils.COMMENT_SIMPLE_START), "script have start comment "); } @Test - public void testScriptOnXhtmlIsoEncoding() throws IOException + void scriptOnXhtmlIsoEncoding() throws Exception { _writer = new HtmlResponseWriterImpl(_stringWriter, "application/xhtml+xml", "ISO-8859-1", true); String innerScript = "document.write('HELLO');"; @@ -231,14 +231,14 @@ public void testScriptOnXhtmlIsoEncoding() throws IOException _writer.endDocument(); String output = _stringWriter.toString(); - Assertions.assertNotNull(output); - Assertions.assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); - Assertions.assertTrue(output.contains(CommentUtils.INLINE_SCRIPT_COMMENT+CommentUtils.CDATA_SIMPLE_START), "script does not have start "); + assertNotNull(output); + assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); + assertTrue(output.contains(CommentUtils.INLINE_SCRIPT_COMMENT+CommentUtils.CDATA_SIMPLE_START), "script does not have start "); } @Test - public void testScriptOnXhtmlUTF8Encoding() throws IOException + void scriptOnXhtmlUTF8Encoding() throws Exception { _writer = new HtmlResponseWriterImpl(_stringWriter, "application/xhtml+xml", "UTF-8", false); String innerScript = "document.write('HELLO');"; @@ -249,14 +249,14 @@ public void testScriptOnXhtmlUTF8Encoding() throws IOException _writer.endDocument(); String output = _stringWriter.toString(); - Assertions.assertNotNull(output); - Assertions.assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); - Assertions.assertTrue(output.contains(CommentUtils.INLINE_SCRIPT_COMMENT+CommentUtils.CDATA_SIMPLE_START), "script does not have start "); + assertNotNull(output); + assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); + assertTrue(output.contains(CommentUtils.INLINE_SCRIPT_COMMENT+CommentUtils.CDATA_SIMPLE_START), "script does not have start "); } - + @Test - public void testStyleOnXhtmlIsoEncoding() throws IOException + void styleOnXhtmlIsoEncoding() throws Exception { _writer = new HtmlResponseWriterImpl(_stringWriter, "application/xhtml+xml", "ISO-8859-1", true); String innerScript = "document.write('HELLO');"; @@ -267,14 +267,14 @@ public void testStyleOnXhtmlIsoEncoding() throws IOException _writer.endDocument(); String output = _stringWriter.toString(); - Assertions.assertNotNull(output); - Assertions.assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); - Assertions.assertTrue(output.contains(CommentUtils.CDATA_SIMPLE_START), "script does not have start "); + assertNotNull(output); + assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); + assertTrue(output.contains(CommentUtils.CDATA_SIMPLE_START), "script does not have start "); } @Test - public void testStyleOnXhtmlUTF8Encoding() throws IOException + void styleOnXhtmlUTF8Encoding() throws Exception { _writer = new HtmlResponseWriterImpl(_stringWriter, "application/xhtml+xml", "UTF-8", false); String innerScript = "document.write('HELLO');"; @@ -285,18 +285,18 @@ public void testStyleOnXhtmlUTF8Encoding() throws IOException _writer.endDocument(); String output = _stringWriter.toString(); - Assertions.assertNotNull(output); - Assertions.assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); - Assertions.assertTrue(output.contains(CommentUtils.CDATA_SIMPLE_START), "script does not have start "); + assertNotNull(output); + assertTrue(output.contains(innerScript), "script does not contain body:" + innerScript); + assertTrue(output.contains(CommentUtils.CDATA_SIMPLE_START), "script does not have start "); } - + /** * writeText(char[]) inside a textarea must NOT map successive spaces to &nbsp; * or newlines to <br/> — this is the key purpose of the _isTextArea flag. */ @Test - public void testTextareaWriteTextPreservesSpacesAndNewlines() throws IOException + void textareaWriteTextPreservesSpacesAndNewlines() throws Exception { _writer.startDocument(); _writer.startElement("form", null); @@ -308,13 +308,13 @@ public void testTextareaWriteTextPreservesSpacesAndNewlines() throws IOException String output = _stringWriter.toString(); // Spaces must not be turned into   inside a textarea - Assertions.assertFalse(output.contains(" "), + assertFalse(output.contains(" "), "textarea: spaces must not be encoded as  "); // Newlines must not be turned into
inside a textarea - Assertions.assertFalse(output.contains(""); // The original characters must appear verbatim - Assertions.assertTrue(output.contains("hello world"), + assertTrue(output.contains("hello world"), "textarea: original spaces must be present in output"); } @@ -323,7 +323,7 @@ public void testTextareaWriteTextPreservesSpacesAndNewlines() throws IOException * to verify case-insensitive textarea detection. */ @Test - public void testTextareaWriteTextUppercase() throws IOException + void textareaWriteTextUppercase() throws Exception { _writer.startDocument(); _writer.startElement("form", null); @@ -334,7 +334,7 @@ public void testTextareaWriteTextUppercase() throws IOException _writer.endDocument(); String output = _stringWriter.toString(); - Assertions.assertFalse(output.contains(" "), + assertFalse(output.contains(" "), "TEXTAREA (uppercase): spaces must not be encoded as  "); } @@ -343,7 +343,7 @@ public void testTextareaWriteTextUppercase() throws IOException * writeText(Object) with the equivalent String — exercises the toString() fallback path. */ @Test - public void testWriteTextObjectNonString() throws IOException + void writeTextObjectNonString() throws Exception { _writer.startDocument(); _writer.startElement("body", null); @@ -351,7 +351,7 @@ public void testWriteTextObjectNonString() throws IOException _writer.endElement("body"); _writer.endDocument(); - Assertions.assertTrue(_stringWriter.toString().contains("42"), + assertTrue(_stringWriter.toString().contains("42"), "Non-String value (Integer 42) must be rendered as its toString()"); } @@ -360,7 +360,7 @@ public void testWriteTextObjectNonString() throws IOException * (exercises the StreamCharBuffer.writeTo path in writeStyleContent). */ @Test - public void testStyleOnHtmlWritesContentVerbatim() throws IOException + void styleOnHtmlWritesContentVerbatim() throws Exception { _writer = new HtmlResponseWriterImpl(_stringWriter, "text/html", "UTF-8", false); String css = "body { color: red; }"; @@ -371,10 +371,10 @@ public void testStyleOnHtmlWritesContentVerbatim() throws IOException _writer.endDocument(); String output = _stringWriter.toString(); - Assertions.assertTrue(output.contains(css), + assertTrue(output.contains(css), "Plain HTML style content must appear verbatim in output"); // In plain text/html there is no CDATA wrapping - Assertions.assertFalse(output.contains(CommentUtils.CDATA_SIMPLE_START), + assertFalse(output.contains(CommentUtils.CDATA_SIMPLE_START), "Plain HTML style must not be wrapped in CDATA"); } @@ -384,7 +384,7 @@ public void testStyleOnHtmlWritesContentVerbatim() throws IOException * @throws IOException */ @Test - public void testEmptyTagNotRenderEnd() throws IOException + void emptyTagNotRenderEnd() throws Exception { _writer.startDocument(); _writer.startElement("body", null); @@ -396,18 +396,18 @@ public void testEmptyTagNotRenderEnd() throws IOException // the following should render
hello String output = _stringWriter.toString(); - Assertions.assertNotNull(output); - Assertions.assertTrue(output.contains("
")); - Assertions.assertFalse(output.contains("
")); + assertNotNull(output); + assertTrue(output.contains("
")); + assertFalse(output.contains("
")); } - + /** * In xhtml, it is valid to have an html empty tag with content. * * @throws IOException */ @Test - public void testEmptyTagNotRenderEndOnXml() throws IOException + void emptyTagNotRenderEndOnXml() throws Exception { _writer = new HtmlResponseWriterImpl(_stringWriter, "application/xml", "UTF-8", false); @@ -421,18 +421,18 @@ public void testEmptyTagNotRenderEndOnXml() throws IOException // the following should render
hello
String output = _stringWriter.toString(); - Assertions.assertNotNull(output); - Assertions.assertTrue(output.contains("
")); - Assertions.assertTrue(output.contains("
")); + assertNotNull(output); + assertTrue(output.contains("
")); + assertTrue(output.contains("
")); } - + /** * In html, it is not valid to have an empty tag with content * * @throws IOException */ @Test - public void testEmptyTagNotRenderEndUppercase() throws IOException + void emptyTagNotRenderEndUppercase() throws Exception { _writer.startDocument(); _writer.startElement("body", null); @@ -444,18 +444,18 @@ public void testEmptyTagNotRenderEndUppercase() throws IOException // the following should render
hello String output = _stringWriter.toString(); - Assertions.assertNotNull(output); - Assertions.assertTrue(output.contains("
")); - Assertions.assertFalse(output.contains("
")); + assertNotNull(output); + assertTrue(output.contains("
")); + assertFalse(output.contains("
")); } - + /** * In xhtml, it is valid to have an html empty tag with content. * * @throws IOException */ @Test - public void testEmptyTagNotRenderEndOnXhtmlUppercase() throws IOException + void emptyTagNotRenderEndOnXhtmlUppercase() throws Exception { _writer = new HtmlResponseWriterImpl(_stringWriter, "application/xml", "UTF-8", false); @@ -469,8 +469,8 @@ public void testEmptyTagNotRenderEndOnXhtmlUppercase() throws IOException // the following should render
hello
String output = _stringWriter.toString(); - Assertions.assertNotNull(output); - Assertions.assertTrue(output.contains("
")); - Assertions.assertTrue(output.contains("
")); + assertNotNull(output); + assertTrue(output.contains("
")); + assertTrue(output.contains("
")); } } \ No newline at end of file diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlRolePassedThroughTestCase.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlRolePassedThroughTestCase.java index e1d53d7d74..7069914b2e 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlRolePassedThroughTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlRolePassedThroughTestCase.java @@ -18,18 +18,18 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import jakarta.el.ExpressionFactory; import jakarta.faces.component.UIViewRoot; -import org.junit.jupiter.api.Assertions; - import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; import org.junit.jupiter.api.Test; -public class HtmlRolePassedThroughTestCase extends AbstractFaceletTestCase +class HtmlRolePassedThroughTestCase extends AbstractFaceletTestCase { @Override @@ -45,7 +45,7 @@ protected ExpressionFactory createExpressionFactory() } @Test - public void testRole() throws Exception + void role() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "role.xhtml"); @@ -59,28 +59,28 @@ public void testRole() throws Exception //System.out.println("********************HTMLRolePassedThroughTest*****************"); //System.out.println(sw.toString()); //System.out.println("********************HTMLRolePassedThroughTest*****************"); - Assertions.assertTrue(sw.toString().contains("value=\"user name\" role=\"new presentation\"")); - Assertions.assertTrue(sw.toString().contains("id=\"helloForm:link\" role=\"new presentation\"")); - Assertions.assertTrue(sw.toString().contains("")); - Assertions.assertTrue(sw.toString().contains("value=\"one\" role=\"new presentation\"")); + assertTrue(sw.toString().contains("value=\"user name\" role=\"new presentation\"")); + assertTrue(sw.toString().contains("id=\"helloForm:link\" role=\"new presentation\"")); + assertTrue(sw.toString().contains("
")); + assertTrue(sw.toString().contains("value=\"one\" role=\"new presentation\"")); - Assertions.assertTrue(sw.toString().contains("id=\"helloForm:data\" role=\"new presentation\"")); - Assertions.assertTrue(sw.toString().contains("id=\"helloForm:graphic\" role=\"new presentation\"")); - Assertions.assertTrue(sw.toString().contains("type=\"file\" role=\"new presentation\"")); - Assertions.assertTrue(sw.toString().contains("name=\"helloForm:area\" role=\"new presentation\"")); + assertTrue(sw.toString().contains("id=\"helloForm:data\" role=\"new presentation\"")); + assertTrue(sw.toString().contains("id=\"helloForm:graphic\" role=\"new presentation\"")); + assertTrue(sw.toString().contains("type=\"file\" role=\"new presentation\"")); + assertTrue(sw.toString().contains("name=\"helloForm:area\" role=\"new presentation\"")); - Assertions.assertTrue(sw.toString().contains("id=\"helloForm:outputFormat\" role=\"new presentation\"")); - Assertions.assertTrue(sw.toString().contains("id=\"helloForm:outputLabel\" role=\"new presentation\"")); - Assertions.assertTrue(sw.toString().contains("name=\"helloForm:outputLink\" role=\"new presentation\"")); - Assertions.assertTrue(sw.toString().contains("id=\"helloForm:outputText\" role=\"new presentation\"")); + assertTrue(sw.toString().contains("id=\"helloForm:outputFormat\" role=\"new presentation\"")); + assertTrue(sw.toString().contains("id=\"helloForm:outputLabel\" role=\"new presentation\"")); + assertTrue(sw.toString().contains("name=\"helloForm:outputLink\" role=\"new presentation\"")); + assertTrue(sw.toString().contains("id=\"helloForm:outputText\" role=\"new presentation\"")); // Assertions.assertTrue(sw.toString().contains("(?s).*", output); + assertEquals("", output); } @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs(); HtmlCheckAttributesUtil.checkRenderedAttributes( inputText, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndName() + void clientBehaviorHolderRendersIdAndName() { inputText.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { inputText.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches(".+id=\".+\".+")); - Assertions.assertTrue(output.matches(".+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches(".+id=\".+\".+")); + assertTrue(output.matches(".+name=\".+\".+")); + }); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTableRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTableRendererTest.java index 13034f332c..1dd9f54e36 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTableRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTableRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.*; + import java.io.StringWriter; import java.util.ArrayList; import java.util.List; @@ -42,7 +44,7 @@ * @author Bruno Aranda (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlTableRendererTest extends AbstractFacesTestCase +class HtmlTableRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer ; private HtmlDataTable dataTable; @@ -83,57 +85,52 @@ public void tearDown() throws Exception } @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs(); HtmlCheckAttributesUtil.checkRenderedAttributes( dataTable, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testHtmlPropertyPassTruNotRendered() throws Exception + void htmlPropertyPassTruNotRendered() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateAttrsNotRenderedForReadOnlyButBehaviorEvents(); HtmlCheckAttributesUtil.checkRenderedAttributes( dataTable, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndName() + void clientBehaviorHolderRendersIdAndName() { dataTable.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { dataTable.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches("(?s).+id=\".+\".+")); - Assertions.assertTrue(output.matches("(?s).+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches("(?s).+id=\".+\".+")); + assertTrue(output.matches("(?s).+name=\".+\".+")); + }); } - + /** * Check table renderer behavior when DataModel returns -1 from getRowCount(). It should * render the same as if that value is provided. Note t:dataTable newspaper mode requires * row count to calculate newspaperRows and newspaperColumns. */ @Test - public void testNoRowCountRender() + void noRowCountRender() { List list = new ArrayList(); list.add(new Person("John" , "Smith")); @@ -162,42 +159,30 @@ public void testNoRowCountRender() dataTable.setValue(new UnknownRowCountDemoDataModel(list)); - String output1 = null; - try - { + String output1 = Assertions.assertDoesNotThrow(() -> { dataTable.encodeAll(facesContext); - output1 = ((StringWriter) writer.getWriter()).getBuffer().toString(); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + return ((StringWriter) writer.getWriter()).getBuffer().toString(); + }); dataTable.setValue(new ListDataModel(list)); ((StringWriter) writer.getWriter()).getBuffer().setLength(0); - String output2 = null; - try - { + String output2 = Assertions.assertDoesNotThrow(() -> { dataTable.encodeAll(facesContext); - output2 = ((StringWriter) writer.getWriter()).getBuffer().toString(); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + return ((StringWriter) writer.getWriter()).getBuffer().toString(); + }); - Assertions.assertTrue(output2.contains("John")); - Assertions.assertTrue(output2.contains("Smith")); - Assertions.assertTrue(output2.contains("class1")); - Assertions.assertTrue(output2.contains("class2")); + assertTrue(output2.contains("John")); + assertTrue(output2.contains("Smith")); + assertTrue(output2.contains("class1")); + assertTrue(output2.contains("class2")); - Assertions.assertTrue(output1.contains("John")); - Assertions.assertTrue(output1.contains("Smith")); - Assertions.assertTrue(output1.contains("class1")); - Assertions.assertTrue(output1.contains("class2")); + assertTrue(output1.contains("John")); + assertTrue(output1.contains("Smith")); + assertTrue(output1.contains("class1")); + assertTrue(output1.contains("class2")); - Assertions.assertEquals(output2, output1); + assertEquals(output2, output1); } public class Person diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java index 8a283c2e41..5e6523b863 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.*; + import java.io.IOException; import java.io.StringWriter; @@ -48,7 +50,7 @@ * @author Bruno Aranda (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlTextRendererTest extends AbstractFacesTestCase +class HtmlTextRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer ; @@ -93,7 +95,7 @@ public void tearDown() throws Exception } @Test - public void testStyleClassAttr() throws IOException + void styleClassAttr() throws Exception { outputText.setValue("Output"); outputText.setStyleClass("myStyleClass"); @@ -104,24 +106,24 @@ public void testStyleClassAttr() throws IOException String output = writer.getWriter().toString(); - Assertions.assertEquals("Output", output); - Assertions.assertNotSame("Output", output); + assertEquals("Output", output); + assertNotSame("Output", output); } @Test - public void testInputDefaultTypeAttr() throws IOException + void inputDefaultTypeAttr() throws Exception { inputText.encodeBegin(facesContext); inputText.encodeEnd(facesContext); facesContext.renderResponse(); String output = writer.getWriter().toString(); - Assertions.assertEquals("", output); - Assertions.assertNotSame("Output", output); + assertEquals("", output); + assertNotSame("Output", output); } @Test - public void testInputTypeAttr() throws IOException + void inputTypeAttr() throws Exception { inputText.setType("tel"); @@ -130,17 +132,17 @@ public void testInputTypeAttr() throws IOException facesContext.renderResponse(); String output = writer.getWriter().toString(); - Assertions.assertEquals("", output); - Assertions.assertNotSame("Output", output); + assertEquals("", output); + assertNotSame("Output", output); } - + /** * Don't add span over escape * @throws IOException */ @Test - public void testEscapeNoSpan() throws IOException + void escapeNoSpan() throws Exception { outputText.setValue("Output"); outputText.setEscape(true); @@ -151,11 +153,11 @@ public void testEscapeNoSpan() throws IOException String output = writer.getWriter().toString(); - Assertions.assertEquals("Output", output); + assertEquals("Output", output); } @Test - public void testHtmlPropertyPassThru() throws Exception + void htmlPropertyPassThru() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs(); @@ -163,12 +165,12 @@ public void testHtmlPropertyPassThru() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes( inputText, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + @Test - public void testWhenSubmittedValueIsNullDefaultShouldDisappearFromRendering() { + void whenSubmittedValueIsNullDefaultShouldDisappearFromRendering() { //See MYFACES-2161 and MYFACES-1549 for details UIViewRoot root = new UIViewRoot(); UIForm form = new UIForm(); @@ -232,75 +234,60 @@ public String getAsString(FacesContext context, // 4) renderer calls getValue(); --> getValue() evaluates the // value-binding, as the local-value is 'null', and I get the // default-value of the bean shown again - Assertions.assertNotSame(expression.getValue(facesContext.getELContext()), inputText.getValue()); - Assertions.assertNull(inputText.getValue()); + assertNotSame(expression.getValue(facesContext.getELContext()), inputText.getValue()); + assertNull(inputText.getValue()); } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndName() + void clientBehaviorHolderRendersIdAndName() { inputText.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { inputText.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches("(?s).+id=\".+\".+")); - Assertions.assertTrue(output.matches("(?s).+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches("(?s).+id=\".+\".+")); + assertTrue(output.matches("(?s).+name=\".+\".+")); + }); } - + /** * Tests if a JavaScript user code is correctly escaped. * e.g. alert('test') has to become alert(\'test\') */ @Test - public void testClientBehaviorUserCodeJavaScriptEscaping() + void clientBehaviorUserCodeJavaScriptEscaping() { inputText.getAttributes().put("onchange", "alert('test')"); inputText.addClientBehavior("change", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { inputText.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); // onchange="faces.util.chain(document.getElementById('j_id0'), event, // 'alert(\'test\')');" - Assertions.assertTrue(output.contains("'alert(\\'test\\')'")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.contains("'alert(\\'test\\')'")); + }); } - + /** * Tests if a JavaScript user code that already contains ' is correctly escaped. * e.g. test = 'a\'b'; has to become test = \'a\\\'b\'; */ @Test - public void testClientBehaviorUserCodeJavaScriptDoubleEscaping() + void clientBehaviorUserCodeJavaScriptDoubleEscaping() { inputText.getAttributes().put("onchange", "var test = 'a\\'b'; alert(test);"); inputText.addClientBehavior("change", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { inputText.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); // onchange="faces.util.chain(document.getElementById('j_id0'), event, // 'var test = \'a\\\'b\'; alert(test);');" - Assertions.assertTrue(output.contains("'var test = \\'a\\\\\\'b\\'; alert(test);'")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.contains("'var test = \\'a\\\\\\'b\\'; alert(test);'")); + }); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextareaRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextareaRendererTest.java index 82a99428d2..319772f83f 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextareaRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextareaRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html; +import static org.junit.jupiter.api.Assertions.*; + import java.io.StringWriter; import jakarta.faces.component.behavior.AjaxBehavior; @@ -37,7 +39,7 @@ * @author Bruno Aranda (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlTextareaRendererTest extends AbstractFacesTestCase +class HtmlTextareaRendererTest extends AbstractFacesTestCase { private MockResponseWriter writer ; private HtmlInputTextarea inputTextarea; @@ -71,18 +73,18 @@ public void tearDown() throws Exception } @Test - public void testRenderDefault() throws Exception + void renderDefault() throws Exception { inputTextarea.encodeBegin(facesContext); inputTextarea.encodeEnd(facesContext); facesContext.renderResponse(); String output = writer.getWriter().toString(); - Assertions.assertEquals("", output); + assertEquals("", output); } @Test - public void testRenderColsRows() throws Exception + void renderColsRows() throws Exception { inputTextarea.setCols(5); inputTextarea.setRows(10); @@ -91,39 +93,34 @@ public void testRenderColsRows() throws Exception facesContext.renderResponse(); String output = writer.getWriter().toString(); - Assertions.assertEquals("", output); + assertEquals("", output); } - + @Test - public void testHtmlPropertyPassTru() throws Exception + void htmlPropertyPassTru() throws Exception { HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs(); HtmlCheckAttributesUtil.checkRenderedAttributes( inputTextarea, facesContext, writer, attrs); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString())); } } - + /** * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndName() + void clientBehaviorHolderRendersIdAndName() { inputTextarea.addClientBehavior("keypress", new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { inputTextarea.encodeAll(facesContext); String output = ((StringWriter) writer.getWriter()).getBuffer().toString(); - Assertions.assertTrue(output.matches("(?s).+id=\".+\".+")); - Assertions.assertTrue(output.matches("(?s).+name=\".+\".+")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(output.matches("(?s).+id=\".+\".+")); + assertTrue(output.matches("(?s).+name=\".+\".+")); + }); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/AbstractClientBehaviorTestCase.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/AbstractClientBehaviorTestCase.java index a7d4e864e1..05e7faba26 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/AbstractClientBehaviorTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/AbstractClientBehaviorTestCase.java @@ -18,17 +18,20 @@ */ package org.apache.myfaces.renderkit.html.behavior; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import jakarta.faces.FactoryFinder; import jakarta.faces.component.UIComponent; import jakarta.faces.component.UIViewRoot; import jakarta.faces.component.behavior.AjaxBehavior; import jakarta.faces.component.behavior.ClientBehaviorHolder; import jakarta.faces.context.ResponseWriter; +import org.junit.jupiter.api.Assertions; import org.apache.myfaces.renderkit.html.HtmlResponseWriterImpl; import org.apache.myfaces.util.lang.FastWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -88,7 +91,7 @@ protected void setUpRenderKit() throws Exception * Components that render client behaviors should always render "id" and "name" attribute */ @Test - public void testClientBehaviorHolderRendersIdAndName() + public void clientBehaviorHolderRendersIdAndName() { HtmlRenderedClientEventAttr[] attrs = getClientBehaviorHtmlRenderedAttributes(); @@ -97,23 +100,18 @@ public void testClientBehaviorHolderRendersIdAndName() UIComponent component = createComponentToTest(); ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component; clientBehaviorHolder.addClientBehavior(attrs[i].getClientEvent(), new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { component.encodeAll(facesContext); String output = outputWriter.toString(); - Assertions.assertTrue(output.indexOf(" id=\""+component.getClientId(facesContext)+"\"") > -1); - Assertions.assertTrue(output.indexOf(" name=\""+component.getClientId(facesContext)+"\"") > -1); + assertTrue(output.indexOf(" id=\"" + component.getClientId(facesContext) + "\"") > -1); + assertTrue(output.indexOf(" name=\"" + component.getClientId(facesContext) + "\"") > -1); outputWriter.reset(); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + }); } } @Test - public void testClientBehaviorRendered() + public void clientBehaviorRendered() { HtmlRenderedClientEventAttr[] attrs = getClientBehaviorHtmlRenderedAttributes(); @@ -131,21 +129,17 @@ public void testClientBehaviorRendered() ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component; clientBehaviorHolder.addClientBehavior(attrs[i].getClientEvent(), new AjaxBehavior()); - try - { + HtmlRenderedClientEventAttr attr = attrs[i]; + Assertions.assertDoesNotThrow(() -> { component.encodeAll(facesContext); String output = outputWriter.toString(); //faces.ajax.request('j_id0',event,{'jakarta.faces.behavior.event':'click'}) //Only check if the property starts with faces.ajax.request( is enough //Assertions.assertTrue("output does not match expected output faces.ajax.request(.... for property "+attrs[i].getName(), // output.matches(".+ "+attrs[i].getName()+"=\"faces\\.ajax\\.request\\(.+")); - int index = checkClientBehaviorRenderedOnClientEventProperty(output, 0, attrs[i]); + int index = checkClientBehaviorRenderedOnClientEventProperty(output, 0, attr); outputWriter.reset(); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + }); } } @@ -159,19 +153,19 @@ public int checkClientBehaviorRenderedOnClientEventProperty(String output, int s int startPropIndex = propIndex + propStart.length(); int endPropIndex = output.indexOf('"' , startPropIndex ); String propertyValue = output.substring(startPropIndex, endPropIndex); - Assertions.assertTrue(propertyValue.contains("myfaces.ab(")); - Assertions.assertTrue(propertyValue.contains(attr.getClientEvent())); + assertTrue(propertyValue.contains("myfaces.ab(")); + assertTrue(propertyValue.contains(attr.getClientEvent())); return endPropIndex + 1; } else { - Assertions.fail("Property " + attr.getName() + " not found"); + fail("Property " + attr.getName() + " not found"); return -1; } } @Test - public void testClientBehaviorRenderedWithHtmlAttribute() + public void clientBehaviorRenderedWithHtmlAttribute() { HtmlRenderedClientEventAttr[] attrs = getClientBehaviorHtmlRenderedAttributes(); @@ -181,21 +175,17 @@ public void testClientBehaviorRenderedWithHtmlAttribute() ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component; clientBehaviorHolder.addClientBehavior(attrs[i].getClientEvent(), new AjaxBehavior()); component.getAttributes().put(attrs[i].getName(), "htmlValue"); - try - { + HtmlRenderedClientEventAttr attr = attrs[i]; + Assertions.assertDoesNotThrow(() -> { component.encodeAll(facesContext); String output = outputWriter.toString(); //faces.ajax.request('j_id0',event,{'jakarta.faces.behavior.event':'click'}) //Only check if the property starts with faces.ajax.request( is enough //Assertions.assertTrue("output does not match expected output faces.ajax.request(.... for property "+attrs[i].getName(), // output.matches(".+ "+attrs[i].getName()+"=\"faces\\.ajax\\.request\\(.+")); - int index = checkClientBehaviorRenderedOnClientEventPropertyAndHtmlValue(output, 0, attrs[i], "htmlValue"); + int index = checkClientBehaviorRenderedOnClientEventPropertyAndHtmlValue(output, 0, attr, "htmlValue"); outputWriter.reset(); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + }); } } @@ -209,15 +199,15 @@ public int checkClientBehaviorRenderedOnClientEventPropertyAndHtmlValue(String o int startPropIndex = propIndex + propStart.length(); int endPropIndex = output.indexOf('"' , startPropIndex ); String propertyValue = output.substring(startPropIndex, endPropIndex); - Assertions.assertTrue(propertyValue.startsWith("faces.util.chain(")); - Assertions.assertTrue(propertyValue.contains("myfaces.ab(")); - Assertions.assertTrue(propertyValue.contains(attr.getClientEvent())); - Assertions.assertTrue(propertyValue.contains(value)); + assertTrue(propertyValue.startsWith("faces.util.chain(")); + assertTrue(propertyValue.contains("myfaces.ab(")); + assertTrue(propertyValue.contains(attr.getClientEvent())); + assertTrue(propertyValue.contains(value)); return endPropIndex + 1; } else { - Assertions.fail("Property " + attr.getName() + " not found Output: "+output); + fail("Property " + attr.getName() + " not found Output: "+output); return -1; } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/AdditionalHtmlEventsClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/AdditionalHtmlEventsClientBehaviorRendererTest.java index 26dbc94ff1..330df6339c 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/AdditionalHtmlEventsClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/AdditionalHtmlEventsClientBehaviorRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html.behavior; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.el.ValueExpression; import jakarta.faces.component.UIComponent; import jakarta.faces.component.behavior.AjaxBehavior; @@ -33,7 +35,6 @@ import org.apache.myfaces.test.el.MockValueExpression; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -45,7 +46,7 @@ * The inherited test cases cover exactly that for a set of events which have no property on any standard component, * this class adds the cases which are specific to this feature. */ -public class AdditionalHtmlEventsClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class AdditionalHtmlEventsClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; @@ -92,14 +93,14 @@ protected HtmlRenderedClientEventAttr[] getClientBehaviorHtmlRenderedAttributes( * A plain on* attribute without a matching property must be rendered as a pass through attribute. */ @Test - public void testPlainAttributeWithoutBehaviorIsRendered() throws Exception + void plainAttributeWithoutBehaviorIsRendered() throws Exception { HtmlInputText input = new HtmlInputText(); input.getAttributes().put("oninput", "alert('input')"); input.encodeAll(facesContext); - Assertions.assertTrue(outputWriter.toString().contains(" oninput=\"alert('input')\""), + assertTrue(outputWriter.toString().contains(" oninput=\"alert('input')\""), outputWriter.toString()); } @@ -108,7 +109,7 @@ public void testPlainAttributeWithoutBehaviorIsRendered() throws Exception * set, so it needs the {@code EVENT_ATTRIBUTES_MARKED} marker to be found at render time. */ @Test - public void testValueExpressionAttributeWithoutBehaviorIsRendered() throws Exception + void valueExpressionAttributeWithoutBehaviorIsRendered() throws Exception { ValueExpression expression = new MockValueExpression("#{requestScope.oninputScript}", String.class); expression.setValue(facesContext.getELContext(), "alert(1)"); @@ -118,7 +119,7 @@ public void testValueExpressionAttributeWithoutBehaviorIsRendered() throws Excep input.encodeAll(facesContext); - Assertions.assertTrue(outputWriter.toString().contains(" oninput=\"alert(1)\""), outputWriter.toString()); + assertTrue(outputWriter.toString().contains(" oninput=\"alert(1)\""), outputWriter.toString()); } /** @@ -126,21 +127,21 @@ public void testValueExpressionAttributeWithoutBehaviorIsRendered() throws Excep * standard HTML RenderKit: the substring after "on" has to be contained in getEventNames(). */ @Test - public void testUnknownEventAttributeIsNotRendered() throws Exception + void unknownEventAttributeIsNotRendered() throws Exception { HtmlInputText input = new HtmlInputText(); input.getAttributes().put("onsomethingweird", "alert('nope')"); input.encodeAll(facesContext); - Assertions.assertFalse(outputWriter.toString().contains("onsomethingweird"), outputWriter.toString()); + assertFalse(outputWriter.toString().contains("onsomethingweird"), outputWriter.toString()); } /** * The very use case of the spec issue: an f:ajax on an event which no component declares as a property. */ @Test - public void testAjaxBehaviorOnAdditionalEventIsRendered() throws Exception + void ajaxBehaviorOnAdditionalEventIsRendered() throws Exception { HtmlInputText input = new HtmlInputText(); input.addClientBehavior("input", new AjaxBehavior()); @@ -148,15 +149,15 @@ public void testAjaxBehaviorOnAdditionalEventIsRendered() throws Exception input.encodeAll(facesContext); String output = outputWriter.toString(); - Assertions.assertTrue(output.contains(" oninput=\""), output); - Assertions.assertTrue(output.contains("myfaces.ab("), output); + assertTrue(output.contains(" oninput=\""), output); + assertTrue(output.contains("myfaces.ab("), output); } /** * The renderer specific attributes must keep working exactly as before, next to the additional ones. */ @Test - public void testRendererSpecificAndAdditionalEventsAreCombined() throws Exception + void rendererSpecificAndAdditionalEventsAreCombined() throws Exception { HtmlInputText input = new HtmlInputText(); input.setOnclick("alert('click')"); @@ -165,8 +166,8 @@ public void testRendererSpecificAndAdditionalEventsAreCombined() throws Exceptio input.encodeAll(facesContext); String output = outputWriter.toString(); - Assertions.assertTrue(output.contains(" onclick=\"alert('click')\""), output); - Assertions.assertTrue(output.contains(" oninput=\"alert('input')\""), output); + assertTrue(output.contains(" onclick=\"alert('click')\""), output); + assertTrue(output.contains(" oninput=\"alert('input')\""), output); } /** @@ -174,7 +175,7 @@ public void testRendererSpecificAndAdditionalEventsAreCombined() throws Exceptio * different renderers and rendering paths. */ @Test - public void testAdditionalEventsOnOtherComponents() throws Exception + void additionalEventsOnOtherComponents() throws Exception { assertAdditionalEventRendered(new HtmlCommandButton()); assertAdditionalEventRendered(new HtmlOutputLink()); @@ -189,7 +190,7 @@ public void testAdditionalEventsOnOtherComponents() throws Exception * hand (h:panelGroup only renders the mouse/key/click events itself) must be rendered generically as well. */ @Test - public void testFieldEventOnNonFieldComponent() throws Exception + void fieldEventOnNonFieldComponent() throws Exception { HtmlPanelGroup group = new HtmlPanelGroup(); group.setLayout("block"); @@ -199,8 +200,8 @@ public void testFieldEventOnNonFieldComponent() throws Exception group.encodeAll(facesContext); String output = outputWriter.toString(); - Assertions.assertTrue(output.contains(" onfocus=\"doFocus()\""), output); - Assertions.assertTrue(output.contains(" onblur=\""), output); + assertTrue(output.contains(" onfocus=\"doFocus()\""), output); + assertTrue(output.contains(" onblur=\""), output); } /** @@ -208,7 +209,7 @@ public void testFieldEventOnNonFieldComponent() throws Exception * the generic pass. */ @Test - public void testRendererHandledEventIsNotRenderedTwice() throws Exception + void rendererHandledEventIsNotRenderedTwice() throws Exception { HtmlInputText input = new HtmlInputText(); input.setOnclick("doClick()"); @@ -217,8 +218,8 @@ public void testRendererHandledEventIsNotRenderedTwice() throws Exception input.encodeAll(facesContext); String output = outputWriter.toString(); - Assertions.assertEquals(output.indexOf(" onclick=\""), output.lastIndexOf(" onclick=\""), output); - Assertions.assertEquals(output.indexOf(" onfocus=\""), output.lastIndexOf(" onfocus=\""), output); + assertEquals(output.indexOf(" onclick=\""), output.lastIndexOf(" onclick=\""), output); + assertEquals(output.indexOf(" onfocus=\""), output.lastIndexOf(" onfocus=\""), output); } private void assertAdditionalEventRendered(UIComponent component) throws Exception @@ -230,9 +231,9 @@ private void assertAdditionalEventRendered(UIComponent component) throws Excepti component.encodeAll(facesContext); String output = outputWriter.toString(); - Assertions.assertTrue(output.contains(" oninput=\"alert('input')\""), + assertTrue(output.contains(" oninput=\"alert('input')\""), component.getClass().getSimpleName() + ": " + output); - Assertions.assertTrue(output.contains(" onwheel=\""), + assertTrue(output.contains(" onwheel=\""), component.getClass().getSimpleName() + ": " + output); } @@ -240,49 +241,49 @@ private void assertAdditionalEventRendered(UIComponent component) throws Excepti * jsf:element mirrors the standard HTML components and must expose and render every HTML event as well. */ @Test - public void testAdditionalEventsOnJsfElement() throws Exception + void additionalEventsOnJsfElement() throws Exception { JsfElement element = new JsfElement(); element.getPassThroughAttributes().put(Renderer.PASSTHROUGH_RENDERER_LOCALNAME_KEY, "div"); element.getAttributes().put("oninput", "doInput()"); element.addClientBehavior("wheel", new AjaxBehavior()); - Assertions.assertTrue(element.getEventNames().contains("input")); - Assertions.assertTrue(element.getEventNames().contains("scrollend")); + assertTrue(element.getEventNames().contains("input")); + assertTrue(element.getEventNames().contains("scrollend")); element.encodeAll(facesContext); String output = outputWriter.toString(); - Assertions.assertTrue(output.contains(" oninput=\"doInput()\""), output); - Assertions.assertTrue(output.contains(" onwheel=\""), output); + assertTrue(output.contains(" oninput=\"doInput()\""), output); + assertTrue(output.contains(" onwheel=\""), output); } /** * The event names must reflect the component type, as the spec assigns a different set per component category. */ @Test - public void testEventNamesPerComponentCategory() + void eventNamesPerComponentCategory() { // EditableValueHolder - Assertions.assertTrue(new HtmlInputText().getEventNames().contains("valueChange")); - Assertions.assertFalse(new HtmlInputText().getEventNames().contains("action")); + assertTrue(new HtmlInputText().getEventNames().contains("valueChange")); + assertFalse(new HtmlInputText().getEventNames().contains("action")); // ActionSource - Assertions.assertTrue(new HtmlCommandButton().getEventNames().contains("action")); - Assertions.assertFalse(new HtmlCommandButton().getEventNames().contains("valueChange")); + assertTrue(new HtmlCommandButton().getEventNames().contains("action")); + assertFalse(new HtmlCommandButton().getEventNames().contains("valueChange")); // neither of both - Assertions.assertFalse(new HtmlPanelGroup().getEventNames().contains("action")); - Assertions.assertFalse(new HtmlPanelGroup().getEventNames().contains("valueChange")); + assertFalse(new HtmlPanelGroup().getEventNames().contains("action")); + assertFalse(new HtmlPanelGroup().getEventNames().contains("valueChange")); // all of them expose the plain HTML events, including the window level ones for (UIComponent component : new UIComponent[] { new HtmlInputText(), new HtmlCommandButton(), new HtmlPanelGroup() }) { ClientBehaviorHolder holder = (ClientBehaviorHolder) component; - Assertions.assertTrue(holder.getEventNames().contains("input")); - Assertions.assertTrue(holder.getEventNames().contains("click")); - Assertions.assertTrue(holder.getEventNames().contains("scrollend")); + assertTrue(holder.getEventNames().contains("input")); + assertTrue(holder.getEventNames().contains("click")); + assertTrue(holder.getEventNames().contains("scrollend")); } } @@ -290,35 +291,35 @@ public void testEventNamesPerComponentCategory() * The default event names as mandated by the spec. */ @Test - public void testDefaultEventNames() + void defaultEventNames() { - Assertions.assertEquals("valueChange", new HtmlInputText().getDefaultEventName()); - Assertions.assertEquals("action", new HtmlCommandButton().getDefaultEventName()); - Assertions.assertEquals("click", new HtmlOutputLink().getDefaultEventName()); - Assertions.assertNull(new HtmlPanelGroup().getDefaultEventName()); + assertEquals("valueChange", new HtmlInputText().getDefaultEventName()); + assertEquals("action", new HtmlCommandButton().getDefaultEventName()); + assertEquals("click", new HtmlOutputLink().getDefaultEventName()); + assertNull(new HtmlPanelGroup().getDefaultEventName()); } /** * Unknown event names can be added via context-param, and are then usable like any built in one. */ @Test - public void testAdditionalEventNamesContextParam() throws Exception + void additionalEventNamesContextParam() throws Exception { servletContext.addInitParameter(HtmlEvents.ADDITIONAL_HTML_EVENT_NAMES_PARAM_NAME, " foo\t bar\nfoo "); - Assertions.assertTrue(HtmlEvents.getAdditionalHtmlEventNames(facesContext).contains("foo")); - Assertions.assertTrue(HtmlEvents.getAdditionalHtmlEventNames(facesContext).contains("bar")); + assertTrue(HtmlEvents.getAdditionalHtmlEventNames(facesContext).contains("foo")); + assertTrue(HtmlEvents.getAdditionalHtmlEventNames(facesContext).contains("bar")); HtmlInputText input = new HtmlInputText(); - Assertions.assertTrue(input.getEventNames().contains("foo")); + assertTrue(input.getEventNames().contains("foo")); input.getAttributes().put("onfoo", "alert('foo')"); input.addClientBehavior("bar", new AjaxBehavior()); input.encodeAll(facesContext); String output = outputWriter.toString(); - Assertions.assertTrue(output.contains(" onfoo=\"alert('foo')\""), output); - Assertions.assertTrue(output.contains(" onbar=\""), output); + assertTrue(output.contains(" onfoo=\"alert('foo')\""), output); + assertTrue(output.contains(" onbar=\""), output); } /** @@ -326,32 +327,32 @@ public void testAdditionalEventNamesContextParam() throws Exception * distinct and layered as documented. */ @Test - public void testEventNameCollections() + void eventNameCollections() { - Assertions.assertTrue(HtmlEvents.getAdditionalHtmlEventNames(facesContext).isEmpty()); + assertTrue(HtmlEvents.getAdditionalHtmlEventNames(facesContext).isEmpty()); - Assertions.assertTrue(HtmlEvents.getHtmlBodyEventNames(facesContext) + assertTrue(HtmlEvents.getHtmlBodyEventNames(facesContext) .containsAll(HtmlEvents.getHtmlElementEventNames(facesContext))); - Assertions.assertTrue(HtmlEvents.getHtmlBodyEventNames(facesContext) + assertTrue(HtmlEvents.getHtmlBodyEventNames(facesContext) .containsAll(HtmlEvents.getHtmlWindowEventNames(facesContext))); - Assertions.assertTrue(HtmlEvents.getFacesActionSourceEventNames(facesContext) + assertTrue(HtmlEvents.getFacesActionSourceEventNames(facesContext) .containsAll(HtmlEvents.getHtmlElementEventNames(facesContext))); - Assertions.assertTrue(HtmlEvents.getFacesEditableValueHolderEventNames(facesContext) + assertTrue(HtmlEvents.getFacesEditableValueHolderEventNames(facesContext) .containsAll(HtmlEvents.getHtmlElementEventNames(facesContext))); // the events which are forwarded to the Window object on the body element are still element level events - Assertions.assertTrue(HtmlEvents.getHtmlElementEventNames(facesContext).contains("load")); - Assertions.assertFalse(HtmlEvents.getHtmlWindowEventNames(facesContext).contains("load")); + assertTrue(HtmlEvents.getHtmlElementEventNames(facesContext).contains("load")); + assertFalse(HtmlEvents.getHtmlWindowEventNames(facesContext).contains("load")); // the window level events are exclusive to the body element event names - Assertions.assertFalse(HtmlEvents.getHtmlElementEventNames(facesContext).contains("unload")); - Assertions.assertTrue(HtmlEvents.getHtmlWindowEventNames(facesContext).contains("unload")); - Assertions.assertTrue(HtmlEvents.getHtmlBodyEventNames(facesContext).contains("unload")); + assertFalse(HtmlEvents.getHtmlElementEventNames(facesContext).contains("unload")); + assertTrue(HtmlEvents.getHtmlWindowEventNames(facesContext).contains("unload")); + assertTrue(HtmlEvents.getHtmlBodyEventNames(facesContext).contains("unload")); String previous = null; for (String eventName : HtmlEvents.getFacesEditableValueHolderEventNames(facesContext)) { - Assertions.assertTrue(previous == null || previous.compareTo(eventName) < 0, + assertTrue(previous == null || previous.compareTo(eventName) < 0, "not sorted and distinct at " + eventName); previous = eventName; } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/AjaxBehaviorRenderTestCase.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/AjaxBehaviorRenderTestCase.java index 33aa87bf07..f217b2412c 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/AjaxBehaviorRenderTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/AjaxBehaviorRenderTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html.behavior; +import static org.junit.jupiter.api.Assertions.*; + import java.io.StringWriter; import jakarta.faces.application.ViewHandler; @@ -25,7 +27,6 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class AjaxBehaviorRenderTestCase extends AbstractFaceletTestCase { @@ -38,7 +39,7 @@ protected void setUpServletObjects() throws Exception } @Test - public void testAjax1() throws Exception { + void ajax1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "ajax_1.xhtml"); @@ -49,12 +50,12 @@ public void testAjax1() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertFalse(response.contains("faces.util.chain")); - Assertions.assertFalse(response.contains("myfaces.ab")); + assertFalse(response.contains("faces.util.chain")); + assertFalse(response.contains("myfaces.ab")); } - + @Test - public void testAjax2() throws Exception { + void ajax2() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "ajax_2.xhtml"); @@ -65,12 +66,12 @@ public void testAjax2() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertTrue(response.contains("myfaces.ab")); - Assertions.assertEquals(countMatches(response, "myfaces.ab"), 1); + assertTrue(response.contains("myfaces.ab")); + assertEquals(1, countMatches(response, "myfaces.ab")); } - + @Test - public void testAjax3() throws Exception { + void ajax3() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "ajax_3.xhtml"); @@ -81,12 +82,12 @@ public void testAjax3() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertTrue(response.contains("myfaces.ab")); - Assertions.assertEquals(countMatches(response, "myfaces.ab"), 1); + assertTrue(response.contains("myfaces.ab")); + assertEquals(1, countMatches(response, "myfaces.ab")); } - + @Test - public void testAjax4() throws Exception { + void ajax4() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "ajax_4.xhtml"); @@ -97,13 +98,13 @@ public void testAjax4() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertTrue(response.contains("myfaces.ab")); - Assertions.assertEquals(countMatches(response, "faces.util.chain"), 1); - Assertions.assertEquals(countMatches(response, "myfaces.ab"), 2); + assertTrue(response.contains("myfaces.ab")); + assertEquals(1, countMatches(response, "faces.util.chain")); + assertEquals(2, countMatches(response, "myfaces.ab")); } - + @Test - public void testAjax5() throws Exception { + void ajax5() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "ajax_5.xhtml"); @@ -114,12 +115,12 @@ public void testAjax5() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertFalse(response.contains("myfaces.ab")); - Assertions.assertFalse(response.contains("faces.util.chain")); + assertFalse(response.contains("myfaces.ab")); + assertFalse(response.contains("faces.util.chain")); } - + @Test - public void testAjax6() throws Exception { + void ajax6() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "ajax_6.xhtml"); @@ -130,11 +131,11 @@ public void testAjax6() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertTrue(response.contains("myfaces.ab")); + assertTrue(response.contains("myfaces.ab")); } - + @Test - public void testAjax7() throws Exception { + void ajax7() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "ajax_7.xhtml"); @@ -145,10 +146,10 @@ public void testAjax7() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertTrue(response.contains("myfaces.ab")); - Assertions.assertTrue(response.contains("faces.util.chain")); - Assertions.assertEquals(countMatches(response, "faces.util.chain"), 1); - Assertions.assertEquals(countMatches(response, "myfaces.ab"), 2); + assertTrue(response.contains("myfaces.ab")); + assertTrue(response.contains("faces.util.chain")); + assertEquals(1, countMatches(response, "faces.util.chain")); + assertEquals(2, countMatches(response, "myfaces.ab")); } public int countMatches(String all, String search) diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlBodyClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlBodyClientBehaviorRendererTest.java index 5848cf23bb..97a2e7c2ce 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlBodyClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlBodyClientBehaviorRendererTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkit.html.behavior; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.faces.component.UIComponent; import jakarta.faces.component.behavior.AjaxBehavior; import jakarta.faces.component.behavior.ClientBehaviorHolder; @@ -36,7 +38,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlBodyClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlBodyClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; @@ -82,7 +84,7 @@ protected HtmlRenderedClientEventAttr[] getClientBehaviorHtmlRenderedAttributes( * does not have "name", so we just need to check "id" */ @Test - public void testClientBehaviorHolderRendersIdAndName() + public void clientBehaviorHolderRendersIdAndName() { HtmlRenderedClientEventAttr[] attrs = getClientBehaviorHtmlRenderedAttributes(); @@ -91,17 +93,12 @@ public void testClientBehaviorHolderRendersIdAndName() UIComponent component = createComponentToTest(); ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component; clientBehaviorHolder.addClientBehavior(attrs[i].getClientEvent(), new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { component.encodeAll(facesContext); String output = outputWriter.toString(); - Assertions.assertTrue(output.contains("id=\"j_id__")); + assertTrue(output.contains("id=\"j_id__")); outputWriter.reset(); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + }); } } @@ -111,33 +108,28 @@ public void testClientBehaviorHolderRendersIdAndName() * <h:body> therefore keeps working, and so do e.g. "unload", "pagehide" and "popstate". */ @Test - public void testWindowEventsAreBehaviorEvents() + void windowEventsAreBehaviorEvents() { HtmlBody body = new HtmlBody(); - Assertions.assertTrue(body.getEventNames().contains(ClientBehaviorEvents.CLICK)); - Assertions.assertTrue(body.getEventNames().contains(ClientBehaviorEvents.LOAD)); - Assertions.assertTrue(body.getEventNames().contains(ClientBehaviorEvents.UNLOAD)); - Assertions.assertTrue(body.getEventNames().contains(HtmlEvents.HtmlWindowEvent.pagehide.name())); - Assertions.assertTrue(body.getEventNames().contains(HtmlEvents.HtmlWindowEvent.popstate.name())); + assertTrue(body.getEventNames().contains(ClientBehaviorEvents.CLICK)); + assertTrue(body.getEventNames().contains(ClientBehaviorEvents.LOAD)); + assertTrue(body.getEventNames().contains(ClientBehaviorEvents.UNLOAD)); + assertTrue(body.getEventNames().contains(HtmlEvents.HtmlWindowEvent.pagehide.name())); + assertTrue(body.getEventNames().contains(HtmlEvents.HtmlWindowEvent.popstate.name())); // but not on any other component HtmlPanelGroup group = new HtmlPanelGroup(); - Assertions.assertTrue(group.getEventNames().contains(ClientBehaviorEvents.LOAD)); - Assertions.assertFalse(group.getEventNames().contains(ClientBehaviorEvents.UNLOAD)); - Assertions.assertFalse(group.getEventNames().contains(HtmlEvents.HtmlWindowEvent.pagehide.name())); + assertTrue(group.getEventNames().contains(ClientBehaviorEvents.LOAD)); + assertFalse(group.getEventNames().contains(ClientBehaviorEvents.UNLOAD)); + assertFalse(group.getEventNames().contains(HtmlEvents.HtmlWindowEvent.pagehide.name())); // still supported as a plain attribute body.setOnload("alert('load')"); - try - { + Assertions.assertDoesNotThrow(() -> { body.encodeAll(facesContext); - Assertions.assertTrue(outputWriter.toString().contains(HTML.ONLOAD_ATTR + "=\"alert('load')\"")); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(outputWriter.toString().contains(HTML.ONLOAD_ATTR + "=\"alert('load')\"")); + }); } /** @@ -145,43 +137,33 @@ public void testWindowEventsAreBehaviorEvents() * second time. */ @Test - public void testRendererHandledWindowEventIsRenderedOnce() + void rendererHandledWindowEventIsRenderedOnce() { HtmlBody body = new HtmlBody(); body.addClientBehavior(ClientBehaviorEvents.LOAD, new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { body.encodeAll(facesContext); String output = outputWriter.toString(); - Assertions.assertTrue(output.contains(HTML.ONLOAD_ATTR + "=\""), output); - Assertions.assertEquals(output.indexOf(HTML.ONLOAD_ATTR + "=\""), + assertTrue(output.contains(HTML.ONLOAD_ATTR + "=\""), output); + assertEquals(output.indexOf(HTML.ONLOAD_ATTR + "=\""), output.lastIndexOf(HTML.ONLOAD_ATTR + "=\""), output); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + }); } /** * The window level events which the renderer does not handle itself are rendered generically. */ @Test - public void testGenericWindowEventIsRendered() + void genericWindowEventIsRendered() { HtmlBody body = new HtmlBody(); body.addClientBehavior(HtmlEvents.HtmlWindowEvent.pagehide.name(), new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { body.encodeAll(facesContext); - Assertions.assertTrue(outputWriter.toString().contains(" onpagehide=\""), outputWriter.toString()); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + assertTrue(outputWriter.toString().contains(" onpagehide=\""), outputWriter.toString()); + }); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlCommandButtonClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlCommandButtonClientBehaviorRendererTest.java index 27d23c727d..aaf967ecbc 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlCommandButtonClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlCommandButtonClientBehaviorRendererTest.java @@ -32,7 +32,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlCommandButtonClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlCommandButtonClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlCommandLinkClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlCommandLinkClientBehaviorRendererTest.java index 11ffb6f93b..df2fcf1ba9 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlCommandLinkClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlCommandLinkClientBehaviorRendererTest.java @@ -33,7 +33,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlCommandLinkClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlCommandLinkClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlDataTableClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlDataTableClientBehaviorRendererTest.java index 2693cb71cb..78567980cd 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlDataTableClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlDataTableClientBehaviorRendererTest.java @@ -27,7 +27,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlDataTableClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlDataTableClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlFormClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlFormClientBehaviorRendererTest.java index e1d7b342c1..27c72c894a 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlFormClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlFormClientBehaviorRendererTest.java @@ -27,7 +27,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlFormClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlFormClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlGraphicImageClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlGraphicImageClientBehaviorRendererTest.java index 29f1a988f3..e96604551b 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlGraphicImageClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlGraphicImageClientBehaviorRendererTest.java @@ -27,7 +27,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlGraphicImageClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlGraphicImageClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutcomeTargetButtonClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutcomeTargetButtonClientBehaviorRendererTest.java index b175d47c78..0b70ecb197 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutcomeTargetButtonClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutcomeTargetButtonClientBehaviorRendererTest.java @@ -32,7 +32,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlOutcomeTargetButtonClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlOutcomeTargetButtonClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutcomeTargetLinkClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutcomeTargetLinkClientBehaviorRendererTest.java index 5527502f47..6704a4a596 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutcomeTargetLinkClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutcomeTargetLinkClientBehaviorRendererTest.java @@ -32,7 +32,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlOutcomeTargetLinkClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlOutcomeTargetLinkClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutputLabelClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutputLabelClientBehaviorRendererTest.java index d2e0c13b2a..eabb75f5b7 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutputLabelClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutputLabelClientBehaviorRendererTest.java @@ -31,7 +31,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlOutputLabelClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlOutputLabelClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutputLinkClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutputLinkClientBehaviorRendererTest.java index 8021a96ea9..c10539724b 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutputLinkClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlOutputLinkClientBehaviorRendererTest.java @@ -31,7 +31,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlOutputLinkClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlOutputLinkClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlPanelGridClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlPanelGridClientBehaviorRendererTest.java index 17f704f096..439e026cb5 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlPanelGridClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlPanelGridClientBehaviorRendererTest.java @@ -27,7 +27,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlPanelGridClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlPanelGridClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSecretClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSecretClientBehaviorRendererTest.java index 0bdf28182b..43b702aee7 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSecretClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSecretClientBehaviorRendererTest.java @@ -27,7 +27,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlSecretClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlSecretClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectBooleanCheckboxClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectBooleanCheckboxClientBehaviorRendererTest.java index 8ad1b78431..4707752700 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectBooleanCheckboxClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectBooleanCheckboxClientBehaviorRendererTest.java @@ -27,7 +27,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlSelectBooleanCheckboxClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlSelectBooleanCheckboxClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectManyCheckboxClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectManyCheckboxClientBehaviorRendererTest.java index 0853bad14a..3b9dbc71ee 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectManyCheckboxClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectManyCheckboxClientBehaviorRendererTest.java @@ -18,13 +18,14 @@ */ package org.apache.myfaces.renderkit.html.behavior; +import static org.junit.jupiter.api.Assertions.assertTrue; + import jakarta.faces.component.UIComponent; import jakarta.faces.component.UISelectItem; import jakarta.faces.component.behavior.AjaxBehavior; import jakarta.faces.component.behavior.ClientBehaviorHolder; import jakarta.faces.component.html.HtmlSelectManyCheckbox; import org.junit.jupiter.api.AfterEach; - import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -33,7 +34,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlSelectManyCheckboxClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlSelectManyCheckboxClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; @@ -71,7 +72,7 @@ protected HtmlRenderedClientEventAttr[] getClientBehaviorHtmlRenderedAttributes( } @Test - public void testClientBehaviorHolderRendersIdAndName() + public void clientBehaviorHolderRendersIdAndName() { HtmlRenderedClientEventAttr[] attrs = getClientBehaviorHtmlRenderedAttributes(); @@ -80,18 +81,13 @@ public void testClientBehaviorHolderRendersIdAndName() UIComponent component = createComponentToTest(); ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component; clientBehaviorHolder.addClientBehavior(attrs[i].getClientEvent(), new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { component.encodeAll(facesContext); String output = outputWriter.toString(); - Assertions.assertTrue(output.contains("id=\"j_id__")); - Assertions.assertTrue(output.contains("name=\"j_id__")); + assertTrue(output.contains("id=\"j_id__")); + assertTrue(output.contains("name=\"j_id__")); outputWriter.reset(); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + }); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectManyListboxClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectManyListboxClientBehaviorRendererTest.java index 2fc469df37..6de67d4f92 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectManyListboxClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectManyListboxClientBehaviorRendererTest.java @@ -28,7 +28,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlSelectManyListboxClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlSelectManyListboxClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectManyMenuClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectManyMenuClientBehaviorRendererTest.java index b7277e19db..b87540aede 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectManyMenuClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectManyMenuClientBehaviorRendererTest.java @@ -28,7 +28,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlSelectManyMenuClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlSelectManyMenuClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectOneListboxClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectOneListboxClientBehaviorRendererTest.java index 458cfe61af..9f88695a14 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectOneListboxClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectOneListboxClientBehaviorRendererTest.java @@ -28,7 +28,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlSelectOneListboxClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlSelectOneListboxClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectOneMenuClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectOneMenuClientBehaviorRendererTest.java index 1a036e2e5e..54c2f586a7 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectOneMenuClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectOneMenuClientBehaviorRendererTest.java @@ -28,7 +28,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlSelectOneMenuClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlSelectOneMenuClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectOneRadioClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectOneRadioClientBehaviorRendererTest.java index 4412533444..9d2331c943 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectOneRadioClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlSelectOneRadioClientBehaviorRendererTest.java @@ -18,13 +18,14 @@ */ package org.apache.myfaces.renderkit.html.behavior; +import static org.junit.jupiter.api.Assertions.assertTrue; + import jakarta.faces.component.UIComponent; import jakarta.faces.component.UISelectItem; import jakarta.faces.component.behavior.AjaxBehavior; import jakarta.faces.component.behavior.ClientBehaviorHolder; import jakarta.faces.component.html.HtmlSelectOneRadio; import org.junit.jupiter.api.AfterEach; - import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -33,7 +34,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlSelectOneRadioClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlSelectOneRadioClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; @@ -71,7 +72,7 @@ protected HtmlRenderedClientEventAttr[] getClientBehaviorHtmlRenderedAttributes( } @Test - public void testClientBehaviorHolderRendersIdAndName() + public void clientBehaviorHolderRendersIdAndName() { HtmlRenderedClientEventAttr[] attrs = getClientBehaviorHtmlRenderedAttributes(); @@ -80,18 +81,13 @@ public void testClientBehaviorHolderRendersIdAndName() UIComponent component = createComponentToTest(); ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component; clientBehaviorHolder.addClientBehavior(attrs[i].getClientEvent(), new AjaxBehavior()); - try - { + Assertions.assertDoesNotThrow(() -> { component.encodeAll(facesContext); String output = outputWriter.toString(); - Assertions.assertTrue(output.contains("id=\"j_id__")); - Assertions.assertTrue(output.contains("name=\"j_id__")); + assertTrue(output.contains("id=\"j_id__")); + assertTrue(output.contains("name=\"j_id__")); outputWriter.reset(); - } - catch (Exception e) - { - Assertions.fail(e.getMessage()); - } + }); } } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlTextClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlTextClientBehaviorRendererTest.java index d410ae343b..cfceda73a7 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlTextClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlTextClientBehaviorRendererTest.java @@ -27,7 +27,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlTextClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlTextClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlTextareaClientBehaviorRendererTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlTextareaClientBehaviorRendererTest.java index 0eb76073af..d7c39b1f49 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlTextareaClientBehaviorRendererTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/behavior/HtmlTextareaClientBehaviorRendererTest.java @@ -27,7 +27,7 @@ * @author Leonardo Uribe (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class HtmlTextareaClientBehaviorRendererTest extends AbstractClientBehaviorTestCase +class HtmlTextareaClientBehaviorRendererTest extends AbstractClientBehaviorTestCase { private HtmlRenderedClientEventAttr[] attrs = null; diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/util/AjaxScriptBuilderTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/util/AjaxScriptBuilderTest.java index 991b62d0f7..787de35e42 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/util/AjaxScriptBuilderTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/util/AjaxScriptBuilderTest.java @@ -22,15 +22,17 @@ import org.apache.myfaces.component.search.*; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.apache.myfaces.test.mock.MockApplication; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.ArrayList; + +import static org.junit.jupiter.api.Assertions.*; + import java.util.Arrays; import java.util.List; -public class AjaxScriptBuilderTest extends AbstractFacesTestCase +class AjaxScriptBuilderTest extends AbstractFacesTestCase { @BeforeEach @Override @@ -61,7 +63,7 @@ public void setUp() throws Exception } @Test - public void test() + void test() { UIComponentMock component = new UIComponentMock(); component.setId("test"); @@ -86,8 +88,8 @@ public void test() String script = sb.toString(); - Assertions.assertFalse(script.contains("':testJsparams:{")); - Assertions.assertTrue(script.contains("':testJs,'params':{")); - Assertions.assertEquals("myfaces.ab('j_id_i',event,'click','test','',{'onevent':testJs,'params':{'var1':'NEW VALUE'}})", script); + assertFalse(script.contains("':testJsparams:{")); + assertTrue(script.contains("':testJs,'params':{")); + assertEquals("myfaces.ab('j_id_i',event,'click','test','',{'onevent':testJs,'params':{'var1':'NEW VALUE'}})", script); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/util/HTMLEncoderTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/util/HTMLEncoderTest.java index 330fdbd8eb..191fce896c 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/util/HTMLEncoderTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/util/HTMLEncoderTest.java @@ -16,18 +16,21 @@ package org.apache.myfaces.renderkit.html.util; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.CharArrayWriter; -import java.io.IOException; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.apache.myfaces.test.mock.MockFacesContext; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * HTMLEncoderTest tests org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder. */ -public class HTMLEncoderTest extends AbstractFacesTestCase { +class HTMLEncoderTest extends AbstractFacesTestCase { private String stringNoSpecialChars = "Hello, this is MyFaces speaking!"; private String stringNoSpecialCharsEncoded = "Hello, this is MyFaces speaking!"; private String stringNoSpecialCharsEncodedPartial = "lo, this is MyFaces speakin"; @@ -42,218 +45,192 @@ public class HTMLEncoderTest extends AbstractFacesTestCase { private String stringBlanks = ""; private String stringBlanksEncoded = "<Hello this is MyFaces speaking!>"; - /** - * Test method for - * {@link org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder#encode(String)}. - */ - @Test - public void testEncodeStringNoSpecialChars() { + /** + * Test method for + * {@link org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder#encode(String)}. + */ + @Test + void encodeStringNoSpecialChars() { String encodedStr = HTMLEncoder.encode(new MockFacesContext(), stringNoSpecialChars); - Assertions.assertEquals(stringNoSpecialCharsEncoded, encodedStr); + assertEquals(stringNoSpecialCharsEncoded, encodedStr); } - @Test - public void testEncodeStringSpecialChars1() { + @Test + void encodeStringSpecialChars1() { String encodedStr = HTMLEncoder.encode(new MockFacesContext(), stringSpecialChars1); - Assertions.assertEquals(stringSpecialChars1Encoded, encodedStr); + assertEquals(stringSpecialChars1Encoded, encodedStr); } - @Test - public void testEncodeStringSpecialChars2() { + @Test + void encodeStringSpecialChars2() { String encodedStr = HTMLEncoder.encode(new MockFacesContext(), stringSpecialChars2); - Assertions.assertEquals(stringSpecialChars2Encoded, encodedStr); + assertEquals(stringSpecialChars2Encoded, encodedStr); } - @Test - public void testEncodeStringLineBreak1() { + @Test + void encodeStringLineBreak1() { String encodedStr = HTMLEncoder.encode(new MockFacesContext(), stringLineBreak, true); - Assertions.assertEquals(stringLineBreakEncoded1, encodedStr); + assertEquals(stringLineBreakEncoded1, encodedStr); } - @Test - public void testEncodeStringLineBreak2() { + @Test + void encodeStringLineBreak2() { String encodedStr = HTMLEncoder.encode(new MockFacesContext(), stringLineBreak, false); - Assertions.assertEquals(stringLineBreakEncoded2, encodedStr); + assertEquals(stringLineBreakEncoded2, encodedStr); } - @Test - public void testEncodeStringEmpty() { + @Test + void encodeStringEmpty() { String encodedStr = HTMLEncoder.encode(new MockFacesContext(), ""); - Assertions.assertEquals("", encodedStr); + assertEquals("", encodedStr); } - @Test - public void testEncodeStringNull() { + @Test + void encodeStringNull() { String encodedStr = HTMLEncoder.encode(new MockFacesContext(), null); - Assertions.assertEquals("", encodedStr); + assertEquals("", encodedStr); } - @Test - public void testEncodeArrayNoSpecialChars() { - try { - CharArrayWriter writer = new CharArrayWriter(); - char[] source = stringNoSpecialChars.toCharArray(); - HTMLEncoder.encode(source, 0, source.length, writer); - assertCharArrayEquals(stringNoSpecialCharsEncoded.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + @Test + void encodeArrayNoSpecialChars() { + Assertions.assertDoesNotThrow(() -> { + CharArrayWriter writer = new CharArrayWriter(); + char[] source = stringNoSpecialChars.toCharArray(); + HTMLEncoder.encode(source, 0, source.length, writer); + assertCharArrayEquals(stringNoSpecialCharsEncoded.toCharArray(), writer.toCharArray()); + }); } - @Test - public void testEncodeArrayNoSpecialCharsPartial() { - try { - CharArrayWriter writer = new CharArrayWriter(); - char[] source = stringNoSpecialChars.toCharArray(); - HTMLEncoder.encode(source, 3, source.length - 5, writer); - assertCharArrayEquals(stringNoSpecialCharsEncodedPartial.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + @Test + void encodeArrayNoSpecialCharsPartial() { + Assertions.assertDoesNotThrow(() -> { + CharArrayWriter writer = new CharArrayWriter(); + char[] source = stringNoSpecialChars.toCharArray(); + HTMLEncoder.encode(source, 3, source.length - 5, writer); + assertCharArrayEquals(stringNoSpecialCharsEncodedPartial.toCharArray(), writer.toCharArray()); + }); } - @Test - public void testEncodeArraySpecialChars1() { - try { - CharArrayWriter writer = new CharArrayWriter(); - char[] source = stringSpecialChars1.toCharArray(); - HTMLEncoder.encode(source, 0, source.length, writer); - assertCharArrayEquals(stringSpecialChars1Encoded.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + @Test + void encodeArraySpecialChars1() { + Assertions.assertDoesNotThrow(() -> { + CharArrayWriter writer = new CharArrayWriter(); + char[] source = stringSpecialChars1.toCharArray(); + HTMLEncoder.encode(source, 0, source.length, writer); + assertCharArrayEquals(stringSpecialChars1Encoded.toCharArray(), writer.toCharArray()); + }); } - @Test - public void testEncodeArraySpecialChars2() { - try { - CharArrayWriter writer = new CharArrayWriter(); - char[] source = stringSpecialChars2.toCharArray(); - HTMLEncoder.encode(source, 0, source.length, writer); - assertCharArrayEquals(stringSpecialChars2Encoded.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + @Test + void encodeArraySpecialChars2() { + Assertions.assertDoesNotThrow(() -> { + CharArrayWriter writer = new CharArrayWriter(); + char[] source = stringSpecialChars2.toCharArray(); + HTMLEncoder.encode(source, 0, source.length, writer); + assertCharArrayEquals(stringSpecialChars2Encoded.toCharArray(), writer.toCharArray()); + }); } - @Test - public void testEncodeArrayEmpty() { - try { - CharArrayWriter writer = new CharArrayWriter(); - HTMLEncoder.encode(new char[]{}, 0, 1, writer); - assertCharArrayEquals(new char[]{}, writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + @Test + void encodeArrayEmpty() { + Assertions.assertDoesNotThrow(() -> { + CharArrayWriter writer = new CharArrayWriter(); + HTMLEncoder.encode(new char[]{}, 0, 1, writer); + assertCharArrayEquals(new char[]{}, writer.toCharArray()); + }); } - @Test - public void testEncodeArrayNull() { - try { - CharArrayWriter writer = new CharArrayWriter(); - HTMLEncoder.encode(null, 0, 0, writer); - assertCharArrayEquals(new char[]{}, writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + @Test + void encodeArrayNull() { + Assertions.assertDoesNotThrow(() -> { + CharArrayWriter writer = new CharArrayWriter(); + HTMLEncoder.encode(null, 0, 0, writer); + assertCharArrayEquals(new char[]{}, writer.toCharArray()); + }); } - @Test - public void testEncodeArrayWrongIndex1() { - try { - CharArrayWriter writer = new CharArrayWriter(); - char[] source = stringSpecialChars2.toCharArray(); - HTMLEncoder.encode(source, 0, source.length - 100, writer); - assertCharArrayEquals(new char[]{}, writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + @Test + void encodeArrayWrongIndex1() { + Assertions.assertDoesNotThrow(() -> { + CharArrayWriter writer = new CharArrayWriter(); + char[] source = stringSpecialChars2.toCharArray(); + HTMLEncoder.encode(source, 0, source.length - 100, writer); + assertCharArrayEquals(new char[]{}, writer.toCharArray()); + }); } - @Test - public void testEncodeArrayWrongIndex2() { - try { - CharArrayWriter writer = new CharArrayWriter(); - char[] source = stringSpecialChars2.toCharArray(); - HTMLEncoder.encode(source, -100, source.length, writer); - assertCharArrayEquals(stringSpecialChars2Encoded.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + @Test + void encodeArrayWrongIndex2() { + Assertions.assertDoesNotThrow(() -> { + CharArrayWriter writer = new CharArrayWriter(); + char[] source = stringSpecialChars2.toCharArray(); + HTMLEncoder.encode(source, -100, source.length, writer); + assertCharArrayEquals(stringSpecialChars2Encoded.toCharArray(), writer.toCharArray()); + }); } - @Test - public void testEncodeArrayWrongIndex3() { - try { - CharArrayWriter writer = new CharArrayWriter(); - char[] source = stringSpecialChars2.toCharArray(); - HTMLEncoder.encode(source, 100000, source.length, writer); - assertCharArrayEquals(new char[]{}, writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + @Test + void encodeArrayWrongIndex3() { + Assertions.assertDoesNotThrow(() -> { + CharArrayWriter writer = new CharArrayWriter(); + char[] source = stringSpecialChars2.toCharArray(); + HTMLEncoder.encode(source, 100000, source.length, writer); + assertCharArrayEquals(new char[]{}, writer.toCharArray()); + }); } - @Test - public void testEncodeArrayLineBreak1() { - try { - CharArrayWriter writer = new CharArrayWriter(); - char[] source = stringLineBreak.toCharArray(); - HTMLEncoder.encode(source, 0, source.length, true, writer); - assertCharArrayEquals(stringLineBreakEncoded1.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + @Test + void encodeArrayLineBreak1() { + Assertions.assertDoesNotThrow(() -> { + CharArrayWriter writer = new CharArrayWriter(); + char[] source = stringLineBreak.toCharArray(); + HTMLEncoder.encode(source, 0, source.length, true, writer); + assertCharArrayEquals(stringLineBreakEncoded1.toCharArray(), writer.toCharArray()); + }); } - @Test - public void testEncodeArrayLineBreak2() { - try { - CharArrayWriter writer = new CharArrayWriter(); - char[] source = stringLineBreak.toCharArray(); - HTMLEncoder.encode(source, 0, source.length, false, writer); - assertCharArrayEquals(stringLineBreakEncoded2.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + @Test + void encodeArrayLineBreak2() { + Assertions.assertDoesNotThrow(() -> { + CharArrayWriter writer = new CharArrayWriter(); + char[] source = stringLineBreak.toCharArray(); + HTMLEncoder.encode(source, 0, source.length, false, writer); + assertCharArrayEquals(stringLineBreakEncoded2.toCharArray(), writer.toCharArray()); + }); } - @Test - public void testEncodeArrayLineBreak2WrongIndex() { - try { - CharArrayWriter writer = new CharArrayWriter(); - char[] source = stringLineBreak.toCharArray(); - HTMLEncoder.encode(source, 0, source.length + 5, false, writer); - assertCharArrayEquals(stringLineBreakEncoded2.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + @Test + void encodeArrayLineBreak2WrongIndex() { + Assertions.assertDoesNotThrow(() -> { + CharArrayWriter writer = new CharArrayWriter(); + char[] source = stringLineBreak.toCharArray(); + HTMLEncoder.encode(source, 0, source.length + 5, false, writer); + assertCharArrayEquals(stringLineBreakEncoded2.toCharArray(), writer.toCharArray()); + }); } - @Test - public void testEncodeArrayLineBreakPartial() { - try { - CharArrayWriter writer = new CharArrayWriter(); - char[] source = stringLineBreak.toCharArray(); - HTMLEncoder.encode(source, 4, source.length - 5, writer); - char[] expected = stringLineBreakEncoded2Partial.toCharArray(); - assertCharArrayEquals(expected, writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + @Test + void encodeArrayLineBreakPartial() { + Assertions.assertDoesNotThrow(() -> { + CharArrayWriter writer = new CharArrayWriter(); + char[] source = stringLineBreak.toCharArray(); + HTMLEncoder.encode(source, 4, source.length - 5, writer); + char[] expected = stringLineBreakEncoded2Partial.toCharArray(); + assertCharArrayEquals(expected, writer.toCharArray()); + }); } - @Test - public void testSimpleWriteURIAttribute() throws Exception + @Test + void simpleWriteURIAttribute() throws Exception { String cad1 = "http://myfaces.apache.org/hello.jsf?key1=val&key2=val2#id"; String cad2 = "http://myfaces.apache.org/hello.jsf?key1=val&key2=val2#id"; String cad3 = HTMLEncoder.encodeURIAttribute(new MockFacesContext(), cad1, "UTF-8"); - Assertions.assertEquals(cad2, cad3); + assertEquals(cad2, cad3); } - - @Test - public void testUsAsciiEscapedCharactersBeforeQuery() throws Exception + + @Test + void usAsciiEscapedCharactersBeforeQuery() throws Exception { // Escape // - From %00 to %20, @@ -265,18 +242,18 @@ public void testUsAsciiEscapedCharactersBeforeQuery() throws Exception String cad1 = "?key=\"%<>\\`{|}^\n "; //Omit % String cad2 = "?key=%22%25%3C%3E%5C%60%7B%7C%7D%5E%0A%20"; String cad3 = HTMLEncoder.encodeURIAttribute(new MockFacesContext(), cad1,"UTF-8"); - Assertions.assertEquals(cad2, cad3); + assertEquals(cad2, cad3); String cad4 = "\"%<>\\`{|}^\n "; String cad5 = "%22%25%3C%3E%5C%60%7B%7C%7D%5E%0A%20"; String cad6 = HTMLEncoder.encodeURIAttribute(new MockFacesContext(), cad4,"UTF-8"); - Assertions.assertEquals(cad5, cad6); + assertEquals(cad5, cad6); } - - @Test - public void testUsAsciiEscapedCharactersBeforeQueryLowerCase() throws Exception + + @Test + void usAsciiEscapedCharactersBeforeQueryLowerCase() throws Exception { // Escape // - From %00 to %20, @@ -288,17 +265,17 @@ public void testUsAsciiEscapedCharactersBeforeQueryLowerCase() throws Exception String cad1 = "?key=\"%<>\\`{|}^\n "; //Omit % String cad2 = "?key=%22%25%3c%3e%5c%60%7b%7c%7d%5e%0a%20"; String cad3 = HTMLEncoder.encodeURIAttribute(new MockFacesContext(), cad1,"UTF-8"); - Assertions.assertEquals(cad2.substring(0,5) + cad2.substring(5).toUpperCase(), cad3); + assertEquals(cad2.substring(0,5) + cad2.substring(5).toUpperCase(), cad3); String cad4 = "\"%<>\\`{|}^\n "; String cad5 = "%22%25%3c%3e%5c%60%7b%7c%7d%5e%0a%20"; String cad6 = HTMLEncoder.encodeURIAttribute(new MockFacesContext(), cad4,"UTF-8"); - Assertions.assertEquals(cad5.substring(0,5) + cad5.substring(5).toUpperCase(), cad6); + assertEquals(cad5.substring(0,5) + cad5.substring(5).toUpperCase(), cad6); - } - - @Test - public void testWriteNonUsAsciiOnURIAttribute() throws Exception + } + + @Test + void writeNonUsAsciiOnURIAttribute() throws Exception { // Character ü in ISO-8859-1 is %FC but on UTF-8 is %C3%BC. In this case, // it should encode as %C3%BC @@ -306,12 +283,12 @@ public void testWriteNonUsAsciiOnURIAttribute() throws Exception String cad1 = new String(array,"ISO-8859-1");//+(char)0xC3BC;//"http://myfaces.apache.org/heüll o.jsf?key=val#id"; String cad2 = "%C3%BC";//"http://myfaces.apache.org/he%FCll%20o.jsf?key=val#id"; String cad3 = HTMLEncoder.encodeURIAttribute(new MockFacesContext(), cad1,"UTF-8"); - Assertions.assertEquals(cad2, cad3); + assertEquals(cad2, cad3); } - - @Test - public void testReservedCharactersOnURIAttribute() throws Exception + + @Test + void reservedCharactersOnURIAttribute() throws Exception { //Reserved // Reserved characters (should not be percent-encoded) @@ -323,15 +300,15 @@ public void testReservedCharactersOnURIAttribute() throws Exception String cad1 = "?key=:/[]@!$'()*+,;="; //Omit & String cad2 = HTMLEncoder.encodeURIAttribute(new MockFacesContext(), cad1,"UTF-8"); - Assertions.assertEquals(cad1, cad2); + assertEquals(cad1, cad2); String cad7 = ":/[]@!$&'()*+,;="; String cad8 = HTMLEncoder.encodeURIAttribute(new MockFacesContext(), cad7,"UTF-8"); - Assertions.assertEquals(cad7, cad8); + assertEquals(cad7, cad8); } - @Test - public void testNonEncodedCharactersOnURIAttribute() throws Exception + @Test + void nonEncodedCharactersOnURIAttribute() throws Exception { // "... for consistency, percent-encoded octets in the ranges of ALPHA // (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period (%2E), @@ -339,19 +316,19 @@ public void testNonEncodedCharactersOnURIAttribute() throws Exception // producers...." String cad1 = "?key=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"; String cad2 = HTMLEncoder.encodeURIAttribute(new MockFacesContext(), cad1,"UTF-8"); - Assertions.assertEquals(cad1, cad2); + assertEquals(cad1, cad2); String cad3 = "#somefile?key=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"; String cad4 = HTMLEncoder.encodeURIAttribute(new MockFacesContext(), cad3,"UTF-8"); - Assertions.assertEquals(cad3, cad4); + assertEquals(cad3, cad4); String cad5 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"; String cad6 = HTMLEncoder.encodeURIAttribute(new MockFacesContext(), cad5,"UTF-8"); - Assertions.assertEquals(cad5, cad6); + assertEquals(cad5, cad6); } - @Test - public void testWriteURIAttribute() throws Exception + @Test + void writeURIAttribute() throws Exception { //Note char 256 or 0x100 should not be passed or percent encoded, because it is not //valid for URIs. @@ -366,13 +343,13 @@ public void testWriteURIAttribute() throws Exception String cad12 = "%C2%A1%C2%A2%C2%A3%C2%A4%C2%A5%C2%A6%C2%A7%C2%A8%C2%A9%C2%AA%C2%AB%C2%AC%C2%AD"+ "%C2%AE%C2%AF%C2%B0%C2%B1%C3%BF%C4%80"; String cad13 = HTMLEncoder.encodeURIAttribute(new MockFacesContext(), cad11,"UTF-8"); - Assertions.assertEquals(cad12, cad13); + assertEquals(cad12, cad13); String cad1= "?key=" + new String(array11,"UTF-8")+((char)(0xFF))+((char)(0x100)); String cad2 = "?key=%C2%A1%C2%A2%C2%A3%C2%A4%C2%A5%C2%A6%C2%A7%C2%A8%C2%A9%C2%AA%C2%AB%C2%AC%C2%AD"+ "%C2%AE%C2%AF%C2%B0%C2%B1%C3%BF%C4%80"; String cad3 = HTMLEncoder.encodeURIAttribute(new MockFacesContext(), cad1,"UTF-8"); - Assertions.assertEquals(cad2, cad3); + assertEquals(cad2, cad3); //String cad14 = "http://myfaces.apache.org/page.jsf?key="+((char)0xFF)+((char)0x100); //String cad15 = HTMLEncoder.encodeURIAttribute(cad14,false); @@ -381,10 +358,10 @@ public void testWriteURIAttribute() throws Exception private void assertCharArrayEquals(char[] expected, char[] actual) { if ((expected == null ^ actual == null) || expected.length != actual.length) { - Assertions.fail(); + fail(); } for (int i = 0; i < expected.length; i++) { - Assertions.assertEquals(expected[i], actual[i]); + assertEquals(expected[i], actual[i]); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/util/HTMLEncoderWriterTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/util/HTMLEncoderWriterTest.java index 879e8f2a45..6c82ced632 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/util/HTMLEncoderWriterTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/util/HTMLEncoderWriterTest.java @@ -15,8 +15,10 @@ */ package org.apache.myfaces.renderkit.html.util; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.CharArrayWriter; -import java.io.IOException; import java.io.StringWriter; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; @@ -29,7 +31,7 @@ * HTMLEncoderTest tests * org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder. */ -public class HTMLEncoderWriterTest extends AbstractFacesTestCase { +class HTMLEncoderWriterTest extends AbstractFacesTestCase { private String stringNoSpecialChars = "Hello, this is MyFaces speaking!"; private String stringNoSpecialCharsEncoded = "Hello, this is MyFaces speaking!"; @@ -66,213 +68,187 @@ public void tearDown() throws Exception { * {@link org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder#encode(String)}. */ @Test - public void testEncodeStringNoSpecialChars() throws Exception { + void encodeStringNoSpecialChars() throws Exception { HTMLEncoder.encode(sw, stringNoSpecialChars); - Assertions.assertEquals(stringNoSpecialCharsEncoded, sw.toString()); + assertEquals(stringNoSpecialCharsEncoded, sw.toString()); } @Test - public void testEncodeStringSpecialChars1() throws Exception { + void encodeStringSpecialChars1() throws Exception { HTMLEncoder.encode(sw, stringSpecialChars1); - Assertions.assertEquals(stringSpecialChars1Encoded, sw.toString()); + assertEquals(stringSpecialChars1Encoded, sw.toString()); } @Test - public void testEncodeStringSpecialChars2() throws Exception { + void encodeStringSpecialChars2() throws Exception { HTMLEncoder.encode(sw, stringSpecialChars2); - Assertions.assertEquals(stringSpecialChars2Encoded, sw.toString()); + assertEquals(stringSpecialChars2Encoded, sw.toString()); } @Test - public void testEncodeStringLineBreak1() throws Exception { + void encodeStringLineBreak1() throws Exception { HTMLEncoder.encode(sw, stringLineBreak, true); - Assertions.assertEquals(stringLineBreakEncoded1, sw.toString()); + assertEquals(stringLineBreakEncoded1, sw.toString()); } @Test - public void testEncodeStringLineBreak2() throws Exception { + void encodeStringLineBreak2() throws Exception { HTMLEncoder.encode(sw, stringLineBreak, false); - Assertions.assertEquals(stringLineBreakEncoded2, sw.toString()); + assertEquals(stringLineBreakEncoded2, sw.toString()); } @Test - public void testEncodeStringEmpty() throws Exception { + void encodeStringEmpty() throws Exception { HTMLEncoder.encode(sw, ""); - Assertions.assertEquals("", sw.toString()); + assertEquals("", sw.toString()); } @Test - public void testEncodeStringNull() throws Exception { + void encodeStringNull() throws Exception { HTMLEncoder.encode(sw, null); - Assertions.assertEquals("", sw.toString()); + assertEquals("", sw.toString()); } @Test - public void testEncodeArrayNoSpecialChars() throws Exception { - try { + void encodeArrayNoSpecialChars() throws Exception { + Assertions.assertDoesNotThrow(() -> { CharArrayWriter writer = new CharArrayWriter(); char[] source = stringNoSpecialChars.toCharArray(); HTMLEncoder.encode(source, 0, source.length, writer); assertCharArrayEquals(stringNoSpecialCharsEncoded.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + }); } @Test - public void testEncodeArrayNoSpecialCharsPartial() throws Exception { - try { + void encodeArrayNoSpecialCharsPartial() throws Exception { + Assertions.assertDoesNotThrow(() -> { CharArrayWriter writer = new CharArrayWriter(); char[] source = stringNoSpecialChars.toCharArray(); HTMLEncoder.encode(source, 3, source.length - 5, writer); assertCharArrayEquals(stringNoSpecialCharsEncodedPartial.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + }); } @Test - public void testEncodeArraySpecialChars1() throws Exception { - try { + void encodeArraySpecialChars1() throws Exception { + Assertions.assertDoesNotThrow(() -> { CharArrayWriter writer = new CharArrayWriter(); char[] source = stringSpecialChars1.toCharArray(); HTMLEncoder.encode(source, 0, source.length, writer); assertCharArrayEquals(stringSpecialChars1Encoded.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + }); } @Test - public void testEncodeArraySpecialChars2() throws Exception { - try { + void encodeArraySpecialChars2() throws Exception { + Assertions.assertDoesNotThrow(() -> { CharArrayWriter writer = new CharArrayWriter(); char[] source = stringSpecialChars2.toCharArray(); HTMLEncoder.encode(source, 0, source.length, writer); assertCharArrayEquals(stringSpecialChars2Encoded.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + }); } @Test - public void testEncodeArrayEmpty() throws Exception { - try { + void encodeArrayEmpty() throws Exception { + Assertions.assertDoesNotThrow(() -> { CharArrayWriter writer = new CharArrayWriter(); HTMLEncoder.encode(new char[]{}, 0, 1, writer); assertCharArrayEquals(new char[]{}, writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + }); } @Test - public void testEncodeArrayNull() throws Exception { - try { + void encodeArrayNull() throws Exception { + Assertions.assertDoesNotThrow(() -> { CharArrayWriter writer = new CharArrayWriter(); HTMLEncoder.encode(null, 0, 0, writer); assertCharArrayEquals(new char[]{}, writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + }); } @Test - public void testEncodeArrayWrongIndex1() throws Exception { - try { + void encodeArrayWrongIndex1() throws Exception { + Assertions.assertDoesNotThrow(() -> { CharArrayWriter writer = new CharArrayWriter(); char[] source = stringSpecialChars2.toCharArray(); HTMLEncoder.encode(source, 0, source.length - 100, writer); assertCharArrayEquals(new char[]{}, writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + }); } @Test - public void testEncodeArrayWrongIndex2() throws Exception { - try { + void encodeArrayWrongIndex2() throws Exception { + Assertions.assertDoesNotThrow(() -> { CharArrayWriter writer = new CharArrayWriter(); char[] source = stringSpecialChars2.toCharArray(); HTMLEncoder.encode(source, -100, source.length, writer); assertCharArrayEquals(stringSpecialChars2Encoded.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + }); } @Test - public void testEncodeArrayWrongIndex3() throws Exception { - try { + void encodeArrayWrongIndex3() throws Exception { + Assertions.assertDoesNotThrow(() -> { CharArrayWriter writer = new CharArrayWriter(); char[] source = stringSpecialChars2.toCharArray(); HTMLEncoder.encode(source, 100000, source.length, writer); assertCharArrayEquals(new char[]{}, writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + }); } @Test - public void testEncodeArrayLineBreak1() throws Exception { - try { + void encodeArrayLineBreak1() throws Exception { + Assertions.assertDoesNotThrow(() -> { CharArrayWriter writer = new CharArrayWriter(); char[] source = stringLineBreak.toCharArray(); HTMLEncoder.encode(source, 0, source.length, true, writer); assertCharArrayEquals(stringLineBreakEncoded1.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + }); } @Test - public void testEncodeArrayLineBreak2() throws Exception { - try { + void encodeArrayLineBreak2() throws Exception { + Assertions.assertDoesNotThrow(() -> { CharArrayWriter writer = new CharArrayWriter(); char[] source = stringLineBreak.toCharArray(); HTMLEncoder.encode(source, 0, source.length, false, writer); assertCharArrayEquals(stringLineBreakEncoded2.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + }); } @Test - public void testEncodeArrayLineBreak2WrongIndex() throws Exception { - try { + void encodeArrayLineBreak2WrongIndex() throws Exception { + Assertions.assertDoesNotThrow(() -> { CharArrayWriter writer = new CharArrayWriter(); char[] source = stringLineBreak.toCharArray(); HTMLEncoder.encode(source, 0, source.length + 5, false, writer); assertCharArrayEquals(stringLineBreakEncoded2.toCharArray(), writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + }); } @Test - public void testEncodeArrayLineBreakPartial() throws Exception { - try { + void encodeArrayLineBreakPartial() throws Exception { + Assertions.assertDoesNotThrow(() -> { CharArrayWriter writer = new CharArrayWriter(); char[] source = stringLineBreak.toCharArray(); HTMLEncoder.encode(source, 4, source.length - 5, writer); char[] expected = stringLineBreakEncoded2Partial.toCharArray(); assertCharArrayEquals(expected, writer.toCharArray()); - } catch (IOException e) { - Assertions.fail(e.getMessage()); - } + }); } @Test - public void testSimpleWriteURIAttribute() throws Exception { + void simpleWriteURIAttribute() throws Exception { String cad1 = "http://myfaces.apache.org/hello.jsf?key1=val&key2=val2#id"; String cad2 = "http://myfaces.apache.org/hello.jsf?key1=val&key2=val2#id"; HTMLEncoder.encodeURIAttribute(sw, cad1, "UTF-8"); String cad3 = sw.toString(); - Assertions.assertEquals(cad2, cad3); + assertEquals(cad2, cad3); } @Test - public void testUsAsciiEscapedCharactersBeforeQuery() throws Exception { + void usAsciiEscapedCharactersBeforeQuery() throws Exception { // Escape // - From %00 to %20, // - <"> %22, "%" %25 @@ -284,19 +260,19 @@ public void testUsAsciiEscapedCharactersBeforeQuery() throws Exception { String cad2 = "?key=%22%25%3C%3E%5C%60%7B%7C%7D%5E%0A%20"; HTMLEncoder.encodeURIAttribute(sw, cad1, "UTF-8"); String cad3 = sw.toString(); - Assertions.assertEquals(cad2, cad3); + assertEquals(cad2, cad3); String cad4 = "\"%<>\\`{|}^\n "; String cad5 = "%22%25%3C%3E%5C%60%7B%7C%7D%5E%0A%20"; sw = new StringWriter(); HTMLEncoder.encodeURIAttribute(sw, cad4, "UTF-8"); String cad6 = sw.toString(); - Assertions.assertEquals(cad5, cad6); + assertEquals(cad5, cad6); } @Test - public void testWriteNonUsAsciiOnURIAttribute() throws Exception { + void writeNonUsAsciiOnURIAttribute() throws Exception { // Character ü in ISO-8859-1 is %FC but on UTF-8 is %C3%BC. In this case, // it should encode as %C3%BC byte[] array = new byte[]{(byte) 0xFC}; @@ -304,12 +280,12 @@ public void testWriteNonUsAsciiOnURIAttribute() throws Exception { String cad2 = "%C3%BC";//"http://myfaces.apache.org/he%FCll%20o.jsf?key=val#id"; HTMLEncoder.encodeURIAttribute(sw, cad1, "UTF-8"); String cad3 = sw.toString(); - Assertions.assertEquals(cad2, cad3); + assertEquals(cad2, cad3); } @Test - public void testReservedCharactersOnURIAttribute() throws Exception { + void reservedCharactersOnURIAttribute() throws Exception { //Reserved // Reserved characters (should not be percent-encoded) // reserved = gen-delims / sub-delims @@ -321,17 +297,17 @@ public void testReservedCharactersOnURIAttribute() throws Exception { String cad1 = "?key=:/[]@!$'()*+,;="; //Omit & HTMLEncoder.encodeURIAttribute(sw, cad1, "UTF-8"); String cad2 = sw.toString(); - Assertions.assertEquals(cad1, cad2); + assertEquals(cad1, cad2); String cad7 = ":/[]@!$&'()*+,;="; sw = new StringWriter(40); HTMLEncoder.encodeURIAttribute(sw, cad7, "UTF-8"); String cad8 = sw.toString(); - Assertions.assertEquals(cad7, cad8); + assertEquals(cad7, cad8); } @Test - public void testNonEncodedCharactersOnURIAttribute() throws Exception { + void nonEncodedCharactersOnURIAttribute() throws Exception { // "... for consistency, percent-encoded octets in the ranges of ALPHA // (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period (%2E), // underscore (%5F), or tilde (%7E) should not be created by URI @@ -339,23 +315,23 @@ public void testNonEncodedCharactersOnURIAttribute() throws Exception { String cad1 = "?key=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"; HTMLEncoder.encodeURIAttribute(sw, cad1, "UTF-8"); String cad2 = sw.toString(); - Assertions.assertEquals(cad1, cad2); + assertEquals(cad1, cad2); String cad3 = "#somefile?key=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"; sw = new StringWriter(40); HTMLEncoder.encodeURIAttribute(sw, cad3, "UTF-8"); String cad4 = sw.toString(); - Assertions.assertEquals(cad3, cad4); + assertEquals(cad3, cad4); String cad5 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"; sw = new StringWriter(40); HTMLEncoder.encodeURIAttribute(sw, cad5, "UTF-8"); String cad6 = sw.toString(); - Assertions.assertEquals(cad5, cad6); + assertEquals(cad5, cad6); } @Test - public void testWriteURIAttribute() throws Exception { + void writeURIAttribute() throws Exception { //Note char 256 or 0x100 should not be passed or percent encoded, because it is not //valid for URIs. byte[] array11 = new byte[]{(byte) 0xC2, (byte) 0xA1, (byte) 0xC2, (byte) 0xA2, @@ -370,7 +346,7 @@ public void testWriteURIAttribute() throws Exception { + "%C2%AE%C2%AF%C2%B0%C2%B1%C3%BF%C4%80"; HTMLEncoder.encodeURIAttribute(sw, cad11, "UTF-8"); String cad13 = sw.toString(); - Assertions.assertEquals(cad12, cad13); + assertEquals(cad12, cad13); String cad1 = "?key=" + new String(array11, "UTF-8") + ((char) (0xFF)) + ((char) (0x100)); String cad2 = "?key=%C2%A1%C2%A2%C2%A3%C2%A4%C2%A5%C2%A6%C2%A7%C2%A8%C2%A9%C2%AA%C2%AB%C2%AC%C2%AD" @@ -378,7 +354,7 @@ public void testWriteURIAttribute() throws Exception { sw = new StringWriter(40); HTMLEncoder.encodeURIAttribute(sw, cad1, "UTF-8"); String cad3 = sw.toString(); - Assertions.assertEquals(cad2, cad3); + assertEquals(cad2, cad3); //String cad14 = "http://myfaces.apache.org/page.jsf?key="+((char)0xFF)+((char)0x100); //String cad15 = HTMLEncoder.encodeURIAttribute(cad14,false); @@ -387,10 +363,10 @@ public void testWriteURIAttribute() throws Exception { private void assertCharArrayEquals(char[] expected, char[] actual) { if ((expected == null ^ actual == null) || expected.length != actual.length) { - Assertions.fail(); + fail(); } for (int i = 0; i < expected.length; i++) { - Assertions.assertEquals(expected[i], actual[i]); + assertEquals(expected[i], actual[i]); } } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/util/JavascriptUtilsTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/util/JavascriptUtilsTest.java index a4ea3f8a99..6eb080ba68 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/util/JavascriptUtilsTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/util/JavascriptUtilsTest.java @@ -18,65 +18,66 @@ */ package org.apache.myfaces.renderkit.html.util; -import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.Test; -public class JavascriptUtilsTest +class JavascriptUtilsTest { @Test - public void testGetValidJavascriptNameTest_SimpleIdentifierUnchanged() + void getValidJavascriptNameTestSimpleIdentifierUnchanged() { - Assertions.assertEquals("fooBar123", + assertEquals("fooBar123", JavascriptUtils.getValidJavascriptName("fooBar123", false)); - Assertions.assertEquals("fooBar123", + assertEquals("fooBar123", JavascriptUtils.getValidJavascriptName("fooBar123", true, false)); } @Test - public void testGetValidJavascriptNameTest_ReservedWordAppendsUnderscoreWhenChecking() + void getValidJavascriptNameTestReservedWordAppendsUnderscoreWhenChecking() { - Assertions.assertEquals("var_", + assertEquals("var_", JavascriptUtils.getValidJavascriptName("var", true)); - Assertions.assertEquals("var_", + assertEquals("var_", JavascriptUtils.getValidJavascriptName("var", true, true)); } @Test - public void testGetValidJavascriptNameTest_ReservedWordUnchangedWhenNotChecking() + void getValidJavascriptNameTestReservedWordUnchangedWhenNotChecking() { - Assertions.assertEquals("var", + assertEquals("var", JavascriptUtils.getValidJavascriptName("var", false)); } @Test - public void testGetValidJavascriptNameTest_InvalidCharactersBecomeUnderscorePlusHex() + void getValidJavascriptNameTestInvalidCharactersBecomeUnderscorePlusHex() { - Assertions.assertEquals("a_2Db", + assertEquals("a_2Db", JavascriptUtils.getValidJavascriptName("a-b", false)); - Assertions.assertEquals("x_2Ey", + assertEquals("x_2Ey", JavascriptUtils.getValidJavascriptName("x.y", false)); } @Test - public void testGetValidJavascriptNameTest_AllowNamespacesSplitsSegments() + void getValidJavascriptNameTestAllowNamespacesSplitsSegments() { - Assertions.assertEquals("a.b", + assertEquals("a.b", JavascriptUtils.getValidJavascriptName("a.b", true, false)); - Assertions.assertEquals("a_3Ab.c", + assertEquals("a_3Ab.c", JavascriptUtils.getValidJavascriptName("a:b.c", true, false)); } @Test - public void testGetValidJavascriptNameTest_AllowNamespacesFalseTreatsDotsAsInvalid() + void getValidJavascriptNameTestAllowNamespacesFalseTreatsDotsAsInvalid() { - Assertions.assertEquals("a_2Eb", + assertEquals("a_2Eb", JavascriptUtils.getValidJavascriptName("a.b", false, false)); } @Test - public void testGetValidJavascriptNameTest_EmptyString() + void getValidJavascriptNameTestEmptyString() { - Assertions.assertEquals("", + assertEquals("", JavascriptUtils.getValidJavascriptName("", false)); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkit/html/util/UnicodeEncoderTest.java b/impl/src/test/java/org/apache/myfaces/renderkit/html/util/UnicodeEncoderTest.java index ab313716d9..045cfa3620 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkit/html/util/UnicodeEncoderTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkit/html/util/UnicodeEncoderTest.java @@ -15,44 +15,45 @@ */ package org.apache.myfaces.renderkit.html.util; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.StringWriter; -import org.junit.jupiter.api.Assertions; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.junit.jupiter.api.Test; -public class UnicodeEncoderTest extends AbstractFacesTestCase +class UnicodeEncoderTest extends AbstractFacesTestCase { @Test - public void testUnicodeEncoder1() throws Exception + void unicodeEncoder1() throws Exception { StringWriter sw = new StringWriter(40); UnicodeEncoder.encode(sw, ""+(char)0xE1); - Assertions.assertEquals(UnicodeEncoder.encode(""+(char)0xE1), sw.toString()); + assertEquals(UnicodeEncoder.encode(""+(char)0xE1), sw.toString()); } - + @Test - public void testUnicodeEncoder2() throws Exception + void unicodeEncoder2() throws Exception { StringWriter sw = new StringWriter(40); UnicodeEncoder.encode(sw, "h"+(char)0xE1); - Assertions.assertEquals(UnicodeEncoder.encode("h"+(char)0xE1), sw.toString()); + assertEquals(UnicodeEncoder.encode("h"+(char)0xE1), sw.toString()); } - + @Test - public void testUnicodeEncoder3() throws Exception + void unicodeEncoder3() throws Exception { StringWriter sw = new StringWriter(40); UnicodeEncoder.encode(sw, ""+(char)0xE1+"a"); - Assertions.assertEquals(UnicodeEncoder.encode(""+(char)0xE1)+"a", sw.toString()); + assertEquals(UnicodeEncoder.encode(""+(char)0xE1)+"a", sw.toString()); } - + @Test - public void testUnicodeEncoder4() throws Exception + void unicodeEncoder4() throws Exception { StringWriter sw = new StringWriter(40); UnicodeEncoder.encode(sw, "hello h"+(char)0xE1+"aaa

"); - Assertions.assertEquals("hello háaaa

", sw.toString()); + assertEquals("hello háaaa

", sw.toString()); } } diff --git a/impl/src/test/java/org/apache/myfaces/renderkits/OwnRenderkitTest.java b/impl/src/test/java/org/apache/myfaces/renderkits/OwnRenderkitTest.java index 32a2af14b3..8089c1f961 100644 --- a/impl/src/test/java/org/apache/myfaces/renderkits/OwnRenderkitTest.java +++ b/impl/src/test/java/org/apache/myfaces/renderkits/OwnRenderkitTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.renderkits; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import jakarta.faces.FactoryFinder; @@ -31,7 +33,6 @@ import org.apache.myfaces.test.mock.MockFacesContext12; import org.apache.myfaces.test.mock.MockResponseWriter; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -77,12 +78,12 @@ public void tearDown() throws Exception { } @Test - public void testOwnRenderKit() throws Exception { + void ownRenderKit() throws Exception { inputText.encodeEnd(facesContext); facesContext.renderResponse(); - Assertions.assertTrue(isOwnRenderKit); + assertTrue(isOwnRenderKit); } diff --git a/impl/src/test/java/org/apache/myfaces/resource/ResourceLoaderUtilsTest.java b/impl/src/test/java/org/apache/myfaces/resource/ResourceLoaderUtilsTest.java index 76e3237e48..6be42a725a 100644 --- a/impl/src/test/java/org/apache/myfaces/resource/ResourceLoaderUtilsTest.java +++ b/impl/src/test/java/org/apache/myfaces/resource/ResourceLoaderUtilsTest.java @@ -18,30 +18,27 @@ */ package org.apache.myfaces.resource; -import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.Test; -public class ResourceLoaderUtilsTest { - +class ResourceLoaderUtilsTest { + @Test - public void testFormatDateHeader() + void formatDateHeader() { - Assertions.assertEquals("Tue, 16 Jul 2019 08:10:19 GMT", + assertEquals("Tue, 16 Jul 2019 08:10:19 GMT", ResourceLoaderUtils.formatDateHeader(1563264619000L)); - Assertions.assertEquals("Tue, 16 Jul 2019 08:29:38 GMT", + assertEquals("Tue, 16 Jul 2019 08:29:38 GMT", ResourceLoaderUtils.formatDateHeader(1563265778653L)); } - + @Test - public void testParseDateHeader() + void parseDateHeader() { - Assertions.assertEquals(1563264619000L, - ResourceLoaderUtils.parseDateHeader("Tue, 16 Jul 2019 08:10:19 GMT"), - 2000); - - Assertions.assertEquals(1563265778653L, - ResourceLoaderUtils.parseDateHeader("Tue, 16 Jul 2019 08:29:38 GMT"), - 2000); + assertEquals(1563264619000L, ResourceLoaderUtils.parseDateHeader("Tue, 16 Jul 2019 08:10:19 GMT"), 2000); + + assertEquals(1563265778653L, ResourceLoaderUtils.parseDateHeader("Tue, 16 Jul 2019 08:29:38 GMT"), 2000); } } diff --git a/impl/src/test/java/org/apache/myfaces/resource/ResourceValidationUtilsTest.java b/impl/src/test/java/org/apache/myfaces/resource/ResourceValidationUtilsTest.java index df523942af..11672f2353 100644 --- a/impl/src/test/java/org/apache/myfaces/resource/ResourceValidationUtilsTest.java +++ b/impl/src/test/java/org/apache/myfaces/resource/ResourceValidationUtilsTest.java @@ -19,80 +19,83 @@ package org.apache.myfaces.resource; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; + import org.junit.jupiter.api.Test; -public class ResourceValidationUtilsTest extends AbstractFacesTestCase +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class ResourceValidationUtilsTest extends AbstractFacesTestCase { @Test - public void testLocaleNames() throws Exception + void localeNames() throws Exception { - Assertions.assertTrue(ResourceValidationUtils.isValidLocalePrefix("es_CO")); - Assertions.assertTrue(ResourceValidationUtils.isValidLocalePrefix("de")); - Assertions.assertTrue(ResourceValidationUtils.isValidLocalePrefix("de_AT")); - Assertions.assertTrue(ResourceValidationUtils.isValidLocalePrefix("zh_CN_id")); - Assertions.assertTrue(ResourceValidationUtils.isValidLocalePrefix("zh_CN_23")); + assertTrue(ResourceValidationUtils.isValidLocalePrefix("es_CO")); + assertTrue(ResourceValidationUtils.isValidLocalePrefix("de")); + assertTrue(ResourceValidationUtils.isValidLocalePrefix("de_AT")); + assertTrue(ResourceValidationUtils.isValidLocalePrefix("zh_CN_id")); + assertTrue(ResourceValidationUtils.isValidLocalePrefix("zh_CN_23")); - Assertions.assertFalse(ResourceValidationUtils.isValidLocalePrefix("de-AT")); - Assertions.assertFalse(ResourceValidationUtils.isValidLocalePrefix(".")); - Assertions.assertFalse(ResourceValidationUtils.isValidLocalePrefix("..")); - Assertions.assertFalse(ResourceValidationUtils.isValidLocalePrefix("zh_"+'\t'+"CN")); - Assertions.assertFalse(ResourceValidationUtils.isValidLocalePrefix("\\..")); - Assertions.assertFalse(ResourceValidationUtils.isValidLocalePrefix("/..")); - Assertions.assertFalse(ResourceValidationUtils.isValidLocalePrefix("../")); - Assertions.assertFalse(ResourceValidationUtils.isValidLocalePrefix("..\\")); - Assertions.assertFalse(ResourceValidationUtils.isValidLocalePrefix("..")); + assertFalse(ResourceValidationUtils.isValidLocalePrefix("de-AT")); + assertFalse(ResourceValidationUtils.isValidLocalePrefix(".")); + assertFalse(ResourceValidationUtils.isValidLocalePrefix("..")); + assertFalse(ResourceValidationUtils.isValidLocalePrefix("zh_"+'\t'+"CN")); + assertFalse(ResourceValidationUtils.isValidLocalePrefix("\\..")); + assertFalse(ResourceValidationUtils.isValidLocalePrefix("/..")); + assertFalse(ResourceValidationUtils.isValidLocalePrefix("../")); + assertFalse(ResourceValidationUtils.isValidLocalePrefix("..\\")); + assertFalse(ResourceValidationUtils.isValidLocalePrefix("..")); } - + @Test - public void testLibraryNames() throws Exception + void libraryNames() throws Exception { - Assertions.assertTrue(ResourceValidationUtils.isValidLibraryName("mylib")); - Assertions.assertTrue(ResourceValidationUtils.isValidLibraryName("org.apache.myfaces")); - Assertions.assertTrue(ResourceValidationUtils.isValidLibraryName("some-js-lib")); - Assertions.assertTrue(ResourceValidationUtils.isValidLibraryName("some_js_lib")); + assertTrue(ResourceValidationUtils.isValidLibraryName("mylib")); + assertTrue(ResourceValidationUtils.isValidLibraryName("org.apache.myfaces")); + assertTrue(ResourceValidationUtils.isValidLibraryName("some-js-lib")); + assertTrue(ResourceValidationUtils.isValidLibraryName("some_js_lib")); - Assertions.assertTrue(ResourceValidationUtils.isValidLibraryName("components/panels", true)); - Assertions.assertFalse(ResourceValidationUtils.isValidLibraryName("components/panels", false)); + assertTrue(ResourceValidationUtils.isValidLibraryName("components/panels", true)); + assertFalse(ResourceValidationUtils.isValidLibraryName("components/panels", false)); - Assertions.assertFalse(ResourceValidationUtils.isValidLibraryName("/mylib")); - Assertions.assertFalse(ResourceValidationUtils.isValidLibraryName("mylib"+'\t'+"22")); - Assertions.assertFalse(ResourceValidationUtils.isValidLibraryName("\\mylib")); - Assertions.assertFalse(ResourceValidationUtils.isValidLibraryName("..")); - Assertions.assertFalse(ResourceValidationUtils.isValidLibraryName("..", true)); - Assertions.assertFalse(ResourceValidationUtils.isValidLibraryName("some:js")); - Assertions.assertFalse(ResourceValidationUtils.isValidLibraryName("some?js")); - Assertions.assertFalse(ResourceValidationUtils.isValidLibraryName("some&js")); + assertFalse(ResourceValidationUtils.isValidLibraryName("/mylib")); + assertFalse(ResourceValidationUtils.isValidLibraryName("mylib"+'\t'+"22")); + assertFalse(ResourceValidationUtils.isValidLibraryName("\\mylib")); + assertFalse(ResourceValidationUtils.isValidLibraryName("..")); + assertFalse(ResourceValidationUtils.isValidLibraryName("..", true)); + assertFalse(ResourceValidationUtils.isValidLibraryName("some:js")); + assertFalse(ResourceValidationUtils.isValidLibraryName("some?js")); + assertFalse(ResourceValidationUtils.isValidLibraryName("some&js")); } @Test - public void testResourceNames() throws Exception + void resourceNames() throws Exception { - Assertions.assertTrue(ResourceValidationUtils.isValidResourceName("myres")); - Assertions.assertTrue(ResourceValidationUtils.isValidResourceName("myres.css")); - Assertions.assertTrue(ResourceValidationUtils.isValidResourceName("/myres")); - Assertions.assertTrue(ResourceValidationUtils.isValidResourceName("/mydir/./myres.css")); - Assertions.assertTrue(ResourceValidationUtils.isValidResourceName("org.apache.myfaces")); - Assertions.assertTrue(ResourceValidationUtils.isValidResourceName("my_res_file.css")); - Assertions.assertTrue(ResourceValidationUtils.isValidResourceName("my-res-file.css")); + assertTrue(ResourceValidationUtils.isValidResourceName("myres")); + assertTrue(ResourceValidationUtils.isValidResourceName("myres.css")); + assertTrue(ResourceValidationUtils.isValidResourceName("/myres")); + assertTrue(ResourceValidationUtils.isValidResourceName("/mydir/./myres.css")); + assertTrue(ResourceValidationUtils.isValidResourceName("org.apache.myfaces")); + assertTrue(ResourceValidationUtils.isValidResourceName("my_res_file.css")); + assertTrue(ResourceValidationUtils.isValidResourceName("my-res-file.css")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("myres"+'\t'+"22")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("\\myres")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("..")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("../")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("/..")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("\\..")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("..\\")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("myres.css/..")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("myres.css\\..")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("../myres.css")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("..\\myres.css")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("my/../res.css")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("my\\../res.css")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("my/..\\res.css")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("/mydir/../myres.css")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("my_res:file.css")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("my_res?file.css")); - Assertions.assertFalse(ResourceValidationUtils.isValidResourceName("my_res&file.css")); + assertFalse(ResourceValidationUtils.isValidResourceName("myres"+'\t'+"22")); + assertFalse(ResourceValidationUtils.isValidResourceName("\\myres")); + assertFalse(ResourceValidationUtils.isValidResourceName("..")); + assertFalse(ResourceValidationUtils.isValidResourceName("../")); + assertFalse(ResourceValidationUtils.isValidResourceName("/..")); + assertFalse(ResourceValidationUtils.isValidResourceName("\\..")); + assertFalse(ResourceValidationUtils.isValidResourceName("..\\")); + assertFalse(ResourceValidationUtils.isValidResourceName("myres.css/..")); + assertFalse(ResourceValidationUtils.isValidResourceName("myres.css\\..")); + assertFalse(ResourceValidationUtils.isValidResourceName("../myres.css")); + assertFalse(ResourceValidationUtils.isValidResourceName("..\\myres.css")); + assertFalse(ResourceValidationUtils.isValidResourceName("my/../res.css")); + assertFalse(ResourceValidationUtils.isValidResourceName("my\\../res.css")); + assertFalse(ResourceValidationUtils.isValidResourceName("my/..\\res.css")); + assertFalse(ResourceValidationUtils.isValidResourceName("/mydir/../myres.css")); + assertFalse(ResourceValidationUtils.isValidResourceName("my_res:file.css")); + assertFalse(ResourceValidationUtils.isValidResourceName("my_res?file.css")); + assertFalse(ResourceValidationUtils.isValidResourceName("my_res&file.css")); } } diff --git a/impl/src/test/java/org/apache/myfaces/spi/FactoryFinderProviderTest.java b/impl/src/test/java/org/apache/myfaces/spi/FactoryFinderProviderTest.java index 2bfbeba4c0..da95c4d63e 100644 --- a/impl/src/test/java/org/apache/myfaces/spi/FactoryFinderProviderTest.java +++ b/impl/src/test/java/org/apache/myfaces/spi/FactoryFinderProviderTest.java @@ -18,10 +18,11 @@ */ package org.apache.myfaces.spi; +import static org.junit.jupiter.api.Assertions.assertEquals; + import jakarta.faces.FactoryFinder; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -34,18 +35,18 @@ public FactoryFinderProviderTest() } @BeforeEach - public void setUp() throws Exception + void setUp() throws Exception { } @AfterEach - public void tearDown() throws Exception + void tearDown() throws Exception { } - + @Test - public void testGetFactory() throws Exception + void getFactory() throws Exception { FactoryFinderProviderFactory ffp = new CustomFactoryFinderProviderFactoryImpl(); @@ -53,7 +54,7 @@ public void testGetFactory() throws Exception Object uno = FactoryFinder.getFactory("anything"); - Assertions.assertEquals(1, uno); + assertEquals(1, uno); FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, "sfdsfdsf"); diff --git a/impl/src/test/java/org/apache/myfaces/test/core/mock/MockMyFacesClient.java b/impl/src/test/java/org/apache/myfaces/test/core/mock/MockMyFacesClient.java index 1c178cc662..22b292c71f 100644 --- a/impl/src/test/java/org/apache/myfaces/test/core/mock/MockMyFacesClient.java +++ b/impl/src/test/java/org/apache/myfaces/test/core/mock/MockMyFacesClient.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.test.core.mock; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.HashMap; import java.util.Map; import jakarta.faces.FacesException; @@ -42,7 +44,6 @@ import org.apache.myfaces.renderkit.RendererUtils; import org.apache.myfaces.test.mock.MockHttpServletRequest; import org.apache.myfaces.test.mock.MockHttpServletResponse; -import org.junit.jupiter.api.Assertions; /** * Client that keep track and "translate" the commands done in a Faces component. @@ -95,7 +96,7 @@ public void processRedirect() } else { - Assertions.fail("Expected redirect not found"); + fail("Expected redirect not found"); } } diff --git a/impl/src/test/java/org/apache/myfaces/test/mock/MockRenderedValueExpression.java b/impl/src/test/java/org/apache/myfaces/test/mock/MockRenderedValueExpression.java index faa5bb5693..f668daf4c3 100644 --- a/impl/src/test/java/org/apache/myfaces/test/mock/MockRenderedValueExpression.java +++ b/impl/src/test/java/org/apache/myfaces/test/mock/MockRenderedValueExpression.java @@ -18,13 +18,13 @@ */ package org.apache.myfaces.test.mock; +import static org.junit.jupiter.api.Assertions.assertEquals; + import jakarta.el.ELContext; import jakarta.faces.component.UIComponent; import jakarta.faces.component.UIPanel; import jakarta.faces.context.FacesContext; -import org.junit.jupiter.api.Assertions; - /** * Verifies the current component on stack in method getValue. Created for MYFACES-3157 */ @@ -48,7 +48,7 @@ public MockRenderedValueExpression(String expression, Class expectedType, UIC public Object getValue(ELContext elContext) { FacesContext facesContext = (FacesContext) elContext.getContext(FacesContext.class); UIComponent currentComponent = UIComponent.getCurrentComponent(facesContext); - Assertions.assertEquals(currentComponent , toVerify, + assertEquals(currentComponent , toVerify, "If this ValueExpression is evaluated, component on stack must be actual"); return value; } diff --git a/impl/src/test/java/org/apache/myfaces/util/CommentUtilsTest.java b/impl/src/test/java/org/apache/myfaces/util/CommentUtilsTest.java index ce50e53d97..fcfbc1fce4 100644 --- a/impl/src/test/java/org/apache/myfaces/util/CommentUtilsTest.java +++ b/impl/src/test/java/org/apache/myfaces/util/CommentUtilsTest.java @@ -18,54 +18,54 @@ */ package org.apache.myfaces.util; -import java.io.IOException; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CommentUtilsTest extends AbstractFacesTestCase +class CommentUtilsTest extends AbstractFacesTestCase { @Test - public void testIsStartMatchWithCommentedCDATA() throws IOException + void isStartMatchWithCommentedCDATA() throws Exception { - Assertions.assertTrue(CommentUtils.isStartMatchWithCommentedCDATA("/*"+CommentUtils.CDATA_SIMPLE_START)); - Assertions.assertTrue(CommentUtils.isStartMatchWithCommentedCDATA("/* "+CommentUtils.CDATA_SIMPLE_START)); - Assertions.assertTrue(CommentUtils.isStartMatchWithCommentedCDATA("/* \n\t"+CommentUtils.CDATA_SIMPLE_START)); + assertTrue(CommentUtils.isStartMatchWithCommentedCDATA("/*"+CommentUtils.CDATA_SIMPLE_START)); + assertTrue(CommentUtils.isStartMatchWithCommentedCDATA("/* "+CommentUtils.CDATA_SIMPLE_START)); + assertTrue(CommentUtils.isStartMatchWithCommentedCDATA("/* \n\t"+CommentUtils.CDATA_SIMPLE_START)); } - + @Test - public void testIsEndMatchWithCommentedCDATA() throws IOException + void isEndMatchWithCommentedCDATA() throws Exception { - Assertions.assertTrue(CommentUtils.isEndMatchWithCommentedCDATA("fkdjslkfjsl "+CommentUtils.CDATA_SIMPLE_END+"*/")); - Assertions.assertTrue(CommentUtils.isEndMatchWithCommentedCDATA("fkdjslkfjsl "+CommentUtils.CDATA_SIMPLE_END+" */")); - Assertions.assertTrue(CommentUtils.isEndMatchWithCommentedCDATA("fkdjslkfjsl "+CommentUtils.CDATA_SIMPLE_END+"\n\t */")); + assertTrue(CommentUtils.isEndMatchWithCommentedCDATA("fkdjslkfjsl "+CommentUtils.CDATA_SIMPLE_END+"*/")); + assertTrue(CommentUtils.isEndMatchWithCommentedCDATA("fkdjslkfjsl "+CommentUtils.CDATA_SIMPLE_END+" */")); + assertTrue(CommentUtils.isEndMatchWithCommentedCDATA("fkdjslkfjsl "+CommentUtils.CDATA_SIMPLE_END+"\n\t */")); } - + @Test - public void testIsStartMatchWithInlineCommentedCDATA() throws IOException + void isStartMatchWithInlineCommentedCDATA() throws Exception { - Assertions.assertTrue(CommentUtils.isStartMatchWithInlineCommentedCDATA("//"+CommentUtils.CDATA_SIMPLE_START)); - Assertions.assertTrue(CommentUtils.isStartMatchWithInlineCommentedCDATA("// "+CommentUtils.CDATA_SIMPLE_START)); - Assertions.assertTrue(CommentUtils.isStartMatchWithInlineCommentedCDATA("// \t"+CommentUtils.CDATA_SIMPLE_START)); - Assertions.assertFalse(CommentUtils.isStartMatchWithInlineCommentedCDATA("// \n"+CommentUtils.CDATA_SIMPLE_START)); + assertTrue(CommentUtils.isStartMatchWithInlineCommentedCDATA("//"+CommentUtils.CDATA_SIMPLE_START)); + assertTrue(CommentUtils.isStartMatchWithInlineCommentedCDATA("// "+CommentUtils.CDATA_SIMPLE_START)); + assertTrue(CommentUtils.isStartMatchWithInlineCommentedCDATA("// \t"+CommentUtils.CDATA_SIMPLE_START)); + assertFalse(CommentUtils.isStartMatchWithInlineCommentedCDATA("// \n"+CommentUtils.CDATA_SIMPLE_START)); } @Test - public void testIsEndMatchWithInlineCommentedCDATA() throws IOException + void isEndMatchWithInlineCommentedCDATA() throws Exception { - Assertions.assertTrue(CommentUtils.isEndMatchWithInlineCommentedCDATA("fkdjslkfjsl //"+CommentUtils.CDATA_SIMPLE_END)); - Assertions.assertTrue(CommentUtils.isEndMatchWithInlineCommentedCDATA("fkdjslkfjsl // "+CommentUtils.CDATA_SIMPLE_END)); - Assertions.assertTrue(CommentUtils.isEndMatchWithInlineCommentedCDATA("fkdjslkfjsl //\t "+CommentUtils.CDATA_SIMPLE_END)); - Assertions.assertFalse(CommentUtils.isEndMatchWithInlineCommentedCDATA("fkdjslkfjsl //\n\t "+CommentUtils.CDATA_SIMPLE_END)); + assertTrue(CommentUtils.isEndMatchWithInlineCommentedCDATA("fkdjslkfjsl //"+CommentUtils.CDATA_SIMPLE_END)); + assertTrue(CommentUtils.isEndMatchWithInlineCommentedCDATA("fkdjslkfjsl // "+CommentUtils.CDATA_SIMPLE_END)); + assertTrue(CommentUtils.isEndMatchWithInlineCommentedCDATA("fkdjslkfjsl //\t "+CommentUtils.CDATA_SIMPLE_END)); + assertFalse(CommentUtils.isEndMatchWithInlineCommentedCDATA("fkdjslkfjsl //\n\t "+CommentUtils.CDATA_SIMPLE_END)); } - + @Test - public void testIsEndMatchtWithInlineCommentedXmlCommentTag() throws IOException + void isEndMatchtWithInlineCommentedXmlCommentTag() throws Exception { - Assertions.assertTrue(CommentUtils.isEndMatchtWithInlineCommentedXmlCommentTag("fkdjslkfjsl //"+CommentUtils.COMMENT_SIMPLE_END)); - Assertions.assertTrue(CommentUtils.isEndMatchtWithInlineCommentedXmlCommentTag("fkdjslkfjsl // "+CommentUtils.COMMENT_SIMPLE_END)); - Assertions.assertTrue(CommentUtils.isEndMatchtWithInlineCommentedXmlCommentTag("fkdjslkfjsl //\t "+CommentUtils.COMMENT_SIMPLE_END)); - Assertions.assertFalse(CommentUtils.isEndMatchtWithInlineCommentedXmlCommentTag("fkdjslkfjsl //\n\t "+CommentUtils.COMMENT_SIMPLE_END)); + assertTrue(CommentUtils.isEndMatchtWithInlineCommentedXmlCommentTag("fkdjslkfjsl //"+CommentUtils.COMMENT_SIMPLE_END)); + assertTrue(CommentUtils.isEndMatchtWithInlineCommentedXmlCommentTag("fkdjslkfjsl // "+CommentUtils.COMMENT_SIMPLE_END)); + assertTrue(CommentUtils.isEndMatchtWithInlineCommentedXmlCommentTag("fkdjslkfjsl //\t "+CommentUtils.COMMENT_SIMPLE_END)); + assertFalse(CommentUtils.isEndMatchtWithInlineCommentedXmlCommentTag("fkdjslkfjsl //\n\t "+CommentUtils.COMMENT_SIMPLE_END)); } } diff --git a/impl/src/test/java/org/apache/myfaces/util/MessageUtilsTest.java b/impl/src/test/java/org/apache/myfaces/util/MessageUtilsTest.java index 5469926784..9587b8aa5c 100644 --- a/impl/src/test/java/org/apache/myfaces/util/MessageUtilsTest.java +++ b/impl/src/test/java/org/apache/myfaces/util/MessageUtilsTest.java @@ -15,6 +15,8 @@ */ package org.apache.myfaces.util; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.text.NumberFormat; import java.util.Locale; import java.util.ResourceBundle; @@ -22,13 +24,12 @@ import jakarta.faces.application.FacesMessage; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * TestCase for MessageUtils */ -public class MessageUtilsTest extends AbstractFacesTestCase +class MessageUtilsTest extends AbstractFacesTestCase { private static final String DEFAULT_BUNDLE = "jakarta.faces.Messages"; @@ -36,76 +37,76 @@ public class MessageUtilsTest extends AbstractFacesTestCase * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(Severity, String, Object)' */ @Test - public void testGetMessageSeverityStringObject() + void getMessageSeverityStringObject() { facesContext.getViewRoot().setLocale(Locale.ENGLISH); FacesMessage msg = MessageUtils.getMessage(FacesMessage.Severity.ERROR, "jakarta.faces.component.UIInput.CONVERSION", null); - Assertions.assertEquals("{0}: Conversion error occurred.", msg.getSummary()); + assertEquals("{0}: Conversion error occurred.", msg.getSummary()); facesContext.getViewRoot().setLocale(Locale.GERMAN); msg = MessageUtils.getMessage(FacesMessage.Severity.ERROR, "jakarta.faces.component.UIInput.CONVERSION", "blubb"); - Assertions.assertEquals("blubb: Ein Konvertierungsfehler ist aufgetreten.", msg.getSummary()); + assertEquals("blubb: Ein Konvertierungsfehler ist aufgetreten.", msg.getSummary()); } /** * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(Severity, String, Object[])' */ @Test - public void testGetMessageSeverityStringObjectArray() + void getMessageSeverityStringObjectArray() { facesContext.getViewRoot().setLocale(Locale.ENGLISH); FacesMessage msg = MessageUtils.getMessage(FacesMessage.Severity.ERROR, "jakarta.faces.component.UIInput.CONVERSION", null); - Assertions.assertEquals("{0}: Conversion error occurred.", msg.getSummary()); + assertEquals("{0}: Conversion error occurred.", msg.getSummary()); facesContext.getViewRoot().setLocale(Locale.GERMAN); msg = MessageUtils.getMessage(FacesMessage.Severity.ERROR, "jakarta.faces.component.UIInput.CONVERSION", null); - Assertions.assertEquals("{0}: Ein Konvertierungsfehler ist aufgetreten.", msg.getSummary()); + assertEquals("{0}: Ein Konvertierungsfehler ist aufgetreten.", msg.getSummary()); } /** * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(Severity, String, Object[], FacesContext)' */ @Test - public void testGetMessageSeverityStringObjectArrayFacesContext() + void getMessageSeverityStringObjectArrayFacesContext() { facesContext.getViewRoot().setLocale(Locale.ENGLISH); FacesMessage msg = MessageUtils.getMessage(FacesMessage.Severity.ERROR, "jakarta.faces.component.UIInput.CONVERSION", null, facesContext); - Assertions.assertEquals("{0}: Conversion error occurred.", msg.getSummary()); + assertEquals("{0}: Conversion error occurred.", msg.getSummary()); facesContext.getViewRoot().setLocale(Locale.GERMAN); msg = MessageUtils.getMessage(FacesMessage.Severity.ERROR, "jakarta.faces.component.UIInput.CONVERSION", null, facesContext); - Assertions.assertEquals("{0}: Ein Konvertierungsfehler ist aufgetreten.", msg.getSummary()); + assertEquals("{0}: Ein Konvertierungsfehler ist aufgetreten.", msg.getSummary()); } /** * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(Locale, String, Object[])' */ @Test - public void testGetMessageLocaleStringObjectArray() + void getMessageLocaleStringObjectArray() { facesContext.getViewRoot().setLocale(Locale.ENGLISH); FacesMessage msg = org.apache.myfaces.util.MessageUtils.getMessage(Locale.ENGLISH, "jakarta.faces.component.UIInput.CONVERSION", null); - Assertions.assertEquals("{0}: Conversion error occurred.", msg.getSummary()); + assertEquals("{0}: Conversion error occurred.", msg.getSummary()); msg = MessageUtils.getMessage(Locale.GERMAN, "jakarta.faces.component.UIInput.CONVERSION", null); - Assertions.assertEquals("{0}: Ein Konvertierungsfehler ist aufgetreten.", msg.getSummary()); + assertEquals("{0}: Ein Konvertierungsfehler ist aufgetreten.", msg.getSummary()); } @@ -113,45 +114,45 @@ public void testGetMessageLocaleStringObjectArray() * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(FacesContext, String)' */ @Test - public void testGetMessageFacesContextString() + void getMessageFacesContextString() { facesContext.getViewRoot().setLocale(Locale.ENGLISH); FacesMessage msg = MessageUtils.getMessage(facesContext, "jakarta.faces.component.UIInput.CONVERSION"); - Assertions.assertEquals("{0}: Conversion error occurred.", msg.getSummary()); + assertEquals("{0}: Conversion error occurred.", msg.getSummary()); facesContext.getViewRoot().setLocale(Locale.GERMAN); msg = MessageUtils.getMessage(facesContext, "jakarta.faces.component.UIInput.CONVERSION"); - Assertions.assertEquals("{0}: Ein Konvertierungsfehler ist aufgetreten.", msg.getSummary()); + assertEquals("{0}: Ein Konvertierungsfehler ist aufgetreten.", msg.getSummary()); } /** * Test method for 'org.apache.myfaces.shared.util.MessageUtils.getMessage(FacesContext, String, Object[])' */ @Test - public void testGetMessageFacesContextStringObjectArray() + void getMessageFacesContextStringObjectArray() { facesContext.getViewRoot().setLocale(Locale.ENGLISH); FacesMessage msg = MessageUtils.getMessage(facesContext, "jakarta.faces.component.UIInput.CONVERSION", null); - Assertions.assertEquals("{0}: Conversion error occurred.", msg.getSummary()); + assertEquals("{0}: Conversion error occurred.", msg.getSummary()); facesContext.getViewRoot().setLocale(Locale.GERMAN); msg = MessageUtils.getMessage(facesContext, "jakarta.faces.component.UIInput.CONVERSION", null); - Assertions.assertEquals("{0}: Ein Konvertierungsfehler ist aufgetreten.", msg.getSummary()); + assertEquals("{0}: Ein Konvertierungsfehler ist aufgetreten.", msg.getSummary()); } /** * testGetMessageWithBundle */ @Test - public void testGetMessageWithBundle() + void getMessageWithBundle() { facesContext.getViewRoot().setLocale(Locale.ENGLISH); @@ -160,55 +161,55 @@ public void testGetMessageWithBundle() FacesMessage msg = MessageUtils.getMessage(bundle, "jakarta.faces.component.UIInput.CONVERSION", null); - Assertions.assertEquals("{0}: Conversion error occurred.", msg.getSummary()); + assertEquals("{0}: Conversion error occurred.", msg.getSummary()); } /** * testGetMessageWithBundleName */ @Test - public void testGetMessageWithBundleName() + void getMessageWithBundleName() { facesContext.getViewRoot().setLocale(Locale.ENGLISH); FacesMessage msg = MessageUtils.getMessage(DEFAULT_BUNDLE, "jakarta.faces.component.UIInput.CONVERSION", null); - Assertions.assertEquals("{0}: Conversion error occurred.", msg.getSummary()); + assertEquals("{0}: Conversion error occurred.", msg.getSummary()); } /** * testGetMessageWithBundleNameLocale */ @Test - public void testGetMessageWithBundleNameLocale() + void getMessageWithBundleNameLocale() { FacesMessage msg = MessageUtils.getMessage(DEFAULT_BUNDLE, Locale.GERMAN, "jakarta.faces.component.UIInput.CONVERSION", null); - Assertions.assertEquals("{0}: Ein Konvertierungsfehler ist aufgetreten.", msg.getSummary()); + assertEquals("{0}: Ein Konvertierungsfehler ist aufgetreten.", msg.getSummary()); } /** * testSubstituteParamsWithDELocale( */ @Test - public void testSubstituteParamsWithDELocale() { + void substituteParamsWithDELocale() { String paramString = MessageUtils.substituteParams(Locale.GERMANY, "currency {0,number,currency}", new Object[]{100}); String expected = "currency " + NumberFormat.getCurrencyInstance(Locale.GERMANY).format(100); - Assertions.assertEquals(expected, paramString); + assertEquals(expected, paramString); } /** * testSubstituteParamsWithGBLocale( */ @Test - public void testSubstituteParamsWithGBLocale() { + void substituteParamsWithGBLocale() { String paramString = MessageUtils.substituteParams(Locale.UK, "currency {0,number,currency}", new Object[]{100}); //System.out.println(paramString); - Assertions.assertEquals("currency \u00a3100.00",paramString); + assertEquals("currency \u00a3100.00",paramString); } } diff --git a/impl/src/test/java/org/apache/myfaces/util/lang/AbstractAttributeMapTest.java b/impl/src/test/java/org/apache/myfaces/util/lang/AbstractAttributeMapTest.java index 6eb95edf6c..946f5556f3 100644 --- a/impl/src/test/java/org/apache/myfaces/util/lang/AbstractAttributeMapTest.java +++ b/impl/src/test/java/org/apache/myfaces/util/lang/AbstractAttributeMapTest.java @@ -18,12 +18,14 @@ */ package org.apache.myfaces.util.lang; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -31,32 +33,32 @@ * @author Mathias Broekelmann (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class AbstractAttributeMapTest +class AbstractAttributeMapTest { private TestAttributeMap _testimpl; @BeforeEach - public void setUp() throws Exception + void setUp() throws Exception { Map map = new HashMap(); map.put("key", "value"); _testimpl = new TestAttributeMap(map); } - + /** * Test method for {@link java.util.AbstractMap#hashCode()}. */ @Test - public void testHashCodeEquals() + void hashCodeEquals() { - Assertions.assertEquals(_testimpl.hashCode(), _testimpl.hashCode()); + assertEquals(_testimpl.hashCode(), _testimpl.hashCode()); } @Test - public void testValues() throws Exception + void values() throws Exception { _testimpl.put("myKey", "myValue"); - Assertions.assertTrue(_testimpl.containsValue("myValue")); + assertTrue(_testimpl.containsValue("myValue")); } private static final class TestAttributeMap extends AbstractAttributeMap diff --git a/impl/src/test/java/org/apache/myfaces/util/lang/ConcurrentLRUCacheTest.java b/impl/src/test/java/org/apache/myfaces/util/lang/ConcurrentLRUCacheTest.java index 40cef0065a..8a35b908fa 100644 --- a/impl/src/test/java/org/apache/myfaces/util/lang/ConcurrentLRUCacheTest.java +++ b/impl/src/test/java/org/apache/myfaces/util/lang/ConcurrentLRUCacheTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.util.lang; +import static org.junit.jupiter.api.Assertions.*; + import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashSet; @@ -30,129 +32,128 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class ConcurrentLRUCacheTest +class ConcurrentLRUCacheTest { @Test - public void testPutAndGet() + void putAndGet() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(10, 5); - Assertions.assertNull(cache.get("a")); - Assertions.assertEquals(0, cache.size()); + assertNull(cache.get("a")); + assertEquals(0, cache.size()); - Assertions.assertNull(cache.put("a", "1")); - Assertions.assertEquals("1", cache.get("a")); - Assertions.assertEquals(1, cache.size()); + assertNull(cache.put("a", "1")); + assertEquals("1", cache.get("a")); + assertEquals(1, cache.size()); - Assertions.assertNull(cache.get("b")); + assertNull(cache.get("b")); } @Test - public void testPutReturnsPreviousValue() + void putReturnsPreviousValue() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(10, 5); - Assertions.assertNull(cache.put("a", "1")); - Assertions.assertEquals("1", cache.put("a", "2")); - Assertions.assertEquals("2", cache.get("a")); - Assertions.assertEquals(1, cache.size()); + assertNull(cache.put("a", "1")); + assertEquals("1", cache.put("a", "2")); + assertEquals("2", cache.get("a")); + assertEquals(1, cache.size()); } @Test - public void testPutIgnoresNullValue() + void putIgnoresNullValue() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(10, 5); - Assertions.assertNull(cache.put("a", null)); - Assertions.assertEquals(0, cache.size()); + assertNull(cache.put("a", null)); + assertEquals(0, cache.size()); cache.put("a", "1"); // a null value must not drop the existing mapping either - Assertions.assertNull(cache.put("a", null)); - Assertions.assertEquals("1", cache.get("a")); + assertNull(cache.put("a", null)); + assertEquals("1", cache.get("a")); } @Test - public void testRemove() + void remove() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(10, 5); cache.put("a", "1"); - Assertions.assertNull(cache.remove("unknown")); - Assertions.assertEquals("1", cache.remove("a")); - Assertions.assertNull(cache.get("a")); - Assertions.assertEquals(0, cache.size()); - Assertions.assertNull(cache.remove("a")); + assertNull(cache.remove("unknown")); + assertEquals("1", cache.remove("a")); + assertNull(cache.get("a")); + assertEquals(0, cache.size()); + assertNull(cache.remove("a")); } @Test - public void testClear() + void clear() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(10, 5); putRange(cache, 0, 5); - Assertions.assertEquals(5, cache.size()); + assertEquals(5, cache.size()); cache.clear(); - Assertions.assertEquals(0, cache.size()); - Assertions.assertNull(cache.get("k0")); - Assertions.assertTrue(cache.getLatestAccessedItems(10).isEmpty()); + assertEquals(0, cache.size()); + assertNull(cache.get("k0")); + assertTrue(cache.getLatestAccessedItems(10).isEmpty()); } @Test - public void testInvalidWaterMarks() + void invalidWaterMarks() { - Assertions.assertThrows(IllegalArgumentException.class, () -> new ConcurrentLRUCache<>(0, 0)); - Assertions.assertThrows(IllegalArgumentException.class, () -> new ConcurrentLRUCache<>(-1, 0)); - Assertions.assertThrows(IllegalArgumentException.class, () -> new ConcurrentLRUCache<>(10, 10)); - Assertions.assertThrows(IllegalArgumentException.class, () -> new ConcurrentLRUCache<>(10, 11)); - Assertions.assertThrows(IllegalArgumentException.class, () -> new ConcurrentLRUCache<>(10, -1)); + assertThrows(IllegalArgumentException.class, () -> new ConcurrentLRUCache<>(0, 0)); + assertThrows(IllegalArgumentException.class, () -> new ConcurrentLRUCache<>(-1, 0)); + assertThrows(IllegalArgumentException.class, () -> new ConcurrentLRUCache<>(10, 10)); + assertThrows(IllegalArgumentException.class, () -> new ConcurrentLRUCache<>(10, 11)); + assertThrows(IllegalArgumentException.class, () -> new ConcurrentLRUCache<>(10, -1)); } @Test - public void testNoEvictionBelowUpperWaterMark() + void noEvictionBelowUpperWaterMark() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(10, 5); putRange(cache, 0, 10); - Assertions.assertEquals(10, cache.size()); - Assertions.assertEquals(keys(0, 10), keysOf(cache)); + assertEquals(10, cache.size()); + assertEquals(keys(0, 10), keysOf(cache)); } @Test - public void testEvictionDropsDownToLowerWaterMark() + void evictionDropsDownToLowerWaterMark() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(10, 5); putRange(cache, 0, 11); // the 11th put crosses the upper water mark, nothing was accessed, so the entries which // were inserted first are dropped - Assertions.assertEquals(5, cache.size()); - Assertions.assertEquals(keys(6, 11), keysOf(cache)); + assertEquals(5, cache.size()); + assertEquals(keys(6, 11), keysOf(cache)); } @Test - public void testEvictionKeepsAccessedEntries() + void evictionKeepsAccessedEntries() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(10, 5); putRange(cache, 0, 10); // k0 and k1 are the oldest entries, but accessing them protects them - Assertions.assertEquals("v0", cache.get("k0")); - Assertions.assertEquals("v1", cache.get("k1")); + assertEquals("v0", cache.get("k0")); + assertEquals("v1", cache.get("k1")); cache.put("k10", "v10"); - Assertions.assertEquals(5, cache.size()); - Assertions.assertEquals(new LinkedHashSet<>(Arrays.asList("k0", "k1", "k8", "k9", "k10")), + assertEquals(5, cache.size()); + assertEquals(new LinkedHashSet<>(Arrays.asList("k0", "k1", "k8", "k9", "k10")), keysOf(cache)); } @Test - public void testEvictionResetsTheAccessFlag() + void evictionResetsTheAccessFlag() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(10, 5); putRange(cache, 0, 10); @@ -165,68 +166,68 @@ public void testEvictionResetsTheAccessFlag() cache.get("k8"); putRange(cache, 11, 17); - Assertions.assertEquals(5, cache.size()); - Assertions.assertEquals(new LinkedHashSet<>(Arrays.asList("k8", "k13", "k14", "k15", "k16")), + assertEquals(5, cache.size()); + assertEquals(new LinkedHashSet<>(Arrays.asList("k8", "k13", "k14", "k15", "k16")), keysOf(cache)); } @Test - public void testEvictionWithLowerWaterMarkZero() + void evictionWithLowerWaterMarkZero() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(2, 0); putRange(cache, 0, 3); - Assertions.assertEquals(0, cache.size()); + assertEquals(0, cache.size()); } @Test - public void testRepeatedPutsStayBounded() + void repeatedPutsStayBounded() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(10, 5); for (int i = 0; i < 1000; i++) { cache.put("k" + i, "v" + i); - Assertions.assertTrue(cache.size() <= 10, "size must never exceed the upper water mark"); + assertTrue(cache.size() <= 10, "size must never exceed the upper water mark"); } - Assertions.assertEquals(10, cache.size()); - Assertions.assertEquals(keys(990, 1000), keysOf(cache)); + assertEquals(10, cache.size()); + assertEquals(keys(990, 1000), keysOf(cache)); } @Test - public void testAccessedItemsReturnEveryEntry() + void accessedItemsReturnEveryEntry() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(10, 5); putRange(cache, 0, 5); // all five entries share the same state, none of them may be swallowed - Assertions.assertEquals(5, cache.getLatestAccessedItems(5).size()); - Assertions.assertEquals(5, cache.getLatestAccessedItems(100).size()); - Assertions.assertEquals(5, cache.getOldestAccessedItems(100).size()); + assertEquals(5, cache.getLatestAccessedItems(5).size()); + assertEquals(5, cache.getLatestAccessedItems(100).size()); + assertEquals(5, cache.getOldestAccessedItems(100).size()); Map items = cache.getLatestAccessedItems(100); for (int i = 0; i < 5; i++) { - Assertions.assertEquals("v" + i, items.get("k" + i)); + assertEquals("v" + i, items.get("k" + i)); } } @Test - public void testAccessedItemsRespectN() + void accessedItemsRespectN() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(10, 5); putRange(cache, 0, 5); - Assertions.assertTrue(cache.getLatestAccessedItems(0).isEmpty()); - Assertions.assertTrue(cache.getLatestAccessedItems(-1).isEmpty()); - Assertions.assertTrue(cache.getOldestAccessedItems(0).isEmpty()); - Assertions.assertEquals(1, cache.getLatestAccessedItems(1).size()); - Assertions.assertEquals(3, cache.getOldestAccessedItems(3).size()); + assertTrue(cache.getLatestAccessedItems(0).isEmpty()); + assertTrue(cache.getLatestAccessedItems(-1).isEmpty()); + assertTrue(cache.getOldestAccessedItems(0).isEmpty()); + assertEquals(1, cache.getLatestAccessedItems(1).size()); + assertEquals(3, cache.getOldestAccessedItems(3).size()); } @Test - public void testAccessedItemsOrder() + void accessedItemsOrder() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(10, 5); cache.put("k0", "v0"); @@ -236,23 +237,23 @@ public void testAccessedItemsOrder() // k0 was accessed, so it ranks before the untouched entries; those are ordered by insertion cache.get("k0"); - Assertions.assertEquals(Arrays.asList("k0", "k2", "k1"), + assertEquals(Arrays.asList("k0", "k2", "k1"), new ArrayList<>(cache.getLatestAccessedItems(3).keySet())); - Assertions.assertEquals(Arrays.asList("k1", "k2", "k0"), + assertEquals(Arrays.asList("k1", "k2", "k0"), new ArrayList<>(cache.getOldestAccessedItems(3).keySet())); } @Test - public void testAccessedItemsOnEmptyCache() + void accessedItemsOnEmptyCache() { ConcurrentLRUCache cache = new ConcurrentLRUCache<>(10, 5); - Assertions.assertTrue(cache.getLatestAccessedItems(10).isEmpty()); - Assertions.assertTrue(cache.getOldestAccessedItems(10).isEmpty()); + assertTrue(cache.getLatestAccessedItems(10).isEmpty()); + assertTrue(cache.getOldestAccessedItems(10).isEmpty()); } @Test - public void testConcurrentAccess() throws Exception + void concurrentAccess() throws Exception { final int upperWaterMark = 200; final ConcurrentLRUCache cache = new ConcurrentLRUCache<>(upperWaterMark, 100); @@ -283,7 +284,7 @@ public void testConcurrentAccess() throws Exception if (value != null) { // a key must never be mapped to the value of another key - Assertions.assertEquals(valueOf(key), value); + assertEquals(valueOf(key), value); } else { @@ -292,7 +293,7 @@ public void testConcurrentAccess() throws Exception if ((j & 0xFF) == 0) { - Assertions.assertTrue(cache.getLatestAccessedItems(10).size() <= 10); + assertTrue(cache.getLatestAccessedItems(10).size() <= 10); } } } @@ -308,7 +309,7 @@ public void testConcurrentAccess() throws Exception } start.countDown(); - Assertions.assertTrue(done.await(60, TimeUnit.SECONDS), "threads did not finish in time"); + assertTrue(done.await(60, TimeUnit.SECONDS), "threads did not finish in time"); } finally { @@ -323,7 +324,7 @@ public void testConcurrentAccess() throws Exception // one quiescent put is enough to bring a cache which grew during the concurrent phase back // under the upper water mark cache.put("quiescent", "v"); - Assertions.assertTrue(cache.size() <= upperWaterMark, + assertTrue(cache.size() <= upperWaterMark, "size " + cache.size() + " exceeds the upper water mark " + upperWaterMark); } diff --git a/impl/src/test/java/org/apache/myfaces/util/lang/LRULinkedHashMapTest.java b/impl/src/test/java/org/apache/myfaces/util/lang/LRULinkedHashMapTest.java index 999bc25af6..b9b398c3f4 100644 --- a/impl/src/test/java/org/apache/myfaces/util/lang/LRULinkedHashMapTest.java +++ b/impl/src/test/java/org/apache/myfaces/util/lang/LRULinkedHashMapTest.java @@ -18,12 +18,14 @@ */ package org.apache.myfaces.util.lang; +import static org.junit.jupiter.api.Assertions.*; + import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -33,61 +35,61 @@ * @param * @param */ -public class LRULinkedHashMapTest { +class LRULinkedHashMapTest { - @Test - public void testLRU() { + @Test + void lru() { final K[] keys = getSampleKeys(); final V[] values = getSampleValues(); Iterator kit; Iterator vit; final LRULinkedHashMap map = new LRULinkedHashMap<>(2); - Assertions.assertEquals(0, map.size()); + assertEquals(0, map.size()); map.put(keys[0], values[0]); - Assertions.assertEquals(1, map.size()); + assertEquals(1, map.size()); map.put(keys[1], values[1]); - Assertions.assertEquals(2, map.size()); + assertEquals(2, map.size()); kit = map.keySet().iterator(); - Assertions.assertSame(keys[0], kit.next()); - Assertions.assertSame(keys[1], kit.next()); + assertSame(keys[0], kit.next()); + assertSame(keys[1], kit.next()); vit = map.values().iterator(); - Assertions.assertSame(values[0], vit.next()); - Assertions.assertSame(values[1], vit.next()); + assertSame(values[0], vit.next()); + assertSame(values[1], vit.next()); map.put(keys[2], values[2]); - Assertions.assertEquals(2, map.size()); + assertEquals(2, map.size()); kit = map.keySet().iterator(); - Assertions.assertSame(keys[1], kit.next()); - Assertions.assertSame(keys[2], kit.next()); + assertSame(keys[1], kit.next()); + assertSame(keys[2], kit.next()); vit = map.values().iterator(); - Assertions.assertSame(values[1], vit.next()); - Assertions.assertSame(values[2], vit.next()); + assertSame(values[1], vit.next()); + assertSame(values[2], vit.next()); map.put(keys[2], values[0]); - Assertions.assertEquals(2, map.size()); + assertEquals(2, map.size()); kit = map.keySet().iterator(); - Assertions.assertSame(keys[1], kit.next()); - Assertions.assertSame(keys[2], kit.next()); + assertSame(keys[1], kit.next()); + assertSame(keys[2], kit.next()); vit = map.values().iterator(); - Assertions.assertSame(values[1], vit.next()); - Assertions.assertSame(values[0], vit.next()); + assertSame(values[1], vit.next()); + assertSame(values[0], vit.next()); map.put(keys[1], values[3]); - Assertions.assertEquals(2, map.size()); + assertEquals(2, map.size()); kit = map.keySet().iterator(); - Assertions.assertSame(keys[2], kit.next()); - Assertions.assertSame(keys[1], kit.next()); + assertSame(keys[2], kit.next()); + assertSame(keys[1], kit.next()); vit = map.values().iterator(); - Assertions.assertSame(values[0], vit.next()); - Assertions.assertSame(values[3], vit.next()); + assertSame(values[0], vit.next()); + assertSame(values[3], vit.next()); } - //----------------------------------------------------------------------- - @Test - public void testAccessOrder() { + //----------------------------------------------------------------------- + @Test + void accessOrder() { final K[] keys = getSampleKeys(); final V[] values = getSampleValues(); Iterator kit; @@ -97,79 +99,79 @@ public void testAccessOrder() { map.put(keys[0], values[0]); map.put(keys[1], values[1]); kit = map.keySet().iterator(); - Assertions.assertSame(keys[0], kit.next()); - Assertions.assertSame(keys[1], kit.next()); + assertSame(keys[0], kit.next()); + assertSame(keys[1], kit.next()); vit = map.values().iterator(); - Assertions.assertSame(values[0], vit.next()); - Assertions.assertSame(values[1], vit.next()); + assertSame(values[0], vit.next()); + assertSame(values[1], vit.next()); // no change to order map.put(keys[1], values[1]); kit = map.keySet().iterator(); - Assertions.assertSame(keys[0], kit.next()); - Assertions.assertSame(keys[1], kit.next()); + assertSame(keys[0], kit.next()); + assertSame(keys[1], kit.next()); vit = map.values().iterator(); - Assertions.assertSame(values[0], vit.next()); - Assertions.assertSame(values[1], vit.next()); + assertSame(values[0], vit.next()); + assertSame(values[1], vit.next()); // no change to order map.put(keys[1], values[2]); kit = map.keySet().iterator(); - Assertions.assertSame(keys[0], kit.next()); - Assertions.assertSame(keys[1], kit.next()); + assertSame(keys[0], kit.next()); + assertSame(keys[1], kit.next()); vit = map.values().iterator(); - Assertions.assertSame(values[0], vit.next()); - Assertions.assertSame(values[2], vit.next()); + assertSame(values[0], vit.next()); + assertSame(values[2], vit.next()); // change to order map.put(keys[0], values[3]); kit = map.keySet().iterator(); - Assertions.assertSame(keys[1], kit.next()); - Assertions.assertSame(keys[0], kit.next()); + assertSame(keys[1], kit.next()); + assertSame(keys[0], kit.next()); vit = map.values().iterator(); - Assertions.assertSame(values[2], vit.next()); - Assertions.assertSame(values[3], vit.next()); + assertSame(values[2], vit.next()); + assertSame(values[3], vit.next()); // change to order map.get(keys[1]); kit = map.keySet().iterator(); - Assertions.assertSame(keys[0], kit.next()); - Assertions.assertSame(keys[1], kit.next()); + assertSame(keys[0], kit.next()); + assertSame(keys[1], kit.next()); vit = map.values().iterator(); - Assertions.assertSame(values[3], vit.next()); - Assertions.assertSame(values[2], vit.next()); + assertSame(values[3], vit.next()); + assertSame(values[2], vit.next()); // change to order map.get(keys[0]); kit = map.keySet().iterator(); - Assertions.assertSame(keys[1], kit.next()); - Assertions.assertSame(keys[0], kit.next()); + assertSame(keys[1], kit.next()); + assertSame(keys[0], kit.next()); vit = map.values().iterator(); - Assertions.assertSame(values[2], vit.next()); - Assertions.assertSame(values[3], vit.next()); + assertSame(values[2], vit.next()); + assertSame(values[3], vit.next()); // no change to order map.get(keys[0]); kit = map.keySet().iterator(); - Assertions.assertSame(keys[1], kit.next()); - Assertions.assertSame(keys[0], kit.next()); + assertSame(keys[1], kit.next()); + assertSame(keys[0], kit.next()); vit = map.values().iterator(); - Assertions.assertSame(values[2], vit.next()); - Assertions.assertSame(values[3], vit.next()); + assertSame(values[2], vit.next()); + assertSame(values[3], vit.next()); } - @SuppressWarnings("unchecked") - @Test - public void testClone() { + @SuppressWarnings("unchecked") + @Test + void testClone() { final LRULinkedHashMap map = new LRULinkedHashMap<>(10); map.put((K) "1", (V) "1"); final Map cloned = (Map) map.clone(); - Assertions.assertEquals(map.size(), cloned.size()); - Assertions.assertSame(map.get("1"), cloned.get("1")); + assertEquals(map.size(), cloned.size()); + assertSame(map.get("1"), cloned.get("1")); } - @Test - public void testSynchronizedRemoveFromEntrySet() throws InterruptedException { + @Test + void synchronizedRemoveFromEntrySet() throws Exception { final Map map = new LRULinkedHashMap<>(10000); @@ -191,28 +193,28 @@ public void uncaughtException(final Thread t, final Throwable e) { @Override public void run() { int i = 0; - try { - synchronized (this) { - notifyAll(); - wait(); - } - final Thread thread = Thread.currentThread(); - while (i < 1000 && !interrupted()) { - synchronized (map) { - map.put(thread.getName() + "[" + ++i + "]", thread); - } - } - synchronized (map) { - for (final Iterator> iter = map.entrySet().iterator(); iter.hasNext();) { - final Map.Entry entry = iter.next(); - if (entry.getValue() == this) { - iter.remove(); + try { + synchronized (this) { + notifyAll(); + wait(); + } + final Thread thread = Thread.currentThread(); + while (i < 1000 && !interrupted()) { + synchronized (map) { + map.put(thread.getName() + "[" + ++i + "]", thread); } - } - } - } catch (final InterruptedException e) { - Assertions.fail("Unexpected InterruptedException"); - } + } + synchronized (map) { + for (final Iterator> iter = map.entrySet().iterator();iter.hasNext();) { + final Map.Entry entry = iter.next(); + if (entry.getValue() == this) { + iter.remove(); + } + } + } + } catch (final InterruptedException e) { + fail("Unexpected InterruptedException"); + } if (i > 0) { synchronized (counter) { counter[0]++; @@ -247,13 +249,13 @@ public void run() { } } - Assertions.assertEquals(0, exceptions.size()); - Assertions.assertTrue(counter[0] >= threads.length, "Each thread should have put at least 1 element into the map, but only " + assertEquals(0, exceptions.size()); + assertTrue(counter[0] >= threads.length, "Each thread should have put at least 1 element into the map, but only " + counter[0] + " did succeed"); } - @Test - public void testSynchronizedRemoveFromKeySet() throws InterruptedException { + @Test + void synchronizedRemoveFromKeySet() throws Exception { final Map map = new LRULinkedHashMap<>(10000); @@ -275,28 +277,28 @@ public void uncaughtException(final Thread t, final Throwable e) { @Override public void run() { int i = 0; - try { - synchronized (this) { - notifyAll(); - wait(); - } - final Thread thread = Thread.currentThread(); - while (i < 1000 && !interrupted()) { - synchronized (map) { - map.put(thread.getName() + "[" + ++i + "]", thread); - } - } - synchronized (map) { - for (final Iterator iter = map.keySet().iterator(); iter.hasNext();) { - final String name = (String) iter.next(); - if (name.substring(0, name.indexOf('[')).equals(getName())) { - iter.remove(); + try { + synchronized (this) { + notifyAll(); + wait(); + } + final Thread thread = Thread.currentThread(); + while (i < 1000 && !interrupted()) { + synchronized (map) { + map.put(thread.getName() + "[" + ++i + "]", thread); } - } - } - } catch (final InterruptedException e) { - Assertions.fail("Unexpected InterruptedException"); - } + } + synchronized (map) { + for (final Iterator iter = map.keySet().iterator();iter.hasNext();) { + final String name = (String) iter.next(); + if (name.substring(0, name.indexOf('[')).equals(getName())) { + iter.remove(); + } + } + } + } catch (final InterruptedException e) { + fail("Unexpected InterruptedException"); + } if (i > 0) { synchronized (counter) { counter[0]++; @@ -331,13 +333,13 @@ public void run() { } } - Assertions.assertEquals(0, exceptions.size()); - Assertions.assertTrue(counter[0] >= threads.length, "Each thread should have put at least 1 element into the map, but only " + assertEquals(0, exceptions.size()); + assertTrue(counter[0] >= threads.length, "Each thread should have put at least 1 element into the map, but only " + counter[0] + " did succeed"); } - @Test - public void testSynchronizedRemoveFromValues() throws InterruptedException { + @Test + void synchronizedRemoveFromValues() throws Exception { final Map map = new LinkedHashMap<>(10000); @@ -359,27 +361,27 @@ public void uncaughtException(final Thread t, final Throwable e) { @Override public void run() { int i = 0; - try { - synchronized (this) { - notifyAll(); - wait(); - } - final Thread thread = Thread.currentThread(); - while (i < 1000 && !interrupted()) { - synchronized (map) { - map.put(thread.getName() + "[" + ++i + "]", thread); - } - } - synchronized (map) { - for (final Iterator iter = map.values().iterator(); iter.hasNext();) { - if (iter.next() == this) { - iter.remove(); + try { + synchronized (this) { + notifyAll(); + wait(); + } + final Thread thread = Thread.currentThread(); + while (i < 1000 && !interrupted()) { + synchronized (map) { + map.put(thread.getName() + "[" + ++i + "]", thread); } - } - } - } catch (final InterruptedException e) { - Assertions.fail("Unexpected InterruptedException"); - } + } + synchronized (map) { + for (final Iterator iter = map.values().iterator();iter.hasNext();) { + if (iter.next() == this) { + iter.remove(); + } + } + } + } catch (final InterruptedException e) { + fail("Unexpected InterruptedException"); + } if (i > 0) { synchronized (counter) { counter[0]++; @@ -414,8 +416,8 @@ public void run() { } } - Assertions.assertEquals(0, exceptions.size()); - Assertions.assertTrue(counter[0] >= threads.length, "Each thread should have put at least 1 element into the map, but only " + assertEquals(0, exceptions.size()); + assertTrue(counter[0] >= threads.length, "Each thread should have put at least 1 element into the map, but only " + counter[0] + " did succeed"); } diff --git a/impl/src/test/java/org/apache/myfaces/util/lang/XorShiftRandomTest.java b/impl/src/test/java/org/apache/myfaces/util/lang/XorShiftRandomTest.java index 93b8333976..5f77356f87 100644 --- a/impl/src/test/java/org/apache/myfaces/util/lang/XorShiftRandomTest.java +++ b/impl/src/test/java/org/apache/myfaces/util/lang/XorShiftRandomTest.java @@ -21,14 +21,15 @@ import org.junit.jupiter.api.Test; import java.util.HashSet; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Set; -import org.junit.jupiter.api.Assertions; -public class XorShiftRandomTest +class XorShiftRandomTest { @Test - public void testXorShiftRandom() + void xorShiftRandom() { XorShiftRandom random = new XorShiftRandom(System.nanoTime()); Set randomVals = new HashSet(10); @@ -41,12 +42,12 @@ public void testXorShiftRandom() } // if the random generator is good then we had no collisions. - Assertions.assertEquals(randomVals.size(), 100); + assertEquals(100, randomVals.size()); } @Test - public void testThreadsafeXorShiftRandom() + void threadsafeXorShiftRandom() { XorShiftRandom random = new ThreadsafeXorShiftRandom(); Set randomVals = new HashSet(10); @@ -59,6 +60,6 @@ public void testThreadsafeXorShiftRandom() } // if the random generator is good then we had no collisions. - Assertions.assertEquals(randomVals.size(), 100); + assertEquals(100, randomVals.size()); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/BrokenTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/BrokenTestCase.java index 395f71a1de..02778a5d01 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/BrokenTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/BrokenTestCase.java @@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test; -public class BrokenTestCase extends AbstractFaceletTestCase { +class BrokenTestCase extends AbstractFaceletTestCase { @Test - public void testBroken() throws Exception { + void broken() throws Exception { } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/EncodingTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/EncodingTestCase.java index b783987331..2eefe6bc70 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/EncodingTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/EncodingTestCase.java @@ -28,7 +28,7 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.junit.jupiter.api.Test; -public class EncodingTestCase extends AbstractFaceletTestCase +class EncodingTestCase extends AbstractFaceletTestCase { @Override @@ -49,7 +49,7 @@ protected void setupRenderers() throws Exception } @Test - public void testPattern() throws Exception + void pattern() throws Exception { Pattern p = Pattern .compile("^<\\?xml.+?version=['\"](.+?)['\"](.+?encoding=['\"]((.+?))['\"])?.*?\\?>"); @@ -71,7 +71,7 @@ public void testPattern() throws Exception } @Test - public void testEncoding() throws Exception + void encoding() throws Exception { request.setAttribute("name", "Mr. Hookom"); UIViewRoot root = facesContext.getViewRoot(); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/ExceptionTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/ExceptionTestCase.java index add4dce379..025fb9f360 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/ExceptionTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/ExceptionTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets; +import static org.junit.jupiter.api.Assertions.*; + import java.io.IOException; import java.util.Iterator; @@ -44,7 +46,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class ExceptionTestCase extends AbstractFaceletTestCase +class ExceptionTestCase extends AbstractFaceletTestCase { @Override @@ -59,9 +61,9 @@ protected void setUpFacesContext() throws Exception super.setUpFacesContext(); facesContext.setExceptionHandler(new ExceptionHandlerImpl()); } - + @Test - public void testActionException1() throws Exception + void actionException1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root,"testActionException1.xhtml"); @@ -69,7 +71,7 @@ public void testActionException1() throws Exception request.addParameter("mainForm:button1", "Submit"); UICommand button = (UICommand) root.findComponent("mainForm:button1"); - Assertions.assertNotNull(button); + assertNotNull(button); ExceptionBean bean = EasyMock.createMock(ExceptionBean.class); EasyMock.expect(bean.doSomeAction()).andThrow(new AbortProcessingException()); @@ -79,15 +81,10 @@ public void testActionException1() throws Exception request.setAttribute("bean", bean); button.processDecodes(facesContext); - - try - { + + Assertions.assertDoesNotThrow(() -> { root.processApplication(facesContext); - } - catch(FacesException e) - { - Assertions.fail("No exception should be thrown at this point."); - } + }, "No exception should be thrown at this point."); int i = 0; for (Iterator it = facesContext.getExceptionHandler().getUnhandledExceptionQueuedEvents().iterator(); it.hasNext();) @@ -101,10 +98,10 @@ public void testActionException1() throws Exception } else { - Assertions.fail("Unexpected exception queued"); + fail("Unexpected exception queued"); } } - Assertions.assertEquals(1, i); + assertEquals(1, i); } /** @@ -113,7 +110,7 @@ public void testActionException1() throws Exception * @throws Exception */ @Test - public void testActionException1_1() throws Exception + void actionException11() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root,"testActionException1.xhtml"); @@ -121,7 +118,7 @@ public void testActionException1_1() throws Exception request.addParameter("mainForm:button1", "Submit"); UICommand button = (UICommand) root.findComponent("mainForm:button1"); - Assertions.assertNotNull(button); + assertNotNull(button); ExceptionBean bean = EasyMock.createMock(ExceptionBean.class); EasyMock.expect(bean.doSomeAction()).andThrow(new RuntimeException()); @@ -143,16 +140,16 @@ public void testActionException1_1() throws Exception Iterable unhandledExceptionQueuedEvents = facesContext.getExceptionHandler().getUnhandledExceptionQueuedEvents(); ExceptionQueuedEvent exceptionQueuedEvent = unhandledExceptionQueuedEvents.iterator().next(); - Assertions.assertNotNull(exceptionQueuedEvent.getContext().getException()); + assertNotNull(exceptionQueuedEvent.getContext().getException()); } - + /** * A runtime exception thrown must be * * @throws Exception */ @Test - public void testActionException1_2() throws Exception + void actionException12() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root,"testActionException1.xhtml"); @@ -160,7 +157,7 @@ public void testActionException1_2() throws Exception request.addParameter("mainForm:button1", "Submit"); UICommand button = (UICommand) root.findComponent("mainForm:button1"); - Assertions.assertNotNull(button); + assertNotNull(button); ExceptionBean bean = EasyMock.createMock(ExceptionBean.class); EasyMock.expect(bean.doSomeAction()).andThrow(new IOException()); @@ -182,11 +179,11 @@ public void testActionException1_2() throws Exception Iterable unhandledExceptionQueuedEvents = facesContext.getExceptionHandler().getUnhandledExceptionQueuedEvents(); ExceptionQueuedEvent exceptionQueuedEvent = unhandledExceptionQueuedEvents.iterator().next(); - Assertions.assertNotNull(exceptionQueuedEvent.getContext().getException()); + assertNotNull(exceptionQueuedEvent.getContext().getException()); } @Test - public void testActionListenerException1() throws Exception + void actionListenerException1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root,"testActionListenerException1.xhtml"); @@ -194,7 +191,7 @@ public void testActionListenerException1() throws Exception request.addParameter("mainForm:button1", "Submit"); UICommand button = (UICommand) root.findComponent("mainForm:button1"); - Assertions.assertNotNull(button); + assertNotNull(button); //ActionEvent event = new ActionEvent(button); ExceptionBean bean = EasyMock.createMock(ExceptionBean.class); @@ -206,15 +203,10 @@ public void testActionListenerException1() throws Exception request.setAttribute("bean", bean); button.processDecodes(facesContext); - - try - { + + Assertions.assertDoesNotThrow(() -> { root.processApplication(facesContext); - } - catch(FacesException e) - { - Assertions.fail("No exception should be thrown at this point."); - } + }, "No exception should be thrown at this point."); int i = 0; for (Iterator it = facesContext.getExceptionHandler().getUnhandledExceptionQueuedEvents().iterator(); it.hasNext();) @@ -228,10 +220,10 @@ public void testActionListenerException1() throws Exception } else { - Assertions.fail("Unexpected exception queued"); + fail("Unexpected exception queued"); } } - Assertions.assertEquals(1, i); + assertEquals(1, i); } @@ -241,7 +233,7 @@ public void testActionListenerException1() throws Exception * @throws Exception */ @Test - public void testActionListenerException1_1() throws Exception + void actionListenerException11() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root,"testActionListenerException1.xhtml"); @@ -249,7 +241,7 @@ public void testActionListenerException1_1() throws Exception request.addParameter("mainForm:button1", "Submit"); UICommand button = (UICommand) root.findComponent("mainForm:button1"); - Assertions.assertNotNull(button); + assertNotNull(button); //ActionEvent event = new ActionEvent(button); ExceptionBean bean = EasyMock.createMock(ExceptionBean.class); @@ -284,7 +276,7 @@ public void testActionListenerException1_1() throws Exception Throwable e = eqe.getContext().getException(); if (e instanceof AbortProcessingException) { - Assertions.fail("Unexpected exception queued"); + fail("Unexpected exception queued"); } else { @@ -292,7 +284,7 @@ public void testActionListenerException1_1() throws Exception i++; } } - Assertions.assertEquals(1, i); + assertEquals(1, i); } @@ -304,7 +296,7 @@ private void publishException (Throwable e, PhaseId phaseId, FacesContext facesC } @Test - public void testValidatorException1() throws Exception + void validatorException1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root,"testValidatorException1.xhtml"); @@ -324,21 +316,16 @@ public void invokeContextCallback(FacesContext context, UIComponent target) UIInput input = (UIInput) target; input.setSubmittedValue(submittedValue); - try - { + Assertions.assertDoesNotThrow(() -> { input.processValidators(facesContext); - Assertions.assertTrue(facesContext.isValidationFailed()); - } - catch(FacesException e) - { - Assertions.fail("No exception expected"); - } + assertTrue(facesContext.isValidationFailed()); + }, "No exception expected"); } }); } - + @Test - public void testValidatorException2() throws Exception + void validatorException2() throws Exception { application.addValidator("customValidatorId", CustomValidator.class.getName()); UIViewRoot root = facesContext.getViewRoot(); @@ -352,23 +339,18 @@ public void invokeContextCallback(FacesContext context, UIComponent target) UIInput input = (UIInput) target; input.setSubmittedValue(submittedValue); - try - { + Assertions.assertDoesNotThrow(() -> { input.processValidators(facesContext); - Assertions.assertTrue(facesContext.isValidationFailed()); - } - catch(FacesException e) - { - Assertions.fail("No exception expected"); - } + assertTrue(facesContext.isValidationFailed()); + }, "No exception expected"); } }); - Assertions.assertEquals("not valid!", facesContext.getMessageList().get(0).getSummary()); + assertEquals("not valid!", facesContext.getMessageList().get(0).getSummary()); } - + @Test - public void testValueChangeListenerException1() throws Exception + void valueChangeListenerException1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root,"testValueChangeListenerException1.xhtml"); @@ -388,14 +370,9 @@ public void invokeContextCallback(FacesContext context, UIComponent target) UIInput input = (UIInput) target; input.setSubmittedValue(submittedValue); - try - { + Assertions.assertDoesNotThrow(() -> { input.processValidators(facesContext); - } - catch(FacesException e) - { - Assertions.fail("No exception expected"); - } + }, "No exception expected"); } }); @@ -421,14 +398,14 @@ public void invokeContextCallback(FacesContext context, UIComponent target) } else { - Assertions.fail("Unexpected exception queued"); + fail("Unexpected exception queued"); } } - Assertions.assertEquals(1, i); + assertEquals(1, i); } - + @Test - public void testValueChangeListenerException1_1() throws Exception + void valueChangeListenerException11() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root,"testValueChangeListenerException1.xhtml"); @@ -446,14 +423,9 @@ public void invokeContextCallback(FacesContext context, UIComponent target) UIInput input = (UIInput) target; input.setSubmittedValue(submittedValue); - try - { + Assertions.assertDoesNotThrow(() -> { input.processValidators(facesContext); - } - catch(FacesException e) - { - Assertions.fail("No exception expected"); - } + }, "No exception expected"); request.setAttribute("bean", bean); } @@ -476,7 +448,7 @@ public void invokeContextCallback(FacesContext context, UIComponent target) Throwable e = eqe.getContext().getException(); if (e instanceof AbortProcessingException) { - Assertions.fail("Unexpected exception queued"); + fail("Unexpected exception queued"); } else { @@ -484,7 +456,7 @@ public void invokeContextCallback(FacesContext context, UIComponent target) i++; } } - Assertions.assertEquals(1, i); + assertEquals(1, i); } public static class CustomValidator implements Validator diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguageTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguageTest.java index 25326b298a..132b281171 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguageTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguageTest.java @@ -18,8 +18,9 @@ */ package org.apache.myfaces.view.facelets; +import static org.junit.jupiter.api.Assertions.*; + import java.util.Locale; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import jakarta.faces.component.UIComponent; @@ -34,14 +35,14 @@ * * @author Jakob Korherr */ -public class FaceletViewDeclarationLanguageTest extends AbstractFaceletTestCase +class FaceletViewDeclarationLanguageTest extends AbstractFaceletTestCase { /** * Test case for MYFACES-3002. */ @Test - public void testBuildViewUIViewParameters() throws Exception + void buildViewUIViewParameters() throws Exception { // build a UIViewRoot with a UIViewParameter ViewMetadata viewMetadata = this.vdl.getViewMetadata(facesContext, "viewparameter1.xhtml"); @@ -63,16 +64,16 @@ private void checkUIViewParameter(UIViewRoot root) { // the metadata facet MUST be there UIComponent metadataFacet = root.getFacet(UIViewRoot.METADATA_FACET_NAME); - Assertions.assertNotNull(metadataFacet); - Assertions.assertTrue(metadataFacet instanceof UIPanel); // the metadata-facet must be a UIPanel + assertNotNull(metadataFacet); + assertInstanceOf(UIPanel.class, metadataFacet); // the metadata-facet must be a UIPanel // get the UIViewParameter UIComponent viewParameter = metadataFacet.getChildren().get(0); - Assertions.assertTrue(viewParameter instanceof UIViewParameter); + assertInstanceOf(UIViewParameter.class, viewParameter); } @Test - public void testBuildViewUIViewParametersLocale() throws Exception + void buildViewUIViewParametersLocale() throws Exception { request.setAttribute("viewBean", new ViewBean()); @@ -84,7 +85,7 @@ public void testBuildViewUIViewParametersLocale() throws Exception // UIViewParameter must be there checkUIViewParameter(root); - Assertions.assertEquals(Locale.FRANCE, root.getLocale()); + assertEquals(Locale.FRANCE, root.getLocale()); // build and render view (must not remove UIViewParameter) vdl.buildView(facesContext, root, "viewparameter2.xhtml"); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/ImportConstantsMetadataTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/ImportConstantsMetadataTest.java index 099aaeda8d..a071824480 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/ImportConstantsMetadataTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/ImportConstantsMetadataTest.java @@ -18,18 +18,19 @@ */ package org.apache.myfaces.view.facelets; +import static org.junit.jupiter.api.Assertions.assertTrue; + import jakarta.faces.component.UIViewRoot; import jakarta.faces.context.ResponseWriter; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.test.mock.MockPrintWriter; import org.apache.myfaces.util.lang.FastWriter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class ImportConstantsMetadataTest extends AbstractMyFacesCDIRequestTestCase +class ImportConstantsMetadataTest extends AbstractMyFacesCDIRequestTestCase { @Test - public void test() throws Exception + void test() throws Exception { startViewRequest("/importConstantsMetadata.xhtml"); processLifecycleExecuteAndRender(); @@ -37,6 +38,6 @@ public void test() throws Exception MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content = new String(writer1.content()); - Assertions.assertTrue(content.contains("Value:a!")); + assertTrue(content.contains("Value:a!")); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/ImportConstantsTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/ImportConstantsTest.java index bddfd5193e..e6f962071f 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/ImportConstantsTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/ImportConstantsTest.java @@ -20,13 +20,15 @@ import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.test.mock.MockPrintWriter; -import org.junit.jupiter.api.Assertions; + import org.junit.jupiter.api.Test; -public class ImportConstantsTest extends AbstractMyFacesCDIRequestTestCase +import static org.junit.jupiter.api.Assertions.assertTrue; + +class ImportConstantsTest extends AbstractMyFacesCDIRequestTestCase { @Test - public void test() throws Exception + void test() throws Exception { startViewRequest("/importConstants.xhtml"); processLifecycleExecuteAndRender(); @@ -34,6 +36,6 @@ public void test() throws Exception MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content = new String(writer1.content()); - Assertions.assertTrue(content.contains("Value:a!")); + assertTrue(content.contains("Value:a!")); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/InstructionsTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/InstructionsTestCase.java index 08d1ea8201..ea3838df73 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/InstructionsTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/InstructionsTestCase.java @@ -25,7 +25,7 @@ import org.apache.myfaces.util.lang.FastWriter; import org.junit.jupiter.api.Test; -public class InstructionsTestCase extends AbstractFaceletTestCase +class InstructionsTestCase extends AbstractFaceletTestCase { @Override @@ -46,7 +46,7 @@ protected void setupRenderers() throws Exception } @Test - public void testInstructions() throws Exception + void instructions() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "instructions.xhtml"); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/PartialStateManagementStrategyTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/PartialStateManagementStrategyTest.java index 0d5f040e0c..cd64894439 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/PartialStateManagementStrategyTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/PartialStateManagementStrategyTest.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.view.facelets; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import java.beans.BeanInfo; import java.io.IOException; import java.util.Iterator; @@ -50,7 +53,6 @@ import org.apache.myfaces.test.mock.MockRenderKit; import org.apache.myfaces.view.ViewMetadataBase; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -143,7 +145,7 @@ protected void setFactories() throws Exception } @Test - public void testSimpleSaveRestore() throws Exception + void simpleSaveRestore() throws Exception { ViewDeclarationLanguage vdl =((MockViewDeclarationLanguageFactory)FactoryFinder.getFactory(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY)).vdl; PartialStateManagementStrategy stateManagement = new PartialStateManagementStrategy(); @@ -163,15 +165,15 @@ public void testSimpleSaveRestore() throws Exception viewRoot = facesContext.getViewRoot(); - Assertions.assertEquals("somevalue", viewRoot.getAttributes().get("somekey")); - Assertions.assertNotNull(viewRoot.findComponent("form1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:foo1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:var1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:button1")); + assertEquals("somevalue", viewRoot.getAttributes().get("somekey")); + assertNotNull(viewRoot.findComponent("form1")); + assertNotNull(viewRoot.findComponent("form1:foo1")); + assertNotNull(viewRoot.findComponent("form1:var1")); + assertNotNull(viewRoot.findComponent("form1:button1")); } - + @Test - public void testSaveRestoreAddComponent() throws Exception + void saveRestoreAddComponent() throws Exception { ViewDeclarationLanguage vdl =((MockViewDeclarationLanguageFactory)FactoryFinder.getFactory(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY)).vdl; PartialStateManagementStrategy stateManagement = new PartialStateManagementStrategy(); @@ -198,19 +200,19 @@ public void testSaveRestoreAddComponent() throws Exception viewRoot = facesContext.getViewRoot(); - Assertions.assertEquals("somevalue", viewRoot.getAttributes().get("somekey")); - Assertions.assertNotNull(viewRoot.findComponent("form1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:foo1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:var1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:button1")); + assertEquals("somevalue", viewRoot.getAttributes().get("somekey")); + assertNotNull(viewRoot.findComponent("form1")); + assertNotNull(viewRoot.findComponent("form1:foo1")); + assertNotNull(viewRoot.findComponent("form1:var1")); + assertNotNull(viewRoot.findComponent("form1:button1")); a = (HtmlOutputText) viewRoot.findComponent("output1"); - Assertions.assertNotNull(a); - Assertions.assertEquals("testOutput1",a.getValue()); + assertNotNull(a); + assertEquals("testOutput1",a.getValue()); } - + @Test - public void testSaveRestoreAddComponentMultiplePostback() throws Exception + void saveRestoreAddComponentMultiplePostback() throws Exception { ViewDeclarationLanguage vdl =((MockViewDeclarationLanguageFactory)FactoryFinder.getFactory(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY)).vdl; PartialStateManagementStrategy stateManagement = new PartialStateManagementStrategy(); @@ -257,28 +259,28 @@ public void testSaveRestoreAddComponentMultiplePostback() throws Exception viewRoot = saveAndRestore(stateManagement, viewRoot); - Assertions.assertEquals("somevalue", viewRoot.getAttributes().get("somekey")); - Assertions.assertNotNull(viewRoot.findComponent("form1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:foo1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:var1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:button1")); + assertEquals("somevalue", viewRoot.getAttributes().get("somekey")); + assertNotNull(viewRoot.findComponent("form1")); + assertNotNull(viewRoot.findComponent("form1:foo1")); + assertNotNull(viewRoot.findComponent("form1:var1")); + assertNotNull(viewRoot.findComponent("form1:button1")); a = (HtmlOutputText) viewRoot.findComponent("output1"); - Assertions.assertNotNull(a); - Assertions.assertEquals("testOutput1",a.getValue()); + assertNotNull(a); + assertEquals("testOutput1",a.getValue()); b = (HtmlOutputText) viewRoot.findComponent("output2"); - Assertions.assertNotNull(b); - Assertions.assertEquals("testOutput2",b.getValue()); + assertNotNull(b); + assertEquals("testOutput2",b.getValue()); c = (HtmlOutputText) viewRoot.findComponent("output3"); - Assertions.assertNotNull(c); - Assertions.assertEquals("testOutput3",c.getValue()); + assertNotNull(c); + assertEquals("testOutput3",c.getValue()); d = (HtmlOutputText) viewRoot.findComponent("output4"); - Assertions.assertNotNull(d); - Assertions.assertEquals("testOutput4",d.getValue()); + assertNotNull(d); + assertEquals("testOutput4",d.getValue()); } - + @Test - public void testSaveRestoreToogleComponent() throws Exception + void saveRestoreToogleComponent() throws Exception { ViewDeclarationLanguage vdl =((MockViewDeclarationLanguageFactory)FactoryFinder.getFactory(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY)).vdl; PartialStateManagementStrategy stateManagement = new PartialStateManagementStrategy(); @@ -299,54 +301,54 @@ public void testSaveRestoreToogleComponent() throws Exception viewRoot = saveAndRestore(stateManagement, viewRoot); - Assertions.assertEquals("form1",viewRoot.getChildren().get(0).getId()); - Assertions.assertEquals("output1",viewRoot.getChildren().get(1).getId()); + assertEquals("form1",viewRoot.getChildren().get(0).getId()); + assertEquals("output1",viewRoot.getChildren().get(1).getId()); UIComponent component = viewRoot.getChildren().remove( 0 ); viewRoot.getChildren().add( component ); viewRoot = saveAndRestore(stateManagement, viewRoot); - Assertions.assertEquals("output1",viewRoot.getChildren().get(0).getId()); - Assertions.assertEquals("form1",viewRoot.getChildren().get(1).getId()); + assertEquals("output1",viewRoot.getChildren().get(0).getId()); + assertEquals("form1",viewRoot.getChildren().get(1).getId()); component = viewRoot.getChildren().remove( 0 ); viewRoot.getChildren().add( component ); viewRoot = saveAndRestore(stateManagement, viewRoot); - Assertions.assertEquals("form1",viewRoot.getChildren().get(0).getId()); - Assertions.assertEquals("output1",viewRoot.getChildren().get(1).getId()); + assertEquals("form1",viewRoot.getChildren().get(0).getId()); + assertEquals("output1",viewRoot.getChildren().get(1).getId()); component = viewRoot.getChildren().remove( 0 ); viewRoot.getChildren().add( component ); viewRoot = saveAndRestore(stateManagement, viewRoot); - Assertions.assertEquals("output1",viewRoot.getChildren().get(0).getId()); - Assertions.assertEquals("form1",viewRoot.getChildren().get(1).getId()); + assertEquals("output1",viewRoot.getChildren().get(0).getId()); + assertEquals("form1",viewRoot.getChildren().get(1).getId()); component = viewRoot.getChildren().remove( 0 ); viewRoot.getChildren().add( component ); viewRoot = saveAndRestore(stateManagement, viewRoot); - Assertions.assertEquals("form1",viewRoot.getChildren().get(0).getId()); - Assertions.assertEquals("output1",viewRoot.getChildren().get(1).getId()); + assertEquals("form1",viewRoot.getChildren().get(0).getId()); + assertEquals("output1",viewRoot.getChildren().get(1).getId()); - Assertions.assertEquals("somevalue", viewRoot.getAttributes().get("somekey")); - Assertions.assertNotNull(viewRoot.findComponent("form1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:foo1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:var1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:button1")); + assertEquals("somevalue", viewRoot.getAttributes().get("somekey")); + assertNotNull(viewRoot.findComponent("form1")); + assertNotNull(viewRoot.findComponent("form1:foo1")); + assertNotNull(viewRoot.findComponent("form1:var1")); + assertNotNull(viewRoot.findComponent("form1:button1")); a = (HtmlOutputText) viewRoot.findComponent("output1"); - Assertions.assertNotNull(a); - Assertions.assertEquals("testOutput1",a.getValue()); + assertNotNull(a); + assertEquals("testOutput1",a.getValue()); } - + @Test - public void testSaveRestoreToogleComponent2() throws Exception + void saveRestoreToogleComponent2() throws Exception { ViewDeclarationLanguage vdl =((MockViewDeclarationLanguageFactory)FactoryFinder.getFactory(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY)).vdl; PartialStateManagementStrategy stateManagement = new PartialStateManagementStrategy(); @@ -371,55 +373,55 @@ public void testSaveRestoreToogleComponent2() throws Exception viewRoot = saveAndRestore(stateManagement, viewRoot); - Assertions.assertEquals("form1",viewRoot.getChildren().get(0).getId()); - Assertions.assertEquals("output1",viewRoot.getChildren().get(1).getId()); - Assertions.assertEquals("output2",viewRoot.getChildren().get(2).getId()); + assertEquals("form1",viewRoot.getChildren().get(0).getId()); + assertEquals("output1",viewRoot.getChildren().get(1).getId()); + assertEquals("output2",viewRoot.getChildren().get(2).getId()); UIComponent component = viewRoot.getChildren().remove( 0 ); viewRoot.getChildren().add( component ); viewRoot = saveAndRestore(stateManagement, viewRoot); - Assertions.assertEquals("output1",viewRoot.getChildren().get(0).getId()); - Assertions.assertEquals("output2",viewRoot.getChildren().get(1).getId()); - Assertions.assertEquals("form1",viewRoot.getChildren().get(2).getId()); + assertEquals("output1",viewRoot.getChildren().get(0).getId()); + assertEquals("output2",viewRoot.getChildren().get(1).getId()); + assertEquals("form1",viewRoot.getChildren().get(2).getId()); component = viewRoot.getChildren().remove( 0 ); viewRoot.getChildren().add( component ); viewRoot = saveAndRestore(stateManagement, viewRoot); - Assertions.assertEquals("output2",viewRoot.getChildren().get(0).getId()); - Assertions.assertEquals("form1",viewRoot.getChildren().get(1).getId()); - Assertions.assertEquals("output1",viewRoot.getChildren().get(2).getId()); + assertEquals("output2",viewRoot.getChildren().get(0).getId()); + assertEquals("form1",viewRoot.getChildren().get(1).getId()); + assertEquals("output1",viewRoot.getChildren().get(2).getId()); component = viewRoot.getChildren().remove( 0 ); viewRoot.getChildren().add( component ); viewRoot = saveAndRestore(stateManagement, viewRoot); - Assertions.assertEquals("form1",viewRoot.getChildren().get(0).getId()); - Assertions.assertEquals("output1",viewRoot.getChildren().get(1).getId()); - Assertions.assertEquals("output2",viewRoot.getChildren().get(2).getId()); + assertEquals("form1",viewRoot.getChildren().get(0).getId()); + assertEquals("output1",viewRoot.getChildren().get(1).getId()); + assertEquals("output2",viewRoot.getChildren().get(2).getId()); component = viewRoot.getChildren().remove( 0 ); viewRoot.getChildren().add( component ); viewRoot = saveAndRestore(stateManagement, viewRoot); - Assertions.assertEquals("output1",viewRoot.getChildren().get(0).getId()); - Assertions.assertEquals("output2",viewRoot.getChildren().get(1).getId()); - Assertions.assertEquals("form1",viewRoot.getChildren().get(2).getId()); + assertEquals("output1",viewRoot.getChildren().get(0).getId()); + assertEquals("output2",viewRoot.getChildren().get(1).getId()); + assertEquals("form1",viewRoot.getChildren().get(2).getId()); - Assertions.assertEquals("somevalue", viewRoot.getAttributes().get("somekey")); - Assertions.assertNotNull(viewRoot.findComponent("form1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:foo1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:var1")); - Assertions.assertNotNull(viewRoot.findComponent("form1:button1")); + assertEquals("somevalue", viewRoot.getAttributes().get("somekey")); + assertNotNull(viewRoot.findComponent("form1")); + assertNotNull(viewRoot.findComponent("form1:foo1")); + assertNotNull(viewRoot.findComponent("form1:var1")); + assertNotNull(viewRoot.findComponent("form1:button1")); a = (HtmlOutputText) viewRoot.findComponent("output1"); - Assertions.assertNotNull(a); - Assertions.assertEquals("testOutput1",a.getValue()); + assertNotNull(a); + assertEquals("testOutput1",a.getValue()); } public UIViewRoot saveAndRestore(StateManagementStrategy stateManagement, UIViewRoot viewRoot) diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/StateManagerWithFaceletsClientSideTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/StateManagerWithFaceletsClientSideTest.java index c7d3c89d7d..89550ac400 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/StateManagerWithFaceletsClientSideTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/StateManagerWithFaceletsClientSideTest.java @@ -42,15 +42,15 @@ protected void setUpServletContextAndSession() throws Exception } @Override - public void testWriteAndRestoreState() throws Exception + void writeAndRestoreState() throws Exception { - super.testWriteAndRestoreState(); + super.writeAndRestoreState(); } @Override - public void testWriteAndRestoreStateWithMyFacesRSM() throws Exception + void writeAndRestoreStateWithMyFacesRSM() throws Exception { - super.testWriteAndRestoreStateWithMyFacesRSM(); + super.writeAndRestoreStateWithMyFacesRSM(); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/StateManagerWithFaceletsTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/StateManagerWithFaceletsTest.java index d2e8322923..406daeac11 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/StateManagerWithFaceletsTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/StateManagerWithFaceletsTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import jakarta.faces.application.StateManager; import jakarta.faces.application.ViewHandler; import jakarta.faces.component.UIViewRoot; @@ -32,7 +34,6 @@ import org.apache.myfaces.spi.impl.DefaultSerialFactory; import org.apache.myfaces.test.mock.MockFacesContext20; import org.apache.myfaces.test.mock.MockRenderKit; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class StateManagerWithFaceletsTest extends AbstractFaceletMultipleRequestsTestCase @@ -55,7 +56,7 @@ protected void setUpServletContextAndSession() throws Exception } @Test - public void testWriteAndRestoreState() throws Exception + void writeAndRestoreState() throws Exception { String viewId = "/simpleTree.xhtml"; @@ -95,16 +96,16 @@ public void testWriteAndRestoreState() throws Exception UIViewRoot restoredViewRoot = sms.restoreView(facesContext, viewId, RenderKitFactory.HTML_BASIC_RENDER_KIT); - Assertions.assertNotNull(restoredViewRoot); + assertNotNull(restoredViewRoot); } finally { tearDownRequest(); } } - + @Test - public void testWriteAndRestoreStateWithMyFacesRSM() throws Exception + void writeAndRestoreStateWithMyFacesRSM() throws Exception { String viewId = "/simpleTree.xhtml"; String viewStateParam = null; @@ -148,7 +149,7 @@ public void testWriteAndRestoreStateWithMyFacesRSM() throws Exception UIViewRoot restoredViewRoot = sms.restoreView(facesContext, viewId, RenderKitFactory.HTML_BASIC_RENDER_KIT); - Assertions.assertNotNull(restoredViewRoot); + assertNotNull(restoredViewRoot); } finally { diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/TagTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/TagTestCase.java index e331b7776b..6c9460de39 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/TagTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/TagTestCase.java @@ -28,7 +28,7 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.junit.jupiter.api.Test; -public class TagTestCase extends AbstractFaceletTestCase { +class TagTestCase extends AbstractFaceletTestCase { @Override protected void setupComponents() throws Exception @@ -51,9 +51,9 @@ protected void setupRenderers() throws Exception renderKit.addRenderer(UIOutput.COMPONENT_FAMILY, "jakarta.faces.Text", new HtmlTextRenderer()); } - + @Test - public void testTagBody() throws Exception { + void tagBody() throws Exception { request.setAttribute("name", "Mr. Hookom"); UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root,"userTag.xhtml"); @@ -65,7 +65,7 @@ public void testTagBody() throws Exception { } @Test - public void testConditionalInsert() throws Exception { + void conditionalInsert() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root,"userTagConditional.xhtml"); FastWriter fw = new FastWriter(); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/TemplateClientTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/TemplateClientTestCase.java index 530c8abf13..6bd0043f74 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/TemplateClientTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/TemplateClientTestCase.java @@ -24,7 +24,7 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.junit.jupiter.api.Test; -public class TemplateClientTestCase extends AbstractFaceletTestCase { +class TemplateClientTestCase extends AbstractFaceletTestCase { @Override protected void setupComponents() throws Exception @@ -42,9 +42,9 @@ protected void setupConvertersAndValidators() throws Exception protected void setupRenderers() throws Exception { } - + @Test - public void testClientClient() throws Exception { + void clientClient() throws Exception { request.setAttribute("name", "Mr. Hookom"); UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root,"template-client-client.xhtml"); @@ -54,9 +54,9 @@ public void testClientClient() throws Exception { root.encodeAll(facesContext); //System.out.println(fw); } - + @Test - public void testLayoutClient() throws Exception + void layoutClient() throws Exception { request.setAttribute("name", "Mr. Hookom"); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/TemplateInResourcesDirTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/TemplateInResourcesDirTestCase.java index 707edf9b1c..cc63fac2f8 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/TemplateInResourcesDirTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/TemplateInResourcesDirTestCase.java @@ -18,11 +18,12 @@ */ package org.apache.myfaces.view.facelets; +import static org.junit.jupiter.api.Assertions.assertTrue; + import jakarta.el.ExpressionFactory; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.test.core.AbstractMyFacesRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -31,7 +32,7 @@ * @author Jay Sartoris */ -public class TemplateInResourcesDirTestCase extends AbstractMyFacesCDIRequestTestCase +class TemplateInResourcesDirTestCase extends AbstractMyFacesCDIRequestTestCase { @Override protected void setUpWebConfigParams() throws Exception @@ -43,16 +44,16 @@ protected void setUpWebConfigParams() throws Exception protected ExpressionFactory createExpressionFactory() { return new org.apache.el.ExpressionFactoryImpl(); - } - + } + @Test - public void testFaceletWithTemplateInResourcesDir() throws Exception + void faceletWithTemplateInResourcesDir() throws Exception { startViewRequest("/templateInResourcesDir.xhtml"); processLifecycleExecuteAndRender(); String text = getRenderedContent(facesContext); - Assertions.assertTrue(text.contains("This template is working as expected!")); + assertTrue(text.contains("This template is working as expected!")); endRequest(); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/CompressSpacesTextUnitTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/CompressSpacesTextUnitTestCase.java index f5350b3722..d65b598aed 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/CompressSpacesTextUnitTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/CompressSpacesTextUnitTestCase.java @@ -18,12 +18,13 @@ */ package org.apache.myfaces.view.facelets.compiler; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.ArrayList; import java.util.List; import jakarta.faces.context.ResponseWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; import org.apache.myfaces.util.lang.FastWriter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -32,9 +33,9 @@ */ public class CompressSpacesTextUnitTestCase extends AbstractFaceletTestCase { - + @Test - public void testSimpleCompress1() throws Exception { + void simpleCompress1() throws Exception { List instructions = new ArrayList(); @@ -61,12 +62,12 @@ public void testSimpleCompress1() throws Exception { { i.write(facesContext); } - - Assertions.assertEquals(fw.toString(), "

hello

"); + + assertEquals("

hello

", fw.toString()); } @Test - public void testSimpleCompress2() throws Exception { + void simpleCompress2() throws Exception { List instructions = new ArrayList(); @@ -86,13 +87,13 @@ public void testSimpleCompress2() throws Exception { { i.write(facesContext); } - - Assertions.assertEquals(fw.toString(), "

hello

"); + + assertEquals("

hello

", fw.toString()); } @Test - public void testSimpleCompress3() throws Exception { + void simpleCompress3() throws Exception { List instructions = new ArrayList(); @@ -119,12 +120,12 @@ public void testSimpleCompress3() throws Exception { { i.write(facesContext); } - - Assertions.assertEquals(fw.toString(), "

hello

\n"); + + assertEquals("

hello

\n", fw.toString()); } - + @Test - public void testSimpleCompress4() throws Exception { + void simpleCompress4() throws Exception { List instructions = new ArrayList(); @@ -142,13 +143,13 @@ public void testSimpleCompress4() throws Exception { { i.write(facesContext); } - - Assertions.assertEquals(fw.toString(), "\n"); + + assertEquals("\n", fw.toString()); } @Test - public void testSimpleCompress4_1() throws Exception { + void simpleCompress41() throws Exception { List instructions = new ArrayList(); @@ -166,13 +167,13 @@ public void testSimpleCompress4_1() throws Exception { { i.write(facesContext); } - - Assertions.assertEquals(fw.toString(), "\r\n"); - } - + assertEquals("\r\n", fw.toString()); + + } + @Test - public void testSimpleCompress5() throws Exception { + void simpleCompress5() throws Exception { List instructions = new ArrayList(); @@ -190,13 +191,13 @@ public void testSimpleCompress5() throws Exception { { i.write(facesContext); } - - Assertions.assertEquals(fw.toString(), "&#160;\n"); + + assertEquals("&#160;\n", fw.toString()); } - + @Test - public void testSimpleCompress6() throws Exception { + void simpleCompress6() throws Exception { List instructions = new ArrayList(); @@ -224,20 +225,20 @@ public void testSimpleCompress6() throws Exception { i.write(facesContext); } - Assertions.assertEquals(fw.toString(), "\r\n "); } @Test - public void testCompressOnELExpressions() throws Exception + void compressOnELExpressions() throws Exception { - Assertions.assertEquals(tryCompress("#{bean.name}"), "#{bean.name}"); - Assertions.assertEquals(tryCompress(" #{bean.name}"), " #{bean.name}"); - Assertions.assertEquals(tryCompress("#{bean.name} "), "#{bean.name} "); + assertEquals("#{bean.name}", tryCompress("#{bean.name}")); + assertEquals(" #{bean.name}", tryCompress(" #{bean.name}")); + assertEquals("#{bean.name} ", tryCompress("#{bean.name} ")); String text = tryCompress(" #{bean.name} "); - Assertions.assertEquals(tryCompress(" #{bean.name} "), " #{bean.name} "); - Assertions.assertEquals(tryCompress("\n #{bean.name}\n "), "\n#{bean.name}\n"); - Assertions.assertEquals(tryCompress(" \r\n #{bean.name} \r\n "), "\r\n#{bean.name} "); + assertEquals(" #{bean.name} ", tryCompress(" #{bean.name} ")); + assertEquals("\n#{bean.name}\n", tryCompress("\n #{bean.name}\n ")); + assertEquals("\r\n#{bean.name} ", tryCompress(" \r\n #{bean.name} \r\n ")); } public String tryCompress(String value) diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/DynamicComponentFaceletTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/DynamicComponentFaceletTestCase.java index a3f1f305e2..0bbdf1398d 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/DynamicComponentFaceletTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/DynamicComponentFaceletTestCase.java @@ -29,11 +29,11 @@ * * @author lu4242 */ -public class DynamicComponentFaceletTestCase extends AbstractFaceletTestCase +class DynamicComponentFaceletTestCase extends AbstractFaceletTestCase { - + @Test - public void testCompileComponentHandler() throws Exception + void compileComponentHandler() throws Exception { Map attributes = new HashMap(); attributes.put("value", "hello"); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/ELParserTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/ELParserTestCase.java index fef1ba66b8..b1f4f2c592 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/ELParserTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/ELParserTestCase.java @@ -54,10 +54,10 @@ protected void setupRenderers() throws Exception { renderKit.addRenderer(UIOutput.COMPONENT_FAMILY, "jakarta.faces.Text", new HtmlTextRenderer()); - } - + } + @Test - public void testSelectOneMenu() throws Exception { + void selectOneMenu() throws Exception { request.setAttribute("test", this); UIViewRoot root = facesContext.getViewRoot(); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/HTML5FaceletsProcessingTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/HTML5FaceletsProcessingTestCase.java index cce44c4efc..5e5a61e280 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/HTML5FaceletsProcessingTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/HTML5FaceletsProcessingTestCase.java @@ -19,6 +19,8 @@ package org.apache.myfaces.view.facelets.compiler; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import jakarta.faces.component.UIForm; @@ -32,8 +34,6 @@ import jakarta.faces.component.html.HtmlPanelGrid; import jakarta.faces.component.html.HtmlSelectOneMenu; -import org.junit.jupiter.api.Assertions; - import org.apache.myfaces.renderkit.html.HtmlFormRenderer; import org.apache.myfaces.renderkit.html.HtmlGridRenderer; import org.apache.myfaces.renderkit.html.HtmlMenuRenderer; @@ -42,7 +42,7 @@ import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; import org.junit.jupiter.api.Test; -public class HTML5FaceletsProcessingTestCase extends AbstractFaceletTestCase { +class HTML5FaceletsProcessingTestCase extends AbstractFaceletTestCase { @Override protected void setupComponents() throws Exception @@ -91,7 +91,7 @@ protected void setUpExternalContext() throws Exception } @Test - public void testXHTMLProcessing1() throws Exception + void xhtmlProcessing1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testXHTMLProcessing1.xhtml"); @@ -106,13 +106,13 @@ public void testXHTMLProcessing1() throws Exception String resp = sw.toString(); - Assertions.assertTrue(resp.contains("")); - Assertions.assertTrue(resp.contains("")); + assertTrue(resp.contains("")); - Assertions.assertTrue(resp.contains("")); + assertTrue(resp.contains(" as HTML5 is default - Assertions.assertEquals(null, ((AbstractFacelet) f).getDoctype().getPublic()); - Assertions.assertEquals(null, ((AbstractFacelet) f).getDoctype().getSystem()); + assertNull(((AbstractFacelet) f).getDoctype().getPublic()); + assertNull(((AbstractFacelet) f).getDoctype().getSystem()); } - + @Test - public void testHtml5() throws Exception + void html5() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "html5.xhtml"); - Assertions.assertNotNull(root.getDoctype()); - Assertions.assertEquals("html", root.getDoctype().getRootElement()); - Assertions.assertEquals(null, root.getDoctype().getPublic()); - Assertions.assertEquals(null, root.getDoctype().getSystem()); + assertNotNull(root.getDoctype()); + assertEquals("html", root.getDoctype().getRootElement()); + assertNull(root.getDoctype().getPublic()); + assertNull(root.getDoctype().getSystem()); } - + @Test - public void testXhtml() throws Exception + void xhtml() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "xhtml.xhtml"); - Assertions.assertNotNull(root.getDoctype()); - Assertions.assertEquals("html", root.getDoctype().getRootElement()); + assertNotNull(root.getDoctype()); + assertEquals("html", root.getDoctype().getRootElement()); // MYFACES-4681 - Simplified to as HTML5 is default - Assertions.assertEquals(null, root.getDoctype().getPublic()); - Assertions.assertEquals(null, root.getDoctype().getSystem()); + assertNull(root.getDoctype().getPublic()); + assertNull(root.getDoctype().getSystem()); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/component/UIRepeatResetSaveStateModeTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/component/UIRepeatResetSaveStateModeTest.java index 2a8f742efe..4ab331eb6d 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/component/UIRepeatResetSaveStateModeTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/component/UIRepeatResetSaveStateModeTest.java @@ -18,11 +18,13 @@ */ package org.apache.myfaces.view.facelets.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Map; import jakarta.faces.event.PhaseId; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.apache.myfaces.view.facelets.ViewPoolProcessor; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -31,7 +33,7 @@ * the delta state, a hard reset clears all state (see {@link ViewPoolProcessor#RESET_MODE_SOFT} and * {@link ViewPoolProcessor#RESET_MODE_HARD}). UIRepeat must do the same as UIData with its per-row state. */ -public class UIRepeatResetSaveStateModeTest extends AbstractFacesTestCase +class UIRepeatResetSaveStateModeTest extends AbstractFacesTestCase { private UIRepeat repeat; @@ -50,24 +52,24 @@ public void setUp() throws Exception } @Test - public void testSoftResetKeepsDeltaState() + void softResetKeepsDeltaState() { facesContext.getViewRoot().getAttributes().put(ViewPoolProcessor.RESET_SAVE_STATE_MODE_KEY, ViewPoolProcessor.RESET_MODE_SOFT); repeat.saveState(facesContext); - Assertions.assertEquals(Map.of("repeat:0:in", "delta"), repeat._rowDeltaStates.get("repeat:0")); - Assertions.assertTrue(repeat._rowTransientStates.isEmpty()); + assertEquals(Map.of("repeat:0:in", "delta"), repeat._rowDeltaStates.get("repeat:0")); + assertTrue(repeat._rowTransientStates.isEmpty()); } @Test - public void testHardResetClearsAllState() + void hardResetClearsAllState() { facesContext.getViewRoot().getAttributes().put(ViewPoolProcessor.RESET_SAVE_STATE_MODE_KEY, ViewPoolProcessor.RESET_MODE_HARD); repeat.saveState(facesContext); - Assertions.assertTrue(repeat._rowDeltaStates.isEmpty()); - Assertions.assertTrue(repeat._rowTransientStates.isEmpty()); + assertTrue(repeat._rowDeltaStates.isEmpty()); + assertTrue(repeat._rowTransientStates.isEmpty()); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/component/UIRepeatTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/component/UIRepeatTest.java index 4388644cb1..a4299f5a26 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/component/UIRepeatTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/component/UIRepeatTest.java @@ -25,11 +25,13 @@ import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; import org.easymock.classextension.EasyMock; import org.easymock.classextension.IMocksControl; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; + +import static org.junit.jupiter.api.Assertions.*; + import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -62,7 +64,7 @@ public void setUp() throws Exception * {@link jakarta.faces.component.UIData#setValueExpression(java.lang.String, jakarta.el.ValueExpression)}. */ @Test - public void testValueExpression() + void valueExpression() { assertSetValueExpressionException(IllegalArgumentException.class, "rowIndex"); assertSetValueExpressionException(NullPointerException.class, null); @@ -70,7 +72,7 @@ public void testValueExpression() private void assertSetValueExpressionException(Class expected, final String name) { - Assertions.assertThrows(expected, + assertThrows(expected, () -> _testImpl.setValueExpression(name, null)); } @@ -79,7 +81,7 @@ private void assertSetValueExpressionException(Class expect * Adapted to use UIRepeat with rowStatePreserved */ @Test - public void testPreserveRowComponentState() throws Exception + void preserveRowComponentState() throws Exception { List model = new ArrayList(); model.add(new RowData("text1","style1")); @@ -128,7 +130,7 @@ public void testPreserveRowComponentState() throws Exception { RowData rowData = model.get(i); table.setRowIndex(i); - Assertions.assertEquals(rowData.getText(), text.getValue()); + assertEquals(rowData.getText(), text.getValue()); text.getAttributes().put("style", rowData.getStyle()); } @@ -139,7 +141,7 @@ public void testPreserveRowComponentState() throws Exception for (int i = 0; i < model.size(); i++) { table.setRowIndex(i); - Assertions.assertEquals(model.get(i).getStyle(), text.getAttributes().get("style")); + assertEquals(model.get(i).getStyle(), text.getAttributes().get("style")); } } @@ -156,7 +158,7 @@ public void testPreserveRowComponentState() throws Exception * @throws Exception */ @Test - public void testSaveAndRestorePortletLifecycleWithoutPss1() throws Exception + void saveAndRestorePortletLifecycleWithoutPss1() throws Exception { List model = new ArrayList(); model.add(new RowData("text1","style1")); @@ -180,7 +182,7 @@ public void testSaveAndRestorePortletLifecycleWithoutPss1() throws Exception { RowData rowData = model.get(i); table.setRowIndex(i); - Assertions.assertEquals(rowData.getText(), text.getValue()); + assertEquals(rowData.getText(), text.getValue()); text.setSubmittedValue("value"+(i+1)); //text.getAttributes().put("style", rowData.getStyle()); } @@ -219,11 +221,11 @@ public void testSaveAndRestorePortletLifecycleWithoutPss1() throws Exception { RowData rowData = model.get(i); table.setRowIndex(i); - Assertions.assertEquals("value"+(i+1), text.getSubmittedValue()); + assertEquals("value"+(i+1), text.getSubmittedValue()); //assertEquals(model.get(i).getStyle(), text.getAttributes().get("style")); } } - + /** * A UIRepeat nested inside another UIRepeat keeps its per-row state per enclosing row: the inner repeat's row 0 * in outer row 0 is a different cell from the inner repeat's row 0 in outer row 1. Keying the inner repeat's @@ -231,7 +233,7 @@ public void testSaveAndRestorePortletLifecycleWithoutPss1() throws Exception * submitted values of every enclosing row but the last. */ @Test - public void testNestedRepeatRowStateIsScopedPerOuterRow() + void nestedRepeatRowStateIsScopedPerOuterRow() { UIViewRoot root = facesContext.getViewRoot(); root.setId(root.createUniqueId()); @@ -273,7 +275,7 @@ public void testNestedRepeatRowStateIsScopedPerOuterRow() for (int innerRow = 0; innerRow < 2; innerRow++) { inner.setRowIndex(innerRow); - Assertions.assertEquals("v" + outerRow + innerRow, input.getSubmittedValue(), + assertEquals("v" + outerRow + innerRow, input.getSubmittedValue(), "outer row " + outerRow + ", inner row " + innerRow + " must keep the value submitted into it"); } @@ -331,7 +333,7 @@ private void createSimpleTable(UIViewRoot root) * This exercises {@code saveChildStates} / {@code restoreChildStates}. */ @Test - public void testStatefulRowStateIsPreservedOnRevisit() + void statefulRowStateIsPreservedOnRevisit() { UIViewRoot root = facesContext.getViewRoot(); UIRepeat repeat = createRepeat(root, Arrays.asList("a", "b", "c")); @@ -354,7 +356,7 @@ public void testStatefulRowStateIsPreservedOnRevisit() for (int i = 0; i < 3; i++) { repeat.setRowIndex(i); - Assertions.assertEquals("submitted_" + i, input.getSubmittedValue(), + assertEquals("submitted_" + i, input.getSubmittedValue(), "Row " + i + ": submitted value should be restored from Integer row-index-keyed _rowStates"); } repeat.setRowIndex(-1); @@ -365,7 +367,7 @@ public void testStatefulRowStateIsPreservedOnRevisit() * components to their initial (empty) state. */ @Test - public void testStatefulResetToInitialStateAtIndexMinusOne() + void statefulResetToInitialStateAtIndexMinusOne() { UIViewRoot root = facesContext.getViewRoot(); UIRepeat repeat = createRepeat(root, Arrays.asList("a", "b")); @@ -383,9 +385,9 @@ public void testStatefulResetToInitialStateAtIndexMinusOne() // Reset to -1: components must be in their clean template state. repeat.setRowIndex(-1); - Assertions.assertNull(input.getSubmittedValue(), + assertNull(input.getSubmittedValue(), "After reset to -1, submitted value must be cleared to initial state"); - Assertions.assertTrue(input.isValid(), + assertTrue(input.isValid(), "After reset to -1, valid flag must be restored to true"); } @@ -393,7 +395,7 @@ public void testStatefulResetToInitialStateAtIndexMinusOne() * Multiple UIInput siblings must each have independent per-row state. */ @Test - public void testStatefulMultipleEVHSiblingsHaveIndependentState() + void statefulMultipleEVHSiblingsHaveIndependentState() { UIViewRoot root = facesContext.getViewRoot(); UIRepeat repeat = createRepeat(root, Arrays.asList("x", "y")); @@ -419,13 +421,13 @@ public void testStatefulMultipleEVHSiblingsHaveIndependentState() // Revisit row 0 — both inputs must have their row-0 values. repeat.setRowIndex(0); - Assertions.assertEquals("a0", inputA.getSubmittedValue()); - Assertions.assertEquals("b0", inputB.getSubmittedValue()); + assertEquals("a0", inputA.getSubmittedValue()); + assertEquals("b0", inputB.getSubmittedValue()); // Revisit row 1 — both inputs must have their row-1 values. repeat.setRowIndex(1); - Assertions.assertEquals("a1", inputA.getSubmittedValue()); - Assertions.assertEquals("b1", inputB.getSubmittedValue()); + assertEquals("a1", inputA.getSubmittedValue()); + assertEquals("b1", inputB.getSubmittedValue()); } /** @@ -433,7 +435,7 @@ public void testStatefulMultipleEVHSiblingsHaveIndependentState() * {@code _iterationEVHList} (depth-first traversal). */ @Test - public void testStatefulNestedEVHStateIsPreserved() + void statefulNestedEVHStateIsPreserved() { UIViewRoot root = facesContext.getViewRoot(); UIRepeat repeat = createRepeat(root, Arrays.asList("x", "y")); @@ -456,11 +458,11 @@ public void testStatefulNestedEVHStateIsPreserved() repeat.setRowIndex(-1); repeat.setRowIndex(0); - Assertions.assertEquals("nested_0", input.getSubmittedValue(), + assertEquals("nested_0", input.getSubmittedValue(), "Nested UIInput row-0 state must be restored"); repeat.setRowIndex(1); - Assertions.assertEquals("nested_1", input.getSubmittedValue(), + assertEquals("nested_1", input.getSubmittedValue(), "Nested UIInput row-1 state must be restored"); } @@ -473,7 +475,7 @@ public void testStatefulNestedEVHStateIsPreserved() * reset clientIds correctly so each row produces unique clientIds. */ @Test - public void testReadOnlyClientIdResetPerRow() + void readOnlyClientIdResetPerRow() { UIViewRoot root = facesContext.getViewRoot(); UIRepeat repeat = createRepeat(root, Arrays.asList("x", "y", "z")); @@ -492,13 +494,13 @@ public void testReadOnlyClientIdResetPerRow() repeat.setRowIndex(2); String clientId2 = out.getClientId(facesContext); - Assertions.assertNotEquals(clientId0, clientId1, "ClientIds must differ between rows"); - Assertions.assertNotEquals(clientId1, clientId2, "ClientIds must differ between rows"); + assertNotEquals(clientId0, clientId1, "ClientIds must differ between rows"); + assertNotEquals(clientId1, clientId2, "ClientIds must differ between rows"); // After resetting, the IDs must match the first pass. repeat.setRowIndex(-1); repeat.setRowIndex(0); - Assertions.assertEquals(clientId0, out.getClientId(facesContext), + assertEquals(clientId0, out.getClientId(facesContext), "ClientId for row 0 must be stable across iteration sequences"); } @@ -507,7 +509,7 @@ public void testReadOnlyClientIdResetPerRow() * state is not saved ({@code _iterationResetList} includes them). */ @Test - public void testReadOnlyTransientComponentClientIdIsReset() + void readOnlyTransientComponentClientIdIsReset() { UIViewRoot root = facesContext.getViewRoot(); UIRepeat repeat = createRepeat(root, Arrays.asList("x", "y")); @@ -524,7 +526,7 @@ public void testReadOnlyTransientComponentClientIdIsReset() repeat.setRowIndex(1); String id1 = transientOut.getClientId(facesContext); - Assertions.assertNotEquals(id0, id1, + assertNotEquals(id0, id1, "Transient component clientId must be reset per row"); } @@ -537,7 +539,7 @@ public void testReadOnlyTransientComponentClientIdIsReset() * iteration sequence (simulating RENDER_RESPONSE) must still work correctly. */ @Test - public void testIterationListsAreRebuiltAfterEncodeBegin() throws Exception + void iterationListsAreRebuiltAfterEncodeBegin() throws Exception { UIViewRoot root = facesContext.getViewRoot(); root.setRenderKitId("HTML_BASIC"); @@ -563,11 +565,11 @@ public void testIterationListsAreRebuiltAfterEncodeBegin() throws Exception // Second iteration sequence (simulates RENDER_RESPONSE row walk) // must still reset clientIds without NPE or stale state repeat.setRowIndex(0); - Assertions.assertNull(input.getSubmittedValue(), + assertNull(input.getSubmittedValue(), "After encodeBegin, _rowStates is cleared and initial state is clean"); repeat.setRowIndex(1); - Assertions.assertNull(input.getSubmittedValue()); + assertNull(input.getSubmittedValue()); repeat.setRowIndex(-1); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStatePreservedNestedTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStatePreservedNestedTest.java index b8394b6068..67c4218f62 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStatePreservedNestedTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStatePreservedNestedTest.java @@ -18,10 +18,11 @@ */ package org.apache.myfaces.view.facelets.component.rowstate; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.test.mock.MockPrintWriter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -30,7 +31,7 @@ * nested component for the next row must not change that map in place, otherwise the per-row state of the row before * is lost. This only shows from the second request with validation errors on. */ -public class RowStatePreservedNestedTest extends AbstractMyFacesCDIRequestTestCase +class RowStatePreservedNestedTest extends AbstractMyFacesCDIRequestTestCase { private static final List ROWS = List.of( "outer:0:inner:0:in", "outer:0:inner:1:in", "outer:1:inner:0:in", "outer:1:inner:1:in", @@ -45,7 +46,7 @@ protected void setUpWebConfigParams() throws Exception } @Test - public void testNestedTypedValuesSurviveRepeatedValidationFailures() throws Exception + void nestedTypedValuesSurviveRepeatedValidationFailures() throws Exception { startViewRequest("/rowStatePreservedNested.xhtml"); processLifecycleExecuteAndRender(); @@ -59,7 +60,7 @@ public void testNestedTypedValuesSurviveRepeatedValidationFailures() throws Exce client.getParameters().put("mainForm:required", ""); client.submit("mainForm:submit"); processLifecycleExecuteAndRender(); - Assertions.assertTrue(facesContext.isValidationFailed()); + assertTrue(facesContext.isValidationFailed()); String content = new String(((MockPrintWriter) response.getWriter()).content()); for (String row : ROWS) @@ -73,9 +74,9 @@ public void testNestedTypedValuesSurviveRepeatedValidationFailures() throws Exce private static void assertRenderedValue(String content, String clientId, String expected, int round) { int start = content.indexOf("id=\"" + clientId + "\""); - Assertions.assertTrue(start >= 0, clientId + " not rendered in: " + content); + assertTrue(start >= 0, clientId + " not rendered in: " + content); String input = content.substring(start, content.indexOf('>', start)); - Assertions.assertTrue(input.contains("value=\"" + expected + "\""), + assertTrue(input.contains("value=\"" + expected + "\""), "request " + round + ": " + clientId + " should render " + expected + " but was: " + input); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStatePreservedNewRowTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStatePreservedNewRowTest.java index 70efc342b1..63f1d8ced3 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStatePreservedNewRowTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStatePreservedNewRowTest.java @@ -20,15 +20,18 @@ import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.test.mock.MockPrintWriter; -import org.junit.jupiter.api.Assertions; + import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * MYFACES-4777 (TCK Issue6128IT): with {@code rowStatePreserved="true"}, a row without saved state of its own, such * as a row added to the model after the last render, must not show the local value of the row before it. The input is * created in Java with only an id, so that nothing is in its state helper initially. */ -public class RowStatePreservedNewRowTest extends AbstractMyFacesCDIRequestTestCase +class RowStatePreservedNewRowTest extends AbstractMyFacesCDIRequestTestCase { @Override protected void setUpWebConfigParams() throws Exception @@ -39,7 +42,7 @@ protected void setUpWebConfigParams() throws Exception } @Test - public void testNewRowDoesNotShowLocalValueOfRowBefore() throws Exception + void newRowDoesNotShowLocalValueOfRowBefore() throws Exception { startViewRequest("/rowStatePreservedNewRow.xhtml"); processLifecycleExecuteAndRender(); @@ -52,20 +55,20 @@ public void testNewRowDoesNotShowLocalValueOfRowBefore() throws Exception processLifecycleExecuteAndRender(); String content = content(); - Assertions.assertTrue(renderedInput(content, "form:table:1:in").contains("value=\"typed\""), content); - Assertions.assertTrue(renderedInput(content, "form:repeat:1:in").contains("value=\"typed\""), content); + assertTrue(renderedInput(content, "form:table:1:in").contains("value=\"typed\""), content); + assertTrue(renderedInput(content, "form:repeat:1:in").contains("value=\"typed\""), content); client.ajax("form:addRow", "action", "form:addRow", "form", true); processLifecycleExecuteAndRender(); content = content(); - Assertions.assertTrue(renderedInput(content, "form:table:1:in").contains("value=\"typed\""), content); - Assertions.assertTrue(renderedInput(content, "form:repeat:1:in").contains("value=\"typed\""), content); + assertTrue(renderedInput(content, "form:table:1:in").contains("value=\"typed\""), content); + assertTrue(renderedInput(content, "form:repeat:1:in").contains("value=\"typed\""), content); String tableRow2 = renderedInput(content, "form:table:2:in"); - Assertions.assertFalse(tableRow2.contains("typed"), "new table row shows the value of the row before: " + assertFalse(tableRow2.contains("typed"), "new table row shows the value of the row before: " + tableRow2); String repeatRow2 = renderedInput(content, "form:repeat:2:in"); - Assertions.assertFalse(repeatRow2.contains("typed"), "new repeat row shows the value of the row before: " + assertFalse(repeatRow2.contains("typed"), "new repeat row shows the value of the row before: " + repeatRow2); endRequest(); } @@ -78,7 +81,7 @@ private String content() throws Exception private static String renderedInput(String content, String clientId) { int start = content.indexOf("id=\"" + clientId + "\""); - Assertions.assertTrue(start >= 0, clientId + " not rendered in: " + content); + assertTrue(start >= 0, clientId + " not rendered in: " + content); return content.substring(start, content.indexOf('>', start)); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStatePreservedUpdateModelTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStatePreservedUpdateModelTest.java index 7c790c7005..21a0366d6f 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStatePreservedUpdateModelTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStatePreservedUpdateModelTest.java @@ -18,10 +18,12 @@ */ package org.apache.myfaces.view.facelets.component.rowstate; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.test.mock.MockPrintWriter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -29,7 +31,7 @@ * {@code rowStatePreserved="true"}, the saved state of a row must not keep the local value of its inputs after Update * Model Values cleared it, otherwise that stale local value hides every later change of the model in that row. */ -public class RowStatePreservedUpdateModelTest extends AbstractMyFacesCDIRequestTestCase +class RowStatePreservedUpdateModelTest extends AbstractMyFacesCDIRequestTestCase { private static final List INPUTS = List.of( "form:preserved:0:in", "form:preserved:1:in", @@ -45,7 +47,7 @@ protected void setUpWebConfigParams() throws Exception } @Test - public void testRowStatePreservedDoesNotKeepLocalValueAfterUpdateModel() throws Exception + void rowStatePreservedDoesNotKeepLocalValueAfterUpdateModel() throws Exception { startViewRequest("/rowStatePreservedUpdateModel.xhtml"); processLifecycleExecuteAndRender(); @@ -57,7 +59,7 @@ public void testRowStatePreservedDoesNotKeepLocalValueAfterUpdateModel() throws client.submit("form:submit"); processLifecycleExecuteAndRender(); - Assertions.assertFalse(facesContext.isValidationFailed()); + assertFalse(facesContext.isValidationFailed()); String content = content(); for (String input : INPUTS) { @@ -83,9 +85,9 @@ private String content() throws Exception private static void assertRenderedValue(String content, String clientId, String expected) { int start = content.indexOf("id=\"" + clientId + "\""); - Assertions.assertTrue(start >= 0, clientId + " not rendered in: " + content); + assertTrue(start >= 0, clientId + " not rendered in: " + content); String input = content.substring(start, content.indexOf('>', start)); - Assertions.assertTrue(input.contains("value=\"" + expected + "\""), + assertTrue(input.contains("value=\"" + expected + "\""), clientId + " should render " + expected + " but was: " + input); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStateRerenderTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStateRerenderTest.java index 8446d9f9c3..5a2206e4d7 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStateRerenderTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStateRerenderTest.java @@ -18,10 +18,11 @@ */ package org.apache.myfaces.view.facelets.component.rowstate; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.test.mock.MockPrintWriter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -47,7 +48,7 @@ protected void setUpWebConfigParams() throws Exception } @Test - public void testRefreshWithoutMessagesRendersModelValues() throws Exception + void refreshWithoutMessagesRendersModelValues() throws Exception { submitTypedValuesWithValidationError(); client.ajax("mainForm:refresh", "action", "mainForm:refresh", "mainForm", true); @@ -57,7 +58,7 @@ public void testRefreshWithoutMessagesRendersModelValues() throws Exception } @Test - public void testRefreshWithInfoRendersModelValues() throws Exception + void refreshWithInfoRendersModelValues() throws Exception { submitTypedValuesWithValidationError(); client.ajax("mainForm:refreshWithInfo", "action", "mainForm:refreshWithInfo", "mainForm", true); @@ -67,7 +68,7 @@ public void testRefreshWithInfoRendersModelValues() throws Exception } @Test - public void testRefreshWithErrorsRendersTypedValues() throws Exception + void refreshWithErrorsRendersTypedValues() throws Exception { submitTypedValuesWithValidationError(); client.getParameters().put("mainForm:required", ""); @@ -78,7 +79,7 @@ public void testRefreshWithErrorsRendersTypedValues() throws Exception } @Test - public void testRefreshWithFatalRendersTypedValues() throws Exception + void refreshWithFatalRendersTypedValues() throws Exception { submitTypedValuesWithValidationError(); client.ajax("mainForm:refreshWithFatal", "action", "mainForm:refreshWithFatal", "mainForm", true); @@ -88,7 +89,7 @@ public void testRefreshWithFatalRendersTypedValues() throws Exception } @Test - public void testRefreshWithErrorsTwiceThenWithoutMessages() throws Exception + void refreshWithErrorsTwiceThenWithoutMessages() throws Exception { submitTypedValuesWithValidationError(); @@ -122,7 +123,7 @@ private void submitTypedValuesWithValidationError() throws Exception client.submit("mainForm:submit"); processLifecycleExecuteAndRender(); - Assertions.assertTrue(facesContext.isValidationFailed()); + assertTrue(facesContext.isValidationFailed()); assertRenderedValues(true); } @@ -139,7 +140,7 @@ private void assertRenderedValues(boolean typed) throws Exception String row = ROWS.get(i); String expected = typed ? typed(row) : model[i]; String input = renderedInput(content, "mainForm:" + row); - Assertions.assertTrue(input.contains("value=\"" + expected + "\""), + assertTrue(input.contains("value=\"" + expected + "\""), "mainForm:" + row + " should render " + expected + " but was: " + input); } } @@ -147,7 +148,7 @@ private void assertRenderedValues(boolean typed) throws Exception private static String renderedInput(String content, String clientId) { int start = content.indexOf("id=\"" + clientId + "\""); - Assertions.assertTrue(start >= 0, clientId + " not rendered in: " + content); + assertTrue(start >= 0, clientId + " not rendered in: " + content); return content.substring(start, content.indexOf('>', start)); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStateSharedSavedStateTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStateSharedSavedStateTest.java index 61510f1573..37bd1ec3b9 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStateSharedSavedStateTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/component/rowstate/RowStateSharedSavedStateTest.java @@ -18,11 +18,13 @@ */ package org.apache.myfaces.view.facelets.component.rowstate; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import jakarta.faces.render.ResponseStateManager; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.test.core.mock.MockMyFacesClient; import org.apache.myfaces.test.mock.MockPrintWriter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -62,7 +64,7 @@ protected void applyStateFromPreviousRequest() } @Test - public void testSecondRestoreOfSavedStateDoesNotSeeChangesOfFirstRestore() throws Exception + void secondRestoreOfSavedStateDoesNotSeeChangesOfFirstRestore() throws Exception { startViewRequest("/rowStateSharedSavedState.xhtml"); processLifecycleExecuteAndRender(); @@ -71,7 +73,7 @@ public void testSecondRestoreOfSavedStateDoesNotSeeChangesOfFirstRestore() throw putRows("first", "one"); client.submit("form:submit"); processLifecycleExecuteAndRender(); - Assertions.assertFalse(facesContext.getMessageList().isEmpty(), "required input should fail"); + assertFalse(facesContext.getMessageList().isEmpty(), "required input should fail"); assertRows("first", "one"); String viewStateOfStep1 = renderedViewState(); @@ -79,7 +81,7 @@ public void testSecondRestoreOfSavedStateDoesNotSeeChangesOfFirstRestore() throw putRows("first", "second"); client.submit("form:submit"); processLifecycleExecuteAndRender(); - Assertions.assertFalse(facesContext.getMessageList().isEmpty(), "required input should fail"); + assertFalse(facesContext.getMessageList().isEmpty(), "required input should fail"); assertRows("first", "second"); // step 3: restore the view state of step 1 again, as the back button or a second tab would do @@ -87,7 +89,7 @@ public void testSecondRestoreOfSavedStateDoesNotSeeChangesOfFirstRestore() throw client.getParameters().put("form:required", ""); client.ajax("form:refresh", "action", "form:required", "form", true); processLifecycleExecuteAndRender(); - Assertions.assertFalse(facesContext.getMessageList().isEmpty(), "required input should fail"); + assertFalse(facesContext.getMessageList().isEmpty(), "required input should fail"); assertRows("first", "one"); endRequest(); } @@ -117,7 +119,7 @@ private String renderedViewState() throws Exception { String content = new String(((MockPrintWriter) response.getWriter()).content()); int start = content.indexOf("name=\"" + ResponseStateManager.VIEW_STATE_PARAM + "\""); - Assertions.assertTrue(start >= 0, "view state not rendered in: " + content); + assertTrue(start >= 0, "view state not rendered in: " + content); String field = content.substring(start, content.indexOf('>', start)); int valueStart = field.indexOf("value=\"") + "value=\"".length(); return field.substring(valueStart, field.indexOf('"', valueStart)); @@ -126,9 +128,9 @@ private String renderedViewState() throws Exception private static void assertRenderedValue(String content, String clientId, String expected) { int start = content.indexOf("id=\"" + clientId + "\""); - Assertions.assertTrue(start >= 0, clientId + " not rendered in: " + content); + assertTrue(start >= 0, clientId + " not rendered in: " + content); String input = content.substring(start, content.indexOf('>', start)); - Assertions.assertTrue(input.contains("value=\"" + expected + "\""), + assertTrue(input.contains("value=\"" + expected + "\""), clientId + " should render " + expected + " but was: " + input); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/el/CacheELExpressionsAlwaysRecompileTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/el/CacheELExpressionsAlwaysRecompileTestCase.java index fca0a6a89d..6a64bc4aad 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/el/CacheELExpressionsAlwaysRecompileTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/el/CacheELExpressionsAlwaysRecompileTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.el; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import jakarta.el.ExpressionFactory; import jakarta.faces.application.ViewHandler; @@ -27,14 +29,13 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.ELExpressionCacheMode; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * * @author lu4242 */ -public class CacheELExpressionsAlwaysRecompileTestCase extends AbstractFaceletTestCase +class CacheELExpressionsAlwaysRecompileTestCase extends AbstractFaceletTestCase { @Override protected void setUpServletObjects() throws Exception @@ -51,9 +52,9 @@ protected ExpressionFactory createExpressionFactory() { return new org.apache.el.ExpressionFactoryImpl(); } - + @Test - public void testUIParamCaching1() throws Exception + void uIParamCaching1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "uiparamcache1.xhtml"); @@ -64,14 +65,14 @@ public void testUIParamCaching1() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } - + @Test - public void testUserTagCaching1() throws Exception + void userTagCaching1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "usertagtest1.xhtml"); @@ -82,14 +83,14 @@ public void testUserTagCaching1() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } @Test - public void testUIParamIncludeCaching1() throws Exception + void uIParamIncludeCaching1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "includetagtest1.xhtml"); @@ -100,9 +101,9 @@ public void testUIParamIncludeCaching1() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/el/CacheELExpressionsTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/el/CacheELExpressionsTestCase.java index 5ce7bb1c98..133720984a 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/el/CacheELExpressionsTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/el/CacheELExpressionsTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.el; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import jakarta.el.ExpressionFactory; import jakarta.faces.component.UIViewRoot; @@ -26,23 +28,22 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.ELExpressionCacheMode; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * * @author lu4242 */ -public class CacheELExpressionsTestCase extends AbstractFaceletTestCase +class CacheELExpressionsTestCase extends AbstractFaceletTestCase { @Override protected ExpressionFactory createExpressionFactory() { return new org.apache.el.ExpressionFactoryImpl(); } - + @Test - public void testUIParamCaching1() throws Exception + void uIParamCaching1() throws Exception { // Works in "none", "allowCset", and "strict" but it does not in always. servletContext.addInitParameter(MyfacesConfig.CACHE_EL_EXPRESSIONS, @@ -57,14 +58,14 @@ public void testUIParamCaching1() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } - + @Test - public void testUIParamCaching2() throws Exception + void uIParamCaching2() throws Exception { // Works in "none", "allowCset", and "strict" but it does not in always. servletContext.addInitParameter(MyfacesConfig.CACHE_EL_EXPRESSIONS, @@ -79,10 +80,10 @@ public void testUIParamCaching2() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/el/CompositeComponentELUtilsTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/el/CompositeComponentELUtilsTestCase.java index 05d87254d0..fd1bbfe4ec 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/el/CompositeComponentELUtilsTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/el/CompositeComponentELUtilsTestCase.java @@ -18,16 +18,18 @@ */ package org.apache.myfaces.view.facelets.el; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import jakarta.el.ExpressionFactory; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * * @author Leonardo Uribe */ -public class CompositeComponentELUtilsTestCase extends AbstractFaceletTestCase +class CompositeComponentELUtilsTestCase extends AbstractFaceletTestCase { @Override @@ -35,35 +37,35 @@ protected ExpressionFactory createExpressionFactory() { return new org.apache.el.ExpressionFactoryImpl(); } - + @Test - public void test_cc_attrs_method_expression1() throws Exception + void cc_attrs_method_expression1() throws Exception { - Assertions.assertTrue( + assertTrue( CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression( "#{cc.attrs.someProp}")); - Assertions.assertTrue( + assertTrue( CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression( "#{ cc.attrs.someProp}")); - Assertions.assertFalse( + assertFalse( CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression( "#{cc.attrs.someProp.someKey}")); - Assertions.assertFalse( + assertFalse( CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression( "#{xy:call(cc.attrs.someProp)}")); - Assertions.assertFalse( + assertFalse( CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression( "#{xy:call( cc.attrs.someProp)}")); - Assertions.assertFalse( + assertFalse( CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression( "#{xy:call(zz, cc.attrs.someProp)}")); - Assertions.assertFalse( + assertFalse( CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression( "#{xy:call(zz,cc.attrs.someProp)}")); - Assertions.assertTrue( + assertTrue( CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression( "#{cc.attrs.method(someProp)}")); - Assertions.assertTrue( + assertTrue( CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression( "#{cc.attrs.method( someProp, someAttr )}")); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/el/ELTextTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/el/ELTextTest.java index c4b0473dd5..e298e6523f 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/el/ELTextTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/el/ELTextTest.java @@ -18,64 +18,65 @@ */ package org.apache.myfaces.view.facelets.el; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.el.ExpressionFactory; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class ELTextTest { - +class ELTextTest { + @Test - public void parseLiteral() + void parseLiteral() { ExpressionFactory expressionFactory = new org.apache.el.ExpressionFactoryImpl(); ELText elText = ELText.parse(expressionFactory, null, "blub", null); - Assertions.assertEquals("blub", elText.toString()); + assertEquals("blub", elText.toString()); elText = ELText.parse(expressionFactory, null, "", null); - Assertions.assertEquals(null, elText); + assertNull(elText); } @Test - public void parseValueExpressionAndLiteral() + void parseValueExpressionAndLiteral() { ExpressionFactory expressionFactory = new org.apache.el.ExpressionFactoryImpl(); ELText elText = ELText.parse(expressionFactory, null, "#{myblub.blub} blub", null); - Assertions.assertTrue(elText instanceof ELText.ELTextComposite); - Assertions.assertEquals(2, ((ELText.ELTextComposite) elText).getElements().length); - Assertions.assertEquals(" blub", ((ELText.ELTextComposite) elText).getElements()[1].toString()); + assertInstanceOf(ELText.ELTextComposite.class, elText); + assertEquals(2, ((ELText.ELTextComposite) elText).getElements().length); + assertEquals(" blub", ((ELText.ELTextComposite) elText).getElements()[1].toString()); elText = ELText.parse(expressionFactory, null, "#{myblub.blub} blub #{myblub.blub}", null); - Assertions.assertTrue(elText instanceof ELText.ELTextComposite); - Assertions.assertEquals(3, ((ELText.ELTextComposite) elText).getElements().length); - Assertions.assertEquals(" blub ", ((ELText.ELTextComposite) elText).getElements()[1].toString()); + assertInstanceOf(ELText.ELTextComposite.class, elText); + assertEquals(3, ((ELText.ELTextComposite) elText).getElements().length); + assertEquals(" blub ", ((ELText.ELTextComposite) elText).getElements()[1].toString()); } @Test - public void parseAsArrayLiteral() + void parseAsArrayLiteral() { ExpressionFactory expressionFactory = new org.apache.el.ExpressionFactoryImpl(); ELText[] elText = ELText.parseAsArray(expressionFactory, null, "blub", null); - Assertions.assertEquals("blub", elText[0].toString()); + assertEquals("blub", elText[0].toString()); elText = ELText.parseAsArray(expressionFactory, null, "", null); - Assertions.assertTrue(elText == null); + assertNull(elText); } @Test - public void parseAsArrayValueExpressionAndLiteral() + void parseAsArrayValueExpressionAndLiteral() { ExpressionFactory expressionFactory = new org.apache.el.ExpressionFactoryImpl(); ELText[] elText = ELText.parseAsArray(expressionFactory, null, "#{myblub.blub} blub", null); - Assertions.assertEquals(2, elText.length); - Assertions.assertEquals(" blub", elText[1].toString()); + assertEquals(2, elText.length); + assertEquals(" blub", elText[1].toString()); elText = ELText.parseAsArray(expressionFactory, null, "#{myblub.blub} blub #{myblub.blub}", null); - Assertions.assertEquals(3, elText.length); - Assertions.assertEquals(" blub ", elText[1].toString()); + assertEquals(3, elText.length); + assertEquals(" blub ", elText[1].toString()); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/el/SerializableELExpressionsTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/el/SerializableELExpressionsTestCase.java index fcfe167f3a..1566045897 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/el/SerializableELExpressionsTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/el/SerializableELExpressionsTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.el; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; @@ -29,10 +31,9 @@ import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; import org.apache.myfaces.view.facelets.tag.TagAttributeImpl; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class SerializableELExpressionsTestCase extends AbstractFaceletTestCase +class SerializableELExpressionsTestCase extends AbstractFaceletTestCase { @Override @@ -40,9 +41,9 @@ protected ExpressionFactory createExpressionFactory() { return new org.apache.el.ExpressionFactoryImpl(); } - + @Test - public void testSerializeLocationValueExpressionWrapper() throws Exception + void serializeLocationValueExpressionWrapper() throws Exception { ValueExpression ve = facesContext.getApplication().getExpressionFactory().createValueExpression( facesContext.getELContext(), "#{cc.attrs.value}", Object.class); @@ -61,16 +62,16 @@ public void testSerializeLocationValueExpressionWrapper() throws Exception ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); LocationValueExpression lve2 = (LocationValueExpression) ois.readObject(); - Assertions.assertEquals(lve.getExpressionString(), lve2.getExpressionString()); - Assertions.assertEquals(lve.getLocation().getPath(), lve2.getLocation().getPath()); - Assertions.assertEquals(lve.getLocation().getLine(), lve2.getLocation().getLine()); - Assertions.assertEquals(lve.getLocation().getColumn(), lve2.getLocation().getColumn()); + assertEquals(lve.getExpressionString(), lve2.getExpressionString()); + assertEquals(lve.getLocation().getPath(), lve2.getLocation().getPath()); + assertEquals(lve.getLocation().getLine(), lve2.getLocation().getLine()); + assertEquals(lve.getLocation().getColumn(), lve2.getLocation().getColumn()); oos.close(); ois.close(); } - + @Test - public void testSerializeLocationValueExpressionUELWrapper() throws Exception + void serializeLocationValueExpressionUELWrapper() throws Exception { ValueExpression ve = facesContext.getApplication().getExpressionFactory().createValueExpression( facesContext.getELContext(), "#{cc.attrs.value}", Object.class); @@ -89,10 +90,10 @@ public void testSerializeLocationValueExpressionUELWrapper() throws Exception ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); LocationValueExpression lve2 = (LocationValueExpression) ois.readObject(); - Assertions.assertEquals(lve.getExpressionString(), lve2.getExpressionString()); - Assertions.assertEquals(lve.getLocation().getPath(), lve2.getLocation().getPath()); - Assertions.assertEquals(lve.getLocation().getLine(), lve2.getLocation().getLine()); - Assertions.assertEquals(lve.getLocation().getColumn(), lve2.getLocation().getColumn()); + assertEquals(lve.getExpressionString(), lve2.getExpressionString()); + assertEquals(lve.getLocation().getPath(), lve2.getLocation().getPath()); + assertEquals(lve.getLocation().getLine(), lve2.getLocation().getLine()); + assertEquals(lve.getLocation().getColumn(), lve2.getLocation().getColumn()); oos.close(); ois.close(); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactoryPathValidationTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactoryPathValidationTest.java index 99d584ba1b..ef76999ca9 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactoryPathValidationTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactoryPathValidationTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.impl; +import static org.junit.jupiter.api.Assertions.*; + import java.net.URL; import jakarta.faces.application.ViewHandler; @@ -26,7 +28,6 @@ import org.apache.myfaces.context.InvalidFileException; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -36,7 +37,7 @@ *

The suite runs under {@code Development} stage (overriding the default * {@code UnitTest} set by the base class) so the validation code-path is always active.

*/ -public class DefaultFaceletFactoryPathValidationTest extends AbstractMyFacesCDIRequestTestCase +class DefaultFaceletFactoryPathValidationTest extends AbstractMyFacesCDIRequestTestCase { @Override protected void setUpWebConfigParams() throws Exception @@ -67,20 +68,20 @@ private DefaultFaceletFactory getFactory() * {@link InvalidFileException.Reason#DISALLOWED_SCHEME}. */ @Test - public void testExternalHttpUrlIsRejected() throws Exception + void externalHttpUrlIsRejected() throws Exception { // Only a live facesContext is needed — no view rendering required startViewRequest(null); DefaultFaceletFactory factory = getFactory(); - InvalidFileException ex = Assertions.assertThrows( + InvalidFileException ex = assertThrows( InvalidFileException.class, () -> factory.resolveURL(facesContext, null, "http://someverybadmaliciouswebsite.com/attack.xhtml"), "Expected InvalidFileException for external http: URL"); - Assertions.assertEquals(InvalidFileException.Reason.DISALLOWED_SCHEME, ex.getReason()); + assertEquals(InvalidFileException.Reason.DISALLOWED_SCHEME, ex.getReason()); endRequest(); } @@ -96,7 +97,7 @@ public void testExternalHttpUrlIsRejected() throws Exception * the {@code mappingAllowed} check.

*/ @Test - public void testNonFaceletExtensionIsRejected() throws Exception + void nonFaceletExtensionIsRejected() throws Exception { servletContext.addInitParameter(ViewHandler.FACELETS_SUFFIX_PARAM_NAME, ".xhtml"); startViewRequest(null); @@ -106,12 +107,12 @@ public void testNonFaceletExtensionIsRejected() throws Exception URL webappRoot = getWebappContextURI().toURL(); URL source = new URL(webappRoot, "views/index.xhtml"); - InvalidFileException ex = Assertions.assertThrows( + InvalidFileException ex = assertThrows( InvalidFileException.class, () -> factory.resolveURL(facesContext, source, "template.properties"), "Expected InvalidFileException for a .properties path"); - Assertions.assertEquals(InvalidFileException.Reason.INVALID_EXTENSION, ex.getReason()); + assertEquals(InvalidFileException.Reason.INVALID_EXTENSION, ex.getReason()); endRequest(); } @@ -121,11 +122,11 @@ public void testNonFaceletExtensionIsRejected() throws Exception * fail open when {@code source == null}). */ @Test - public void testRelativeTraversalWithNullSourceIsRejected() throws Exception + void relativeTraversalWithNullSourceIsRejected() throws Exception { startViewRequest(null); - Assertions.assertThrows( + assertThrows( java.io.IOException.class, () -> getFactory().resolveURL(facesContext, null, "../../etc/passwd.xhtml")); } @@ -136,7 +137,7 @@ public void testRelativeTraversalWithNullSourceIsRejected() throws Exception * must not be rejected as {@code PATH_TRAVERSAL}. */ @Test - public void testRelativeIncludeBetweenSiblingsInJarIsAllowed() throws Exception + void relativeIncludeBetweenSiblingsInJarIsAllowed() throws Exception { startViewRequest(null); @@ -144,7 +145,7 @@ public void testRelativeIncludeBetweenSiblingsInJarIsAllowed() throws Exception java.net.URL resolved = getFactory().resolveURL(facesContext, source, "breadcrumbs.xhtml"); - Assertions.assertTrue(resolved.toExternalForm().endsWith("!/META-INF/resources/breadcrumbs.xhtml"), + assertTrue(resolved.toExternalForm().endsWith("!/META-INF/resources/breadcrumbs.xhtml"), "Unexpected URL: " + resolved); } @@ -152,17 +153,17 @@ public void testRelativeIncludeBetweenSiblingsInJarIsAllowed() throws Exception * A relative path that climbs out of the jar's {@code META-INF/resources} root must still be rejected. */ @Test - public void testRelativePathEscapingJarResourceRootIsRejected() throws Exception + void relativePathEscapingJarResourceRootIsRejected() throws Exception { startViewRequest(null); java.net.URL source = createTemplatesJar("includeOnly.xhtml"); - InvalidFileException ex = Assertions.assertThrows( + InvalidFileException ex = assertThrows( InvalidFileException.class, () -> getFactory().resolveURL(facesContext, source, "../../escaped.xhtml")); - Assertions.assertEquals(InvalidFileException.Reason.PATH_TRAVERSAL, ex.getReason()); + assertEquals(InvalidFileException.Reason.PATH_TRAVERSAL, ex.getReason()); } /** Creates templates.jar with META-INF/resources/{includeOnly,breadcrumbs}.xhtml; returns URL of 'entry'. */ diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactoryTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactoryTest.java index 5cc1bac8d0..28be47430b 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactoryTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactoryTest.java @@ -18,64 +18,63 @@ */ package org.apache.myfaces.view.facelets.impl; -import java.io.IOException; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; import org.apache.myfaces.view.facelets.compiler.SAXCompiler; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * Unit tests for {@link DefaultFaceletFactory#_removeFirst(String, String)} (same-package access to protected). */ -public class DefaultFaceletFactoryTest extends AbstractFaceletTestCase +class DefaultFaceletFactoryTest extends AbstractFaceletTestCase { @Test - public void testRemoveFirstPrefix() throws IOException + void removeFirstPrefix() throws Exception { DefaultFaceletFactory factory = new DefaultFaceletFactory(new SAXCompiler()); - Assertions.assertEquals("/y/z", factory._removeFirst("/x/y/z", "/x")); + assertEquals("/y/z", factory._removeFirst("/x/y/z", "/x")); } @Test - public void testRemoveFirstOnlyFirstOccurrence() throws IOException + void removeFirstOnlyFirstOccurrence() throws Exception { DefaultFaceletFactory factory = new DefaultFaceletFactory(new SAXCompiler()); - Assertions.assertEquals("/a/b/a", factory._removeFirst("/a/b/a/b/a", "/a/b")); + assertEquals("/a/b/a", factory._removeFirst("/a/b/a/b/a", "/a/b")); } @Test - public void testRemoveFirstNotFound() throws IOException + void removeFirstNotFound() throws Exception { DefaultFaceletFactory factory = new DefaultFaceletFactory(new SAXCompiler()); - Assertions.assertEquals("/unchanged", factory._removeFirst("/unchanged", "/missing")); + assertEquals("/unchanged", factory._removeFirst("/unchanged", "/missing")); } @Test - public void testRemoveFirstEmptyToRemove() throws IOException + void removeFirstEmptyToRemove() throws Exception { DefaultFaceletFactory factory = new DefaultFaceletFactory(new SAXCompiler()); - Assertions.assertEquals("/same", factory._removeFirst("/same", "")); + assertEquals("/same", factory._removeFirst("/same", "")); } @Test - public void testRemoveFirstNullToRemove() throws IOException + void removeFirstNullToRemove() throws Exception { DefaultFaceletFactory factory = new DefaultFaceletFactory(new SAXCompiler()); - Assertions.assertEquals("/same", factory._removeFirst("/same", null)); + assertEquals("/same", factory._removeFirst("/same", null)); } @Test - public void testRemoveFirstRegexMetacharactersAreLiteral() throws IOException + void removeFirstRegexMetacharactersAreLiteral() throws Exception { DefaultFaceletFactory factory = new DefaultFaceletFactory(new SAXCompiler()); - Assertions.assertEquals("prefixsuffix", factory._removeFirst("prefix.+suffix", ".+")); + assertEquals("prefixsuffix", factory._removeFirst("prefix.+suffix", ".+")); } @Test - public void testRemoveFirstWholeString() throws IOException + void removeFirstWholeString() throws Exception { DefaultFaceletFactory factory = new DefaultFaceletFactory(new SAXCompiler()); - Assertions.assertEquals("", factory._removeFirst("/only", "/only")); + assertEquals("", factory._removeFirst("/only", "/only")); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/impl/ProgrammaticViewTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/impl/ProgrammaticViewTest.java index d19a036935..7d375ef469 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/impl/ProgrammaticViewTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/impl/ProgrammaticViewTest.java @@ -18,20 +18,20 @@ */ package org.apache.myfaces.view.facelets.impl; -import java.io.IOException; +import static org.junit.jupiter.api.Assertions.assertTrue; + import jakarta.faces.component.UIOutput; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /* - Basic test that verifies programmmatic facelets work. See spec issue: https://github.com/jakartaee/faces/issues/1581 - Facelet code is generated by ProgrammaticViewBean. - */ -public class ProgrammaticViewTest extends org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase //extends FaceletTestCase + Basic test that verifies programmmatic facelets work. See spec issue: https://github.com/jakartaee/faces/issues/1581 + Facelet code is generated by ProgrammaticViewBean. +*/ +class ProgrammaticViewTest extends org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase //extends FaceletTestCase { @Test - public void testProgrammaticView() throws IOException + void programmaticView() throws Exception { startViewRequest("/test.xhtml"); processLifecycleExecuteAndRender(); @@ -40,13 +40,13 @@ public void testProgrammaticView() throws IOException UIOutput out = (UIOutput) facesContext.getViewRoot().findComponent("messageId"); String result1 = out.getValue().toString(); - Assertions.assertTrue(result1.contains("Success!")); + assertTrue(result1.contains("Success!")); //Grab by ID UIOutput cdiOut = (UIOutput) facesContext.getViewRoot().findComponent("cdiId"); String result2 = cdiOut.getValue().toString(); - Assertions.assertTrue(result2.contains("CDI Bean Name: Test1581Bean")); + assertTrue(result2.contains("CDI Bean Name: Test1581Bean")); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/impl/ResourceMarkDeleteTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/impl/ResourceMarkDeleteTest.java index f427e9b4a2..c86052cb87 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/impl/ResourceMarkDeleteTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/impl/ResourceMarkDeleteTest.java @@ -18,19 +18,19 @@ */ package org.apache.myfaces.view.facelets.impl; -import java.io.IOException; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.List; import jakarta.faces.component.UIComponent; import jakarta.faces.component.UIViewRoot; import jakarta.faces.event.PhaseId; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class ResourceMarkDeleteTest extends AbstractFaceletTestCase +class ResourceMarkDeleteTest extends AbstractFaceletTestCase { @Test - public void test_only_ajs_is_included() throws IOException + void only_ajs_is_included() throws Exception { UIViewRoot root = facesContext.getViewRoot(); @@ -40,12 +40,12 @@ public void test_only_ajs_is_included() throws IOException List resources = root.getComponentResources(facesContext, "head"); - Assertions.assertEquals(1, resources.size()); - Assertions.assertTrue(resources.get(0).getAttributes().get("name").equals("a.js")); + assertEquals(1, resources.size()); + assertEquals("a.js", resources.get(0).getAttributes().get("name")); } @Test - public void test_ajs_and_xjs_are_included() throws IOException + void ajs_and_xjs_are_included() throws Exception { facesContext.getAttributes().put("includeResource", Boolean.TRUE); UIViewRoot root = facesContext.getViewRoot(); @@ -56,11 +56,11 @@ public void test_ajs_and_xjs_are_included() throws IOException List resources = root.getComponentResources(facesContext, "head"); - Assertions.assertEquals(2, resources.size()); + assertEquals(2, resources.size()); } @Test - public void test_only_ajs_after_refresh_view_is_included() throws IOException + void only_ajs_after_refresh_view_is_included() throws Exception { UIViewRoot view = facesContext.getViewRoot(); @@ -71,7 +71,7 @@ public void test_only_ajs_after_refresh_view_is_included() throws IOException { List resources = view.getComponentResources(facesContext, "head"); - Assertions.assertEquals(1, resources.size()); + assertEquals(1, resources.size()); } // reset 'isFilledView' @@ -89,7 +89,7 @@ public void test_only_ajs_after_refresh_view_is_included() throws IOException { List resources = view.getComponentResources(facesContext, "head"); - Assertions.assertEquals(2, resources.size()); + assertEquals(2, resources.size()); } // reset 'isFilledView' @@ -103,7 +103,7 @@ public void test_only_ajs_after_refresh_view_is_included() throws IOException { List resources = view.getComponentResources(facesContext, "head"); - Assertions.assertEquals(1, resources.size()); + assertEquals(1, resources.size()); } } } \ No newline at end of file diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounterTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounterTest.java index 08831d5f05..ccfe16bfca 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounterTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounterTest.java @@ -18,42 +18,44 @@ */ package org.apache.myfaces.view.facelets.impl; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Set; import java.util.TreeSet; import org.apache.myfaces.test.base.junit.AbstractFacesTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class SectionUniqueIdCounterTest extends AbstractFacesTestCase +class SectionUniqueIdCounterTest extends AbstractFacesTestCase { @Test - public void testSimpleCounter() + void simpleCounter() { Set idSet = new TreeSet(); SectionUniqueIdCounter counter = new SectionUniqueIdCounter(); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - Assertions.assertTrue(idSet.add(counter.startUniqueIdSection())); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - Assertions.assertTrue(idSet.add(counter.startUniqueIdSection())); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - counter.endUniqueIdSection(); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - counter.endUniqueIdSection(); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); - Assertions.assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.startUniqueIdSection())); + assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.startUniqueIdSection())); + assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.generateUniqueId())); + counter.endUniqueIdSection(); + assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.generateUniqueId())); + counter.endUniqueIdSection(); + assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.generateUniqueId())); + assertTrue(idSet.add(counter.generateUniqueId())); /* SectionUniqueIdCounter counter = new SectionUniqueIdCounter("_"); @@ -126,123 +128,123 @@ public void testSimpleCounter() System.out.println(UIViewRoot.UNIQUE_ID_PREFIX+counter.generateUniqueId()); */ } - + @Test - public void testCachedCounter() + void cachedCounter() { String[] cache = SectionUniqueIdCounter.generateUniqueIdCache("_", 10); SectionUniqueIdCounter counter = new SectionUniqueIdCounter("_", cache); SectionUniqueIdCounter counterOrig = new SectionUniqueIdCounter("_"); - Assertions.assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); - Assertions.assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); - Assertions.assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); - Assertions.assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); + assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); + assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); + assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); + assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); counterOrig.startUniqueIdSection(); counter.startUniqueIdSection(); - Assertions.assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); - Assertions.assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); - Assertions.assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); - Assertions.assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); + assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); + assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); + assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); + assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); counterOrig.endUniqueIdSection(); counter.endUniqueIdSection(); - Assertions.assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); - Assertions.assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); - Assertions.assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); - Assertions.assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); + assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); + assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); + assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); + assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId()); } - + @Test - public void testCounterExpansion() + void counterExpansion() { SectionUniqueIdCounter counter = new SectionUniqueIdCounter(); - Assertions.assertEquals("1", counter.generateUniqueId()); - Assertions.assertEquals("2", counter.generateUniqueId()); - Assertions.assertEquals("2_X", counter.startUniqueIdSection("X")); - Assertions.assertEquals("2_X_1", counter.generateUniqueId()); - Assertions.assertEquals("2_X_2",counter.generateUniqueId()); - Assertions.assertEquals("2_X_3",counter.startUniqueIdSection()); - Assertions.assertEquals("2_X_3_1",counter.generateUniqueId()); - Assertions.assertEquals("2_X_3_2",counter.generateUniqueId()); - counter.endUniqueIdSection(); - Assertions.assertEquals("2_X_4",counter.generateUniqueId()); + assertEquals("1", counter.generateUniqueId()); + assertEquals("2", counter.generateUniqueId()); + assertEquals("2_X", counter.startUniqueIdSection("X")); + assertEquals("2_X_1", counter.generateUniqueId()); + assertEquals("2_X_2",counter.generateUniqueId()); + assertEquals("2_X_3",counter.startUniqueIdSection()); + assertEquals("2_X_3_1",counter.generateUniqueId()); + assertEquals("2_X_3_2",counter.generateUniqueId()); + counter.endUniqueIdSection(); + assertEquals("2_X_4",counter.generateUniqueId()); counter.endUniqueIdSection("X"); - Assertions.assertEquals("2_Y", counter.startUniqueIdSection("Y")); - Assertions.assertEquals("2_Y_1", counter.generateUniqueId()); + assertEquals("2_Y", counter.startUniqueIdSection("Y")); + assertEquals("2_Y_1", counter.generateUniqueId()); counter.endUniqueIdSection("Y"); - Assertions.assertEquals("3", counter.generateUniqueId()); - Assertions.assertEquals("4", counter.generateUniqueId()); + assertEquals("3", counter.generateUniqueId()); + assertEquals("4", counter.generateUniqueId()); } - + @Test - public void testCounterExpansion2() + void counterExpansion2() { SectionUniqueIdCounter counter = new SectionUniqueIdCounter(); - Assertions.assertEquals("1", counter.generateUniqueId()); - Assertions.assertEquals("2",counter.startUniqueIdSection()); - Assertions.assertEquals("2_1",counter.startUniqueIdSection()); - Assertions.assertEquals("2_1_1", counter.generateUniqueId()); + assertEquals("1", counter.generateUniqueId()); + assertEquals("2",counter.startUniqueIdSection()); + assertEquals("2_1",counter.startUniqueIdSection()); + assertEquals("2_1_1", counter.generateUniqueId()); counter.endUniqueIdSection(); - Assertions.assertEquals("2_2", counter.generateUniqueId()); + assertEquals("2_2", counter.generateUniqueId()); counter.endUniqueIdSection(); - Assertions.assertEquals("3", counter.generateUniqueId()); + assertEquals("3", counter.generateUniqueId()); - Assertions.assertEquals("3_X", counter.startUniqueIdSection("X")); - Assertions.assertEquals("3_X_1", counter.generateUniqueId()); - Assertions.assertEquals("3_X_2",counter.generateUniqueId()); - Assertions.assertEquals("3_X_3",counter.startUniqueIdSection()); - Assertions.assertEquals("3_X_3_1",counter.generateUniqueId()); - Assertions.assertEquals("3_X_3_2",counter.generateUniqueId()); - counter.endUniqueIdSection(); - Assertions.assertEquals("3_X_4",counter.generateUniqueId()); + assertEquals("3_X", counter.startUniqueIdSection("X")); + assertEquals("3_X_1", counter.generateUniqueId()); + assertEquals("3_X_2",counter.generateUniqueId()); + assertEquals("3_X_3",counter.startUniqueIdSection()); + assertEquals("3_X_3_1",counter.generateUniqueId()); + assertEquals("3_X_3_2",counter.generateUniqueId()); + counter.endUniqueIdSection(); + assertEquals("3_X_4",counter.generateUniqueId()); counter.endUniqueIdSection("X"); - Assertions.assertEquals("3_Y", counter.startUniqueIdSection("Y")); - Assertions.assertEquals("3_Y_1", counter.generateUniqueId()); + assertEquals("3_Y", counter.startUniqueIdSection("Y")); + assertEquals("3_Y_1", counter.generateUniqueId()); counter.endUniqueIdSection("Y"); - Assertions.assertEquals("4",counter.startUniqueIdSection()); + assertEquals("4",counter.startUniqueIdSection()); counter.endUniqueIdSection(); - Assertions.assertEquals("5", counter.generateUniqueId()); - Assertions.assertEquals("6", counter.generateUniqueId()); + assertEquals("5", counter.generateUniqueId()); + assertEquals("6", counter.generateUniqueId()); } - + @Test - public void testCounterExpansion3() + void counterExpansion3() { SectionUniqueIdCounter counter = new SectionUniqueIdCounter(); - Assertions.assertEquals("1",counter.startUniqueIdSection()); - Assertions.assertEquals("1_1", counter.generateUniqueId()); - Assertions.assertEquals("1_2",counter.startUniqueIdSection()); - Assertions.assertEquals("1_2_1",counter.startUniqueIdSection()); - Assertions.assertEquals("1_2_1_1", counter.generateUniqueId()); + assertEquals("1",counter.startUniqueIdSection()); + assertEquals("1_1", counter.generateUniqueId()); + assertEquals("1_2",counter.startUniqueIdSection()); + assertEquals("1_2_1",counter.startUniqueIdSection()); + assertEquals("1_2_1_1", counter.generateUniqueId()); counter.endUniqueIdSection(); - Assertions.assertEquals("1_2_2", counter.generateUniqueId()); + assertEquals("1_2_2", counter.generateUniqueId()); counter.endUniqueIdSection(); - Assertions.assertEquals("1_3", counter.generateUniqueId()); + assertEquals("1_3", counter.generateUniqueId()); - Assertions.assertEquals("1_3_X", counter.startUniqueIdSection("X")); - Assertions.assertEquals("1_3_X_1", counter.generateUniqueId()); - Assertions.assertEquals("1_3_X_2",counter.generateUniqueId()); - Assertions.assertEquals("1_3_X_3",counter.startUniqueIdSection()); - Assertions.assertEquals("1_3_X_3_1",counter.generateUniqueId()); - Assertions.assertEquals("1_3_X_3_2",counter.generateUniqueId()); - counter.endUniqueIdSection(); - Assertions.assertEquals("1_3_X_4",counter.generateUniqueId()); + assertEquals("1_3_X", counter.startUniqueIdSection("X")); + assertEquals("1_3_X_1", counter.generateUniqueId()); + assertEquals("1_3_X_2",counter.generateUniqueId()); + assertEquals("1_3_X_3",counter.startUniqueIdSection()); + assertEquals("1_3_X_3_1",counter.generateUniqueId()); + assertEquals("1_3_X_3_2",counter.generateUniqueId()); + counter.endUniqueIdSection(); + assertEquals("1_3_X_4",counter.generateUniqueId()); counter.endUniqueIdSection("X"); - Assertions.assertEquals("1_3_Y", counter.startUniqueIdSection("Y")); - Assertions.assertEquals("1_3_Y_1", counter.generateUniqueId()); + assertEquals("1_3_Y", counter.startUniqueIdSection("Y")); + assertEquals("1_3_Y_1", counter.generateUniqueId()); counter.endUniqueIdSection("Y"); - Assertions.assertEquals("1_4",counter.startUniqueIdSection()); + assertEquals("1_4",counter.startUniqueIdSection()); counter.endUniqueIdSection(); - Assertions.assertEquals("1_5", counter.generateUniqueId()); - Assertions.assertEquals("1_6", counter.generateUniqueId()); + assertEquals("1_5", counter.generateUniqueId()); + assertEquals("1_6", counter.generateUniqueId()); counter.endUniqueIdSection(); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/pool/ViewPoolFaceletsTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/pool/ViewPoolFaceletsTestCase.java index 241fb90862..1771973eea 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/pool/ViewPoolFaceletsTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/pool/ViewPoolFaceletsTestCase.java @@ -18,12 +18,14 @@ */ package org.apache.myfaces.view.facelets.pool; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import jakarta.faces.application.ProjectStage; import jakarta.faces.component.UIComponent; import jakarta.faces.component.UIViewRoot; import jakarta.faces.event.PhaseId; import jakarta.faces.render.RenderKitFactory; -import org.junit.jupiter.api.Assertions; import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; import org.apache.myfaces.view.facelets.ViewPoolProcessor; @@ -34,7 +36,7 @@ * * @author lu4242 */ -public class ViewPoolFaceletsTestCase extends AbstractFaceletTestCase +class ViewPoolFaceletsTestCase extends AbstractFaceletTestCase { @Override @@ -69,7 +71,7 @@ protected void setupComponents() throws Exception * @throws Exception */ @Test - public void testDynPageResourceCleanup1() throws Exception + void dynPageResourceCleanup1() throws Exception { facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE); ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); @@ -100,24 +102,24 @@ public void testDynPageResourceCleanup1() throws Exception // the resource should still be there //Assertions.assertEquals(1, oldCount); // The code in MYFACES-3659 reset the component after refresh - Assertions.assertEquals(0, oldCount); + assertEquals(0, oldCount); // Clear the view and synchronize resources ViewStructureMetadata metadata = processor.retrieveViewStructureMetadata(facesContext, root); - Assertions.assertNotNull(metadata); + assertNotNull(metadata); processor.clearTransientAndNonFaceletComponentsForDynamicView(facesContext, root, metadata); // the resource added by state checkA=true should not be there - Assertions.assertEquals(0, headerFacet.getChildCount()); + assertEquals(0, headerFacet.getChildCount()); } - + /** * Check remove component resource added using @ResourceDependency * * @throws Exception */ @Test - public void testDynPageResourceCleanup2() throws Exception + void dynPageResourceCleanup2() throws Exception { facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE); ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); @@ -146,15 +148,15 @@ public void testDynPageResourceCleanup2() throws Exception // the resource should still be there UIComponent headerFacet = root.getFacet("head"); int oldCount = headerFacet.getChildCount(); - Assertions.assertEquals(1, oldCount); + assertEquals(1, oldCount); // Clear the view and synchronize resources ViewStructureMetadata metadata = processor.retrieveViewStructureMetadata(facesContext, root); - Assertions.assertNotNull(metadata); + assertNotNull(metadata); processor.clearTransientAndNonFaceletComponentsForDynamicView(facesContext, root, metadata); // the resource added by state checkA=true should not be there - Assertions.assertEquals(0, headerFacet.getChildCount()); + assertEquals(0, headerFacet.getChildCount()); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/pool/ViewPoolMyFacesRequestTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/pool/ViewPoolMyFacesRequestTestCase.java index 5a9776ea15..ea1f25f222 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/pool/ViewPoolMyFacesRequestTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/pool/ViewPoolMyFacesRequestTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.pool; +import static org.junit.jupiter.api.Assertions.*; + import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -39,10 +41,9 @@ import org.apache.myfaces.view.facelets.pool.impl.ViewPoolImpl; import org.apache.myfaces.view.facelets.tag.faces.ComponentSupport; import org.apache.myfaces.view.facelets.tag.faces.FaceletState; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class ViewPoolMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase +class ViewPoolMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase { protected ExpressionFactory createExpressionFactory() { @@ -72,7 +73,7 @@ protected void setUpWebConfigParams() throws Exception * @throws Exception */ @Test - public void testStaticPageNoForm1() throws Exception + void staticPageNoForm1() throws Exception { Locale locale = null; startViewRequest("/staticPageNoForm.xhtml"); @@ -88,8 +89,8 @@ public void testStaticPageNoForm1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); endRequest(); } @@ -100,7 +101,7 @@ public void testStaticPageNoForm1() throws Exception * @throws Exception */ @Test - public void testStaticPageNoForm1_1() throws Exception + void staticPageNoForm11() throws Exception { Locale locale = null; startViewRequest("/staticPageNoForm.xhtml"); @@ -120,7 +121,7 @@ public void testStaticPageNoForm1_1() throws Exception executeBeforeRender(); executeBuildViewCycle(); - Assertions.assertTrue(facesContext.getViewRoot().getChildCount() > 0); + assertTrue(facesContext.getViewRoot().getChildCount() > 0); UIViewRoot root = new UIViewRoot(); root.setLocale(locale); @@ -131,11 +132,11 @@ public void testStaticPageNoForm1_1() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); // Check it was used. - Assertions.assertNull(entry); + assertNull(entry); } - + @Test - public void testStaticPageNoForm2() throws Exception + void staticPageNoForm2() throws Exception { Locale locale = null; startViewRequest("/staticPageNoForm2.xhtml"); @@ -146,11 +147,11 @@ public void testStaticPageNoForm2() throws Exception executeBuildViewCycle(); UIOutput testjs1_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs"); - Assertions.assertNotNull(testjs1_1); + assertNotNull(testjs1_1); testjs1_1.getAttributes().put("param1", "value1"); List crlist = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(2, crlist.size()); + assertEquals(2, crlist.size()); for(UIComponent comp : crlist) { comp.getAttributes().put("param2", "value2"); @@ -167,18 +168,18 @@ public void testStaticPageNoForm2() throws Exception executeBeforeRender(); executeBuildViewCycle(); - Assertions.assertTrue(facesContext.getViewRoot().getChildCount() > 0); + assertTrue(facesContext.getViewRoot().getChildCount() > 0); UIOutput testjs2_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs"); - Assertions.assertNotNull(testjs2_1); + assertNotNull(testjs2_1); // The state of the component should not be transferred. - Assertions.assertNull(testjs2_1.getAttributes().get("param1")); + assertNull(testjs2_1.getAttributes().get("param1")); List crlist2 = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(2, crlist2.size()); + assertEquals(2, crlist2.size()); for(UIComponent comp : crlist) { - Assertions.assertNull(comp.getAttributes().get("param2")); + assertNull(comp.getAttributes().get("param2")); } UIViewRoot root = new UIViewRoot(); @@ -190,11 +191,11 @@ public void testStaticPageNoForm2() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); // Check it was used. - Assertions.assertNull(entry); - } + assertNull(entry); + } @Test - public void testStaticPage1() throws Exception + void staticPage1() throws Exception { Locale locale = null; startViewRequest("/staticPage.xhtml"); @@ -210,13 +211,13 @@ public void testStaticPage1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); endRequest(); } - + @Test - public void testStaticPage1_1() throws Exception + void staticPage11() throws Exception { Locale locale = null; startViewRequest("/staticPage.xhtml"); @@ -243,20 +244,20 @@ public void testStaticPage1_1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); //Check the component was removed UIForm form2 = (UIForm) entry.getViewRoot().findComponent("mainForm"); - Assertions.assertNotNull(form2); + assertNotNull(form2); UIOutput testComponent2 = (UIOutput) form2.findComponent("testId"); - Assertions.assertNull(testComponent2); + assertNull(testComponent2); endRequest(); } - + @Test - public void testStaticPage1_2() throws Exception + void staticPage12() throws Exception { Locale locale = null; startViewRequest("/staticPage.xhtml"); @@ -283,20 +284,20 @@ public void testStaticPage1_2() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); //Check the component was removed UIForm form2 = (UIForm) entry.getViewRoot().findComponent("mainForm"); - Assertions.assertNotNull(form2); + assertNotNull(form2); UIOutput testComponent2 = (UIOutput) form2.findComponent("testId"); - Assertions.assertNull(testComponent2); + assertNull(testComponent2); endRequest(); } - + @Test - public void testStaticPage1_3() throws Exception + void staticPage13() throws Exception { Locale locale = null; startViewRequest("/staticPage.xhtml"); @@ -323,13 +324,13 @@ public void testStaticPage1_3() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); endRequest(); } - + @Test - public void testStaticPage1_4() throws Exception + void staticPage14() throws Exception { Locale locale = null; startViewRequest("/staticPage.xhtml"); @@ -358,13 +359,13 @@ public void testStaticPage1_4() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); endRequest(); } - + @Test - public void testStaticPage1_5() throws Exception + void staticPage15() throws Exception { Locale locale = null; startViewRequest("/staticPage.xhtml"); @@ -389,7 +390,7 @@ public void testStaticPage1_5() throws Exception executeBuildViewCycle(); //Check if the view scope value is preserved - Assertions.assertEquals("someValue", facesContext.getViewRoot().getViewMap().get("someKey")); + assertEquals("someValue", facesContext.getViewRoot().getViewMap().get("someKey")); facesContext.getViewRoot().getViewMap().put("someKey", "someValue2"); @@ -406,9 +407,9 @@ public void testStaticPage1_5() throws Exception executeBuildViewCycle(); //Check if the view scope value is preserved - Assertions.assertEquals("someValue2", facesContext.getViewRoot().getViewMap().get("someKey")); + assertEquals("someValue2", facesContext.getViewRoot().getViewMap().get("someKey")); - Assertions.assertTrue(facesContext.getViewRoot().getChildCount() > 0); + assertTrue(facesContext.getViewRoot().getChildCount() > 0); executeViewHandlerRender(); executeAfterRender(); @@ -421,14 +422,14 @@ public void testStaticPage1_5() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); endRequest(); - } - + } + @Test - public void testStaticPage1_6() throws Exception + void staticPage16() throws Exception { Locale locale = null; startViewRequest("/staticPage3.xhtml"); @@ -440,7 +441,7 @@ public void testStaticPage1_6() throws Exception executeBuildViewCycle(); // Use view scope - Assertions.assertEquals("someBeforeValue", facesContext.getViewRoot().getViewMap().get("keyBeforeView")); + assertEquals("someBeforeValue", facesContext.getViewRoot().getViewMap().get("keyBeforeView")); facesContext.getViewRoot().getViewMap().put("someKey", "someValue"); UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit"); @@ -456,7 +457,7 @@ public void testStaticPage1_6() throws Exception executeBuildViewCycle(); //Check if the view scope value is preserved - Assertions.assertEquals("someValue", facesContext.getViewRoot().getViewMap().get("someKey")); + assertEquals("someValue", facesContext.getViewRoot().getViewMap().get("someKey")); facesContext.getViewRoot().getViewMap().put("someKey", "someValue2"); @@ -473,9 +474,9 @@ public void testStaticPage1_6() throws Exception executeBuildViewCycle(); //Check if the view scope value is preserved - Assertions.assertEquals("someValue2", facesContext.getViewRoot().getViewMap().get("someKey")); + assertEquals("someValue2", facesContext.getViewRoot().getViewMap().get("someKey")); - Assertions.assertTrue(facesContext.getViewRoot().getChildCount() > 0); + assertTrue(facesContext.getViewRoot().getChildCount() > 0); executeViewHandlerRender(); executeAfterRender(); @@ -488,14 +489,14 @@ public void testStaticPage1_6() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); endRequest(); - } - + } + @Test - public void testStaticPage1_7() throws Exception + void staticPage17() throws Exception { Locale locale = null; startViewRequest("/staticPage3.xhtml"); @@ -519,18 +520,18 @@ public void testStaticPage1_7() throws Exception facesContext.getViewRoot().getViewMap().put("keyBeforeView", "someBeforeValue"); UIViewParameter paramComponent = ViewMetadata.getViewParameters(facesContext.getViewRoot()).iterator().next(); - Assertions.assertNotNull(paramComponent); - Assertions.assertEquals("someId", paramComponent.getValue()); + assertNotNull(paramComponent); + assertEquals("someId", paramComponent.getValue()); executeBeforeRender(); executeBuildViewCycle(); paramComponent = ViewMetadata.getViewParameters(facesContext.getViewRoot()).iterator().next(); - Assertions.assertNotNull(paramComponent); - Assertions.assertEquals("someId", paramComponent.getValue()); + assertNotNull(paramComponent); + assertEquals("someId", paramComponent.getValue()); // Use view scope - Assertions.assertEquals("someBeforeValue", facesContext.getViewRoot().getViewMap().get("keyBeforeView")); + assertEquals("someBeforeValue", facesContext.getViewRoot().getViewMap().get("keyBeforeView")); facesContext.getViewRoot().getViewMap().put("someKey", "someValue"); //Assertions.assertEquals("viewValue", facesContext.getViewRoot().getViewMap().get("viewKey")); @@ -540,10 +541,10 @@ public void testStaticPage1_7() throws Exception executeAfterRender(); endRequest(); - } - + } + @Test - public void testStaticPage2() throws Exception + void staticPage2() throws Exception { Locale locale = null; startViewRequest("/staticPage2.xhtml"); @@ -554,11 +555,11 @@ public void testStaticPage2() throws Exception executeBuildViewCycle(); UIOutput testjs1_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs"); - Assertions.assertNotNull(testjs1_1); + assertNotNull(testjs1_1); testjs1_1.getAttributes().put("param1", "value1"); List crlist = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(2, crlist.size()); + assertEquals(2, crlist.size()); for(UIComponent comp : crlist) { comp.getAttributes().put("param2", "value2"); @@ -576,18 +577,18 @@ public void testStaticPage2() throws Exception executeBeforeRender(); executeBuildViewCycle(); - Assertions.assertTrue(facesContext.getViewRoot().getChildCount() > 0); + assertTrue(facesContext.getViewRoot().getChildCount() > 0); UIOutput testjs2_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs"); - Assertions.assertNotNull(testjs2_1); + assertNotNull(testjs2_1); // The state of the component should not be transferred. - Assertions.assertEquals("value1",testjs2_1.getAttributes().get("param1")); + assertEquals("value1",testjs2_1.getAttributes().get("param1")); List crlist2 = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(2, crlist2.size()); + assertEquals(2, crlist2.size()); for(UIComponent comp : crlist) { - Assertions.assertEquals("value2", comp.getAttributes().get("param2")); + assertEquals("value2", comp.getAttributes().get("param2")); } UIViewRoot root = new UIViewRoot(); @@ -599,11 +600,11 @@ public void testStaticPage2() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); // Check it was used. - Assertions.assertNull(entry); + assertNull(entry); } - + @Test - public void testStaticPageWithViewScope1() throws Exception + void staticPageWithViewScope1() throws Exception { Locale locale = null; startViewRequest("/staticPage.xhtml"); @@ -623,7 +624,7 @@ public void testStaticPageWithViewScope1() throws Exception executeBuildViewCycle(); // Check the ViewMap value is not passed to the view - Assertions.assertNull(facesContext.getViewRoot().getViewMap(false)); + assertNull(facesContext.getViewRoot().getViewMap(false)); // Check the view was used UIViewRoot root = new UIViewRoot(); @@ -633,11 +634,11 @@ public void testStaticPageWithViewScope1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); } - + @Test - public void testStaticPageWithViewScope1_1() throws Exception + void staticPageWithViewScope11() throws Exception { Locale locale = null; startViewRequest("/staticPage.xhtml"); @@ -657,13 +658,13 @@ public void testStaticPageWithViewScope1_1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); endRequest(); } - + @Test - public void testStaticPageWithViewScope2() throws Exception + void staticPageWithViewScope2() throws Exception { Locale locale = null; startViewRequest("/staticPage.xhtml"); @@ -687,18 +688,18 @@ public void testStaticPageWithViewScope2() throws Exception processLifecycleExecute(); // Check the ViewMap is passed to the view - Assertions.assertNotNull(facesContext.getViewRoot().getViewMap(false)); - Assertions.assertEquals("someValue", facesContext.getViewRoot().getViewMap(false).get("viewItem")); + assertNotNull(facesContext.getViewRoot().getViewMap(false)); + assertEquals("someValue", facesContext.getViewRoot().getViewMap(false).get("viewItem")); ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); // Check the view was used ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); } @Test - public void testStaticUIParamPage1() throws Exception + void staticUIParamPage1() throws Exception { Locale locale = null; startViewRequest("/staticUIParamPage1.xhtml"); @@ -714,13 +715,13 @@ public void testStaticUIParamPage1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); endRequest(); } - + @Test - public void testStaticUIParamPage1_1() throws Exception + void staticUIParamPage11() throws Exception { Locale locale = null; startViewRequest("/staticUIParamPage1.xhtml"); @@ -730,12 +731,12 @@ public void testStaticUIParamPage1_1() throws Exception executeBuildViewCycle(); UIOutput outParam1_1 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:paramOut_1"); - Assertions.assertNotNull(outParam1_1); - Assertions.assertEquals("hello_1", outParam1_1.getValue()); + assertNotNull(outParam1_1); + assertEquals("hello_1", outParam1_1.getValue()); UIOutput outParam1_2 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:paramOut_2"); - Assertions.assertNotNull(outParam1_2); - Assertions.assertEquals("hello_2", outParam1_2.getValue()); + assertNotNull(outParam1_2); + assertEquals("hello_2", outParam1_2.getValue()); executeViewHandlerRender(); @@ -752,12 +753,12 @@ public void testStaticUIParamPage1_1() throws Exception executeBuildViewCycle(); UIOutput outParam2_1 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:paramOut_1"); - Assertions.assertNotNull(outParam2_1); - Assertions.assertEquals("hello_1", outParam2_1.getValue()); + assertNotNull(outParam2_1); + assertEquals("hello_1", outParam2_1.getValue()); UIOutput outParam2_2 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:paramOut_2"); - Assertions.assertNotNull(outParam2_2); - Assertions.assertEquals("hello_2", outParam2_2.getValue()); + assertNotNull(outParam2_2); + assertEquals("hello_2", outParam2_2.getValue()); // Check the view was used UIViewRoot root = new UIViewRoot(); @@ -767,7 +768,7 @@ public void testStaticUIParamPage1_1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); executeViewHandlerRender(); @@ -776,9 +777,9 @@ public void testStaticUIParamPage1_1() throws Exception executeAfterRender(); } - + @Test - public void testStaticViewParamPage1() throws Exception + void staticViewParamPage1() throws Exception { Locale locale = null; startViewRequest("/staticViewParamPage1.xhtml"); @@ -794,13 +795,13 @@ public void testStaticViewParamPage1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); endRequest(); } - + @Test - public void testStaticViewParamPage1_1() throws Exception + void staticViewParamPage11() throws Exception { Locale locale = null; startViewRequest("/staticViewParamPage1.xhtml"); @@ -810,7 +811,7 @@ public void testStaticViewParamPage1_1() throws Exception executeBuildViewCycle(); UIOutput testId1_1 = (UIOutput) facesContext.getViewRoot().findComponent("testId"); - Assertions.assertNotNull(testId1_1); + assertNotNull(testId1_1); testId1_1.getAttributes().put("param1", "value1"); executeViewHandlerRender(); @@ -825,8 +826,8 @@ public void testStaticViewParamPage1_1() throws Exception executeBuildViewCycle(); UIOutput testId2_1 = (UIOutput) facesContext.getViewRoot().findComponent("testId"); - Assertions.assertNotNull(testId2_1); - Assertions.assertNull(testId2_1.getAttributes().get("param1")); + assertNotNull(testId2_1); + assertNull(testId2_1.getAttributes().get("param1")); // Check the view was used UIViewRoot root = new UIViewRoot(); @@ -836,7 +837,7 @@ public void testStaticViewParamPage1_1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); executeViewHandlerRender(); @@ -844,7 +845,7 @@ public void testStaticViewParamPage1_1() throws Exception } @Test - public void testStaticViewParamPage1_2() throws Exception + void staticViewParamPage12() throws Exception { Locale locale = null; startViewRequest("/staticViewParamPage1.xhtml"); @@ -854,7 +855,7 @@ public void testStaticViewParamPage1_2() throws Exception executeBuildViewCycle(); UIOutput testId1_1 = (UIOutput) facesContext.getViewRoot().findComponent("testId"); - Assertions.assertNotNull(testId1_1); + assertNotNull(testId1_1); // With the line below, we put something into the state. The idea is everything inside // metadata facet should not be taken into account by the view pool testId1_1.getAttributes().put("param1", "value1"); @@ -870,16 +871,16 @@ public void testStaticViewParamPage1_2() throws Exception processLifecycleExecute(); UIOutput testId2_1 = (UIOutput) facesContext.getViewRoot().findComponent("testId"); - Assertions.assertNotNull(testId2_1); + assertNotNull(testId2_1); // Check the state is correctly restored. - Assertions.assertEquals("value1", testId2_1.getAttributes().get("param1")); + assertEquals("value1", testId2_1.getAttributes().get("param1")); executeBuildViewCycle(); UIOutput testId3_1 = (UIOutput) facesContext.getViewRoot().findComponent("testId"); - Assertions.assertNotNull(testId3_1); + assertNotNull(testId3_1); // Check the state is correctly restored. - Assertions.assertEquals("value1", testId3_1.getAttributes().get("param1")); + assertEquals("value1", testId3_1.getAttributes().get("param1")); // Check the view was used UIViewRoot root = new UIViewRoot(); @@ -889,15 +890,15 @@ public void testStaticViewParamPage1_2() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); executeViewHandlerRender(); executeAfterRender(); } - + @Test - public void testDynamicPage1() throws Exception + void dynamicPage1() throws Exception { Locale locale = null; startViewRequest("/dynPage1.xhtml"); @@ -921,13 +922,13 @@ public void testDynamicPage1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popDynamicStructureView(facesContext, root, faceletState); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); endRequest(); } - + @Test - public void testDynamicPage1_1() throws Exception + void dynamicPage11() throws Exception { Locale locale = null; startViewRequest("/dynPage1.xhtml"); @@ -957,20 +958,20 @@ public void testDynamicPage1_1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popDynamicStructureView(facesContext, root, faceletState); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); //Check the component was removed UIForm form2 = (UIForm) entry.getViewRoot().findComponent("mainForm"); - Assertions.assertNotNull(form2); + assertNotNull(form2); UIOutput testComponent2 = (UIOutput) form2.findComponent("testId"); - Assertions.assertNull(testComponent2); + assertNull(testComponent2); endRequest(); } @Test - public void testDynamicPage1_2() throws Exception + void dynamicPage12() throws Exception { Locale locale = null; startViewRequest("/dynPage1.xhtml"); @@ -989,8 +990,8 @@ public void testDynamicPage1_2() throws Exception processLifecycleExecute(); // Check the ViewMap is passed to the view - Assertions.assertNotNull(facesContext.getViewRoot().getViewMap(false)); - Assertions.assertEquals("someValue", facesContext.getViewRoot().getViewMap(false).get("viewItem")); + assertNotNull(facesContext.getViewRoot().getViewMap(false)); + assertEquals("someValue", facesContext.getViewRoot().getViewMap(false).get("viewItem")); FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get( ComponentSupport.FACELET_STATE_INSTANCE); @@ -1004,13 +1005,13 @@ public void testDynamicPage1_2() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); // Check the view was used ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState); - Assertions.assertNull(entry3); + assertNull(entry3); } - + @Test - public void testStaticPageLocale1() throws Exception + void staticPageLocale1() throws Exception { Locale locale = null; startViewRequest("/staticPageLocale1.xhtml"); @@ -1018,7 +1019,7 @@ public void testStaticPageLocale1() throws Exception executeBeforeRender(); executeBuildViewCycle(); locale = facesContext.getViewRoot().getLocale(); - Assertions.assertEquals(Locale.US, locale); + assertEquals(Locale.US, locale); executeViewHandlerRender(); @@ -1032,19 +1033,19 @@ public void testStaticPageLocale1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); endRequest(); } - + @Test - public void testStaticPageLocale1_1() throws Exception + void staticPageLocale11() throws Exception { Locale locale = null; startViewRequest("/staticPageLocale1.xhtml"); processLifecycleExecute(); locale = facesContext.getViewRoot().getLocale(); - Assertions.assertEquals(Locale.US, locale); + assertEquals(Locale.US, locale); executeBuildViewCycle(); executeViewHandlerRender(); @@ -1065,22 +1066,22 @@ public void testStaticPageLocale1_1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); } - + /** * Check if the locale changes, the view IS NOT reused. * * @throws Exception */ @Test - public void testStaticPageLocale1_2() throws Exception + void staticPageLocale12() throws Exception { Locale locale = null; startViewRequest("/staticPageLocale1.xhtml"); processLifecycleExecute(); locale = facesContext.getViewRoot().getLocale(); - Assertions.assertEquals(Locale.US, locale); + assertEquals(Locale.US, locale); executeBuildViewCycle(); executeViewHandlerRender(); @@ -1095,7 +1096,7 @@ public void testStaticPageLocale1_2() throws Exception startViewRequest("/staticPageLocale1.xhtml"); processLifecycleExecute(); locale = facesContext.getViewRoot().getLocale(); - Assertions.assertEquals(Locale.UK, locale); + assertEquals(Locale.UK, locale); executeBuildViewCycle(); // Check the view with Locale.US was not used @@ -1106,11 +1107,11 @@ public void testStaticPageLocale1_2() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry2); + assertNotNull(entry2); } @Test - public void testStaticPageContract1() throws Exception + void staticPageContract1() throws Exception { Locale locale = null; startViewRequest("/staticPageContract1.xhtml"); @@ -1130,13 +1131,13 @@ public void testStaticPageContract1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); endRequest(); } - + @Test - public void testStaticPageContract1_1() throws Exception + void staticPageContract11() throws Exception { Locale locale = null; startViewRequest("/staticPageContract1.xhtml"); @@ -1162,16 +1163,16 @@ public void testStaticPageContract1_1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); } - + /** * Check if the locale changes, the view IS NOT reused. * * @throws Exception */ @Test - public void testStaticPageContract1_2() throws Exception + void staticPageContract12() throws Exception { Locale locale = null; startViewRequest("/staticPageContract1.xhtml"); @@ -1204,11 +1205,11 @@ public void testStaticPageContract1_2() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry2); + assertNotNull(entry2); } - + @Test - public void testDynPageResource1() throws Exception + void dynPageResource1() throws Exception { Locale locale = null; startViewRequest("/dynPageResource.xhtml"); @@ -1231,11 +1232,11 @@ public void testDynPageResource1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry1 = viewPool.popDynamicStructureView(facesContext, root, faceletState); - Assertions.assertNotNull(entry1); + assertNotNull(entry1); } - + @Test - public void testDynPageResource1_1() throws Exception + void dynPageResource11() throws Exception { Locale locale = null; startViewRequest("/dynPageResource.xhtml"); @@ -1246,11 +1247,11 @@ public void testDynPageResource1_1() throws Exception executeBuildViewCycle(); UIOutput testjs1_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs"); - Assertions.assertNotNull(testjs1_1); + assertNotNull(testjs1_1); testjs1_1.getAttributes().put("param1", "value1"); List crlist = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(2, crlist.size()); + assertEquals(2, crlist.size()); for(UIComponent comp : crlist) { comp.getAttributes().put("param2", "value2"); @@ -1268,18 +1269,18 @@ public void testDynPageResource1_1() throws Exception executeBeforeRender(); executeBuildViewCycle(); - Assertions.assertTrue(facesContext.getViewRoot().getChildCount() > 0); + assertTrue(facesContext.getViewRoot().getChildCount() > 0); UIOutput testjs2_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs"); - Assertions.assertNotNull(testjs2_1); + assertNotNull(testjs2_1); // The state of the component should not be transferred. - Assertions.assertEquals("value1",testjs2_1.getAttributes().get("param1")); + assertEquals("value1",testjs2_1.getAttributes().get("param1")); List crlist2 = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(2, crlist2.size()); + assertEquals(2, crlist2.size()); for(UIComponent comp : crlist) { - Assertions.assertEquals("value2", comp.getAttributes().get("param2")); + assertEquals("value2", comp.getAttributes().get("param2")); } UIViewRoot root = new UIViewRoot(); @@ -1291,11 +1292,11 @@ public void testDynPageResource1_1() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); // Check it was used. - Assertions.assertNull(entry); + assertNull(entry); } - + @Test - public void testDynPageResource2() throws Exception + void dynPageResource2() throws Exception { Locale locale = null; @@ -1323,11 +1324,11 @@ public void testDynPageResource2() throws Exception executeBuildViewCycle(); UIOutput testjs1_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs"); - Assertions.assertNotNull(testjs1_1); + assertNotNull(testjs1_1); testjs1_1.getAttributes().put("param1", "value1"); List crlist = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(2, crlist.size()); + assertEquals(2, crlist.size()); for(UIComponent comp : crlist) { comp.getAttributes().put("param2", "value2"); @@ -1345,12 +1346,12 @@ public void testDynPageResource2() throws Exception processLifecycleExecute(); UIOutput testjs2_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs"); - Assertions.assertNotNull(testjs2_1); + assertNotNull(testjs2_1); // The state of the component should not be transferred. - Assertions.assertEquals("value1",testjs2_1.getAttributes().get("param1")); + assertEquals("value1",testjs2_1.getAttributes().get("param1")); List crlist2 = facesContext.getViewRoot().getComponentResources(facesContext, "head"); - Assertions.assertEquals(2, crlist2.size()); + assertEquals(2, crlist2.size()); /* Resource dependency components do not preserve state for(UIComponent comp : crlist) @@ -1370,11 +1371,11 @@ public void testDynPageResource2() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); // Check it was used. - Assertions.assertNull(entry); + assertNull(entry); } - + @Test - public void testStaticPageBinding1() throws Exception + void staticPageBinding1() throws Exception { Locale locale = null; startViewRequest("/staticPageBinding1.xhtml"); @@ -1384,7 +1385,7 @@ public void testStaticPageBinding1() throws Exception executeBuildViewCycle(); UIPanel panel1 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel1"); - Assertions.assertNotNull(panel1); + assertNotNull(panel1); executeViewHandlerRender(); executeAfterRender(); @@ -1397,13 +1398,13 @@ public void testStaticPageBinding1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); endRequest(); } - + @Test - public void testStaticPageBinding1_1() throws Exception + void staticPageBinding11() throws Exception { Locale locale = null; startViewRequest("/staticPageBinding1.xhtml"); @@ -1414,7 +1415,7 @@ public void testStaticPageBinding1_1() throws Exception UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit"); UIPanel panel1 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel1"); - Assertions.assertNotNull(panel1); + assertNotNull(panel1); executeViewHandlerRender(); executeAfterRender(); @@ -1424,7 +1425,7 @@ public void testStaticPageBinding1_1() throws Exception processLifecycleExecute(); UIPanel panel2_1 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel1"); - Assertions.assertNotNull(panel2_1); + assertNotNull(panel2_1); FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get( ComponentSupport.FACELET_STATE_INSTANCE); @@ -1438,14 +1439,14 @@ public void testStaticPageBinding1_1() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); // Check the view was used ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState); - Assertions.assertNull(entry3); + assertNull(entry3); } - + @Test - public void testStaticPageBinding2() throws Exception + void staticPageBinding2() throws Exception { Locale locale = null; startViewRequest("/staticPageBinding2.xhtml"); @@ -1456,9 +1457,9 @@ public void testStaticPageBinding2() throws Exception executeBuildViewCycle(); UIPanel panel1_2 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel2"); - Assertions.assertNotNull(panel1_2); - Assertions.assertEquals(1, panel1_2.getChildCount()); - Assertions.assertEquals("added component through binding", + assertNotNull(panel1_2); + assertEquals(1, panel1_2.getChildCount()); + assertEquals("added component through binding", panel1_2.getChildren().get(0).getAttributes().get("value")); executeViewHandlerRender(); @@ -1472,13 +1473,13 @@ public void testStaticPageBinding2() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); endRequest(); } - + @Test - public void testStaticPageBinding2_1() throws Exception + void staticPageBinding21() throws Exception { Locale locale = null; startViewRequest("/staticPageBinding2.xhtml"); @@ -1488,9 +1489,9 @@ public void testStaticPageBinding2_1() throws Exception executeBuildViewCycle(); UIPanel panel1_2 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel2"); - Assertions.assertNotNull(panel1_2); - Assertions.assertEquals(1, panel1_2.getChildCount()); - Assertions.assertEquals("added component through binding", + assertNotNull(panel1_2); + assertEquals(1, panel1_2.getChildCount()); + assertEquals("added component through binding", panel1_2.getChildren().get(0).getAttributes().get("value")); UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit"); @@ -1503,9 +1504,9 @@ public void testStaticPageBinding2_1() throws Exception processLifecycleExecute(); UIPanel panel2_2 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel2"); - Assertions.assertNotNull(panel2_2); - Assertions.assertEquals(1, panel2_2.getChildCount()); - Assertions.assertEquals("added component through binding", + assertNotNull(panel2_2); + assertEquals(1, panel2_2.getChildCount()); + assertEquals("added component through binding", panel2_2.getChildren().get(0).getAttributes().get("value")); FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get( @@ -1520,13 +1521,13 @@ public void testStaticPageBinding2_1() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); // Check the view was used ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState); - Assertions.assertNull(entry3); + assertNull(entry3); } - + @Test - public void testStaticPageBinding3() throws Exception + void staticPageBinding3() throws Exception { Locale locale = null; startViewRequest("/staticPageBinding3.xhtml"); @@ -1537,9 +1538,9 @@ public void testStaticPageBinding3() throws Exception executeBuildViewCycle(); UIPanel panel1_3 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel3"); - Assertions.assertNotNull(panel1_3); - Assertions.assertEquals(1, panel1_3.getChildCount()); - Assertions.assertEquals("added component through binding", + assertNotNull(panel1_3); + assertEquals(1, panel1_3.getChildCount()); + assertEquals("added component through binding", panel1_3.getChildren().get(0).getAttributes().get("value")); executeViewHandlerRender(); @@ -1553,13 +1554,13 @@ public void testStaticPageBinding3() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); endRequest(); } @Test - public void testStaticPageBinding3_1() throws Exception + void staticPageBinding31() throws Exception { Locale locale = null; startViewRequest("/staticPageBinding3.xhtml"); @@ -1569,9 +1570,9 @@ public void testStaticPageBinding3_1() throws Exception executeBuildViewCycle(); UIPanel panel1_3 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel3"); - Assertions.assertNotNull(panel1_3); - Assertions.assertEquals(1, panel1_3.getChildCount()); - Assertions.assertEquals("added component through binding", + assertNotNull(panel1_3); + assertEquals(1, panel1_3.getChildCount()); + assertEquals("added component through binding", panel1_3.getChildren().get(0).getAttributes().get("value")); UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit"); @@ -1584,9 +1585,9 @@ public void testStaticPageBinding3_1() throws Exception processLifecycleExecute(); UIPanel panel2_3 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel3"); - Assertions.assertNotNull(panel2_3); - Assertions.assertEquals(1, panel2_3.getChildCount()); - Assertions.assertEquals("added component through binding", + assertNotNull(panel2_3); + assertEquals(1, panel2_3.getChildCount()); + assertEquals("added component through binding", panel2_3.getChildren().get(0).getAttributes().get("value")); FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get( @@ -1601,13 +1602,13 @@ public void testStaticPageBinding3_1() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); // Check the view was used ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState); - Assertions.assertNull(entry3); + assertNull(entry3); } - + @Test - public void testStaticPageBinding4() throws Exception + void staticPageBinding4() throws Exception { Locale locale = null; startViewRequest("/staticPageBinding4.xhtml"); @@ -1618,8 +1619,8 @@ public void testStaticPageBinding4() throws Exception executeBuildViewCycle(); UIPanel panel1_4 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel4"); - Assertions.assertNotNull(panel1_4); - Assertions.assertEquals(1, panel1_4.getChildCount()); + assertNotNull(panel1_4); + assertEquals(1, panel1_4.getChildCount()); executeViewHandlerRender(); executeAfterRender(); @@ -1632,13 +1633,13 @@ public void testStaticPageBinding4() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); endRequest(); } - + @Test - public void testStaticPageBinding4_1() throws Exception + void staticPageBinding41() throws Exception { Locale locale = null; startViewRequest("/staticPageBinding4.xhtml"); @@ -1648,8 +1649,8 @@ public void testStaticPageBinding4_1() throws Exception executeBuildViewCycle(); UIPanel panel1_4 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel4"); - Assertions.assertNotNull(panel1_4); - Assertions.assertEquals(1, panel1_4.getChildCount()); + assertNotNull(panel1_4); + assertEquals(1, panel1_4.getChildCount()); UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit"); @@ -1661,8 +1662,8 @@ public void testStaticPageBinding4_1() throws Exception processLifecycleExecute(); UIPanel panel2_4 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel4"); - Assertions.assertNotNull(panel2_4); - Assertions.assertEquals(1, panel2_4.getChildCount()); + assertNotNull(panel2_4); + assertEquals(1, panel2_4.getChildCount()); FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get( ComponentSupport.FACELET_STATE_INSTANCE); @@ -1676,13 +1677,13 @@ public void testStaticPageBinding4_1() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); // Check the view was used ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState); - Assertions.assertNull(entry3); + assertNull(entry3); } - + @Test - public void testStaticPageBindingValidator1() throws Exception + void staticPageBindingValidator1() throws Exception { Locale locale = null; startViewRequest("/staticPageBindingValidator1.xhtml"); @@ -1702,13 +1703,13 @@ public void testStaticPageBindingValidator1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult()); endRequest(); } - + @Test - public void testStaticPageBindingValidator1_1() throws Exception + void staticPageBindingValidator11() throws Exception { Locale locale = null; startViewRequest("/staticPageBindingValidator1.xhtml"); @@ -1737,12 +1738,12 @@ public void testStaticPageBindingValidator1_1() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); // Check the view was used ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState); - Assertions.assertNull(entry3); + assertNull(entry3); } - + /** * The existence of a converter that implements StateHolder makes the view * not reseteable. This means the view is considered partial and force @@ -1751,7 +1752,7 @@ public void testStaticPageBindingValidator1_1() throws Exception * @throws Exception T */ @Test - public void testStaticPageStateHolderConverter1() throws Exception + void staticPageStateHolderConverter1() throws Exception { Locale locale = null; startViewRequest("/staticPageStateHolderConverter1.xhtml"); @@ -1771,13 +1772,13 @@ public void testStaticPageStateHolderConverter1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); endRequest(); } - + @Test - public void testStaticPageStateHolderConverter1_1() throws Exception + void staticPageStateHolderConverter11() throws Exception { Locale locale = null; startViewRequest("/staticPageStateHolderConverter1.xhtml"); @@ -1806,12 +1807,12 @@ public void testStaticPageStateHolderConverter1_1() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); // Check the view was used ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState); - Assertions.assertNull(entry3); + assertNull(entry3); } - + /** * The existence of a converter that implements StateHolder makes the view * not reseteable. This means the view is considered partial and force @@ -1820,7 +1821,7 @@ public void testStaticPageStateHolderConverter1_1() throws Exception * @throws Exception T */ @Test - public void testStaticPageStateHolderConverter2() throws Exception + void staticPageStateHolderConverter2() throws Exception { Locale locale = null; startViewRequest("/staticPageStateHolderConverter2.xhtml"); @@ -1840,13 +1841,13 @@ public void testStaticPageStateHolderConverter2() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); endRequest(); } - + @Test - public void testStaticPageStateHolderConverter2_1() throws Exception + void staticPageStateHolderConverter21() throws Exception { Locale locale = null; startViewRequest("/staticPageStateHolderConverter2.xhtml"); @@ -1875,14 +1876,14 @@ public void testStaticPageStateHolderConverter2_1() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); // Check the view was used ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState); - Assertions.assertNull(entry3); + assertNull(entry3); } - + @Test - public void testPartialPage1() throws Exception + void partialPage1() throws Exception { Locale locale = null; startViewRequest("/partialPage1.xhtml"); @@ -1910,13 +1911,13 @@ public void testPartialPage1() throws Exception ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext); ViewPool viewPool = processor.getViewPool(facesContext, root); ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNotNull(entry); - Assertions.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); + assertNotNull(entry); + assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult()); endRequest(); } - + @Test - public void testPartialPage1_1() throws Exception + void partialPage11() throws Exception { Locale locale = null; startViewRequest("/partialPage1.xhtml"); @@ -1952,14 +1953,14 @@ public void testPartialPage1_1() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); // Check the view was used ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState); - Assertions.assertNull(entry3); + assertNull(entry3); } - + @Test - public void testPartialPage1_2() throws Exception + void partialPage12() throws Exception { Locale locale = null; startViewRequest("/partialPage1.xhtml"); @@ -1985,7 +1986,7 @@ public void testPartialPage1_2() throws Exception processLifecycleExecute(); - Assertions.assertEquals("someValue", facesContext.getViewRoot().getViewMap().get("someKey")); + assertEquals("someValue", facesContext.getViewRoot().getViewMap().get("someKey")); FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get( ComponentSupport.FACELET_STATE_INSTANCE); @@ -1999,9 +2000,9 @@ public void testPartialPage1_2() throws Exception ViewPool viewPool = processor.getViewPool(facesContext, root); // Check the view was used ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root); - Assertions.assertNull(entry2); + assertNull(entry2); ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState); - Assertions.assertNull(entry3); + assertNull(entry3); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java index b1b55f215f..b4699d4aec 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.pss.acid; +import static org.junit.jupiter.api.Assertions.*; + import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -49,7 +51,6 @@ import org.apache.myfaces.view.facelets.pss.acid.managed.ForEachInputSessionBean; import org.apache.myfaces.view.facelets.pss.acid.managed.ResourceDependencyBean; import org.apache.myfaces.view.facelets.pss.acid.managed.AcidTestBean; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class AcidMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase @@ -67,17 +68,17 @@ protected void setUpWebConfigParams() throws Exception protected ExpressionFactory createExpressionFactory() { return new org.apache.el.ExpressionFactoryImpl(); - } - + } + @Test - public void testIndex() throws Exception + void index() throws Exception { startViewRequest("/index.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); - Assertions.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value")); + assertEquals(1, comp.getChildCount()); + assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value")); /* MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); @@ -95,8 +96,8 @@ public void testIndex() throws Exception processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); - Assertions.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value")); + assertEquals(1, comp.getChildCount()); + assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value")); /* MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); Assertions.assertTrue(new String(writer2.content()).contains( @@ -110,17 +111,17 @@ public void testIndex() throws Exception //System.out.println(writer2.content()); endRequest(); } - + @Test - public void testInput() throws Exception + void input() throws Exception { startViewRequest("/input.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); - Assertions.assertEquals(1, comp.getChildren().get(0).getChildCount()); - Assertions.assertEquals("mainForm:input", comp.getChildren().get(0).getChildren().get(0).getClientId(facesContext)); + assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildren().get(0).getChildCount()); + assertEquals("mainForm:input", comp.getChildren().get(0).getChildren().get(0).getClientId(facesContext)); /* MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); Assertions.assertTrue(new String(writer1.content()).contains( @@ -139,9 +140,9 @@ public void testInput() throws Exception processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); - Assertions.assertEquals(1, comp.getChildren().get(0).getChildCount()); - Assertions.assertEquals("mainForm:input", comp.getChildren().get(0).getChildren().get(0).getClientId(facesContext)); + assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildren().get(0).getChildCount()); + assertEquals("mainForm:input", comp.getChildren().get(0).getChildren().get(0).getClientId(facesContext)); /* MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); @@ -157,61 +158,61 @@ public void testInput() throws Exception "
TestComponent::encodeEnd
")); */ } - + @Test - public void testRecursive() throws Exception + void recursive() throws Exception { startViewRequest("/recursive.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(2, comp.getChildCount()); - Assertions.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value")); - Assertions.assertEquals(1, comp.getChildren().get(1).getChildCount()); - Assertions.assertEquals("Dynamically added child", comp.getChildren().get(1).getChildren().get(0).getAttributes().get("value")); + assertEquals(2, comp.getChildCount()); + assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value")); + assertEquals(1, comp.getChildren().get(1).getChildCount()); + assertEquals("Dynamically added child", comp.getChildren().get(1).getChildren().get(0).getAttributes().get("value")); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(2, comp.getChildCount()); - Assertions.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value")); - Assertions.assertEquals(1, comp.getChildren().get(1).getChildCount()); - Assertions.assertEquals("Dynamically added child", comp.getChildren().get(1).getChildren().get(0).getAttributes().get("value")); + assertEquals(2, comp.getChildCount()); + assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value")); + assertEquals(1, comp.getChildren().get(1).getChildCount()); + assertEquals("Dynamically added child", comp.getChildren().get(1).getChildren().get(0).getAttributes().get("value")); endRequest(); } - + @Test - public void testStable() throws Exception + void stable() throws Exception { startViewRequest("/stable.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(3, comp.getChildCount()); - Assertions.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value")); - Assertions.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value")); - Assertions.assertEquals("text3", comp.getChildren().get(2).getId()); + assertEquals(3, comp.getChildCount()); + assertEquals("1", comp.getChildren().get(0).getAttributes().get("value")); + assertEquals("2", comp.getChildren().get(1).getAttributes().get("value")); + assertEquals("text3", comp.getChildren().get(2).getId()); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(3, comp.getChildCount()); - Assertions.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value")); - Assertions.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value")); - Assertions.assertEquals("text3", comp.getChildren().get(2).getId()); + assertEquals(3, comp.getChildCount()); + assertEquals("1", comp.getChildren().get(0).getAttributes().get("value")); + assertEquals("2", comp.getChildren().get(1).getAttributes().get("value")); + assertEquals("text3", comp.getChildren().get(2).getId()); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(3, comp.getChildCount()); - Assertions.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value")); - Assertions.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value")); - Assertions.assertEquals("text3", comp.getChildren().get(2).getId()); + assertEquals(3, comp.getChildCount()); + assertEquals("1", comp.getChildren().get(0).getAttributes().get("value")); + assertEquals("2", comp.getChildren().get(1).getAttributes().get("value")); + assertEquals("text3", comp.getChildren().get(2).getId()); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); UIInput input = (UIInput) facesContext.getViewRoot().findComponent("mainForm:text3"); @@ -220,76 +221,76 @@ public void testStable() throws Exception processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(3, comp.getChildCount()); - Assertions.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value")); - Assertions.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value")); - Assertions.assertEquals("text3", comp.getChildren().get(2).getId()); + assertEquals(3, comp.getChildCount()); + assertEquals("1", comp.getChildren().get(0).getAttributes().get("value")); + assertEquals("2", comp.getChildren().get(1).getAttributes().get("value")); + assertEquals("text3", comp.getChildren().get(2).getId()); } - + @Test - public void testTable() throws Exception + void table() throws Exception { startViewRequest("/table.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); HtmlDataTable dataTable = (HtmlDataTable) comp.getChildren().get(0); - Assertions.assertEquals(1, dataTable.getChildCount()); + assertEquals(1, dataTable.getChildCount()); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); dataTable = (HtmlDataTable) comp.getChildren().get(0); - Assertions.assertEquals(1, dataTable.getChildCount()); + assertEquals(1, dataTable.getChildCount()); } - + @Test - public void testToggle() throws Exception + void toggle() throws Exception { startViewRequest("/toggle.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(2, comp.getChildCount()); - Assertions.assertEquals("Manually added child 2
", comp.getChildren().get(0).getAttributes().get("value")); - Assertions.assertEquals("Manually added child 1
", comp.getChildren().get(1).getAttributes().get("value")); + assertEquals(2, comp.getChildCount()); + assertEquals("Manually added child 2
", comp.getChildren().get(0).getAttributes().get("value")); + assertEquals("Manually added child 1
", comp.getChildren().get(1).getAttributes().get("value")); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(2, comp.getChildCount()); - Assertions.assertEquals("Manually added child 1
", comp.getChildren().get(0).getAttributes().get("value")); - Assertions.assertEquals("Manually added child 2
", comp.getChildren().get(1).getAttributes().get("value")); + assertEquals(2, comp.getChildCount()); + assertEquals("Manually added child 1
", comp.getChildren().get(0).getAttributes().get("value")); + assertEquals("Manually added child 2
", comp.getChildren().get(1).getAttributes().get("value")); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(2, comp.getChildCount()); - Assertions.assertEquals("Manually added child 2
", comp.getChildren().get(0).getAttributes().get("value")); - Assertions.assertEquals("Manually added child 1
", comp.getChildren().get(1).getAttributes().get("value")); + assertEquals(2, comp.getChildCount()); + assertEquals("Manually added child 2
", comp.getChildren().get(0).getAttributes().get("value")); + assertEquals("Manually added child 1
", comp.getChildren().get(1).getAttributes().get("value")); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(2, comp.getChildCount()); - Assertions.assertEquals("Manually added child 1
", comp.getChildren().get(0).getAttributes().get("value")); - Assertions.assertEquals("Manually added child 2
", comp.getChildren().get(1).getAttributes().get("value")); + assertEquals(2, comp.getChildCount()); + assertEquals("Manually added child 1
", comp.getChildren().get(0).getAttributes().get("value")); + assertEquals("Manually added child 2
", comp.getChildren().get(1).getAttributes().get("value")); } - + @Test - public void testInclude() throws Exception + void include() throws Exception { startViewRequest("/include.xhtml"); processLifecycleExecute(); @@ -306,11 +307,11 @@ public void testInclude() throws Exception processLifecycleExecute(); //Check it is restored component = facesContext.getViewRoot().findComponent("mainForm:component1"); - Assertions.assertEquals("test1", component.getAttributes().get("test")); + assertEquals("test1", component.getAttributes().get("test")); renderResponse(); //Check buildView does not destroy the state component = facesContext.getViewRoot().findComponent("mainForm:component1"); - Assertions.assertEquals("test1", component.getAttributes().get("test")); + assertEquals("test1", component.getAttributes().get("test")); //Go to page2 button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2"); @@ -319,7 +320,7 @@ public void testInclude() throws Exception processLifecycleExecute(); component = facesContext.getViewRoot().findComponent("mainForm:component1"); //Check it is restored - Assertions.assertEquals("test1", component.getAttributes().get("test")); + assertEquals("test1", component.getAttributes().get("test")); //Build the view facesContext.getApplication().getViewHandler().getViewDeclarationLanguage( @@ -327,13 +328,13 @@ public void testInclude() throws Exception //Check the page was changed and the state discarded, because it is a different component. component = facesContext.getViewRoot().findComponent("mainForm:component2"); - Assertions.assertNull(component.getAttributes().get("test")); + assertNull(component.getAttributes().get("test")); //Set a token to save on the state as delta component.getAttributes().put("test", "test2"); renderResponse(); component = facesContext.getViewRoot().findComponent("mainForm:component2"); - Assertions.assertEquals("test2", component.getAttributes().get("test")); + assertEquals("test2", component.getAttributes().get("test")); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2"); client.submit(button); @@ -341,8 +342,8 @@ public void testInclude() throws Exception processLifecycleExecute(); component = facesContext.getViewRoot().findComponent("mainForm:component2"); //Check it is restored - Assertions.assertNotNull(component); - Assertions.assertEquals("test2", component.getAttributes().get("test")); + assertNotNull(component); + assertEquals("test2", component.getAttributes().get("test")); //Build the view facesContext.getApplication().getViewHandler().getViewDeclarationLanguage( @@ -350,7 +351,7 @@ public void testInclude() throws Exception //Check buildView does not destroy the state component = facesContext.getViewRoot().findComponent("mainForm:component2"); - Assertions.assertEquals("test2", component.getAttributes().get("test")); + assertEquals("test2", component.getAttributes().get("test")); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2"); client.submit(button); @@ -358,7 +359,7 @@ public void testInclude() throws Exception processLifecycleExecute(); component = facesContext.getViewRoot().findComponent("mainForm:component2"); //Check it is restored - Assertions.assertEquals("test2", component.getAttributes().get("test")); + assertEquals("test2", component.getAttributes().get("test")); } /** @@ -368,7 +369,7 @@ public void testInclude() throws Exception * @throws Exception */ @Test - public void testInclude2() throws Exception + void include2() throws Exception { startViewRequest("/include.xhtml"); processLifecycleExecute(); @@ -377,7 +378,7 @@ public void testInclude2() throws Exception facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot()); //Set a token to save on the state as delta UIComponent component = facesContext.getViewRoot().findComponent("mainForm:component1"); - Assertions.assertNotNull(component); + assertNotNull(component); renderResponse(); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page1"); @@ -386,11 +387,11 @@ public void testInclude2() throws Exception processLifecycleExecute(); //Check it is restored component = facesContext.getViewRoot().findComponent("mainForm:component1"); - Assertions.assertNotNull(component); + assertNotNull(component); renderResponse(); //Check buildView does not destroy the state component = facesContext.getViewRoot().findComponent("mainForm:component1"); - Assertions.assertNotNull(component); + assertNotNull(component); //Go to page2 button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2"); @@ -399,7 +400,7 @@ public void testInclude2() throws Exception processLifecycleExecute(); component = facesContext.getViewRoot().findComponent("mainForm:component1"); //Check it is restored - Assertions.assertNotNull(component); + assertNotNull(component); //Build the view facesContext.getApplication().getViewHandler().getViewDeclarationLanguage( @@ -407,11 +408,11 @@ public void testInclude2() throws Exception //Check the page was changed and the state discarded, because it is a different component. component = facesContext.getViewRoot().findComponent("mainForm:component2"); - Assertions.assertNotNull(component); + assertNotNull(component); renderResponse(); component = facesContext.getViewRoot().findComponent("mainForm:component2"); - Assertions.assertNotNull(component); + assertNotNull(component); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2"); client.submit(button); @@ -419,7 +420,7 @@ public void testInclude2() throws Exception processLifecycleExecute(); component = facesContext.getViewRoot().findComponent("mainForm:component2"); //Check it is restored - Assertions.assertNotNull(component); + assertNotNull(component); //Build the view facesContext.getApplication().getViewHandler().getViewDeclarationLanguage( @@ -427,7 +428,7 @@ public void testInclude2() throws Exception //Check buildView does not destroy the state component = facesContext.getViewRoot().findComponent("mainForm:component2"); - Assertions.assertNotNull(component); + assertNotNull(component); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2"); client.submit(button); @@ -435,9 +436,9 @@ public void testInclude2() throws Exception processLifecycleExecute(); component = facesContext.getViewRoot().findComponent("mainForm:component2"); //Check it is restored - Assertions.assertNotNull(component); + assertNotNull(component); } - + /** * Check if a dynamic subtree can be created from a binding property, and if it * will be preserved across request. @@ -456,52 +457,52 @@ public void testInclude2() throws Exception * @throws Exception */ @Test - public void testComponentBinding() throws Exception + void componentBinding() throws Exception { startViewRequest("/componentBinding1.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("panel"); - Assertions.assertNotNull(comp); - Assertions.assertEquals(1, comp.getChildCount()); + assertNotNull(comp); + assertEquals(1, comp.getChildCount()); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); - Assertions.assertNotNull(comp); + assertNotNull(comp); // Even if in the postback two components were added, pss algorithm must replace the // component with the one saved. - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); comp = facesContext.getViewRoot().findComponent("panel"); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("panel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); // Even if in the postback two components were added, pss algorithm must replace the // component with the one saved. - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); endRequest(); } - + @Test - public void testComponentBinding2() throws Exception + void componentBinding2() throws Exception { startViewRequest("/componentBinding2.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); int fieldCount = comp.getChildCount(); Set clientIds = new TreeSet(); for (UIComponent c : comp.getChildren()) @@ -514,15 +515,15 @@ public void testComponentBinding2() throws Exception processLifecycleExecute(); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); // Check the components are restored. - Assertions.assertEquals(fieldCount, comp.getChildCount()); + assertEquals(fieldCount, comp.getChildCount()); Set clientIds2 = new TreeSet(); for (UIComponent c : comp.getChildren()) { clientIds2.add(c.getClientId(facesContext)); } - Assertions.assertArrayEquals(clientIds.toArray(), clientIds2.toArray()); + assertArrayEquals(clientIds.toArray(), clientIds2.toArray()); ComponentBindingFormBean formBean = facesContext.getApplication().evaluateExpressionGet( facesContext, "#{componentBindingFormBean}", ComponentBindingFormBean.class); @@ -531,7 +532,7 @@ public void testComponentBinding2() throws Exception processLifecycleRender(); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); fieldCount = comp.getChildCount(); clientIds.clear(); for (UIComponent c : comp.getChildren()) @@ -545,14 +546,14 @@ public void testComponentBinding2() throws Exception processLifecycleExecute(); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertNotNull(comp); - Assertions.assertEquals(fieldCount, comp.getChildCount()); + assertNotNull(comp); + assertEquals(fieldCount, comp.getChildCount()); clientIds2.clear(); for (UIComponent c : comp.getChildren()) { clientIds2.add(c.getClientId(facesContext)); } - Assertions.assertArrayEquals(clientIds.toArray(), clientIds2.toArray()); + assertArrayEquals(clientIds.toArray(), clientIds2.toArray()); formBean = facesContext.getApplication().evaluateExpressionGet( facesContext, "#{componentBindingFormBean}", ComponentBindingFormBean.class); @@ -561,7 +562,7 @@ public void testComponentBinding2() throws Exception processLifecycleRender(); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); fieldCount = comp.getChildCount(); clientIds.clear(); for (UIComponent c : comp.getChildren()) @@ -575,14 +576,14 @@ public void testComponentBinding2() throws Exception processLifecycleExecute(); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertNotNull(comp); - Assertions.assertEquals(fieldCount, comp.getChildCount()); + assertNotNull(comp); + assertEquals(fieldCount, comp.getChildCount()); clientIds2.clear(); for (UIComponent c : comp.getChildren()) { clientIds2.add(c.getClientId(facesContext)); } - Assertions.assertArrayEquals(clientIds.toArray(), clientIds2.toArray()); + assertArrayEquals(clientIds.toArray(), clientIds2.toArray()); formBean = facesContext.getApplication().evaluateExpressionGet( facesContext, "#{componentBindingFormBean}", ComponentBindingFormBean.class); @@ -591,66 +592,66 @@ public void testComponentBinding2() throws Exception processLifecycleRender(); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); endRequest(); - } - + } + @Test - public void testViewParamBinding() throws Exception + void viewParamBinding() throws Exception { startViewRequest("/viewParamBinding1.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("panel"); - Assertions.assertNotNull(comp); - Assertions.assertEquals(1, comp.getChildCount()); + assertNotNull(comp); + assertEquals(1, comp.getChildCount()); UIViewParameter viewParam = (UIViewParameter) facesContext.getExternalContext().getRequestMap().get("foo"); - Assertions.assertNotNull(viewParam); - Assertions.assertEquals("foo", viewParam.getName()); + assertNotNull(viewParam); + assertEquals("foo", viewParam.getName()); UIViewParameter viewParam2 = facesContext.getApplication().evaluateExpressionGet( facesContext, "#{componentBindingBean}", ComponentBindingBean.class).getViewParam(); - Assertions.assertNotNull(viewParam2); - Assertions.assertEquals("foo2", viewParam2.getName()); + assertNotNull(viewParam2); + assertEquals("foo2", viewParam2.getName()); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); - Assertions.assertNotNull(comp); + assertNotNull(comp); // Even if in the postback two components were added, pss algorithm must replace the // component with the one saved. - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); comp = facesContext.getViewRoot().findComponent("panel"); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("panel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); // Even if in the postback two components were added, pss algorithm must replace the // component with the one saved. - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); endRequest(); - } - + } + @Test - public void testDynamicForm() throws Exception + void dynamicForm() throws Exception { startViewRequest("/dynamicForm.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:dynPanel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); int fieldCount = comp.getChildCount(); Set clientIds = new TreeSet(); for (UIComponent c : comp.getChildren()) @@ -662,19 +663,19 @@ public void testDynamicForm() throws Exception client.submit(button); processLifecycleExecute(); comp = facesContext.getViewRoot().findComponent("mainForm:dynPanel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); // Check the components are restored. - Assertions.assertEquals(fieldCount, comp.getChildCount()); + assertEquals(fieldCount, comp.getChildCount()); Set clientIds2 = new TreeSet(); for (UIComponent c : comp.getChildren()) { clientIds2.add(c.getClientId(facesContext)); } - Assertions.assertArrayEquals(clientIds.toArray(), clientIds2.toArray()); + assertArrayEquals(clientIds.toArray(), clientIds2.toArray()); processLifecycleRender(); comp = facesContext.getViewRoot().findComponent("mainForm:dynPanel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); fieldCount = comp.getChildCount(); clientIds.clear(); for (UIComponent c : comp.getChildren()) @@ -686,20 +687,20 @@ public void testDynamicForm() throws Exception client.submit(button); processLifecycleExecute(); comp = facesContext.getViewRoot().findComponent("mainForm:dynPanel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); // Check the components are restored. - Assertions.assertEquals(fieldCount, comp.getChildCount()); + assertEquals(fieldCount, comp.getChildCount()); clientIds2.clear(); for (UIComponent c : comp.getChildren()) { clientIds2.add(c.getClientId(facesContext)); } - Assertions.assertArrayEquals(clientIds.toArray(), clientIds2.toArray()); + assertArrayEquals(clientIds.toArray(), clientIds2.toArray()); // Check the components are restored. processLifecycleRender(); comp = facesContext.getViewRoot().findComponent("mainForm:dynPanel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); fieldCount = comp.getChildCount(); clientIds.clear(); for (UIComponent c : comp.getChildren()) @@ -711,19 +712,19 @@ public void testDynamicForm() throws Exception client.submit(button); processLifecycleExecute(); comp = facesContext.getViewRoot().findComponent("mainForm:dynPanel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); // Check the components are restored. - Assertions.assertEquals(fieldCount, comp.getChildCount()); + assertEquals(fieldCount, comp.getChildCount()); clientIds2.clear(); for (UIComponent c : comp.getChildren()) { clientIds2.add(c.getClientId(facesContext)); } - Assertions.assertArrayEquals(clientIds.toArray(), clientIds2.toArray()); + assertArrayEquals(clientIds.toArray(), clientIds2.toArray()); processLifecycleRender(); comp = facesContext.getViewRoot().findComponent("mainForm:dynPanel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); fieldCount = comp.getChildCount(); clientIds.clear(); for (UIComponent c : comp.getChildren()) @@ -735,19 +736,19 @@ public void testDynamicForm() throws Exception client.submit(button); processLifecycleExecute(); comp = facesContext.getViewRoot().findComponent("mainForm:dynPanel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); // Check the components are restored. - Assertions.assertEquals(fieldCount, comp.getChildCount()); + assertEquals(fieldCount, comp.getChildCount()); clientIds2.clear(); for (UIComponent c : comp.getChildren()) { clientIds2.add(c.getClientId(facesContext)); } - Assertions.assertArrayEquals(clientIds.toArray(), clientIds2.toArray()); + assertArrayEquals(clientIds.toArray(), clientIds2.toArray()); processLifecycleRender(); comp = facesContext.getViewRoot().findComponent("mainForm:dynPanel"); - Assertions.assertNotNull(comp); + assertNotNull(comp); fieldCount = comp.getChildCount(); clientIds.clear(); for (UIComponent c : comp.getChildren()) @@ -757,9 +758,9 @@ public void testDynamicForm() throws Exception endRequest(); } - + @Test - public void testResourceDependency() throws Exception + void resourceDependency() throws Exception { startViewRequest("/resourceDependency1.xhtml"); processLifecycleExecute(); @@ -768,8 +769,8 @@ public void testResourceDependency() throws Exception executeBuildViewCycle(); UIPanel headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head"); - Assertions.assertNotNull(headPanel); - Assertions.assertEquals(1, headPanel.getChildCount()); + assertNotNull(headPanel); + assertEquals(1, headPanel.getChildCount()); String nextUniqueId = facesContext.getViewRoot().createUniqueId(facesContext, null); @@ -789,16 +790,16 @@ public void testResourceDependency() throws Exception executeBuildViewCycle(); headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head"); - Assertions.assertNotNull(headPanel); - Assertions.assertEquals(1, headPanel.getChildCount()); - Assertions.assertNotSame(nextUniqueId, headPanel.getChildren().get(0).getId()); + assertNotNull(headPanel); + assertEquals(1, headPanel.getChildCount()); + assertNotSame(nextUniqueId, headPanel.getChildren().get(0).getId()); executeViewHandlerRender(); executeAfterRender(); } @Test - public void testResourceDependency2() throws Exception + void resourceDependency2() throws Exception { startViewRequest("/resourceDependency2.xhtml"); processLifecycleExecute(); @@ -807,7 +808,7 @@ public void testResourceDependency2() throws Exception executeBuildViewCycle(); UIPanel headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head"); - Assertions.assertNull(headPanel); + assertNull(headPanel); String nextUniqueId = facesContext.getViewRoot().createUniqueId(facesContext, null); @@ -827,9 +828,9 @@ public void testResourceDependency2() throws Exception executeBuildViewCycle(); headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head"); - Assertions.assertNotNull(headPanel); - Assertions.assertTrue(1 >= headPanel.getChildCount()); - Assertions.assertNotSame(nextUniqueId, headPanel.getChildren().get(0).getId()); + assertNotNull(headPanel); + assertTrue(1 >= headPanel.getChildCount()); + assertNotSame(nextUniqueId, headPanel.getChildren().get(0).getId()); executeViewHandlerRender(); executeAfterRender(); @@ -847,8 +848,8 @@ public void testResourceDependency2() throws Exception executeBuildViewCycle(); headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head"); - Assertions.assertNotNull(headPanel); - Assertions.assertTrue(1 >= headPanel.getChildCount()); + assertNotNull(headPanel); + assertTrue(1 >= headPanel.getChildCount()); //Assertions.assertNotSame(nextUniqueId, headPanel.getChildren().get(0).getId()); executeViewHandlerRender(); @@ -867,8 +868,8 @@ public void testResourceDependency2() throws Exception executeBuildViewCycle(); headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head"); - Assertions.assertNotNull(headPanel); - Assertions.assertTrue(1 >= headPanel.getChildCount()); + assertNotNull(headPanel); + assertTrue(1 >= headPanel.getChildCount()); //Assertions.assertNotSame(nextUniqueId, headPanel.getChildren().get(0).getId()); executeViewHandlerRender(); @@ -887,8 +888,8 @@ public void testResourceDependency2() throws Exception executeBuildViewCycle(); headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head"); - Assertions.assertNotNull(headPanel); - Assertions.assertTrue(1 >= headPanel.getChildCount()); + assertNotNull(headPanel); + assertTrue(1 >= headPanel.getChildCount()); //Assertions.assertNotSame(nextUniqueId, headPanel.getChildren().get(0).getId()); executeViewHandlerRender(); @@ -896,71 +897,71 @@ public void testResourceDependency2() throws Exception } @Test - public void testAddSimpleComponentVDL() throws Exception + void addSimpleComponentVDL() throws Exception { startViewRequest("/addSimpleComponentVDL.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); - Assertions.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value")); + assertEquals(1, comp.getChildCount()); + assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value")); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); - Assertions.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value")); + assertEquals(1, comp.getChildCount()); + assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value")); endRequest(); } - + @Test - public void testAddSimpleIncludeVDL_1() throws Exception + void addSimpleIncludeVDL1() throws Exception { startViewRequest("/addSimpleIncludeVDL_1.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(0); - Assertions.assertEquals(2, wrapper.getChildCount()); - Assertions.assertEquals("Dynamically added child", wrapper.getChildren().get(1).getAttributes().get("value")); + assertEquals(2, wrapper.getChildCount()); + assertEquals("Dynamically added child", wrapper.getChildren().get(1).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); - Assertions.assertTrue(new String(writer1.content()).contains("Dynamically added markup")); + assertTrue(new String(writer1.content()).contains("Dynamically added markup")); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); wrapper = comp.getChildren().get(0); - Assertions.assertEquals(2, wrapper.getChildCount()); - Assertions.assertEquals("Dynamically added child", wrapper.getChildren().get(1).getAttributes().get("value")); + assertEquals(2, wrapper.getChildCount()); + assertEquals("Dynamically added child", wrapper.getChildren().get(1).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); - Assertions.assertTrue(new String(writer2.content()).contains("Dynamically added markup")); + assertTrue(new String(writer2.content()).contains("Dynamically added markup")); endRequest(); } - + @Test - public void testAddSimpleIncludeVDL_2() throws Exception + void addSimpleIncludeVDL2() throws Exception { startViewRequest("/addSimpleIncludeVDL_2.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(0); - Assertions.assertEquals(3, wrapper.getChildCount()); - Assertions.assertEquals("Dynamically added child", wrapper.getChildren().get(1).getAttributes().get("value")); + assertEquals(3, wrapper.getChildCount()); + assertEquals("Dynamically added child", wrapper.getChildren().get(1).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content = new String(writer1.content()); - Assertions.assertTrue(content.contains("Dynamically added markup")); - Assertions.assertTrue(content.contains("Value in param1: value1")); - Assertions.assertTrue(content.contains("Value in param2: value2")); + assertTrue(content.contains("Dynamically added markup")); + assertTrue(content.contains("Value in param1: value1")); + assertTrue(content.contains("Value in param2: value2")); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); @@ -972,342 +973,342 @@ public void testAddSimpleIncludeVDL_2() throws Exception processLifecycleRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); wrapper = comp.getChildren().get(0); - Assertions.assertEquals(3, wrapper.getChildCount()); - Assertions.assertEquals("Dynamically added child", wrapper.getChildren().get(1).getAttributes().get("value")); + assertEquals(3, wrapper.getChildCount()); + assertEquals("Dynamically added child", wrapper.getChildren().get(1).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("Dynamically added markup")); - Assertions.assertTrue(content2.contains("Value in param1: value1")); - Assertions.assertTrue(content2.contains("Value in param2: otherValue2")); + assertTrue(content2.contains("Dynamically added markup")); + assertTrue(content2.contains("Value in param1: value1")); + assertTrue(content2.contains("Value in param2: otherValue2")); endRequest(); } - + @Test - public void testAddSimpleCCVDL() throws Exception + void addSimpleCCVDL() throws Exception { startViewRequest("/addSimpleCCVDL.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(0); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added header", + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added header", ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); - Assertions.assertTrue(new String(writer1.content()).contains("Dynamically added markup")); + assertTrue(new String(writer1.content()).contains("Dynamically added markup")); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); wrapper = comp.getChildren().get(0); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added header", + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added header", ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); - Assertions.assertTrue(new String(writer2.content()).contains("Dynamically added markup")); + assertTrue(new String(writer2.content()).contains("Dynamically added markup")); endRequest(); } @Test - public void testAddSimpleCCVDL2() throws Exception + void addSimpleCCVDL2() throws Exception { startViewRequest("/addSimpleCCVDL2.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(0); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("Dynamically added header")); - Assertions.assertTrue(content1.contains("Dynamically added markup")); + assertTrue(content1.contains("Dynamically added header")); + assertTrue(content1.contains("Dynamically added markup")); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); wrapper = comp.getChildren().get(0); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("Dynamically added header")); - Assertions.assertTrue(content2.contains("Dynamically added markup")); + assertTrue(content2.contains("Dynamically added header")); + assertTrue(content2.contains("Dynamically added markup")); endRequest(); } @Test - public void testAddSimpleCCVDL3() throws Exception + void addSimpleCCVDL3() throws Exception { startViewRequest("/addSimpleCCVDL3.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(0); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("Dynamically added markup")); + assertTrue(content1.contains("Dynamically added markup")); int indexDynHeader1_1 = content1.indexOf("Start Dynamic Header"); int indexDynHeader1_2 = content1.indexOf("Dynamically added header", indexDynHeader1_1); int indexDynHeader1_3 = content1.indexOf("End Dynamic Header", indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_1); - Assertions.assertNotSame(-1, indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_3); + assertNotSame(-1, indexDynHeader1_1); + assertNotSame(-1, indexDynHeader1_2); + assertNotSame(-1, indexDynHeader1_3); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); wrapper = comp.getChildren().get(0); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("Dynamically added markup")); + assertTrue(content2.contains("Dynamically added markup")); int indexDynHeader1 = content2.indexOf("Start Dynamic Header"); int indexDynHeader2 = content2.indexOf("Dynamically added header", indexDynHeader1); int indexDynHeader3 = content2.indexOf("End Dynamic Header", indexDynHeader2); - Assertions.assertNotSame(-1, indexDynHeader1); - Assertions.assertNotSame(-1, indexDynHeader2); - Assertions.assertNotSame(-1, indexDynHeader3); + assertNotSame(-1, indexDynHeader1); + assertNotSame(-1, indexDynHeader2); + assertNotSame(-1, indexDynHeader3); endRequest(); } @Test - public void testAddSimpleCCVDL4() throws Exception + void addSimpleCCVDL4() throws Exception { startViewRequest("/addSimpleCCVDL4.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(0); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("Dynamically added markup")); + assertTrue(content1.contains("Dynamically added markup")); int indexDynHeader1_1 = content1.indexOf("Start Dynamic Header"); int indexDynHeader1_2 = content1.indexOf("Dynamically added header", indexDynHeader1_1); int indexDynHeader1_3 = content1.indexOf("End Dynamic Header", indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_1); - Assertions.assertNotSame(-1, indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_3); + assertNotSame(-1, indexDynHeader1_1); + assertNotSame(-1, indexDynHeader1_2); + assertNotSame(-1, indexDynHeader1_3); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); wrapper = comp.getChildren().get(0); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("Dynamically added markup")); + assertTrue(content2.contains("Dynamically added markup")); int indexDynHeader1 = content2.indexOf("Start Dynamic Header"); int indexDynHeader2 = content2.indexOf("Dynamically added header", indexDynHeader1); int indexDynHeader3 = content2.indexOf("End Dynamic Header", indexDynHeader2); - Assertions.assertNotSame(-1, indexDynHeader1); - Assertions.assertNotSame(-1, indexDynHeader2); - Assertions.assertNotSame(-1, indexDynHeader3); + assertNotSame(-1, indexDynHeader1); + assertNotSame(-1, indexDynHeader2); + assertNotSame(-1, indexDynHeader3); endRequest(); } - + @Test - public void testAddSimpleCCVDL5() throws Exception + void addSimpleCCVDL5() throws Exception { startViewRequest("/addSimpleCCVDL5.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(0); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("Dynamically added markup")); + assertTrue(content1.contains("Dynamically added markup")); int indexDynHeader1_1 = content1.indexOf("Start Dynamic Header"); int indexDynHeader1_2 = content1.indexOf("Dynamically added header", indexDynHeader1_1); int indexDynHeader1_3 = content1.indexOf("End Dynamic Header", indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_1); - Assertions.assertNotSame(-1, indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_3); + assertNotSame(-1, indexDynHeader1_1); + assertNotSame(-1, indexDynHeader1_2); + assertNotSame(-1, indexDynHeader1_3); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); wrapper = comp.getChildren().get(0); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("Dynamically added markup")); + assertTrue(content2.contains("Dynamically added markup")); int indexDynHeader2_1 = content2.indexOf("Start Dynamic Header"); int indexDynHeader2_2 = content2.indexOf("Dynamically added header", indexDynHeader2_1); int indexDynHeader2_3 = content2.indexOf("End Dynamic Header", indexDynHeader2_2); - Assertions.assertNotSame(-1, indexDynHeader2_1); - Assertions.assertNotSame(-1, indexDynHeader2_2); - Assertions.assertNotSame(-1, indexDynHeader2_3); + assertNotSame(-1, indexDynHeader2_1); + assertNotSame(-1, indexDynHeader2_2); + assertNotSame(-1, indexDynHeader2_3); endRequest(); } - + @Test - public void testAddSimpleCCVDL6() throws Exception + void addSimpleCCVDL6() throws Exception { startViewRequest("/addSimpleCCVDL6.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(0); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("Dynamically added markup")); + assertTrue(content1.contains("Dynamically added markup")); int indexDynHeader1_1 = content1.indexOf("Start Dynamic Header"); int indexDynHeader1_2 = content1.indexOf("Dynamically added header", indexDynHeader1_1); int indexDynHeader1_3 = content1.indexOf("End Dynamic Header", indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_1); - Assertions.assertNotSame(-1, indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_3); + assertNotSame(-1, indexDynHeader1_1); + assertNotSame(-1, indexDynHeader1_2); + assertNotSame(-1, indexDynHeader1_3); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); wrapper = comp.getChildren().get(0); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("Dynamically added markup")); + assertTrue(content2.contains("Dynamically added markup")); int indexDynHeader2_1 = content2.indexOf("Start Dynamic Header"); int indexDynHeader2_2 = content2.indexOf("Dynamically added header", indexDynHeader2_1); int indexDynHeader2_3 = content2.indexOf("End Dynamic Header", indexDynHeader2_2); - Assertions.assertNotSame(-1, indexDynHeader2_1); - Assertions.assertNotSame(-1, indexDynHeader2_2); - Assertions.assertNotSame(-1, indexDynHeader2_3); + assertNotSame(-1, indexDynHeader2_1); + assertNotSame(-1, indexDynHeader2_2); + assertNotSame(-1, indexDynHeader2_3); endRequest(); } - + @Test - public void testAddSimpleCCVDL7() throws Exception + void addSimpleCCVDL7() throws Exception { startViewRequest("/addSimpleCCVDL7.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(0); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("Dynamically added markup")); + assertTrue(content1.contains("Dynamically added markup")); int indexDynHeader1_1 = content1.indexOf("Start Dynamic Header"); int indexDynHeader1_2 = content1.indexOf("Dynamically added header", indexDynHeader1_1); int indexDynHeader1_3 = content1.indexOf("End Dynamic Header", indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_1); - Assertions.assertNotSame(-1, indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_3); + assertNotSame(-1, indexDynHeader1_1); + assertNotSame(-1, indexDynHeader1_2); + assertNotSame(-1, indexDynHeader1_3); - Assertions.assertFalse(content1.contains("This is section 1")); + assertFalse(content1.contains("This is section 1")); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); @@ -1322,137 +1323,137 @@ public void testAddSimpleCCVDL7() throws Exception renderResponse(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertEquals(1, comp.getChildCount()); + assertEquals(1, comp.getChildCount()); wrapper = comp.getChildren().get(0); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("Dynamically added markup")); + assertTrue(content2.contains("Dynamically added markup")); int indexDynHeader1 = content2.indexOf("Start Dynamic Header"); int indexDynHeader2 = content2.indexOf("Dynamically added header", indexDynHeader1); int indexDynHeader3 = content2.indexOf("End Dynamic Header", indexDynHeader2); - Assertions.assertNotSame(-1, indexDynHeader1); - Assertions.assertNotSame(-1, indexDynHeader2); - Assertions.assertNotSame(-1, indexDynHeader3); + assertNotSame(-1, indexDynHeader1); + assertNotSame(-1, indexDynHeader2); + assertNotSame(-1, indexDynHeader3); - Assertions.assertTrue(content2.contains("This is section 1")); + assertTrue(content2.contains("This is section 1")); endRequest(); } @Test - public void testComponentBindingVDL_1() throws Exception + void componentBindingVDL1() throws Exception { startViewRequest("/componentBindingVDL_1.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("panel"); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added header", + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added header", ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("Dynamically added markup")); + assertTrue(content1.contains("Dynamically added markup")); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecute(); UIComponent comp2 = facesContext.getViewRoot().findComponent("panel"); - Assertions.assertNotNull(comp2); - Assertions.assertEquals(2, comp2.getChildCount()); + assertNotNull(comp2); + assertEquals(2, comp2.getChildCount()); - Assertions.assertEquals("value1", comp2.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp2.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp2.getAttributes().get("attr1")); + assertEquals("value2", comp2.getChildren().get(0).getAttributes().get("attr2")); wrapper = comp2.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added header", + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added header", ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); renderResponse(); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("Dynamically added markup")); + assertTrue(content2.contains("Dynamically added markup")); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); UIComponent comp3 = facesContext.getViewRoot().findComponent("panel"); - Assertions.assertNotNull(comp3); - Assertions.assertEquals(2, comp3.getChildCount()); + assertNotNull(comp3); + assertEquals(2, comp3.getChildCount()); - Assertions.assertEquals("value1", comp3.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp3.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp3.getAttributes().get("attr1")); + assertEquals("value2", comp3.getChildren().get(0).getAttributes().get("attr2")); wrapper = comp3.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added header", + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added header", ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer3 = (MockPrintWriter) response.getWriter(); String content3 = new String(writer3.content()); - Assertions.assertTrue(content3.contains("Dynamically added markup")); + assertTrue(content3.contains("Dynamically added markup")); endRequest(); } - + @Test - public void testComponentBindingVDL_2() throws Exception + void componentBindingVDL2() throws Exception { startViewRequest("/componentBindingVDL_2.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("Dynamically added header")); - Assertions.assertTrue(content1.contains("Dynamically added markup")); + assertTrue(content1.contains("Dynamically added header")); + assertTrue(content1.contains("Dynamically added markup")); UIComponent ccpanel = facesContext.getViewRoot().findComponent("mainForm:ccpanel"); - Assertions.assertNotNull(ccpanel); + assertNotNull(ccpanel); UIComponent ccinnerpanel = facesContext.getViewRoot().findComponent("mainForm:ccpanel:component"); - Assertions.assertNotNull(ccinnerpanel); + assertNotNull(ccinnerpanel); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:ccpanel:component:increment"); - Assertions.assertNotNull(button); + assertNotNull(button); CheckActionEventBean checkBean = facesContext.getApplication().evaluateExpressionGet(facesContext, "#{checkActionEventBean}", CheckActionEventBean.class); @@ -1461,279 +1462,279 @@ public void testComponentBindingVDL_2() throws Exception client.submit(button); processLifecycleExecute(); - Assertions.assertEquals(oldcount1+1, checkBean.getActionListenerCount()); + assertEquals(oldcount1+1, checkBean.getActionListenerCount()); renderResponse(); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("Dynamically added header")); - Assertions.assertTrue(content2.contains("Dynamically added markup")); + assertTrue(content2.contains("Dynamically added header")); + assertTrue(content2.contains("Dynamically added markup")); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:ccpanel:component:increment"); - Assertions.assertNotNull(button); + assertNotNull(button); int oldcount2 = checkBean.getActionListenerCount(); client.submit(button); processLifecycleExecute(); - Assertions.assertEquals(oldcount2+1, checkBean.getActionListenerCount()); + assertEquals(oldcount2+1, checkBean.getActionListenerCount()); renderResponse(); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer3 = (MockPrintWriter) response.getWriter(); String content3 = new String(writer3.content()); - Assertions.assertTrue(content3.contains("Dynamically added header")); - Assertions.assertTrue(content3.contains("Dynamically added markup")); + assertTrue(content3.contains("Dynamically added header")); + assertTrue(content3.contains("Dynamically added markup")); endRequest(); } - + @Test - public void testComponentBindingVDL_3() throws Exception + void componentBindingVDL3() throws Exception { startViewRequest("/componentBindingVDL_3.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("Dynamically added markup")); + assertTrue(content1.contains("Dynamically added markup")); int indexDynHeader1_1 = content1.indexOf("Start Dynamic Header"); int indexDynHeader1_2 = content1.indexOf("Dynamically added header", indexDynHeader1_1); int indexDynHeader1_3 = content1.indexOf("End Dynamic Header", indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_1); - Assertions.assertNotSame(-1, indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_3); + assertNotSame(-1, indexDynHeader1_1); + assertNotSame(-1, indexDynHeader1_2); + assertNotSame(-1, indexDynHeader1_3); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("Dynamically added markup")); + assertTrue(content2.contains("Dynamically added markup")); int indexDynHeader2_1 = content2.indexOf("Start Dynamic Header"); int indexDynHeader2_2 = content2.indexOf("Dynamically added header", indexDynHeader2_1); int indexDynHeader2_3 = content2.indexOf("End Dynamic Header", indexDynHeader2_2); - Assertions.assertNotSame(-1, indexDynHeader2_1); - Assertions.assertNotSame(-1, indexDynHeader2_2); - Assertions.assertNotSame(-1, indexDynHeader2_3); + assertNotSame(-1, indexDynHeader2_1); + assertNotSame(-1, indexDynHeader2_2); + assertNotSame(-1, indexDynHeader2_3); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer3 = (MockPrintWriter) response.getWriter(); String content3 = new String(writer3.content()); - Assertions.assertTrue(content3.contains("Dynamically added markup")); + assertTrue(content3.contains("Dynamically added markup")); int indexDynHeader3_1 = content3.indexOf("Start Dynamic Header"); int indexDynHeader3_2 = content3.indexOf("Dynamically added header", indexDynHeader3_1); int indexDynHeader3_3 = content3.indexOf("End Dynamic Header", indexDynHeader3_2); - Assertions.assertNotSame(-1, indexDynHeader3_1); - Assertions.assertNotSame(-1, indexDynHeader3_2); - Assertions.assertNotSame(-1, indexDynHeader3_3); + assertNotSame(-1, indexDynHeader3_1); + assertNotSame(-1, indexDynHeader3_2); + assertNotSame(-1, indexDynHeader3_3); endRequest(); } - + @Test - public void testComponentBindingVDL_4() throws Exception + void componentBindingVDL4() throws Exception { startViewRequest("/componentBindingVDL_4.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("Dynamically added markup")); + assertTrue(content1.contains("Dynamically added markup")); int indexDynHeader1_1 = content1.indexOf("Start Dynamic Header"); int indexDynHeader1_2 = content1.indexOf("Dynamically added header", indexDynHeader1_1); int indexDynHeader1_3 = content1.indexOf("End Dynamic Header", indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_1); - Assertions.assertNotSame(-1, indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_3); + assertNotSame(-1, indexDynHeader1_1); + assertNotSame(-1, indexDynHeader1_2); + assertNotSame(-1, indexDynHeader1_3); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("Dynamically added markup")); + assertTrue(content2.contains("Dynamically added markup")); int indexDynHeader2_1 = content2.indexOf("Start Dynamic Header"); int indexDynHeader2_2 = content2.indexOf("Dynamically added header", indexDynHeader2_1); int indexDynHeader2_3 = content2.indexOf("End Dynamic Header", indexDynHeader2_2); - Assertions.assertNotSame(-1, indexDynHeader2_1); - Assertions.assertNotSame(-1, indexDynHeader2_2); - Assertions.assertNotSame(-1, indexDynHeader2_3); + assertNotSame(-1, indexDynHeader2_1); + assertNotSame(-1, indexDynHeader2_2); + assertNotSame(-1, indexDynHeader2_3); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer3 = (MockPrintWriter) response.getWriter(); String content3 = new String(writer3.content()); - Assertions.assertTrue(content3.contains("Dynamically added markup")); + assertTrue(content3.contains("Dynamically added markup")); int indexDynHeader3_1 = content3.indexOf("Start Dynamic Header"); int indexDynHeader3_2 = content3.indexOf("Dynamically added header", indexDynHeader3_1); int indexDynHeader3_3 = content3.indexOf("End Dynamic Header", indexDynHeader3_2); - Assertions.assertNotSame(-1, indexDynHeader3_1); - Assertions.assertNotSame(-1, indexDynHeader3_2); - Assertions.assertNotSame(-1, indexDynHeader3_3); + assertNotSame(-1, indexDynHeader3_1); + assertNotSame(-1, indexDynHeader3_2); + assertNotSame(-1, indexDynHeader3_3); endRequest(); } - + @Test - public void testComponentBindingVDL_5() throws Exception + void componentBindingVDL5() throws Exception { startViewRequest("/componentBindingVDL_5.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("Dynamically added markup")); + assertTrue(content1.contains("Dynamically added markup")); int indexDynHeader1_1 = content1.indexOf("Start Dynamic Header"); int indexDynHeader1_2 = content1.indexOf("Dynamically added header", indexDynHeader1_1); int indexDynHeader1_3 = content1.indexOf("End Dynamic Header", indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_1); - Assertions.assertNotSame(-1, indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_3); + assertNotSame(-1, indexDynHeader1_1); + assertNotSame(-1, indexDynHeader1_2); + assertNotSame(-1, indexDynHeader1_3); UIComponent ccpanel = facesContext.getViewRoot().findComponent("mainForm:ccpanel"); - Assertions.assertNotNull(ccpanel); + assertNotNull(ccpanel); UIComponent ccinnerpanel = facesContext.getViewRoot().findComponent("mainForm:ccpanel:component"); - Assertions.assertNotNull(ccinnerpanel); + assertNotNull(ccinnerpanel); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:ccpanel:component:increment"); - Assertions.assertNotNull(button); + assertNotNull(button); CheckActionEventBean checkBean = facesContext.getApplication().evaluateExpressionGet(facesContext, "#{checkActionEventBean}", CheckActionEventBean.class); @@ -1742,105 +1743,105 @@ public void testComponentBindingVDL_5() throws Exception client.submit(button); processLifecycleExecute(); - Assertions.assertEquals(oldcount1+1, checkBean.getActionListenerCount()); + assertEquals(oldcount1+1, checkBean.getActionListenerCount()); renderResponse(); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("Dynamically added markup")); + assertTrue(content2.contains("Dynamically added markup")); int indexDynHeader2_1 = content2.indexOf("Start Dynamic Header"); int indexDynHeader2_2 = content2.indexOf("Dynamically added header", indexDynHeader2_1); int indexDynHeader2_3 = content2.indexOf("End Dynamic Header", indexDynHeader2_2); - Assertions.assertNotSame(-1, indexDynHeader2_1); - Assertions.assertNotSame(-1, indexDynHeader2_2); - Assertions.assertNotSame(-1, indexDynHeader2_3); + assertNotSame(-1, indexDynHeader2_1); + assertNotSame(-1, indexDynHeader2_2); + assertNotSame(-1, indexDynHeader2_3); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:ccpanel:component:increment"); - Assertions.assertNotNull(button); + assertNotNull(button); int oldcount2 = checkBean.getActionListenerCount(); client.submit(button); processLifecycleExecute(); - Assertions.assertEquals(oldcount2+1, checkBean.getActionListenerCount()); + assertEquals(oldcount2+1, checkBean.getActionListenerCount()); renderResponse(); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer3 = (MockPrintWriter) response.getWriter(); String content3 = new String(writer3.content()); - Assertions.assertTrue(content3.contains("Dynamically added markup")); + assertTrue(content3.contains("Dynamically added markup")); int indexDynHeader3_1 = content3.indexOf("Start Dynamic Header"); int indexDynHeader3_2 = content3.indexOf("Dynamically added header", indexDynHeader3_1); int indexDynHeader3_3 = content3.indexOf("End Dynamic Header", indexDynHeader3_2); - Assertions.assertNotSame(-1, indexDynHeader3_1); - Assertions.assertNotSame(-1, indexDynHeader3_2); - Assertions.assertNotSame(-1, indexDynHeader3_3); + assertNotSame(-1, indexDynHeader3_1); + assertNotSame(-1, indexDynHeader3_2); + assertNotSame(-1, indexDynHeader3_3); endRequest(); } @Test - public void testComponentBindingVDL_6() throws Exception + void componentBindingVDL6() throws Exception { startViewRequest("/componentBindingVDL_6.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("Dynamically added markup")); + assertTrue(content1.contains("Dynamically added markup")); int indexDynHeader1_1 = content1.indexOf("Start Dynamic Header"); int indexDynHeader1_2 = content1.indexOf("Dynamically added header", indexDynHeader1_1); int indexDynHeader1_3 = content1.indexOf("End Dynamic Header", indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_1); - Assertions.assertNotSame(-1, indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_3); + assertNotSame(-1, indexDynHeader1_1); + assertNotSame(-1, indexDynHeader1_2); + assertNotSame(-1, indexDynHeader1_3); UIComponent ccpanel = facesContext.getViewRoot().findComponent("mainForm:ccpanel"); - Assertions.assertNotNull(ccpanel); + assertNotNull(ccpanel); UIComponent ccinnerpanel = facesContext.getViewRoot().findComponent("mainForm:ccpanel:component"); - Assertions.assertNotNull(ccinnerpanel); + assertNotNull(ccinnerpanel); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:ccpanel:component:increment"); - Assertions.assertNotNull(button); + assertNotNull(button); CheckActionEventBean checkBean = facesContext.getApplication().evaluateExpressionGet(facesContext, "#{checkActionEventBean}", CheckActionEventBean.class); @@ -1849,102 +1850,102 @@ public void testComponentBindingVDL_6() throws Exception client.submit(button); processLifecycleExecute(); - Assertions.assertEquals(oldcount1+1, checkBean.getActionListenerCount()); + assertEquals(oldcount1+1, checkBean.getActionListenerCount()); renderResponse(); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("Dynamically added markup")); + assertTrue(content2.contains("Dynamically added markup")); int indexDynHeader2_1 = content2.indexOf("Start Dynamic Header"); int indexDynHeader2_2 = content2.indexOf("Dynamically added header", indexDynHeader2_1); int indexDynHeader2_3 = content2.indexOf("End Dynamic Header", indexDynHeader2_2); - Assertions.assertNotSame(-1, indexDynHeader2_1); - Assertions.assertNotSame(-1, indexDynHeader2_2); - Assertions.assertNotSame(-1, indexDynHeader2_3); + assertNotSame(-1, indexDynHeader2_1); + assertNotSame(-1, indexDynHeader2_2); + assertNotSame(-1, indexDynHeader2_3); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:ccpanel:component:increment"); - Assertions.assertNotNull(button); + assertNotNull(button); int oldcount2 = checkBean.getActionListenerCount(); client.submit(button); processLifecycleExecute(); - Assertions.assertEquals(oldcount2+1, checkBean.getActionListenerCount()); + assertEquals(oldcount2+1, checkBean.getActionListenerCount()); renderResponse(); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer3 = (MockPrintWriter) response.getWriter(); String content3 = new String(writer3.content()); - Assertions.assertTrue(content3.contains("Dynamically added markup")); + assertTrue(content3.contains("Dynamically added markup")); int indexDynHeader3_1 = content3.indexOf("Start Dynamic Header"); int indexDynHeader3_2 = content3.indexOf("Dynamically added header", indexDynHeader3_1); int indexDynHeader3_3 = content3.indexOf("End Dynamic Header", indexDynHeader3_2); - Assertions.assertNotSame(-1, indexDynHeader3_1); - Assertions.assertNotSame(-1, indexDynHeader3_2); - Assertions.assertNotSame(-1, indexDynHeader3_3); + assertNotSame(-1, indexDynHeader3_1); + assertNotSame(-1, indexDynHeader3_2); + assertNotSame(-1, indexDynHeader3_3); endRequest(); } - + @Test - public void testComponentBindingVDL_7() throws Exception + void componentBindingVDL7() throws Exception { startViewRequest("/componentBindingVDL_7.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); UIComponent wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("Dynamically added markup")); + assertTrue(content1.contains("Dynamically added markup")); int indexDynHeader1_1 = content1.indexOf("Start Dynamic Header"); int indexDynHeader1_2 = content1.indexOf("Dynamically added header", indexDynHeader1_1); int indexDynHeader1_3 = content1.indexOf("End Dynamic Header", indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_1); - Assertions.assertNotSame(-1, indexDynHeader1_2); - Assertions.assertNotSame(-1, indexDynHeader1_3); + assertNotSame(-1, indexDynHeader1_1); + assertNotSame(-1, indexDynHeader1_2); + assertNotSame(-1, indexDynHeader1_3); - Assertions.assertFalse(content1.contains("This is section 1")); + assertFalse(content1.contains("This is section 1")); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); @@ -1957,34 +1958,34 @@ public void testComponentBindingVDL_7() throws Exception sessionBean.setShowSection1(true); renderResponse(); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("Dynamically added markup")); + assertTrue(content2.contains("Dynamically added markup")); int indexDynHeader2_1 = content2.indexOf("Start Dynamic Header"); int indexDynHeader2_2 = content2.indexOf("Dynamically added header", indexDynHeader2_1); int indexDynHeader2_3 = content2.indexOf("End Dynamic Header", indexDynHeader2_2); - Assertions.assertNotSame(-1, indexDynHeader2_1); - Assertions.assertNotSame(-1, indexDynHeader2_2); - Assertions.assertNotSame(-1, indexDynHeader2_3); + assertNotSame(-1, indexDynHeader2_1); + assertNotSame(-1, indexDynHeader2_2); + assertNotSame(-1, indexDynHeader2_3); - Assertions.assertTrue(content2.contains("This is section 1")); + assertTrue(content2.contains("This is section 1")); button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); @@ -1993,40 +1994,40 @@ public void testComponentBindingVDL_7() throws Exception sessionBean.setShowSection1(false); renderResponse(); - Assertions.assertNotNull(comp); - Assertions.assertEquals(2, comp.getChildCount()); + assertNotNull(comp); + assertEquals(2, comp.getChildCount()); comp = facesContext.getViewRoot().findComponent("mainForm:panel"); - Assertions.assertEquals("value1", comp.getAttributes().get("attr1")); - Assertions.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); + assertEquals("value1", comp.getAttributes().get("attr1")); + assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2")); wrapper = comp.getChildren().get(1); - Assertions.assertNotNull(wrapper); - Assertions.assertTrue(UIComponent.isCompositeComponent(wrapper)); + assertNotNull(wrapper); + assertTrue(UIComponent.isCompositeComponent(wrapper)); ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(ccContent); - Assertions.assertEquals(3, ccContent.getChildCount()); + assertNotNull(ccContent); + assertEquals(3, ccContent.getChildCount()); //Assertions.assertEquals("Dynamically added header", // ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value")); - Assertions.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); + assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value")); MockPrintWriter writer3 = (MockPrintWriter) response.getWriter(); String content3 = new String(writer3.content()); - Assertions.assertTrue(content3.contains("Dynamically added markup")); + assertTrue(content3.contains("Dynamically added markup")); int indexDynHeader3_1 = content3.indexOf("Start Dynamic Header"); int indexDynHeader3_2 = content3.indexOf("Dynamically added header", indexDynHeader3_1); int indexDynHeader3_3 = content3.indexOf("End Dynamic Header", indexDynHeader3_2); - Assertions.assertNotSame(-1, indexDynHeader3_1); - Assertions.assertNotSame(-1, indexDynHeader3_2); - Assertions.assertNotSame(-1, indexDynHeader3_3); + assertNotSame(-1, indexDynHeader3_1); + assertNotSame(-1, indexDynHeader3_2); + assertNotSame(-1, indexDynHeader3_3); - Assertions.assertFalse(content3.contains("This is section 1")); + assertFalse(content3.contains("This is section 1")); endRequest(); } @Test - public void testCForEach1() throws Exception + void cForEach1() throws Exception { startViewRequest("/forEach1.xhtml"); processLifecycleExecute(); @@ -2035,16 +2036,16 @@ public void testCForEach1() throws Exception executeBuildViewCycle(); UIOutput itemA_1 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_a"); - Assertions.assertNotNull(itemA_1); - Assertions.assertEquals("a", itemA_1.getValue()); + assertNotNull(itemA_1); + assertEquals("a", itemA_1.getValue()); itemA_1.getAttributes().put("prop", "a"); UIOutput itemB_1 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_b"); - Assertions.assertNotNull(itemB_1); - Assertions.assertEquals("b", itemB_1.getValue()); + assertNotNull(itemB_1); + assertEquals("b", itemB_1.getValue()); itemB_1.getAttributes().put("prop", "b"); UIOutput itemC_1 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_c"); - Assertions.assertNotNull(itemC_1); - Assertions.assertEquals("c", itemC_1.getValue()); + assertNotNull(itemC_1); + assertEquals("c", itemC_1.getValue()); itemC_1.getAttributes().put("prop", "c"); executeViewHandlerRender(); @@ -2055,17 +2056,17 @@ public void testCForEach1() throws Exception processLifecycleExecute(); UIOutput itemA_2 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_a"); - Assertions.assertNotNull(itemA_2); - Assertions.assertEquals("a", itemA_2.getValue()); - Assertions.assertEquals("a", itemA_2.getAttributes().get("prop")); + assertNotNull(itemA_2); + assertEquals("a", itemA_2.getValue()); + assertEquals("a", itemA_2.getAttributes().get("prop")); UIOutput itemB_2 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_b"); - Assertions.assertNotNull(itemB_2); - Assertions.assertEquals("b", itemB_2.getValue()); - Assertions.assertEquals("b", itemB_2.getAttributes().get("prop")); + assertNotNull(itemB_2); + assertEquals("b", itemB_2.getValue()); + assertEquals("b", itemB_2.getAttributes().get("prop")); UIOutput itemC_2 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_c"); - Assertions.assertNotNull(itemC_2); - Assertions.assertEquals("c", itemC_2.getValue()); - Assertions.assertEquals("c", itemC_2.getAttributes().get("prop")); + assertNotNull(itemC_2); + assertEquals("c", itemC_2.getValue()); + assertEquals("c", itemC_2.getAttributes().get("prop")); ForEachBean bean = facesContext.getApplication().evaluateExpressionGet(facesContext, "#{forEachBean}", ForEachBean.class); @@ -2077,23 +2078,23 @@ public void testCForEach1() throws Exception executeBuildViewCycle(); UIOutput itemA_3 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_a"); - Assertions.assertNotNull(itemA_3); - Assertions.assertEquals("a", itemA_3.getValue()); - Assertions.assertEquals("a", itemA_3.getAttributes().get("prop")); + assertNotNull(itemA_3); + assertEquals("a", itemA_3.getValue()); + assertEquals("a", itemA_3.getAttributes().get("prop")); UIOutput itemB_3 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_b"); - Assertions.assertNotNull(itemB_3); - Assertions.assertEquals("b", itemB_3.getValue()); - Assertions.assertEquals("b", itemB_3.getAttributes().get("prop")); + assertNotNull(itemB_3); + assertEquals("b", itemB_3.getValue()); + assertEquals("b", itemB_3.getAttributes().get("prop")); UIOutput itemC_3 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_c"); - Assertions.assertNull(itemC_3); + assertNull(itemC_3); UIOutput itemZ_3 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_z"); - Assertions.assertNotNull(itemZ_3); - Assertions.assertEquals("z", itemZ_3.getValue()); - Assertions.assertNull(itemZ_3.getAttributes().get("prop")); + assertNotNull(itemZ_3); + assertEquals("z", itemZ_3.getValue()); + assertNull(itemZ_3.getAttributes().get("prop")); UIOutput itemX_3 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_x"); - Assertions.assertNotNull(itemX_3); - Assertions.assertEquals("x", itemX_3.getValue()); - Assertions.assertNull(itemX_3.getAttributes().get("prop")); + assertNotNull(itemX_3); + assertEquals("x", itemX_3.getValue()); + assertNull(itemX_3.getAttributes().get("prop")); executeViewHandlerRender(); @@ -2103,19 +2104,19 @@ public void testCForEach1() throws Exception processLifecycleExecute(); UIOutput itemA_4 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_a"); - Assertions.assertNotNull(itemA_4); - Assertions.assertEquals("a", itemA_4.getValue()); + assertNotNull(itemA_4); + assertEquals("a", itemA_4.getValue()); UIOutput itemB_4 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_b"); - Assertions.assertNotNull(itemB_4); - Assertions.assertEquals("b", itemB_4.getValue()); + assertNotNull(itemB_4); + assertEquals("b", itemB_4.getValue()); UIOutput itemC_4 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_c"); - Assertions.assertNull(itemC_4); + assertNull(itemC_4); UIOutput itemZ_4 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_z"); - Assertions.assertNotNull(itemZ_4); - Assertions.assertEquals("z", itemZ_4.getValue()); + assertNotNull(itemZ_4); + assertEquals("z", itemZ_4.getValue()); UIOutput itemX_4 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:item_x"); - Assertions.assertNotNull(itemX_4); - Assertions.assertEquals("x", itemX_4.getValue()); + assertNotNull(itemX_4); + assertEquals("x", itemX_4.getValue()); endRequest(); } @@ -2125,7 +2126,7 @@ public void testCForEach1() throws Exception * not a copy of the element saved with the view state. */ @Test - public void testCForEachInputUpdatesLiveItem() throws Exception + void cForEachInputUpdatesLiveItem() throws Exception { startViewRequest("/forEachInput.xhtml"); processLifecycleExecuteAndRender(); @@ -2138,25 +2139,25 @@ public void testCForEachInputUpdatesLiveItem() throws Exception processLifecycleExecute(); - Assertions.assertFalse(facesContext.getMessages().hasNext()); + assertFalse(facesContext.getMessages().hasNext()); ForEachInputSessionBean sessionBean = facesContext.getApplication().evaluateExpressionGet( facesContext, "#{forEachInputSessionBean}", ForEachInputSessionBean.class); - Assertions.assertEquals("edited session a", sessionBean.getItems().get(0).getName()); - Assertions.assertEquals("edited session b", sessionBean.getItems().get(1).getName()); + assertEquals("edited session a", sessionBean.getItems().get(0).getName()); + assertEquals("edited session b", sessionBean.getItems().get(1).getName()); ForEachInputRequestBean requestBean = facesContext.getApplication().evaluateExpressionGet( facesContext, "#{forEachInputRequestBean}", ForEachInputRequestBean.class); - Assertions.assertEquals("edited request a", requestBean.getItems().get(0).getName()); - Assertions.assertEquals("edited request b", requestBean.getItems().get(1).getName()); + assertEquals("edited request a", requestBean.getItems().get(0).getName()); + assertEquals("edited request b", requestBean.getItems().get(1).getName()); executeBeforeRender(); executeBuildViewCycle(); executeViewHandlerRender(); String content = new String(((MockPrintWriter) response.getWriter()).content()); - Assertions.assertTrue(content.contains("edited session a")); - Assertions.assertTrue(content.contains("edited request b")); + assertTrue(content.contains("edited session a")); + assertTrue(content.contains("edited request b")); endRequest(); } @@ -2166,18 +2167,18 @@ public void testCForEachInputUpdatesLiveItem() throws Exception * remaining item follows its item, the value of the vanished item goes nowhere. */ @Test - public void testCForEachInputItemRemovedBeforePostback() throws Exception + void cForEachInputItemRemovedBeforePostback() throws Exception { ForEachInputSessionBean bean = renderForEachInputAndEdit(items -> items.remove(0)); - Assertions.assertFalse(facesContext.getMessages().hasNext()); - Assertions.assertEquals(1, bean.getItems().size()); - Assertions.assertEquals("b", bean.getItems().get(0).getId()); - Assertions.assertEquals("edited session b", bean.getItems().get(0).getName()); + assertFalse(facesContext.getMessages().hasNext()); + assertEquals(1, bean.getItems().size()); + assertEquals("b", bean.getItems().get(0).getId()); + assertEquals("edited session b", bean.getItems().get(0).getName()); // the restored rows keep the ids of their rendered items, also while the view is built - Assertions.assertNotNull(facesContext.getViewRoot().findComponent("mainForm:session_a")); - Assertions.assertNotNull(facesContext.getViewRoot().findComponent("mainForm:session_b")); + assertNotNull(facesContext.getViewRoot().findComponent("mainForm:session_a")); + assertNotNull(facesContext.getViewRoot().findComponent("mainForm:session_b")); renderAndEndRequest(); } @@ -2187,21 +2188,21 @@ public void testCForEachInputItemRemovedBeforePostback() throws Exception * item, the new item stays untouched. */ @Test - public void testCForEachInputItemAddedBeforePostback() throws Exception + void cForEachInputItemAddedBeforePostback() throws Exception { ForEachInputSessionBean bean = renderForEachInputAndEdit( items -> items.add(0, new ForEachInputKeyedItem("z", "original z"))); - Assertions.assertFalse(facesContext.getMessages().hasNext()); - Assertions.assertEquals(3, bean.getItems().size()); - Assertions.assertEquals("original z", bean.getItems().get(0).getName()); - Assertions.assertEquals("edited session a", bean.getItems().get(1).getName()); - Assertions.assertEquals("edited session b", bean.getItems().get(2).getName()); + assertFalse(facesContext.getMessages().hasNext()); + assertEquals(3, bean.getItems().size()); + assertEquals("original z", bean.getItems().get(0).getName()); + assertEquals("edited session a", bean.getItems().get(1).getName()); + assertEquals("edited session b", bean.getItems().get(2).getName()); // the restored rows keep the ids of their rendered items, the new item gets no row yet - Assertions.assertNotNull(facesContext.getViewRoot().findComponent("mainForm:session_a")); - Assertions.assertNotNull(facesContext.getViewRoot().findComponent("mainForm:session_b")); - Assertions.assertNull(facesContext.getViewRoot().findComponent("mainForm:session_z")); + assertNotNull(facesContext.getViewRoot().findComponent("mainForm:session_a")); + assertNotNull(facesContext.getViewRoot().findComponent("mainForm:session_b")); + assertNull(facesContext.getViewRoot().findComponent("mainForm:session_z")); renderAndEndRequest(); } @@ -2211,13 +2212,13 @@ public void testCForEachInputItemAddedBeforePostback() throws Exception * item must neither fail nor write anything. */ @Test - public void testCForEachInputLastItemRemovedBeforePostback() throws Exception + void cForEachInputLastItemRemovedBeforePostback() throws Exception { ForEachInputSessionBean bean = renderForEachInputAndEdit(items -> items.remove(1)); - Assertions.assertFalse(facesContext.getMessages().hasNext()); - Assertions.assertEquals(1, bean.getItems().size()); - Assertions.assertEquals("edited session a", bean.getItems().get(0).getName()); + assertFalse(facesContext.getMessages().hasNext()); + assertEquals(1, bean.getItems().size()); + assertEquals("edited session a", bean.getItems().get(0).getName()); renderAndEndRequest(); } @@ -2227,12 +2228,12 @@ public void testCForEachInputLastItemRemovedBeforePostback() throws Exception * fail nor write anything. */ @Test - public void testCForEachInputItemsClearedBeforePostback() throws Exception + void cForEachInputItemsClearedBeforePostback() throws Exception { ForEachInputSessionBean bean = renderForEachInputAndEdit(List::clear); - Assertions.assertFalse(facesContext.getMessages().hasNext()); - Assertions.assertTrue(bean.getItems().isEmpty()); + assertFalse(facesContext.getMessages().hasNext()); + assertTrue(bean.getItems().isEmpty()); renderAndEndRequest(); } @@ -2241,7 +2242,7 @@ public void testCForEachInputItemsClearedBeforePostback() throws Exception * MYFACES-4775: a Set and nested c:forEach loops must update the live items as well. */ @Test - public void testCForEachInputSetAndNestedUpdateLiveItems() throws Exception + void cForEachInputSetAndNestedUpdateLiveItems() throws Exception { startViewRequest("/forEachInput.xhtml"); processLifecycleExecuteAndRender(); @@ -2254,15 +2255,15 @@ public void testCForEachInputSetAndNestedUpdateLiveItems() throws Exception processLifecycleExecute(); - Assertions.assertFalse(facesContext.getMessages().hasNext()); + assertFalse(facesContext.getMessages().hasNext()); ForEachInputSessionBean bean = facesContext.getApplication().evaluateExpressionGet( facesContext, "#{forEachInputSessionBean}", ForEachInputSessionBean.class); List setItems = List.copyOf(bean.getItemSet()); - Assertions.assertEquals("edited s1", setItems.get(0).getName()); - Assertions.assertEquals("edited s2", setItems.get(1).getName()); - Assertions.assertEquals("edited g1", bean.getGroups().get(0).get(0).getName()); - Assertions.assertEquals("edited g2", bean.getGroups().get(1).get(0).getName()); + assertEquals("edited s1", setItems.get(0).getName()); + assertEquals("edited s2", setItems.get(1).getName()); + assertEquals("edited g1", bean.getGroups().get(0).get(0).getName()); + assertEquals("edited g2", bean.getGroups().get(1).get(0).getName()); renderAndEndRequest(); } @@ -2273,14 +2274,14 @@ public void testCForEachInputSetAndNestedUpdateLiveItems() throws Exception * first item writes nowhere, the row of the second item still updates it. */ @Test - public void testCForEachGeneratedIdsItemRemovedBeforePostback() throws Exception + void cForEachGeneratedIdsItemRemovedBeforePostback() throws Exception { ForEachInputSessionBean bean = renderGeneratedIdsAndEdit("keyed", items -> items.remove(0)); - Assertions.assertFalse(facesContext.getMessages().hasNext()); - Assertions.assertEquals(1, bean.getItems().size()); - Assertions.assertEquals("b", bean.getItems().get(0).getId()); - Assertions.assertEquals("edited 2", bean.getItems().get(0).getName()); + assertFalse(facesContext.getMessages().hasNext()); + assertEquals(1, bean.getItems().size()); + assertEquals("b", bean.getItems().get(0).getId()); + assertEquals("edited 2", bean.getItems().get(0).getName()); renderAndEndRequest(); } @@ -2290,16 +2291,16 @@ public void testCForEachGeneratedIdsItemRemovedBeforePostback() throws Exception * row follows its item, the new item stays untouched. */ @Test - public void testCForEachGeneratedIdsItemAddedBeforePostback() throws Exception + void cForEachGeneratedIdsItemAddedBeforePostback() throws Exception { ForEachInputSessionBean bean = renderGeneratedIdsAndEdit("keyed", items -> items.add(0, new ForEachInputKeyedItem("z", "original z"))); - Assertions.assertFalse(facesContext.getMessages().hasNext()); - Assertions.assertEquals(3, bean.getItems().size()); - Assertions.assertEquals("original z", bean.getItems().get(0).getName()); - Assertions.assertEquals("edited 1", bean.getItems().get(1).getName()); - Assertions.assertEquals("edited 2", bean.getItems().get(2).getName()); + assertFalse(facesContext.getMessages().hasNext()); + assertEquals(3, bean.getItems().size()); + assertEquals("original z", bean.getItems().get(0).getName()); + assertEquals("edited 1", bean.getItems().get(1).getName()); + assertEquals("edited 2", bean.getItems().get(2).getName()); renderAndEndRequest(); } @@ -2309,13 +2310,13 @@ public void testCForEachGeneratedIdsItemAddedBeforePostback() throws Exception * rendered items saved with the view state are copies, the rows update the live items by position. */ @Test - public void testCForEachIdentityItemsUpdateLiveItems() throws Exception + void cForEachIdentityItemsUpdateLiveItems() throws Exception { ForEachInputSessionBean bean = renderGeneratedIdsAndEdit("identity", items -> { }); - Assertions.assertFalse(facesContext.getMessages().hasNext()); - Assertions.assertEquals("edited 1", bean.getIdentityItems().get(0).getName()); - Assertions.assertEquals("edited 2", bean.getIdentityItems().get(1).getName()); + assertFalse(facesContext.getMessages().hasNext()); + assertEquals("edited 1", bean.getIdentityItems().get(0).getName()); + assertEquals("edited 2", bean.getIdentityItems().get(1).getName()); renderAndEndRequest(); } @@ -2327,14 +2328,14 @@ public void testCForEachIdentityItemsUpdateLiveItems() throws Exception * the row of the vanished position writes nowhere. */ @Test - public void testCForEachIdentityItemsFallBackToPosition() throws Exception + void cForEachIdentityItemsFallBackToPosition() throws Exception { ForEachInputSessionBean bean = renderGeneratedIdsAndEdit("identity", items -> items.remove(0)); - Assertions.assertFalse(facesContext.getMessages().hasNext()); - Assertions.assertEquals(1, bean.getIdentityItems().size()); - Assertions.assertEquals("b", bean.getIdentityItems().get(0).getId()); - Assertions.assertEquals("edited 1", bean.getIdentityItems().get(0).getName()); + assertFalse(facesContext.getMessages().hasNext()); + assertEquals(1, bean.getIdentityItems().size()); + assertEquals("b", bean.getIdentityItems().get(0).getId()); + assertEquals("edited 1", bean.getIdentityItems().get(0).getName()); renderAndEndRequest(); } @@ -2371,7 +2372,7 @@ private ForEachInputSessionBean renderGeneratedIdsAndEdit(String group, facesContext.getViewRoot().findComponent("mainForm:" + group).getChildren().stream() .filter(UIInput.class::isInstance) .forEach(input -> clientIds.add(input.getClientId(facesContext))); - Assertions.assertEquals(2, clientIds.size()); + assertEquals(2, clientIds.size()); ForEachInputSessionBean bean = facesContext.getApplication().evaluateExpressionGet( facesContext, "#{forEachInputSessionBean}", ForEachInputSessionBean.class); @@ -2403,14 +2404,14 @@ private void renderAndEndRequest() throws Exception * @throws Exception */ @Test - public void testSimpleComponent1() throws Exception + void simpleComponent1() throws Exception { startViewRequest("/simpleComponent1.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertNotNull(comp); - Assertions.assertTrue(comp instanceof UISimpleComponent1); + assertNotNull(comp); + assertInstanceOf(UISimpleComponent1.class, comp); //Assertions.assertEquals(1, comp.getChildCount()); //Assertions.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value")); @@ -2419,21 +2420,21 @@ public void testSimpleComponent1() throws Exception processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertNotNull(comp); - Assertions.assertTrue(comp instanceof UISimpleComponent1); + assertNotNull(comp); + assertInstanceOf(UISimpleComponent1.class, comp); endRequest(); } - + @Test - public void testSimpleComponent2() throws Exception + void simpleComponent2() throws Exception { startViewRequest("/simpleComponent2.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertNotNull(comp); - Assertions.assertTrue(comp instanceof UISimpleComponent2); + assertNotNull(comp); + assertInstanceOf(UISimpleComponent2.class, comp); //Assertions.assertEquals(1, comp.getChildCount()); //Assertions.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value")); @@ -2442,23 +2443,23 @@ public void testSimpleComponent2() throws Exception processLifecycleExecuteAndRender(); comp = facesContext.getViewRoot().findComponent("mainForm:component"); - Assertions.assertNotNull(comp); - Assertions.assertTrue(comp instanceof UISimpleComponent2); + assertNotNull(comp); + assertInstanceOf(UISimpleComponent2.class, comp); endRequest(); } - + @Test - public void testUIRepeatCC1() throws Exception + void uIRepeatCC1() throws Exception { startViewRequest("/nested_ui_repeat_1.xhtml"); processLifecycleExecuteAndRender(); MockPrintWriter writer1 = (MockPrintWriter) response.getWriter(); String content1 = new String(writer1.content()); - Assertions.assertTrue(content1.contains("A-")); - Assertions.assertTrue(content1.contains("B-")); - Assertions.assertTrue(content1.contains("C-")); + assertTrue(content1.contains("A-")); + assertTrue(content1.contains("B-")); + assertTrue(content1.contains("C-")); this.client.ajax("mainForm:j_id_7:1:j_id_8:refresh", "action", "mainForm:j_id_7:1:j_id_8:refresh", @@ -2468,29 +2469,29 @@ public void testUIRepeatCC1() throws Exception MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); String content2 = new String(writer2.content()); - Assertions.assertTrue(content2.contains("mainForm:j_id_7:1:j_id_8:compToUpdate")); - Assertions.assertTrue(content2.contains("B-")); + assertTrue(content2.contains("mainForm:j_id_7:1:j_id_8:compToUpdate")); + assertTrue(content2.contains("B-")); endRequest(); } @Test - public void testOnloadScript() throws Exception + void onloadScript() throws Exception { startViewRequest("/onloadscript.xhtml"); processLifecycleExecuteAndRender(); MockPrintWriter writer2 = (MockPrintWriter) response.getWriter(); - Assertions.assertTrue(new String(writer2.content()).contains("onloadScript successfully executed")); - Assertions.assertTrue(new String(writer2.content()).contains("Remove this c:if and it will work.")); + assertTrue(new String(writer2.content()).contains("onloadScript successfully executed")); + assertTrue(new String(writer2.content()).contains("Remove this c:if and it will work.")); UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback"); client.submit(button); processLifecycleExecuteAndRender(); writer2 = (MockPrintWriter) response.getWriter(); - Assertions.assertTrue(new String(writer2.content()).contains("onloadScript successfully executed")); - Assertions.assertTrue(new String(writer2.content()).contains("Remove this c:if and it will work.")); + assertTrue(new String(writer2.content()).contains("onloadScript successfully executed")); + assertTrue(new String(writer2.content()).contains("Remove this c:if and it will work.")); endRequest(); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/pss/dynamicchild/DynamicChildInPostAddToViewTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/pss/dynamicchild/DynamicChildInPostAddToViewTestCase.java index 3f8de457c8..f8cfa763f0 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/pss/dynamicchild/DynamicChildInPostAddToViewTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/pss/dynamicchild/DynamicChildInPostAddToViewTestCase.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.view.facelets.pss.dynamicchild; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + import java.util.List; import jakarta.el.ExpressionFactory; @@ -27,7 +30,6 @@ import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.view.facelets.PartialStateManagementStrategy; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -35,7 +37,7 @@ * reproduces it. It must therefore not be tracked as a dynamically added component in the saved state, and the * postback must neither lose it nor duplicate it. */ -public class DynamicChildInPostAddToViewTestCase extends AbstractMyFacesCDIRequestTestCase +class DynamicChildInPostAddToViewTestCase extends AbstractMyFacesCDIRequestTestCase { private static final String SUBMITTED_VALUE = "submitted into a dynamically added input"; @@ -58,13 +60,13 @@ protected void setUpWebConfigParams() throws Exception } @Test - public void testListenerOnViewRoot() throws Exception + void listenerOnViewRoot() throws Exception { assertBuildTimeAddIsNotSaved("/dynamicChildInViewRoot.xhtml"); } @Test - public void testListenerOnContainer() throws Exception + void listenerOnContainer() throws Exception { assertBuildTimeAddIsNotSaved("/dynamicChildInContainer.xhtml"); } @@ -74,22 +76,22 @@ private void assertBuildTimeAddIsNotSaved(String viewId) throws Exception startViewRequest(viewId); processLifecycleExecuteAndRender(); - Assertions.assertEquals(1, countDynamicChildren(), "one added child on initial render"); - Assertions.assertFalse(isMarkedAsAddedAfterBuild(), "added child marked as added after build on initial render"); - Assertions.assertEquals(0, countClientIdsAdded(), "dynamically added components on initial render"); + assertEquals(1, countDynamicChildren(), "one added child on initial render"); + assertFalse(isMarkedAsAddedAfterBuild(), "added child marked as added after build on initial render"); + assertEquals(0, countClientIdsAdded(), "dynamically added components on initial render"); client.inputText(CHILD_CLIENT_ID, SUBMITTED_VALUE); client.submit("form:submit"); processLifecycleExecuteAndRender(); - Assertions.assertEquals(1, countDynamicChildren(), "one added child after postback"); - Assertions.assertEquals(SUBMITTED_VALUE, facesContext.getApplication().evaluateExpressionGet(facesContext, + assertEquals(1, countDynamicChildren(), "one added child after postback"); + assertEquals(SUBMITTED_VALUE, facesContext.getApplication().evaluateExpressionGet(facesContext, "#{dynamicChildInPostAddToViewBean.value}", String.class), "value decoded from the added child"); - Assertions.assertEquals(SUBMITTED_VALUE, + assertEquals(SUBMITTED_VALUE, ((UIInput) facesContext.getViewRoot().findComponent(CHILD_CLIENT_ID)).getValue(), "value of the added child after postback"); - Assertions.assertFalse(isMarkedAsAddedAfterBuild(), "added child marked as added after build after postback"); - Assertions.assertEquals(0, countClientIdsAdded(), "dynamically added components after postback"); + assertFalse(isMarkedAsAddedAfterBuild(), "added child marked as added after build after postback"); + assertEquals(0, countClientIdsAdded(), "dynamically added components after postback"); endRequest(); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/stateless/StatelessTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/stateless/StatelessTest.java index 68c50a2fa0..9a9a920c56 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/stateless/StatelessTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/stateless/StatelessTest.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.stateless; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.faces.application.StateManager; import jakarta.faces.component.UIComponent; import jakarta.faces.render.ResponseStateManager; @@ -25,13 +27,12 @@ import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.test.core.AbstractMyFacesRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * See https://issues.apache.org/jira/browse/MYFACES-4267 */ -public class StatelessTest extends AbstractMyFacesCDIRequestTestCase +class StatelessTest extends AbstractMyFacesCDIRequestTestCase { @Override protected void setUpWebConfigParams() throws Exception @@ -41,19 +42,19 @@ protected void setUpWebConfigParams() throws Exception servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.StateSavingMethod.SERVER.name()); servletContext.addInitParameter(MyfacesConfig.REFRESH_TRANSIENT_BUILD_ON_PSS, "auto"); } - + /** * Verify that a view with a template that has transient set can be restored * * @throws Exception */ @Test - public void restoreStatelessTemplateView() throws Exception + void restoreStatelessTemplateView() throws Exception { startViewRequest("/stateless.xhtml"); processLifecycleExecuteAndRender(); - Assertions.assertTrue(facesContext.getViewRoot().isTransient()); + assertTrue(facesContext.getViewRoot().isTransient()); // set the view state param so this context is treated as a postback client.getParameters().put(ResponseStateManager.VIEW_STATE_PARAM, "stateless"); @@ -64,18 +65,18 @@ public void restoreStatelessTemplateView() throws Exception // this will cause an exception without the fix in MYFACES-4267 restoreView(); } catch (Exception e) { - Assertions.fail("caught an exception trying to restore a stateless view", e); + fail("caught an exception trying to restore a stateless view", e); endRequest(); return; } - Assertions.assertNotNull(facesContext.getViewRoot()); + assertNotNull(facesContext.getViewRoot()); // render the response and make sure the view contains the expected text renderResponse(); String text = getRenderedContent(facesContext); - Assertions.assertTrue(text.contains("success")); + assertTrue(text.contains("success")); endRequest(); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/AbstractMyfaces4585FaceletsIntegrationTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/AbstractMyfaces4585FaceletsIntegrationTestCase.java index d82dd005ac..7aaeb25455 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/AbstractMyfaces4585FaceletsIntegrationTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/AbstractMyfaces4585FaceletsIntegrationTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.tag; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; @@ -37,7 +39,6 @@ import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -86,7 +87,7 @@ protected ExpressionFactory createExpressionFactory() } @Test - public void testTagAttributeConverterMethodNotLost4585() throws Exception + public void tagAttributeConverterMethodNotLost4585() throws Exception { facesContext.getExternalContext().getRequestMap().put("autoCompleteDepartmentConverter", new DepartmentConverter()); @@ -96,9 +97,9 @@ public void testTagAttributeConverterMethodNotLost4585() throws Exception vdl.buildView(facesContext, root, "myfaces4585_test.xhtml"); String out = render(root); - Assertions.assertTrue(out.contains("Development"), () -> out); - Assertions.assertTrue(out.contains("Sales"), () -> out); - Assertions.assertTrue(out.contains("departmentName"), () -> out); + assertTrue(out.contains("Development"), () -> out); + assertTrue(out.contains("Sales"), () -> out); + assertTrue(out.contains("departmentName"), () -> out); } public static class TestViewBean diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/AbstractMyfaces4589FaceletsIntegrationTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/AbstractMyfaces4589FaceletsIntegrationTestCase.java index a1b45f9b9b..e78c2f07d1 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/AbstractMyfaces4589FaceletsIntegrationTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/AbstractMyfaces4589FaceletsIntegrationTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.tag; +import static org.junit.jupiter.api.Assertions.assertTrue; + import jakarta.el.ExpressionFactory; import jakarta.faces.application.ProjectStage; import jakarta.faces.application.StateManager; @@ -26,7 +28,6 @@ import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -74,7 +75,7 @@ protected ExpressionFactory createExpressionFactory() * Asserts request beans {@code color} / {@code icon} are not shadowed inside nested composites (MYFACES-4589). */ @Test - public void testExternalReproducerTagAttributeShadowing4589() throws Exception + public void externalReproducerTagAttributeShadowing4589() throws Exception { facesContext.getExternalContext().getRequestMap().put("color", new ColorBean()); facesContext.getExternalContext().getRequestMap().put("icon", new IconBean()); @@ -84,10 +85,10 @@ public void testExternalReproducerTagAttributeShadowing4589() throws Exception vdl.buildView(facesContext, root, "myfaces4589_test.xhtml"); String out = render(root); - Assertions.assertTrue(out.contains("color-blue-panel"), () -> out); - Assertions.assertTrue(out.contains("pi pi-at pi-spin"), () -> out); - Assertions.assertTrue(out.contains("color-blue"), () -> out); - Assertions.assertTrue(out.contains("Development"), () -> out); + assertTrue(out.contains("color-blue-panel"), () -> out); + assertTrue(out.contains("pi pi-at pi-spin"), () -> out); + assertTrue(out.contains("color-blue"), () -> out); + assertTrue(out.contains("Development"), () -> out); } public static class ColorBean diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/TagAttributesImplTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/TagAttributesImplTest.java index d3892db635..b4dff73fd0 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/TagAttributesImplTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/TagAttributesImplTest.java @@ -18,42 +18,43 @@ */ package org.apache.myfaces.view.facelets.tag; +import static org.junit.jupiter.api.Assertions.*; + import java.util.Arrays; import jakarta.faces.view.facelets.TagAttribute; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TagAttributesImplTest +class TagAttributesImplTest { @Test - public void testNamespaceMapping() + void namespaceMapping() { TagAttributeImpl test1 = new TagAttributeImpl(null, "", "test1", null, ""); TagAttributeImpl test2 = new TagAttributeImpl(null, "", "test2", null, ""); TagAttributeImpl testTest1 = new TagAttributeImpl(null, "test", "test1", null, ""); TagAttributesImpl impl = new TagAttributesImpl(new TagAttribute[] { test1, test2, testTest1 }); - Assertions.assertEquals(test1, impl.get("test1")); - Assertions.assertEquals(test2, impl.get("test2")); + assertEquals(test1, impl.get("test1")); + assertEquals(test2, impl.get("test2")); - Assertions.assertEquals(testTest1, impl.get("test", "test1")); + assertEquals(testTest1, impl.get("test", "test1")); - Assertions.assertEquals(3, Arrays.asList(impl.getAll()).size()); - Assertions.assertTrue(Arrays.asList(impl.getAll()).contains(test1)); - Assertions.assertTrue(Arrays.asList(impl.getAll()).contains(test2)); - Assertions.assertTrue(Arrays.asList(impl.getAll()).contains(testTest1)); + assertEquals(3, Arrays.asList(impl.getAll()).size()); + assertTrue(Arrays.asList(impl.getAll()).contains(test1)); + assertTrue(Arrays.asList(impl.getAll()).contains(test2)); + assertTrue(Arrays.asList(impl.getAll()).contains(testTest1)); - Assertions.assertEquals(2, Arrays.asList(impl.getAll("")).size()); - Assertions.assertTrue(Arrays.asList(impl.getAll()).contains(test1)); - Assertions.assertTrue(Arrays.asList(impl.getAll()).contains(test2)); + assertEquals(2, Arrays.asList(impl.getAll("")).size()); + assertTrue(Arrays.asList(impl.getAll()).contains(test1)); + assertTrue(Arrays.asList(impl.getAll()).contains(test2)); } - + @Test - public void testNotAvailable() + void notAvailable() { TagAttributesImpl impl = new TagAttributesImpl(new TagAttribute[] { }); - Assertions.assertEquals(null, impl.get("test1")); - Assertions.assertEquals(null, impl.get("test", "test2")); + assertNull(impl.get("test1")); + assertNull(impl.get("test", "test2")); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentActionListenerTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentActionListenerTestCase.java index fe0d297bfb..74772c2130 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentActionListenerTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentActionListenerTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.tag.composite; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.el.ExpressionFactory; import jakarta.faces.component.UICommand; import jakarta.faces.component.UIComponent; @@ -26,10 +28,9 @@ import jakarta.faces.event.ActionEvent; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CompositeComponentActionListenerTestCase extends AbstractFaceletTestCase +class CompositeComponentActionListenerTestCase extends AbstractFaceletTestCase { @Override protected void setupComponents() throws Exception @@ -52,9 +53,9 @@ protected ExpressionFactory createExpressionFactory() { return new org.apache.el.ExpressionFactoryImpl(); } - + @Test - public void testSimpleActionListenerTarget() throws Exception + void simpleActionListenerTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -66,34 +67,34 @@ public void testSimpleActionListenerTarget() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UICommand button1 = (UICommand) compositeComponent1.findComponent("testComponent"); - Assertions.assertNotNull(button1); - Assertions.assertNotNull(button1.getActionListeners()); - Assertions.assertEquals(1, button1.getActionListeners().length); + assertNotNull(button1); + assertNotNull(button1.getActionListeners()); + assertEquals(1, button1.getActionListeners().length); bean.setActionListener1Called(false); button1.getActionListeners()[0].processAction(new ActionEvent(button1)); - Assertions.assertTrue(bean.isActionListener1Called()); + assertTrue(bean.isActionListener1Called()); UIComponent panelGroup2 = root.findComponent("testGroup2"); - Assertions.assertNotNull(panelGroup2); + assertNotNull(panelGroup2); UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UICommand button2 = (UICommand) compositeComponent2.findComponent("testComponent"); - Assertions.assertNotNull(button2); - Assertions.assertNotNull(button2.getActionListeners()); - Assertions.assertEquals(1, button2.getActionListeners().length); + assertNotNull(button2); + assertNotNull(button2.getActionListeners()); + assertEquals(1, button2.getActionListeners().length); bean.setActionListener2Called(false); button2.getActionListeners()[0].processAction(new ActionEvent(button2)); - Assertions.assertTrue(bean.isActionListener2Called()); + assertTrue(bean.isActionListener2Called()); } @Test - public void testCompositeActionListenerTarget() throws Exception + void compositeActionListenerTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -104,41 +105,41 @@ public void testCompositeActionListenerTarget() throws Exception vdl.buildView(facesContext, root, "testCompositeAttributeActionListenerTarget.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UINamingContainer compositeComponent1inner = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent1inner); + assertNotNull(compositeComponent1inner); UICommand button1 = (UICommand) compositeComponent1inner.findComponent("testComponent"); - Assertions.assertNotNull(button1); - Assertions.assertNotNull(button1.getActionListeners()); - Assertions.assertEquals(1, button1.getActionListeners().length); + assertNotNull(button1); + assertNotNull(button1.getActionListeners()); + assertEquals(1, button1.getActionListeners().length); bean.setActionListener1Called(false); button1.getActionListeners()[0].processAction(new ActionEvent(button1)); - Assertions.assertTrue(bean.isActionListener1Called()); + assertTrue(bean.isActionListener1Called()); UIComponent panelGroup2 = root.findComponent("testGroup2"); - Assertions.assertNotNull(panelGroup2); + assertNotNull(panelGroup2); UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UINamingContainer compositeComponent2inner = (UINamingContainer) compositeComponent2.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent2inner); + assertNotNull(compositeComponent2inner); UICommand button2 = (UICommand) compositeComponent2inner.findComponent("testComponent"); - Assertions.assertNotNull(button2); - Assertions.assertNotNull(button2.getActionListeners()); - Assertions.assertEquals(1, button2.getActionListeners().length); + assertNotNull(button2); + assertNotNull(button2.getActionListeners()); + assertEquals(1, button2.getActionListeners().length); bean.setActionListener2Called(false); button2.getActionListeners()[0].processAction(new ActionEvent(button2)); - Assertions.assertTrue(bean.isActionListener2Called()); + assertTrue(bean.isActionListener2Called()); } - + @Test - public void testSimpleActionListenerTarget2() throws Exception + void simpleActionListenerTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -150,58 +151,58 @@ public void testSimpleActionListenerTarget2() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UICommand button1 = (UICommand) compositeComponent1.findComponent("testComponent"); - Assertions.assertNotNull(button1); - Assertions.assertNotNull(button1.getActionListeners()); - Assertions.assertEquals(1, button1.getActionListeners().length); + assertNotNull(button1); + assertNotNull(button1.getActionListeners()); + assertEquals(1, button1.getActionListeners().length); bean.setActionListener1Called(false); button1.getActionListeners()[0].processAction(new ActionEvent(button1)); - Assertions.assertTrue(bean.isActionListener1Called()); + assertTrue(bean.isActionListener1Called()); UICommand button1n = (UICommand) compositeComponent1.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(button1n); - Assertions.assertNotNull(button1n.getActionListeners()); - Assertions.assertEquals(1, button1n.getActionListeners().length); + assertNotNull(button1n); + assertNotNull(button1n.getActionListeners()); + assertEquals(1, button1n.getActionListeners().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); bean.setActionListener1Called(false); button1n.getActionListeners()[0].processAction(new ActionEvent(button1n)); - Assertions.assertTrue(bean.isActionListener1Called()); + assertTrue(bean.isActionListener1Called()); compositeComponent1.popComponentFromEL(facesContext); UIComponent panelGroup2 = root.findComponent("testGroup2"); - Assertions.assertNotNull(panelGroup2); + assertNotNull(panelGroup2); UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UICommand button2 = (UICommand) compositeComponent2.findComponent("testComponent"); - Assertions.assertNotNull(button2); - Assertions.assertNotNull(button2.getActionListeners()); - Assertions.assertEquals(1, button2.getActionListeners().length); + assertNotNull(button2); + assertNotNull(button2.getActionListeners()); + assertEquals(1, button2.getActionListeners().length); bean.setActionListener2Called(false); button2.getActionListeners()[0].processAction(new ActionEvent(button2)); - Assertions.assertTrue(bean.isActionListener2Called()); + assertTrue(bean.isActionListener2Called()); UICommand button2n = (UICommand) compositeComponent2.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(button2n); - Assertions.assertNotNull(button2n.getActionListeners()); - Assertions.assertEquals(1, button2n.getActionListeners().length); + assertNotNull(button2n); + assertNotNull(button2n.getActionListeners()); + assertEquals(1, button2n.getActionListeners().length); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2); bean.setActionListener2Called(false); button2n.getActionListeners()[0].processAction(new ActionEvent(button2n)); - Assertions.assertTrue(bean.isActionListener2Called()); + assertTrue(bean.isActionListener2Called()); compositeComponent2.popComponentFromEL(facesContext); } @Test - public void testCompositeActionListenerTarget2() throws Exception + void compositeActionListenerTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -212,120 +213,120 @@ public void testCompositeActionListenerTarget2() throws Exception vdl.buildView(facesContext, root, "testCompositeAttributeActionListenerTarget2.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UINamingContainer compositeComponent1target = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent1target); + assertNotNull(compositeComponent1target); UICommand button1target = (UICommand) compositeComponent1target.findComponent("testComponent"); - Assertions.assertNotNull(button1target); - Assertions.assertNotNull(button1target.getActionListeners()); - Assertions.assertEquals(1, button1target.getActionListeners().length); + assertNotNull(button1target); + assertNotNull(button1target.getActionListeners()); + assertEquals(1, button1target.getActionListeners().length); bean.setActionListener1Called(false); button1target.getActionListeners()[0].processAction(new ActionEvent(button1target)); - Assertions.assertTrue(bean.isActionListener1Called()); + assertTrue(bean.isActionListener1Called()); UICommand button1notarget = (UICommand) compositeComponent1target.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(button1notarget); - Assertions.assertNotNull(button1notarget.getActionListeners()); - Assertions.assertEquals(1, button1notarget.getActionListeners().length); + assertNotNull(button1notarget); + assertNotNull(button1notarget.getActionListeners()); + assertEquals(1, button1notarget.getActionListeners().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1target.pushComponentToEL(facesContext, compositeComponent1target); bean.setActionListener1Called(false); button1notarget.getActionListeners()[0].processAction(new ActionEvent(button1notarget)); - Assertions.assertTrue(bean.isActionListener1Called()); + assertTrue(bean.isActionListener1Called()); compositeComponent1target.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); UINamingContainer compositeComponent1notarget = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent1notarget); + assertNotNull(compositeComponent1notarget); UICommand buttonnotarget1target = (UICommand) compositeComponent1notarget.findComponent("testComponent"); - Assertions.assertNotNull(buttonnotarget1target); - Assertions.assertNotNull(buttonnotarget1target.getActionListeners()); - Assertions.assertEquals(1, buttonnotarget1target.getActionListeners().length); + assertNotNull(buttonnotarget1target); + assertNotNull(buttonnotarget1target.getActionListeners()); + assertEquals(1, buttonnotarget1target.getActionListeners().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1notarget.pushComponentToEL(facesContext, compositeComponent1notarget); bean.setActionListener1Called(false); buttonnotarget1target.getActionListeners()[0].processAction(new ActionEvent(buttonnotarget1target)); - Assertions.assertTrue(bean.isActionListener1Called()); + assertTrue(bean.isActionListener1Called()); compositeComponent1notarget.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); UICommand buttonnotarget1notarget = (UICommand) compositeComponent1notarget.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(buttonnotarget1notarget); - Assertions.assertNotNull(buttonnotarget1notarget.getActionListeners()); - Assertions.assertEquals(1, buttonnotarget1notarget.getActionListeners().length); + assertNotNull(buttonnotarget1notarget); + assertNotNull(buttonnotarget1notarget.getActionListeners()); + assertEquals(1, buttonnotarget1notarget.getActionListeners().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1notarget.pushComponentToEL(facesContext, compositeComponent1notarget); bean.setActionListener1Called(false); buttonnotarget1notarget.getActionListeners()[0].processAction(new ActionEvent(buttonnotarget1notarget)); - Assertions.assertTrue(bean.isActionListener1Called()); + assertTrue(bean.isActionListener1Called()); compositeComponent1notarget.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); UIComponent panelGroup2 = root.findComponent("testGroup2"); - Assertions.assertNotNull(panelGroup2); + assertNotNull(panelGroup2); UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UINamingContainer compositeComponent2target = (UINamingContainer) compositeComponent2.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent2target); + assertNotNull(compositeComponent2target); UICommand button2target = (UICommand) compositeComponent2target.findComponent("testComponent"); - Assertions.assertNotNull(button2target); - Assertions.assertNotNull(button2target.getActionListeners()); - Assertions.assertEquals(1, button2target.getActionListeners().length); + assertNotNull(button2target); + assertNotNull(button2target.getActionListeners()); + assertEquals(1, button2target.getActionListeners().length); bean.setActionListener2Called(false); button2target.getActionListeners()[0].processAction(new ActionEvent(button2target)); - Assertions.assertTrue(bean.isActionListener2Called()); + assertTrue(bean.isActionListener2Called()); UICommand button2notarget = (UICommand) compositeComponent2target.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(button2notarget); - Assertions.assertNotNull(button2notarget.getActionListeners()); - Assertions.assertEquals(1, button2notarget.getActionListeners().length); + assertNotNull(button2notarget); + assertNotNull(button2notarget.getActionListeners()); + assertEquals(1, button2notarget.getActionListeners().length); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2); compositeComponent2target.pushComponentToEL(facesContext, compositeComponent2target); bean.setActionListener2Called(false); button2notarget.getActionListeners()[0].processAction(new ActionEvent(button2notarget)); - Assertions.assertTrue(bean.isActionListener2Called()); + assertTrue(bean.isActionListener2Called()); compositeComponent2target.popComponentFromEL(facesContext); compositeComponent2.popComponentFromEL(facesContext); UINamingContainer compositeComponent2notarget = (UINamingContainer) compositeComponent2.findComponent("simpleAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent2notarget); + assertNotNull(compositeComponent2notarget); UICommand buttonnotarget2target = (UICommand) compositeComponent2notarget.findComponent("testComponent"); - Assertions.assertNotNull(buttonnotarget2target); - Assertions.assertNotNull(buttonnotarget2target.getActionListeners()); - Assertions.assertEquals(1, buttonnotarget2target.getActionListeners().length); + assertNotNull(buttonnotarget2target); + assertNotNull(buttonnotarget2target.getActionListeners()); + assertEquals(1, buttonnotarget2target.getActionListeners().length); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2); compositeComponent2notarget.pushComponentToEL(facesContext, compositeComponent2notarget); bean.setActionListener2Called(false); buttonnotarget2target.getActionListeners()[0].processAction(new ActionEvent(buttonnotarget2target)); - Assertions.assertTrue(bean.isActionListener2Called()); + assertTrue(bean.isActionListener2Called()); compositeComponent2notarget.popComponentFromEL(facesContext); compositeComponent2.popComponentFromEL(facesContext); UICommand buttonnotarget2notarget = (UICommand) compositeComponent2notarget.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(buttonnotarget2notarget); - Assertions.assertNotNull(buttonnotarget2notarget.getActionListeners()); - Assertions.assertEquals(1, buttonnotarget2notarget.getActionListeners().length); + assertNotNull(buttonnotarget2notarget); + assertNotNull(buttonnotarget2notarget.getActionListeners()); + assertEquals(1, buttonnotarget2notarget.getActionListeners().length); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2); compositeComponent2notarget.pushComponentToEL(facesContext, compositeComponent2notarget); bean.setActionListener2Called(false); buttonnotarget2notarget.getActionListeners()[0].processAction(new ActionEvent(buttonnotarget2notarget)); - Assertions.assertTrue(bean.isActionListener2Called()); + assertTrue(bean.isActionListener2Called()); compositeComponent2notarget.popComponentFromEL(facesContext); compositeComponent2.popComponentFromEL(facesContext); } - + @Test - public void testSimpleActionListenerNoTarget() throws Exception + void simpleActionListenerNoTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -336,44 +337,44 @@ public void testSimpleActionListenerNoTarget() throws Exception vdl.buildView(facesContext, root, "testSimpleAttributeActionListenerNoTarget.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UICommand button1 = (UICommand) compositeComponent1.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(button1); - Assertions.assertNotNull(button1.getActionListeners()); - Assertions.assertEquals(1, button1.getActionListeners().length); + assertNotNull(button1); + assertNotNull(button1.getActionListeners()); + assertEquals(1, button1.getActionListeners().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); button1.pushComponentToEL(facesContext, button1); bean.setActionListener1Called(false); button1.getActionListeners()[0].processAction(new ActionEvent(button1)); - Assertions.assertTrue(bean.isActionListener1Called()); + assertTrue(bean.isActionListener1Called()); button1.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); UIComponent panelGroup2 = root.findComponent("testGroup2"); - Assertions.assertNotNull(panelGroup2); + assertNotNull(panelGroup2); UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UICommand button2 = (UICommand) compositeComponent2.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(button2); - Assertions.assertNotNull(button2.getActionListeners()); - Assertions.assertEquals(1, button2.getActionListeners().length); + assertNotNull(button2); + assertNotNull(button2.getActionListeners()); + assertEquals(1, button2.getActionListeners().length); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2); button2.pushComponentToEL(facesContext, button2); bean.setActionListener2Called(false); button2.getActionListeners()[0].processAction(new ActionEvent(button2)); - Assertions.assertTrue(bean.isActionListener2Called()); + assertTrue(bean.isActionListener2Called()); button2.popComponentFromEL(facesContext); compositeComponent2.popComponentFromEL(facesContext); } - + @Test - public void testCompositeActionListenerNoTarget() throws Exception + void compositeActionListenerNoTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -384,49 +385,49 @@ public void testCompositeActionListenerNoTarget() throws Exception vdl.buildView(facesContext, root, "testCompositeAttributeActionListenerNoTarget.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UINamingContainer compositeComponent1inner = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeActionMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent1inner); + assertNotNull(compositeComponent1inner); UICommand testComponentNoTarget1 = (UICommand) compositeComponent1inner.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget1); - Assertions.assertNotNull(testComponentNoTarget1.getActionListeners()); - Assertions.assertEquals(1, testComponentNoTarget1.getActionListeners().length); + assertNotNull(testComponentNoTarget1); + assertNotNull(testComponentNoTarget1.getActionListeners()); + assertEquals(1, testComponentNoTarget1.getActionListeners().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1inner); bean.setActionListener1Called(false); testComponentNoTarget1.getActionListeners()[0].processAction(new ActionEvent(testComponentNoTarget1)); - Assertions.assertTrue(bean.isActionListener1Called()); + assertTrue(bean.isActionListener1Called()); compositeComponent1inner.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); UIComponent panelGroup2 = root.findComponent("testGroup2"); - Assertions.assertNotNull(panelGroup2); + assertNotNull(panelGroup2); UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UINamingContainer compositeComponent2inner = (UINamingContainer) compositeComponent2.findComponent("simpleAttributeActionMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent2inner); + assertNotNull(compositeComponent2inner); UICommand testComponentNoTarget2 = (UICommand) compositeComponent2inner.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget2); - Assertions.assertNotNull(testComponentNoTarget2.getActionListeners()); - Assertions.assertEquals(1, testComponentNoTarget2.getActionListeners().length); + assertNotNull(testComponentNoTarget2); + assertNotNull(testComponentNoTarget2.getActionListeners()); + assertEquals(1, testComponentNoTarget2.getActionListeners().length); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2inner); bean.setActionListener2Called(false); testComponentNoTarget2.getActionListeners()[0].processAction(new ActionEvent(testComponentNoTarget2)); - Assertions.assertTrue(bean.isActionListener2Called()); + assertTrue(bean.isActionListener2Called()); compositeComponent2inner.popComponentFromEL(facesContext); compositeComponent2.popComponentFromEL(facesContext); } @Test - public void testCompositeActionListenerNoTarget2() throws Exception + void compositeActionListenerNoTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -437,23 +438,23 @@ public void testCompositeActionListenerNoTarget2() throws Exception vdl.buildView(facesContext, root, "testCompositeAttributeActionListenerNoTarget2.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UINamingContainer compositeComponent1n1 = (UINamingContainer) compositeComponent1.findComponent("compositeAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent1n1); + assertNotNull(compositeComponent1n1); UINamingContainer compositeComponent1n2 = (UINamingContainer) compositeComponent1n1.findComponent("simpleAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent1n2); + assertNotNull(compositeComponent1n2); UICommand button1 = (UICommand) compositeComponent1n2.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(button1); - Assertions.assertNotNull(button1.getActionListeners()); - Assertions.assertEquals(1, button1.getActionListeners().length); + assertNotNull(button1); + assertNotNull(button1.getActionListeners()); + assertEquals(1, button1.getActionListeners().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1n2); bean.setActionListener1Called(false); button1.getActionListeners()[0].processAction(new ActionEvent(button1)); - Assertions.assertTrue(bean.isActionListener1Called()); + assertTrue(bean.isActionListener1Called()); compositeComponent1n2.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentAttributeTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentAttributeTestCase.java index cef3f6a1ed..c1e1ba5af2 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentAttributeTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentAttributeTestCase.java @@ -19,6 +19,8 @@ package org.apache.myfaces.view.facelets.tag.composite; +import static org.junit.jupiter.api.Assertions.*; + import java.beans.BeanDescriptor; import java.beans.FeatureDescriptor; import java.beans.PropertyDescriptor; @@ -46,10 +48,9 @@ import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; import org.apache.myfaces.view.facelets.bean.DummyBean; import org.apache.myfaces.view.facelets.bean.HelloWorld; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CompositeComponentAttributeTestCase extends AbstractFaceletTestCase +class CompositeComponentAttributeTestCase extends AbstractFaceletTestCase { @Override @@ -66,7 +67,7 @@ protected void setupComponents() throws Exception * @throws Exception */ @Test - public void testSimpleCompositeAttribute() throws Exception + void simpleCompositeAttribute() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -77,35 +78,35 @@ public void testSimpleCompositeAttribute() throws Exception vdl.buildView(facesContext, root, "testSimpleAttributeVE.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); CompositeTestComponent compositeComponent1 = (CompositeTestComponent) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); HtmlOutputText text1 = (HtmlOutputText) facet1.findComponent("text"); - Assertions.assertNotNull(text1); + assertNotNull(text1); HtmlCommandButton button1 = (HtmlCommandButton) facet1.findComponent("button"); - Assertions.assertNotNull(button1); + assertNotNull(button1); HtmlInputText input1 = (HtmlInputText) facet1.findComponent("input"); - Assertions.assertNotNull(input1); + assertNotNull(input1); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); facet1.pushComponentToEL(facesContext, facet1); text1.pushComponentToEL(facesContext, text1); //set on tag - Assertions.assertEquals(bean.getStyleClass(), text1.getStyleClass()); + assertEquals(bean.getStyleClass(), text1.getStyleClass()); //set as default - Assertions.assertEquals(bean.getStyle(), text1.getStyle()); + assertEquals(bean.getStyle(), text1.getStyle()); - Assertions.assertEquals(bean.getJavaProperty(), text1.getValue()); + assertEquals(bean.getJavaProperty(), text1.getValue()); - Assertions.assertEquals(bean.getValue(), input1.getValue()); - Assertions.assertEquals(true, input1.isRequired()); + assertEquals(bean.getValue(), input1.getValue()); + assertTrue(input1.isRequired()); text1.popComponentFromEL(facesContext); button1.pushComponentToEL(facesContext, button1); MethodExpression method = button1.getActionExpression(); - Assertions.assertEquals(bean.doSomethingFunny("xysj"), method.invoke(facesContext.getELContext(), new Object[]{"xysj"})); + assertEquals(bean.doSomethingFunny("xysj"), method.invoke(facesContext.getELContext(), new Object[]{"xysj"})); button1.popComponentFromEL(facesContext); facet1.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); @@ -123,14 +124,14 @@ public void testSimpleCompositeAttribute() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); } - + /** * Test simple attribute resolution (not set, default, normal use case). * * @throws Exception */ @Test - public void testSimpleCompositeAttributeInsertChildren() throws Exception + void simpleCompositeAttributeInsertChildren() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -141,34 +142,34 @@ public void testSimpleCompositeAttributeInsertChildren() throws Exception vdl.buildView(facesContext, root, "testSimpleAttributeVEInsertChildren.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); CompositeTestComponent compositeComponent1 = (CompositeTestComponent) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); UIComponent compositeComponent2 = facet1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UIComponent facet2 = compositeComponent2.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet2); + assertNotNull(facet2); HtmlOutputText text1 = (HtmlOutputText) facet2.findComponent("text"); - Assertions.assertNotNull(text1); + assertNotNull(text1); HtmlCommandButton button1 = (HtmlCommandButton) facet2.findComponent("button"); - Assertions.assertNotNull(button1); + assertNotNull(button1); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); facet1.pushComponentToEL(facesContext, facet1); text1.pushComponentToEL(facesContext, text1); //set on tag - Assertions.assertEquals(bean.getStyleClass(), text1.getStyleClass()); + assertEquals(bean.getStyleClass(), text1.getStyleClass()); //set as default - Assertions.assertEquals(bean.getStyle(), text1.getStyle()); + assertEquals(bean.getStyle(), text1.getStyle()); - Assertions.assertEquals(bean.getJavaProperty(), text1.getValue()); + assertEquals(bean.getJavaProperty(), text1.getValue()); text1.popComponentFromEL(facesContext); button1.pushComponentToEL(facesContext, button1); MethodExpression method = button1.getActionExpression(); - Assertions.assertEquals(bean.doSomethingFunny("xysj"), method.invoke(facesContext.getELContext(), new Object[]{"xysj"})); + assertEquals(bean.doSomethingFunny("xysj"), method.invoke(facesContext.getELContext(), new Object[]{"xysj"})); button1.popComponentFromEL(facesContext); facet1.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); @@ -186,10 +187,10 @@ public void testSimpleCompositeAttributeInsertChildren() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); } - - + + @Test - public void testSimpleMethodInvocation() throws Exception + void simpleMethodInvocation() throws Exception { DummyBean dummyBean = new DummyBean(); @@ -200,27 +201,27 @@ public void testSimpleMethodInvocation() throws Exception vdl.buildView(facesContext, root, "testSimpleMethodInvocation.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); UINamingContainer compositeComponent2 = (UINamingContainer) facet1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UIComponent facet2 = compositeComponent2.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet2); + assertNotNull(facet2); UIForm form = (UIForm) facet2.findComponent("mainForm"); - Assertions.assertNotNull(form); + assertNotNull(form); UICommand button1 = (UICommand) form.findComponent("button1"); - Assertions.assertNotNull(button1); + assertNotNull(button1); UICommand button2 = (UICommand) form.findComponent("button2"); - Assertions.assertNotNull(button2); + assertNotNull(button2); UICommand button3 = (UICommand) form.findComponent("button3"); - Assertions.assertNotNull(button3); + assertNotNull(button3); UIInput text1 = (UIInput) form.findComponent("text1"); - Assertions.assertNotNull(text1); + assertNotNull(text1); UIInput text2 = (UIInput) form.findComponent("text2"); - Assertions.assertNotNull(text2); + assertNotNull(text2); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); facet1.pushComponentToEL(facesContext, facet1); @@ -265,9 +266,9 @@ public void testSimpleMethodInvocation() throws Exception String resp = sw.toString(); } - + @Test - public void testCompositeActionMethodInvocation() throws Exception + void compositeActionMethodInvocation() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -278,19 +279,19 @@ public void testCompositeActionMethodInvocation() throws Exception vdl.buildView(facesContext, root, "testCompositeActionMethodInvocation.xhtml"); UIComponent form = root.findComponent("testForm1"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("button1"); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UICommand button = (UICommand) compositeComponent2.findComponent("button2"); - Assertions.assertNotNull(button); + assertNotNull(button); - Assertions.assertNotNull(button.getActionExpression()); + assertNotNull(button.getActionExpression()); - Assertions.assertEquals("success", button.getActionExpression().invoke(facesContext.getELContext(), null)); + assertEquals("success", button.getActionExpression().invoke(facesContext.getELContext(), null)); - Assertions.assertEquals(1, button.getActionListeners().length); + assertEquals(1, button.getActionListeners().length); //StringWriter sw = new StringWriter(); //MockResponseWriter mrw = new MockResponseWriter(sw); @@ -299,8 +300,8 @@ public void testCompositeActionMethodInvocation() throws Exception //root.encodeAll(facesContext); //sw.flush(); //System.out.print(sw.toString()); - } - + } + /** * Tests if unspecified attributes on , * and are handled correctly. @@ -308,7 +309,7 @@ public void testCompositeActionMethodInvocation() throws Exception */ @Test @SuppressWarnings("unchecked") - public void testUnspecifiedAttributes() throws Exception + void unspecifiedAttributes() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testInterfaceDescriptorAttributes.xhtml"); @@ -318,7 +319,7 @@ public void testUnspecifiedAttributes() throws Exception CompositeComponentBeanInfo beanInfo = (CompositeComponentBeanInfo) composite.getAttributes() .get(UIComponent.BEANINFO_KEY); - Assertions.assertNotNull(beanInfo); + assertNotNull(beanInfo); // get the descriptor and check the unspecified attribute BeanDescriptor interfaceDescriptor = beanInfo.getBeanDescriptor(); @@ -326,7 +327,7 @@ public void testUnspecifiedAttributes() throws Exception "unspecifiedInterfaceAttribute", "unspecifiedInterfaceValue"); // check - Assertions.assertEquals(1, beanInfo.getPropertyDescriptors().length, + assertEquals(1, beanInfo.getPropertyDescriptors().length, "Expecting one "); PropertyDescriptor attributeDescriptor = beanInfo.getPropertyDescriptors()[0]; _checkUnspecifiedAttribute(attributeDescriptor, @@ -335,7 +336,7 @@ public void testUnspecifiedAttributes() throws Exception // check Map facetPropertyDescriptorMap = (Map) interfaceDescriptor.getValue(UIComponent.FACETS_KEY); - Assertions.assertNotNull(facetPropertyDescriptorMap); + assertNotNull(facetPropertyDescriptorMap); PropertyDescriptor facetDescriptor = facetPropertyDescriptorMap.get("facet"); _checkUnspecifiedAttribute(facetDescriptor, "unspecifiedFacetAttribute", "unspecifiedFacetValue"); @@ -351,12 +352,11 @@ private void _checkUnspecifiedAttribute(FeatureDescriptor descriptor, final String attributeName, final String attributeValue) { Object value = descriptor.getValue(attributeName); - Assertions.assertTrue(value instanceof ValueExpression, - "Unspecified attributes must be stored as a ValueExpression"); - Assertions.assertEquals(attributeValue, + assertInstanceOf(ValueExpression.class, value, "Unspecified attributes must be stored as a ValueExpression"); + assertEquals(attributeValue, ((ValueExpression) value).getValue(facesContext.getELContext())); } - + /** * The "displayName", "shortDescription", "expert", "hidden", and "preferred" * attributes are only exposed, if ProjectStage equals Development. This test @@ -364,11 +364,11 @@ private void _checkUnspecifiedAttribute(FeatureDescriptor descriptor, * @throws Exception */ @Test - public void testDevelopmentValuesDevelopmentStage() throws Exception + void developmentValuesDevelopmentStage() throws Exception { _testDevelopmentValues(ProjectStage.Development); } - + /** * The "displayName", "shortDescription", "expert", "hidden", and "preferred" * attributes are only exposed, if ProjectStage equals Development. This test @@ -377,7 +377,7 @@ public void testDevelopmentValuesDevelopmentStage() throws Exception * @throws Exception */ @Test - public void testDevelopmentValuesProductionStage() throws Exception + void developmentValuesProductionStage() throws Exception { _testDevelopmentValues(ProjectStage.Production); } @@ -404,7 +404,7 @@ private void _testDevelopmentValues(ProjectStage stage) throws Exception CompositeComponentBeanInfo beanInfo = (CompositeComponentBeanInfo) composite.getAttributes() .get(UIComponent.BEANINFO_KEY); - Assertions.assertNotNull(beanInfo); + assertNotNull(beanInfo); // check BeanDescriptor interfaceDescriptor = beanInfo.getBeanDescriptor(); @@ -412,7 +412,7 @@ private void _testDevelopmentValues(ProjectStage stage) throws Exception "interfaceShortDescription", development); // check - Assertions.assertEquals(1, beanInfo.getPropertyDescriptors().length, + assertEquals(1, beanInfo.getPropertyDescriptors().length, "Expecting one "); PropertyDescriptor attributeDescriptor = beanInfo.getPropertyDescriptors()[0]; _checkDevelopmentValues(attributeDescriptor, "attributeDisplayName", @@ -421,7 +421,7 @@ private void _testDevelopmentValues(ProjectStage stage) throws Exception // check Map facetPropertyDescriptorMap = (Map) interfaceDescriptor.getValue(UIComponent.FACETS_KEY); - Assertions.assertNotNull(facetPropertyDescriptorMap); + assertNotNull(facetPropertyDescriptorMap); PropertyDescriptor facetDescriptor = facetPropertyDescriptorMap.get("facet"); _checkDevelopmentValues(facetDescriptor, "facetDisplayName", "facetShortDescription", development); @@ -462,15 +462,15 @@ private void _checkDevelopmentValues(FeatureDescriptor descriptor, } // Assertions - Assertions.assertEquals(displayName, descriptor.getDisplayName()); - Assertions.assertEquals(shortDescription, descriptor.getShortDescription()); - Assertions.assertEquals(booleanPropertiesValue, descriptor.isExpert()); - Assertions.assertEquals(booleanPropertiesValue, descriptor.isHidden()); - Assertions.assertEquals(booleanPropertiesValue, descriptor.isPreferred()); + assertEquals(displayName, descriptor.getDisplayName()); + assertEquals(shortDescription, descriptor.getShortDescription()); + assertEquals(booleanPropertiesValue, descriptor.isExpert()); + assertEquals(booleanPropertiesValue, descriptor.isHidden()); + assertEquals(booleanPropertiesValue, descriptor.isPreferred()); } - + @Test - public void testSimpleActionTargetAttributeName() throws Exception + void simpleActionTargetAttributeName() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -481,36 +481,36 @@ public void testSimpleActionTargetAttributeName() throws Exception vdl.buildView(facesContext, root, "testActionTargetAttributeName.xhtml"); UIComponent panelGroup1 = root.findComponent("mainForm:testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.findComponent("cc1"); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); HtmlCommandButton button1 = (HtmlCommandButton) facet1.findComponent("submitButton"); - Assertions.assertNotNull(button1); + assertNotNull(button1); HtmlCommandButton button2 = (HtmlCommandButton) facet1.findComponent("cancelAction"); - Assertions.assertNotNull(button2); + assertNotNull(button2); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); facet1.pushComponentToEL(facesContext, facet1); button1.pushComponentToEL(facesContext, button1); MethodExpression method = button1.getActionExpression(); - Assertions.assertEquals("testActionMethodTypeSubmit", method.invoke(facesContext.getELContext(), null)); + assertEquals("testActionMethodTypeSubmit", method.invoke(facesContext.getELContext(), null)); - Assertions.assertEquals(1, button1.getActionListeners().length); + assertEquals(1, button1.getActionListeners().length); button1.getActionListeners()[0].processAction(new ActionEvent(button1)); - Assertions.assertTrue(bean.isSubmitActionListenerCalled()); + assertTrue(bean.isSubmitActionListenerCalled()); button1.popComponentFromEL(facesContext); button2.pushComponentToEL(facesContext, button2); method = button2.getActionExpression(); - Assertions.assertEquals(bean.cancelAction(), method.invoke(facesContext.getELContext(), null)); + assertEquals(bean.cancelAction(), method.invoke(facesContext.getELContext(), null)); - Assertions.assertEquals(1, button2.getActionListeners().length); + assertEquals(1, button2.getActionListeners().length); button2.getActionListeners()[0].processAction(new ActionEvent(button2)); - Assertions.assertTrue(bean.isCancelActionListenerCalled()); + assertTrue(bean.isCancelActionListenerCalled()); button2.popComponentFromEL(facesContext); facet1.popComponentFromEL(facesContext); @@ -533,7 +533,7 @@ public void testSimpleActionTargetAttributeName() throws Exception } @Test - public void testCompositeActionTargetAttributeName() throws Exception + void compositeActionTargetAttributeName() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -544,21 +544,21 @@ public void testCompositeActionTargetAttributeName() throws Exception vdl.buildView(facesContext, root, "testCompositeActionTargetAttributeName.xhtml"); UIComponent panelGroup1 = root.findComponent("mainForm:testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.findComponent("cc1"); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); UINamingContainer compositeComponent2 = (UINamingContainer) facet1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UIComponent facet2 = compositeComponent2.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet2); + assertNotNull(facet2); HtmlCommandButton button1 = (HtmlCommandButton) facet2.findComponent("submitButton"); - Assertions.assertNotNull(button1); + assertNotNull(button1); HtmlCommandButton button2 = (HtmlCommandButton) facet2.findComponent("cancelAction"); - Assertions.assertNotNull(button2); + assertNotNull(button2); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); facet1.pushComponentToEL(facesContext, facet1); @@ -567,21 +567,21 @@ public void testCompositeActionTargetAttributeName() throws Exception button1.pushComponentToEL(facesContext, button1); MethodExpression method = button1.getActionExpression(); - Assertions.assertEquals("testActionMethodTypeSubmit", method.invoke(facesContext.getELContext(), null)); + assertEquals("testActionMethodTypeSubmit", method.invoke(facesContext.getELContext(), null)); - Assertions.assertEquals(1, button1.getActionListeners().length); + assertEquals(1, button1.getActionListeners().length); button1.getActionListeners()[0].processAction(new ActionEvent(button1)); - Assertions.assertTrue(bean.isSubmitActionListenerCalled()); + assertTrue(bean.isSubmitActionListenerCalled()); button1.popComponentFromEL(facesContext); button2.pushComponentToEL(facesContext, button2); method = button2.getActionExpression(); - Assertions.assertEquals(bean.cancelAction(), method.invoke(facesContext.getELContext(), null)); + assertEquals(bean.cancelAction(), method.invoke(facesContext.getELContext(), null)); - Assertions.assertEquals(1, button2.getActionListeners().length); + assertEquals(1, button2.getActionListeners().length); button2.getActionListeners()[0].processAction(new ActionEvent(button2)); - Assertions.assertTrue(bean.isCancelActionListenerCalled()); + assertTrue(bean.isCancelActionListenerCalled()); button2.popComponentFromEL(facesContext); facet2.popComponentFromEL(facesContext); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentBeanValidationTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentBeanValidationTest.java index 42d786409f..41a723a96b 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentBeanValidationTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentBeanValidationTest.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.view.facelets.tag.composite; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; + import java.io.IOException; import jakarta.el.ValueExpression; @@ -28,7 +31,6 @@ import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.el.resolver.CompositeComponentELResolver; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -37,7 +39,7 @@ * @author Jakob Korherr (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class CompositeComponentBeanValidationTest extends AbstractFaceletTestCase +class CompositeComponentBeanValidationTest extends AbstractFaceletTestCase { /** @@ -51,7 +53,7 @@ public class CompositeComponentBeanValidationTest extends AbstractFaceletTestCas * @throws IOException */ @Test - public void testCompositeComponentExpressionHolder() throws IOException + void compositeComponentExpressionHolder() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testSimpleEditableValueHolder.xhtml"); @@ -62,16 +64,16 @@ public void testCompositeComponentExpressionHolder() throws IOException // "resolve" #{cc.attrs} CompositeComponentELResolver resolver = new CompositeComponentELResolver(MyfacesConfig.getCurrentInstance()); Object attrs = resolver.getValue(facesContext.getELContext(), compositeComponent, "attrs"); - + // the resolved value has to be a CompositeComponentExpressionHolder - Assertions.assertTrue(attrs instanceof CompositeComponentExpressionHolder); + assertInstanceOf(CompositeComponentExpressionHolder.class, attrs); // get the actual ValueExpression which is needed by the BeanValidator ValueExpression valueExpression = ((CompositeComponentExpressionHolder) attrs).getExpression("input"); - + // the expression String from the VE has to be #{myBean.input} - Assertions.assertTrue("#{myBean.input}".equals(valueExpression.getExpressionString())); + assertEquals("#{myBean.input}", valueExpression.getExpressionString()); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentCCRefTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentCCRefTestCase.java index 0bfc2769c1..76a4463a0f 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentCCRefTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentCCRefTestCase.java @@ -19,6 +19,9 @@ package org.apache.myfaces.view.facelets.tag.composite; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import jakarta.el.ExpressionFactory; @@ -28,10 +31,9 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; import org.apache.myfaces.view.facelets.bean.HelloWorld; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CompositeComponentCCRefTestCase extends AbstractFaceletTestCase +class CompositeComponentCCRefTestCase extends AbstractFaceletTestCase { @Override @@ -45,9 +47,9 @@ protected ExpressionFactory createExpressionFactory() { return new org.apache.el.ExpressionFactoryImpl(); } - + @Test - public void testCCRefOnStylesheet() throws Exception + void cCRefOnStylesheet() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -58,7 +60,7 @@ public void testCCRefOnStylesheet() throws Exception vdl.buildView(facesContext, root, "testCCRefOnStylesheet.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -66,11 +68,11 @@ public void testCCRefOnStylesheet() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains(".myCustomStyle { background:red }")); + assertTrue(sw.toString().contains(".myCustomStyle { background:red }")); } - + @Test - public void testCCRefOnScript() throws Exception + void cCRefOnScript() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -81,7 +83,7 @@ public void testCCRefOnScript() throws Exception vdl.buildView(facesContext, root, "testCCRefOnScript.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -89,7 +91,7 @@ public void testCCRefOnScript() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains(".myCustomStyle { background:red }")); - Assertions.assertTrue(sw.toString().contains(".myCustomScript = 'myvalue'")); + assertTrue(sw.toString().contains(".myCustomStyle { background:red }")); + assertTrue(sw.toString().contains(".myCustomScript = 'myvalue'")); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentCConIncludeTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentCConIncludeTestCase.java index ca1bdf4067..9e7d68b306 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentCConIncludeTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentCConIncludeTestCase.java @@ -19,6 +19,8 @@ package org.apache.myfaces.view.facelets.tag.composite; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import jakarta.el.ExpressionFactory; @@ -26,10 +28,9 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CompositeComponentCConIncludeTestCase extends AbstractFaceletTestCase +class CompositeComponentCConIncludeTestCase extends AbstractFaceletTestCase { @Override @@ -43,9 +44,9 @@ protected ExpressionFactory createExpressionFactory() { return new org.apache.el.ExpressionFactoryImpl(); } - + @Test - public void testCCOnInclude1() throws Exception + void cCOnInclude1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testCConInclude1.xhtml"); @@ -59,13 +60,13 @@ public void testCCOnInclude1() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("value1")); - Assertions.assertTrue(sw.toString().contains("value2")); - Assertions.assertTrue(sw.toString().contains("value3")); + assertTrue(sw.toString().contains("value1")); + assertTrue(sw.toString().contains("value2")); + assertTrue(sw.toString().contains("value3")); } - + @Test - public void testCCOnInclude2() throws Exception + void cCOnInclude2() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testCConInclude2.xhtml"); @@ -79,8 +80,8 @@ public void testCCOnInclude2() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("value1")); - Assertions.assertTrue(sw.toString().contains("value2")); - Assertions.assertTrue(sw.toString().contains("value3")); + assertTrue(sw.toString().contains("value1")); + assertTrue(sw.toString().contains("value2")); + assertTrue(sw.toString().contains("value3")); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentClientBehaviorTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentClientBehaviorTestCase.java index e24f1cb600..af61510e59 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentClientBehaviorTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentClientBehaviorTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.tag.composite; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.faces.component.UICommand; import jakarta.faces.component.UIComponent; import jakarta.faces.component.UINamingContainer; @@ -25,13 +27,12 @@ import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; import org.apache.myfaces.view.facelets.bean.HelloWorld; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CompositeComponentClientBehaviorTestCase extends AbstractFaceletTestCase +class CompositeComponentClientBehaviorTestCase extends AbstractFaceletTestCase { @Test - public void testSimpleClientBehavior() throws Exception + void simpleClientBehavior() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -42,13 +43,13 @@ public void testSimpleClientBehavior() throws Exception vdl.buildView(facesContext, root, "testSimpleClientBehavior.xhtml"); UIComponent form = root.findComponent("testForm1"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UICommand button = (UICommand) compositeComponent.findComponent("button"); - Assertions.assertNotNull(button); - Assertions.assertNotNull(button.getClientBehaviors().get("action")); - Assertions.assertEquals(1, button.getClientBehaviors().get("action").size()); + assertNotNull(button); + assertNotNull(button.getClientBehaviors().get("action")); + assertEquals(1, button.getClientBehaviors().get("action").size()); //StringWriter sw = new StringWriter(); //MockResponseWriter mrw = new MockResponseWriter(sw); @@ -58,9 +59,9 @@ public void testSimpleClientBehavior() throws Exception //sw.flush(); //System.out.print(sw.toString()); } - + @Test - public void testSimpleClientBehaviorDefault() throws Exception + void simpleClientBehaviorDefault() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -71,13 +72,13 @@ public void testSimpleClientBehaviorDefault() throws Exception vdl.buildView(facesContext, root, "testSimpleClientBehaviorDefault.xhtml"); UIComponent form = root.findComponent("testForm1"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UICommand button = (UICommand) compositeComponent.findComponent("button"); - Assertions.assertNotNull(button); - Assertions.assertNotNull(button.getClientBehaviors().get("dblclick")); - Assertions.assertEquals(1, button.getClientBehaviors().get("dblclick").size()); + assertNotNull(button); + assertNotNull(button.getClientBehaviors().get("dblclick")); + assertEquals(1, button.getClientBehaviors().get("dblclick").size()); //StringWriter sw = new StringWriter(); //MockResponseWriter mrw = new MockResponseWriter(sw); @@ -89,7 +90,7 @@ public void testSimpleClientBehaviorDefault() throws Exception } @Test - public void testSimpleClientBehaviorDefaultNoEvent() throws Exception + void simpleClientBehaviorDefaultNoEvent() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -100,13 +101,13 @@ public void testSimpleClientBehaviorDefaultNoEvent() throws Exception vdl.buildView(facesContext, root, "testSimpleClientBehaviorDefaultNoEvent.xhtml"); UIComponent form = root.findComponent("testForm1"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UICommand button = (UICommand) compositeComponent.findComponent("button"); - Assertions.assertNotNull(button); - Assertions.assertNotNull(button.getClientBehaviors().get("action")); - Assertions.assertEquals(1, button.getClientBehaviors().get("action").size()); + assertNotNull(button); + assertNotNull(button.getClientBehaviors().get("action")); + assertEquals(1, button.getClientBehaviors().get("action").size()); //StringWriter sw = new StringWriter(); //MockResponseWriter mrw = new MockResponseWriter(sw); @@ -118,7 +119,7 @@ public void testSimpleClientBehaviorDefaultNoEvent() throws Exception } @Test - public void testSimpleClientBehaviorAjaxWrap() throws Exception + void simpleClientBehaviorAjaxWrap() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -129,13 +130,13 @@ public void testSimpleClientBehaviorAjaxWrap() throws Exception vdl.buildView(facesContext, root, "testSimpleClientBehaviorAjaxWrap.xhtml"); UIComponent form = root.findComponent("testForm1"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UICommand button = (UICommand) compositeComponent.findComponent("button"); - Assertions.assertNotNull(button); - Assertions.assertNotNull(button.getClientBehaviors().get("action")); - Assertions.assertEquals(1, button.getClientBehaviors().get("action").size()); + assertNotNull(button); + assertNotNull(button.getClientBehaviors().get("action")); + assertEquals(1, button.getClientBehaviors().get("action").size()); //StringWriter sw = new StringWriter(); //MockResponseWriter mrw = new MockResponseWriter(sw); @@ -147,7 +148,7 @@ public void testSimpleClientBehaviorAjaxWrap() throws Exception } @Test - public void testSimpleClientBehaviorDefaultAjaxWrap() throws Exception + void simpleClientBehaviorDefaultAjaxWrap() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -158,13 +159,13 @@ public void testSimpleClientBehaviorDefaultAjaxWrap() throws Exception vdl.buildView(facesContext, root, "testSimpleClientBehaviorDefaultAjaxWrap.xhtml"); UIComponent form = root.findComponent("testForm1"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UICommand button = (UICommand) compositeComponent.findComponent("button"); - Assertions.assertNotNull(button); - Assertions.assertNotNull(button.getClientBehaviors().get("dblclick")); - Assertions.assertEquals(1, button.getClientBehaviors().get("dblclick").size()); + assertNotNull(button); + assertNotNull(button.getClientBehaviors().get("dblclick")); + assertEquals(1, button.getClientBehaviors().get("dblclick").size()); //StringWriter sw = new StringWriter(); //MockResponseWriter mrw = new MockResponseWriter(sw); @@ -176,7 +177,7 @@ public void testSimpleClientBehaviorDefaultAjaxWrap() throws Exception } @Test - public void testSimpleClientBehaviorDefaultNoEventAjaxWrap() throws Exception + void simpleClientBehaviorDefaultNoEventAjaxWrap() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -187,13 +188,13 @@ public void testSimpleClientBehaviorDefaultNoEventAjaxWrap() throws Exception vdl.buildView(facesContext, root, "testSimpleClientBehaviorDefaultNoEventAjaxWrap.xhtml"); UIComponent form = root.findComponent("testForm1"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UICommand button = (UICommand) compositeComponent.findComponent("button"); - Assertions.assertNotNull(button); - Assertions.assertNotNull(button.getClientBehaviors().get("action")); - Assertions.assertEquals(1, button.getClientBehaviors().get("action").size()); + assertNotNull(button); + assertNotNull(button.getClientBehaviors().get("action")); + assertEquals(1, button.getClientBehaviors().get("action").size()); //StringWriter sw = new StringWriter(); //MockResponseWriter mrw = new MockResponseWriter(sw); @@ -203,9 +204,9 @@ public void testSimpleClientBehaviorDefaultNoEventAjaxWrap() throws Exception //sw.flush(); //System.out.print(sw.toString()); } - + @Test - public void testCompositeClientBehavior() throws Exception + void compositeClientBehavior() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -216,17 +217,17 @@ public void testCompositeClientBehavior() throws Exception vdl.buildView(facesContext, root, "testCompositeClientBehavior.xhtml"); UIComponent form = root.findComponent("testForm1"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("button3"); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UICommand button = (UICommand) compositeComponent2.findComponent("button"); - Assertions.assertNotNull(button); + assertNotNull(button); //One added in testCompositeActionSource, the other one //inside compositeActionSource.xhtml - Assertions.assertNotNull(button.getClientBehaviors().get("action")); - Assertions.assertEquals(1, button.getClientBehaviors().get("action").size()); + assertNotNull(button.getClientBehaviors().get("action")); + assertEquals(1, button.getClientBehaviors().get("action").size()); //StringWriter sw = new StringWriter(); //MockResponseWriter mrw = new MockResponseWriter(sw); @@ -238,7 +239,7 @@ public void testCompositeClientBehavior() throws Exception } @Test - public void testCompositeDoubleClientBehavior() throws Exception + void compositeDoubleClientBehavior() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -249,19 +250,19 @@ public void testCompositeDoubleClientBehavior() throws Exception vdl.buildView(facesContext, root, "testCompositeDoubleClientBehavior.xhtml"); UIComponent form = root.findComponent("testForm1"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("compositeClientBehavior"); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UINamingContainer compositeComponent3 = (UINamingContainer) compositeComponent2.findComponent("button3"); - Assertions.assertNotNull(compositeComponent3); + assertNotNull(compositeComponent3); UICommand button = (UICommand) compositeComponent3.findComponent("button"); - Assertions.assertNotNull(button); + assertNotNull(button); //One added in testCompositeActionSource, the other one //inside compositeActionSource.xhtml - Assertions.assertNotNull(button.getClientBehaviors().get("action")); - Assertions.assertEquals(1, button.getClientBehaviors().get("action").size()); + assertNotNull(button.getClientBehaviors().get("action")); + assertEquals(1, button.getClientBehaviors().get("action").size()); //StringWriter sw = new StringWriter(); //MockResponseWriter mrw = new MockResponseWriter(sw); @@ -271,9 +272,9 @@ public void testCompositeDoubleClientBehavior() throws Exception //sw.flush(); //System.out.print(sw.toString()); } - + @Test - public void testSimpleClientBehaviorProcessThisInCC() throws Exception + void simpleClientBehaviorProcessThisInCC() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -284,16 +285,16 @@ public void testSimpleClientBehaviorProcessThisInCC() throws Exception vdl.buildView(facesContext, root, "testSimpleClientBehaviorProcessThisInCC.xhtml"); UIComponent form = root.findComponent("form"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UICommand button = (UICommand) compositeComponent.findComponent("button"); - Assertions.assertNotNull(button); - Assertions.assertNotNull(button.getClientBehaviors().get("action")); - Assertions.assertEquals(1, button.getClientBehaviors().get("action").size()); + assertNotNull(button); + assertNotNull(button.getClientBehaviors().get("action")); + assertEquals(1, button.getClientBehaviors().get("action").size()); String content = render(root); - Assertions.assertTrue(content.contains("myfaces.ab(this,event,'action','form:cc:button','form:cc:button'")); + assertTrue(content.contains("myfaces.ab(this,event,'action','form:cc:button','form:cc:button'")); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentConditionalButtonTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentConditionalButtonTestCase.java index 0a6fd4ca49..f2556c9f2c 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentConditionalButtonTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentConditionalButtonTestCase.java @@ -19,6 +19,9 @@ package org.apache.myfaces.view.facelets.tag.composite; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import jakarta.el.ExpressionFactory; import jakarta.faces.component.UICommand; import jakarta.faces.component.UIComponent; @@ -27,10 +30,9 @@ import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; import org.apache.myfaces.view.facelets.bean.HelloWorld; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CompositeComponentConditionalButtonTestCase extends AbstractFaceletTestCase +class CompositeComponentConditionalButtonTestCase extends AbstractFaceletTestCase { @Override @@ -46,7 +48,7 @@ protected ExpressionFactory createExpressionFactory() } @Test - public void testConditionalButtonTargets() throws Exception + void conditionalButtonTargets() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -58,25 +60,25 @@ public void testConditionalButtonTargets() throws Exception //The first component has a default command button UIComponent form = root.findComponent("testForm1"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent1 = (UINamingContainer) form.findComponent("actionSource1"); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UICommand button1 = (UICommand) compositeComponent1.findComponent("button"); - Assertions.assertNotNull(button1); - Assertions.assertEquals("submit", button1.getActionExpression().invoke(facesContext.getELContext(), null)); + assertNotNull(button1); + assertEquals("submit", button1.getActionExpression().invoke(facesContext.getELContext(), null)); - Assertions.assertNotNull(button1.getActionListeners()); - Assertions.assertEquals(1, button1.getActionListeners().length); + assertNotNull(button1.getActionListeners()); + assertEquals(1, button1.getActionListeners().length); UINamingContainer compositeComponent2 = (UINamingContainer) form.findComponent("actionSource"); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UICommand button2 = (UICommand) compositeComponent2.findComponent("button"); - Assertions.assertNotNull(button2); + assertNotNull(button2); //Since the button is outside cc:implementation, by the spec it cannot be taken into account as a valid "targets" value. - Assertions.assertEquals("fail", button2.getActionExpression().invoke(facesContext.getELContext(), null)); + assertEquals("fail", button2.getActionExpression().invoke(facesContext.getELContext(), null)); //It also cannot be target of cc:actionSource - Assertions.assertNotNull(button2.getActionListeners()); - Assertions.assertEquals(0, button2.getActionListeners().length); + assertNotNull(button2.getActionListeners()); + assertEquals(0, button2.getActionListeners().length); //StringWriter sw = new StringWriter(); //MockResponseWriter mrw = new MockResponseWriter(sw); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentMethodExpressionTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentMethodExpressionTestCase.java index 42ab375353..20e4eb83d0 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentMethodExpressionTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentMethodExpressionTestCase.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.view.facelets.tag.composite; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import jakarta.el.ExpressionFactory; import jakarta.el.MethodExpression; import jakarta.faces.component.UICommand; @@ -26,10 +29,9 @@ import jakarta.faces.component.UIViewRoot; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CompositeComponentMethodExpressionTestCase extends AbstractFaceletTestCase +class CompositeComponentMethodExpressionTestCase extends AbstractFaceletTestCase { @Override protected void setupComponents() throws Exception @@ -54,7 +56,7 @@ protected ExpressionFactory createExpressionFactory() } @Test - public void testSimpleMethodExpressionTarget() throws Exception + void simpleMethodExpressionTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -66,17 +68,17 @@ public void testSimpleMethodExpressionTarget() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); SimpleComponent testComponent = (SimpleComponent) compositeComponent.findComponent("testComponent"); - Assertions.assertNotNull(testComponent); - Assertions.assertNotNull(testComponent.getCustomMethod()); - Assertions.assertEquals("somethingFunny"+"x", testComponent.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); + assertNotNull(testComponent); + assertNotNull(testComponent.getCustomMethod()); + assertEquals("somethingFunny"+"x", testComponent.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); } @Test - public void testCompositeMethodExpressionTarget() throws Exception + void compositeMethodExpressionTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -88,20 +90,20 @@ public void testCompositeMethodExpressionTarget() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); SimpleComponent testComponent = (SimpleComponent) compositeComponent2.findComponent("testComponent"); - Assertions.assertNotNull(testComponent); - Assertions.assertNotNull(testComponent.getCustomMethod()); - Assertions.assertEquals("somethingFunny"+"x", testComponent.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); + assertNotNull(testComponent); + assertNotNull(testComponent.getCustomMethod()); + assertEquals("somethingFunny"+"x", testComponent.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); } - + @Test - public void testSimpleMethodExpressionNoTarget() throws Exception + void simpleMethodExpressionNoTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -113,21 +115,21 @@ public void testSimpleMethodExpressionNoTarget() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); SimpleComponent testComponentNoTarget = (SimpleComponent) compositeComponent.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget); - Assertions.assertNotNull(testComponentNoTarget.getCustomMethod()); + assertNotNull(testComponentNoTarget); + assertNotNull(testComponentNoTarget.getCustomMethod()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); - Assertions.assertEquals("somethingFunny"+"x", testComponentNoTarget.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); + assertEquals("somethingFunny"+"x", testComponentNoTarget.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); compositeComponent.popComponentFromEL(facesContext); } @Test - public void testCompositeMethodExpressionNoTarget() throws Exception + void compositeMethodExpressionNoTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -139,24 +141,24 @@ public void testCompositeMethodExpressionNoTarget() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UINamingContainer compositeComponent3 = (UINamingContainer) compositeComponent.findComponent("simpleAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent3); + assertNotNull(compositeComponent3); SimpleComponent testComponentNoTarget3 = (SimpleComponent) compositeComponent3.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget3); - Assertions.assertNotNull(testComponentNoTarget3.getCustomMethod()); + assertNotNull(testComponentNoTarget3); + assertNotNull(testComponentNoTarget3.getCustomMethod()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); compositeComponent.pushComponentToEL(facesContext, compositeComponent3); - Assertions.assertEquals("somethingFunny"+"x", testComponentNoTarget3.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); + assertEquals("somethingFunny"+"x", testComponentNoTarget3.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); compositeComponent3.popComponentFromEL(facesContext); compositeComponent.popComponentFromEL(facesContext); } - + @Test - public void testCompositeMethodExpressionNoTarget2() throws Exception + void compositeMethodExpressionNoTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -168,27 +170,27 @@ public void testCompositeMethodExpressionNoTarget2() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("compositeAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UINamingContainer compositeComponent3 = (UINamingContainer) compositeComponent2.findComponent("simpleAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent3); + assertNotNull(compositeComponent3); SimpleComponent testComponentNoTarget3 = (SimpleComponent) compositeComponent3.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget3); - Assertions.assertNotNull(testComponentNoTarget3.getCustomMethod()); + assertNotNull(testComponentNoTarget3); + assertNotNull(testComponentNoTarget3.getCustomMethod()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); compositeComponent.pushComponentToEL(facesContext, compositeComponent3); - Assertions.assertEquals("somethingFunny"+"x", testComponentNoTarget3.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); + assertEquals("somethingFunny"+"x", testComponentNoTarget3.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); compositeComponent3.popComponentFromEL(facesContext); compositeComponent.popComponentFromEL(facesContext); } @Test - public void testSimpleMethodExpressionTarget2() throws Exception + void simpleMethodExpressionTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -200,24 +202,24 @@ public void testSimpleMethodExpressionTarget2() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); SimpleComponent testComponent = (SimpleComponent) compositeComponent.findComponent("testComponent"); - Assertions.assertNotNull(testComponent); - Assertions.assertNotNull(testComponent.getCustomMethod()); - Assertions.assertEquals("somethingFunny"+"x", testComponent.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); + assertNotNull(testComponent); + assertNotNull(testComponent.getCustomMethod()); + assertEquals("somethingFunny"+"x", testComponent.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); SimpleComponent testComponentNoTarget = (SimpleComponent) compositeComponent.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget); - Assertions.assertNotNull(testComponentNoTarget.getCustomMethod()); + assertNotNull(testComponentNoTarget); + assertNotNull(testComponentNoTarget.getCustomMethod()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); - Assertions.assertEquals("somethingFunny"+"x", testComponentNoTarget.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); + assertEquals("somethingFunny"+"x", testComponentNoTarget.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); compositeComponent.popComponentFromEL(facesContext); } @Test - public void testCompositeMethodExpressionTarget2() throws Exception + void compositeMethodExpressionTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -229,47 +231,47 @@ public void testCompositeMethodExpressionTarget2() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); SimpleComponent testComponent = (SimpleComponent) compositeComponent2.findComponent("testComponent"); - Assertions.assertNotNull(testComponent); - Assertions.assertNotNull(testComponent.getCustomMethod()); - Assertions.assertEquals("somethingFunny"+"x", testComponent.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); + assertNotNull(testComponent); + assertNotNull(testComponent.getCustomMethod()); + assertEquals("somethingFunny"+"x", testComponent.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); SimpleComponent testComponentNoTarget = (SimpleComponent) compositeComponent2.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget); - Assertions.assertNotNull(testComponentNoTarget.getCustomMethod()); + assertNotNull(testComponentNoTarget); + assertNotNull(testComponentNoTarget.getCustomMethod()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); - Assertions.assertEquals("somethingFunny"+"x", testComponentNoTarget.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); + assertEquals("somethingFunny"+"x", testComponentNoTarget.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); compositeComponent.popComponentFromEL(facesContext); UINamingContainer compositeComponent3 = (UINamingContainer) compositeComponent.findComponent("simpleAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent3); + assertNotNull(compositeComponent3); SimpleComponent testComponent3 = (SimpleComponent) compositeComponent3.findComponent("testComponent"); - Assertions.assertNotNull(testComponent3); - Assertions.assertNotNull(testComponent3.getCustomMethod()); + assertNotNull(testComponent3); + assertNotNull(testComponent3.getCustomMethod()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); compositeComponent3.pushComponentToEL(facesContext, compositeComponent3); - Assertions.assertEquals("somethingFunny"+"x", testComponent3.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); + assertEquals("somethingFunny"+"x", testComponent3.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); compositeComponent3.popComponentFromEL(facesContext); compositeComponent.popComponentFromEL(facesContext); SimpleComponent testComponentNoTarget3 = (SimpleComponent) compositeComponent3.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget3); - Assertions.assertNotNull(testComponentNoTarget3.getCustomMethod()); + assertNotNull(testComponentNoTarget3); + assertNotNull(testComponentNoTarget3.getCustomMethod()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); compositeComponent3.pushComponentToEL(facesContext, compositeComponent3); - Assertions.assertEquals("somethingFunny"+"x", testComponentNoTarget3.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); + assertEquals("somethingFunny"+"x", testComponentNoTarget3.getCustomMethod().invoke(facesContext.getELContext(), new Object[]{"x"})); compositeComponent3.popComponentFromEL(facesContext); compositeComponent.popComponentFromEL(facesContext); } @Test - public void testSimpleActionMethodExpressionTarget() throws Exception + void simpleActionMethodExpressionTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -281,17 +283,17 @@ public void testSimpleActionMethodExpressionTarget() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UICommand testComponent = (UICommand) compositeComponent.findComponent("testComponent"); - Assertions.assertNotNull(testComponent); - Assertions.assertNotNull(testComponent.getActionExpression()); - Assertions.assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null)); + assertNotNull(testComponent); + assertNotNull(testComponent.getActionExpression()); + assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null)); } @Test - public void testCompositeActionMethodExpressionTarget() throws Exception + void compositeActionMethodExpressionTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -303,20 +305,20 @@ public void testCompositeActionMethodExpressionTarget() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UICommand testComponent = (UICommand) compositeComponent2.findComponent("testComponent"); - Assertions.assertNotNull(testComponent); - Assertions.assertNotNull(testComponent.getActionExpression()); - Assertions.assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null)); + assertNotNull(testComponent); + assertNotNull(testComponent.getActionExpression()); + assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null)); } @Test - public void testSimpleActionMethodExpressionNoTarget() throws Exception + void simpleActionMethodExpressionNoTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -328,23 +330,23 @@ public void testSimpleActionMethodExpressionNoTarget() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UICommand button = (UICommand) compositeComponent.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(button); + assertNotNull(button); compositeComponent.pushComponentToEL(facesContext, compositeComponent); button.pushComponentToEL(facesContext, button); MethodExpression method = button.getActionExpression(); - Assertions.assertEquals(bean.doSomeAction(), method.invoke(facesContext.getELContext(), null)); + assertEquals(bean.doSomeAction(), method.invoke(facesContext.getELContext(), null)); button.popComponentFromEL(facesContext); compositeComponent.popComponentFromEL(facesContext); } - + @Test - public void testCompositeActionMethodExpressionNoTarget() throws Exception + void compositeActionMethodExpressionNoTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -355,24 +357,24 @@ public void testCompositeActionMethodExpressionNoTarget() throws Exception vdl.buildView(facesContext, root, "testCompositeAttributeActionMethodExpressionNoTarget.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UINamingContainer compositeComponent3 = (UINamingContainer) compositeComponent.findComponent("simpleAttributeActionMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent3); + assertNotNull(compositeComponent3); UICommand testComponentNoTarget3 = (UICommand) compositeComponent3.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget3); - Assertions.assertNotNull(testComponentNoTarget3.getActionExpression()); + assertNotNull(testComponentNoTarget3); + assertNotNull(testComponentNoTarget3.getActionExpression()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); compositeComponent.pushComponentToEL(facesContext, compositeComponent3); - Assertions.assertEquals(bean.doSomeAction(), testComponentNoTarget3.getActionExpression().invoke(facesContext.getELContext(), null)); + assertEquals(bean.doSomeAction(), testComponentNoTarget3.getActionExpression().invoke(facesContext.getELContext(), null)); compositeComponent3.popComponentFromEL(facesContext); compositeComponent.popComponentFromEL(facesContext); } @Test - public void testSimpleActionMethodExpressionTarget2() throws Exception + void simpleActionMethodExpressionTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -384,24 +386,24 @@ public void testSimpleActionMethodExpressionTarget2() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UICommand testComponent = (UICommand) compositeComponent.findComponent("testComponent"); - Assertions.assertNotNull(testComponent); - Assertions.assertNotNull(testComponent.getActionExpression()); - Assertions.assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null)); + assertNotNull(testComponent); + assertNotNull(testComponent.getActionExpression()); + assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null)); UICommand testComponentNoTarget = (UICommand) compositeComponent.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget); - Assertions.assertNotNull(testComponentNoTarget.getActionExpression()); + assertNotNull(testComponentNoTarget); + assertNotNull(testComponentNoTarget.getActionExpression()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); - Assertions.assertEquals(bean.doSomeAction(), testComponentNoTarget.getActionExpression().invoke(facesContext.getELContext(), null)); + assertEquals(bean.doSomeAction(), testComponentNoTarget.getActionExpression().invoke(facesContext.getELContext(), null)); compositeComponent.popComponentFromEL(facesContext); } - + @Test - public void testSimpleActionMethodExpressionTarget3() throws Exception + void simpleActionMethodExpressionTarget3() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -413,24 +415,24 @@ public void testSimpleActionMethodExpressionTarget3() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UICommand testComponent = (UICommand) compositeComponent.findComponent("testComponent"); - Assertions.assertNotNull(testComponent); - Assertions.assertNotNull(testComponent.getActionExpression()); - Assertions.assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null)); + assertNotNull(testComponent); + assertNotNull(testComponent.getActionExpression()); + assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null)); UICommand testComponentNoTarget = (UICommand) compositeComponent.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget); - Assertions.assertNotNull(testComponentNoTarget.getActionExpression()); + assertNotNull(testComponentNoTarget); + assertNotNull(testComponentNoTarget.getActionExpression()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); - Assertions.assertEquals(bean.doSomeAction(), testComponentNoTarget.getActionExpression().invoke(facesContext.getELContext(), null)); + assertEquals(bean.doSomeAction(), testComponentNoTarget.getActionExpression().invoke(facesContext.getELContext(), null)); compositeComponent.popComponentFromEL(facesContext); } @Test - public void testCompositeActionMethodExpressionTarget2() throws Exception + void compositeActionMethodExpressionTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -442,47 +444,47 @@ public void testCompositeActionMethodExpressionTarget2() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UICommand testComponent = (UICommand) compositeComponent2.findComponent("testComponent"); - Assertions.assertNotNull(testComponent); - Assertions.assertNotNull(testComponent.getActionExpression()); - Assertions.assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null)); + assertNotNull(testComponent); + assertNotNull(testComponent.getActionExpression()); + assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null)); UICommand testComponentNoTarget = (UICommand) compositeComponent2.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget); - Assertions.assertNotNull(testComponentNoTarget.getActionExpression()); + assertNotNull(testComponentNoTarget); + assertNotNull(testComponentNoTarget.getActionExpression()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); - Assertions.assertEquals(bean.doSomeAction(), testComponentNoTarget.getActionExpression().invoke(facesContext.getELContext(), null)); + assertEquals(bean.doSomeAction(), testComponentNoTarget.getActionExpression().invoke(facesContext.getELContext(), null)); compositeComponent.popComponentFromEL(facesContext); UINamingContainer compositeComponent3 = (UINamingContainer) compositeComponent.findComponent("simpleAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent3); + assertNotNull(compositeComponent3); UICommand testComponent3 = (UICommand) compositeComponent3.findComponent("testComponent"); - Assertions.assertNotNull(testComponent3); - Assertions.assertNotNull(testComponent3.getActionExpression()); + assertNotNull(testComponent3); + assertNotNull(testComponent3.getActionExpression()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); compositeComponent3.pushComponentToEL(facesContext, compositeComponent3); - Assertions.assertEquals(bean.doSomeAction(), testComponent3.getActionExpression().invoke(facesContext.getELContext(), null)); + assertEquals(bean.doSomeAction(), testComponent3.getActionExpression().invoke(facesContext.getELContext(), null)); compositeComponent3.popComponentFromEL(facesContext); compositeComponent.popComponentFromEL(facesContext); UICommand testComponentNoTarget3 = (UICommand) compositeComponent3.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget3); - Assertions.assertNotNull(testComponentNoTarget3.getActionExpression()); + assertNotNull(testComponentNoTarget3); + assertNotNull(testComponentNoTarget3.getActionExpression()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); compositeComponent3.pushComponentToEL(facesContext, compositeComponent3); - Assertions.assertEquals(bean.doSomeAction(), testComponentNoTarget3.getActionExpression().invoke(facesContext.getELContext(), null)); + assertEquals(bean.doSomeAction(), testComponentNoTarget3.getActionExpression().invoke(facesContext.getELContext(), null)); compositeComponent3.popComponentFromEL(facesContext); compositeComponent.popComponentFromEL(facesContext); } @Test - public void testCompositeActionMethodExpressionNoTarget2() throws Exception + void compositeActionMethodExpressionNoTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -493,26 +495,26 @@ public void testCompositeActionMethodExpressionNoTarget2() throws Exception vdl.buildView(facesContext, root, "testCompositeAttributeActionMethodExpressionNoTarget2.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("compositeAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UINamingContainer compositeComponent3 = (UINamingContainer) compositeComponent2.findComponent("simpleAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent3); + assertNotNull(compositeComponent3); UICommand testComponentNoTarget3 = (UICommand) compositeComponent3.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget3); - Assertions.assertNotNull(testComponentNoTarget3.getActionExpression()); + assertNotNull(testComponentNoTarget3); + assertNotNull(testComponentNoTarget3.getActionExpression()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); compositeComponent.pushComponentToEL(facesContext, compositeComponent3); - Assertions.assertEquals(bean.doSomeAction(), testComponentNoTarget3.getActionExpression().invoke(facesContext.getELContext(), null)); + assertEquals(bean.doSomeAction(), testComponentNoTarget3.getActionExpression().invoke(facesContext.getELContext(), null)); compositeComponent3.popComponentFromEL(facesContext); compositeComponent.popComponentFromEL(facesContext); } - + @Test - public void testCompositeActionMethodExpressionTarget3() throws Exception + void compositeActionMethodExpressionTarget3() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -524,43 +526,43 @@ public void testCompositeActionMethodExpressionTarget3() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UICommand testComponent = (UICommand) compositeComponent2.findComponent("testComponent"); - Assertions.assertNotNull(testComponent); - Assertions.assertNotNull(testComponent.getActionExpression()); - Assertions.assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null)); + assertNotNull(testComponent); + assertNotNull(testComponent.getActionExpression()); + assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null)); UICommand testComponentNoTarget = (UICommand) compositeComponent2.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget); - Assertions.assertNotNull(testComponentNoTarget.getActionExpression()); + assertNotNull(testComponentNoTarget); + assertNotNull(testComponentNoTarget.getActionExpression()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2); - Assertions.assertEquals(bean.doSomeAction(), testComponentNoTarget.getActionExpression().invoke(facesContext.getELContext(), null)); + assertEquals(bean.doSomeAction(), testComponentNoTarget.getActionExpression().invoke(facesContext.getELContext(), null)); compositeComponent2.popComponentFromEL(facesContext); compositeComponent.popComponentFromEL(facesContext); UINamingContainer compositeComponent3 = (UINamingContainer) compositeComponent.findComponent("simpleAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent3); + assertNotNull(compositeComponent3); UICommand testComponent3 = (UICommand) compositeComponent3.findComponent("testComponent"); - Assertions.assertNotNull(testComponent3); - Assertions.assertNotNull(testComponent3.getActionExpression()); + assertNotNull(testComponent3); + assertNotNull(testComponent3.getActionExpression()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); compositeComponent3.pushComponentToEL(facesContext, compositeComponent3); - Assertions.assertEquals(bean.doSomeAction(), testComponent3.getActionExpression().invoke(facesContext.getELContext(), null)); + assertEquals(bean.doSomeAction(), testComponent3.getActionExpression().invoke(facesContext.getELContext(), null)); compositeComponent3.popComponentFromEL(facesContext); compositeComponent.popComponentFromEL(facesContext); UICommand testComponentNoTarget3 = (UICommand) compositeComponent3.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget3); - Assertions.assertNotNull(testComponentNoTarget3.getActionExpression()); + assertNotNull(testComponentNoTarget3); + assertNotNull(testComponentNoTarget3.getActionExpression()); compositeComponent.pushComponentToEL(facesContext, compositeComponent); compositeComponent3.pushComponentToEL(facesContext, compositeComponent3); - Assertions.assertEquals(bean.doSomeAction(), testComponentNoTarget3.getActionExpression().invoke(facesContext.getELContext(), null)); + assertEquals(bean.doSomeAction(), testComponentNoTarget3.getActionExpression().invoke(facesContext.getELContext(), null)); compositeComponent3.popComponentFromEL(facesContext); compositeComponent.popComponentFromEL(facesContext); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentNestedCCTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentNestedCCTestCase.java index 5659a48c4f..a4fdea3876 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentNestedCCTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentNestedCCTestCase.java @@ -19,6 +19,9 @@ package org.apache.myfaces.view.facelets.tag.composite; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import jakarta.el.ExpressionFactory; @@ -29,10 +32,9 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.ELExpressionCacheMode; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CompositeComponentNestedCCTestCase extends AbstractFaceletTestCase +class CompositeComponentNestedCCTestCase extends AbstractFaceletTestCase { @Override @@ -46,15 +48,15 @@ protected ExpressionFactory createExpressionFactory() { return new org.apache.el.ExpressionFactoryImpl(); } - + @Test - public void testCompositeNestedCC1() throws Exception + void compositeNestedCC1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testCompositeNestedCC1.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -62,11 +64,11 @@ public void testCompositeNestedCC1() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); } - + /** * The same tests, but with caching enabled. In this case, ccLevel changes * all the time, so the caching logic must take that into account. @@ -74,7 +76,7 @@ public void testCompositeNestedCC1() throws Exception * @throws Exception */ @Test - public void testCompositeNestedCC1Cache() throws Exception + void compositeNestedCC1Cache() throws Exception { servletContext.addInitParameter(MyfacesConfig.CACHE_EL_EXPRESSIONS, ELExpressionCacheMode.always.toString()); @@ -82,7 +84,7 @@ public void testCompositeNestedCC1Cache() throws Exception vdl.buildView(facesContext, root, "testCompositeNestedCC1.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -90,24 +92,24 @@ public void testCompositeNestedCC1Cache() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); } - + /** * Try a nested reference inside the same composite component * * @throws Exception */ @Test - public void testCompositeNestedCC2() throws Exception + void compositeNestedCC2() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testCompositeNestedCC2.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -115,10 +117,10 @@ public void testCompositeNestedCC2() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } /** @@ -127,7 +129,7 @@ public void testCompositeNestedCC2() throws Exception * @throws Exception */ @Test - public void testCompositeNestedCC2Cache() throws Exception + void compositeNestedCC2Cache() throws Exception { servletContext.addInitParameter(MyfacesConfig.CACHE_EL_EXPRESSIONS, ELExpressionCacheMode.always.toString()); @@ -135,7 +137,7 @@ public void testCompositeNestedCC2Cache() throws Exception vdl.buildView(facesContext, root, "testCompositeNestedCC2.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -143,12 +145,12 @@ public void testCompositeNestedCC2Cache() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } - + /** * Try what happen when a dynamic ui:include is used inside a composite * component and that include contains a reference to the same composite @@ -157,13 +159,13 @@ public void testCompositeNestedCC2Cache() throws Exception * @throws Exception */ @Test - public void testCompositeNestedCC3() throws Exception + void compositeNestedCC3() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testCompositeNestedCC3.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -171,12 +173,12 @@ public void testCompositeNestedCC3() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } - + /** * Try what happen when a dynamic ui:include is used inside a composite * component and that include contains a reference to the same composite @@ -185,7 +187,7 @@ public void testCompositeNestedCC3() throws Exception * @throws Exception */ @Test - public void testCompositeNestedCC3Cache() throws Exception + void compositeNestedCC3Cache() throws Exception { servletContext.addInitParameter(MyfacesConfig.CACHE_EL_EXPRESSIONS, ELExpressionCacheMode.always.toString()); //allowCset @@ -194,7 +196,7 @@ public void testCompositeNestedCC3Cache() throws Exception vdl.buildView(facesContext, root, "testCompositeNestedCC3.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -202,25 +204,25 @@ public void testCompositeNestedCC3Cache() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } - + /** * Try a nested insertChildren with some conditional inclusions. * * @throws Exception */ @Test - public void testCompositeNestedCC4() throws Exception + void compositeNestedCC4() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testCompositeNestedCC4.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -228,19 +230,19 @@ public void testCompositeNestedCC4() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } - + /** * Try a nested insertChildren with some conditional inclusions. * * @throws Exception */ @Test - public void testCompositeNestedCC4Cache() throws Exception + void compositeNestedCC4Cache() throws Exception { servletContext.addInitParameter(MyfacesConfig.CACHE_EL_EXPRESSIONS, ELExpressionCacheMode.always.toString()); @@ -249,7 +251,7 @@ public void testCompositeNestedCC4Cache() throws Exception vdl.buildView(facesContext, root, "testCompositeNestedCC4.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -257,20 +259,20 @@ public void testCompositeNestedCC4Cache() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } @Test - public void testCompositeNestedCC5() throws Exception + void compositeNestedCC5() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testCompositeNestedCC5.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -278,11 +280,11 @@ public void testCompositeNestedCC5() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); } - + /** * The same tests, but with caching enabled. In this case, ccLevel changes * all the time, so the caching logic must take that into account. @@ -290,7 +292,7 @@ public void testCompositeNestedCC5() throws Exception * @throws Exception */ @Test - public void testCompositeNestedCC5Cache() throws Exception + void compositeNestedCC5Cache() throws Exception { servletContext.addInitParameter(MyfacesConfig.CACHE_EL_EXPRESSIONS, ELExpressionCacheMode.always.toString()); @@ -298,7 +300,7 @@ public void testCompositeNestedCC5Cache() throws Exception vdl.buildView(facesContext, root, "testCompositeNestedCC5.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -306,24 +308,24 @@ public void testCompositeNestedCC5Cache() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); } - + /** * Try a nested reference inside the same composite component * * @throws Exception */ @Test - public void testCompositeNestedCC6() throws Exception + void compositeNestedCC6() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testCompositeNestedCC6.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -331,10 +333,10 @@ public void testCompositeNestedCC6() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } /** @@ -343,7 +345,7 @@ public void testCompositeNestedCC6() throws Exception * @throws Exception */ @Test - public void testCompositeNestedCC6Cache() throws Exception + void compositeNestedCC6Cache() throws Exception { servletContext.addInitParameter(MyfacesConfig.CACHE_EL_EXPRESSIONS, ELExpressionCacheMode.always.toString()); @@ -351,7 +353,7 @@ public void testCompositeNestedCC6Cache() throws Exception vdl.buildView(facesContext, root, "testCompositeNestedCC6.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -359,12 +361,12 @@ public void testCompositeNestedCC6Cache() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } - + /** * Try what happen when a dynamic ui:include is used inside a composite * component and that include contains a reference to the same composite @@ -373,13 +375,13 @@ public void testCompositeNestedCC6Cache() throws Exception * @throws Exception */ @Test - public void testCompositeNestedCC7() throws Exception + void compositeNestedCC7() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testCompositeNestedCC7.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -387,12 +389,12 @@ public void testCompositeNestedCC7() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } - + /** * Try what happen when a dynamic ui:include is used inside a composite * component and that include contains a reference to the same composite @@ -401,7 +403,7 @@ public void testCompositeNestedCC7() throws Exception * @throws Exception */ @Test - public void testCompositeNestedCC7Cache() throws Exception + void compositeNestedCC7Cache() throws Exception { servletContext.addInitParameter(MyfacesConfig.CACHE_EL_EXPRESSIONS, ELExpressionCacheMode.always.toString()); //allowCset @@ -410,7 +412,7 @@ public void testCompositeNestedCC7Cache() throws Exception vdl.buildView(facesContext, root, "testCompositeNestedCC7.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -418,25 +420,25 @@ public void testCompositeNestedCC7Cache() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } - + /** * Try a nested insertChildren with some conditional inclusions. * * @throws Exception */ @Test - public void testCompositeNestedCC8() throws Exception + void compositeNestedCC8() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testCompositeNestedCC8.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -444,19 +446,19 @@ public void testCompositeNestedCC8() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } - + /** * Try a nested insertChildren with some conditional inclusions. * * @throws Exception */ @Test - public void testCompositeNestedCC8Cache() throws Exception + void compositeNestedCC8Cache() throws Exception { servletContext.addInitParameter(MyfacesConfig.CACHE_EL_EXPRESSIONS, ELExpressionCacheMode.always.toString()); @@ -465,7 +467,7 @@ public void testCompositeNestedCC8Cache() throws Exception vdl.buildView(facesContext, root, "testCompositeNestedCC8.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -473,9 +475,9 @@ public void testCompositeNestedCC8Cache() throws Exception root.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("ALFA")); - Assertions.assertTrue(sw.toString().contains("BETA")); - Assertions.assertTrue(sw.toString().contains("GAMMA")); - Assertions.assertTrue(sw.toString().contains("OMEGA")); + assertTrue(sw.toString().contains("ALFA")); + assertTrue(sw.toString().contains("BETA")); + assertTrue(sw.toString().contains("GAMMA")); + assertTrue(sw.toString().contains("OMEGA")); } } \ No newline at end of file diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentTestCase.java index 115d9ad8ea..41b377d25a 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentTestCase.java @@ -19,6 +19,8 @@ package org.apache.myfaces.view.facelets.tag.composite; +import static org.junit.jupiter.api.Assertions.*; + import java.io.StringWriter; import jakarta.el.MethodExpression; @@ -44,10 +46,9 @@ import org.apache.myfaces.test.utils.HtmlRenderedAttr; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; import org.apache.myfaces.view.facelets.bean.HelloWorld; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CompositeComponentTestCase extends AbstractFaceletTestCase +class CompositeComponentTestCase extends AbstractFaceletTestCase { @Override @@ -81,17 +82,17 @@ protected void setUpExternalContext() throws Exception * @throws Exception */ @Test - public void testSimpleCompositeComponent() throws Exception + void simpleCompositeComponent() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testSimpleComposite.xhtml"); UIComponent panelGroup = root.findComponent("testGroup"); - Assertions.assertNotNull(panelGroup); + assertNotNull(panelGroup); UINamingContainer compositeComponent = (UINamingContainer) panelGroup.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UIOutput text = (UIOutput) compositeComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME).findComponent("text"); - Assertions.assertNotNull(text); + assertNotNull(text); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -113,54 +114,54 @@ public void testSimpleCompositeComponent() throws Exception * @throws Exception */ @Test - public void testSimpleCompositeAttribute() throws Exception + void simpleCompositeAttribute() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testSimpleAttribute.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); HtmlOutputText text1 = (HtmlOutputText) facet1.findComponent("text"); - Assertions.assertNotNull(text1); + assertNotNull(text1); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); facet1.pushComponentToEL(facesContext, facet1); text1.pushComponentToEL(facesContext, text1); //set on tag - Assertions.assertEquals("class1", text1.getStyleClass()); + assertEquals("class1", text1.getStyleClass()); //set as default - Assertions.assertEquals("background:red", text1.getStyle()); + assertEquals("background:red", text1.getStyle()); //Check coercion of attribute using type value - Assertions.assertEquals(5, compositeComponent1.getAttributes().get("index")); + assertEquals(5, compositeComponent1.getAttributes().get("index")); //Check default coercion ValueExpression ve = facesContext.getApplication().getExpressionFactory().createValueExpression( facesContext.getELContext(), "#{cc.attrs.cols}", Object.class); - Assertions.assertEquals(1, (int) ve.getValue(facesContext.getELContext())); + assertEquals(1, (int) ve.getValue(facesContext.getELContext())); text1.popComponentFromEL(facesContext); facet1.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); UIComponent panelGroup2 = root.findComponent("testGroup2"); - Assertions.assertNotNull(panelGroup2); + assertNotNull(panelGroup2); UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UIComponent facet2 = compositeComponent2.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet2); + assertNotNull(facet2); HtmlOutputText text2 = (HtmlOutputText) facet2.findComponent("text"); - Assertions.assertNotNull(text2); + assertNotNull(text2); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2); facet2.pushComponentToEL(facesContext, facet2); text2.pushComponentToEL(facesContext, text2); //set on tag - Assertions.assertEquals("background:green", text2.getStyle()); + assertEquals("background:green", text2.getStyle()); // not set, should return null, but since there is a ValueExpression indirection, // coercing rules apply here, so null is converted as "" - Assertions.assertEquals("", text2.getStyleClass()); + assertEquals("", text2.getStyleClass()); text2.popComponentFromEL(facesContext); facet2.popComponentFromEL(facesContext); compositeComponent2.popComponentFromEL(facesContext); @@ -178,9 +179,9 @@ public void testSimpleCompositeAttribute() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); } - + @Test - public void testSimpleCompositeAttributeMethodExpression() throws Exception + void simpleCompositeAttributeMethodExpression() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -191,22 +192,22 @@ public void testSimpleCompositeAttributeMethodExpression() throws Exception vdl.buildView(facesContext, root, "testSimpleAttributeMethodExpression.xhtml"); UIComponent form = root.findComponent("testForm1"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UICommand button = (UICommand) compositeComponent.findComponent("button"); - Assertions.assertNotNull(button); - Assertions.assertEquals("#{helloWorldBean.send}", button.getActionExpression().getExpressionString()); - Assertions.assertEquals("#{helloWorldBean.send}", ((MethodExpression)compositeComponent.getAttributes().get("metodo")).getExpressionString()); - Assertions.assertNull(button.getAttributes().get("metodo")); + assertNotNull(button); + assertEquals("#{helloWorldBean.send}", button.getActionExpression().getExpressionString()); + assertEquals("#{helloWorldBean.send}", ((MethodExpression)compositeComponent.getAttributes().get("metodo")).getExpressionString()); + assertNull(button.getAttributes().get("metodo")); UICommand link = (UICommand) compositeComponent.findComponent("link"); - Assertions.assertNotNull(link); - Assertions.assertEquals(1, link.getActionListeners().length); + assertNotNull(link); + assertEquals(1, link.getActionListeners().length); UIInput input = (UIInput) compositeComponent.findComponent("input"); - Assertions.assertNotNull(input); - Assertions.assertEquals(1, input.getValidators().length); - Assertions.assertEquals(1, input.getValueChangeListeners().length); + assertNotNull(input); + assertEquals(1, input.getValidators().length); + assertEquals(1, input.getValueChangeListeners().length); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -217,9 +218,9 @@ public void testSimpleCompositeAttributeMethodExpression() throws Exception //sw.flush(); //System.out.print(sw.toString()); } - + @Test - public void testSimpleActionSource() throws Exception + void simpleActionSource() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -230,12 +231,12 @@ public void testSimpleActionSource() throws Exception vdl.buildView(facesContext, root, "testSimpleActionSource.xhtml"); UIComponent form = root.findComponent("testForm1"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UICommand button = (UICommand) compositeComponent.findComponent("button"); - Assertions.assertNotNull(button); - Assertions.assertEquals(3, button.getActionListeners().length); + assertNotNull(button); + assertEquals(3, button.getActionListeners().length); //StringWriter sw = new StringWriter(); //MockResponseWriter mrw = new MockResponseWriter(sw); @@ -245,9 +246,9 @@ public void testSimpleActionSource() throws Exception //sw.flush(); //System.out.print(sw.toString()); } - + @Test - public void testSimpleValueHolder() throws Exception + void simpleValueHolder() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -258,12 +259,12 @@ public void testSimpleValueHolder() throws Exception vdl.buildView(facesContext, root, "testSimpleValueHolder.xhtml"); UIComponent form = root.findComponent("testForm1"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UIOutput text = (UIOutput) compositeComponent.findComponent("text"); - Assertions.assertNotNull(text); - Assertions.assertNotNull(text.getConverter()); + assertNotNull(text); + assertNotNull(text.getConverter()); //Assertions.assertEquals(2, button.getActionListeners().length); //StringWriter sw = new StringWriter(); @@ -274,9 +275,9 @@ public void testSimpleValueHolder() throws Exception //sw.flush(); //System.out.print(sw.toString()); } - + @Test - public void testCompositeActionSource() throws Exception + void compositeActionSource() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -287,16 +288,16 @@ public void testCompositeActionSource() throws Exception vdl.buildView(facesContext, root, "testCompositeActionSource.xhtml"); UIComponent form = root.findComponent("testForm1"); - Assertions.assertNotNull(form); + assertNotNull(form); UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("button3"); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UICommand button = (UICommand) compositeComponent2.findComponent("button"); - Assertions.assertNotNull(button); + assertNotNull(button); //One added in testCompositeActionSource, the other one //inside compositeActionSource.xhtml - Assertions.assertEquals(2, button.getActionListeners().length); + assertEquals(2, button.getActionListeners().length); //StringWriter sw = new StringWriter(); //MockResponseWriter mrw = new MockResponseWriter(sw); @@ -306,9 +307,9 @@ public void testCompositeActionSource() throws Exception //sw.flush(); //System.out.print(sw.toString()); } - + @Test - public void testSimpleInsertChildren() throws Exception + void simpleInsertChildren() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -337,16 +338,16 @@ public void testSimpleInsertChildren() throws Exception String resp = sw.toString(); - Assertions.assertTrue(resp.contains("Hello")); - Assertions.assertTrue(resp.contains("Leonardo")); - Assertions.assertTrue(resp.contains("Alfredo")); - Assertions.assertTrue(resp.contains("Uribe")); - Assertions.assertTrue(resp.contains("Sayonara")); + assertTrue(resp.contains("Hello")); + assertTrue(resp.contains("Leonardo")); + assertTrue(resp.contains("Alfredo")); + assertTrue(resp.contains("Uribe")); + assertTrue(resp.contains("Sayonara")); //System.out.print(sw.toString()); } - + @Test - public void testSimpleInsertChildrenAjax() throws Exception + void simpleInsertChildrenAjax() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -357,15 +358,15 @@ public void testSimpleInsertChildrenAjax() throws Exception vdl.buildView(facesContext, root, "testSimpleInsertChildrenAjax.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); HtmlCommandLink link = (HtmlCommandLink) facet1.findComponent("link"); - Assertions.assertNotNull(link); - Assertions.assertEquals(1, link.getClientBehaviors().size()); - Assertions.assertEquals(1, link.getClientBehaviors().get(link.getDefaultEventName()).size()); + assertNotNull(link); + assertEquals(1, link.getClientBehaviors().size()); + assertEquals(1, link.getClientBehaviors().get(link.getDefaultEventName()).size()); /* StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -380,7 +381,7 @@ public void testSimpleInsertChildrenAjax() throws Exception } @Test - public void testSimpleInsertChildrenAjax2() throws Exception + void simpleInsertChildrenAjax2() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -391,15 +392,15 @@ public void testSimpleInsertChildrenAjax2() throws Exception vdl.buildView(facesContext, root, "testSimpleInsertChildrenAjax2.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); HtmlCommandLink link = (HtmlCommandLink) compositeComponent1.findComponent("link"); - Assertions.assertNotNull(link); - Assertions.assertEquals(1, link.getClientBehaviors().size()); - Assertions.assertEquals(1, link.getClientBehaviors().get(link.getDefaultEventName()).size()); + assertNotNull(link); + assertEquals(1, link.getClientBehaviors().size()); + assertEquals(1, link.getClientBehaviors().get(link.getDefaultEventName()).size()); /* StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -412,9 +413,9 @@ public void testSimpleInsertChildrenAjax2() throws Exception */ //System.out.print(sw.toString()); } - + @Test - public void testSimpleInsertChildrenNoAjax() throws Exception + void simpleInsertChildrenNoAjax() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -425,14 +426,14 @@ public void testSimpleInsertChildrenNoAjax() throws Exception vdl.buildView(facesContext, root, "testSimpleInsertChildrenNoAjax.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); HtmlCommandLink link = (HtmlCommandLink) facet1.findComponent("link"); - Assertions.assertNotNull(link); - Assertions.assertEquals(0, link.getClientBehaviors().size()); + assertNotNull(link); + assertEquals(0, link.getClientBehaviors().size()); /* StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -445,9 +446,9 @@ public void testSimpleInsertChildrenNoAjax() throws Exception */ //System.out.print(sw.toString()); } - + @Test - public void testCompositeInsertChildren() throws Exception + void compositeInsertChildren() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -458,11 +459,11 @@ public void testCompositeInsertChildren() throws Exception vdl.buildView(facesContext, root, "testCompositeInsertChildren.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -474,14 +475,14 @@ public void testCompositeInsertChildren() throws Exception String resp = sw.toString(); - Assertions.assertTrue(resp.contains("ALFA")); - Assertions.assertTrue(resp.contains("BETA")); - Assertions.assertTrue(resp.contains("GAMMA")); - Assertions.assertTrue(resp.contains("OMEGA")); + assertTrue(resp.contains("ALFA")); + assertTrue(resp.contains("BETA")); + assertTrue(resp.contains("GAMMA")); + assertTrue(resp.contains("OMEGA")); } - + @Test - public void testCompositeInsertChildrenPreserveTemplateSlot() throws Exception + void compositeInsertChildrenPreserveTemplateSlot() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -492,11 +493,11 @@ public void testCompositeInsertChildrenPreserveTemplateSlot() throws Exception vdl.buildView(facesContext, root, "testCompositeInsertChildren2.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -508,14 +509,14 @@ public void testCompositeInsertChildrenPreserveTemplateSlot() throws Exception String resp = sw.toString(); - Assertions.assertTrue(resp.contains("ALFA")); - Assertions.assertTrue(resp.contains("BETA")); - Assertions.assertTrue(resp.contains("GAMMA")); - Assertions.assertTrue(resp.contains("OMEGA")); + assertTrue(resp.contains("ALFA")); + assertTrue(resp.contains("BETA")); + assertTrue(resp.contains("GAMMA")); + assertTrue(resp.contains("OMEGA")); } - + @Test - public void testCompositeInsertChildren3() throws Exception + void compositeInsertChildren3() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -526,11 +527,11 @@ public void testCompositeInsertChildren3() throws Exception vdl.buildView(facesContext, root, "testCompositeInsertChildren3.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -542,14 +543,14 @@ public void testCompositeInsertChildren3() throws Exception String resp = sw.toString(); - Assertions.assertTrue(resp.contains("ALFA")); - Assertions.assertTrue(resp.contains("BETA")); - Assertions.assertTrue(resp.contains("GAMMA")); - Assertions.assertTrue(resp.contains("OMEGA")); + assertTrue(resp.contains("ALFA")); + assertTrue(resp.contains("BETA")); + assertTrue(resp.contains("GAMMA")); + assertTrue(resp.contains("OMEGA")); } - + @Test - public void testCompositeInsertChildren4() throws Exception + void compositeInsertChildren4() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -560,7 +561,7 @@ public void testCompositeInsertChildren4() throws Exception vdl.buildView(facesContext, root, "testCompositeInsertChildren4.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); //UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); //Assertions.assertNotNull(compositeComponent1); //UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); @@ -576,15 +577,15 @@ public void testCompositeInsertChildren4() throws Exception String resp = sw.toString(); - Assertions.assertTrue(resp.contains("ALFA")); - Assertions.assertTrue(resp.contains("BETA")); - Assertions.assertTrue(resp.contains("GAMMA")); - Assertions.assertTrue(resp.contains("OMEGA")); + assertTrue(resp.contains("ALFA")); + assertTrue(resp.contains("BETA")); + assertTrue(resp.contains("GAMMA")); + assertTrue(resp.contains("OMEGA")); } - - + + @Test - public void testCompositeInsertChildren5() throws Exception + void compositeInsertChildren5() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -595,7 +596,7 @@ public void testCompositeInsertChildren5() throws Exception vdl.buildView(facesContext, root, "testCompositeInsertChildren5.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); //UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); //Assertions.assertNotNull(compositeComponent1); //UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); @@ -611,14 +612,14 @@ public void testCompositeInsertChildren5() throws Exception String resp = sw.toString(); - Assertions.assertTrue(resp.contains("ALFA")); - Assertions.assertTrue(resp.contains("BETA")); - Assertions.assertTrue(resp.contains("GAMMA")); - Assertions.assertTrue(resp.contains("OMEGA")); + assertTrue(resp.contains("ALFA")); + assertTrue(resp.contains("BETA")); + assertTrue(resp.contains("GAMMA")); + assertTrue(resp.contains("OMEGA")); } @Test - public void testCompositeInsertChildren6() throws Exception + void compositeInsertChildren6() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -629,7 +630,7 @@ public void testCompositeInsertChildren6() throws Exception vdl.buildView(facesContext, root, "testCompositeInsertChildren6.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); //UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); //Assertions.assertNotNull(compositeComponent1); //UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); @@ -645,14 +646,14 @@ public void testCompositeInsertChildren6() throws Exception String resp = sw.toString(); - Assertions.assertTrue(resp.contains("ALFA")); - Assertions.assertTrue(resp.contains("BETA")); - Assertions.assertTrue(resp.contains("GAMMA")); - Assertions.assertTrue(resp.contains("OMEGA")); + assertTrue(resp.contains("ALFA")); + assertTrue(resp.contains("BETA")); + assertTrue(resp.contains("GAMMA")); + assertTrue(resp.contains("OMEGA")); } @Test - public void testCompositeInsertFacet() throws Exception + void compositeInsertFacet() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -663,24 +664,24 @@ public void testCompositeInsertFacet() throws Exception vdl.buildView(facesContext, root, "testCompositeInsertFacet.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); UINamingContainer compositeComponent2 = (UINamingContainer) facet1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UIComponent facet2 = compositeComponent2.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet2); - Assertions.assertEquals(1,facet2.getChildCount()); + assertNotNull(facet2); + assertEquals(1,facet2.getChildCount()); UIOutput targetComp = (UIOutput) facet2.getChildren().get(0); UIComponent insertedFacet = targetComp.getFacet("header"); - Assertions.assertNotNull(insertedFacet); + assertNotNull(insertedFacet); } - + @Test - public void testCompositeInsertFacetChildren() throws Exception + void compositeInsertFacetChildren() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -691,23 +692,23 @@ public void testCompositeInsertFacetChildren() throws Exception vdl.buildView(facesContext, root, "testCompositeInsertFacetChildren.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); UINamingContainer compositeComponent2 = (UINamingContainer) facet1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UIComponent facet2 = compositeComponent2.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet2); - Assertions.assertEquals(3,facet2.getChildCount()); + assertNotNull(facet2); + assertEquals(3,facet2.getChildCount()); UIComponent insertedFacet = facet2.getChildren().get(1).getFacet("header"); - Assertions.assertNotNull(insertedFacet); + assertNotNull(insertedFacet); } @Test - public void testSimpleRenderFacet() throws Exception + void simpleRenderFacet() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -718,9 +719,9 @@ public void testSimpleRenderFacet() throws Exception vdl.buildView(facesContext, root, "testSimpleRenderFacet.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -732,13 +733,13 @@ public void testSimpleRenderFacet() throws Exception String resp = sw.toString(); - Assertions.assertTrue(resp.contains("HELLO")); - Assertions.assertTrue(resp.contains("WORLD")); + assertTrue(resp.contains("HELLO")); + assertTrue(resp.contains("WORLD")); } - + @Test - public void testSimpleFEvent() throws Exception + void simpleFEvent() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -749,11 +750,11 @@ public void testSimpleFEvent() throws Exception vdl.buildView(facesContext, root, "testSimpleFEvent.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); CompositeTestComponent compositeComponent1 = (CompositeTestComponent) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); - Assertions.assertTrue((Boolean) compositeComponent1.getAttributes().get("postAddToViewCallback"), + assertTrue((Boolean) compositeComponent1.getAttributes().get("postAddToViewCallback"), "postAddToViewCallback should be called"); /* @@ -772,9 +773,9 @@ public void testSimpleFEvent() throws Exception */ } - + @Test - public void testSimpleFEvent2() throws Exception + void simpleFEvent2() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -785,18 +786,18 @@ public void testSimpleFEvent2() throws Exception vdl.buildView(facesContext, root, "testSimpleFEvent2.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); CompositeTestComponent compositeComponent1 = (CompositeTestComponent) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); application.publishEvent(facesContext, PreRenderViewEvent.class, root); - Assertions.assertTrue((Boolean) compositeComponent1.getAttributes().get("preRenderViewCallback"), + assertTrue((Boolean) compositeComponent1.getAttributes().get("preRenderViewCallback"), "preRenderViewCallback should be called"); application.publishEvent(facesContext, PostRenderViewEvent.class, root); - Assertions.assertTrue((Boolean) compositeComponent1.getAttributes().get("postRenderViewCallback"), + assertTrue((Boolean) compositeComponent1.getAttributes().get("postRenderViewCallback"), "postRenderViewCallback should be called"); /* @@ -815,9 +816,9 @@ public void testSimpleFEvent2() throws Exception */ } - + @Test - public void testsCompositeRefVE() throws Exception { + void testsCompositeRefVE() throws Exception { servletContext.addInitParameter( MyfacesConfig.CACHE_EL_EXPRESSIONS, @@ -827,11 +828,11 @@ public void testsCompositeRefVE() throws Exception { vdl.buildView(facesContext, root, "testCompositeRefVE.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME); - Assertions.assertNotNull(facet1); + assertNotNull(facet1); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -840,20 +841,20 @@ public void testsCompositeRefVE() throws Exception { compositeComponent1.encodeAll(facesContext); sw.flush(); - Assertions.assertTrue(sw.toString().contains("success"), + assertTrue(sw.toString().contains("success"), "Error when rendering" + sw.toString()); } @Test - public void testSimpleThisResourceReference() throws Exception + void simpleThisResourceReference() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testSimpleThisResourceReference.xhtml"); UINamingContainer compositeComponent = (UINamingContainer) root.findComponent("cc1"); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); HtmlGraphicImage gi = (HtmlGraphicImage) compositeComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME).findComponent("gi"); - Assertions.assertNotNull(gi); + assertNotNull(gi); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -865,23 +866,23 @@ public void testSimpleThisResourceReference() throws Exception String result = sw.toString(); Resource resource = facesContext.getApplication().getResourceHandler().createResource("logo_mini.jpg", "testComposite"); - Assertions.assertNotNull(resource); + assertNotNull(resource); - Assertions.assertTrue(result.contains(resource.getRequestPath())); + assertTrue(result.contains(resource.getRequestPath())); } - + @Test - public void testComponentFromResourceId() throws Exception + void componentFromResourceId() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testComponentFromResourceId.xhtml"); UIComponent panelGroup = root.findComponent("testGroup"); - Assertions.assertNotNull(panelGroup); + assertNotNull(panelGroup); UINamingContainer compositeComponent = (UINamingContainer) panelGroup.getChildren().get(0); - Assertions.assertNotNull(compositeComponent); + assertNotNull(compositeComponent); UIOutput text = (UIOutput) compositeComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME).findComponent("text"); - Assertions.assertNotNull(text); + assertNotNull(text); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentValidatorTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentValidatorTestCase.java index 31268ab8eb..1a34061c70 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentValidatorTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentValidatorTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.tag.composite; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.el.ExpressionFactory; import jakarta.faces.component.UIComponent; import jakarta.faces.component.UIInput; @@ -25,10 +27,9 @@ import jakarta.faces.component.UIViewRoot; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CompositeComponentValidatorTestCase extends AbstractFaceletTestCase +class CompositeComponentValidatorTestCase extends AbstractFaceletTestCase { @Override protected void setupComponents() throws Exception @@ -53,7 +54,7 @@ protected ExpressionFactory createExpressionFactory() } @Test - public void testSimpleValidatorTarget() throws Exception + void simpleValidatorTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -65,21 +66,21 @@ public void testSimpleValidatorTarget() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIInput input1 = (UIInput) compositeComponent1.findComponent("testComponent"); - Assertions.assertNotNull(input1); - Assertions.assertNotNull(input1.getValidators()); - Assertions.assertEquals(1, input1.getValidators().length); + assertNotNull(input1); + assertNotNull(input1.getValidators()); + assertEquals(1, input1.getValidators().length); bean.setValidator1Called(false); input1.getValidators()[0].validate(facesContext, input1, "x"); - Assertions.assertTrue(bean.isValidator1Called()); + assertTrue(bean.isValidator1Called()); } @Test - public void testCompositeValidatorTarget() throws Exception + void compositeValidatorTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -90,25 +91,25 @@ public void testCompositeValidatorTarget() throws Exception vdl.buildView(facesContext, root, "testCompositeAttributeValidatorTarget.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UINamingContainer compositeComponent1inner = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent1inner); + assertNotNull(compositeComponent1inner); UIInput input1 = (UIInput) compositeComponent1inner.findComponent("testComponent"); - Assertions.assertNotNull(input1); - Assertions.assertNotNull(input1.getValidators()); - Assertions.assertEquals(1, input1.getValidators().length); + assertNotNull(input1); + assertNotNull(input1.getValidators()); + assertEquals(1, input1.getValidators().length); bean.setValidator1Called(false); input1.getValidators()[0].validate(facesContext, input1, "x"); - Assertions.assertTrue(bean.isValidator1Called()); + assertTrue(bean.isValidator1Called()); } - + @Test - public void testSimpleValidatorTarget2() throws Exception + void simpleValidatorTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -120,34 +121,34 @@ public void testSimpleValidatorTarget2() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIInput input1 = (UIInput) compositeComponent1.findComponent("testComponent"); - Assertions.assertNotNull(input1); - Assertions.assertNotNull(input1.getValidators()); - Assertions.assertEquals(1, input1.getValidators().length); + assertNotNull(input1); + assertNotNull(input1.getValidators()); + assertEquals(1, input1.getValidators().length); bean.setValidator1Called(false); input1.getValidators()[0].validate(facesContext, input1, "x"); - Assertions.assertTrue(bean.isValidator1Called()); + assertTrue(bean.isValidator1Called()); UIInput input1n = (UIInput) compositeComponent1.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(input1n); - Assertions.assertNotNull(input1n.getValidators()); - Assertions.assertEquals(1, input1n.getValidators().length); + assertNotNull(input1n); + assertNotNull(input1n.getValidators()); + assertEquals(1, input1n.getValidators().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); bean.setValidator1Called(false); input1n.getValidators()[0].validate(facesContext, input1n, "x"); - Assertions.assertTrue(bean.isValidator1Called()); + assertTrue(bean.isValidator1Called()); compositeComponent1.popComponentFromEL(facesContext); } @Test - public void testCompositeValidatorTarget2() throws Exception + void compositeValidatorTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -158,65 +159,65 @@ public void testCompositeValidatorTarget2() throws Exception vdl.buildView(facesContext, root, "testCompositeAttributeValidatorTarget2.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UINamingContainer compositeComponent1target = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent1target); + assertNotNull(compositeComponent1target); UIInput input1target = (UIInput) compositeComponent1target.findComponent("testComponent"); - Assertions.assertNotNull(input1target); - Assertions.assertNotNull(input1target.getValidators()); - Assertions.assertEquals(1, input1target.getValidators().length); + assertNotNull(input1target); + assertNotNull(input1target.getValidators()); + assertEquals(1, input1target.getValidators().length); bean.setValidator1Called(false); input1target.getValidators()[0].validate(facesContext, input1target, "x"); - Assertions.assertTrue(bean.isValidator1Called()); + assertTrue(bean.isValidator1Called()); UIInput input1notarget = (UIInput) compositeComponent1target.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(input1notarget); - Assertions.assertNotNull(input1notarget.getValidators()); - Assertions.assertEquals(1, input1notarget.getValidators().length); + assertNotNull(input1notarget); + assertNotNull(input1notarget.getValidators()); + assertEquals(1, input1notarget.getValidators().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1target.pushComponentToEL(facesContext, compositeComponent1target); bean.setValidator1Called(false); input1notarget.getValidators()[0].validate(facesContext, input1notarget, "x"); - Assertions.assertTrue(bean.isValidator1Called()); + assertTrue(bean.isValidator1Called()); compositeComponent1target.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); UINamingContainer compositeComponent1notarget = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent1notarget); + assertNotNull(compositeComponent1notarget); UIInput inputnotarget1target = (UIInput) compositeComponent1notarget.findComponent("testComponent"); - Assertions.assertNotNull(inputnotarget1target); - Assertions.assertNotNull(inputnotarget1target.getValidators()); - Assertions.assertEquals(1, inputnotarget1target.getValidators().length); + assertNotNull(inputnotarget1target); + assertNotNull(inputnotarget1target.getValidators()); + assertEquals(1, inputnotarget1target.getValidators().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1notarget.pushComponentToEL(facesContext, compositeComponent1notarget); bean.setValidator1Called(false); inputnotarget1target.getValidators()[0].validate(facesContext, inputnotarget1target, "x"); - Assertions.assertTrue(bean.isValidator1Called()); + assertTrue(bean.isValidator1Called()); compositeComponent1notarget.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); UIInput inputnotarget1notarget = (UIInput) compositeComponent1notarget.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(inputnotarget1notarget); - Assertions.assertNotNull(inputnotarget1notarget.getValidators()); - Assertions.assertEquals(1, inputnotarget1notarget.getValidators().length); + assertNotNull(inputnotarget1notarget); + assertNotNull(inputnotarget1notarget.getValidators()); + assertEquals(1, inputnotarget1notarget.getValidators().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1notarget.pushComponentToEL(facesContext, compositeComponent1notarget); bean.setValidator1Called(false); inputnotarget1notarget.getValidators()[0].validate(facesContext, inputnotarget1notarget, "x"); - Assertions.assertTrue(bean.isValidator1Called()); + assertTrue(bean.isValidator1Called()); compositeComponent1notarget.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); } - + @Test - public void testSimpleValidatorNoTarget() throws Exception + void simpleValidatorNoTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -227,26 +228,26 @@ public void testSimpleValidatorNoTarget() throws Exception vdl.buildView(facesContext, root, "testSimpleAttributeValidatorNoTarget.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIInput input1 = (UIInput) compositeComponent1.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(input1); - Assertions.assertNotNull(input1.getValidators()); - Assertions.assertEquals(1, input1.getValidators().length); + assertNotNull(input1); + assertNotNull(input1.getValidators()); + assertEquals(1, input1.getValidators().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); input1.pushComponentToEL(facesContext, input1); bean.setValidator1Called(false); input1.getValidators()[0].validate(facesContext, input1, "x"); - Assertions.assertTrue(bean.isValidator1Called()); + assertTrue(bean.isValidator1Called()); input1.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); } - + @Test - public void testCompositeValidatorNoTarget() throws Exception + void compositeValidatorNoTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -257,29 +258,29 @@ public void testCompositeValidatorNoTarget() throws Exception vdl.buildView(facesContext, root, "testCompositeAttributeValidatorNoTarget.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UINamingContainer compositeComponent1inner = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeActionMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent1inner); + assertNotNull(compositeComponent1inner); UIInput testComponentNoTarget1 = (UIInput) compositeComponent1inner.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget1); - Assertions.assertNotNull(testComponentNoTarget1.getValidators()); - Assertions.assertEquals(1, testComponentNoTarget1.getValidators().length); + assertNotNull(testComponentNoTarget1); + assertNotNull(testComponentNoTarget1.getValidators()); + assertEquals(1, testComponentNoTarget1.getValidators().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1inner); bean.setValidator1Called(false); testComponentNoTarget1.getValidators()[0].validate(facesContext, testComponentNoTarget1, "x"); - Assertions.assertTrue(bean.isValidator1Called()); + assertTrue(bean.isValidator1Called()); compositeComponent1inner.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); } @Test - public void testCompositeValidatorNoTarget2() throws Exception + void compositeValidatorNoTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -290,23 +291,23 @@ public void testCompositeValidatorNoTarget2() throws Exception vdl.buildView(facesContext, root, "testCompositeAttributeValidatorNoTarget2.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UINamingContainer compositeComponent1n1 = (UINamingContainer) compositeComponent1.findComponent("compositeAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent1n1); + assertNotNull(compositeComponent1n1); UINamingContainer compositeComponent1n2 = (UINamingContainer) compositeComponent1n1.findComponent("simpleAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent1n2); + assertNotNull(compositeComponent1n2); UIInput input1 = (UIInput) compositeComponent1n2.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(input1); - Assertions.assertNotNull(input1.getValidators()); - Assertions.assertEquals(1, input1.getValidators().length); + assertNotNull(input1); + assertNotNull(input1.getValidators()); + assertEquals(1, input1.getValidators().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1n2); bean.setValidator1Called(false); input1.getValidators()[0].validate(facesContext, input1, "x"); - Assertions.assertTrue(bean.isValidator1Called()); + assertTrue(bean.isValidator1Called()); compositeComponent1n2.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentValueChangeListenerTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentValueChangeListenerTestCase.java index c50c019315..8447802961 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentValueChangeListenerTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentValueChangeListenerTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.tag.composite; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.el.ExpressionFactory; import jakarta.faces.component.UIComponent; import jakarta.faces.component.UIInput; @@ -26,10 +28,9 @@ import jakarta.faces.event.ValueChangeEvent; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CompositeComponentValueChangeListenerTestCase extends AbstractFaceletTestCase +class CompositeComponentValueChangeListenerTestCase extends AbstractFaceletTestCase { @Override protected void setupComponents() throws Exception @@ -52,9 +53,9 @@ protected ExpressionFactory createExpressionFactory() { return new org.apache.el.ExpressionFactoryImpl(); } - + @Test - public void testSimpleValueChangeListenerTarget() throws Exception + void simpleValueChangeListenerTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -66,34 +67,34 @@ public void testSimpleValueChangeListenerTarget() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIInput input1 = (UIInput) compositeComponent1.findComponent("testComponent"); - Assertions.assertNotNull(input1); - Assertions.assertNotNull(input1.getValueChangeListeners()); - Assertions.assertEquals(1, input1.getValueChangeListeners().length); + assertNotNull(input1); + assertNotNull(input1.getValueChangeListeners()); + assertEquals(1, input1.getValueChangeListeners().length); bean.setValueChangeListener1Called(false); input1.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input1,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener1Called()); + assertTrue(bean.isValueChangeListener1Called()); UIComponent panelGroup2 = root.findComponent("testGroup2"); - Assertions.assertNotNull(panelGroup2); + assertNotNull(panelGroup2); UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UIInput input2 = (UIInput) compositeComponent2.findComponent("testComponent"); - Assertions.assertNotNull(input2); - Assertions.assertNotNull(input2.getValueChangeListeners()); - Assertions.assertEquals(1, input2.getValueChangeListeners().length); + assertNotNull(input2); + assertNotNull(input2.getValueChangeListeners()); + assertEquals(1, input2.getValueChangeListeners().length); bean.setValueChangeListener2Called(false); input2.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input2,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener2Called()); + assertTrue(bean.isValueChangeListener2Called()); } @Test - public void testCompositeValueChangeListenerTarget() throws Exception + void compositeValueChangeListenerTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -104,41 +105,41 @@ public void testCompositeValueChangeListenerTarget() throws Exception vdl.buildView(facesContext, root, "testCompositeAttributeValueChangeListenerTarget.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UINamingContainer compositeComponent1inner = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent1inner); + assertNotNull(compositeComponent1inner); UIInput input1 = (UIInput) compositeComponent1inner.findComponent("testComponent"); - Assertions.assertNotNull(input1); - Assertions.assertNotNull(input1.getValueChangeListeners()); - Assertions.assertEquals(1, input1.getValueChangeListeners().length); + assertNotNull(input1); + assertNotNull(input1.getValueChangeListeners()); + assertEquals(1, input1.getValueChangeListeners().length); bean.setValueChangeListener1Called(false); input1.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input1,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener1Called()); + assertTrue(bean.isValueChangeListener1Called()); UIComponent panelGroup2 = root.findComponent("testGroup2"); - Assertions.assertNotNull(panelGroup2); + assertNotNull(panelGroup2); UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UINamingContainer compositeComponent2inner = (UINamingContainer) compositeComponent2.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent2inner); + assertNotNull(compositeComponent2inner); UIInput input2 = (UIInput) compositeComponent2inner.findComponent("testComponent"); - Assertions.assertNotNull(input2); - Assertions.assertNotNull(input2.getValueChangeListeners()); - Assertions.assertEquals(1, input2.getValueChangeListeners().length); + assertNotNull(input2); + assertNotNull(input2.getValueChangeListeners()); + assertEquals(1, input2.getValueChangeListeners().length); bean.setValueChangeListener2Called(false); input2.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input2,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener2Called()); + assertTrue(bean.isValueChangeListener2Called()); } - + @Test - public void testSimpleValueChangeListenerTarget2() throws Exception + void simpleValueChangeListenerTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -150,58 +151,58 @@ public void testSimpleValueChangeListenerTarget2() throws Exception UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIInput input1 = (UIInput) compositeComponent1.findComponent("testComponent"); - Assertions.assertNotNull(input1); - Assertions.assertNotNull(input1.getValueChangeListeners()); - Assertions.assertEquals(1, input1.getValueChangeListeners().length); + assertNotNull(input1); + assertNotNull(input1.getValueChangeListeners()); + assertEquals(1, input1.getValueChangeListeners().length); bean.setValueChangeListener1Called(false); input1.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input1,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener1Called()); + assertTrue(bean.isValueChangeListener1Called()); UIInput input1n = (UIInput) compositeComponent1.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(input1n); - Assertions.assertNotNull(input1n.getValueChangeListeners()); - Assertions.assertEquals(1, input1n.getValueChangeListeners().length); + assertNotNull(input1n); + assertNotNull(input1n.getValueChangeListeners()); + assertEquals(1, input1n.getValueChangeListeners().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); bean.setValueChangeListener1Called(false); input1n.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input1n,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener1Called()); + assertTrue(bean.isValueChangeListener1Called()); compositeComponent1.popComponentFromEL(facesContext); UIComponent panelGroup2 = root.findComponent("testGroup2"); - Assertions.assertNotNull(panelGroup2); + assertNotNull(panelGroup2); UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UIInput input2 = (UIInput) compositeComponent2.findComponent("testComponent"); - Assertions.assertNotNull(input2); - Assertions.assertNotNull(input2.getValueChangeListeners()); - Assertions.assertEquals(1, input2.getValueChangeListeners().length); + assertNotNull(input2); + assertNotNull(input2.getValueChangeListeners()); + assertEquals(1, input2.getValueChangeListeners().length); bean.setValueChangeListener2Called(false); input2.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input2,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener2Called()); + assertTrue(bean.isValueChangeListener2Called()); UIInput input2n = (UIInput) compositeComponent2.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(input2n); - Assertions.assertNotNull(input2n.getValueChangeListeners()); - Assertions.assertEquals(1, input2n.getValueChangeListeners().length); + assertNotNull(input2n); + assertNotNull(input2n.getValueChangeListeners()); + assertEquals(1, input2n.getValueChangeListeners().length); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2); bean.setValueChangeListener2Called(false); input2n.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input2n,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener2Called()); + assertTrue(bean.isValueChangeListener2Called()); compositeComponent2.popComponentFromEL(facesContext); } @Test - public void testCompositeValueChangeListenerTarget2() throws Exception + void compositeValueChangeListenerTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -212,120 +213,120 @@ public void testCompositeValueChangeListenerTarget2() throws Exception vdl.buildView(facesContext, root, "testCompositeAttributeValueChangeListenerTarget2.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UINamingContainer compositeComponent1target = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent1target); + assertNotNull(compositeComponent1target); UIInput input1target = (UIInput) compositeComponent1target.findComponent("testComponent"); - Assertions.assertNotNull(input1target); - Assertions.assertNotNull(input1target.getValueChangeListeners()); - Assertions.assertEquals(1, input1target.getValueChangeListeners().length); + assertNotNull(input1target); + assertNotNull(input1target.getValueChangeListeners()); + assertEquals(1, input1target.getValueChangeListeners().length); bean.setValueChangeListener1Called(false); input1target.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input1target,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener1Called()); + assertTrue(bean.isValueChangeListener1Called()); UIInput input1notarget = (UIInput) compositeComponent1target.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(input1notarget); - Assertions.assertNotNull(input1notarget.getValueChangeListeners()); - Assertions.assertEquals(1, input1notarget.getValueChangeListeners().length); + assertNotNull(input1notarget); + assertNotNull(input1notarget.getValueChangeListeners()); + assertEquals(1, input1notarget.getValueChangeListeners().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1target.pushComponentToEL(facesContext, compositeComponent1target); bean.setValueChangeListener1Called(false); input1notarget.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input1notarget,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener1Called()); + assertTrue(bean.isValueChangeListener1Called()); compositeComponent1target.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); UINamingContainer compositeComponent1notarget = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent1notarget); + assertNotNull(compositeComponent1notarget); UIInput inputnotarget1target = (UIInput) compositeComponent1notarget.findComponent("testComponent"); - Assertions.assertNotNull(inputnotarget1target); - Assertions.assertNotNull(inputnotarget1target.getValueChangeListeners()); - Assertions.assertEquals(1, inputnotarget1target.getValueChangeListeners().length); + assertNotNull(inputnotarget1target); + assertNotNull(inputnotarget1target.getValueChangeListeners()); + assertEquals(1, inputnotarget1target.getValueChangeListeners().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1notarget.pushComponentToEL(facesContext, compositeComponent1notarget); bean.setValueChangeListener1Called(false); inputnotarget1target.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(inputnotarget1target,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener1Called()); + assertTrue(bean.isValueChangeListener1Called()); compositeComponent1notarget.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); UIInput inputnotarget1notarget = (UIInput) compositeComponent1notarget.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(inputnotarget1notarget); - Assertions.assertNotNull(inputnotarget1notarget.getValueChangeListeners()); - Assertions.assertEquals(1, inputnotarget1notarget.getValueChangeListeners().length); + assertNotNull(inputnotarget1notarget); + assertNotNull(inputnotarget1notarget.getValueChangeListeners()); + assertEquals(1, inputnotarget1notarget.getValueChangeListeners().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1notarget.pushComponentToEL(facesContext, compositeComponent1notarget); bean.setValueChangeListener1Called(false); inputnotarget1notarget.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(inputnotarget1notarget,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener1Called()); + assertTrue(bean.isValueChangeListener1Called()); compositeComponent1notarget.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); UIComponent panelGroup2 = root.findComponent("testGroup2"); - Assertions.assertNotNull(panelGroup2); + assertNotNull(panelGroup2); UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UINamingContainer compositeComponent2target = (UINamingContainer) compositeComponent2.findComponent("simpleAttributeMethodExpressionTarget"); - Assertions.assertNotNull(compositeComponent2target); + assertNotNull(compositeComponent2target); UIInput input2target = (UIInput) compositeComponent2target.findComponent("testComponent"); - Assertions.assertNotNull(input2target); - Assertions.assertNotNull(input2target.getValueChangeListeners()); - Assertions.assertEquals(1, input2target.getValueChangeListeners().length); + assertNotNull(input2target); + assertNotNull(input2target.getValueChangeListeners()); + assertEquals(1, input2target.getValueChangeListeners().length); bean.setValueChangeListener2Called(false); input2target.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input2target,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener2Called()); + assertTrue(bean.isValueChangeListener2Called()); UIInput input2notarget = (UIInput) compositeComponent2target.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(input2notarget); - Assertions.assertNotNull(input2notarget.getValueChangeListeners()); - Assertions.assertEquals(1, input2notarget.getValueChangeListeners().length); + assertNotNull(input2notarget); + assertNotNull(input2notarget.getValueChangeListeners()); + assertEquals(1, input2notarget.getValueChangeListeners().length); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2); compositeComponent2target.pushComponentToEL(facesContext, compositeComponent2target); bean.setValueChangeListener2Called(false); input2notarget.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input2notarget,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener2Called()); + assertTrue(bean.isValueChangeListener2Called()); compositeComponent2target.popComponentFromEL(facesContext); compositeComponent2.popComponentFromEL(facesContext); UINamingContainer compositeComponent2notarget = (UINamingContainer) compositeComponent2.findComponent("simpleAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent2notarget); + assertNotNull(compositeComponent2notarget); UIInput inputnotarget2target = (UIInput) compositeComponent2notarget.findComponent("testComponent"); - Assertions.assertNotNull(inputnotarget2target); - Assertions.assertNotNull(inputnotarget2target.getValueChangeListeners()); - Assertions.assertEquals(1, inputnotarget2target.getValueChangeListeners().length); + assertNotNull(inputnotarget2target); + assertNotNull(inputnotarget2target.getValueChangeListeners()); + assertEquals(1, inputnotarget2target.getValueChangeListeners().length); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2); compositeComponent2notarget.pushComponentToEL(facesContext, compositeComponent2notarget); bean.setValueChangeListener2Called(false); inputnotarget2target.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(inputnotarget2target,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener2Called()); + assertTrue(bean.isValueChangeListener2Called()); compositeComponent2notarget.popComponentFromEL(facesContext); compositeComponent2.popComponentFromEL(facesContext); UIInput inputnotarget2notarget = (UIInput) compositeComponent2notarget.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(inputnotarget2notarget); - Assertions.assertNotNull(inputnotarget2notarget.getValueChangeListeners()); - Assertions.assertEquals(1, inputnotarget2notarget.getValueChangeListeners().length); + assertNotNull(inputnotarget2notarget); + assertNotNull(inputnotarget2notarget.getValueChangeListeners()); + assertEquals(1, inputnotarget2notarget.getValueChangeListeners().length); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2); compositeComponent2notarget.pushComponentToEL(facesContext, compositeComponent2notarget); bean.setValueChangeListener2Called(false); inputnotarget2notarget.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(inputnotarget2notarget,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener2Called()); + assertTrue(bean.isValueChangeListener2Called()); compositeComponent2notarget.popComponentFromEL(facesContext); compositeComponent2.popComponentFromEL(facesContext); } - + @Test - public void testSimpleValueChangeListenerNoTarget() throws Exception + void simpleValueChangeListenerNoTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -336,44 +337,44 @@ public void testSimpleValueChangeListenerNoTarget() throws Exception vdl.buildView(facesContext, root, "testSimpleAttributeValueChangeListenerNoTarget.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UIInput input1 = (UIInput) compositeComponent1.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(input1); - Assertions.assertNotNull(input1.getValueChangeListeners()); - Assertions.assertEquals(1, input1.getValueChangeListeners().length); + assertNotNull(input1); + assertNotNull(input1.getValueChangeListeners()); + assertEquals(1, input1.getValueChangeListeners().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); input1.pushComponentToEL(facesContext, input1); bean.setValueChangeListener1Called(false); input1.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input1,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener1Called()); + assertTrue(bean.isValueChangeListener1Called()); input1.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); UIComponent panelGroup2 = root.findComponent("testGroup2"); - Assertions.assertNotNull(panelGroup2); + assertNotNull(panelGroup2); UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UIInput input2 = (UIInput) compositeComponent2.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(input2); - Assertions.assertNotNull(input2.getValueChangeListeners()); - Assertions.assertEquals(1, input2.getValueChangeListeners().length); + assertNotNull(input2); + assertNotNull(input2.getValueChangeListeners()); + assertEquals(1, input2.getValueChangeListeners().length); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2); input2.pushComponentToEL(facesContext, input2); bean.setValueChangeListener2Called(false); input2.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input2,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener2Called()); + assertTrue(bean.isValueChangeListener2Called()); input2.popComponentFromEL(facesContext); compositeComponent2.popComponentFromEL(facesContext); } - + @Test - public void testCompositeValueChangeListenerNoTarget() throws Exception + void compositeValueChangeListenerNoTarget() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -384,49 +385,49 @@ public void testCompositeValueChangeListenerNoTarget() throws Exception vdl.buildView(facesContext, root, "testCompositeAttributeValueChangeListenerNoTarget.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UINamingContainer compositeComponent1inner = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeActionMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent1inner); + assertNotNull(compositeComponent1inner); UIInput testComponentNoTarget1 = (UIInput) compositeComponent1inner.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget1); - Assertions.assertNotNull(testComponentNoTarget1.getValueChangeListeners()); - Assertions.assertEquals(1, testComponentNoTarget1.getValueChangeListeners().length); + assertNotNull(testComponentNoTarget1); + assertNotNull(testComponentNoTarget1.getValueChangeListeners()); + assertEquals(1, testComponentNoTarget1.getValueChangeListeners().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1inner); bean.setValueChangeListener1Called(false); testComponentNoTarget1.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(testComponentNoTarget1,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener1Called()); + assertTrue(bean.isValueChangeListener1Called()); compositeComponent1inner.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); UIComponent panelGroup2 = root.findComponent("testGroup2"); - Assertions.assertNotNull(panelGroup2); + assertNotNull(panelGroup2); UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0); - Assertions.assertNotNull(compositeComponent2); + assertNotNull(compositeComponent2); UINamingContainer compositeComponent2inner = (UINamingContainer) compositeComponent2.findComponent("simpleAttributeActionMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent2inner); + assertNotNull(compositeComponent2inner); UIInput testComponentNoTarget2 = (UIInput) compositeComponent2inner.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(testComponentNoTarget2); - Assertions.assertNotNull(testComponentNoTarget2.getValueChangeListeners()); - Assertions.assertEquals(1, testComponentNoTarget2.getValueChangeListeners().length); + assertNotNull(testComponentNoTarget2); + assertNotNull(testComponentNoTarget2.getValueChangeListeners()); + assertEquals(1, testComponentNoTarget2.getValueChangeListeners().length); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2); compositeComponent2.pushComponentToEL(facesContext, compositeComponent2inner); bean.setValueChangeListener2Called(false); testComponentNoTarget2.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(testComponentNoTarget2,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener2Called()); + assertTrue(bean.isValueChangeListener2Called()); compositeComponent2inner.popComponentFromEL(facesContext); compositeComponent2.popComponentFromEL(facesContext); } @Test - public void testCompositeValueChangeListenerNoTarget2() throws Exception + void compositeValueChangeListenerNoTarget2() throws Exception { MockAttributeBean bean = new MockAttributeBean(); @@ -437,23 +438,23 @@ public void testCompositeValueChangeListenerNoTarget2() throws Exception vdl.buildView(facesContext, root, "testCompositeAttributeValueChangeListenerNoTarget2.xhtml"); UIComponent panelGroup1 = root.findComponent("testGroup1"); - Assertions.assertNotNull(panelGroup1); + assertNotNull(panelGroup1); UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0); - Assertions.assertNotNull(compositeComponent1); + assertNotNull(compositeComponent1); UINamingContainer compositeComponent1n1 = (UINamingContainer) compositeComponent1.findComponent("compositeAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent1n1); + assertNotNull(compositeComponent1n1); UINamingContainer compositeComponent1n2 = (UINamingContainer) compositeComponent1n1.findComponent("simpleAttributeMethodExpressionNoTarget"); - Assertions.assertNotNull(compositeComponent1n2); + assertNotNull(compositeComponent1n2); UIInput input1 = (UIInput) compositeComponent1n2.findComponent("testComponentNoTarget"); - Assertions.assertNotNull(input1); - Assertions.assertNotNull(input1.getValueChangeListeners()); - Assertions.assertEquals(1, input1.getValueChangeListeners().length); + assertNotNull(input1); + assertNotNull(input1.getValueChangeListeners()); + assertEquals(1, input1.getValueChangeListeners().length); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1); compositeComponent1.pushComponentToEL(facesContext, compositeComponent1n2); bean.setValueChangeListener1Called(false); input1.getValueChangeListeners()[0].processValueChange(new ValueChangeEvent(input1,"x","y")); - Assertions.assertTrue(bean.isValueChangeListener1Called()); + assertTrue(bean.isValueChangeListener1Called()); compositeComponent1n2.popComponentFromEL(facesContext); compositeComponent1.popComponentFromEL(facesContext); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/OverwriteRequiredCompositeTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/OverwriteRequiredCompositeTest.java index e2ce92b55e..85bddbb8c8 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/OverwriteRequiredCompositeTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/OverwriteRequiredCompositeTest.java @@ -19,14 +19,15 @@ package org.apache.myfaces.view.facelets.tag.composite; +import static org.junit.jupiter.api.Assertions.assertTrue; + import jakarta.el.ExpressionFactory; import jakarta.faces.component.UICommand; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; // test for MYFACES-4656 -public class OverwriteRequiredCompositeTest extends AbstractMyFacesCDIRequestTestCase +class OverwriteRequiredCompositeTest extends AbstractMyFacesCDIRequestTestCase { @Override protected void setUpServletObjects() throws Exception @@ -37,28 +38,28 @@ protected void setUpServletObjects() throws Exception } @Test - public void testSimpleCompositeComponent() throws Exception + void simpleCompositeComponent() throws Exception { startViewRequest("/overwriteRequiredComposite.xhtml"); processLifecycleExecuteAndRender(); String content = getRenderedContent(facesContext); - Assertions.assertTrue(content.contains("form:fifth REQUIRED: false") + assertTrue(content.contains("form:fifth REQUIRED: false") && content.contains("form:fifth VALID: true")); - Assertions.assertTrue(content.contains("form:sixth REQUIRED: true") + assertTrue(content.contains("form:sixth REQUIRED: true") && content.contains("form:sixth VALID: true")); - Assertions.assertTrue(content.contains("form:seventh REQUIRED: true") + assertTrue(content.contains("form:seventh REQUIRED: true") && content.contains("form:seventh VALID: true")); - Assertions.assertTrue(content.contains("form:eight REQUIRED: true") + assertTrue(content.contains("form:eight REQUIRED: true") && content.contains("form:eight VALID: true")); - Assertions.assertTrue(content.contains("form:ninth REQUIRED: false") + assertTrue(content.contains("form:ninth REQUIRED: false") && content.contains("form:ninth VALID: true")); - Assertions.assertTrue(content.contains("form:tenth REQUIRED: true") + assertTrue(content.contains("form:tenth REQUIRED: true") && content.contains("form:tenth VALID: true")); - Assertions.assertTrue(content.contains("form:eleventh REQUIRED: true") + assertTrue(content.contains("form:eleventh REQUIRED: true") && content.contains("form:eleventh VALID: true")); - Assertions.assertTrue(content.contains("form:twelvth REQUIRED: true") + assertTrue(content.contains("form:twelvth REQUIRED: true") && content.contains("form:twelvth VALID: true")); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/SerializableAttributesTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/SerializableAttributesTestCase.java index 5e5a9a341d..8f4396d5a5 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/SerializableAttributesTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/SerializableAttributesTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.tag.composite; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.beans.BeanDescriptor; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -25,13 +27,12 @@ import java.io.ObjectOutputStream; import jakarta.faces.component.UINamingContainer; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class SerializableAttributesTestCase +class SerializableAttributesTestCase { @Test - public void testSerializeCompositeResourceWrapper() throws Exception + void serializeCompositeResourceWrapper() throws Exception { CompositeResourceWrapper subject = new CompositeResourceWrapper(); subject.setResourceName("testRes"); @@ -46,15 +47,15 @@ public void testSerializeCompositeResourceWrapper() throws Exception ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); CompositeResourceWrapper blorg = (CompositeResourceWrapper) ois.readObject(); - Assertions.assertEquals(blorg.getResourceName(), subject.getResourceName()); - Assertions.assertEquals(blorg.getLibraryName(), subject.getLibraryName()); - Assertions.assertEquals(blorg.getContentType(), subject.getContentType()); + assertEquals(blorg.getResourceName(), subject.getResourceName()); + assertEquals(blorg.getLibraryName(), subject.getLibraryName()); + assertEquals(blorg.getContentType(), subject.getContentType()); oos.close(); ois.close(); } - + @Test - public void testSerializeCompositeComponentBeanInfo() throws Exception + void serializeCompositeComponentBeanInfo() throws Exception { BeanDescriptor descriptor = new BeanDescriptor(UINamingContainer.class); CompositeComponentBeanInfo subject = new CompositeComponentBeanInfo(descriptor); @@ -70,8 +71,8 @@ public void testSerializeCompositeComponentBeanInfo() throws Exception ObjectInputStream ois = new ObjectInputStream(bais); CompositeComponentBeanInfo blorg = (CompositeComponentBeanInfo) ois.readObject(); - Assertions.assertEquals(UINamingContainer.class, blorg.getBeanDescriptor().getBeanClass()); - Assertions.assertEquals(pd.getName(), blorg.getPropertyDescriptorsList().get(0).getName()); + assertEquals(UINamingContainer.class, blorg.getBeanDescriptor().getBeanClass()); + assertEquals(pd.getName(), blorg.getPropertyDescriptorsList().get(0).getName()); oos.close(); ois.close(); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/localized/LocalizedCompositeComponentTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/localized/LocalizedCompositeComponentTestCase.java index 61a6f3c041..9584c5a613 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/localized/LocalizedCompositeComponentTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/localized/LocalizedCompositeComponentTestCase.java @@ -21,9 +21,11 @@ import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.apache.myfaces.test.core.AbstractMyFacesRequestTestCase; import org.apache.myfaces.test.core.annotation.DeclareFacesConfig; -import org.junit.jupiter.api.Assertions; + import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Check if a composite component can be localized following the rules * of Faces 2.0 Resource Handler API that are used for css, javascript @@ -33,7 +35,7 @@ * */ @DeclareFacesConfig("/faces-config.xml") -public class LocalizedCompositeComponentTestCase extends AbstractMyFacesCDIRequestTestCase +class LocalizedCompositeComponentTestCase extends AbstractMyFacesCDIRequestTestCase { // This is a nice example that shows how AbstractMyFacesRequestTestCase // could be be useful. @@ -43,31 +45,31 @@ public class LocalizedCompositeComponentTestCase extends AbstractMyFacesCDIReque // teardown all MyFaces container. @Test - public void testNoLocaleCompositeComponent() throws Exception + void noLocaleCompositeComponent() throws Exception { startViewRequest("/testNoLocalizedComposite.xhtml"); processLifecycleExecuteAndRender(); - Assertions.assertTrue(getRenderedContent().contains( + assertTrue(getRenderedContent().contains( "English page fragment")); endRequest(); } - + @Test - public void testSpanishLocaleCompositeComponent() throws Exception + void spanishLocaleCompositeComponent() throws Exception { startViewRequest("/testSpanishLocalizedComposite.xhtml"); processLifecycleExecuteAndRender(); - Assertions.assertTrue(getRenderedContent().contains( + assertTrue(getRenderedContent().contains( "Fragmento de pagina Espanol")); endRequest(); } - + @Test - public void testGermanLocaleCompositeComponent() throws Exception + void germanLocaleCompositeComponent() throws Exception { startViewRequest("/testGermanLocalizedComposite.xhtml"); processLifecycleExecuteAndRender(); - Assertions.assertTrue(getRenderedContent().contains( + assertTrue(getRenderedContent().contains( "Deutsches Seitenfragment")); endRequest(); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/AjaxListenerTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/AjaxListenerTestCase.java index e3fb8acd9b..c13dfc3a33 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/AjaxListenerTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/AjaxListenerTestCase.java @@ -19,6 +19,8 @@ package org.apache.myfaces.view.facelets.tag.faces.core; +import static org.junit.jupiter.api.Assertions.*; + import java.util.List; import java.util.Map; @@ -33,7 +35,6 @@ import jakarta.faces.event.AjaxBehaviorEvent; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -41,43 +42,43 @@ * f:ajax listener must accept a method taking the AjaxBehaviorEvent or a method taking no arguments. * The method taking the event is preferred when both exist. */ -public class AjaxListenerTestCase extends AbstractFaceletTestCase +class AjaxListenerTestCase extends AbstractFaceletTestCase { private AjaxListenerBean bean; @BeforeEach - public void setUpBean() + void setUpBean() { bean = new AjaxListenerBean(); facesContext.getExternalContext().getRequestMap().put("ajaxListenerBean", bean); } @Test - public void testOneArgMethod() throws Exception + void oneArgMethod() throws Exception { - Assertions.assertEquals(List.of("oneArg(event)"), broadcast("oneArg")); + assertEquals(List.of("oneArg(event)"), broadcast("oneArg")); } @Test - public void testZeroArgMethod() throws Exception + void zeroArgMethod() throws Exception { - Assertions.assertEquals(List.of("zeroArg()"), broadcast("zeroArg")); + assertEquals(List.of("zeroArg()"), broadcast("zeroArg")); } @Test - public void testBothMethodsPrefersEvent() throws Exception + void bothMethodsPrefersEvent() throws Exception { - Assertions.assertEquals(List.of("both(event)"), broadcast("both")); + assertEquals(List.of("both(event)"), broadcast("both")); } @Test - public void testMissingMethod() throws Exception + void missingMethod() throws Exception { - Assertions.assertThrows(MethodNotFoundException.class, () -> broadcast("missing")); + assertThrows(MethodNotFoundException.class, () -> broadcast("missing")); } @Test - public void testStateSaving() throws Exception + void stateSaving() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "ajaxListener.xhtml"); @@ -96,7 +97,7 @@ public void testStateSaving() throws Exception restored.processAjaxBehavior(new AjaxBehaviorEvent(facesContext, root.findComponent("form:zeroArg"), getAjaxBehavior(root, "zeroArg"))); - Assertions.assertEquals(List.of("zeroArg()"), bean.getInvocations()); + assertEquals(List.of("zeroArg()"), bean.getInvocations()); } private List broadcast(String id) throws Exception @@ -114,12 +115,12 @@ private List broadcast(String id) throws Exception private AjaxBehavior getAjaxBehavior(UIViewRoot root, String id) { UIComponent input = root.findComponent("form:" + id); - Assertions.assertNotNull(input); + assertNotNull(input); Map> behaviors = ((ClientBehaviorHolder) input).getClientBehaviors(); List change = behaviors.get("change"); - Assertions.assertNotNull(change); - Assertions.assertEquals(1, change.size()); + assertNotNull(change); + assertEquals(1, change.size()); return (AjaxBehavior) change.get(0); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/CoreTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/CoreTestCase.java index 871d1595a9..b64e191c2b 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/CoreTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/CoreTestCase.java @@ -20,7 +20,11 @@ package org.apache.myfaces.view.facelets.tag.faces.core; import org.apache.myfaces.view.facelets.tag.faces.core.reset.ResetValuesBean; + import java.text.DateFormat; + +import static org.junit.jupiter.api.Assertions.*; + import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; @@ -59,10 +63,9 @@ import org.apache.myfaces.renderkit.html.HtmlTableRenderer; import org.apache.myfaces.renderkit.html.HtmlTextRenderer; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CoreTestCase extends AbstractFaceletTestCase +class CoreTestCase extends AbstractFaceletTestCase { @Override @@ -124,7 +127,7 @@ protected void setupRenderers() throws Exception } @Test - public void testActionListenerHandler() throws Exception + void actionListenerHandler() throws Exception { ActionListener listener = new ActionListenerImpl(); @@ -137,15 +140,15 @@ public void testActionListenerHandler() throws Exception UICommand action1 = (UICommand) root.findComponent("action1"); UICommand action2 = (UICommand) root.findComponent("action2"); - Assertions.assertNotNull(action1); - Assertions.assertNotNull(action2); + assertNotNull(action1); + assertNotNull(action2); - Assertions.assertEquals(1,action1.getActionListeners().length); - Assertions.assertEquals(2,action2.getActionListeners().length); + assertEquals(1,action1.getActionListeners().length); + assertEquals(2,action2.getActionListeners().length); } @Test - public void testAttributeHandler() throws Exception + void attributeHandler() throws Exception { String title = "Dog in a Funny Hat"; facesContext.getExternalContext().getRequestMap().put("title", title); @@ -158,15 +161,15 @@ public void testAttributeHandler() throws Exception HtmlGraphicImage graphic2 = (HtmlGraphicImage) root .findComponent("graphic2"); - Assertions.assertNotNull(graphic1); - Assertions.assertNotNull(graphic2); + assertNotNull(graphic1); + assertNotNull(graphic2); - Assertions.assertEquals("literal", graphic1.getTitle()); - Assertions.assertEquals(title, graphic2.getTitle()); + assertEquals("literal", graphic1.getTitle()); + assertEquals(title, graphic2.getTitle()); } @Test - public void testConvertDateTimeHandler() throws Exception + void convertDateTimeHandler() throws Exception { Date now = new Date(1000 * 360 * 60 * 24 * 7); facesContext.getExternalContext().getRequestMap().put("now", now); @@ -181,18 +184,18 @@ public void testConvertDateTimeHandler() throws Exception UIOutput out5 = (UIOutput) root.findComponent("form:out5"); UIOutput out6 = (UIOutput) root.findComponent("form:out6"); - Assertions.assertNotNull(out1); - Assertions.assertNotNull(out2); - Assertions.assertNotNull(out3); - Assertions.assertNotNull(out4); - Assertions.assertNotNull(out5); - Assertions.assertNotNull(out6); - - Assertions.assertNotNull(out1.getConverter()); - Assertions.assertNotNull(out2.getConverter()); - Assertions.assertNotNull(out3.getConverter()); - Assertions.assertNotNull(out4.getConverter()); - Assertions.assertNotNull(out5.getConverter()); + assertNotNull(out1); + assertNotNull(out2); + assertNotNull(out3); + assertNotNull(out4); + assertNotNull(out5); + assertNotNull(out6); + + assertNotNull(out1.getConverter()); + assertNotNull(out2.getConverter()); + assertNotNull(out3.getConverter()); + assertNotNull(out4.getConverter()); + assertNotNull(out5.getConverter()); DateTimeConverter converter6 = (DateTimeConverter) out6.getConverter(); TimeZone gmt = TimeZone.getTimeZone("GMT"); @@ -200,38 +203,38 @@ public void testConvertDateTimeHandler() throws Exception DateFormat shortDate = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US); shortDate.setLenient(false); shortDate.setTimeZone(gmt); - Assertions.assertEquals(shortDate.format(now), out1.getConverter().getAsString( + assertEquals(shortDate.format(now), out1.getConverter().getAsString( facesContext, out1, now)); DateFormat shortDateMediumTime = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.MEDIUM, Locale.US); shortDateMediumTime.setLenient(false); shortDateMediumTime.setTimeZone(gmt); - Assertions.assertEquals(shortDateMediumTime.format(now), out2.getConverter() + assertEquals(shortDateMediumTime.format(now), out2.getConverter() .getAsString(facesContext, out2, now)); DateFormat mediumDate = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US); mediumDate.setTimeZone(TimeZone.getTimeZone("CST")); mediumDate.setLenient(false); - Assertions.assertEquals(mediumDate.format(now), out3.getConverter() + assertEquals(mediumDate.format(now), out3.getConverter() .getAsString(facesContext, out3, now)); DateFormat mediumTime = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.US); mediumTime.setLenient(false); mediumTime.setTimeZone(gmt); - Assertions.assertEquals(mediumTime.format(now), out4.getConverter() + assertEquals(mediumTime.format(now), out4.getConverter() .getAsString(facesContext, out4, now)); SimpleDateFormat patternCst = new SimpleDateFormat("K:mm a, z", Locale.US); patternCst.setTimeZone(TimeZone.getTimeZone("CST")); patternCst.setLenient(false); - Assertions.assertEquals(patternCst.format(now), out5.getConverter() + assertEquals(patternCst.format(now), out5.getConverter() .getAsString(facesContext, out5, now)); - Assertions.assertEquals(TimeZone.getTimeZone("GMT"), converter6.getTimeZone()); + assertEquals(TimeZone.getTimeZone("GMT"), converter6.getTimeZone()); } @Test - public void testConvertDelegateHandler() throws Exception + void convertDelegateHandler() throws Exception { UIViewRoot root = facesContext.getViewRoot(); root.setLocale(Locale.US); @@ -239,16 +242,16 @@ public void testConvertDelegateHandler() throws Exception UIOutput out1 = (UIOutput) root.findComponent("out1"); - Assertions.assertNotNull( out1); + assertNotNull( out1); - Assertions.assertNotNull(out1.getConverter()); + assertNotNull(out1.getConverter()); - Assertions.assertEquals(new Double(42.5), out1.getConverter() + assertEquals(new Double(42.5), out1.getConverter() .getAsObject(facesContext, out1, out1.getLocalValue().toString())); } @Test - public void testConvertNumberHandler() throws Exception + void convertNumberHandler() throws Exception { UIViewRoot root = facesContext.getViewRoot(); root.setLocale(Locale.US); @@ -260,57 +263,57 @@ public void testConvertNumberHandler() throws Exception UIOutput out4 = (UIOutput) root.findComponent("out4"); UIOutput out5 = (UIOutput) root.findComponent("out5"); - Assertions.assertNotNull(out1); - Assertions.assertNotNull(out2); - Assertions.assertNotNull(out3); - Assertions.assertNotNull(out4); - Assertions.assertNotNull(out5); + assertNotNull(out1); + assertNotNull(out2); + assertNotNull(out3); + assertNotNull(out4); + assertNotNull(out5); - Assertions.assertNotNull(out1.getConverter()); - Assertions.assertNotNull(out2.getConverter()); - Assertions.assertNotNull(out3.getConverter()); - Assertions.assertNotNull(out4.getConverter()); - Assertions.assertNotNull(out5.getConverter()); + assertNotNull(out1.getConverter()); + assertNotNull(out2.getConverter()); + assertNotNull(out3.getConverter()); + assertNotNull(out4.getConverter()); + assertNotNull(out5.getConverter()); - Assertions.assertEquals("12", out1.getConverter().getAsString(facesContext, + assertEquals("12", out1.getConverter().getAsString(facesContext, out1, new Double(12.001))); - Assertions.assertEquals("$12.00", out2.getConverter().getAsString( + assertEquals("$12.00", out2.getConverter().getAsString( facesContext, out2, new Double(12.00))); - Assertions.assertEquals("00,032", out3.getConverter().getAsString( + assertEquals("00,032", out3.getConverter().getAsString( facesContext, out3, new Double(32))); - Assertions.assertEquals("0.67", out4.getConverter().getAsString( + assertEquals("0.67", out4.getConverter().getAsString( facesContext, out4, new Double(2.0 / 3.0))); - Assertions.assertEquals("67%", out5.getConverter().getAsString( + assertEquals("67%", out5.getConverter().getAsString( facesContext, out5, new Double(0.67))); } @Test - public void testFacetHandler() throws Exception + void facetHandler() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "facet.xml"); UIData data = (UIData) root.findComponent("table"); - Assertions.assertNotNull(data); + assertNotNull(data); UIComponent footer = data.getFooter(); - Assertions.assertNotNull(footer); + assertNotNull(footer); } @Test - public void testLoadBundleHandler() throws Exception + void loadBundleHandler() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "loadBundle.xml"); Object value = facesContext.getExternalContext().getRequestMap().get("foo"); - Assertions.assertNotNull(value); - Assertions.assertTrue(value instanceof Map); + assertNotNull(value); + assertInstanceOf(Map.class, value); String result = (String) ((Map) value).get("some.not.found.key"); - Assertions.assertTrue(result.contains("???")); + assertTrue(result.contains("???")); } /** @@ -320,35 +323,35 @@ public void testLoadBundleHandler() throws Exception * buildView time; changing the locale afterwards had no effect. */ @Test - public void testLoadBundleHandlerRefreshesOnLocaleChange() throws Exception + void loadBundleHandlerRefreshesOnLocaleChange() throws Exception { UIViewRoot root = facesContext.getViewRoot(); root.setLocale(Locale.ENGLISH); vdl.buildView(facesContext, root, "loadBundle.xml"); Map bundle = (Map) facesContext.getExternalContext().getRequestMap().get("foo"); - Assertions.assertNotNull(bundle); - Assertions.assertEquals("bar_en", bundle.get("foo"), + assertNotNull(bundle); + assertEquals("bar_en", bundle.get("foo"), "English locale should return 'bar_en' (from bundle_en.properties)"); // Simulate locale change during invoke-application (MYFACES-4426). root.setLocale(Locale.GERMAN); - Assertions.assertEquals("baz_de", bundle.get("foo"), + assertEquals("baz_de", bundle.get("foo"), "After setLocale(GERMAN) the bundle map must return the German value without rebuildView"); } @Test - public void testValidateDelegateHandler() throws Exception + void validateDelegateHandler() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "validator.xml"); UIInput input = (UIInput) root.findComponent("form:input"); - Assertions.assertNotNull(input); + assertNotNull(input); - Assertions.assertEquals(1, input.getValidators().length); + assertEquals(1, input.getValidators().length); Validator v = input.getValidators()[0]; @@ -356,16 +359,16 @@ public void testValidateDelegateHandler() throws Exception } @Test - public void testValidateDoubleRangeHandler() throws Exception + void validateDoubleRangeHandler() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "validateDoubleRange.xml"); UIInput input = (UIInput) root.findComponent("form:input"); - Assertions.assertNotNull(input); + assertNotNull(input); - Assertions.assertEquals(1, input.getValidators().length); + assertEquals(1, input.getValidators().length); Validator v = input.getValidators()[0]; @@ -373,16 +376,16 @@ public void testValidateDoubleRangeHandler() throws Exception } @Test - public void testValidateLengthHandler() throws Exception + void validateLengthHandler() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "validateLength.xml"); UIInput input = (UIInput) root.findComponent("form:input"); - Assertions.assertNotNull(input); + assertNotNull(input); - Assertions.assertEquals(1, input.getValidators().length); + assertEquals(1, input.getValidators().length); Validator v = input.getValidators()[0]; @@ -390,16 +393,16 @@ public void testValidateLengthHandler() throws Exception } @Test - public void testValidateLongRangeHandler() throws Exception + void validateLongRangeHandler() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "validateLongRange.xml"); UIInput input = (UIInput) root.findComponent("form:input"); - Assertions.assertNotNull(input); + assertNotNull(input); - Assertions.assertEquals(1, input.getValidators().length); + assertEquals(1, input.getValidators().length); Validator v = input.getValidators()[0]; @@ -407,30 +410,30 @@ public void testValidateLongRangeHandler() throws Exception } @Test - public void testValueChangeListenerHandler() throws Exception + void valueChangeListenerHandler() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "valueChangeListener.xml"); UIInput input = (UIInput) root.findComponent("form:input"); - Assertions.assertNotNull(input); + assertNotNull(input); - Assertions.assertEquals(1, + assertEquals(1, input.getValueChangeListeners().length); } @Test - public void testViewHandler() throws Exception + void viewHandler() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "view.xml"); - Assertions.assertEquals(Locale.GERMAN, root.getLocale()); + assertEquals(Locale.GERMAN, root.getLocale()); } - + @Test - public void testResetValuesActionListenerHandler() throws Exception + void resetValuesActionListenerHandler() throws Exception { ResetValuesBean bean = new ResetValuesBean(); @@ -443,14 +446,14 @@ public void testResetValuesActionListenerHandler() throws Exception UICommand action1 = (UICommand) root.findComponent("mainForm:submit"); - Assertions.assertNotNull(action1); + assertNotNull(action1); - Assertions.assertEquals(1, action1.getActionListeners().length); + assertEquals(1, action1.getActionListeners().length); UIInput field1 = (UIInput) root.findComponent("mainForm:field1"); field1.setValue("xxx"); - Assertions.assertEquals("xxx", field1.getValue()); - Assertions.assertTrue(field1.isLocalValueSet()); + assertEquals("xxx", field1.getValue()); + assertTrue(field1.isLocalValueSet()); UIInput field2 = (UIInput) root.findComponent("mainForm:field2"); field2.setSubmittedValue("1"); @@ -459,10 +462,10 @@ public void testResetValuesActionListenerHandler() throws Exception action1.getActionListeners()[0].processAction(new ActionEvent(action1)); // If resetValues() was activated, - Assertions.assertEquals("Hello",field1.getValue()); - Assertions.assertFalse(field1.isLocalValueSet()); - Assertions.assertNull(field2.getSubmittedValue()); - Assertions.assertTrue(field2.isValid()); + assertEquals("Hello",field1.getValue()); + assertFalse(field1.isLocalValueSet()); + assertNull(field2.getSubmittedValue()); + assertTrue(field2.isValid()); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/ValidateBeanTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/ValidateBeanTestCase.java index c7e8ccd2bf..f1f4345cf5 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/ValidateBeanTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/ValidateBeanTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.tag.faces.core; +import static org.junit.jupiter.api.Assertions.*; + import java.io.IOException; import java.lang.reflect.Field; @@ -29,7 +31,6 @@ import org.apache.myfaces.util.ExternalSpecifications; import org.apache.myfaces.util.lang.Lazy; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -39,7 +40,7 @@ * @author Jakob Korherr (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class ValidateBeanTestCase extends AbstractFaceletTestCase +class ValidateBeanTestCase extends AbstractFaceletTestCase { @Override @@ -136,7 +137,7 @@ private String _getValidationGroups(UIInput input) */ @Test @SuppressWarnings("unchecked") - public void testBeanValidatorInstalledManually() throws IOException + void beanValidatorInstalledManually() throws Exception { // put the disabled value on the request scope externalContext.getRequestMap().put("validateBeanDisabled", Boolean.FALSE); @@ -149,9 +150,9 @@ public void testBeanValidatorInstalledManually() throws IOException UIInput input = (UIInput) root.findComponent("form:input"); // the UIInput has to have the BeanValidator installed - Assertions.assertTrue(_hasValidator(input, BeanValidator.class)); + assertTrue(_hasValidator(input, BeanValidator.class)); } - + /** * Tests the case that the UIInput has no nested * on the facelet, but the BeanValidator is a default validator. @@ -159,7 +160,7 @@ public void testBeanValidatorInstalledManually() throws IOException * @throws IOException */ @Test - public void testBeanValidatorInstalledAutomatically() throws IOException + void beanValidatorInstalledAutomatically() throws Exception { // add the BeanValidator as default-validator application.addDefaultValidatorId(BeanValidator.VALIDATOR_ID); @@ -172,9 +173,9 @@ public void testBeanValidatorInstalledAutomatically() throws IOException UIInput input = (UIInput) root.findComponent("form:input"); // the UIInput has to have the BeanValidator installed - Assertions.assertTrue(_hasValidator(input, BeanValidator.class)); + assertTrue(_hasValidator(input, BeanValidator.class)); } - + /** * Tests the case that the BeanValidator is a default validator, but the * UIInput has a nested on the facelet. @@ -183,7 +184,7 @@ public void testBeanValidatorInstalledAutomatically() throws IOException */ @Test @SuppressWarnings("unchecked") - public void testDisabledBeanValidatorNotInstalled() throws IOException + void disabledBeanValidatorNotInstalled() throws Exception { // add the BeanValidator as default-validator application.addDefaultValidatorId(BeanValidator.VALIDATOR_ID); @@ -199,9 +200,9 @@ public void testDisabledBeanValidatorNotInstalled() throws IOException UIInput input = (UIInput) root.findComponent("form:input"); // the UIInput must not have the BeanValidator installed - Assertions.assertFalse(_hasValidator(input, BeanValidator.class)); + assertFalse(_hasValidator(input, BeanValidator.class)); } - + /** * Tests the case when is used in wrapping mode * and the BeanValidator is not a default-validator. @@ -212,7 +213,7 @@ public void testDisabledBeanValidatorNotInstalled() throws IOException */ @Test @SuppressWarnings("unchecked") - public void testNestingValidateBean() throws IOException + void nestingValidateBean() throws Exception { // put the disabled value on the request scope externalContext.getRequestMap().put("validateBeanDisabled", Boolean.FALSE); @@ -228,12 +229,12 @@ public void testNestingValidateBean() throws IOException UIInput nonnestedinput = (UIInput) root.findComponent("form:nonnestedinput"); // all wrapped UIInputs have to have the BeanValidator installed - Assertions.assertTrue(_hasValidator(nestedinput, BeanValidator.class)); - Assertions.assertTrue(_hasValidator(doublenestedinput, BeanValidator.class)); - Assertions.assertTrue(_hasValidator(nestedinput2, BeanValidator.class)); - Assertions.assertFalse(_hasValidator(nonnestedinput, BeanValidator.class)); + assertTrue(_hasValidator(nestedinput, BeanValidator.class)); + assertTrue(_hasValidator(doublenestedinput, BeanValidator.class)); + assertTrue(_hasValidator(nestedinput2, BeanValidator.class)); + assertFalse(_hasValidator(nonnestedinput, BeanValidator.class)); } - + /** * Tests the case when is used in wrapping mode, * its disabled attribute is true and the BeanValidator is a default-validator. @@ -244,7 +245,7 @@ public void testNestingValidateBean() throws IOException */ @Test @SuppressWarnings("unchecked") - public void testNestingValidateBeanDisabled() throws IOException + void nestingValidateBeanDisabled() throws Exception { // put the disabled value on the request scope externalContext.getRequestMap().put("validateBeanDisabled", Boolean.TRUE); @@ -263,12 +264,12 @@ public void testNestingValidateBeanDisabled() throws IOException UIInput nonnestedinput = (UIInput) root.findComponent("form:nonnestedinput"); // all wrapped UIInputs have to have the BeanValidator installed - Assertions.assertFalse(_hasValidator(nestedinput, BeanValidator.class)); - Assertions.assertFalse(_hasValidator(doublenestedinput, BeanValidator.class)); - Assertions.assertFalse(_hasValidator(nestedinput2, BeanValidator.class)); - Assertions.assertTrue(_hasValidator(nonnestedinput, BeanValidator.class)); + assertFalse(_hasValidator(nestedinput, BeanValidator.class)); + assertFalse(_hasValidator(doublenestedinput, BeanValidator.class)); + assertFalse(_hasValidator(nestedinput2, BeanValidator.class)); + assertTrue(_hasValidator(nonnestedinput, BeanValidator.class)); } - + /** * Tests the case that there are two tags, one disabled and * one not. The disabled one should add the validator id of the BeanValidator @@ -278,7 +279,7 @@ public void testNestingValidateBeanDisabled() throws IOException * @throws IOException */ @Test - public void testValidateBeanDisabledAndEnabled() throws IOException + void validateBeanDisabledAndEnabled() throws Exception { // build testValidateBeanDisabledAndEnabled.xhtml UIViewRoot root = facesContext.getViewRoot(); @@ -288,9 +289,9 @@ public void testValidateBeanDisabledAndEnabled() throws IOException UIInput input = (UIInput) root.findComponent("form:input"); // the UIInput has to have the BeanValidator installed - Assertions.assertTrue(_hasValidator(input, BeanValidator.class)); + assertTrue(_hasValidator(input, BeanValidator.class)); } - + /** * Tests the case that there are a wrapping f:validateBean with disabled * set to true and one nested f:validateBean. Also the BeanValidator is @@ -302,7 +303,7 @@ public void testValidateBeanDisabledAndEnabled() throws IOException */ @Test @SuppressWarnings("unchecked") - public void testValidateBeanNestingAndNested() throws IOException + void validateBeanNestingAndNested() throws Exception { // add the BeanValidator as default-validator application.addDefaultValidatorId(BeanValidator.VALIDATOR_ID); @@ -321,18 +322,18 @@ public void testValidateBeanNestingAndNested() throws IOException // no wrapped UIInput has to have the BeanValidator installed, // except the one nesting itself. - Assertions.assertFalse(_hasValidator(nestedinput, BeanValidator.class)); - Assertions.assertTrue(_hasValidator(nestedinputWithValidator, BeanValidator.class)); - Assertions.assertTrue(_hasValidator(nonnestedinput, BeanValidator.class)); + assertFalse(_hasValidator(nestedinput, BeanValidator.class)); + assertTrue(_hasValidator(nestedinputWithValidator, BeanValidator.class)); + assertTrue(_hasValidator(nonnestedinput, BeanValidator.class)); } - + /** * Tests if the validationGroups are set correctly. * @throws IOException */ @Test @SuppressWarnings("unchecked") - public void testValidateBeanValidationGroups() throws IOException + void validateBeanValidationGroups() throws Exception { final String validationGroups = "org.apache.myfaces.beanvalidation.Group1," + "org.apache.myfaces.beanvalidation.Group2"; @@ -348,9 +349,9 @@ public void testValidateBeanValidationGroups() throws IOException UIInput input = (UIInput) root.findComponent("form:input"); // the validationGroups have to match - Assertions.assertEquals(validationGroups, _getValidationGroups(input)); + assertEquals(validationGroups, _getValidationGroups(input)); } - + /** * Tests the case that the BeanValidator is a default validator and the * UIInput on the facelet does not have a custom tag. @@ -358,7 +359,7 @@ public void testValidateBeanValidationGroups() throws IOException * @throws IOException */ @Test - public void testValidateBeanDefaultValidationGroup() throws IOException + void validateBeanDefaultValidationGroup() throws Exception { // add the BeanValidator as default-validator application.addDefaultValidatorId(BeanValidator.VALIDATOR_ID); @@ -371,10 +372,10 @@ public void testValidateBeanDefaultValidationGroup() throws IOException UIInput input = (UIInput) root.findComponent("form:input"); // the validationGroups have to match the Default ones - Assertions.assertEquals(jakarta.validation.groups.Default.class.getName(), + assertEquals(jakarta.validation.groups.Default.class.getName(), _getValidationGroups(input)); } - + /** * Tests the case that there is a wrapping on the facelet * with some validationGroups. These validationGroups should be applied to @@ -385,7 +386,7 @@ public void testValidateBeanDefaultValidationGroup() throws IOException */ @Test @SuppressWarnings("unchecked") - public void testValidateBeanValidationGroupsNested() throws IOException + void validateBeanValidationGroupsNested() throws Exception { final String validationGroups = "org.apache.myfaces.beanvalidation.Group1"; @@ -408,13 +409,13 @@ public void testValidateBeanValidationGroupsNested() throws IOException // the validationGroups in the wrapped components have to match // org.apache.myfaces.beanvalidation.Group1 and the non-nested ones // have to match the Default group. - Assertions.assertEquals(validationGroups, _getValidationGroups(nestedinput)); - Assertions.assertEquals(validationGroups, _getValidationGroups(doublenestedinput)); - Assertions.assertEquals(validationGroups, _getValidationGroups(nestedinput2)); - Assertions.assertEquals(jakarta.validation.groups.Default.class.getName(), + assertEquals(validationGroups, _getValidationGroups(nestedinput)); + assertEquals(validationGroups, _getValidationGroups(doublenestedinput)); + assertEquals(validationGroups, _getValidationGroups(nestedinput2)); + assertEquals(jakarta.validation.groups.Default.class.getName(), _getValidationGroups(nonnestedinput)); } - + /** * Tests the case that there is a wrapping with some validationGroups * and one nested component has its own with different validationGroups. @@ -425,7 +426,7 @@ public void testValidateBeanValidationGroupsNested() throws IOException */ @Test @SuppressWarnings("unchecked") - public void testValidateBeanValidationGroupsNestingAndNested() throws IOException + void validateBeanValidationGroupsNestingAndNested() throws Exception { final String wrappingValidationGroups = "org.apache.myfaces.beanvalidation.Group1"; final String componentValidationGroups = "org.apache.myfaces.beanvalidation.ACompletelyOtherGroup"; @@ -452,12 +453,12 @@ public void testValidateBeanValidationGroupsNestingAndNested() throws IOExceptio // the nested component without a validator must get the wrapping validationGroups, // the nested component with the validator must get the validationGroups from the // validator and the non-nested component must get the Default validationGroups. - Assertions.assertEquals(wrappingValidationGroups, _getValidationGroups(nestedinput)); - Assertions.assertEquals(componentValidationGroups, _getValidationGroups(nestedinputWithValidator)); - Assertions.assertEquals(jakarta.validation.groups.Default.class.getName(), + assertEquals(wrappingValidationGroups, _getValidationGroups(nestedinput)); + assertEquals(componentValidationGroups, _getValidationGroups(nestedinputWithValidator)); + assertEquals(jakarta.validation.groups.Default.class.getName(), _getValidationGroups(nonnestedinput)); } - + /** * Tests the case that there are two wrapping with different * validationGroups. @@ -468,7 +469,7 @@ public void testValidateBeanValidationGroupsNestingAndNested() throws IOExceptio */ @Test @SuppressWarnings("unchecked") - public void testValidateBeanValidationGroupsDoubleNesting() throws IOException + void validateBeanValidationGroupsDoubleNesting() throws Exception { final String validationGroupsOuter = "org.apache.myfaces.beanvalidation.OuterGroup"; final String validationGroupsInner = "org.apache.myfaces.beanvalidation.InnerGroup"; @@ -492,12 +493,12 @@ public void testValidateBeanValidationGroupsDoubleNesting() throws IOException // the nested component must get the outer wrapping validationGroups, // the double-nested component must get the inner wrapping validationGroups // and the non-nested component must get the Default validationGroups. - Assertions.assertEquals(validationGroupsOuter, _getValidationGroups(nestedinput)); - Assertions.assertEquals(validationGroupsInner, _getValidationGroups(doublenestedinput)); - Assertions.assertEquals(jakarta.validation.groups.Default.class.getName(), + assertEquals(validationGroupsOuter, _getValidationGroups(nestedinput)); + assertEquals(validationGroupsInner, _getValidationGroups(doublenestedinput)); + assertEquals(jakarta.validation.groups.Default.class.getName(), _getValidationGroups(nonnestedinput)); } - + /** * Tests the case that the BeanValidator is installed as a default-validator, * but bean validation is not available in the classpath. @@ -506,7 +507,7 @@ public void testValidateBeanValidationGroupsDoubleNesting() throws IOException * @throws IOException */ @Test - public void testValidateBeanWithBeanValidationNotAvailable() throws IOException + void validateBeanWithBeanValidationNotAvailable() throws Exception { // add the BeanValidator as default-validator application.addDefaultValidatorId(BeanValidator.VALIDATOR_ID); @@ -523,7 +524,7 @@ public void testValidateBeanWithBeanValidationNotAvailable() throws IOException // the UIInput must not have the BeanValidator installed, // because bean validation is not available - Assertions.assertFalse(_hasValidator(input, BeanValidator.class)); + assertFalse(_hasValidator(input, BeanValidator.class)); } /** @@ -532,7 +533,7 @@ public void testValidateBeanWithBeanValidationNotAvailable() throws IOException */ @Test @SuppressWarnings("unchecked") - public void testValidateBeanValidationDisabledDoubleNesting() throws IOException + void validateBeanValidationDisabledDoubleNesting() throws Exception { final String validationGroupsOuter = "org.apache.myfaces.beanvalidation.OuterGroup"; final String validationGroupsInner = "org.apache.myfaces.beanvalidation.InnerGroup"; @@ -557,10 +558,10 @@ public void testValidateBeanValidationDisabledDoubleNesting() throws IOException // the nested component must get the outer wrapping validationGroups, // the double-nested component must get the inner wrapping validationGroups // and the non-nested component must get the Default validationGroups. - Assertions.assertEquals(validationGroupsOuter, _getValidationGroups(nestedinput)); - Assertions.assertFalse(_hasValidator(doublenestedinput, BeanValidator.class)); - Assertions.assertEquals(validationGroupsInner, _getValidationGroups(nesteouterdisabledinput)); - Assertions.assertEquals(jakarta.validation.groups.Default.class.getName(), + assertEquals(validationGroupsOuter, _getValidationGroups(nestedinput)); + assertFalse(_hasValidator(doublenestedinput, BeanValidator.class)); + assertEquals(validationGroupsInner, _getValidationGroups(nesteouterdisabledinput)); + assertEquals(jakarta.validation.groups.Default.class.getName(), _getValidationGroups(nonnestedinput)); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/ViewMetadataTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/ViewMetadataTestCase.java index e5aa3e1bd8..de7044e9c7 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/ViewMetadataTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/ViewMetadataTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.tag.faces.core; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.StringWriter; import java.util.Collection; import java.util.HashMap; @@ -37,11 +39,10 @@ import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; import org.apache.myfaces.view.facelets.bean.HelloWorld; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class ViewMetadataTestCase extends AbstractFaceletTestCase +class ViewMetadataTestCase extends AbstractFaceletTestCase { protected NavigationHandler navigationHandler; @@ -107,9 +108,9 @@ public void tearDown() throws Exception super.tearDown(); navigationHandler = null; } - + @Test - public void testSimpleViewMetadata() throws Exception + void simpleViewMetadata() throws Exception { HelloWorld helloWorld = new HelloWorld(); @@ -128,7 +129,7 @@ public void testSimpleViewMetadata() throws Exception Collection viewParameters = metadata.getViewParameters(root); - Assertions.assertEquals(1, viewParameters.size()); + assertEquals(1, viewParameters.size()); //root.setViewId("viewMetadata.xhtml"); vdl.buildView(facesContext, root, "viewMetadata.xhtml"); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/reset/ResetValuesTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/reset/ResetValuesTestCase.java index a838281533..59f4f6c5f2 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/reset/ResetValuesTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/reset/ResetValuesTestCase.java @@ -18,9 +18,10 @@ */ package org.apache.myfaces.view.facelets.tag.faces.core.reset; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.faces.component.UIComponent; import jakarta.faces.component.UIInput; -import org.junit.jupiter.api.Assertions; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; import org.junit.jupiter.api.Test; @@ -28,7 +29,7 @@ * * @author lu4242 */ -public class ResetValuesTestCase extends AbstractMyFacesCDIRequestTestCase +class ResetValuesTestCase extends AbstractMyFacesCDIRequestTestCase { @Override protected void setUpWebConfigParams() throws Exception @@ -38,7 +39,7 @@ protected void setUpWebConfigParams() throws Exception } @Test - public void testResetValuesActionListenerHandler2() throws Exception + void resetValuesActionListenerHandler2() throws Exception { startViewRequest("/resetValuesActionListener_2.xhtml"); @@ -84,13 +85,13 @@ public void testResetValuesActionListenerHandler2() throws Exception UIInput field1_2 = (UIInput) facesContext.getViewRoot().findComponent("mainForm:field1"); UIInput field2_2 = (UIInput) facesContext.getViewRoot().findComponent("mainForm:field2"); - Assertions.assertEquals("Hello", field1_2.getValue()); - Assertions.assertEquals(1, field2_2.getValue()); - Assertions.assertNull(field1_2.getSubmittedValue()); - Assertions.assertNull(field2_2.getSubmittedValue()); + assertEquals("Hello", field1_2.getValue()); + assertEquals(1, field2_2.getValue()); + assertNull(field1_2.getSubmittedValue()); + assertNull(field2_2.getSubmittedValue()); - Assertions.assertEquals("Hello", bean.getField1()); - Assertions.assertEquals(Integer.valueOf(1), bean.getField2()); + assertEquals("Hello", bean.getField1()); + assertEquals(Integer.valueOf(1), bean.getField2()); //Now let's try the normal way with no resetValues client.inputText(field1_2, "xxx"); @@ -112,17 +113,17 @@ public void testResetValuesActionListenerHandler2() throws Exception // The values in the model are kept but the submitted values are there // and the renderer takes them. - Assertions.assertEquals("Hello", field1_3.getValue()); + assertEquals("Hello", field1_3.getValue()); // the second field doesn't have validation error!, but the local value // is set with 2, but the model still is 1 because update model phase // was not executed. - Assertions.assertEquals(2, field2_3.getValue()); - Assertions.assertTrue(field2_3.isLocalValueSet()); - Assertions.assertEquals("xxx", field1_3.getSubmittedValue()); - Assertions.assertNull(field2_3.getSubmittedValue()); + assertEquals(2, field2_3.getValue()); + assertTrue(field2_3.isLocalValueSet()); + assertEquals("xxx", field1_3.getSubmittedValue()); + assertNull(field2_3.getSubmittedValue()); - Assertions.assertEquals("Hello", bean.getField1()); - Assertions.assertEquals(Integer.valueOf(1), bean.getField2()); + assertEquals("Hello", bean.getField1()); + assertEquals(Integer.valueOf(1), bean.getField2()); // Now let's try a valid one, in this case the model is updated client.inputText(field1_3, "xxxx"); @@ -142,17 +143,17 @@ public void testResetValuesActionListenerHandler2() throws Exception UIInput field1_4 = (UIInput) facesContext.getViewRoot().findComponent("mainForm:field1"); UIInput field2_4 = (UIInput) facesContext.getViewRoot().findComponent("mainForm:field2"); - Assertions.assertEquals("xxxx", field1_4.getValue()); - Assertions.assertEquals(3, field2_4.getValue()); - Assertions.assertNull(field1_4.getSubmittedValue()); - Assertions.assertNull(field2_4.getSubmittedValue()); + assertEquals("xxxx", field1_4.getValue()); + assertEquals(3, field2_4.getValue()); + assertNull(field1_4.getSubmittedValue()); + assertNull(field2_4.getSubmittedValue()); - Assertions.assertEquals("xxxx", bean.getField1()); - Assertions.assertEquals(Integer.valueOf(3), bean.getField2()); + assertEquals("xxxx", bean.getField1()); + assertEquals(Integer.valueOf(3), bean.getField2()); } @Test - public void testResetValuesActionListenerHandler3() throws Exception + void resetValuesActionListenerHandler3() throws Exception { startViewRequest("/resetValuesActionListener_3.xhtml"); @@ -186,13 +187,13 @@ public void testResetValuesActionListenerHandler3() throws Exception field1 = (UIInput) facesContext.getViewRoot().findComponent("mainForm:field1"); field2 = (UIInput) facesContext.getViewRoot().findComponent("mainForm:field2"); - Assertions.assertEquals("Hello", field1.getValue()); - Assertions.assertEquals(1, field2.getValue()); + assertEquals("Hello", field1.getValue()); + assertEquals(1, field2.getValue()); } @Test - public void testResetValuesActionListenerHandler4() throws Exception + void resetValuesActionListenerHandler4() throws Exception { startViewRequest("/resetValuesActionListener_4.xhtml"); @@ -237,13 +238,13 @@ public void testResetValuesActionListenerHandler4() throws Exception UIInput field1_2 = (UIInput) facesContext.getViewRoot().findComponent("mainForm:field1"); UIInput field2_2 = (UIInput) facesContext.getViewRoot().findComponent("mainForm:field2"); - Assertions.assertEquals("Hello", field1_2.getValue()); - Assertions.assertEquals(1, field2_2.getValue()); - Assertions.assertNull(field1_2.getSubmittedValue()); - Assertions.assertNull(field2_2.getSubmittedValue()); + assertEquals("Hello", field1_2.getValue()); + assertEquals(1, field2_2.getValue()); + assertNull(field1_2.getSubmittedValue()); + assertNull(field2_2.getSubmittedValue()); - Assertions.assertEquals("Hello", bean.getField1()); - Assertions.assertEquals(Integer.valueOf(1), bean.getField2()); + assertEquals("Hello", bean.getField1()); + assertEquals(Integer.valueOf(1), bean.getField2()); //Now let's try the normal way with no resetValues client.inputText(field1_2, "xxx"); @@ -264,17 +265,17 @@ public void testResetValuesActionListenerHandler4() throws Exception // The values in the model are kept but the submitted values are there // and the renderer takes them. - Assertions.assertEquals("Hello", field1_3.getValue()); + assertEquals("Hello", field1_3.getValue()); // the second field doesn't have validation error!, but the local value // is set with 2, but the model still is 1 because update model phase // was not executed. - Assertions.assertEquals(2, field2_3.getValue()); - Assertions.assertTrue(field2_3.isLocalValueSet()); - Assertions.assertEquals("xxx", field1_3.getSubmittedValue()); - Assertions.assertNull(field2_3.getSubmittedValue()); + assertEquals(2, field2_3.getValue()); + assertTrue(field2_3.isLocalValueSet()); + assertEquals("xxx", field1_3.getSubmittedValue()); + assertNull(field2_3.getSubmittedValue()); - Assertions.assertEquals("Hello", bean.getField1()); - Assertions.assertEquals(Integer.valueOf(1), bean.getField2()); + assertEquals("Hello", bean.getField1()); + assertEquals(Integer.valueOf(1), bean.getField2()); // Now let's try a valid one, in this case the model is updated client.inputText(field1_3, "xxxx"); @@ -293,17 +294,17 @@ public void testResetValuesActionListenerHandler4() throws Exception UIInput field1_4 = (UIInput) facesContext.getViewRoot().findComponent("mainForm:field1"); UIInput field2_4 = (UIInput) facesContext.getViewRoot().findComponent("mainForm:field2"); - Assertions.assertEquals("xxxx", field1_4.getValue()); - Assertions.assertEquals(3, field2_4.getValue()); - Assertions.assertNull(field1_4.getSubmittedValue()); - Assertions.assertNull(field2_4.getSubmittedValue()); + assertEquals("xxxx", field1_4.getValue()); + assertEquals(3, field2_4.getValue()); + assertNull(field1_4.getSubmittedValue()); + assertNull(field2_4.getSubmittedValue()); - Assertions.assertEquals("xxxx", bean.getField1()); - Assertions.assertEquals(Integer.valueOf(3), bean.getField2()); + assertEquals("xxxx", bean.getField1()); + assertEquals(Integer.valueOf(3), bean.getField2()); } @Test - public void testResetValuesActionListenerHandler5() throws Exception + void resetValuesActionListenerHandler5() throws Exception { startViewRequest("/resetValuesActionListener_5.xhtml"); @@ -348,13 +349,13 @@ public void testResetValuesActionListenerHandler5() throws Exception UIInput field1_2 = (UIInput) facesContext.getViewRoot().findComponent("mainForm:field1"); UIInput field2_2 = (UIInput) facesContext.getViewRoot().findComponent("mainForm:field2"); - Assertions.assertEquals("Hello", field1_2.getValue()); - Assertions.assertEquals(1, field2_2.getValue()); - Assertions.assertNull(field1_2.getSubmittedValue()); - Assertions.assertNull(field2_2.getSubmittedValue()); + assertEquals("Hello", field1_2.getValue()); + assertEquals(1, field2_2.getValue()); + assertNull(field1_2.getSubmittedValue()); + assertNull(field2_2.getSubmittedValue()); - Assertions.assertEquals("Hello", bean.getField1()); - Assertions.assertEquals(Integer.valueOf(1), bean.getField2()); + assertEquals("Hello", bean.getField1()); + assertEquals(Integer.valueOf(1), bean.getField2()); //Now let's try the normal way with no resetValues client.inputText(field1_2, "xxx"); @@ -375,17 +376,17 @@ public void testResetValuesActionListenerHandler5() throws Exception // The values in the model are kept but the submitted values are there // and the renderer takes them. - Assertions.assertEquals("Hello", field1_3.getValue()); + assertEquals("Hello", field1_3.getValue()); // the second field doesn't have validation error!, but the local value // is set with 2, but the model still is 1 because update model phase // was not executed. - Assertions.assertEquals(2, field2_3.getValue()); - Assertions.assertTrue(field2_3.isLocalValueSet()); - Assertions.assertEquals("xxx", field1_3.getSubmittedValue()); - Assertions.assertNull(field2_3.getSubmittedValue()); + assertEquals(2, field2_3.getValue()); + assertTrue(field2_3.isLocalValueSet()); + assertEquals("xxx", field1_3.getSubmittedValue()); + assertNull(field2_3.getSubmittedValue()); - Assertions.assertEquals("Hello", bean.getField1()); - Assertions.assertEquals(Integer.valueOf(1), bean.getField2()); + assertEquals("Hello", bean.getField1()); + assertEquals(Integer.valueOf(1), bean.getField2()); // Now let's try a valid one, in this case the model is updated client.inputText(field1_3, "xxxx"); @@ -404,12 +405,12 @@ public void testResetValuesActionListenerHandler5() throws Exception UIInput field1_4 = (UIInput) facesContext.getViewRoot().findComponent("mainForm:field1"); UIInput field2_4 = (UIInput) facesContext.getViewRoot().findComponent("mainForm:field2"); - Assertions.assertEquals("xxxx", field1_4.getValue()); - Assertions.assertEquals(3, field2_4.getValue()); - Assertions.assertNull(field1_4.getSubmittedValue()); - Assertions.assertNull(field2_4.getSubmittedValue()); + assertEquals("xxxx", field1_4.getValue()); + assertEquals(3, field2_4.getValue()); + assertNull(field1_4.getSubmittedValue()); + assertNull(field2_4.getSubmittedValue()); - Assertions.assertEquals("xxxx", bean.getField1()); - Assertions.assertEquals(Integer.valueOf(3), bean.getField2()); + assertEquals("xxxx", bean.getField1()); + assertEquals(Integer.valueOf(3), bean.getField2()); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/validation/BeanValidationCDIRequestTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/validation/BeanValidationCDIRequestTestCase.java index a0cdbab3a2..becbc372a1 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/validation/BeanValidationCDIRequestTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/core/validation/BeanValidationCDIRequestTestCase.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.view.facelets.tag.faces.core.validation; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import jakarta.faces.application.StateManager; import jakarta.faces.component.UIInput; import jakarta.faces.validator.BeanValidator; @@ -25,14 +28,13 @@ import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * This test is the same as FlowMyFacesRequestTestCase with the difference that * in this case CDI is enabled and the other alternative is used. */ -public class BeanValidationCDIRequestTestCase extends AbstractMyFacesCDIRequestTestCase +class BeanValidationCDIRequestTestCase extends AbstractMyFacesCDIRequestTestCase { @Override protected void setUpWebConfigParams() throws Exception @@ -45,9 +47,9 @@ protected void setUpWebConfigParams() throws Exception servletContext.addInitParameter("jakarta.faces.CLIENT_WINDOW_MODE", "url"); servletContext.addInitParameter("org.apache.myfaces.validator.BEAN_BEFORE_JSF_VALIDATION", "true"); } - + @Test - public void testBeanValidation_1() throws Exception + void beanValidation1() throws Exception { startViewRequest("/testBeanValidation_1.xhtml"); @@ -60,13 +62,13 @@ public void testBeanValidation_1() throws Exception processLifecycleExecute(); UIInput username = (UIInput) facesContext.getViewRoot().findComponent("mainForm:username"); - Assertions.assertNotNull(username); + assertNotNull(username); Validator[] array = username.getValidators(); - Assertions.assertTrue(array[0] instanceof BeanValidator); + assertInstanceOf(BeanValidator.class, array[0]); } - + @Test - public void testBeanValidation_2() throws Exception + void beanValidation2() throws Exception { startViewRequest("/testBeanValidation_2.xhtml"); @@ -79,8 +81,8 @@ public void testBeanValidation_2() throws Exception processLifecycleExecute(); UIInput username = (UIInput) facesContext.getViewRoot().findComponent("mainForm:username"); - Assertions.assertNotNull(username); + assertNotNull(username); Validator[] array = username.getValidators(); - Assertions.assertTrue(array[0] instanceof BeanValidator); + assertInstanceOf(BeanValidator.class, array[0]); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/AdditionalHtmlEventsTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/AdditionalHtmlEventsTestCase.java index bc82588ea2..ee250c6e04 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/AdditionalHtmlEventsTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/AdditionalHtmlEventsTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.tag.faces.html; +import static org.junit.jupiter.api.Assertions.*; + import java.io.StringWriter; import jakarta.faces.component.UIComponent; @@ -32,14 +34,13 @@ import org.apache.myfaces.renderkit.html.HtmlTextRenderer; import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * Spec issue 1507, end to end: an on* attribute without a matching component property has to survive the facelet * tag handling and end up in the rendered markup, on its own as well as chained with an f:ajax on the same event. */ -public class AdditionalHtmlEventsTestCase extends AbstractFaceletTestCase +class AdditionalHtmlEventsTestCase extends AbstractFaceletTestCase { @Override @@ -65,7 +66,7 @@ protected void setupRenderers() throws Exception } @Test - public void testAdditionalHtmlEvents() throws Exception + void additionalHtmlEvents() throws Exception { externalContext.getRequestMap().put("inputScript", "doEl()"); @@ -74,30 +75,30 @@ public void testAdditionalHtmlEvents() throws Exception // a literal on* attribute without matching property String plain = encode(root, "plain"); - Assertions.assertTrue(plain.contains("oninput=\"doPlain()\""), plain); + assertTrue(plain.contains("oninput=\"doPlain()\""), plain); // the same, but bound to a ValueExpression String el = encode(root, "el"); - Assertions.assertTrue(el.contains("oninput=\"doEl()\""), el); + assertTrue(el.contains("oninput=\"doEl()\""), el); // on a component which has no oninput property - Assertions.assertEquals("[input]", + assertEquals("[input]", ((ClientBehaviorHolder) root.findComponent("ajax")).getClientBehaviors().keySet().toString()); String ajax = encode(root, "ajax"); - Assertions.assertTrue(ajax.contains("oninput=\""), ajax); - Assertions.assertTrue(ajax.contains("myfaces.ab("), ajax); + assertTrue(ajax.contains("oninput=\""), ajax); + assertTrue(ajax.contains("myfaces.ab("), ajax); // both of them on the same component must be chained String both = encode(root, "both"); - Assertions.assertTrue(both.contains("faces.util.chain("), both); - Assertions.assertTrue(both.contains("doBoth()"), both); - Assertions.assertTrue(both.contains("myfaces.ab("), both); + assertTrue(both.contains("faces.util.chain("), both); + assertTrue(both.contains("doBoth()"), both); + assertTrue(both.contains("myfaces.ab("), both); } private String encode(UIViewRoot root, String id) throws Exception { UIComponent component = root.findComponent(id); - Assertions.assertNotNull(component, "component " + id + " not found"); + assertNotNull(component, "component " + id + " not found"); StringWriter sw = new StringWriter(); facesContext.setResponseWriter(new MockResponseWriter(sw)); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/DataTableTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/DataTableTestCase.java index d9ed2e7da8..c2ceaa9033 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/DataTableTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/DataTableTestCase.java @@ -36,7 +36,7 @@ import org.apache.myfaces.util.lang.FastWriter; import org.junit.jupiter.api.Test; -public class DataTableTestCase extends AbstractFaceletTestCase +class DataTableTestCase extends AbstractFaceletTestCase { @Override @@ -71,7 +71,7 @@ protected void setupRenderers() throws Exception } @Test - public void testDataTable() throws Exception + void dataTable() throws Exception { facesContext.getExternalContext().getRequestMap().put("company", Example.createCompany()); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/DataTableTestCaseUrn.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/DataTableTestCaseUrn.java index 5d0c6545ba..e7d36f63fd 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/DataTableTestCaseUrn.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/DataTableTestCaseUrn.java @@ -36,7 +36,7 @@ import org.apache.myfaces.util.lang.FastWriter; import org.junit.jupiter.api.Test; -public class DataTableTestCaseUrn extends AbstractFaceletTestCase +class DataTableTestCaseUrn extends AbstractFaceletTestCase { @Override @@ -71,7 +71,7 @@ protected void setupRenderers() throws Exception } @Test - public void testDataTable() throws Exception + void dataTable() throws Exception { facesContext.getExternalContext().getRequestMap().put("company", Example.createCompany()); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/DefaultHtmlDecoratorTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/DefaultHtmlDecoratorTestCase.java index ca528599e2..b4ace9bfde 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/DefaultHtmlDecoratorTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/faces/html/DefaultHtmlDecoratorTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.tag.faces.html; +import static org.junit.jupiter.api.Assertions.*; + import java.io.StringWriter; import jakarta.faces.component.UIComponent; import jakarta.faces.component.UIForm; @@ -56,14 +58,13 @@ import org.apache.myfaces.view.facelets.tag.TagAttributeImpl; import org.apache.myfaces.view.facelets.tag.TagAttributesImpl; import org.apache.myfaces.view.facelets.tag.faces.JsfLibrary; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * * @author Leonardo Uribe */ -public class DefaultHtmlDecoratorTestCase extends AbstractFaceletTestCase +class DefaultHtmlDecoratorTestCase extends AbstractFaceletTestCase { @Override @@ -77,7 +78,7 @@ protected void setUpServletObjects() throws Exception } @Test - public void testHtmlPassthrough1() throws Exception + void htmlPassthrough1() throws Exception { request.getSession().setAttribute("test", new MockBean()); @@ -91,9 +92,9 @@ public void testHtmlPassthrough1() throws Exception //facesContext.setResponseWriter(mrw); //sw.flush(); } - + @Test - public void testHtmlPassthrough2() throws Exception + void htmlPassthrough2() throws Exception { request.getSession().setAttribute("test", new MockBean()); @@ -121,12 +122,12 @@ private void checkTags() throws Exception { if (ResourceUtils.DEFAULT_SCRIPT_RENDERER_TYPE.equals(child.getRendererType())) { - Assertions.assertEquals("osc", child.getId()); + assertEquals("osc", child.getId()); scriptsFound++; } if (ResourceUtils.DEFAULT_STYLESHEET_RENDERER_TYPE.equals(child.getRendererType())) { - Assertions.assertEquals("osh", child.getId()); + assertEquals("osh", child.getId()); linksFound++; } } @@ -135,123 +136,123 @@ private void checkTags() throws Exception { if ("jakarta.faces.resource.Stylesheet".equals(child.getRendererType())) { - Assertions.assertEquals("osh", child.getId()); + assertEquals("osh", child.getId()); linksFound++; } } - Assertions.assertEquals(1, linksFound); - Assertions.assertEquals(1, scriptsFound); + assertEquals(1, linksFound); + assertEquals(1, scriptsFound); HtmlBody body = (HtmlBody) root.findComponent("idBody"); - Assertions.assertNotNull(body); + assertNotNull(body); UIForm form = (UIForm) root.findComponent("myForm"); - Assertions.assertNotNull(form); + assertNotNull(form); HtmlCommandLink link1 = (HtmlCommandLink) form.findComponent("link1"); - Assertions.assertNotNull(link1); - Assertions.assertEquals("#{test.testAction}", link1.getActionExpression().getExpressionString()); + assertNotNull(link1); + assertEquals("#{test.testAction}", link1.getActionExpression().getExpressionString()); HtmlCommandLink link2 = (HtmlCommandLink) form.findComponent("link2"); - Assertions.assertNotNull(link2); - Assertions.assertEquals(1, link2.getActionListeners().length); + assertNotNull(link2); + assertEquals(1, link2.getActionListeners().length); HtmlOutputLink link3 = (HtmlOutputLink) form.findComponent("link3"); - Assertions.assertNotNull(link3); - Assertions.assertEquals("/my/new/location.txt", link3.getValue()); + assertNotNull(link3); + assertEquals("/my/new/location.txt", link3.getValue()); HtmlOutcomeTargetLink link4 = (HtmlOutcomeTargetLink) form.findComponent("link4"); - Assertions.assertNotNull(link4); - Assertions.assertEquals("rollback", link4.getOutcome()); + assertNotNull(link4); + assertEquals("rollback", link4.getOutcome()); HtmlCommandButton button = (HtmlCommandButton) form.findComponent("button1"); - Assertions.assertNotNull(button); - Assertions.assertEquals("#{test.testAction}", button.getActionExpression().getExpressionString()); + assertNotNull(button); + assertEquals("#{test.testAction}", button.getActionExpression().getExpressionString()); HtmlOutcomeTargetButton button2 = (HtmlOutcomeTargetButton) form.findComponent("button2"); - Assertions.assertNotNull(button2); - Assertions.assertEquals("rollback", button2.getOutcome()); + assertNotNull(button2); + assertEquals("rollback", button2.getOutcome()); HtmlGraphicImage img1 = (HtmlGraphicImage) form.findComponent("img1"); - Assertions.assertNotNull(img1); - Assertions.assertEquals("/my/image.png", img1.getUrl()); + assertNotNull(img1); + assertEquals("/my/image.png", img1.getUrl()); HtmlCommandButton input1 = (HtmlCommandButton) form.findComponent("input1"); - Assertions.assertNotNull(input1); + assertNotNull(input1); HtmlSelectBooleanCheckbox input2 = (HtmlSelectBooleanCheckbox) form.findComponent("input2"); - Assertions.assertNotNull(input2); + assertNotNull(input2); HtmlInputText input3 = (HtmlInputText) form.findComponent("input3"); - Assertions.assertNotNull(input3); + assertNotNull(input3); HtmlInputText input4 = (HtmlInputText) form.findComponent("input4"); - Assertions.assertNotNull(input4); + assertNotNull(input4); HtmlInputText input5 = (HtmlInputText) form.findComponent("input5"); - Assertions.assertNotNull(input5); + assertNotNull(input5); HtmlInputText input6 = (HtmlInputText) form.findComponent("input6"); - Assertions.assertNotNull(input6); + assertNotNull(input6); HtmlInputText input7 = (HtmlInputText) form.findComponent("input7"); - Assertions.assertNotNull(input7); + assertNotNull(input7); HtmlInputText input8 = (HtmlInputText) form.findComponent("input8"); - Assertions.assertNotNull(input8); + assertNotNull(input8); HtmlInputText input9 = (HtmlInputText) form.findComponent("input9"); - Assertions.assertNotNull(input9); + assertNotNull(input9); HtmlInputText input10 = (HtmlInputText) form.findComponent("input10"); - Assertions.assertNotNull(input10); + assertNotNull(input10); HtmlInputText input11 = (HtmlInputText) form.findComponent("input11"); - Assertions.assertNotNull(input11); + assertNotNull(input11); HtmlInputText input12 = (HtmlInputText) form.findComponent("input12"); - Assertions.assertNotNull(input12); + assertNotNull(input12); HtmlInputText input13 = (HtmlInputText) form.findComponent("input13"); - Assertions.assertNotNull(input13); + assertNotNull(input13); HtmlInputText input14 = (HtmlInputText) form.findComponent("input14"); - Assertions.assertNotNull(input14); + assertNotNull(input14); HtmlInputFile input15 = (HtmlInputFile) form.findComponent("input15"); - Assertions.assertNotNull(input15); + assertNotNull(input15); HtmlInputHidden input16 = (HtmlInputHidden) form.findComponent("input16"); - Assertions.assertNotNull(input16); + assertNotNull(input16); HtmlInputSecret input17 = (HtmlInputSecret) form.findComponent("input17"); - Assertions.assertNotNull(input17); + assertNotNull(input17); HtmlCommandButton input18 = (HtmlCommandButton) form.findComponent("input18"); - Assertions.assertNotNull(input18); + assertNotNull(input18); HtmlCommandButton input19 = (HtmlCommandButton) form.findComponent("input19"); - Assertions.assertNotNull(input19); + assertNotNull(input19); HtmlInputText input20 = (HtmlInputText) form.findComponent("input20"); - Assertions.assertNotNull(input20); + assertNotNull(input20); HtmlOutputLabel label1 = (HtmlOutputLabel) form.findComponent("label1"); - Assertions.assertNotNull(label1); + assertNotNull(label1); HtmlSelectOneListbox select1 = (HtmlSelectOneListbox) form.findComponent("select1"); - Assertions.assertNotNull(select1); + assertNotNull(select1); HtmlSelectManyListbox select2 = (HtmlSelectManyListbox) form.findComponent("select2"); - Assertions.assertNotNull(select2); + assertNotNull(select2); HtmlInputTextarea textarea1 = (HtmlInputTextarea) form.findComponent("textarea1"); - Assertions.assertNotNull(textarea1); + assertNotNull(textarea1); } @Test - public void testDefaultTagDecorator1() throws Exception + void defaultTagDecorator1() throws Exception { Location location = new Location("/test.xhtml", 20, 5); Tag tag = new Tag(location, DefaultTagDecorator.XHTML_NAMESPACE, "body", "body", @@ -264,11 +265,11 @@ public void testDefaultTagDecorator1() throws Exception TagDecorator tagDecorator = new DefaultTagDecorator(); Tag decoratedTag = tagDecorator.decorate(tag); - Assertions.assertNotNull(decoratedTag); + assertNotNull(decoratedTag); } - + @Test - public void testDefaultTagDecorator2() throws Exception + void defaultTagDecorator2() throws Exception { Location location = new Location("/test.xhtml", 20, 5); Tag tag = new Tag(location, DefaultTagDecorator.XHTML_NAMESPACE, "a", "a", @@ -281,11 +282,11 @@ public void testDefaultTagDecorator2() throws Exception TagDecorator tagDecorator = new DefaultTagDecorator(); Tag decoratedTag = tagDecorator.decorate(tag); - Assertions.assertNotNull(decoratedTag); + assertNotNull(decoratedTag); } - + @Test - public void testDefaultTagDecorator3() throws Exception + void defaultTagDecorator3() throws Exception { Location location = new Location("/test.xhtml", 20, 5); Tag tag = new Tag(location, DefaultTagDecorator.XHTML_NAMESPACE, "body", "body", @@ -298,11 +299,11 @@ public void testDefaultTagDecorator3() throws Exception TagDecorator tagDecorator = new DefaultTagDecorator(); Tag decoratedTag = tagDecorator.decorate(tag); - Assertions.assertNotNull(decoratedTag); + assertNotNull(decoratedTag); } - + @Test - public void testDefaultTagDecorator4() throws Exception + void defaultTagDecorator4() throws Exception { Location location = new Location("/test.xhtml", 20, 5); Tag tag = new Tag(location, DefaultTagDecorator.XHTML_NAMESPACE, "a", "a", @@ -315,11 +316,11 @@ public void testDefaultTagDecorator4() throws Exception TagDecorator tagDecorator = new DefaultTagDecorator(); Tag decoratedTag = tagDecorator.decorate(tag); - Assertions.assertNotNull(decoratedTag); + assertNotNull(decoratedTag); } - + @Test - public void testNoMatchJSFElement1() throws Exception + void noMatchJSFElement1() throws Exception { request.getSession().setAttribute("test", new MockBean()); @@ -327,17 +328,17 @@ public void testNoMatchJSFElement1() throws Exception vdl.buildView(facesContext, root, "testNoMatchJSFElement1.xhtml"); UIComponent box1 = root.findComponent("myForm:box1"); - Assertions.assertNotNull(box1); - Assertions.assertEquals(box1.getRendererType(), "jakarta.faces.passthrough.Element"); + assertNotNull(box1); + assertEquals("jakarta.faces.passthrough.Element", box1.getRendererType()); //StringWriter sw = new StringWriter(); //MockResponseWriter mrw = new MockResponseWriter(sw); //facesContext.setResponseWriter(mrw); //sw.flush(); - } - + } + @Test - public void testConvertTagAttributes1() throws Exception + void convertTagAttributes1() throws Exception { request.getSession().setAttribute("test", new MockBean()); @@ -350,25 +351,25 @@ public void testConvertTagAttributes1() throws Exception // placeholder="Enter text" // pt:data_up="Going Up"/> UIInput input1 = (UIInput) root.findComponent("myForm:box1"); - Assertions.assertNotNull(input1); - - Assertions.assertEquals(input1.getPassThroughAttributes().get("placeholder"), "Enter text"); - Assertions.assertNull(input1.getAttributes().get("placeholder")); - - - Assertions.assertEquals(input1.getAttributes().get("customAttr"), "SomeValue"); + assertNotNull(input1); + + assertEquals("Enter text", input1.getPassThroughAttributes().get("placeholder")); + assertNull(input1.getAttributes().get("placeholder")); + + + assertEquals("SomeValue", input1.getAttributes().get("customAttr")); // Attributes outside "id", "binding", "rendered" or "transient" can be // copied on passthrough attribute map. - Assertions.assertNull(input1.getPassThroughAttributes().get("customAttr")); - - Assertions.assertEquals(input1.getPassThroughAttributes().get("data_up"), "Going Up"); - Assertions.assertNull(input1.getAttributes().get("data_up")); + assertNull(input1.getPassThroughAttributes().get("customAttr")); + + assertEquals("Going Up", input1.getPassThroughAttributes().get("data_up")); + assertNull(input1.getAttributes().get("data_up")); - Assertions.assertNotNull(input1.getValueExpression("value")); + assertNotNull(input1.getValueExpression("value")); //Assertions.assertNotNull(input1.getPassThroughAttributes().get("value")); - Assertions.assertNull(input1.getPassThroughAttributes().get("value")); - Assertions.assertEquals(input1.getValue(), "value1"); - Assertions.assertEquals(input1.getAttributes().get("value"), "value1"); + assertNull(input1.getPassThroughAttributes().get("value")); + assertEquals("value1", input1.getValue()); + assertEquals("value1", input1.getAttributes().get("value")); //Hello World! UIComponent input2 = root.findComponent("myForm:box2"); - Assertions.assertFalse(input2 instanceof UIInput); - Assertions.assertEquals(input2.getRendererType(), "jakarta.faces.passthrough.Element"); - - Assertions.assertEquals(input2.getPassThroughAttributes().get("placeholder"), "Enter text"); + assertFalse(input2 instanceof UIInput); + assertEquals("jakarta.faces.passthrough.Element", input2.getRendererType()); + + assertEquals("Enter text", input2.getPassThroughAttributes().get("placeholder")); //Assertions.assertEquals(input2.getAttributes().get("placeholder"), "Enter text"); - Assertions.assertNull(input2.getAttributes().get("placeholder")); - - Assertions.assertEquals(input2.getAttributes().get("customAttr"), "SomeValue"); + assertNull(input2.getAttributes().get("placeholder")); + + assertEquals("SomeValue", input2.getAttributes().get("customAttr")); //Assertions.assertNull(input2.getAttributes().get("customAttr")); //Assertions.assertEquals(input2.getPassThroughAttributes().get("customAttr"), "SomeValue"); - Assertions.assertNull(input2.getPassThroughAttributes().get("customAttr")); - - Assertions.assertEquals(input2.getPassThroughAttributes().get("data_up"), "Going Up"); - Assertions.assertNull(input2.getAttributes().get("data_up")); + assertNull(input2.getPassThroughAttributes().get("customAttr")); + + assertEquals("Going Up", input2.getPassThroughAttributes().get("data_up")); + assertNull(input2.getAttributes().get("data_up")); // note there is no type attribute, so it is translated into a jsf:element, and in that // component, "value" is not defined, so it is set as passthrough - Assertions.assertNotNull(input2.getValueExpression("value")); - Assertions.assertNull(input2.getPassThroughAttributes().get("value")); - Assertions.assertNotNull(input2.getAttributes().get("value")); + assertNotNull(input2.getValueExpression("value")); + assertNull(input2.getPassThroughAttributes().get("value")); + assertNotNull(input2.getAttributes().get("value")); // UIComponent input3 = root.findComponent("myForm:box3"); - Assertions.assertFalse(input3 instanceof UIInput); - Assertions.assertEquals(input3.getRendererType(), "jakarta.faces.passthrough.Element"); + assertFalse(input3 instanceof UIInput); + assertEquals("jakarta.faces.passthrough.Element", input3.getRendererType()); - Assertions.assertEquals(input3.getAttributes().get("placeholder"), "Enter text"); - Assertions.assertNull(input3.getPassThroughAttributes().get("placeholder")); - - Assertions.assertNull(input3.getPassThroughAttributes().get("customAttr")); - Assertions.assertEquals(input3.getAttributes().get("customAttr"), "SomeValue"); + assertEquals("Enter text", input3.getAttributes().get("placeholder")); + assertNull(input3.getPassThroughAttributes().get("placeholder")); - Assertions.assertEquals(input3.getPassThroughAttributes().get("data_up"), "Going Up"); - Assertions.assertNull(input3.getAttributes().get("data_up")); + assertNull(input3.getPassThroughAttributes().get("customAttr")); + assertEquals("SomeValue", input3.getAttributes().get("customAttr")); + + assertEquals("Going Up", input3.getPassThroughAttributes().get("data_up")); + assertNull(input3.getAttributes().get("data_up")); - Assertions.assertNotNull(input3.getValueExpression("value")); - Assertions.assertNull(input3.getPassThroughAttributes().get("value")); - Assertions.assertNotNull(input3.getAttributes().get("value")); + assertNotNull(input3.getValueExpression("value")); + assertNull(input3.getPassThroughAttributes().get("value")); + assertNotNull(input3.getAttributes().get("value")); //Assertions.assertEquals(input2.getPassThroughAttributes().get("elementName"), "meter"); @@ -429,12 +430,12 @@ public void testConvertTagAttributes1() throws Exception // // UIComponent box4 = root.findComponent("myForm:box4"); - Assertions.assertNotNull(box4); + assertNotNull(box4); UIComponent boxDiv4 = box4.getChildren().get(0); - Assertions.assertNotNull(boxDiv4); - Assertions.assertEquals(boxDiv4.getAttributes().get("styleClass"), "noprint"); + assertNotNull(boxDiv4); + assertEquals("noprint", boxDiv4.getAttributes().get("styleClass")); //Assertions.assertEquals(boxDiv4.getPassThroughAttributes().get("class"), "noprint"); - Assertions.assertNull(boxDiv4.getPassThroughAttributes().get("class")); + assertNull(boxDiv4.getPassThroughAttributes().get("class")); // //
@@ -442,12 +443,12 @@ public void testConvertTagAttributes1() throws Exception //
//
UIComponent box5 = root.findComponent("myForm:box5"); - Assertions.assertNotNull(box5); + assertNotNull(box5); UIComponent boxDiv5 = box5.getChildren().get(0); - Assertions.assertNotNull(boxDiv5); - Assertions.assertNotNull(boxDiv5.getAttributes().get("style")); + assertNotNull(boxDiv5); + assertNotNull(boxDiv5.getAttributes().get("style")); //Assertions.assertEquals(boxDiv5.getPassThroughAttributes().get("style"), "noprint"); - Assertions.assertNull(boxDiv5.getPassThroughAttributes().get("style")); + assertNull(boxDiv5.getPassThroughAttributes().get("style")); StringWriter sw = new StringWriter(); @@ -469,7 +470,7 @@ public void testConvertTagAttributes1() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); } sw = new StringWriter(); @@ -490,10 +491,10 @@ public void testConvertTagAttributes1() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); } - Assertions.assertTrue(sw.toString().contains("")); + assertTrue(sw.toString().contains("")); sw = new StringWriter(); mrw = new HtmlResponseWriterImpl(sw, "text/html", "UTF-8"); @@ -514,10 +515,10 @@ public void testConvertTagAttributes1() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); } - Assertions.assertTrue(sw.toString().contains("")); + assertTrue(sw.toString().contains("")); // TEST 4 sw = new StringWriter(); @@ -535,11 +536,11 @@ public void testConvertTagAttributes1() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); } - Assertions.assertTrue(sw.toString().contains("MYBOX4")); - Assertions.assertTrue(sw.toString().contains("
")); + assertTrue(sw.toString().contains("MYBOX4")); + assertTrue(sw.toString().contains("
")); // TEST 5 sw = new StringWriter(); @@ -557,15 +558,15 @@ public void testConvertTagAttributes1() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); } - Assertions.assertTrue(sw.toString().contains("MYBOX5")); - Assertions.assertTrue(sw.toString().contains("
")); - } - + assertTrue(sw.toString().contains("MYBOX5")); + assertTrue(sw.toString().contains("
")); + } + @Test - public void testConvertTagAttributes6() throws Exception + void convertTagAttributes6() throws Exception { request.getSession().setAttribute("test", new MockBean()); @@ -578,8 +579,8 @@ public void testConvertTagAttributes6() throws Exception //
// Try second time, to avoid the script section by f:ajax effect UIComponent box6 = root.findComponent("myForm:box6"); - Assertions.assertNotNull(box6); - Assertions.assertEquals(box6.getAttributes().get("onclick"), "alert('hello')"); + assertNotNull(box6); + assertEquals("alert('hello')", box6.getAttributes().get("onclick")); StringWriter sw = new StringWriter(); ResponseWriter mrw = new HtmlResponseWriterImpl(sw, "text/html", "UTF-8"); @@ -597,15 +598,15 @@ public void testConvertTagAttributes6() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); } - Assertions.assertTrue(sw.toString().contains("MYBOX6")); - Assertions.assertTrue(sw.toString().contains("
")); - } - + assertTrue(sw.toString().contains("MYBOX6")); + assertTrue(sw.toString().contains("
")); + } + @Test - public void testConvertTagAttributes7() throws Exception + void convertTagAttributes7() throws Exception { request.getSession().setAttribute("test", new MockBean()); @@ -617,9 +618,9 @@ public void testConvertTagAttributes7() throws Exception // UIComponent box7 = root.findComponent("myForm:box7"); - Assertions.assertNotNull(box7); + assertNotNull(box7); UIComponent boxDiv7 = box7.getChildren().get(0); - Assertions.assertNotNull(boxDiv7); + assertNotNull(boxDiv7); StringWriter sw = new StringWriter(); @@ -636,9 +637,9 @@ public void testConvertTagAttributes7() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); } - Assertions.assertTrue(sw.toString().contains(" UIInput input1 = (UIInput) root.findComponent("myForm:box1"); - Assertions.assertNotNull(input1); - - Assertions.assertEquals(input1.getPassThroughAttributes().get("placeholder"), "Enter text"); - Assertions.assertNull(input1.getAttributes().get("placeholder")); - - - Assertions.assertEquals(input1.getAttributes().get("customAttr"), "SomeValue"); + assertNotNull(input1); + + assertEquals("Enter text", input1.getPassThroughAttributes().get("placeholder")); + assertNull(input1.getAttributes().get("placeholder")); + + + assertEquals("SomeValue", input1.getAttributes().get("customAttr")); // Attributes outside "id", "binding", "rendered" or "transient" can be // copied on passthrough attribute map. - Assertions.assertNull(input1.getPassThroughAttributes().get("customAttr")); - - Assertions.assertEquals(input1.getPassThroughAttributes().get("data_up"), "Going Up"); - Assertions.assertNull(input1.getAttributes().get("data_up")); + assertNull(input1.getPassThroughAttributes().get("customAttr")); + + assertEquals("Going Up", input1.getPassThroughAttributes().get("data_up")); + assertNull(input1.getAttributes().get("data_up")); - Assertions.assertNotNull(input1.getValueExpression("value")); + assertNotNull(input1.getValueExpression("value")); //Assertions.assertNotNull(input1.getPassThroughAttributes().get("value")); - Assertions.assertNull(input1.getPassThroughAttributes().get("value")); - Assertions.assertEquals(input1.getValue(), "value1"); - Assertions.assertEquals(input1.getAttributes().get("value"), "value1"); + assertNull(input1.getPassThroughAttributes().get("value")); + assertEquals("value1", input1.getValue()); + assertEquals("value1", input1.getAttributes().get("value")); //Hello World! UIComponent input2 = root.findComponent("myForm:box2"); - Assertions.assertFalse(input2 instanceof UIInput); - Assertions.assertEquals(input2.getRendererType(), "jakarta.faces.passthrough.Element"); - - Assertions.assertEquals(input2.getPassThroughAttributes().get("placeholder"), "Enter text"); + assertFalse(input2 instanceof UIInput); + assertEquals("jakarta.faces.passthrough.Element", input2.getRendererType()); + + assertEquals("Enter text", input2.getPassThroughAttributes().get("placeholder")); //Assertions.assertEquals(input2.getAttributes().get("placeholder"), "Enter text"); - Assertions.assertNull(input2.getAttributes().get("placeholder")); - - Assertions.assertEquals(input2.getAttributes().get("customAttr"), "SomeValue"); + assertNull(input2.getAttributes().get("placeholder")); + + assertEquals("SomeValue", input2.getAttributes().get("customAttr")); //Assertions.assertNull(input2.getAttributes().get("customAttr")); //Assertions.assertEquals(input2.getPassThroughAttributes().get("customAttr"), "SomeValue"); - Assertions.assertNull(input2.getPassThroughAttributes().get("customAttr")); - - Assertions.assertEquals(input2.getPassThroughAttributes().get("data_up"), "Going Up"); - Assertions.assertNull(input2.getAttributes().get("data_up")); + assertNull(input2.getPassThroughAttributes().get("customAttr")); + + assertEquals("Going Up", input2.getPassThroughAttributes().get("data_up")); + assertNull(input2.getAttributes().get("data_up")); // note there is no type attribute, so it is translated into a jsf:element, and in that // component, "value" is not defined, so it is set as passthrough - Assertions.assertNotNull(input2.getValueExpression("value")); - Assertions.assertNull(input2.getPassThroughAttributes().get("value")); - Assertions.assertNotNull(input2.getAttributes().get("value")); + assertNotNull(input2.getValueExpression("value")); + assertNull(input2.getPassThroughAttributes().get("value")); + assertNotNull(input2.getAttributes().get("value")); // UIComponent input3 = root.findComponent("myForm:box3"); - Assertions.assertFalse(input3 instanceof UIInput); - Assertions.assertEquals(input3.getRendererType(), "jakarta.faces.passthrough.Element"); + assertFalse(input3 instanceof UIInput); + assertEquals("jakarta.faces.passthrough.Element", input3.getRendererType()); - Assertions.assertEquals(input3.getAttributes().get("placeholder"), "Enter text"); - Assertions.assertNull(input3.getPassThroughAttributes().get("placeholder")); - - Assertions.assertNull(input3.getPassThroughAttributes().get("customAttr")); - Assertions.assertEquals(input3.getAttributes().get("customAttr"), "SomeValue"); + assertEquals("Enter text", input3.getAttributes().get("placeholder")); + assertNull(input3.getPassThroughAttributes().get("placeholder")); - Assertions.assertEquals(input3.getPassThroughAttributes().get("data_up"), "Going Up"); - Assertions.assertNull(input3.getAttributes().get("data_up")); + assertNull(input3.getPassThroughAttributes().get("customAttr")); + assertEquals("SomeValue", input3.getAttributes().get("customAttr")); + + assertEquals("Going Up", input3.getPassThroughAttributes().get("data_up")); + assertNull(input3.getAttributes().get("data_up")); - Assertions.assertNotNull(input3.getValueExpression("value")); - Assertions.assertNull(input3.getPassThroughAttributes().get("value")); - Assertions.assertNotNull(input3.getAttributes().get("value")); + assertNotNull(input3.getValueExpression("value")); + assertNull(input3.getPassThroughAttributes().get("value")); + assertNotNull(input3.getAttributes().get("value")); //Assertions.assertEquals(input2.getPassThroughAttributes().get("elementName"), "meter"); @@ -429,12 +430,12 @@ public void testConvertTagAttributes1() throws Exception //
// UIComponent box4 = root.findComponent("myForm:box4"); - Assertions.assertNotNull(box4); + assertNotNull(box4); UIComponent boxDiv4 = box4.getChildren().get(0); - Assertions.assertNotNull(boxDiv4); - Assertions.assertEquals(boxDiv4.getAttributes().get("styleClass"), "noprint"); + assertNotNull(boxDiv4); + assertEquals("noprint", boxDiv4.getAttributes().get("styleClass")); //Assertions.assertEquals(boxDiv4.getPassThroughAttributes().get("class"), "noprint"); - Assertions.assertNull(boxDiv4.getPassThroughAttributes().get("class")); + assertNull(boxDiv4.getPassThroughAttributes().get("class")); // //
@@ -442,12 +443,12 @@ public void testConvertTagAttributes1() throws Exception //
//
UIComponent box5 = root.findComponent("myForm:box5"); - Assertions.assertNotNull(box5); + assertNotNull(box5); UIComponent boxDiv5 = box5.getChildren().get(0); - Assertions.assertNotNull(boxDiv5); - Assertions.assertNotNull(boxDiv5.getAttributes().get("style")); + assertNotNull(boxDiv5); + assertNotNull(boxDiv5.getAttributes().get("style")); //Assertions.assertEquals(boxDiv5.getPassThroughAttributes().get("style"), "noprint"); - Assertions.assertNull(boxDiv5.getPassThroughAttributes().get("style")); + assertNull(boxDiv5.getPassThroughAttributes().get("style")); StringWriter sw = new StringWriter(); @@ -469,7 +470,7 @@ public void testConvertTagAttributes1() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); } sw = new StringWriter(); @@ -490,10 +491,10 @@ public void testConvertTagAttributes1() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); } - Assertions.assertTrue(sw.toString().contains("")); + assertTrue(sw.toString().contains("")); sw = new StringWriter(); mrw = new HtmlResponseWriterImpl(sw, "text/html", "UTF-8"); @@ -514,10 +515,10 @@ public void testConvertTagAttributes1() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); } - Assertions.assertTrue(sw.toString().contains("")); + assertTrue(sw.toString().contains("")); // TEST 4 sw = new StringWriter(); @@ -535,11 +536,11 @@ public void testConvertTagAttributes1() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); } - Assertions.assertTrue(sw.toString().contains("MYBOX4")); - Assertions.assertTrue(sw.toString().contains("
")); + assertTrue(sw.toString().contains("MYBOX4")); + assertTrue(sw.toString().contains("
")); // TEST 5 sw = new StringWriter(); @@ -557,15 +558,15 @@ public void testConvertTagAttributes1() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); } - Assertions.assertTrue(sw.toString().contains("MYBOX5")); - Assertions.assertTrue(sw.toString().contains("
")); - } - + assertTrue(sw.toString().contains("MYBOX5")); + assertTrue(sw.toString().contains("
")); + } + @Test - public void testConvertTagAttributes6() throws Exception + void convertTagAttributes6() throws Exception { request.getSession().setAttribute("test", new MockBean()); @@ -578,8 +579,8 @@ public void testConvertTagAttributes6() throws Exception //
// Try second time, to avoid the script section by f:ajax effect UIComponent box6 = root.findComponent("myForm:box6"); - Assertions.assertNotNull(box6); - Assertions.assertEquals(box6.getAttributes().get("onclick"), "alert('hello')"); + assertNotNull(box6); + assertEquals("alert('hello')", box6.getAttributes().get("onclick")); StringWriter sw = new StringWriter(); ResponseWriter mrw = new HtmlResponseWriterImpl(sw, "text/html", "UTF-8"); @@ -597,15 +598,15 @@ public void testConvertTagAttributes6() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); } - Assertions.assertTrue(sw.toString().contains("MYBOX6")); - Assertions.assertTrue(sw.toString().contains("
")); - } - + assertTrue(sw.toString().contains("MYBOX6")); + assertTrue(sw.toString().contains("
")); + } + @Test - public void testConvertTagAttributes7() throws Exception + void convertTagAttributes7() throws Exception { request.getSession().setAttribute("test", new MockBean()); @@ -617,9 +618,9 @@ public void testConvertTagAttributes7() throws Exception // UIComponent box7 = root.findComponent("myForm:box7"); - Assertions.assertNotNull(box7); + assertNotNull(box7); UIComponent boxDiv7 = box7.getChildren().get(0); - Assertions.assertNotNull(boxDiv7); + assertNotNull(boxDiv7); StringWriter sw = new StringWriter(); @@ -636,9 +637,9 @@ public void testConvertTagAttributes7() throws Exception HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString()); if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) { - Assertions.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); + fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString())); } - Assertions.assertTrue(sw.toString().contains("Component value: page test2

")); - Assertions.assertTrue(result.contains("

Inline EL value: page test2

")); + assertTrue(result.contains("

Component value: page test2

")); + assertTrue(result.contains("

Inline EL value: page test2

")); //System.out.println(fw); @@ -145,13 +147,13 @@ public void testCaching() throws Exception result = fw.toString(); - Assertions.assertTrue(result.contains("

Component value: page test3

")); - Assertions.assertTrue(result.contains("

Inline EL value: page test3

")); + assertTrue(result.contains("

Component value: page test3

")); + assertTrue(result.contains("

Inline EL value: page test3

")); } - + @Test - public void testSimpleCompositionParam() throws Exception + void simpleCompositionParam() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "simpleCompositionParam.xhtml"); @@ -164,7 +166,7 @@ public void testSimpleCompositionParam() throws Exception rw.flush(); String result = fw.toString(); - Assertions.assertTrue(result.contains("value1")); + assertTrue(result.contains("value1")); } /** @@ -174,7 +176,7 @@ public void testSimpleCompositionParam() throws Exception * @throws Exception */ @Test - public void testUIParamTemplateScope1() throws Exception + void uIParamTemplateScope1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "uiparamtemplatescope1.xhtml"); @@ -187,10 +189,10 @@ public void testUIParamTemplateScope1() throws Exception rw.flush(); String result = fw.toString(); - Assertions.assertTrue(result.contains("rightValue")); - Assertions.assertFalse(result.contains("doNotPrintValue")); + assertTrue(result.contains("rightValue")); + assertFalse(result.contains("doNotPrintValue")); } - + /** * ui:param defined outside should not pass through ui:include, because it occurs * on another template context. @@ -198,7 +200,7 @@ public void testUIParamTemplateScope1() throws Exception * @throws Exception */ @Test - public void testUIParamTemplateScope2() throws Exception + void uIParamTemplateScope2() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "uiparamtemplatescope2.xhtml"); @@ -211,9 +213,9 @@ public void testUIParamTemplateScope2() throws Exception rw.flush(); String result = fw.toString(); - Assertions.assertFalse(result.contains("doNotPrintValue")); + assertFalse(result.contains("doNotPrintValue")); } - + /** * ui:param inside ui:include applies only to the content of the tag and the * referenced template. @@ -221,7 +223,7 @@ public void testUIParamTemplateScope2() throws Exception * @throws Exception */ @Test - public void testUIParamTemplateScope3() throws Exception + void uIParamTemplateScope3() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "uiparamtemplatescope3.xhtml"); @@ -234,10 +236,10 @@ public void testUIParamTemplateScope3() throws Exception rw.flush(); String result = fw.toString(); - Assertions.assertTrue(result.contains("rightValue")); - Assertions.assertFalse(result.contains("doNotPrintValue")); + assertTrue(result.contains("rightValue")); + assertFalse(result.contains("doNotPrintValue")); } - + /** * ui:param inside ui:composition applies only to the content of the tag and the * referenced template. @@ -245,7 +247,7 @@ public void testUIParamTemplateScope3() throws Exception * @throws Exception */ @Test - public void testUIParamTemplateScope4() throws Exception + void uIParamTemplateScope4() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "uiparamtemplatescope4.xhtml"); @@ -258,17 +260,17 @@ public void testUIParamTemplateScope4() throws Exception rw.flush(); String result = fw.toString(); - Assertions.assertTrue(result.contains("rightValue")); - Assertions.assertFalse(result.contains("doNotPrintValue")); + assertTrue(result.contains("rightValue")); + assertFalse(result.contains("doNotPrintValue")); } - + /** * ui:param defined outside should only pass through ui:include if the param is declared. * * @throws Exception */ @Test - public void testUIParamTemplateScope5() throws Exception + void uIParamTemplateScope5() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "uiparamtemplatescope5.xhtml"); @@ -281,11 +283,11 @@ public void testUIParamTemplateScope5() throws Exception rw.flush(); String result = fw.toString(); - Assertions.assertTrue(result.contains("rightValue")); - Assertions.assertTrue(result.contains("right2Value")); - Assertions.assertFalse(result.contains("doNotPrintValue")); + assertTrue(result.contains("rightValue")); + assertTrue(result.contains("right2Value")); + assertFalse(result.contains("doNotPrintValue")); } - + /** * ui:param defined outside should not pass through composite components, to do * that the composite component provide a clean attribute interface. @@ -293,7 +295,7 @@ public void testUIParamTemplateScope5() throws Exception * @throws Exception */ @Test - public void testUIParamTemplateScope6() throws Exception + void uIParamTemplateScope6() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "uiparamtemplatescope6.xhtml"); @@ -306,10 +308,10 @@ public void testUIParamTemplateScope6() throws Exception rw.flush(); String result = fw.toString(); - Assertions.assertTrue(result.contains("rightValue")); - Assertions.assertFalse(result.contains("doNotPrintValue")); + assertTrue(result.contains("rightValue")); + assertFalse(result.contains("doNotPrintValue")); } - + /** * ui:param should pass through nested ui:decorate or ui:composition constructions, because it is the * same template context. Additionally, ui:param declarations should follow the same ordering rules @@ -318,7 +320,7 @@ public void testUIParamTemplateScope6() throws Exception * @throws Exception */ @Test - public void testUIParamTemplateScope7() throws Exception + void uIParamTemplateScope7() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "uiparamtemplatescope7.xhtml"); @@ -331,13 +333,13 @@ public void testUIParamTemplateScope7() throws Exception rw.flush(); String result = fw.toString(); - Assertions.assertTrue(result.contains("value1")); - Assertions.assertTrue(result.contains("value2")); - Assertions.assertTrue(result.contains("value3")); - Assertions.assertTrue(result.contains("value4")); - Assertions.assertTrue(result.contains("value5")); - Assertions.assertTrue(result.contains("valu1e5")); - Assertions.assertTrue(result.contains("valu1e6")); - Assertions.assertFalse(result.contains("value6")); + assertTrue(result.contains("value1")); + assertTrue(result.contains("value2")); + assertTrue(result.contains("value3")); + assertTrue(result.contains("value4")); + assertTrue(result.contains("value5")); + assertTrue(result.contains("valu1e5")); + assertTrue(result.contains("valu1e6")); + assertFalse(result.contains("value6")); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RemoveTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RemoveTestCase.java index 6e44857717..1dc53fdc1b 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RemoveTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RemoveTestCase.java @@ -19,6 +19,9 @@ package org.apache.myfaces.view.facelets.tag.ui; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; + import java.io.StringWriter; import jakarta.faces.component.UIForm; import jakarta.faces.component.UIOutput; @@ -34,14 +37,13 @@ import org.apache.myfaces.renderkit.html.HtmlTextRenderer; import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * * @author lu4242 */ -public class RemoveTestCase extends AbstractFaceletTestCase +class RemoveTestCase extends AbstractFaceletTestCase { @Override protected void setupComponents() throws Exception @@ -76,16 +78,16 @@ protected void setupRenderers() throws Exception "jakarta.faces.Button", new HtmlButtonRenderer()); renderKit.addRenderer(HtmlPanelGrid.COMPONENT_FAMILY, "jakarta.faces.Grid", new HtmlGridRenderer()); - } - + } + @Test - public void testRemoveMetadata() throws Exception { + void removeMetadata() throws Exception { request.setAttribute("beanValue", "hello"); UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testRemoveMetadata.xhtml"); - Assertions.assertNull(root.getFacet(UIViewRoot.METADATA_FACET_NAME)); + assertNull(root.getFacet(UIViewRoot.METADATA_FACET_NAME)); StringWriter sw = new StringWriter(); MockResponseWriter mrw = new MockResponseWriter(sw); @@ -95,9 +97,9 @@ public void testRemoveMetadata() throws Exception { sw.flush(); //System.out.println(sw.toString()); - Assertions.assertFalse(sw.toString().contains("ui:remove")); - Assertions.assertFalse(sw.toString().contains("f:metadata")); - Assertions.assertFalse(sw.toString().contains("Should not be here")); + assertFalse(sw.toString().contains("ui:remove")); + assertFalse(sw.toString().contains("f:metadata")); + assertFalse(sw.toString().contains("Should not be here")); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java index ad2847957c..c107b673b9 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.tag.ui; +import static org.junit.jupiter.api.Assertions.*; + import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -42,7 +44,6 @@ import org.apache.myfaces.view.facelets.bean.Example; import org.apache.myfaces.view.facelets.component.UIRepeat; import org.apache.myfaces.util.lang.FastWriter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -51,11 +52,11 @@ * @author Jakob Korherr (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class RepeatTestCase extends AbstractFaceletTestCase +class RepeatTestCase extends AbstractFaceletTestCase { @Test - public void testRepeat() throws Exception + void repeat() throws Exception { Company c = Example.createCompany(); facesContext.getExternalContext().getRequestMap().put("company", c); @@ -71,31 +72,31 @@ public void testRepeat() throws Exception String content = fw.toString(); int hrIndex = content.indexOf("
HR
"); - Assertions.assertNotSame(-1, hrIndex); + assertNotSame(-1, hrIndex); int rdIndex = content.indexOf("
RD
", hrIndex); - Assertions.assertNotSame(-1, rdIndex); + assertNotSame(-1, rdIndex); int empIndex1 = content.indexOf( "
Ellen, Sue
Scooner, Mary
", hrIndex); - Assertions.assertNotSame(-1, empIndex1); + assertNotSame(-1, empIndex1); int empIndex2 = content.indexOf( "
Burns, Ed
Lubke, Ryan
Kitain, Roger
", rdIndex); - Assertions.assertNotSame(-1, empIndex2); + assertNotSame(-1, empIndex2); int hrIndex2 = content.indexOf("
  • HR
  • "); - Assertions.assertNotSame(-1, hrIndex2); + assertNotSame(-1, hrIndex2); int rdIndex2 = content.indexOf("
  • RD
  • ", hrIndex2); - Assertions.assertNotSame(-1, rdIndex2); + assertNotSame(-1, rdIndex2); } - + /** * Tests UIRepeat.invokeOnComponent() including var and varStatus properties. * @throws IOException */ @Test @SuppressWarnings("unchecked") - public void testInvokeOnComponent() throws IOException + void invokeOnComponent() throws Exception { // put the values for ui:repeat on the request map final String[] repeatValues = new String[]{ "a", "b", "c" }; @@ -123,49 +124,49 @@ public void testInvokeOnComponent() throws IOException // invokeOnComponent on UIRepeat itself String invokeId = "form:repeat"; - Assertions.assertTrue(root.invokeOnComponent(facesContext, invokeId, callback)); - Assertions.assertEquals(repeat, callback._lastTarget); - Assertions.assertEquals(varValue, callback._rowValue); // previous set varValue - Assertions.assertEquals(statusValue, callback._repeatStatus); // previous set statusValue + assertTrue(root.invokeOnComponent(facesContext, invokeId, callback)); + assertEquals(repeat, callback._lastTarget); + assertEquals(varValue, callback._rowValue); // previous set varValue + assertEquals(statusValue, callback._repeatStatus); // previous set statusValue // invokeOnComponent on a child of UIRepeat in the first row invokeId = "form:repeat:0:outputText"; - Assertions.assertTrue(root.invokeOnComponent(facesContext, invokeId, callback)); - Assertions.assertEquals(outputText, callback._lastTarget); - Assertions.assertEquals(repeatValues[0], callback._rowValue); - Assertions.assertEquals(0, callback._index); - Assertions.assertEquals(true, callback._first); - Assertions.assertEquals(false, callback._last); - Assertions.assertEquals(true, callback._even); + assertTrue(root.invokeOnComponent(facesContext, invokeId, callback)); + assertEquals(outputText, callback._lastTarget); + assertEquals(repeatValues[0], callback._rowValue); + assertEquals(0, callback._index); + assertEquals(true, callback._first); + assertEquals(false, callback._last); + assertEquals(true, callback._even); // invokeOnComponent on a child of UIRepeat in the second row invokeId = "form:repeat:1:outputText"; - Assertions.assertTrue(root.invokeOnComponent(facesContext, invokeId, callback)); - Assertions.assertEquals(outputText, callback._lastTarget); - Assertions.assertEquals(repeatValues[1], callback._rowValue); - Assertions.assertEquals(1, callback._index); - Assertions.assertEquals(false, callback._first); - Assertions.assertEquals(false, callback._last); - Assertions.assertEquals(false, callback._even); + assertTrue(root.invokeOnComponent(facesContext, invokeId, callback)); + assertEquals(outputText, callback._lastTarget); + assertEquals(repeatValues[1], callback._rowValue); + assertEquals(1, callback._index); + assertEquals(false, callback._first); + assertEquals(false, callback._last); + assertEquals(false, callback._even); // invokeOnComponent on a child of UIRepeat in the third row invokeId = "form:repeat:2:outputText"; - Assertions.assertTrue(root.invokeOnComponent(facesContext, invokeId, callback)); - Assertions.assertEquals(outputText, callback._lastTarget); - Assertions.assertEquals(repeatValues[2], callback._rowValue); - Assertions.assertEquals(2, callback._index); - Assertions.assertEquals(false, callback._first); - Assertions.assertEquals(true, callback._last); - Assertions.assertEquals(true, callback._even); + assertTrue(root.invokeOnComponent(facesContext, invokeId, callback)); + assertEquals(outputText, callback._lastTarget); + assertEquals(repeatValues[2], callback._rowValue); + assertEquals(2, callback._index); + assertEquals(false, callback._first); + assertEquals(true, callback._last); + assertEquals(true, callback._even); // invokeOnComponent on a child of UIRepeat with invalid row (-1) invokeId = "form:repeat:outputText"; - Assertions.assertTrue(root.invokeOnComponent(facesContext, invokeId, callback)); + assertTrue(root.invokeOnComponent(facesContext, invokeId, callback)); // after all these calls to invokeOnComponent, row and status still // have to be the same like before - Assertions.assertEquals(varValue, externalContext.getRequestMap().get(var)); - Assertions.assertEquals(statusValue, externalContext.getRequestMap().get(varStatus)); + assertEquals(varValue, externalContext.getRequestMap().get(var)); + assertEquals(statusValue, externalContext.getRequestMap().get(varStatus)); // remove the values from the request map externalContext.getRequestMap().remove("repeatValues"); @@ -231,14 +232,14 @@ public void invokeContextCallback(FacesContext context, UIComponent target) } } - + /** * Tests UIRepeat.visitTree(). * @throws IOException */ @Test @SuppressWarnings("unchecked") - public void testVisitTree() throws IOException + void visitTree() throws Exception { // put the values for ui:repeat on the request map final String[] repeatValues = new String[]{ "a", "b", "c" }; @@ -274,12 +275,12 @@ public void testVisitTree() throws IOException expectedClientIds.add("form:repeat:2:outputText"); // see if we got the expected result - Assertions.assertEquals(expectedClientIds, testVisitCallback._visitedClientIds); + assertEquals(expectedClientIds, testVisitCallback._visitedClientIds); // after the tree visit, row and status still // have to be the same like before - Assertions.assertEquals(varValue, externalContext.getRequestMap().get(var)); - Assertions.assertEquals(statusValue, externalContext.getRequestMap().get(varStatus)); + assertEquals(varValue, externalContext.getRequestMap().get(var)); + assertEquals(statusValue, externalContext.getRequestMap().get(varStatus)); // remove the values from the request map externalContext.getRequestMap().remove("repeatValues"); @@ -314,7 +315,7 @@ public VisitResult visit(VisitContext context, UIComponent target) final String clientId = target.getClientId(context.getFacesContext()); if (_visitedClientIds.contains(clientId)) { - Assertions.fail("Component with clientId " + clientId + " visited twice!"); + fail("Component with clientId " + clientId + " visited twice!"); } else { @@ -327,15 +328,15 @@ public VisitResult visit(VisitContext context, UIComponent target) Object indexObject = _indexValueExpression.getValue(elCtx); // indexObject has to be an Integer - Assertions.assertTrue(indexObject instanceof Integer); + assertInstanceOf(Integer.class, indexObject); Integer index = (Integer) indexObject; // the index has to be part of the clientId - Assertions.assertTrue(clientId.contains("" + index)); + assertTrue(clientId.contains("" + index)); Object rowValue = _rowValueExpression.getValue(elCtx); // #{row} has to be the repeatValue for the current index - Assertions.assertEquals(_repeatValues[index], rowValue); + assertEquals(_repeatValues[index], rowValue); } } @@ -343,9 +344,9 @@ public VisitResult visit(VisitContext context, UIComponent target) } } - + @Test - public void testRepeatOffset() throws Exception + void repeatOffset() throws Exception { final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"}; facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues); @@ -354,7 +355,7 @@ public void testRepeatOffset() throws Exception vdl.buildView(facesContext, root, "ui_repeat_offset.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -366,20 +367,20 @@ public void testRepeatOffset() throws Exception // offset="2" size="1" should render only 1 row int itemIndex1 = content.indexOf("B1"); - Assertions.assertEquals(-1, itemIndex1); + assertEquals(-1, itemIndex1); int itemIndex2 = content.indexOf("B2"); - Assertions.assertEquals(-1, itemIndex2); + assertEquals(-1, itemIndex2); String item1 = "B3"; int itemIndex3 = content.indexOf(item1); - Assertions.assertNotSame(-1, itemIndex3); + assertNotSame(-1, itemIndex3); String item2 = "B4"; // the second item should not be there - Assertions.assertEquals(-1, content.indexOf(item2, itemIndex1+2)); + assertEquals(-1, content.indexOf(item2, itemIndex1+2)); } - + @Test - public void testRepeatOffset_0() throws Exception + void repeatOffset0() throws Exception { final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"}; facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues); @@ -388,7 +389,7 @@ public void testRepeatOffset_0() throws Exception vdl.buildView(facesContext, root, "ui_repeat_offset.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat0"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -400,15 +401,15 @@ public void testRepeatOffset_0() throws Exception String content = fw.toString(); int itemIndex1 = content.indexOf("B1"); - Assertions.assertNotSame(-1, itemIndex1); + assertNotSame(-1, itemIndex1); int itemIndex2 = content.indexOf("B2"); - Assertions.assertNotSame(-1, itemIndex2); + assertNotSame(-1, itemIndex2); int itemIndex3 = content.indexOf("B3"); - Assertions.assertEquals(-1, itemIndex3); + assertEquals(-1, itemIndex3); } - + @Test - public void testRepeatOffset_0_7() throws Exception + void repeatOffset07() throws Exception { final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"}; facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues); @@ -417,7 +418,7 @@ public void testRepeatOffset_0_7() throws Exception vdl.buildView(facesContext, root, "ui_repeat_offset.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat0_7"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -429,25 +430,24 @@ public void testRepeatOffset_0_7() throws Exception String content = fw.toString(); int itemIndex1 = content.indexOf("B1"); - Assertions.assertNotSame(-1, itemIndex1); + assertNotSame(-1, itemIndex1); int itemIndex2 = content.indexOf("B2", itemIndex1); - Assertions.assertNotSame(-1, itemIndex2); + assertNotSame(-1, itemIndex2); int itemIndex3 = content.indexOf("B3", itemIndex2); - Assertions.assertNotSame(-1, itemIndex3); + assertNotSame(-1, itemIndex3); int itemIndex4 = content.indexOf("B4", itemIndex3); - Assertions.assertNotSame(-1, itemIndex4); + assertNotSame(-1, itemIndex4); int itemIndex5 = content.indexOf("B5", itemIndex4); - Assertions.assertNotSame(-1, itemIndex5); + assertNotSame(-1, itemIndex5); int itemIndex6 = content.indexOf("B6", itemIndex5); - Assertions.assertNotSame(-1, itemIndex6); + assertNotSame(-1, itemIndex6); int itemIndex7 = content.indexOf("B7", itemIndex6); - Assertions.assertNotSame(-1, itemIndex7); + assertNotSame(-1, itemIndex7); } - - - + + @Test - public void testRepeatOffset_0_8() throws Exception + void repeatOffset08() throws Exception { final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"}; facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues); @@ -456,7 +456,7 @@ public void testRepeatOffset_0_8() throws Exception vdl.buildView(facesContext, root, "ui_repeat_offset.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat0_8"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -466,17 +466,17 @@ public void testRepeatOffset_0_8() throws Exception try { repeat.encodeAll(facesContext); - Assertions.fail(); + fail(); } catch(FacesException e) { // size cannot be greater than collection size } } - - + + @Test - public void testRepeatOffset_1() throws Exception + void repeatOffset1() throws Exception { final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"}; facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues); @@ -485,7 +485,7 @@ public void testRepeatOffset_1() throws Exception vdl.buildView(facesContext, root, "ui_repeat_offset.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat1"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -497,19 +497,19 @@ public void testRepeatOffset_1() throws Exception String content = fw.toString(); int itemIndex1 = content.indexOf("B1"); - Assertions.assertEquals(-1, itemIndex1); + assertEquals(-1, itemIndex1); int itemIndex2 = content.indexOf("B2"); - Assertions.assertNotSame(-1, itemIndex2); + assertNotSame(-1, itemIndex2); int itemIndex3 = content.indexOf("B3", itemIndex2); - Assertions.assertNotSame(-1, itemIndex3); + assertNotSame(-1, itemIndex3); int itemIndex4 = content.indexOf("B4", itemIndex3); - Assertions.assertNotSame(-1, itemIndex4); + assertNotSame(-1, itemIndex4); int itemIndex5 = content.indexOf("B5", itemIndex4); - Assertions.assertEquals(-1, itemIndex5); + assertEquals(-1, itemIndex5); } - + @Test - public void testRepeatOffset_1_7() throws Exception + void repeatOffset17() throws Exception { final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"}; facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues); @@ -518,7 +518,7 @@ public void testRepeatOffset_1_7() throws Exception vdl.buildView(facesContext, root, "ui_repeat_offset.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat1_7"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -530,24 +530,24 @@ public void testRepeatOffset_1_7() throws Exception String content = fw.toString(); int itemIndex1 = content.indexOf("B1"); - Assertions.assertEquals(-1, itemIndex1); + assertEquals(-1, itemIndex1); int itemIndex2 = content.indexOf("B2"); - Assertions.assertNotSame(-1, itemIndex2); + assertNotSame(-1, itemIndex2); int itemIndex3 = content.indexOf("B3", itemIndex2); - Assertions.assertNotSame(-1, itemIndex3); + assertNotSame(-1, itemIndex3); int itemIndex4 = content.indexOf("B4", itemIndex3); - Assertions.assertNotSame(-1, itemIndex4); + assertNotSame(-1, itemIndex4); int itemIndex5 = content.indexOf("B5", itemIndex4); - Assertions.assertNotSame(-1, itemIndex5); + assertNotSame(-1, itemIndex5); int itemIndex6 = content.indexOf("B6", itemIndex5); - Assertions.assertNotSame(-1, itemIndex6); + assertNotSame(-1, itemIndex6); int itemIndex7 = content.indexOf("B7", itemIndex6); - Assertions.assertNotSame(-1, itemIndex7); + assertNotSame(-1, itemIndex7); } - - + + @Test - public void testRepeatOffset_1_8() throws Exception + void repeatOffset18() throws Exception { final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"}; facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues); @@ -556,7 +556,7 @@ public void testRepeatOffset_1_8() throws Exception vdl.buildView(facesContext, root, "ui_repeat_offset.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat1_8"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -566,7 +566,7 @@ public void testRepeatOffset_1_8() throws Exception try { repeat.encodeAll(facesContext); - Assertions.fail(); + fail(); } catch(FacesException e) { @@ -575,7 +575,7 @@ public void testRepeatOffset_1_8() throws Exception } @Test - public void testRepeatOffset2() throws Exception + void repeatOffset2() throws Exception { final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"}; facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues); @@ -584,7 +584,7 @@ public void testRepeatOffset2() throws Exception vdl.buildView(facesContext, root, "ui_repeat_offset2.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -596,34 +596,33 @@ public void testRepeatOffset2() throws Exception String content = fw.toString(); int itemIndex1 = content.indexOf("B1"); - Assertions.assertEquals(-1, itemIndex1); + assertEquals(-1, itemIndex1); int itemIndex2 = content.indexOf("B2"); - Assertions.assertEquals(-1, itemIndex2); + assertEquals(-1, itemIndex2); int itemIndex3 = content.indexOf("B3"); - Assertions.assertNotSame(-1, itemIndex3); + assertNotSame(-1, itemIndex3); int itemIndex4 = content.indexOf("B4", itemIndex3); - Assertions.assertNotSame(-1, itemIndex4); + assertNotSame(-1, itemIndex4); int itemIndex5 = content.indexOf("B5", itemIndex4); - Assertions.assertNotSame(-1, itemIndex5); + assertNotSame(-1, itemIndex5); int itemIndex6 = content.indexOf("B6", itemIndex5); - Assertions.assertNotSame(-1, itemIndex6); + assertNotSame(-1, itemIndex6); int itemIndex7 = content.indexOf("B7", itemIndex6); - Assertions.assertNotSame(-1, itemIndex7); + assertNotSame(-1, itemIndex7); //System.out.println(fw); } - - - + + @Test @SuppressWarnings("unchecked") - public void testInvokeOnComponentBeginEnd() throws IOException + void invokeOnComponentBeginEnd() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "testUIRepeatBeginEnd.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -634,17 +633,17 @@ public void testInvokeOnComponentBeginEnd() throws IOException String content = fw.toString(); - Assertions.assertTrue(content.contains("Hello 1")); - Assertions.assertTrue(content.contains("Hello 2")); - Assertions.assertTrue(content.contains("Hello 3")); + assertTrue(content.contains("Hello 1")); + assertTrue(content.contains("Hello 2")); + assertTrue(content.contains("Hello 3")); - Assertions.assertFalse(content.contains("Hello 0")); - Assertions.assertFalse(content.contains("Hello 4")); + assertFalse(content.contains("Hello 0")); + assertFalse(content.contains("Hello 4")); } @Test @SuppressWarnings("unchecked") - public void testInvokeOnNullModel() throws IOException + void invokeOnNullModel() throws Exception { final List modelValues = null; final List loadedModelValues = Arrays.asList("Claire", "Michael"); @@ -654,7 +653,7 @@ public void testInvokeOnNullModel() throws IOException vdl.buildView(facesContext, root, "testUIRepeatEmpty.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -665,12 +664,12 @@ public void testInvokeOnNullModel() throws IOException String content = fw.toString(); - Assertions.assertFalse(content.contains("Hello ")); + assertFalse(content.contains("Hello ")); } @Test @SuppressWarnings("unchecked") - public void testInvokeOnEmptyList() throws IOException + void invokeOnEmptyList() throws Exception { final List modelValues = Collections.emptyList(); final List loadedModelValues = Arrays.asList("Claire", "Michael"); @@ -680,7 +679,7 @@ public void testInvokeOnEmptyList() throws IOException vdl.buildView(facesContext, root, "testUIRepeatEmpty.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -691,12 +690,12 @@ public void testInvokeOnEmptyList() throws IOException String content = fw.toString(); - Assertions.assertFalse(content.contains("Hello ")); + assertFalse(content.contains("Hello ")); } @Test @SuppressWarnings("unchecked") - public void testInvokeModelStep_1() throws IOException + void invokeModelStep1() throws Exception { final List values = Arrays.asList("User #0", "User #1", "User #2", "User #3", "User #4", "User #5", "User #6", "User #7", "User #8", "User #9", "User #10"); IterationBean iterationBean = new IterationBean(1, 7, 1, values); @@ -705,7 +704,7 @@ public void testInvokeModelStep_1() throws IOException vdl.buildView(facesContext, root, "ui_repeat_model_step.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -716,22 +715,22 @@ public void testInvokeModelStep_1() throws IOException String content = fw.toString(); - Assertions.assertTrue(content.contains("User #1")); - Assertions.assertTrue(content.contains("User #2")); - Assertions.assertTrue(content.contains("User #3")); - Assertions.assertTrue(content.contains("User #4")); - Assertions.assertTrue(content.contains("User #5")); - Assertions.assertTrue(content.contains("User #6")); - Assertions.assertTrue(content.contains("User #7")); - Assertions.assertFalse(content.contains("User #0")); - Assertions.assertFalse(content.contains("User #8")); - Assertions.assertFalse(content.contains("User #9")); - Assertions.assertFalse(content.contains("User #10")); + assertTrue(content.contains("User #1")); + assertTrue(content.contains("User #2")); + assertTrue(content.contains("User #3")); + assertTrue(content.contains("User #4")); + assertTrue(content.contains("User #5")); + assertTrue(content.contains("User #6")); + assertTrue(content.contains("User #7")); + assertFalse(content.contains("User #0")); + assertFalse(content.contains("User #8")); + assertFalse(content.contains("User #9")); + assertFalse(content.contains("User #10")); } - + @Test @SuppressWarnings("unchecked") - public void testInvokeModelStep_2() throws IOException + void invokeModelStep2() throws Exception { final List values = Arrays.asList("User #0", "User #1", "User #2", "User #3", "User #4", "User #5", "User #6", "User #7", "User #8", "User #9", "User #10"); IterationBean iterationBean = new IterationBean(1, 7, 2, values); @@ -740,7 +739,7 @@ public void testInvokeModelStep_2() throws IOException vdl.buildView(facesContext, root, "ui_repeat_model_step.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -751,22 +750,22 @@ public void testInvokeModelStep_2() throws IOException String content = fw.toString(); - Assertions.assertTrue(content.contains("User #1")); - Assertions.assertTrue(content.contains("User #3")); - Assertions.assertTrue(content.contains("User #5")); - Assertions.assertTrue(content.contains("User #7")); - Assertions.assertFalse(content.contains("User #0")); - Assertions.assertFalse(content.contains("User #2")); - Assertions.assertFalse(content.contains("User #4")); - Assertions.assertFalse(content.contains("User #6")); - Assertions.assertFalse(content.contains("User #8")); - Assertions.assertFalse(content.contains("User #9")); - Assertions.assertFalse(content.contains("User #10")); + assertTrue(content.contains("User #1")); + assertTrue(content.contains("User #3")); + assertTrue(content.contains("User #5")); + assertTrue(content.contains("User #7")); + assertFalse(content.contains("User #0")); + assertFalse(content.contains("User #2")); + assertFalse(content.contains("User #4")); + assertFalse(content.contains("User #6")); + assertFalse(content.contains("User #8")); + assertFalse(content.contains("User #9")); + assertFalse(content.contains("User #10")); } - + @Test @SuppressWarnings("unchecked") - public void testInvokeModelStep_3() throws IOException + void invokeModelStep3() throws Exception { final List values = Arrays.asList("User #0", "User #1", "User #2", "User #3", "User #4", "User #5", "User #6", "User #7", "User #8", "User #9", "User #10"); IterationBean iterationBean = new IterationBean(2, 7, 3, values); @@ -775,7 +774,7 @@ public void testInvokeModelStep_3() throws IOException vdl.buildView(facesContext, root, "ui_repeat_model_step.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -786,22 +785,22 @@ public void testInvokeModelStep_3() throws IOException String content = fw.toString(); - Assertions.assertTrue(content.contains("User #2")); - Assertions.assertTrue(content.contains("User #5")); - Assertions.assertFalse(content.contains("User #0")); - Assertions.assertFalse(content.contains("User #1")); - Assertions.assertFalse(content.contains("User #3")); - Assertions.assertFalse(content.contains("User #4")); - Assertions.assertFalse(content.contains("User #6")); - Assertions.assertFalse(content.contains("User #7")); - Assertions.assertFalse(content.contains("User #8")); - Assertions.assertFalse(content.contains("User #9")); - Assertions.assertFalse(content.contains("User #10")); + assertTrue(content.contains("User #2")); + assertTrue(content.contains("User #5")); + assertFalse(content.contains("User #0")); + assertFalse(content.contains("User #1")); + assertFalse(content.contains("User #3")); + assertFalse(content.contains("User #4")); + assertFalse(content.contains("User #6")); + assertFalse(content.contains("User #7")); + assertFalse(content.contains("User #8")); + assertFalse(content.contains("User #9")); + assertFalse(content.contains("User #10")); } @Test @SuppressWarnings("unchecked") - public void testInvokeModelChangeStep_3() throws IOException + void invokeModelChangeStep3() throws Exception { final List values = Arrays.asList("User #0", "User #1", "User #2", "User #3", "User #4", "User #5", "User #6", "User #7", "User #8", "User #9", "User #10"); IterationBean iterationBean = new IterationBean(2, 7, 3, values); @@ -810,7 +809,7 @@ public void testInvokeModelChangeStep_3() throws IOException vdl.buildView(facesContext, root, "ui_repeat_model_step.xhtml"); UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat"); - Assertions.assertNotNull(repeat); + assertNotNull(repeat); FastWriter fw = new FastWriter(); ResponseWriter rw = facesContext.getResponseWriter(); @@ -821,18 +820,18 @@ public void testInvokeModelChangeStep_3() throws IOException String content = fw.toString(); - Assertions.assertTrue(content.contains("User #2")); - Assertions.assertTrue(content.contains("User #5")); - - Assertions.assertFalse(content.contains("User #0")); - Assertions.assertFalse(content.contains("User #1")); - Assertions.assertFalse(content.contains("User #3")); - Assertions.assertFalse(content.contains("User #4")); - Assertions.assertFalse(content.contains("User #6")); - Assertions.assertFalse(content.contains("User #7")); - Assertions.assertFalse(content.contains("User #8")); - Assertions.assertFalse(content.contains("User #9")); - Assertions.assertFalse(content.contains("User #10")); + assertTrue(content.contains("User #2")); + assertTrue(content.contains("User #5")); + + assertFalse(content.contains("User #0")); + assertFalse(content.contains("User #1")); + assertFalse(content.contains("User #3")); + assertFalse(content.contains("User #4")); + assertFalse(content.contains("User #6")); + assertFalse(content.contains("User #7")); + assertFalse(content.contains("User #8")); + assertFalse(content.contains("User #9")); + assertFalse(content.contains("User #10")); } public class IterationBean { diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/TemplateTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/TemplateTestCase.java index be13dffec3..747661933d 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/TemplateTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/TemplateTestCase.java @@ -18,13 +18,14 @@ */ package org.apache.myfaces.view.facelets.tag.ui; +import static org.junit.jupiter.api.Assertions.assertTrue; + import jakarta.faces.component.UIViewRoot; import jakarta.faces.context.ResponseWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; import org.apache.myfaces.util.lang.FastWriter; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -34,7 +35,7 @@ * @author Jakob Korherr (latest modification by $Author$) * @version $Revision$ $Date$ */ -public class TemplateTestCase extends AbstractFaceletTestCase +class TemplateTestCase extends AbstractFaceletTestCase { private FastWriter _writer; @@ -66,7 +67,7 @@ public void tearDown() throws Exception * @throws Exception */ @Test - public void testInsertWithoutNameComposition() throws Exception + void insertWithoutNameComposition() throws Exception { _testInsertWithoutName("s_page_composition.xhtml"); } @@ -77,7 +78,7 @@ public void testInsertWithoutNameComposition() throws Exception * @throws Exception */ @Test - public void testInsertWithoutNameDecorate() throws Exception + void insertWithoutNameDecorate() throws Exception { _testInsertWithoutName("s_page_decorate.xhtml"); } @@ -92,8 +93,8 @@ private void _testInsertWithoutName(String page) throws Exception final String output = _writer.toString(); // assertions - Assertions.assertTrue(output.contains("BODY")); - Assertions.assertTrue(output.contains("

    [POPUPCONTENT]

    ")); + assertTrue(output.contains("BODY")); + assertTrue(output.contains("

    [POPUPCONTENT]

    ")); } /** @@ -102,7 +103,7 @@ private void _testInsertWithoutName(String page) throws Exception * @throws Exception */ @Test - public void testInsertWithDefinedNameDecorate() throws Exception + void insertWithDefinedNameDecorate() throws Exception { _testInsertWithDefinedName("decorate_with_template_and_define.xhtml"); } @@ -113,7 +114,7 @@ public void testInsertWithDefinedNameDecorate() throws Exception * @throws Exception */ @Test - public void testInsertWithDefinedNameComposition() throws Exception + void insertWithDefinedNameComposition() throws Exception { _testInsertWithDefinedName("composition_with_template_and_define.xhtml"); } @@ -128,7 +129,7 @@ private void _testInsertWithDefinedName(String page) throws Exception final String output = _writer.toString(); // assertions - Assertions.assertTrue(output.contains("defined content")); + assertTrue(output.contains("defined content")); } /** @@ -138,7 +139,7 @@ private void _testInsertWithDefinedName(String page) throws Exception * @throws Exception */ @Test - public void testInsertWithoutDefinedNameDecorate() throws Exception + void insertWithoutDefinedNameDecorate() throws Exception { _testInsertWithoutDefinedName("decorate_with_template.xhtml"); } @@ -150,7 +151,7 @@ public void testInsertWithoutDefinedNameDecorate() throws Exception * @throws Exception */ @Test - public void testInsertWithoutDefinedNameComposition() throws Exception + void insertWithoutDefinedNameComposition() throws Exception { _testInsertWithoutDefinedName("composition_with_template.xhtml"); } @@ -165,7 +166,7 @@ private void _testInsertWithoutDefinedName(String page) throws Exception final String output = _writer.toString(); // assertions - Assertions.assertTrue(output + assertTrue(output .contains("default ui:insert content")); } @@ -177,7 +178,7 @@ private void _testInsertWithoutDefinedName(String page) throws Exception * @throws Exception */ @Test - public void _testMultilevelTemplating() throws Exception + void _testMultilevelTemplating() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, @@ -189,7 +190,7 @@ public void _testMultilevelTemplating() throws Exception output = output.replaceAll("(?s)", ""); // remove license headers for clarity // assertions - Assertions.assertTrue(output.contains("inner content")); + assertTrue(output.contains("inner content")); } /** @@ -201,7 +202,7 @@ public void _testMultilevelTemplating() throws Exception * @throws Exception */ @Test - public void _testMultilevelTemplatingInnerFallback() throws Exception + void _testMultilevelTemplatingInnerFallback() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, @@ -213,7 +214,7 @@ public void _testMultilevelTemplatingInnerFallback() throws Exception output = output.replaceAll("(?s)", ""); // remove license headers for clarity // assertions - Assertions.assertTrue(output + assertTrue(output .contains("inner fallback content")); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/TestUserTags.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/TestUserTags.java index 1a12fd5d02..5a3587d652 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/TestUserTags.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/TestUserTags.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.view.facelets.tag.ui; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import jakarta.el.ExpressionFactory; import jakarta.faces.application.ViewHandler; import jakarta.faces.component.UIOutput; @@ -29,10 +32,9 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; import org.apache.myfaces.util.lang.FastWriter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestUserTags extends AbstractFaceletTestCase { +class TestUserTags extends AbstractFaceletTestCase { @Override protected void setUpServletObjects() throws Exception @@ -70,9 +72,9 @@ protected void setupRenderers() throws Exception renderKit.addRenderer(UIOutput.COMPONENT_FAMILY, "jakarta.faces.Text", new HtmlTextRenderer()); } - + @Test - public void testClientClient() throws Exception { + void clientClient() throws Exception { request.setAttribute("test", "foo"); UIViewRoot root = facesContext.getViewRoot(); @@ -91,7 +93,7 @@ public void testClientClient() throws Exception { * @throws Exception */ @Test - public void testUserTag1() throws Exception + void userTag1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "usertagtest1.xhtml"); @@ -104,18 +106,18 @@ public void testUserTag1() throws Exception rw.flush(); String result = fw.toString(); - Assertions.assertTrue(result.contains("value1")); - Assertions.assertFalse(result.contains("value2")); - Assertions.assertFalse(result.contains("value3")); + assertTrue(result.contains("value1")); + assertFalse(result.contains("value2")); + assertFalse(result.contains("value3")); } - + /** * Attributes should not pass to other user tags if they are not declared explicitly. * * @throws Exception */ @Test - public void testUserTag2() throws Exception + void userTag2() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "usertagtest2.xhtml"); @@ -128,8 +130,8 @@ public void testUserTag2() throws Exception rw.flush(); String result = fw.toString(); - Assertions.assertTrue(result.contains("value2")); - Assertions.assertFalse(result.contains("value3")); - Assertions.assertFalse(result.contains("value1")); + assertTrue(result.contains("value2")); + assertFalse(result.contains("value3")); + assertFalse(result.contains("value1")); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/UITestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/UITestCase.java index 98ab00f365..c82a85a7da 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/UITestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/UITestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.tag.ui; +import static org.junit.jupiter.api.Assertions.*; + import java.io.StringWriter; import java.util.HashMap; import java.util.Map; @@ -26,10 +28,9 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class UITestCase extends AbstractFaceletTestCase +class UITestCase extends AbstractFaceletTestCase { @Override @@ -52,7 +53,7 @@ protected void setupRenderers() throws Exception } @Test - public void testRelativePaths() throws Exception + void relativePaths() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "parent.xml"); @@ -62,8 +63,8 @@ public void testRelativePaths() throws Exception facesContext.setResponseWriter(mrw); root.encodeAll(facesContext); sw.flush(); - - Assertions.assertTrue(sw.toString().equals("Hello World!")); + + assertEquals("Hello World!", sw.toString()); //System.out.println("************************"); //System.out.println(sw.toString()); @@ -71,7 +72,7 @@ public void testRelativePaths() throws Exception } @Test - public void testCompositionTemplate() throws Exception + void compositionTemplate() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "composition-template.xml"); @@ -84,12 +85,12 @@ public void testCompositionTemplate() throws Exception String response = sw.toString(); - Assertions.assertTrue(response.contains("New Title")); - Assertions.assertTrue(response.contains("New Body")); + assertTrue(response.contains("New Title")); + assertTrue(response.contains("New Body")); } @Test - public void testCompositionTemplateSimple() throws Exception + void compositionTemplateSimple() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "composition-template-simple.xml"); @@ -102,11 +103,11 @@ public void testCompositionTemplateSimple() throws Exception String response = sw.toString(); - Assertions.assertTrue(response.contains("New Body")); + assertTrue(response.contains("New Body")); } @Test - public void testComponent() throws Exception + void component() throws Exception { Map map = new HashMap(); facesContext.getExternalContext().getRequestMap().put("map", map); @@ -114,8 +115,8 @@ public void testComponent() throws Exception UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "component.xml"); - Assertions.assertEquals(1, root.getChildCount()); - Assertions.assertNotNull(map.get("c")); + assertEquals(1, root.getChildCount()); + assertNotNull(map.get("c")); } /* diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/CompositionTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/CompositionTestCase.java index 8d5557ae14..288e5874b2 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/CompositionTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/CompositionTestCase.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.view.facelets.tag.ui.template; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import jakarta.faces.application.ViewHandler; @@ -25,10 +28,9 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CompositionTestCase extends AbstractFaceletTestCase { +class CompositionTestCase extends AbstractFaceletTestCase { @Override protected void setUpServletObjects() throws Exception @@ -43,7 +45,7 @@ protected void setUpServletObjects() throws Exception * @throws Exception */ @Test - public void testCompositionTrimEffect() throws Exception { + void compositionTrimEffect() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "compositionTrim.xhtml"); @@ -54,8 +56,8 @@ public void testCompositionTrimEffect() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertTrue(response.contains("THIS SHOULD BE RENDERED")); - Assertions.assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); + assertTrue(response.contains("THIS SHOULD BE RENDERED")); + assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); } /** @@ -68,7 +70,7 @@ public void testCompositionTrimEffect() throws Exception { * @throws Exception */ @Test - public void testComposition1() throws Exception { + void composition1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "composition1.xhtml"); @@ -79,10 +81,10 @@ public void testComposition1() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertTrue(response.contains("fragmentNumber1")); - Assertions.assertTrue(response.contains("compositionContent")); - Assertions.assertFalse(response.contains("This fragment will not be inserted")); - Assertions.assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); + assertTrue(response.contains("fragmentNumber1")); + assertTrue(response.contains("compositionContent")); + assertFalse(response.contains("This fragment will not be inserted")); + assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); } /** @@ -92,7 +94,7 @@ public void testComposition1() throws Exception { * @throws Exception */ @Test - public void testComposition2EmptyComposition() throws Exception { + void composition2EmptyComposition() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "composition2.xhtml"); @@ -103,10 +105,10 @@ public void testComposition2EmptyComposition() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertFalse(response.contains("This fragment will not be inserted")); - Assertions.assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); + assertFalse(response.contains("This fragment will not be inserted")); + assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); } - + /** * An empty ui:composition does not means the content of a ui:insert without * name to be rendered @@ -114,7 +116,7 @@ public void testComposition2EmptyComposition() throws Exception { * @throws Exception */ @Test - public void testComposition3EmptyComposition() throws Exception { + void composition3EmptyComposition() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "composition3.xhtml"); @@ -125,17 +127,17 @@ public void testComposition3EmptyComposition() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertFalse(response.contains("This fragment will not be inserted")); - Assertions.assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); + assertFalse(response.contains("This fragment will not be inserted")); + assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); } - + /** * A ui:define takes precedence over a ui:insert * * @throws Exception */ @Test - public void testComposition4DefineOverInsert() throws Exception { + void composition4DefineOverInsert() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "composition4.xhtml"); @@ -146,11 +148,11 @@ public void testComposition4DefineOverInsert() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertTrue(response.contains("fragmentNumber1")); - Assertions.assertFalse(response.contains("This fragment will not be inserted")); - Assertions.assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); + assertTrue(response.contains("fragmentNumber1")); + assertFalse(response.contains("This fragment will not be inserted")); + assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); } - + /** * A ui:insert on nested composition takes the top TemplateClient. * @@ -160,7 +162,7 @@ public void testComposition4DefineOverInsert() throws Exception { * @throws Exception */ @Test - public void testComposition5() throws Exception { + void composition5() throws Exception { /* composition5.xhtml @@ -201,7 +203,7 @@ public void testComposition5() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); + assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); response = checkStringInOrder(response, "start second composition"); response = checkStringInOrder(response, "composition5Content"); @@ -211,11 +213,11 @@ public void testComposition5() throws Exception { private String checkStringInOrder(String response, String token) { int pos = response.indexOf(token); - Assertions.assertTrue(pos > -1); + assertTrue(pos > -1); return response.substring(pos+token.length()); } - - + + /** * An ui:define on the outer most composition takes precedence over * the inner one. @@ -223,7 +225,7 @@ private String checkStringInOrder(String response, String token) * @throws Exception */ @Test - public void testCompositionNested1() throws Exception { + void compositionNested1() throws Exception { /* compositionNested1.xhtml @@ -269,14 +271,14 @@ public void testCompositionNested1() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertTrue(response.contains("fragmentNumber2")); - Assertions.assertFalse(response.contains("fragmentNumber1")); - Assertions.assertFalse(response.contains("This fragment will not be inserted")); - Assertions.assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); + assertTrue(response.contains("fragmentNumber2")); + assertFalse(response.contains("fragmentNumber1")); + assertFalse(response.contains("This fragment will not be inserted")); + assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); } - + @Test - public void testCompositionNested2() throws Exception + void compositionNested2() throws Exception { /* @@ -331,7 +333,7 @@ public void testCompositionNested2() throws Exception sw.flush(); String response = sw.toString(); - Assertions.assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); + assertFalse(response.contains("THIS SHOULD NOT BE RENDERED")); response = checkStringInOrder(response, "start first decoration"); response = checkStringInOrder(response, "start second composition"); diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/DecorateTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/DecorateTestCase.java index 1737fe9b8c..afd371e76e 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/DecorateTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/DecorateTestCase.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.view.facelets.tag.ui.template; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import jakarta.faces.application.ViewHandler; @@ -25,10 +28,9 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class DecorateTestCase extends AbstractFaceletTestCase { +class DecorateTestCase extends AbstractFaceletTestCase { @Override protected void setUpServletObjects() throws Exception @@ -38,7 +40,7 @@ protected void setUpServletObjects() throws Exception } @Test - public void testDecorate1() throws Exception { + void decorate1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "decorate1.xhtml"); @@ -49,15 +51,15 @@ public void testDecorate1() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertTrue(response.contains("fragmentNumber1")); - Assertions.assertTrue(response.contains("decorateContent")); - Assertions.assertFalse(response.contains("This fragment will not be inserted")); - Assertions.assertTrue(response.contains("THIS SHOULD BE RENDERED")); - Assertions.assertTrue(response.contains("THIS SHOULD BE RENDERED TOO")); + assertTrue(response.contains("fragmentNumber1")); + assertTrue(response.contains("decorateContent")); + assertFalse(response.contains("This fragment will not be inserted")); + assertTrue(response.contains("THIS SHOULD BE RENDERED")); + assertTrue(response.contains("THIS SHOULD BE RENDERED TOO")); } - + @Test - public void testDecorate2EmptyDecorate() throws Exception { + void decorate2EmptyDecorate() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "decorate2.xhtml"); @@ -68,13 +70,13 @@ public void testDecorate2EmptyDecorate() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertFalse(response.contains("This fragment will not be inserted")); - Assertions.assertTrue(response.contains("THIS SHOULD BE RENDERED")); - Assertions.assertTrue(response.contains("THIS SHOULD BE RENDERED TOO")); + assertFalse(response.contains("This fragment will not be inserted")); + assertTrue(response.contains("THIS SHOULD BE RENDERED")); + assertTrue(response.contains("THIS SHOULD BE RENDERED TOO")); } - + @Test - public void testDecorate3EmptyDecorate() throws Exception { + void decorate3EmptyDecorate() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "decorate3.xhtml"); @@ -85,13 +87,13 @@ public void testDecorate3EmptyDecorate() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertFalse(response.contains("This fragment will not be inserted")); - Assertions.assertTrue(response.contains("THIS SHOULD BE RENDERED")); - Assertions.assertTrue(response.contains("THIS SHOULD BE RENDERED TOO")); + assertFalse(response.contains("This fragment will not be inserted")); + assertTrue(response.contains("THIS SHOULD BE RENDERED")); + assertTrue(response.contains("THIS SHOULD BE RENDERED TOO")); } - + @Test - public void testDecorate4DefineOverInsert() throws Exception { + void decorate4DefineOverInsert() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "decorate4.xhtml"); @@ -102,12 +104,12 @@ public void testDecorate4DefineOverInsert() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertTrue(response.contains("fragmentNumber1")); - Assertions.assertFalse(response.contains("This fragment will not be inserted")); - Assertions.assertTrue(response.contains("THIS SHOULD BE RENDERED")); - Assertions.assertTrue(response.contains("THIS SHOULD BE RENDERED TOO")); + assertTrue(response.contains("fragmentNumber1")); + assertFalse(response.contains("This fragment will not be inserted")); + assertTrue(response.contains("THIS SHOULD BE RENDERED")); + assertTrue(response.contains("THIS SHOULD BE RENDERED TOO")); } - + /** * Based on * @@ -122,7 +124,7 @@ public void testDecorate4DefineOverInsert() throws Exception { * @throws Exception */ @Test - public void testDecorate5() throws Exception + void decorate5() throws Exception { /* decorate5.xhtml @@ -173,8 +175,8 @@ public void testDecorate5() throws Exception String response = sw.toString(); - Assertions.assertTrue(response.contains("THIS SHOULD BE RENDERED")); - Assertions.assertTrue(response.contains("THIS SHOULD BE RENDERED TOO")); + assertTrue(response.contains("THIS SHOULD BE RENDERED")); + assertTrue(response.contains("THIS SHOULD BE RENDERED TOO")); response = checkStringInOrder(response, "start first decoration"); response = checkStringInOrder(response, "start second decoration"); @@ -188,7 +190,7 @@ public void testDecorate5() throws Exception private String checkStringInOrder(String response, String token) { int pos = response.indexOf(token); - Assertions.assertTrue(pos > -1); + assertTrue(pos > -1); return response.substring(pos+token.length()); } @@ -199,7 +201,7 @@ private String checkStringInOrder(String response, String token) * @throws Exception */ @Test - public void testDecorateNested1() throws Exception { + void decorateNested1() throws Exception { /* decorate4.xhtml @@ -246,17 +248,17 @@ public void testDecorateNested1() throws Exception { sw.flush(); String response = sw.toString(); - Assertions.assertTrue(response.contains("fragmentNumber3")); - Assertions.assertTrue(response.contains("fragmentNumber2")); - Assertions.assertFalse(response.contains("fragmentNumber1")); - Assertions.assertFalse(response.contains("This fragment will not be inserted")); - Assertions.assertTrue(response.contains("THIS SHOULD BE RENDERED")); - Assertions.assertTrue(response.contains("THIS SHOULD BE RENDERED TOO")); + assertTrue(response.contains("fragmentNumber3")); + assertTrue(response.contains("fragmentNumber2")); + assertFalse(response.contains("fragmentNumber1")); + assertFalse(response.contains("This fragment will not be inserted")); + assertTrue(response.contains("THIS SHOULD BE RENDERED")); + assertTrue(response.contains("THIS SHOULD BE RENDERED TOO")); } - - + + @Test - public void testDecorateNested2() throws Exception + void decorateNested2() throws Exception { /* decorateNested2.xhtml diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/IncludeTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/IncludeTestCase.java index 26bfbca1f4..53120a1c29 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/IncludeTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/IncludeTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.myfaces.view.facelets.tag.ui.template; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import jakarta.faces.application.ViewHandler; @@ -25,10 +27,9 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class IncludeTestCase extends AbstractFaceletTestCase +class IncludeTestCase extends AbstractFaceletTestCase { @Override @@ -37,9 +38,9 @@ protected void setUpServletObjects() throws Exception super.setUpServletObjects(); servletContext.addInitParameter(ViewHandler.FACELETS_SKIP_COMMENTS_PARAM_NAME, "true"); } - + @Test - public void testIncludeIsolation1() throws Exception { + void includeIsolation1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "includeIsolation1.xhtml"); @@ -51,7 +52,7 @@ public void testIncludeIsolation1() throws Exception { String response = sw.toString(); - Assertions.assertTrue(response.contains("Do you see me?")); + assertTrue(response.contains("Do you see me?")); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/UserTagTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/UserTagTestCase.java index ec8d106181..4c099bd88f 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/UserTagTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/template/UserTagTestCase.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.view.facelets.tag.ui.template; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import jakarta.faces.application.ViewHandler; @@ -25,10 +28,9 @@ import org.apache.myfaces.test.mock.MockResponseWriter; import org.apache.myfaces.view.facelets.AbstractFaceletTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class UserTagTestCase extends AbstractFaceletTestCase +class UserTagTestCase extends AbstractFaceletTestCase { @Override @@ -38,9 +40,9 @@ protected void setUpServletObjects() throws Exception servletContext.addInitParameter(ViewHandler.FACELETS_SKIP_COMMENTS_PARAM_NAME, "true"); servletContext.addInitParameter(ViewHandler.FACELETS_LIBRARIES_PARAM_NAME, "/user.taglib.xml"); } - + @Test - public void testUserTag1() throws Exception { + void userTag1() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "userTagTest1.xhtml"); @@ -53,11 +55,11 @@ public void testUserTag1() throws Exception { String response = sw.toString(); - Assertions.assertTrue(response.contains("Do you see me?")); + assertTrue(response.contains("Do you see me?")); } @Test - public void testUserTag2() throws Exception { + void userTag2() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "userTagTest2.xhtml"); @@ -70,12 +72,12 @@ public void testUserTag2() throws Exception { String response = sw.toString(); - Assertions.assertTrue(response.contains("Do you see me?")); - Assertions.assertFalse(response.contains("This text should not be rendered")); + assertTrue(response.contains("Do you see me?")); + assertFalse(response.contains("This text should not be rendered")); } - + @Test - public void testUserTag3() throws Exception { + void userTag3() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "userTagTest3.xhtml"); @@ -88,12 +90,12 @@ public void testUserTag3() throws Exception { String response = sw.toString(); - Assertions.assertTrue(response.contains("Do you see me?")); - Assertions.assertFalse(response.contains("This text should not be rendered")); + assertTrue(response.contains("Do you see me?")); + assertFalse(response.contains("This text should not be rendered")); } - + @Test - public void testUserTag4() throws Exception { + void userTag4() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "userTagTest4.xhtml"); @@ -106,12 +108,12 @@ public void testUserTag4() throws Exception { String response = sw.toString(); - Assertions.assertTrue(response.contains("Do you see me?")); - Assertions.assertFalse(response.contains("This text should not be rendered")); + assertTrue(response.contains("Do you see me?")); + assertFalse(response.contains("This text should not be rendered")); } - + @Test - public void testUserTag5() throws Exception { + void userTag5() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "userTagTest5.xhtml"); @@ -124,12 +126,12 @@ public void testUserTag5() throws Exception { String response = sw.toString(); - Assertions.assertTrue(response.contains("Do you see me?")); - Assertions.assertFalse(response.contains("This text should not be rendered")); + assertTrue(response.contains("Do you see me?")); + assertFalse(response.contains("This text should not be rendered")); } @Test - public void testUserTag6() throws Exception { + void userTag6() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "userTagTest6.xhtml"); @@ -142,12 +144,12 @@ public void testUserTag6() throws Exception { String response = sw.toString(); - Assertions.assertTrue(response.contains("Do you see me?")); - Assertions.assertFalse(response.contains("This text should not be rendered")); + assertTrue(response.contains("Do you see me?")); + assertFalse(response.contains("This text should not be rendered")); } - + @Test - public void testUserTag7() throws Exception { + void userTag7() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "userTagTest7.xhtml"); @@ -160,12 +162,12 @@ public void testUserTag7() throws Exception { String response = sw.toString(); - Assertions.assertTrue(response.contains("Do you see me?")); - Assertions.assertFalse(response.contains("This text should not be rendered")); + assertTrue(response.contains("Do you see me?")); + assertFalse(response.contains("This text should not be rendered")); } - + @Test - public void testUserTag8() throws Exception { + void userTag8() throws Exception { UIViewRoot root = facesContext.getViewRoot(); vdl.buildView(facesContext, root, "userTagTest8.xhtml"); @@ -178,7 +180,7 @@ public void testUserTag8() throws Exception { String response = sw.toString(); - Assertions.assertTrue(response.contains("Do you see me?")); - Assertions.assertFalse(response.contains("This text should not be rendered")); + assertTrue(response.contains("Do you see me?")); + assertFalse(response.contains("This text should not be rendered")); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/test/component/FacesComponentAnnotationMyFacesRequestTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/test/component/FacesComponentAnnotationMyFacesRequestTestCase.java index 654f9650b6..2e9a3d9a41 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/test/component/FacesComponentAnnotationMyFacesRequestTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/test/component/FacesComponentAnnotationMyFacesRequestTestCase.java @@ -18,16 +18,17 @@ */ package org.apache.myfaces.view.facelets.test.component; +import static org.junit.jupiter.api.Assertions.*; + import jakarta.el.ExpressionFactory; import jakarta.faces.application.StateManager; import jakarta.faces.component.UIComponent; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.test.core.AbstractMyFacesRequestTestCase; import org.junit.jupiter.api.Test; -public class FacesComponentAnnotationMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase +class FacesComponentAnnotationMyFacesRequestTestCase extends AbstractMyFacesCDIRequestTestCase { @Override protected void setUpWebConfigParams() throws Exception @@ -41,67 +42,67 @@ protected void setUpWebConfigParams() throws Exception protected ExpressionFactory createExpressionFactory() { return new org.apache.el.ExpressionFactoryImpl(); - } - + } + @Test - public void testUIPanel1() throws Exception + void uIPanel1() throws Exception { startViewRequest("/testMyUIPanel1.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("panel1"); - Assertions.assertNotNull(comp); - Assertions.assertTrue(comp instanceof MyUIPanel1); + assertNotNull(comp); + assertInstanceOf(MyUIPanel1.class, comp); endRequest(); - } + } @Test - public void testUIPanel2() throws Exception + void uIPanel2() throws Exception { startViewRequest("/testMyUIPanel2.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("panel1"); - Assertions.assertNotNull(comp); - Assertions.assertTrue(comp instanceof MyUIPanel2); + assertNotNull(comp); + assertInstanceOf(MyUIPanel2.class, comp); endRequest(); } - + @Test - public void testUIPanel3() throws Exception + void uIPanel3() throws Exception { startViewRequest("/testMyUIPanel3.xhtml"); processLifecycleExecuteAndRender(); UIComponent comp = facesContext.getViewRoot().findComponent("panel3"); - Assertions.assertNotNull(comp); - Assertions.assertTrue(comp instanceof MyUIPanel3); + assertNotNull(comp); + assertInstanceOf(MyUIPanel3.class, comp); // Check component type MyUIPanel3 comp2 = (MyUIPanel3) facesContext.getApplication().createComponent("myUIPanel3"); - Assertions.assertNotNull(comp2); + assertNotNull(comp2); endRequest(); } - + // Test for MYFACES-4003 @Test - public void testInputTextWithClass() throws Exception + void inputTextWithClass() throws Exception { startViewRequest("/testClassAttribute.xhtml"); processLifecycleExecuteAndRender(); UIComponent jsfInputText = facesContext.getViewRoot().findComponent("form:JSF_inputText"); - Assertions.assertNotNull(jsfInputText); - Assertions.assertEquals("TEST", jsfInputText.getAttributes().get("styleClass")); + assertNotNull(jsfInputText); + assertEquals("TEST", jsfInputText.getAttributes().get("styleClass")); // The "class" attribute should have been mapped to a "styleClass" attribute UIComponent testInputText = facesContext.getViewRoot().findComponent("form:test_inputText"); - Assertions.assertNotNull(testInputText); - Assertions.assertEquals("TEST", testInputText.getAttributes().get("styleClass")); + assertNotNull(testInputText); + assertEquals("TEST", testInputText.getAttributes().get("styleClass")); endRequest(); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/updateheadres/UpdateHeadDynamicViewTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/updateheadres/UpdateHeadDynamicViewTestCase.java index 53f7958e90..f7bc50c965 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/updateheadres/UpdateHeadDynamicViewTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/updateheadres/UpdateHeadDynamicViewTestCase.java @@ -18,16 +18,18 @@ */ package org.apache.myfaces.view.facelets.updateheadres; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import jakarta.faces.application.StateManager; import jakarta.faces.component.UICommand; import jakarta.faces.component.UIComponent; import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class UpdateHeadDynamicViewTestCase extends AbstractMyFacesCDIRequestTestCase +class UpdateHeadDynamicViewTestCase extends AbstractMyFacesCDIRequestTestCase { @Override @@ -38,9 +40,9 @@ protected void setUpWebConfigParams() throws Exception servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.StateSavingMethod.CLIENT.name()); servletContext.addInitParameter(MyfacesConfig.REFRESH_TRANSIENT_BUILD_ON_PSS, "auto"); } - + @Test - public void testNoUpdateScript1Head() throws Exception + void noUpdateScript1Head() throws Exception { startViewRequest("/ajaxContent.xhtml"); processLifecycleExecuteAndRender(); @@ -53,13 +55,13 @@ public void testNoUpdateScript1Head() throws Exception processLifecycleExecuteAndRender(); String text = getRenderedContent(facesContext); // the inclusion should trigger update head - Assertions.assertFalse(text.contains("update id=\"jakarta.faces.ViewHead\"")); + assertFalse(text.contains("update id=\"jakarta.faces.ViewHead\"")); //System.out.println(text); endRequest(); } - + @Test - public void testUpdateScript2Head() throws Exception + void updateScript2Head() throws Exception { startViewRequest("/ajaxContent.xhtml"); processLifecycleExecuteAndRender(); @@ -73,14 +75,14 @@ public void testUpdateScript2Head() throws Exception String text = getRenderedContent(facesContext); // the inclusion should trigger update head - Assertions.assertTrue(text.contains("update id=\"jakarta.faces.Resource\"")); - Assertions.assertTrue(text.contains("alert(\"script2\");")); + assertTrue(text.contains("update id=\"jakarta.faces.Resource\"")); + assertTrue(text.contains("alert(\"script2\");")); //System.out.println(text); endRequest(); } - + @Test - public void testUpdateScript3Head() throws Exception + void updateScript3Head() throws Exception { startViewRequest("/ajaxContent.xhtml"); processLifecycleExecuteAndRender(); @@ -94,10 +96,10 @@ public void testUpdateScript3Head() throws Exception String text = getRenderedContent(facesContext); // the inclusion should trigger update head - Assertions.assertTrue(text.contains("update id=\"jakarta.faces.Resource\"")); - Assertions.assertTrue(text.contains("alert(\"script3\");")); + assertTrue(text.contains("update id=\"jakarta.faces.Resource\"")); + assertTrue(text.contains("alert(\"script3\");")); // MYFACES-4681 - HTML5 is default output mode, so the type attribute is unnecessary - Assertions.assertTrue(text.contains("link rel=\"stylesheet\" href=\"/test/faces/jakarta.faces.resource/style3.css\"")); + assertTrue(text.contains("link rel=\"stylesheet\" href=\"/test/faces/jakarta.faces.resource/style3.css\"")); //System.out.println(text); endRequest(); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/util/ClasspathTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/util/ClasspathTest.java index 45b7d37e32..28b333f0e3 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/util/ClasspathTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/util/ClasspathTest.java @@ -18,6 +18,9 @@ */ package org.apache.myfaces.view.facelets.util; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -38,7 +41,6 @@ import org.apache.myfaces.config.MetaInfResourceCache; import org.apache.myfaces.test.mock.MockExternalContext; import org.apache.myfaces.test.mock.MockServletContext; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -46,12 +48,12 @@ * META-INF/ URL is neither a JarURLConnection nor a directory on disk, so its entries are read as a zip * stream whose entry names are relative to the URL it was opened on - not to a classpath root. */ -public class ClasspathTest +class ClasspathTest { private static final String JAR = "vfstest:/content/app.war/WEB-INF/lib/custom.jar/"; @Test - public void testStreamEntriesRelativeToMetaInf() throws Exception + void streamEntriesRelativeToMetaInf() throws Exception { // opening META-INF/ itself yields its children (like VFS does for a directory) Map streams = new HashMap<>(); @@ -65,7 +67,7 @@ public void testStreamEntriesRelativeToMetaInf() throws Exception } @Test - public void testStreamEntriesRelativeToJarRoot() throws Exception + void streamEntriesRelativeToJarRoot() throws Exception { // META-INF/ cannot be read as a zip, the scan falls back to the enclosing jar Map streams = new HashMap<>(); @@ -75,11 +77,11 @@ public void testStreamEntriesRelativeToJarRoot() throws Exception new VfsClassLoader(streams, JAR + "META-INF/"), "META-INF/"); assertContains(entries, JAR + "META-INF/custom.taglib.xml"); - Assertions.assertEquals(1, entries.getUrls().size(), entries.getUrls().toString()); + assertEquals(1, entries.getUrls().size(), entries.getUrls().toString()); } @Test - public void testFindResourcesViaMetaInfResourceCache() throws Exception + void findResourcesViaMetaInfResourceCache() throws Exception { // the path the taglib / faces-config providers take: filter the cached scan by suffix Map streams = new HashMap<>(); @@ -92,12 +94,12 @@ public void testFindResourcesViaMetaInfResourceCache() throws Exception ExternalContext context = new MockExternalContext(new MockServletContext(), null, null); Collection taglibs = MetaInfResourceCache.findResources(context, ".taglib.xml"); - Assertions.assertEquals(1, taglibs.size(), taglibs.toString()); - Assertions.assertEquals(JAR + "META-INF/custom.taglib.xml", taglibs.iterator().next().toExternalForm()); + assertEquals(1, taglibs.size(), taglibs.toString()); + assertEquals(JAR + "META-INF/custom.taglib.xml", taglibs.iterator().next().toExternalForm()); Collection configs = MetaInfResourceCache.findResources(context, ".faces-config.xml"); - Assertions.assertEquals(1, configs.size(), configs.toString()); - Assertions.assertEquals(JAR + "META-INF/custom.faces-config.xml", + assertEquals(1, configs.size(), configs.toString()); + assertEquals(JAR + "META-INF/custom.faces-config.xml", configs.iterator().next().toExternalForm()); } finally @@ -108,7 +110,7 @@ public void testFindResourcesViaMetaInfResourceCache() throws Exception private static void assertContains(Classpath.ResourceEntries entries, String url) { - Assertions.assertTrue(entries.getUrls().stream().anyMatch(u -> u.toExternalForm().equals(url)), + assertTrue(entries.getUrls().stream().anyMatch(u -> u.toExternalForm().equals(url)), url + " not found in " + entries.getUrls() + " / " + entries.getNames()); } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/util/FastWriterTest.java b/impl/src/test/java/org/apache/myfaces/view/facelets/util/FastWriterTest.java index e085bcf523..e6171128a0 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/util/FastWriterTest.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/util/FastWriterTest.java @@ -19,14 +19,16 @@ package org.apache.myfaces.view.facelets.util; import org.apache.myfaces.util.lang.FastWriter; -import org.junit.jupiter.api.Assertions; + import org.junit.jupiter.api.Test; -public class FastWriterTest +import static org.junit.jupiter.api.Assertions.assertEquals; + +class FastWriterTest { // Test FastWriter.write(String str, int off, int len) @Test - public void testFastWriterWriteString() throws Exception + void fastWriterWriteString() throws Exception { String sampleStringToWrite = "Test String to write"; @@ -34,11 +36,11 @@ public void testFastWriterWriteString() throws Exception fw.write(sampleStringToWrite, 0, sampleStringToWrite.length()); // fw.toString() should be: Test String to write - Assertions.assertEquals(fw.toString(), sampleStringToWrite); + assertEquals(fw.toString(), sampleStringToWrite); } - + @Test - public void testFastWriterWriteStringOffSet() throws Exception + void fastWriterWriteStringOffSet() throws Exception { int offSet = 5; String sampleStringToWrite = "Test String to write"; @@ -47,11 +49,11 @@ public void testFastWriterWriteStringOffSet() throws Exception fw.write(sampleStringToWrite, offSet, sampleStringToWrite.length() - offSet); // fw.toString() should be: String to write - Assertions.assertEquals(fw.toString(), sampleStringToWrite.substring(offSet)); + assertEquals(fw.toString(), sampleStringToWrite.substring(offSet)); } - + @Test - public void testFastWriterWriteStringLength() throws Exception + void fastWriterWriteStringLength() throws Exception { String sampleStringToWrite = "Test String to write"; int length = sampleStringToWrite.substring(0, sampleStringToWrite.indexOf(' ')).length(); @@ -60,6 +62,6 @@ public void testFastWriterWriteStringLength() throws Exception fw.write(sampleStringToWrite, 0, length); // fw.toString() should be: Test - Assertions.assertEquals(fw.toString(), sampleStringToWrite.substring(0,length)); + assertEquals(fw.toString(), sampleStringToWrite.substring(0,length)); } } \ No newline at end of file diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/viewscope/ViewScopeClientSideStateLimitTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/viewscope/ViewScopeClientSideStateLimitTestCase.java index a0e30b51a3..1734469058 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/viewscope/ViewScopeClientSideStateLimitTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/viewscope/ViewScopeClientSideStateLimitTestCase.java @@ -18,13 +18,14 @@ */ package org.apache.myfaces.view.facelets.viewscope; +import static org.junit.jupiter.api.Assertions.assertEquals; + import jakarta.el.ExpressionFactory; import jakarta.faces.application.ProjectStage; import jakarta.faces.application.StateManager; import org.apache.myfaces.config.webparameters.MyfacesConfig; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -33,7 +34,7 @@ * {@code @ViewScoped} bean must not let the number of view scopes in the session grow without limit: * only the most recent {@code org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION} are kept. */ -public class ViewScopeClientSideStateLimitTestCase extends AbstractMyFacesCDIRequestTestCase +class ViewScopeClientSideStateLimitTestCase extends AbstractMyFacesCDIRequestTestCase { private static final int LIMIT = 3; @@ -56,7 +57,7 @@ protected void setUpWebConfigParams() throws Exception } @Test - public void testViewScopesAreLimitedWithClientSideStateSaving() throws Exception + void viewScopesAreLimitedWithClientSideStateSaving() throws Exception { ViewScopeLimitProbeBean.reset(); @@ -69,9 +70,9 @@ public void testViewScopesAreLimitedWithClientSideStateSaving() throws Exception endRequest(); } - Assertions.assertEquals(requests, ViewScopeLimitProbeBean.CREATED.get(), + assertEquals(requests, ViewScopeLimitProbeBean.CREATED.get(), "the @ViewScoped bean must be created once per request"); - Assertions.assertEquals(requests - LIMIT, ViewScopeLimitProbeBean.DESTROYED.get(), + assertEquals(requests - LIMIT, ViewScopeLimitProbeBean.DESTROYED.get(), "only the most recent " + LIMIT + " view scopes must be kept in the session"); } } diff --git a/impl/src/test/java/org/apache/myfaces/view/facelets/viewscope/ViewScopeFormlessLeakTestCase.java b/impl/src/test/java/org/apache/myfaces/view/facelets/viewscope/ViewScopeFormlessLeakTestCase.java index 49dcbf3742..6275b42e4c 100644 --- a/impl/src/test/java/org/apache/myfaces/view/facelets/viewscope/ViewScopeFormlessLeakTestCase.java +++ b/impl/src/test/java/org/apache/myfaces/view/facelets/viewscope/ViewScopeFormlessLeakTestCase.java @@ -18,11 +18,12 @@ */ package org.apache.myfaces.view.facelets.viewscope; +import static org.junit.jupiter.api.Assertions.assertEquals; + import jakarta.el.ExpressionFactory; import jakarta.faces.application.ProjectStage; import org.apache.myfaces.test.core.AbstractMyFacesCDIRequestTestCase; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -34,7 +35,7 @@ * the scope has to be destroyed at the end of each request. Before the fix the beans were never * destroyed and piled up in the session (a memory leak), so {@code DESTROYED} stayed at 0.

    */ -public class ViewScopeFormlessLeakTestCase extends AbstractMyFacesCDIRequestTestCase +class ViewScopeFormlessLeakTestCase extends AbstractMyFacesCDIRequestTestCase { protected ExpressionFactory createExpressionFactory() @@ -52,7 +53,7 @@ protected void setUpWebConfigParams() throws Exception } @Test - public void testFormlessViewDoesNotLeakViewScopedBeans() throws Exception + void formlessViewDoesNotLeakViewScopedBeans() throws Exception { ViewScopeLeakProbeBean.reset(); @@ -65,9 +66,9 @@ public void testFormlessViewDoesNotLeakViewScopedBeans() throws Exception endRequest(); } - Assertions.assertEquals(requests, ViewScopeLeakProbeBean.CREATED.get(), + assertEquals(requests, ViewScopeLeakProbeBean.CREATED.get(), "the @ViewScoped bean must be created once per request"); - Assertions.assertEquals(requests, ViewScopeLeakProbeBean.DESTROYED.get(), + assertEquals(requests, ViewScopeLeakProbeBean.DESTROYED.get(), "the @ViewScoped beans of a formless (never-saved) view must be destroyed each " + "request, not leaked into the session"); } diff --git a/parent/pom.xml b/parent/pom.xml index 42b10215dc..c7b0f3a295 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -210,7 +210,7 @@ maven-surefire-plugin - 3.0.0-M7 + 3.6.1 @@ -455,7 +455,7 @@ org.junit.jupiter junit-jupiter-api - 5.13.4 + 6.1.3 test diff --git a/test/src/main/java/org/apache/myfaces/test/base/junit/AbstractViewControllerTestCase.java b/test/src/main/java/org/apache/myfaces/test/base/junit/AbstractViewControllerTestCase.java index feedf67cc0..afcef0112f 100644 --- a/test/src/main/java/org/apache/myfaces/test/base/junit/AbstractViewControllerTestCase.java +++ b/test/src/main/java/org/apache/myfaces/test/base/junit/AbstractViewControllerTestCase.java @@ -19,9 +19,10 @@ package org.apache.myfaces.test.base.junit; -import java.util.Iterator; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; -import org.junit.jupiter.api.Assertions; +import java.util.Iterator; /** *

    Abstract base class for testing ViewController @@ -72,7 +73,7 @@ protected void checkMessageCount(int expected) messages.next(); actual++; } - Assertions.assertEquals(expected, actual, "Complete message count"); + assertEquals(expected, actual, "Complete message count"); } @@ -94,7 +95,7 @@ protected void checkMessageCount(String clientId, int expected) messages.next(); actual++; } - Assertions.assertSame(expected, actual, "Complete message count"); + assertSame(expected, actual, "Complete message count"); }