From 76f1cebe8db9d505156698b7973a1555f5835739 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sat, 2 Mar 2024 12:00:04 -0400 Subject: [PATCH 1/9] First step, migrate junit4 to junit5 --- impl/pom.xml | 6 +- .../faces/application/FacesMessageTest.java | 6 +- .../resource/ResourceCacheTest.java | 7 +- .../com/sun/faces/config/DigesterFactory.java | 5 +- .../FacesConfigNamespaceContextTest.java | 6 +- .../context/ExternalContextImplTest.java | 19 +- ...siteComponentAttributesELResolverTest.java | 24 +- .../java/com/sun/faces/el/ELUtilsTest.java | 8 +- .../facelets/component/UIRepeatTest.java | 7 +- .../facelets/util/ClasspathTestCase.java | 12 +- .../faces/junit/JUnitFacesTestCaseBase.java | 27 +-- .../mock/MockExternalContextFactory.java | 7 +- .../faces/mock/MockFacesContextFactory.java | 7 +- .../com/sun/faces/mock/MockLifecycle.java | 3 +- .../sun/faces/mock/MockLifecycleFactory.java | 3 +- .../java/com/sun/faces/mock/MockServlet.java | 1 + .../com/sun/faces/mock/MockServletConfig.java | 1 + .../html_basic/BodyRendererTest.java | 9 +- .../html_basic/HeadRendererTest.java | 7 +- .../html_basic/HtmlResponseWriterTest.java | 8 +- ...figurationResourceProviderFactoryTest.java | 13 +- .../faces/util/ByteArrayGuardAESCTRTest.java | 25 +- .../com/sun/faces/util/FacesLoggerTest.java | 16 +- .../sun/faces/util/MostlySingletonTest.java | 6 +- .../com/sun/faces/util/TestHtmlUtils.java | 8 +- .../com/sun/faces/util/TestLRUMap_local.java | 17 +- .../com/sun/faces/util/TestUtil_local.java | 49 ++-- .../com/sun/faces/xml/ParseXMLTestCase.java | 27 +-- .../sun/faces/xml/XHTMLResolvingHandler.java | 1 + .../faces/FacesConfigOrderingTestCase.java | 79 +++---- .../jakarta/faces/FacesWrapperTestCase.java | 25 +- .../jakarta/faces/FactoryFinderTestCase.java | 85 +++---- .../jakarta/faces/FactoryFinderTestCase2.java | 52 ++-- .../component/NamingContainerTestCase.java | 28 +-- .../SearchExpressionHandlerTest.java | 222 +++++++++++------- .../component/StateHolderSaverTestCase.java | 27 +-- .../faces/component/UIColumnTestCase.java | 23 +- .../faces/component/UICommandTestCase.java | 32 ++- .../UIComponentBaseAttachedStateTestCase.java | 41 ++-- .../UIComponentBaseBehaviorTestCase.java | 11 +- .../component/UIComponentBaseTestCase.java | 143 +++++------ .../faces/component/UIComponentTestCase.java | 145 +++++++----- .../jakarta/faces/component/UIDataTest.java | 11 +- .../faces/component/UIGraphicTestCase.java | 37 ++- .../jakarta/faces/component/UIInputTest.java | 17 +- .../faces/component/UIInputTestCase.java | 50 ++-- .../UIOutputAttachedObjectStateTestCase.java | 35 ++- .../faces/component/UIOutputTestCase.java | 21 +- .../faces/component/UIPanelTestCase.java | 21 +- .../faces/component/UIParameterTest.java | 4 +- .../faces/component/UIParameterTestCase.java | 41 ++-- .../component/UISelectBooleanTestCase.java | 27 +-- .../faces/component/UISelectItemSub.java | 1 - .../faces/component/UISelectItemTestCase.java | 54 ++--- .../component/UISelectItemsTestCase.java | 34 ++- .../faces/component/UISelectManyTestCase.java | 49 ++-- .../faces/component/UISelectOneTestCase.java | 35 ++- .../faces/component/UIViewRootTest.java | 6 +- .../faces/component/UIViewRootTestCase.java | 69 +++--- .../component/ValueHolderTestCaseBase.java | 46 ++-- .../convert/BigIntegerConverterTest.java | 19 +- .../faces/convert/DoubleConverterTest.java | 15 +- .../faces/convert/FloatConverterTest.java | 15 +- .../faces/convert/IntegerConverterTest.java | 15 +- .../faces/convert/LongConverterTest.java | 15 +- .../faces/convert/ShortConverterTest.java | 15 +- .../java/jakarta/faces/event/PhaseIdTest.java | 34 +-- .../faces/model/ArrayDataModelTestCase.java | 21 +- .../faces/model/CollectionDataModelTest.java | 6 +- .../faces/model/DataModelTestCaseBase.java | 123 +++++----- .../faces/model/ListDataModelTestCase.java | 23 +- .../model/ResultSetDataModelTestCase.java | 49 ++-- .../faces/model/ScalarDataModelTestCase.java | 21 +- .../validator/BeanValidatorTestCase.java | 32 +-- .../validator/CastingValidatorTestCase.java | 26 +- .../DoubleRangeValidatorTestCase.java | 41 ++-- .../validator/LengthValidatorTestCase.java | 34 +-- .../validator/LongRangeValidatorTestCase.java | 42 ++-- .../validator/RegexValidatorTestCase.java | 25 +- .../validator/RequiredValidatorTest.java | 2 +- .../faces/validator/ValidatorTestCase.java | 22 +- .../faces/webapp/ComponentTestImpl.java | 2 - .../faces/webapp/ConfigFileTestCase.java | 37 +-- .../faces/webapp/FacesServletTestCase.java | 22 +- 84 files changed, 1110 insertions(+), 1352 deletions(-) diff --git a/impl/pom.xml b/impl/pom.xml index 9f0d5182fb..889f7ec9e2 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -163,9 +163,9 @@ - org.powermock - powermock-module-junit4 - 2.0.9 + org.junit.jupiter + junit-jupiter + 5.10.2 test diff --git a/impl/src/test/java/com/sun/faces/application/FacesMessageTest.java b/impl/src/test/java/com/sun/faces/application/FacesMessageTest.java index 420b752ddd..fe3a2f9c73 100644 --- a/impl/src/test/java/com/sun/faces/application/FacesMessageTest.java +++ b/impl/src/test/java/com/sun/faces/application/FacesMessageTest.java @@ -16,18 +16,18 @@ package com.sun.faces.application; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; import jakarta.faces.application.FacesMessage; -import static org.junit.Assert.*; - public class FacesMessageTest { // Case 0 (nothing) diff --git a/impl/src/test/java/com/sun/faces/application/resource/ResourceCacheTest.java b/impl/src/test/java/com/sun/faces/application/resource/ResourceCacheTest.java index c8223cb0ce..140a97740d 100644 --- a/impl/src/test/java/com/sun/faces/application/resource/ResourceCacheTest.java +++ b/impl/src/test/java/com/sun/faces/application/resource/ResourceCacheTest.java @@ -16,14 +16,13 @@ package com.sun.faces.application.resource; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import org.junit.jupiter.api.Test; public class ResourceCacheTest { @@ -36,7 +35,7 @@ public void noMemoryLeakWithContracts() { // now we clear the contracts list, which was used to create the cache entry. contracts.clear(); ResourceInfo cachedResourceInfo = cache.get("bar.gif", null, null, Arrays.asList("foo", "baz")); - assertThat(cachedResourceInfo, is(resourceInfo)); + assertEquals(resourceInfo, cachedResourceInfo); } } diff --git a/impl/src/test/java/com/sun/faces/config/DigesterFactory.java b/impl/src/test/java/com/sun/faces/config/DigesterFactory.java index ddd5e87feb..244fa13480 100644 --- a/impl/src/test/java/com/sun/faces/config/DigesterFactory.java +++ b/impl/src/test/java/com/sun/faces/config/DigesterFactory.java @@ -16,11 +16,13 @@ package com.sun.faces.config; -import javax.xml.parsers.ParserConfigurationException; import java.net.URL; import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; + +import javax.xml.parsers.ParserConfigurationException; + import org.apache.commons.digester.Digester; import org.apache.commons.logging.impl.NoOpLog; import org.xml.sax.ErrorHandler; @@ -30,6 +32,7 @@ import org.xml.sax.SAXNotSupportedException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; + import com.sun.faces.util.ToolsUtil; /** diff --git a/impl/src/test/java/com/sun/faces/config/processor/FacesConfigNamespaceContextTest.java b/impl/src/test/java/com/sun/faces/config/processor/FacesConfigNamespaceContextTest.java index cb59988b72..b9f320d35f 100644 --- a/impl/src/test/java/com/sun/faces/config/processor/FacesConfigNamespaceContextTest.java +++ b/impl/src/test/java/com/sun/faces/config/processor/FacesConfigNamespaceContextTest.java @@ -17,8 +17,8 @@ package com.sun.faces.config.processor; import static com.sun.faces.util.Util.createLocalDocumentBuilderFactory; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -28,7 +28,7 @@ import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; diff --git a/impl/src/test/java/com/sun/faces/context/ExternalContextImplTest.java b/impl/src/test/java/com/sun/faces/context/ExternalContextImplTest.java index 2b2358186d..a7757995c2 100644 --- a/impl/src/test/java/com/sun/faces/context/ExternalContextImplTest.java +++ b/impl/src/test/java/com/sun/faces/context/ExternalContextImplTest.java @@ -16,24 +16,27 @@ package com.sun.faces.context; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.function.Consumer; import java.util.function.Supplier; + +import org.junit.jupiter.api.Test; +import org.powermock.api.easymock.PowerMock; + import jakarta.servlet.ServletContext; import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import org.junit.Test; -import org.powermock.api.easymock.PowerMock; /** * The JUnit tests for the ExternalContextImpl class. diff --git a/impl/src/test/java/com/sun/faces/el/CompositeComponentAttributesELResolverTest.java b/impl/src/test/java/com/sun/faces/el/CompositeComponentAttributesELResolverTest.java index 4647e3a126..3b48ca894f 100644 --- a/impl/src/test/java/com/sun/faces/el/CompositeComponentAttributesELResolverTest.java +++ b/impl/src/test/java/com/sun/faces/el/CompositeComponentAttributesELResolverTest.java @@ -16,23 +16,27 @@ package com.sun.faces.el; -import com.sun.faces.facelets.tag.composite.CompositeComponentBeanInfo; - -import jakarta.faces.application.Resource; -import jakarta.faces.component.UIComponent; -import jakarta.faces.component.UIPanel; -import jakarta.faces.context.FacesContext; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.beans.BeanDescriptor; import java.lang.reflect.Field; import java.util.HashMap; import java.util.Map; -import jakarta.el.ELContext; import org.easymock.EasyMock; -import org.junit.Test; -import static org.junit.Assert.*; -import static org.easymock.EasyMock.*; +import org.junit.jupiter.api.Test; + +import com.sun.faces.facelets.tag.composite.CompositeComponentBeanInfo; + +import jakarta.el.ELContext; +import jakarta.faces.application.Resource; +import jakarta.faces.component.UIComponent; +import jakarta.faces.component.UIPanel; +import jakarta.faces.context.FacesContext; /** * The JUnit tests for the CompositeComponentAttributesELResolver class. diff --git a/impl/src/test/java/com/sun/faces/el/ELUtilsTest.java b/impl/src/test/java/com/sun/faces/el/ELUtilsTest.java index 2eca310586..8bd05397e0 100644 --- a/impl/src/test/java/com/sun/faces/el/ELUtilsTest.java +++ b/impl/src/test/java/com/sun/faces/el/ELUtilsTest.java @@ -2,8 +2,8 @@ import java.net.URL; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.sun.el.ExpressionFactoryImpl; import com.sun.faces.RIConstants; @@ -25,7 +25,7 @@ public class ELUtilsTest { private ApplicationAssociate applicationAssociate; - @Before + @BeforeEach public void setUp() { MockServletContext mockServletContext = new MockServletContext() { @Override @@ -50,7 +50,7 @@ public URL getResource(String path) { applicationAssociate = (ApplicationAssociate) externalContext.getApplicationMap() .get(RIConstants.FACES_PREFIX + "ApplicationAssociate"); - + FacesContext.getCurrentInstance().getAttributes().put(RIConstants.CDI_BEAN_MANAGER, new MockBeanManager()); } diff --git a/impl/src/test/java/com/sun/faces/facelets/component/UIRepeatTest.java b/impl/src/test/java/com/sun/faces/facelets/component/UIRepeatTest.java index d6c44d2952..9fc48eecc8 100644 --- a/impl/src/test/java/com/sun/faces/facelets/component/UIRepeatTest.java +++ b/impl/src/test/java/com/sun/faces/facelets/component/UIRepeatTest.java @@ -18,20 +18,19 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.lang.reflect.Method; -import junit.framework.TestCase; - import org.easymock.EasyMock; import org.easymock.IAnswer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import jakarta.faces.application.FacesMessage; import jakarta.faces.application.FacesMessage.Severity; import jakarta.faces.context.FacesContext; -public class UIRepeatTest extends TestCase { +public class UIRepeatTest { private FacesContext ctx; diff --git a/impl/src/test/java/com/sun/faces/facelets/util/ClasspathTestCase.java b/impl/src/test/java/com/sun/faces/facelets/util/ClasspathTestCase.java index b37ead4d50..2f3761b609 100644 --- a/impl/src/test/java/com/sun/faces/facelets/util/ClasspathTestCase.java +++ b/impl/src/test/java/com/sun/faces/facelets/util/ClasspathTestCase.java @@ -16,17 +16,15 @@ package com.sun.faces.facelets.util; +import static org.junit.jupiter.api.Assertions.assertNull; + import java.util.jar.JarFile; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -public class ClasspathTestCase extends TestCase { +import org.junit.jupiter.api.Test; - public static Test suite() { - return (new TestSuite(ClasspathTestCase.class)); - } +public class ClasspathTestCase { + @Test public void testGetAlternativeJarFile() throws Exception { String input = "rar:/scratch/fleme/fmwhome/AS11gR1SOA/soa/connectors/FileAdapter.rar!fileAdapter.jar!/META-INF/"; diff --git a/impl/src/test/java/com/sun/faces/junit/JUnitFacesTestCaseBase.java b/impl/src/test/java/com/sun/faces/junit/JUnitFacesTestCaseBase.java index c9c0c7de69..ccf81930fd 100644 --- a/impl/src/test/java/com/sun/faces/junit/JUnitFacesTestCaseBase.java +++ b/impl/src/test/java/com/sun/faces/junit/JUnitFacesTestCaseBase.java @@ -16,6 +16,13 @@ package com.sun.faces.junit; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + import com.sun.faces.mock.MockApplication; import com.sun.faces.mock.MockExternalContext; import com.sun.faces.mock.MockFacesContext; @@ -31,13 +38,7 @@ import jakarta.faces.context.FacesContextFactory; import jakarta.faces.lifecycle.LifecycleFactory; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -import junit.framework.TestCase; - -public class JUnitFacesTestCaseBase extends TestCase { +public class JUnitFacesTestCaseBase { protected MockApplication application = null; protected MockServletConfig config = null; @@ -49,14 +50,8 @@ public class JUnitFacesTestCaseBase extends TestCase { protected MockLifecycle lifecycle = null; protected MockHttpSession session = null; - public JUnitFacesTestCaseBase(String name) { - super(name); - } - - @Override + @BeforeEach public void setUp() throws Exception { - super.setUp(); - // Set up Servlet API Objects servletContext = new MockServletContext(); servletContext.addInitParameter("appParamName", "appParamValue"); @@ -100,7 +95,7 @@ public void setUp() throws Exception { } - @Override + @AfterEach public void tearDown() throws Exception { FactoryFinder.releaseFactories(); Method reInitializeFactoryManager = FactoryFinder.class.getDeclaredMethod("reInitializeFactoryManager", (Class[]) null); @@ -116,7 +111,5 @@ public void tearDown() throws Exception { response = null; servletContext = null; session = null; - - super.tearDown(); } } diff --git a/impl/src/test/java/com/sun/faces/mock/MockExternalContextFactory.java b/impl/src/test/java/com/sun/faces/mock/MockExternalContextFactory.java index eb61af8874..662ed31b87 100644 --- a/impl/src/test/java/com/sun/faces/mock/MockExternalContextFactory.java +++ b/impl/src/test/java/com/sun/faces/mock/MockExternalContextFactory.java @@ -16,14 +16,13 @@ package com.sun.faces.mock; -import jakarta.servlet.ServletContext; -import jakarta.servlet.ServletRequest; -import jakarta.servlet.ServletResponse; - import jakarta.faces.FacesException; import jakarta.faces.FactoryFinder; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.ExternalContextFactory; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; public class MockExternalContextFactory extends ExternalContextFactory { diff --git a/impl/src/test/java/com/sun/faces/mock/MockFacesContextFactory.java b/impl/src/test/java/com/sun/faces/mock/MockFacesContextFactory.java index 6939db8d0b..59cdc6673e 100644 --- a/impl/src/test/java/com/sun/faces/mock/MockFacesContextFactory.java +++ b/impl/src/test/java/com/sun/faces/mock/MockFacesContextFactory.java @@ -17,10 +17,6 @@ package com.sun.faces.mock; import jakarta.el.ELContext; -import jakarta.servlet.ServletContext; -import jakarta.servlet.ServletRequest; -import jakarta.servlet.ServletResponse; - import jakarta.faces.FacesException; import jakarta.faces.FactoryFinder; import jakarta.faces.application.Application; @@ -29,6 +25,9 @@ import jakarta.faces.context.FacesContext; import jakarta.faces.context.FacesContextFactory; import jakarta.faces.lifecycle.Lifecycle; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; public class MockFacesContextFactory extends FacesContextFactory { public MockFacesContextFactory(FacesContextFactory oldImpl) { diff --git a/impl/src/test/java/com/sun/faces/mock/MockLifecycle.java b/impl/src/test/java/com/sun/faces/mock/MockLifecycle.java index a463f65ab7..8977b8c90b 100644 --- a/impl/src/test/java/com/sun/faces/mock/MockLifecycle.java +++ b/impl/src/test/java/com/sun/faces/mock/MockLifecycle.java @@ -16,13 +16,12 @@ package com.sun.faces.mock; -import jakarta.servlet.http.HttpServletResponse; - import jakarta.faces.FacesException; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; import jakarta.faces.event.PhaseListener; import jakarta.faces.lifecycle.Lifecycle; +import jakarta.servlet.http.HttpServletResponse; public class MockLifecycle extends Lifecycle { diff --git a/impl/src/test/java/com/sun/faces/mock/MockLifecycleFactory.java b/impl/src/test/java/com/sun/faces/mock/MockLifecycleFactory.java index e70a4a414e..4405d07d0d 100644 --- a/impl/src/test/java/com/sun/faces/mock/MockLifecycleFactory.java +++ b/impl/src/test/java/com/sun/faces/mock/MockLifecycleFactory.java @@ -16,14 +16,13 @@ package com.sun.faces.mock; +import java.util.ArrayList; import java.util.Iterator; import jakarta.faces.FactoryFinder; import jakarta.faces.lifecycle.Lifecycle; import jakarta.faces.lifecycle.LifecycleFactory; -import java.util.ArrayList; - public class MockLifecycleFactory extends LifecycleFactory { public MockLifecycleFactory(LifecycleFactory oldImpl) { diff --git a/impl/src/test/java/com/sun/faces/mock/MockServlet.java b/impl/src/test/java/com/sun/faces/mock/MockServlet.java index 6fb35a3267..d5264f2abf 100644 --- a/impl/src/test/java/com/sun/faces/mock/MockServlet.java +++ b/impl/src/test/java/com/sun/faces/mock/MockServlet.java @@ -17,6 +17,7 @@ package com.sun.faces.mock; import java.io.IOException; + import jakarta.servlet.Servlet; import jakarta.servlet.ServletConfig; import jakarta.servlet.ServletException; diff --git a/impl/src/test/java/com/sun/faces/mock/MockServletConfig.java b/impl/src/test/java/com/sun/faces/mock/MockServletConfig.java index 19e5bfa2b7..e838cee073 100644 --- a/impl/src/test/java/com/sun/faces/mock/MockServletConfig.java +++ b/impl/src/test/java/com/sun/faces/mock/MockServletConfig.java @@ -18,6 +18,7 @@ import java.util.Enumeration; import java.util.Hashtable; + import jakarta.servlet.ServletConfig; import jakarta.servlet.ServletContext; diff --git a/impl/src/test/java/com/sun/faces/renderkit/html_basic/BodyRendererTest.java b/impl/src/test/java/com/sun/faces/renderkit/html_basic/BodyRendererTest.java index 52048f9e5a..2f5b39dfb8 100644 --- a/impl/src/test/java/com/sun/faces/renderkit/html_basic/BodyRendererTest.java +++ b/impl/src/test/java/com/sun/faces/renderkit/html_basic/BodyRendererTest.java @@ -16,13 +16,14 @@ package com.sun.faces.renderkit.html_basic; +import static org.easymock.EasyMock.expect; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import java.util.Collections; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.easymock.EasyMock.expect; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.powermock.api.easymock.PowerMock; import jakarta.faces.application.Application; diff --git a/impl/src/test/java/com/sun/faces/renderkit/html_basic/HeadRendererTest.java b/impl/src/test/java/com/sun/faces/renderkit/html_basic/HeadRendererTest.java index 44be54f739..b8d0ef7758 100644 --- a/impl/src/test/java/com/sun/faces/renderkit/html_basic/HeadRendererTest.java +++ b/impl/src/test/java/com/sun/faces/renderkit/html_basic/HeadRendererTest.java @@ -16,12 +16,13 @@ package com.sun.faces.renderkit.html_basic; +import static org.easymock.EasyMock.expect; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import java.util.Collections; -import static org.junit.Assert.assertTrue; -import static org.easymock.EasyMock.expect; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.powermock.api.easymock.PowerMock; import jakarta.faces.component.UIViewRoot; diff --git a/impl/src/test/java/com/sun/faces/renderkit/html_basic/HtmlResponseWriterTest.java b/impl/src/test/java/com/sun/faces/renderkit/html_basic/HtmlResponseWriterTest.java index 83d1d22629..a768502b0b 100644 --- a/impl/src/test/java/com/sun/faces/renderkit/html_basic/HtmlResponseWriterTest.java +++ b/impl/src/test/java/com/sun/faces/renderkit/html_basic/HtmlResponseWriterTest.java @@ -16,19 +16,21 @@ package com.sun.faces.renderkit.html_basic; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.StringWriter; import java.io.Writer; import java.lang.reflect.Field; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import jakarta.faces.component.UIComponent; import jakarta.faces.component.UIOutput; import jakarta.faces.context.FacesContext; -import static org.junit.Assert.*; - public class HtmlResponseWriterTest { /** diff --git a/impl/src/test/java/com/sun/faces/spi/ConfigurationResourceProviderFactoryTest.java b/impl/src/test/java/com/sun/faces/spi/ConfigurationResourceProviderFactoryTest.java index fba1e9ac76..9f3ec3a0d3 100644 --- a/impl/src/test/java/com/sun/faces/spi/ConfigurationResourceProviderFactoryTest.java +++ b/impl/src/test/java/com/sun/faces/spi/ConfigurationResourceProviderFactoryTest.java @@ -1,13 +1,16 @@ package com.sun.faces.spi; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; +import org.junit.jupiter.api.Test; + import com.sun.faces.spi.ConfigurationResourceProviderFactory.ProviderType; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; /** * Tests {@link ConfigurationResourceProviderFactory}. @@ -52,7 +55,7 @@ public void testCreateProvidersSuccessful() throws FileNotFoundException { * @throws FileNotFoundException * Thrown when the test service file can't be written. */ - @Test(expected = IllegalStateException.class) + @Test public void testCreateProvidersWrongService() throws FileNotFoundException { ProviderType facesConfig = ProviderType.FacesConfig; @@ -65,7 +68,7 @@ public void testCreateProvidersWrongService() throws FileNotFoundException { } try { - ConfigurationResourceProviderFactory.createProviders(facesConfig); + assertThrows(IllegalStateException.class, () -> ConfigurationResourceProviderFactory.createProviders(facesConfig)); } finally { servicesFile.delete(); } diff --git a/impl/src/test/java/com/sun/faces/util/ByteArrayGuardAESCTRTest.java b/impl/src/test/java/com/sun/faces/util/ByteArrayGuardAESCTRTest.java index 50ccaf5de7..d4740f76b6 100644 --- a/impl/src/test/java/com/sun/faces/util/ByteArrayGuardAESCTRTest.java +++ b/impl/src/test/java/com/sun/faces/util/ByteArrayGuardAESCTRTest.java @@ -16,16 +16,19 @@ package com.sun.faces.util; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.security.InvalidKeyException; -import jakarta.xml.bind.DatatypeConverter; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; + +import jakarta.xml.bind.DatatypeConverter; public class ByteArrayGuardAESCTRTest { - + @Test public void testSmallerSizeBytes() throws Exception { ByteArrayGuardAESCTR guard = new ByteArrayGuardAESCTR(); @@ -34,22 +37,22 @@ public void testSmallerSizeBytes() throws Exception { String value = "1fX_2vX"; String encrypted = guard.encrypt(value); assertTrue(encrypted.length() < 33); - + String decryptedValue = guard.decrypt(encrypted); assertEquals(decryptedValue, value); - + } - - @Test(expected = InvalidKeyException.class) + + @Test public void testDecryptValueWithoutIvBytes() throws InvalidKeyException { ByteArrayGuardAESCTR sut = new ByteArrayGuardAESCTR(); - + String value = "noIV"; byte[] bytes = DatatypeConverter.parseBase64Binary(value); assertTrue(bytes.length < 16); - sut.decrypt(value); + assertThrows(InvalidKeyException.class, () -> sut.decrypt(value)); } } diff --git a/impl/src/test/java/com/sun/faces/util/FacesLoggerTest.java b/impl/src/test/java/com/sun/faces/util/FacesLoggerTest.java index b4d0830c71..95244f8e4c 100644 --- a/impl/src/test/java/com/sun/faces/util/FacesLoggerTest.java +++ b/impl/src/test/java/com/sun/faces/util/FacesLoggerTest.java @@ -1,14 +1,16 @@ package com.sun.faces.util; +import java.util.Locale; + +import org.easymock.EasyMock; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + import com.sun.faces.mock.MockApplication; import com.sun.faces.mock.MockFacesContext; + import jakarta.el.ELContext; import jakarta.faces.component.UIViewRoot; -import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Locale; public class FacesLoggerTest { @@ -23,7 +25,7 @@ public void unresolvedNavigationUS() { final Object[] params = {"componentId1", "outcome.xhtml", "viewId.xhtml"}; Locale.setDefault(new Locale("en", "US")); final String result = FacesLogger.RENDERKIT.interpolateMessage(facesContext, "faces.outcometarget.navigation.case.not.resolved", params); - Assert.assertEquals("JSF1090: Navigation case outcome.xhtml not resolved for component componentId1 in viewId viewId.xhtml", result); + Assertions.assertEquals("JSF1090: Navigation case outcome.xhtml not resolved for component componentId1 in viewId viewId.xhtml", result); } @@ -38,6 +40,6 @@ public void unresolvedNavigationGermany() { final Object[] params = {"componentId1", "outcome.xhtml", "viewId.xhtml"}; Locale.setDefault(new Locale("de", "DE")); final String result = FacesLogger.RENDERKIT.interpolateMessage(facesContext, "faces.outcometarget.navigation.case.not.resolved", params); - Assert.assertEquals("JSF1090: Navigations-Fall wurde für Komponente componentId1 nicht aufgelöst.", result); + Assertions.assertEquals("JSF1090: Navigations-Fall wurde für Komponente componentId1 nicht aufgelöst.", result); } } diff --git a/impl/src/test/java/com/sun/faces/util/MostlySingletonTest.java b/impl/src/test/java/com/sun/faces/util/MostlySingletonTest.java index 26ead141bf..310ea86ed9 100644 --- a/impl/src/test/java/com/sun/faces/util/MostlySingletonTest.java +++ b/impl/src/test/java/com/sun/faces/util/MostlySingletonTest.java @@ -16,10 +16,12 @@ package com.sun.faces.util; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.HashSet; import java.util.Set; -import org.junit.Test; -import static org.junit.Assert.*; + +import org.junit.jupiter.api.Test; public class MostlySingletonTest { diff --git a/impl/src/test/java/com/sun/faces/util/TestHtmlUtils.java b/impl/src/test/java/com/sun/faces/util/TestHtmlUtils.java index f585413391..55255644ae 100644 --- a/impl/src/test/java/com/sun/faces/util/TestHtmlUtils.java +++ b/impl/src/test/java/com/sun/faces/util/TestHtmlUtils.java @@ -16,17 +16,20 @@ // TestHtmlUtils.java package com.sun.faces.util; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.io.StringWriter; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; /** * TestHtmlUtils is a class ... */ -public class TestHtmlUtils extends TestCase { +public class TestHtmlUtils { + @Test public void testWriteURL() throws IOException { //Test url with no params testURLEncoding("http://www.google.com", @@ -66,6 +69,7 @@ public void testWriteURL() throws IOException { "/index.jsf?greek=%CE%B5%CE%BB&cyrillic=%D0%BA%D0%B8&hebrew=%D7%99%D7%AA&arabic=%D9%8A%D8%A9%D9%8F%E2%80%8E%E2%80%8E&korean=%ED%95%9C%EA%B8%80"); } + @Test public void testControlCharacters() throws IOException { final char[] controlCharacters = new char[32]; diff --git a/impl/src/test/java/com/sun/faces/util/TestLRUMap_local.java b/impl/src/test/java/com/sun/faces/util/TestLRUMap_local.java index 4a4eaf1425..60e54e28c8 100644 --- a/impl/src/test/java/com/sun/faces/util/TestLRUMap_local.java +++ b/impl/src/test/java/com/sun/faces/util/TestLRUMap_local.java @@ -15,31 +15,24 @@ */ package com.sun.faces.util; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; -import java.util.List; import java.util.Collections; +import java.util.List; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; /** * Validate LRU functionality of LRUMap */ -public class TestLRUMap_local extends TestCase { - - // ------------------------------------------------------------ Constructors - public TestLRUMap_local() { - super("TestLRUMap_local"); - } - - public TestLRUMap_local(String name) { - super(name); - } +public class TestLRUMap_local { // ------------------------------------------------------------ Test Methods /** * Ensure that LRUMap works as advertised. */ + @Test public void testLRUMap() { LRUMap map = new LRUMap(5); diff --git a/impl/src/test/java/com/sun/faces/util/TestUtil_local.java b/impl/src/test/java/com/sun/faces/util/TestUtil_local.java index 8e6987494e..404bad4b68 100644 --- a/impl/src/test/java/com/sun/faces/util/TestUtil_local.java +++ b/impl/src/test/java/com/sun/faces/util/TestUtil_local.java @@ -17,46 +17,23 @@ // TestUtil_local.java package com.sun.faces.util; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; import java.util.HashMap; +import org.junit.jupiter.api.Test; /** * TestUtil_local.java is a class ... - * + * * Lifetime And Scope *

* */ -public class TestUtil_local extends TestCase { - -// -// Protected Constants -// -// Class Variables -// -// -// Instance Variables -// -// Attribute Instance Variables -// Relationship Instance Variables -// -// Constructors and Initializers -// - public TestUtil_local() { - super("TestUtil_local.java"); - } +public class TestUtil_local { - public TestUtil_local(String name) { - super(name); - } - -// -// Class methods -// -// -// General Methods -// + @Test public void testGetLocaleFromString() { // positive tests assertNotNull(Util.getLocaleFromString("ps")); @@ -90,23 +67,25 @@ public void testGetLocaleFromString() { } catch (Exception exception) { } } - + + @Test public void testSplit() { String[] result = null; - + result = Util.split(new HashMap(), "fooBarKey=Zm9vQmFyVmFsdWU====", "=", 2); assertEquals(2, result.length); assertEquals(result[1], "Zm9vQmFyVmFsdWU===="); - + result = Util.split(new HashMap(), "fooBarKey=Zm9vQmFyVmFsdWU=", "=", 2); assertEquals(2, result.length); assertEquals(result[1], "Zm9vQmFyVmFsdWU="); - + result = Util.split(new HashMap(), "fooBarKey2=Zm9vQmFyVmFsdWUy", "=", 2); assertEquals(2, result.length); assertEquals(result[1], "Zm9vQmFyVmFsdWUy"); } + @Test public void testExtractFirstNumericSegment() { char separatorChar = ':'; @@ -132,5 +111,5 @@ public void testExtractFirstNumericSegment() { assertEquals("there is no numeric segment", e.getMessage()); } } - + } // end of class TestUtil_local diff --git a/impl/src/test/java/com/sun/faces/xml/ParseXMLTestCase.java b/impl/src/test/java/com/sun/faces/xml/ParseXMLTestCase.java index 1e5976421a..93a90d6f83 100644 --- a/impl/src/test/java/com/sun/faces/xml/ParseXMLTestCase.java +++ b/impl/src/test/java/com/sun/faces/xml/ParseXMLTestCase.java @@ -16,6 +16,8 @@ package com.sun.faces.xml; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.io.FileInputStream; import java.util.ArrayList; @@ -24,34 +26,19 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import org.junit.jupiter.api.Test; import org.xml.sax.InputSource; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class ParseXMLTestCase extends TestCase { +public class ParseXMLTestCase { List list = new ArrayList<>(); private final static String xmlDir = "/conf/share"; - public ParseXMLTestCase(String name) { - super(name); - } - - @Override - public void setUp() throws Exception { - super.setUp(); - } - - public static Test suite() { - return (new TestSuite(ParseXMLTestCase.class)); - } - // ------------------------------------------------------------ Test Methods /** * Added for issue 904. */ + @Test public void testParseXML() throws Exception { String curDir = System.getProperty("user.dir"); @@ -81,7 +68,7 @@ public void testParseXML() throws Exception { } // Process all files and directories under dir - public void visitAllDirsAndFiles(File dir) { + private void visitAllDirsAndFiles(File dir) { if (dir.isFile()) { if (isXML(dir)) { @@ -96,7 +83,7 @@ public void visitAllDirsAndFiles(File dir) { } } - public boolean isXML(File file) { + private boolean isXML(File file) { String name = file.getName(); return name.endsWith(".xml"); } diff --git a/impl/src/test/java/com/sun/faces/xml/XHTMLResolvingHandler.java b/impl/src/test/java/com/sun/faces/xml/XHTMLResolvingHandler.java index 766ca44be3..3fde265a21 100644 --- a/impl/src/test/java/com/sun/faces/xml/XHTMLResolvingHandler.java +++ b/impl/src/test/java/com/sun/faces/xml/XHTMLResolvingHandler.java @@ -24,6 +24,7 @@ import java.io.UnsupportedEncodingException; import java.util.Locale; import java.util.ResourceBundle; + import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; diff --git a/impl/src/test/java/jakarta/faces/FacesConfigOrderingTestCase.java b/impl/src/test/java/jakarta/faces/FacesConfigOrderingTestCase.java index c072c4fd98..32a0eab13a 100644 --- a/impl/src/test/java/jakarta/faces/FacesConfigOrderingTestCase.java +++ b/impl/src/test/java/jakarta/faces/FacesConfigOrderingTestCase.java @@ -17,6 +17,7 @@ package jakarta.faces; import static com.sun.faces.util.Util.createLocalDocumentBuilderFactory; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Method; import java.util.ArrayList; @@ -27,6 +28,8 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -34,29 +37,13 @@ import com.sun.faces.config.manager.documents.DocumentOrderingWrapper; import jakarta.faces.context.FacesContext; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -public class FacesConfigOrderingTestCase extends TestCase { - - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name - * Name of the test case - */ - public FacesConfigOrderingTestCase(String name) { - super(name); - } +public class FacesConfigOrderingTestCase { // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. - @Override + @BeforeEach public void setUp() throws Exception { - super.setUp(); - Method method = FacesContext.class.getDeclaredMethod( "setCurrentInstance", FacesContext.class); method.setAccessible(true); @@ -64,17 +51,6 @@ public void setUp() throws Exception { } - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(FacesConfigOrderingTestCase.class)); - } - - // Tear down instance variables required by ths test case - @Override - public void tearDown() throws Exception { - super.tearDown(); - } - // ------------------------------------------------- Individual Test Methods /** *

@@ -84,6 +60,7 @@ public void tearDown() throws Exception { * * @throws java.lang.Exception */ + @Test public void testNoOrderingStartWithCab() throws Exception { DocumentInfo docC = createDocument("C", null, null); DocumentInfo doca = createDocument("a", null, null); @@ -113,10 +90,11 @@ public void testNoOrderingStartWithCab() throws Exception { boolean assertion = (actually.equals(possibility1)); String message = "\n original: " + original + "\n expected: " + possibility1 + "\n actually: " + actually + "\n"; - assertTrue(message, assertion); + assertTrue(assertion, message); System.out.println("testNoOrderingStartWithCab: Passed" + message); } - + + @Test public void testCafteraStartWithCab() throws Exception { List docCAfterIds = new ArrayList(); Collections.addAll(docCAfterIds, "a"); @@ -150,10 +128,11 @@ public void testCafteraStartWithCab() throws Exception { boolean assertion = (actually.equals(possibility1)); String message = "\n original: " + original + "\n expected: " + possibility1 + "\n actually: " + actually + "\n"; - assertTrue(message, assertion); + assertTrue(assertion, message); System.out.println("testCafteraStartWithCab: Passed" + message); } - + + @Test public void testAafterD_BafterCbeforeOthers_CafterDbeforeB_startWithABCD() throws Exception { List docAAfterIds = new ArrayList(); Collections.addAll(docAAfterIds, "D"); @@ -203,10 +182,11 @@ public void testAafterD_BafterCbeforeOthers_CafterDbeforeB_startWithABCD() throw ); String message = "\n original: " + original + "\n expected: " + possibility1 + "\n actually: " + actually + "\n"; - assertTrue(message, assertion); + assertTrue(assertion, message); System.out.println("testAafterD_BafterCbeforeOthers_CafterDbeforeB_startWithABCD: Passed" + message); } - + + @Test public void testAafterD_BafterCbeforeOthers_CafterDbeforeB_startWithADBC() throws Exception { List docAAfterIds = new ArrayList(); @@ -257,11 +237,12 @@ public void testAafterD_BafterCbeforeOthers_CafterDbeforeB_startWithADBC() throw ); String message = "\n original: " + original + "\n expected: " + possibility1 + "\n actually: " + actually + "\n"; - assertTrue(message, assertion); + assertTrue(assertion, message); System.out.println("testAafterD_BafterCbeforeOthers_CafterDbeforeB_startWithADBC: Passed" + message); } - + + @Test public void testAafterD_BafterCbeforeOthers_CafterDbeforeB_shuffle() throws Exception { List docAAfterIds = new ArrayList(); @@ -294,38 +275,38 @@ public void testAafterD_BafterCbeforeOthers_CafterDbeforeB_shuffle() throws Exce new DocumentOrderingWrapper(docD) ); //J+ - + int number = 100; for (int i = 0; i < number; i++) { - + Collections.shuffle(documents); - + DocumentOrderingWrapper[] wrappers = documents.toArray(new DocumentOrderingWrapper[documents.size()]); String[] originalOrder = extractNames(wrappers); DocumentOrderingWrapper.sort(wrappers); - + String[] orderedNames = extractNames(wrappers); - + // some solutions: // [D, C, B, A] // [D, A, C, B] List original = Arrays.asList(originalOrder); List actually = Arrays.asList(orderedNames); - + List possibility1 = Arrays.asList("D", "C", "B", "A"); List possibility2 = Arrays.asList("D", "A", "C", "B"); - + boolean assertion = (actually.equals(possibility1) || actually.equals(possibility2) ); - String message = "\n original: " + original + + String message = "\n original: " + original + "\n expected: " + possibility1 + "\n or: " + possibility2 + "\n actually: " + actually + "\n"; - assertTrue(message, assertion); - + assertTrue(assertion, message); + } - + System.out.println("testAafterD_BafterCbeforeOthers_CafterDbeforeB_shuffle: " + number + " shuffles passed."); } @@ -359,7 +340,7 @@ private DocumentInfo createDocument(String documentId, return new DocumentInfo(document, null); } - + public static String[] extractNames(DocumentOrderingWrapper[] documents) { String[] extractedNames = new String[documents.length]; int i = 0; diff --git a/impl/src/test/java/jakarta/faces/FacesWrapperTestCase.java b/impl/src/test/java/jakarta/faces/FacesWrapperTestCase.java index f456c07f65..f8c6c76daa 100644 --- a/impl/src/test/java/jakarta/faces/FacesWrapperTestCase.java +++ b/impl/src/test/java/jakarta/faces/FacesWrapperTestCase.java @@ -16,6 +16,9 @@ package jakarta.faces; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -23,7 +26,8 @@ import java.util.Arrays; import java.util.List; -import junit.framework.TestCase; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** *

@@ -32,7 +36,7 @@ * should help to keep the wrapper classes in synch with the wrapped classes. *

*/ -public class FacesWrapperTestCase extends TestCase { +public class FacesWrapperTestCase { private static List> wrapperClasses; private static List> noWrapperClasses; @@ -44,8 +48,8 @@ public class FacesWrapperTestCase extends TestCase { * implementing FacesWrapper. * @throws java.lang.Exception */ - @Override - protected void setUp() throws Exception { + @BeforeEach + public void setUp() throws Exception { if (wrapperClasses == null) { loadWrapperClasses(); methodsToIgnore = new ArrayList(); @@ -56,22 +60,24 @@ protected void setUp() throws Exception { /** * Unit test to assert wrapperClasses list was loaded (see {@link #setUp()}. */ + @Test public void testWrapperClassesLoaded() { assertNotNull(wrapperClasses); - assertTrue("no wrapper classes found!", !wrapperClasses.isEmpty()); + assertTrue(!wrapperClasses.isEmpty()); } /** * Unit test to assert there are no *Wrapper classes not implementing * FacesWrapper. */ + @Test public void testWrapperClassesImplementFacesWrapper() { assertNotNull(noWrapperClasses); if (noWrapperClasses.size() > 0) { System.out.println("Wrapper classes not implementing jakarta.faces.FacesWrapper:"); System.out.println(noWrapperClasses.toString()); } - assertTrue("Found wrapper classes not implementing FacesWrapper!", noWrapperClasses + assertTrue(noWrapperClasses .isEmpty()); } @@ -80,6 +86,7 @@ public void testWrapperClassesImplementFacesWrapper() { * implementing FacesWrapper do wrap all public and protected methods of the * wrapped class. */ + @Test public void testWrapperClassWrapsPublicAndProtectedMethods() { for (Class wrapper : wrapperClasses) { if (wrapper.isInterface()) { @@ -95,7 +102,7 @@ public void testWrapperClassWrapsPublicAndProtectedMethods() { if (isMethodContained(m, methodsToIgnore)) { continue; } - assertTrue(msg + m.toString(), isMethodContained(m, wrapperMethods)); + assertTrue(isMethodContained(m, wrapperMethods), msg + m.toString()); } } } @@ -154,8 +161,8 @@ private void loadWrapperClasses() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); try { collectWrapperClasses( - classLoader, - JAVAX_FACES_PKG, + classLoader, + JAVAX_FACES_PKG, new File(classLoader.getResource("jakarta/faces/Messages.properties").getFile()) .getParentFile()); } catch (Exception e) { diff --git a/impl/src/test/java/jakarta/faces/FactoryFinderTestCase.java b/impl/src/test/java/jakarta/faces/FactoryFinderTestCase.java index dce43b0c2d..4dc3fbe6f1 100644 --- a/impl/src/test/java/jakarta/faces/FactoryFinderTestCase.java +++ b/impl/src/test/java/jakarta/faces/FactoryFinderTestCase.java @@ -16,6 +16,17 @@ package jakarta.faces; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.File; +import java.io.PrintWriter; +import java.lang.reflect.Method; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.faces.mock.MockHttpServletRequest; import com.sun.faces.mock.MockHttpServletResponse; import com.sun.faces.mock.MockServletContext; @@ -27,25 +38,7 @@ import jakarta.faces.lifecycle.Lifecycle; import jakarta.faces.lifecycle.LifecycleFactory; -import java.io.File; -import java.io.PrintWriter; -import java.lang.reflect.Method; - -import junit.framework.TestCase; -import junit.framework.Test; -import junit.framework.TestSuite; - -public class FactoryFinderTestCase extends TestCase { - - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public FactoryFinderTestCase(String name) { - super(name); - } +public class FactoryFinderTestCase { public static String FACTORIES[][] = { {FactoryFinder.APPLICATION_FACTORY, @@ -67,10 +60,8 @@ public FactoryFinderTestCase(String name) { // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. - @Override + @BeforeEach public void setUp() throws Exception { - super.setUp(); - Method method = FacesContext.class.getDeclaredMethod("setCurrentInstance", FacesContext.class); method.setAccessible(true); method.invoke(null, new Object[]{null}); @@ -80,15 +71,9 @@ public void setUp() throws Exception { } } - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(FactoryFinderTestCase.class)); - } - // Tear down instance variables required by ths test case - @Override + @AfterEach public void tearDown() throws Exception { - super.tearDown(); FactoryFinder.releaseFactories(); for (int i = 0, len = FACTORIES.length; i < len; i++) { System.getProperties().remove(FACTORIES[i][0]); @@ -103,6 +88,7 @@ public void tearDown() throws Exception { * * @throws java.lang.Exception */ + @Test public void testFacesConfigCase() throws Exception { Object factory = null; Class clazz = null; @@ -122,7 +108,7 @@ public void testFacesConfigCase() throws Exception { servicesDir.mkdirs(); File servicesFile = new File(servicesDir, "jakarta.faces.context.FacesContextFactory"); - + if (servicesFile.exists()) { servicesFile.delete(); } @@ -130,12 +116,12 @@ public void testFacesConfigCase() throws Exception { writer.println("jakarta.faces.mock.MockFacesContextFactoryExtender"); writer.flush(); writer.close(); - + File cServicesDir = new File(System.getProperty("basedir"), "target/generated-classes/cobertura/META-INF/services"); cServicesDir.mkdirs(); File cServicesFile = new File(cServicesDir, "jakarta.faces.context.FacesContextFactory"); - + if (cServicesFile.exists()) { cServicesFile.delete(); } @@ -151,19 +137,19 @@ public void testFacesConfigCase() throws Exception { for (i = 0, len = FACTORIES.length; i < len; i++) { clazz = Class.forName(FACTORIES[i][0]); factory = FactoryFinder.getFactory(FACTORIES[i][0]); - assertTrue("Factory for " + clazz.getName() - + " not of expected type.", - clazz.isAssignableFrom(factory.getClass())); + assertTrue( + clazz.isAssignableFrom(factory.getClass()), "Factory for " + clazz.getName() + + " not of expected type."); clazz = Class.forName(FACTORIES[i][1]); - assertTrue("Factory " + FACTORIES[i][1] + " not of expected type", - clazz.isAssignableFrom(factory.getClass())); + assertTrue( + clazz.isAssignableFrom(factory.getClass()), "Factory " + FACTORIES[i][1] + " not of expected type"); } // verify that the delegation works assertTrue(System.getProperty(FACTORIES[2][0]).equals("jakarta.faces.mock.MockFacesContextFactoryExtender2")); assertTrue(System.getProperty("oldImpl").equals("jakarta.faces.mock.MockFacesContextFactoryExtender")); - // Verify IllegalStateException when factory not found + // Verify IllegalStateException when factory not found FactoryFinder.releaseFactories(); FactoryFinder.setFactory(FACTORIES[0][0], FACTORIES[0][1]); FactoryFinder.setFactory(FACTORIES[1][0], FACTORIES[1][1]); @@ -182,6 +168,7 @@ public void testFacesConfigCase() throws Exception { } // TODO re-enable + @Test public void testNoFacesContext() throws Exception { // assertNull(FacesContext.getCurrentInstance()); // Object result = FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); @@ -196,6 +183,7 @@ public void testNoFacesContext() throws Exception { * * @throws java.lang.Exception */ + @Test public void testServicesCase() throws Exception { Object factory = null; Class clazz = null; @@ -215,25 +203,25 @@ public void testServicesCase() throws Exception { servicesDir.mkdirs(); File servicesFile = new File(servicesDir, "jakarta.faces.context.FacesContextFactory"); - + if (servicesFile.exists()) { servicesFile.delete(); } - + PrintWriter writer = new PrintWriter(servicesFile); writer.println("jakarta.faces.mock.MockFacesContextFactoryExtender"); writer.flush(); writer.close(); - + File cServicesDir = new File(System.getProperty("basedir"), "target/generated-classes/cobertura/META-INF/services"); cServicesDir.mkdirs(); File cServicesFile = new File(cServicesDir, "jakarta.faces.context.FacesContextFactory"); - + if (cServicesFile.exists()) { cServicesFile.delete(); } - + PrintWriter cWriter = new PrintWriter(cServicesFile); cWriter.println("jakarta.faces.mock.MockFacesContextFactoryExtender"); cWriter.flush(); @@ -243,12 +231,12 @@ public void testServicesCase() throws Exception { for (i = 0, len = FACTORIES.length; i < len; i++) { clazz = Class.forName(FACTORIES[i][0]); factory = FactoryFinder.getFactory(FACTORIES[i][0]); - assertTrue("Factory for " + clazz.getName() - + " not of expected type.", - clazz.isAssignableFrom(factory.getClass())); + assertTrue( + clazz.isAssignableFrom(factory.getClass()), "Factory for " + clazz.getName() + + " not of expected type."); clazz = Class.forName(FACTORIES[i][1]); - assertTrue("Factory " + FACTORIES[i][1] + " not of expected type", - clazz.isAssignableFrom(factory.getClass())); + assertTrue( + clazz.isAssignableFrom(factory.getClass()), "Factory " + FACTORIES[i][1] + " not of expected type"); } // verify that the delegation works @@ -259,6 +247,7 @@ public void testServicesCase() throws Exception { cServicesFile.delete(); } + @Test public void testNoFacesContextInitially() throws Exception { assertNull(FacesContext.getCurrentInstance()); diff --git a/impl/src/test/java/jakarta/faces/FactoryFinderTestCase2.java b/impl/src/test/java/jakarta/faces/FactoryFinderTestCase2.java index e28e84c25c..8b91e1f928 100644 --- a/impl/src/test/java/jakarta/faces/FactoryFinderTestCase2.java +++ b/impl/src/test/java/jakarta/faces/FactoryFinderTestCase2.java @@ -16,59 +16,44 @@ package jakarta.faces; -import junit.framework.TestCase; -import junit.framework.Test; -import junit.framework.TestSuite; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class FactoryFinderTestCase2 extends TestCase { +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class FactoryFinderTestCase2 { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public FactoryFinderTestCase2(String name) { - super(name); - } - public static String FACTORIES[][] = { - { FactoryFinder.APPLICATION_FACTORY, + { FactoryFinder.APPLICATION_FACTORY, "com.sun.faces.mock.MockApplicationFactory" }, - { FactoryFinder.EXTERNAL_CONTEXT_FACTORY, + { FactoryFinder.EXTERNAL_CONTEXT_FACTORY, "com.sun.faces.mock.MockExternalContextFactory" }, - { FactoryFinder.FACES_CONTEXT_FACTORY, + { FactoryFinder.FACES_CONTEXT_FACTORY, "com.sun.faces.mock.MockFacesContextFactory" }, - { FactoryFinder.LIFECYCLE_FACTORY, + { FactoryFinder.LIFECYCLE_FACTORY, "com.sun.faces.mock.MockLifecycleFactory" }, - { FactoryFinder.RENDER_KIT_FACTORY, + { FactoryFinder.RENDER_KIT_FACTORY, "com.sun.faces.mock.MockRenderKitFactory" } }; // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. - @Override + @BeforeEach public void setUp() throws Exception { - super.setUp(); for (int i = 0, len = FactoryFinderTestCase2.FACTORIES.length; i < len; i++) { System.getProperties().remove(FactoryFinderTestCase2.FACTORIES[i][0]); } } - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(FactoryFinderTestCase2.class)); - } - // Tear down instance variables required by ths test case - @Override + @AfterEach public void tearDown() throws Exception { - super.tearDown(); FactoryFinder.releaseFactories(); for (int i = 0, len = FactoryFinderTestCase2.FACTORIES.length; i < len; i++) { System.getProperties().remove(FactoryFinderTestCase2.FACTORIES[i][0]); @@ -83,6 +68,7 @@ public void tearDown() throws Exception { * precedence.

* @throws java.lang.Exception */ + @Test public void testJSFImplCase() throws Exception { Object factory = null; Class clazz = null; @@ -100,12 +86,12 @@ public void testJSFImplCase() throws Exception { for (i = 0, len = FactoryFinderTestCase2.FACTORIES.length; i < len; i++) { clazz = Class.forName(FactoryFinderTestCase2.FACTORIES[i][0]); factory = FactoryFinder.getFactory(FactoryFinderTestCase2.FACTORIES[i][0]); - assertTrue("Factory for " + clazz.getName() - + " not of expected type.", - clazz.isAssignableFrom(factory.getClass())); + assertTrue( + clazz.isAssignableFrom(factory.getClass()), "Factory for " + clazz.getName() + + " not of expected type."); clazz = Class.forName(FactoryFinderTestCase2.FACTORIES[i][1]); - assertTrue("Factory " + FactoryFinderTestCase2.FACTORIES[i][1] + " not of expected type", - clazz.isAssignableFrom(factory.getClass())); + assertTrue( + clazz.isAssignableFrom(factory.getClass()), "Factory " + FactoryFinderTestCase2.FACTORIES[i][1] + " not of expected type"); } } } diff --git a/impl/src/test/java/jakarta/faces/component/NamingContainerTestCase.java b/impl/src/test/java/jakarta/faces/component/NamingContainerTestCase.java index c83be918e7..716212a50c 100644 --- a/impl/src/test/java/jakarta/faces/component/NamingContainerTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/NamingContainerTestCase.java @@ -16,17 +16,23 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.faces.junit.JUnitFacesTestCaseBase; import com.sun.faces.mock.MockRenderKit; import jakarta.faces.FactoryFinder; import jakarta.faces.render.RenderKit; import jakarta.faces.render.RenderKitFactory; -import junit.framework.Test; -import junit.framework.TestSuite; /** *

@@ -39,15 +45,10 @@ public class NamingContainerTestCase extends JUnitFacesTestCaseBase { // The root of the component tree to be tested private UIViewRoot root = null; - // ------------------------------------------------------------ Constructors - // Construct a new instance of this test case. - public NamingContainerTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); @@ -67,15 +68,9 @@ public void setUp() throws Exception { } - // Return the tests included in this test case. - public static Test suite() { - - return new TestSuite(NamingContainerTestCase.class); - - } - // Tear down instance variables required by this test case. @Override + @AfterEach public void tearDown() throws Exception { root = null; @@ -84,6 +79,7 @@ public void tearDown() throws Exception { // ------------------------------------------------- Individual Test Methods // Test nested NamingContainer callbacks + @Test public void testNested() { NamingContainerTestImpl a = new NamingContainerTestImpl(); @@ -134,6 +130,7 @@ public void testNested() { } // Test nested NamingContainer callbacks + @Test public void testNested2() { NamingContainerTestImpl a = new NamingContainerTestImpl(); @@ -184,6 +181,7 @@ public void testNested2() { } // Test standard NamingContainer functionality + @Test public void testStandard() { // Set up a component hierarchy as follows (component ids in quotes): diff --git a/impl/src/test/java/jakarta/faces/component/SearchExpressionHandlerTest.java b/impl/src/test/java/jakarta/faces/component/SearchExpressionHandlerTest.java index c2f87d76e5..85062251bc 100644 --- a/impl/src/test/java/jakarta/faces/component/SearchExpressionHandlerTest.java +++ b/impl/src/test/java/jakarta/faces/component/SearchExpressionHandlerTest.java @@ -16,13 +16,22 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; -import org.junit.Assert; +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 com.sun.faces.component.search.CompositeSearchKeywordResolver; import com.sun.faces.component.search.SearchExpressionContextFactoryImpl; @@ -57,11 +66,8 @@ public class SearchExpressionHandlerTest extends JUnitFacesTestCaseBase { - public SearchExpressionHandlerTest(String name) { - super(name); - } - @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); @@ -99,6 +105,7 @@ public void setUp() throws Exception { } @Override + @AfterEach public void tearDown() throws Exception { super.tearDown(); } @@ -153,6 +160,7 @@ public void invokeContextCallback(FacesContext context, UIComponent target) { } } + @Test public void test_ResolveComponent_Parent() { UIComponent root = new UIPanel(); @@ -172,9 +180,10 @@ public void test_ResolveComponent_Parent() { UIComponent source = new UICommand(); innerContainer.getChildren().add(source); - assertSame("Failed", innerContainer, resolveComponent(source, "@parent")); + assertSame(innerContainer, resolveComponent(source, "@parent")); } + @Test public void test_ResolveComponent_ParentParent() { UIComponent root = new UIPanel(); @@ -194,9 +203,10 @@ public void test_ResolveComponent_ParentParent() { UIComponent source = new UICommand(); innerContainer.getChildren().add(source); - assertSame("Failed", outerContainer, resolveComponent(source, "@parent:@parent")); + assertSame(outerContainer, resolveComponent(source, "@parent:@parent")); } + @Test public void test_ResolveComponent_Form() { UIComponent root = new UIPanel(); @@ -216,9 +226,10 @@ public void test_ResolveComponent_Form() { UIComponent source = new UICommand(); innerContainer.getChildren().add(source); - assertSame("Failed", form, resolveComponent(source, "@form")); + assertSame(form, resolveComponent(source, "@form")); } + @Test public void test_ResolveComponent_FormParent() { UIComponent root = new UIPanel(); @@ -238,9 +249,10 @@ public void test_ResolveComponent_FormParent() { UIComponent source = new UICommand(); innerContainer.getChildren().add(source); - assertSame("Failed", root, resolveComponent(source, "@form:@parent")); + assertSame(root, resolveComponent(source, "@form:@parent")); } + @Test public void test_ResolveComponent_All() { UIComponent root = new UIPanel(); @@ -260,9 +272,10 @@ public void test_ResolveComponent_All() { UIComponent source = new UICommand(); innerContainer.getChildren().add(source); - assertSame("Failed", root, resolveComponent(source, "@all")); + assertSame(root, resolveComponent(source, "@all")); } + @Test public void test_ResolveComponent_This() { UIComponent root = new UIPanel(); @@ -282,9 +295,10 @@ public void test_ResolveComponent_This() { UIComponent source = new UICommand(); innerContainer.getChildren().add(source); - assertSame("Failed", source, resolveComponent(source, "@this")); + assertSame(source, resolveComponent(source, "@this")); } + @Test public void test_ResolveComponent_ThisParent() { UIComponent root = new UIPanel(); @@ -304,9 +318,10 @@ public void test_ResolveComponent_ThisParent() { UIComponent source = new UICommand(); innerContainer.getChildren().add(source); - assertSame("Failed", innerContainer, resolveComponent(source, "@this:@parent")); + assertSame(innerContainer, resolveComponent(source, "@this:@parent")); } + @Test public void test_ResolveComponent_Namingcontainer() { UIComponent root = new UIPanel(); @@ -326,9 +341,10 @@ public void test_ResolveComponent_Namingcontainer() { UIComponent source = new UICommand(); innerContainer.getChildren().add(source); - assertSame("Failed", innerContainer, resolveComponent(source, "@namingcontainer")); + assertSame(innerContainer, resolveComponent(source, "@namingcontainer")); } + @Test public void test_ResolveComponent_Absolute() { UIComponent root = new UIPanel(); @@ -353,9 +369,10 @@ public void test_ResolveComponent_Absolute() { source.setId("source"); innerContainer.getChildren().add(source); - assertSame("Failed", source, resolveComponent(source, " :form:outerContainer:innerContainer:source ")); + assertSame(source, resolveComponent(source, " :form:outerContainer:innerContainer:source ")); } + @Test public void test_ResolveComponent_Relative() { UIComponent root = new UIPanel(); @@ -380,9 +397,10 @@ public void test_ResolveComponent_Relative() { source.setId("source"); innerContainer.getChildren().add(source); - assertSame("Failed", component, resolveComponent(source, " other ")); + assertSame(component, resolveComponent(source, " other ")); } + @Test public void test_ResolveComponent_AbsoluteForm() { UIComponent root = new UIPanel(); @@ -408,9 +426,10 @@ public void test_ResolveComponent_AbsoluteForm() { source.setId("source"); innerContainer.getChildren().add(source); - assertSame("Failed", root, resolveComponent(source, " :form:@parent ")); + assertSame(root, resolveComponent(source, " :form:@parent ")); } + @Test public void test_ResolveComponent_ParentChild() { UIComponent root = new UIPanel(); @@ -436,10 +455,11 @@ public void test_ResolveComponent_ParentChild() { source.setId("source"); innerContainer.getChildren().add(source); - assertSame("Failed", component, resolveComponent(source, " @parent:@child(0) ")); - assertSame("Failed", source, resolveComponent(source, " @parent:@child(1) ")); + assertSame(component, resolveComponent(source, " @parent:@child(0) ")); + assertSame(source, resolveComponent(source, " @parent:@child(1) ")); } + @Test public void test_ResolveComponent_AbsoluteNamingcontainer() { UIComponent root = new UIPanel(); @@ -465,9 +485,10 @@ public void test_ResolveComponent_AbsoluteNamingcontainer() { source.setId("source"); innerContainer.getChildren().add(source); - assertSame("Failed", form, resolveComponent(source, " :form:outerContainer:@namingcontainer ")); + assertSame(form, resolveComponent(source, " :form:outerContainer:@namingcontainer ")); } + @Test public void test_ResolveClientId_This() { UIComponent root = new UIPanel(); @@ -491,9 +512,10 @@ public void test_ResolveClientId_This() { source.setId("source"); innerContainer.getChildren().add(source); - assertEquals("Failed", "form:outerContainer:innerContainer:source", resolveClientId(source, " @this ")); + assertEquals("form:outerContainer:innerContainer:source", resolveClientId(source, " @this ")); } + @Test public void test_ResolveClientId_Form() { UIComponent root = new UIPanel(); @@ -517,9 +539,10 @@ public void test_ResolveClientId_Form() { source.setId("source"); innerContainer.getChildren().add(source); - assertEquals("Failed", "form", resolveClientId(source, " @form ")); + assertEquals("form", resolveClientId(source, " @form ")); } + @Test public void test_ResolveClientId_AbsoluteId() { UIComponent root = new UIPanel(); @@ -543,9 +566,10 @@ public void test_ResolveClientId_AbsoluteId() { UIComponent source = new UICommand(); innerContainer.getChildren().add(source); - assertEquals("Failed", "form", resolveClientId(source, " :form ")); + assertEquals("form", resolveClientId(source, " :form ")); } + @Test public void test_ResolveClientId_Relative() { UIComponent root = new UIPanel(); @@ -570,9 +594,10 @@ public void test_ResolveClientId_Relative() { source.setId("source"); innerContainer.getChildren().add(source); - assertEquals("Failed", "form:outerContainer:innerContainer:other", resolveClientId(source, " other ")); + assertEquals("form:outerContainer:innerContainer:other", resolveClientId(source, " other ")); } + @Test public void test_ResolveComponents_RelativeAndParentParent() { UIComponent root = new UIPanel(); @@ -598,11 +623,12 @@ public void test_ResolveComponents_RelativeAndParentParent() { innerContainer.getChildren().add(source); List resolvedComponents = resolveComponents(source, " other @parent:@parent "); - assertTrue("Failed", resolvedComponents.contains(component)); - assertTrue("Failed", resolvedComponents.contains(outerContainer)); - assertEquals("Failed", 2, resolvedComponents.size()); + assertTrue(resolvedComponents.contains(component)); + assertTrue(resolvedComponents.contains(outerContainer)); + assertEquals(2, resolvedComponents.size()); } + @Test public void test_ResolveComponents_RelativeAndThisParent() { UIComponent root = new UIPanel(); @@ -628,11 +654,12 @@ public void test_ResolveComponents_RelativeAndThisParent() { innerContainer.getChildren().add(source); List resolvedComponents = resolveComponents(source, " other,@this:@parent @none "); - assertTrue("Failed", resolvedComponents.contains(component)); - assertTrue("Failed", resolvedComponents.contains(innerContainer)); - assertEquals("Failed", 2, resolvedComponents.size()); + assertTrue(resolvedComponents.contains(component)); + assertTrue(resolvedComponents.contains(innerContainer)); + assertEquals(2, resolvedComponents.size()); } + @Test public void test_ResolveComponent_Next() { UIComponent root = new UIPanel(); @@ -650,8 +677,8 @@ public void test_ResolveComponent_Next() { command3.setId("command3"); root.getChildren().add(command3); - assertSame("Failed", command2, resolveComponent(command1, " @next ")); - assertSame("Failed", command3, resolveComponent(command2, " @next ")); + assertSame(command2, resolveComponent(command1, " @next ")); + assertSame(command3, resolveComponent(command2, " @next ")); try { resolveComponent(command3, " @next"); @@ -661,6 +688,7 @@ public void test_ResolveComponent_Next() { } } + @Test public void test_ResolveComponent_NextNext() { UIComponent root = new UIPanel(); @@ -678,7 +706,7 @@ public void test_ResolveComponent_NextNext() { command3.setId("command3"); root.getChildren().add(command3); - assertSame("Failed", command3, resolveComponent(command1, " @next:@next ")); + assertSame(command3, resolveComponent(command1, " @next:@next ")); try { resolveComponent(command2, " @next:@next"); @@ -695,6 +723,7 @@ public void test_ResolveComponent_NextNext() { } } + @Test public void test_ResolveComponent_Previous() { UIComponent root = new UIPanel(); @@ -712,8 +741,8 @@ public void test_ResolveComponent_Previous() { command3.setId("command3"); root.getChildren().add(command3); - assertSame("Failed", command1, resolveComponent(command2, " @previous ")); - assertSame("Failed", command2, resolveComponent(command3, " @previous ")); + assertSame(command1, resolveComponent(command2, " @previous ")); + assertSame(command2, resolveComponent(command3, " @previous ")); try { resolveComponent(command1, " @previous"); @@ -723,6 +752,7 @@ public void test_ResolveComponent_Previous() { } } + @Test public void test_ResolveComponent_Root() { UIComponent root = new UIPanel(); @@ -740,9 +770,10 @@ public void test_ResolveComponent_Root() { command3.setId("command3"); root.getChildren().add(command3); - assertSame("Failed", facesContext.getViewRoot(), resolveComponent(command2, " @root ")); + assertSame(facesContext.getViewRoot(), resolveComponent(command2, " @root ")); } + @Test public void test_ResolveComponent_FormChildNextNext() { UIForm root = new UIForm(); @@ -760,9 +791,10 @@ public void test_ResolveComponent_FormChildNextNext() { command3.setId("command3"); root.getChildren().add(command3); - assertSame("Failed", command3, resolveComponent(command1, " @form:@child(0):@next:@next ")); + assertSame(command3, resolveComponent(command1, " @form:@child(0):@next:@next ")); } + @Test public void test_ResolveComponent_IgnoreNoResult() { UIForm root = new UIForm(); root.setId("form"); @@ -775,9 +807,10 @@ public void test_ResolveComponent_IgnoreNoResult() { command2.setId("command2"); root.getChildren().add(command2); - assertSame("Failed", null, resolveComponent(command1, " command3 ", SearchExpressionHint.IGNORE_NO_RESULT)); + assertSame(null, resolveComponent(command1, " command3 ", SearchExpressionHint.IGNORE_NO_RESULT)); } + @Test public void test_ResolveClientId_AbsoluteWithFormPrependIdFalse() { UIComponent root = new UIPanel(); @@ -803,9 +836,10 @@ public void test_ResolveClientId_AbsoluteWithFormPrependIdFalse() { source.setId("source"); innerContainer.getChildren().add(source); - assertEquals("Failed", "outerContainer:innerContainer:source", resolveClientId(source, " :form:outerContainer:innerContainer:source ")); + assertEquals("outerContainer:innerContainer:source", resolveClientId(source, " :form:outerContainer:innerContainer:source ")); } + @Test public void test_ResolveClientId_AbsoluteWithFormPrependIdFalse_InvokeOnComponent() { UIComponent root = new UIPanel(); @@ -831,76 +865,79 @@ public void test_ResolveClientId_AbsoluteWithFormPrependIdFalse_InvokeOnComponen source.setId("source"); innerContainer.getChildren().add(source); - assertEquals("Failed", "outerContainer:innerContainer:source", resolveClientId(source, " outerContainer:innerContainer:source ")); + assertEquals("outerContainer:innerContainer:source", resolveClientId(source, " outerContainer:innerContainer:source ")); } + @Test public void test_Passthrough() { SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler(); SearchExpressionContext searchExpressionContext = SearchExpressionContext.createSearchExpressionContext(facesContext, null); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:showName")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:table:3:nested:1:nestedText")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:table:3:baseText")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:table:0:baseText")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:table:3:nested:0:nestedText")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:table:3:nested")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:table:1:nested:0:nestedText")); - - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@this")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@this:@parent:showName")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@parent:showName:@parent:showName")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@form")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@form:showName")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@namingcontainer:showName")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@previous")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@next")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@parent:@id(msgName)")); - - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@whoNows")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@parent:@whoNows")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:@whoNows")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "!whoNows")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:showName")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:table:3:nested:1:nestedText")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:table:3:baseText")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:table:0:baseText")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:table:3:nested:0:nestedText")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:table:3:nested")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:table:1:nested:0:nestedText")); + + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@this")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@this:@parent:showName")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@parent:showName:@parent:showName")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@form")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@form:showName")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@namingcontainer:showName")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@previous")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@next")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@parent:@id(msgName)")); + + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@whoNows")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@parent:@whoNows")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "mainForm:@whoNows")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "!whoNows")); Set hints = new HashSet<>(); hints.add(SearchExpressionHint.RESOLVE_CLIENT_SIDE); searchExpressionContext = SearchExpressionContext.createSearchExpressionContext(facesContext, null, hints, null); - Assert.assertTrue(handler.isPassthroughExpression(searchExpressionContext, "@form")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@form:showName")); - Assert.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@form:@child(0)")); + Assertions.assertTrue(handler.isPassthroughExpression(searchExpressionContext, "@form")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@form:showName")); + Assertions.assertFalse(handler.isPassthroughExpression(searchExpressionContext, "@form:@child(0)")); } + @Test public void test_Valid() { SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler(); SearchExpressionContext searchExpressionContext = SearchExpressionContext.createSearchExpressionContext(facesContext, null); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "mainForm:showName")); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "mainForm:table:3:nested:1:nestedText")); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "mainForm:table:3:baseText")); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "mainForm:table:0:baseText")); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "mainForm:table:3:nested:0:nestedText")); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "mainForm:table:3:nested")); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "mainForm:table:1:nested:0:nestedText")); - - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "@this")); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "@this:@parent:showName")); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "@parent:showName:@parent:showName")); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "@form:showName")); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "@namingcontainer:showName")); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "@previous")); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "@next")); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "@parent:@id(msgName)")); - - Assert.assertFalse(handler.isValidExpression(searchExpressionContext, "@whoNows")); - Assert.assertFalse(handler.isValidExpression(searchExpressionContext, "@parent:@whoNows")); - Assert.assertFalse(handler.isValidExpression(searchExpressionContext, "mainForm:@whoNows")); - - Assert.assertFalse(handler.isValidExpression(searchExpressionContext, "@none:@parent")); - Assert.assertFalse(handler.isValidExpression(searchExpressionContext, "@all:@parent")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "mainForm:showName")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "mainForm:table:3:nested:1:nestedText")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "mainForm:table:3:baseText")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "mainForm:table:0:baseText")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "mainForm:table:3:nested:0:nestedText")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "mainForm:table:3:nested")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "mainForm:table:1:nested:0:nestedText")); + + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "@this")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "@this:@parent:showName")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "@parent:showName:@parent:showName")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "@form:showName")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "@namingcontainer:showName")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "@previous")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "@next")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "@parent:@id(msgName)")); + + Assertions.assertFalse(handler.isValidExpression(searchExpressionContext, "@whoNows")); + Assertions.assertFalse(handler.isValidExpression(searchExpressionContext, "@parent:@whoNows")); + Assertions.assertFalse(handler.isValidExpression(searchExpressionContext, "mainForm:@whoNows")); + + Assertions.assertFalse(handler.isValidExpression(searchExpressionContext, "@none:@parent")); + Assertions.assertFalse(handler.isValidExpression(searchExpressionContext, "@all:@parent")); } + @Test public void test_ResolveComponents_Id() { UIComponent root = new UIPanel(); FacesContext.getCurrentInstance().getViewRoot().getChildren().add(root); @@ -938,6 +975,7 @@ public void test_ResolveComponents_Id() { * The SearchExpression API was inspired by PrimeFaces. This test only tests, if PFS (PrimeFaces Selectors -> jQuery * like selectors; like @(#myId > .myStyle)) can be correctly handled by the API+IMPL as a passthrough expression. */ + @Test public void test_PFS() { CompositeSearchKeywordResolver s = (CompositeSearchKeywordResolver) application.getSearchKeywordResolver(); s.add(new SearchKeywordResolver() { @@ -970,10 +1008,11 @@ public boolean isLeaf(SearchExpressionContext searchExpressionContext, String ke SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler(); SearchExpressionContext searchExpressionContext = SearchExpressionContext.createSearchExpressionContext(facesContext, null); - Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "@(.myPanel #id)")); - Assert.assertFalse(handler.isValidExpression(searchExpressionContext, "@(.myPanel #id):test")); + Assertions.assertTrue(handler.isValidExpression(searchExpressionContext, "@(.myPanel #id)")); + Assertions.assertFalse(handler.isValidExpression(searchExpressionContext, "@(.myPanel #id):test")); } + @Test public void test_chainOfResponsability() { CompositeSearchKeywordResolver s = (CompositeSearchKeywordResolver) application.getSearchKeywordResolver(); s.add(new CustomSearchKeywordResolverImplForm()); // drop in new @form resolver @@ -995,8 +1034,8 @@ public void test_chainOfResponsability() { UIComponent source = new UICommand(); innerContainer.getChildren().add(source); - assertSame("Failed", source, resolveComponent(source, "@form")); - assertNotSame("Failed", form, resolveComponent(source, "@form")); + assertSame(source, resolveComponent(source, "@form")); + assertNotSame(form, resolveComponent(source, "@form")); } class CustomSearchKeywordResolverImplForm extends SearchKeywordResolverImplForm { @@ -1006,6 +1045,7 @@ public void resolve(SearchKeywordContext searchKeywordContext, UIComponent curre } } + @Test public void test_ResolveComponent_LeafErrorHandling() { UIComponent root = new UIPanel(); diff --git a/impl/src/test/java/jakarta/faces/component/StateHolderSaverTestCase.java b/impl/src/test/java/jakarta/faces/component/StateHolderSaverTestCase.java index 803413d60a..721dce80c4 100644 --- a/impl/src/test/java/jakarta/faces/component/StateHolderSaverTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/StateHolderSaverTestCase.java @@ -16,42 +16,37 @@ package jakarta.faces.component; -import jakarta.faces.convert.IntegerConverter; -import junit.framework.Test; -import junit.framework.TestSuite; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class StateHolderSaverTestCase extends UIComponentBaseTestCase { +import org.junit.jupiter.api.Test; - // ------------------------------------------------------ Instance Variables - // ------------------------------------------------------------ Constructors - // Construct a new instance of this test case. - public StateHolderSaverTestCase(String name) { - super(name); - } +import jakarta.faces.convert.IntegerConverter; - // ---------------------------------------------------- Overall Test Methods - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(StateHolderSaverTestCase.class); - } +public class StateHolderSaverTestCase extends UIComponentBaseTestCase { // ------------------------------------------------- Individual Test Methods @Override + @Test public void testLifecycleManagement() { } @Override + @Test public void testChildrenRecursive() { } @Override + @Test public void testComponentReconnect() { } @Override + @Test public void testComponentRemoval() { } + @Test public void testImplementsStateHolder() throws Exception { StateHolderSaver saver = null; UIInput postSave, preSave = new UIInput(); @@ -63,6 +58,7 @@ public void testImplementsStateHolder() throws Exception { assertEquals(postSave.getId(), preSave.getId()); } + @Test public void testImplementsSerializable() throws Exception { StateHolderSaver saver = null; String preSave = "hello"; @@ -73,6 +69,7 @@ public void testImplementsSerializable() throws Exception { assertTrue(preSave.equals(postSave)); } + @Test public void testImplementsNeither() throws Exception { StateHolderSaver saver = null; IntegerConverter preSave = new IntegerConverter(), postSave = null; diff --git a/impl/src/test/java/jakarta/faces/component/UIColumnTestCase.java b/impl/src/test/java/jakarta/faces/component/UIColumnTestCase.java index 252331471b..e17feeb7cf 100644 --- a/impl/src/test/java/jakarta/faces/component/UIColumnTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UIColumnTestCase.java @@ -16,8 +16,9 @@ package jakarta.faces.component; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** *

@@ -26,19 +27,10 @@ */ public class UIColumnTestCase extends UIComponentBaseTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public UIColumnTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); component = new UIColumn(); @@ -47,13 +39,9 @@ public void setUp() throws Exception { expectedRendererType = null; } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UIColumnTestCase.class); - } - // Tear down instance variables required by ths test case @Override + @AfterEach public void tearDown() throws Exception { super.tearDown(); } @@ -61,6 +49,7 @@ public void tearDown() throws Exception { // ------------------------------------------------- Individual Test Methods // Suppress lifecycle tests since we do not have a renderer @Override + @Test public void testLifecycleManagement() { } diff --git a/impl/src/test/java/jakarta/faces/component/UICommandTestCase.java b/impl/src/test/java/jakarta/faces/component/UICommandTestCase.java index 40be6928ca..b6d12aea60 100644 --- a/impl/src/test/java/jakarta/faces/component/UICommandTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UICommandTestCase.java @@ -16,10 +16,16 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.IOException; import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.faces.mock.MockExternalContext; import jakarta.faces.FactoryFinder; @@ -30,8 +36,6 @@ import jakarta.faces.render.RenderKit; import jakarta.faces.render.RenderKitFactory; import jakarta.faces.render.Renderer; -import junit.framework.Test; -import junit.framework.TestSuite; /** *

@@ -40,19 +44,10 @@ */ public class UICommandTestCase extends UIComponentBaseTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public UICommandTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); component = new UICommand(); @@ -61,11 +56,6 @@ public void setUp() throws Exception { expectedRendererType = "jakarta.faces.Button"; } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UICommandTestCase.class); - } - // ------------------------------------------------- Individual Test Methods // Test order of action listener calls with actionListener also public void PENDING_FIXME_testActionOrder() throws Exception { @@ -98,6 +88,7 @@ public void PENDING_FIXME_testActionOrder() throws Exception { } // Test event queuing and broadcasting (any phase listeners) + @Test public void testEventsGeneric() { UICommand command = (UICommand) component; @@ -122,6 +113,7 @@ public void testEventsGeneric() { } // Test event queuing and broadcasting (mixed phase listeners) + @Test public void testEventsMixed() { UICommand command = (UICommand) component; @@ -147,6 +139,7 @@ public void testEventsMixed() { // Test event queuing and broadcasting (mixed phase listeners), with // immediate set. + @Test public void testEventsMixedImmediate() { UICommand command = (UICommand) component; @@ -172,6 +165,7 @@ public void testEventsMixedImmediate() { } // Test listener registration and deregistration + @Test public void testListeners() { CommandTestImpl command = new CommandTestImpl(); @@ -191,6 +185,7 @@ public void testListeners() { } // Test empty listener list + @Test public void testEmptyListeners() { CommandTestImpl command = new CommandTestImpl(); @@ -203,9 +198,11 @@ public void testEmptyListeners() { // Suppress lifecycle tests since we do not have a renderer @Override + @Test public void testLifecycleManagement() { } + @Test public void testNestedCommands() { UIViewRoot root = new UIViewRoot(); UICommand c1 = new UICommand(); @@ -229,6 +226,7 @@ public void testNestedCommands() { assertTrue(ae.getPhaseId().equals(PhaseId.INVOKE_APPLICATION)); } + @Test public void testGetActionListeners() throws Exception { UICommand command = (UICommand) component; UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentBaseAttachedStateTestCase.java b/impl/src/test/java/jakarta/faces/component/UIComponentBaseAttachedStateTestCase.java index 12fd79a66f..37d97bc789 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentBaseAttachedStateTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentBaseAttachedStateTestCase.java @@ -16,6 +16,11 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.lang.reflect.Method; import java.util.HashMap; import java.util.HashSet; @@ -23,6 +28,10 @@ import java.util.Set; import java.util.Stack; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.faces.mock.MockExternalContext; import com.sun.faces.mock.MockFacesContext; import com.sun.faces.mock.MockHttpServletRequest; @@ -34,29 +43,16 @@ import jakarta.faces.context.FacesContext; import jakarta.faces.event.FacesListener; import jakarta.faces.event.ValueChangeListener; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -public class UIComponentBaseAttachedStateTestCase extends TestCase { +public class UIComponentBaseAttachedStateTestCase { private MockFacesContext facesContext = null; private MockServletContext servletContext; private MockHttpServletRequest request; private MockHttpServletResponse response; - public UIComponentBaseAttachedStateTestCase(String arg0) { - super(arg0); - } - - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UIComponentBaseAttachedStateTestCase.class); - } - - @Override + @BeforeEach public void setUp() throws Exception { - super.setUp(); facesContext = new MockFacesContext(); servletContext = new MockServletContext(); @@ -71,9 +67,8 @@ public void setUp() throws Exception { } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @AfterEach + public void tearDown() throws Exception { FactoryFinder.releaseFactories(); Method reInitializeFactoryManager = FactoryFinder.class.getDeclaredMethod("reInitializeFactoryManager", (Class[]) null); reInitializeFactoryManager.setAccessible(true); @@ -81,6 +76,7 @@ protected void tearDown() throws Exception { } + @Test public void testAttachedObjectsSet() throws Exception { Set attachedObjects = new HashSet<>(); ValueChangeListener toAdd = new ValueChangeListenerTestImpl(); @@ -96,6 +92,7 @@ public void testAttachedObjectsSet() throws Exception { assertNotNull(returnedAttachedObjects); } + @Test public void testAttachedObjectsStack() throws Exception { Stack attachedObjects = new Stack<>(); ValueChangeListener toAdd = new ValueChangeListenerTestImpl(); @@ -111,6 +108,7 @@ public void testAttachedObjectsStack() throws Exception { assertNotNull(returnedAttachedObjects); } + @Test public void testAttachedObjectsMap() throws Exception { Map attachedObjects = new HashMap<>(); ValueChangeListener toAdd = new ValueChangeListenerTestImpl(); @@ -144,6 +142,7 @@ public void testAttachedObjectsCount() throws Exception { assertEquals(firstSize, secondSize); } + @Test public void testFacesListenerState() { UIComponent component = new UIOutput(); TestFacesListener listener = new TestFacesListener(); @@ -171,7 +170,7 @@ public void testFacesListenerState() { component.addFacesListener(listener); listener.setValue("newinitial"); component.restoreState(facesContext, state); - assertTrue("newvalue".equals(listener.getValue())); + assertEquals("newvalue", listener.getValue()); // verify listeners are overwritten when using full state saving component = new UIOutput(); @@ -185,9 +184,10 @@ public void testFacesListenerState() { component.restoreState(facesContext, state); TestFacesListener l = (TestFacesListener) component.getFacesListeners(TestFacesListener.class)[0]; assertTrue(l != listener); - assertTrue("initial".equals(l.getValue())); + assertEquals("initial", l.getValue()); } + @Test public void testTransientListenersState() { UIComponent output = new UIOutput(); output.markInitialState(); @@ -227,6 +227,7 @@ public void testTransientListenersState() { assertTrue(listeners.length == 0); } + @Test public void testTransientListenersState2() { UIComponent output = new UIOutput(); TestFacesListener l1 = new TestFacesListener(); diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentBaseBehaviorTestCase.java b/impl/src/test/java/jakarta/faces/component/UIComponentBaseBehaviorTestCase.java index f5b070350e..2c8fd6a567 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentBaseBehaviorTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentBaseBehaviorTestCase.java @@ -16,6 +16,10 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.Serializable; import java.util.Collection; import java.util.Collections; @@ -24,6 +28,8 @@ import java.util.Map; import java.util.Set; +import org.junit.jupiter.api.Test; + import jakarta.faces.component.behavior.ClientBehavior; import jakarta.faces.component.behavior.ClientBehaviorContext; import jakarta.faces.component.behavior.ClientBehaviorHint; @@ -138,10 +144,6 @@ public String toString() { } } - public UIComponentBaseBehaviorTestCase(String name) { - super(name); - } - /** * Test method for {@link jakarta.faces.component.UIComponentBase#saveState(jakarta.faces.context.FacesContext)}. */ @@ -173,6 +175,7 @@ public void testSaveState() { assertEquals(behavior2, behaviors.get(ONCLICK).get(1)); } + @Test public void testNonClientBehaviorHolder() throws Exception { UIInput input = new UIInput(); try { diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentBaseTestCase.java b/impl/src/test/java/jakarta/faces/component/UIComponentBaseTestCase.java index b332ecf334..c3f39023dd 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentBaseTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentBaseTestCase.java @@ -16,6 +16,12 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -25,6 +31,10 @@ import java.util.List; import java.util.Map; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import jakarta.faces.FacesException; import jakarta.faces.context.FacesContext; import jakarta.faces.event.AbortProcessingException; @@ -35,8 +45,6 @@ import jakarta.faces.event.PreRenderComponentEvent; import jakarta.faces.event.SystemEvent; import jakarta.faces.event.SystemEventListener; -import junit.framework.Test; -import junit.framework.TestSuite; /** *

@@ -45,21 +53,10 @@ */ public class UIComponentBaseTestCase extends UIComponentTestCase { - // ------------------------------------------------------ Instance Variables - // Mock object instances for our tests - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public UIComponentBaseTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { // Set up the component under test @@ -68,13 +65,9 @@ public void setUp() throws Exception { } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UIComponentBaseTestCase.class); - } - // Tear down instance variables required by ths test case @Override + @AfterEach public void tearDown() throws Exception { externalContext.setRequestParameterMap(null); @@ -84,6 +77,7 @@ public void tearDown() throws Exception { // ------------------------------------------------- Individual Test Methods // Test lifecycle management methods + @Test public void testLifecycleManagement() { checkLifecycleParentRendered(); @@ -93,6 +87,7 @@ public void testLifecycleManagement() { } + @Test public void testComponentToFromEL2() throws Exception { final FacesContext ctx = facesContext; @@ -165,6 +160,7 @@ public void testComponentToFromEL2() throws Exception { } + @Test public void testEncodeChildren() throws Exception { ComponentTestImpl.trace(null); UIComponent comp1 = new ComponentTestImpl("one"); @@ -184,6 +180,7 @@ public void testEncodeChildren() throws Exception { } // Test recursive adding and removing child trees with ids + @Test public void testChildrenRecursive() { // Create the components we will need @@ -219,6 +216,7 @@ public void testChildrenRecursive() { } + @Test public void testChildrenAndFacetsWithNullGetParent() throws Exception { ComponentTestImpl child = new ComponentTestImpl() { @Override @@ -239,6 +237,7 @@ public UIComponent getParent() { } // Test reconnecting a child or facet to a different component + @Test public void testComponentReconnect() { UIComponent parent1 = new ComponentTestImpl(); @@ -292,6 +291,7 @@ public void testComponentReconnect() { } // Test removing components from our naming container. + @Test public void testComponentRemoval() { UIComponent testComponent = new ComponentTestImpl(); @@ -348,6 +348,7 @@ public void testComponentRemoval() { assertTrue(!kidItr.hasNext()); } + @Test public void testStateHolder2() throws Exception { UIComponent c = new UIComponentListener(); @@ -361,6 +362,7 @@ public void testStateHolder2() throws Exception { } + @Test public void testAttributesThatAreSetStateHolder() throws Exception { ComponentTestImpl c = new ComponentTestImpl(); c.getAttributes().put("attr1", "value1"); @@ -376,6 +378,7 @@ public void testAttributesThatAreSetStateHolder() throws Exception { assertEquals(Arrays.asList("attr1", "attr2"), c.getAttributes().get("jakarta.faces.component.UIComponentBase.attributesThatAreSet")); } + @Test public void testValueExpressions() throws Exception { UIComponentBase test = (UIComponentBase) component; @@ -504,17 +507,17 @@ private void checkLifecycleParentRendered() { // Test processDecodes() ComponentTestImpl.trace(null); component.processDecodes(facesContext); - assertEquals("processDecodes", lifecycleTrace("pD", "d"), ComponentTestImpl.trace()); + assertEquals(lifecycleTrace("pD", "d"), ComponentTestImpl.trace()); // Test processValidators() ComponentTestImpl.trace(null); component.processValidators(facesContext); - assertEquals("processValidators", lifecycleTrace("pV", null), ComponentTestImpl.trace()); + assertEquals(lifecycleTrace("pV", null), ComponentTestImpl.trace()); // Test processUpdates() ComponentTestImpl.trace(null); component.processUpdates(facesContext); - assertEquals("processUpdates", lifecycleTrace("pU", null), ComponentTestImpl.trace()); + assertEquals(lifecycleTrace("pU", null), ComponentTestImpl.trace()); } @@ -567,17 +570,17 @@ private void checkLifecycleParentUnrendered() { // Test processDecodes() ComponentTestImpl.trace(null); component.processDecodes(facesContext); - assertEquals("processDecodes", lifecycleTrace("pD", "d"), ComponentTestImpl.trace()); + assertEquals(lifecycleTrace("pD", "d"), ComponentTestImpl.trace()); // Test processValidators() ComponentTestImpl.trace(null); component.processValidators(facesContext); - assertEquals("processValidators", lifecycleTrace("pV", null), ComponentTestImpl.trace()); + assertEquals(lifecycleTrace("pV", null), ComponentTestImpl.trace()); // Test processUpdates() ComponentTestImpl.trace(null); component.processUpdates(facesContext); - assertEquals("processUpdates", lifecycleTrace("pU", null), ComponentTestImpl.trace()); + assertEquals(lifecycleTrace("pU", null), ComponentTestImpl.trace()); } @@ -627,17 +630,17 @@ private void checkLifecycleSelfRendered() { // Test processDecodes() ComponentTestImpl.trace(null); component.processDecodes(facesContext); - assertEquals("processDecodes", lifecycleTrace("pD", "d"), ComponentTestImpl.trace()); + assertEquals(lifecycleTrace("pD", "d"), ComponentTestImpl.trace()); // Test processValidators() ComponentTestImpl.trace(null); component.processValidators(facesContext); - assertEquals("processValidators", lifecycleTrace("pV", null), ComponentTestImpl.trace()); + assertEquals(lifecycleTrace("pV", null), ComponentTestImpl.trace()); // Test processUpdates() ComponentTestImpl.trace(null); component.processUpdates(facesContext); - assertEquals("processUpdates", lifecycleTrace("pU", null), ComponentTestImpl.trace()); + assertEquals(lifecycleTrace("pU", null), ComponentTestImpl.trace()); } @@ -687,17 +690,17 @@ private void checkLifecycleSelfUnrendered() { // Test processDecodes() ComponentTestImpl.trace(null); component.processDecodes(facesContext); - assertEquals("processDecodes", lifecycleTrace("pD", "d"), ComponentTestImpl.trace()); + assertEquals(lifecycleTrace("pD", "d"), ComponentTestImpl.trace()); // Test processValidators() ComponentTestImpl.trace(null); component.processValidators(facesContext); - assertEquals("processValidators", lifecycleTrace("pV", null), ComponentTestImpl.trace()); + assertEquals(lifecycleTrace("pV", null), ComponentTestImpl.trace()); // Test processUpdates() ComponentTestImpl.trace(null); component.processUpdates(facesContext); - assertEquals("processUpdates", lifecycleTrace("pU", null), ComponentTestImpl.trace()); + assertEquals(lifecycleTrace("pU", null), ComponentTestImpl.trace()); } @@ -772,6 +775,7 @@ protected void lifecycleTrace(String lmethod, String cmethod, UIComponent compon } + @Test public void testGetFacetsAndChildren() { UIComponent testComponent = new ComponentTestImpl(); @@ -829,21 +833,21 @@ public void testGetFacetsAndChildren() { *

*
      * root: id: root
-     * 
+     *
      *   form1: id: form1
-     * 
+     *
      *     panel1: id: panel
-     * 
+     *
      *       input1: id: input1
-     * 
+     *
      *       input2: id: input2
-     * 
+     *
      *   form2: id: form2
-     * 
+     *
      *     panel2: id: panel
-     * 
+     *
      *       input3: id: input1
-     * 
+     *
      *       input4: id: input2
      * 
* @@ -895,6 +899,7 @@ private Map setupInvokeOnComponentTree() { return result; } + @Test public void testInvokeOnComponentPositive() throws Exception { Map tree = setupInvokeOnComponentTree(); @@ -910,8 +915,7 @@ public void testInvokeOnComponentPositive() throws Exception { result = root.invokeOnComponent(facesContext, input1.getClientId(facesContext), new ContextCallback() { @Override public void invokeContextCallback(FacesContext context, UIComponent component) { - assertEquals("getCurrentComponent does not return the current component during" + "invokeOnComponent", UIComponent.getCurrentComponent(context), - component); + assertEquals(UIComponent.getCurrentComponent(context), component); foundComponent = component; } }); @@ -921,6 +925,7 @@ public void invokeContextCallback(FacesContext context, UIComponent component) { } + @Test public void testInvokeOnComponentNegative() throws Exception { Map tree = setupInvokeOnComponentTree(); @@ -1012,6 +1017,7 @@ public void invokeContextCallback(FacesContext context, UIComponent component) { } + @Test public void testInvokeOnComponentWithPrependId() throws Exception { Map tree = setupInvokeOnComponentTree(); @@ -1160,6 +1166,7 @@ public void invokeContextCallback(FacesContext context, UIComponent component) { } + @Test public void testChildrenListAfterAddPublish() { Listener listener = new Listener(); @@ -1197,6 +1204,7 @@ public void testChildrenListAfterAddPublish() { } + @Test public void testFacetMapAfterAddViewPublish() { QueueingListener listener = new QueueingListener(); @@ -1209,11 +1217,11 @@ public void testFacetMapAfterAddViewPublish() { List e = listener.getEvents(); Map facets = c1.getFacets(); facets.put("c2", c2); - assertTrue("Expected Event queue size of 0, found: " + e.size(), e.isEmpty()); + assertEquals(0, e.size()); UIViewRoot root = new UIViewRoot(); root.getChildren().add(c1); - assertTrue("Expected Event queue size of 2, found: " + e.size(), e.size() == 2); + assertEquals(2, e.size()); assertTrue(e.get(0).getSource() == c1); assertTrue(e.get(1).getSource() == c2); @@ -1223,13 +1231,13 @@ public void testFacetMapAfterAddViewPublish() { root.getChildren().remove(c1); facets = c1.getFacets(); facets.put("c3", c3); - assertTrue("Expected Event queue size of 0, found: " + e.size(), e.isEmpty()); + assertEquals(0, e.size()); // reorganize the facet structure to ensure nested facets work facets.remove("c3"); c2.getFacets().put("c3", c3); root.getChildren().add(c1); - assertTrue("Expected Event queue size of 3, found: " + e.size(), e.size() == 3); + assertEquals(3, e.size()); assertTrue(e.get(0).getSource() == c1); assertTrue(e.get(1).getSource() == c2); assertTrue(e.get(2).getSource() == c3); @@ -1239,12 +1247,13 @@ public void testFacetMapAfterAddViewPublish() { facets.clear(); c2.getFacets().remove("c3"); c2.getFacets().put("c3", c3); - assertTrue("Expected Event queue size of 0, found: " + e.size(), e.isEmpty()); + assertEquals(0, e.size()); application.unsubscribeFromEvent(PostAddToViewEvent.class, listener); } + @Test public void testChildrenListAfterAddViewPublish() { QueueingListener listener = new QueueingListener(); @@ -1265,11 +1274,11 @@ public void testChildrenListAfterAddViewPublish() { // sub-tree has been added to the view. Ensure that subsequent additions // to that sub-tree cause the PostAddToViewEvent to fire. c2.getChildren().add(c4); - assertTrue("Expected Event queue size of 4, found: " + e.size(), e.size() == 4); + assertEquals(4, e.size()); UIComponent[] comps = { c1, c2, c3, c4 }; for (int i = 0; i < comps.length; i++) { - assertTrue("Index " + i + " invalid", e.get(i).getSource() == comps[i]); + assertTrue(e.get(i).getSource() == comps[i], "Index " + i + " invalid"); } // remove c1 and it's children from the subview, then remove and @@ -1279,18 +1288,18 @@ public void testChildrenListAfterAddViewPublish() { root.getChildren().remove(c1); c2.getChildren().remove(c4); c2.getChildren().add(c4); - assertTrue("AfterAddToView events queued after a sub-tree was removed from the view, and a child added to the sub-view", e.isEmpty()); + assertEquals(0, e.size()); c2.getChildren().remove(c4); c1.getChildren().add(c4); - assertTrue("AfterAddToView events queued after a sub-tree was removed from the view, and a child added to the sub-view", e.isEmpty()); + assertEquals(0, e.size()); // re-wire c1 as a child of root and ensure all children get re-notified root.getChildren().add(c1); - assertTrue("Expected Event queue size of 4, found: " + e.size(), e.size() == 4); + assertEquals(4, e.size()); for (int i = 0; i < comps.length; i++) { - assertTrue("Index " + i + " invalid", e.get(i).getSource() == comps[i]); + assertTrue(e.get(i).getSource() == comps[i], "Index " + i + " invalid"); } // validate clearing c1's children (effectively removing them from the view @@ -1302,24 +1311,24 @@ public void testChildrenListAfterAddViewPublish() { UIComponent temp = createComponent(); e.clear(); c2.getChildren().add(temp); - assertTrue("AfterAddToView events queued after a sub-tree was removed from the view, and a child added to the sub-view", e.isEmpty()); + assertEquals(0, e.size()); c2.getChildren().remove(temp); c3.getChildren().add(temp); - assertTrue("AfterAddToView events queued after a sub-tree was removed from the view, and a child added to the sub-view", e.isEmpty()); + assertEquals(0, e.size()); c3.getChildren().remove(temp); c4.getChildren().add(temp); - assertTrue("AfterAddToView events queued after a sub-tree was removed from the view, and a child added to the sub-view", e.isEmpty()); + assertEquals(0, e.size()); c4.getChildren().remove(temp); // now add c2 and c4 as children of c1. This should cause three // events to fire c1.getChildren().add(c2); c1.getChildren().add(c4); - assertTrue("Expected Event queue size of 3, found: " + e.size(), e.size() == 3); + assertEquals(3, e.size()); UIComponent[] comps2 = { c2, c3, c4 }; for (int i = 0; i < comps2.length; i++) { - assertTrue("Index " + i + " invalid", e.get(i).getSource() == comps2[i]); + assertTrue(e.get(i).getSource() == comps2[i], "Index " + i + " invalid"); } // validate add(int, UIComponent) fires events @@ -1329,7 +1338,7 @@ public void testChildrenListAfterAddViewPublish() { assertTrue(c1.getChildren().get(0) == c4); assertTrue(c1.getChildren().get(1) == c2); - assertTrue("Expected Event queue size of 1, found: " + e.size(), e.size() == 1); + assertEquals(1, e.size()); assertTrue(e.get(0).getSource() == c4); // validate addAll(Collection) fires events @@ -1340,7 +1349,7 @@ public void testChildrenListAfterAddViewPublish() { c1.getChildren().addAll(children); assertTrue(c1.getChildren().get(0) == c2); assertTrue(c1.getChildren().get(1) == c4); - assertTrue("Expected Event queue size of 3, found: " + e.size(), e.size() == 3); + assertEquals(3, e.size()); assertTrue(e.get(0).getSource() == c2); assertTrue(e.get(2).getSource() == c4); @@ -1355,7 +1364,7 @@ public void testChildrenListAfterAddViewPublish() { assertTrue(c1.getChildren().get(1) == t2); assertTrue(c1.getChildren().get(2) == c2); assertTrue(c1.getChildren().get(3) == c4); - assertTrue("Expected Event queue size of 2, found: " + e.size(), e.size() == 2); + assertEquals(2, e.size()); assertTrue(e.get(0).getSource() == t1); assertTrue(e.get(1).getSource() == t2); @@ -1370,7 +1379,7 @@ public void testChildrenListAfterAddViewPublish() { assertTrue(c1.getChildren().get(0) == c2); assertTrue(c1.getChildren().get(1) == c4); t1.getChildren().add(t2); - assertTrue("Expected Event queue size of 0, found: " + e.size(), e.isEmpty()); + assertEquals(0, e.size()); // test set(int, UIComponent) properly fires an event if the parent // the component is being added to is wired to the view @@ -1379,7 +1388,7 @@ public void testChildrenListAfterAddViewPublish() { assertTrue(c1.getChildren().size() == 2); assertTrue(c1.getChildren().get(0) == t1); assertTrue(c1.getChildren().get(1) == c4); - assertTrue("Expected Event queue size of 2, found: " + e.size(), e.size() == 2); + assertEquals(2, e.size()); assertTrue(e.get(0).getSource() == t1); assertTrue(e.get(1).getSource() == t2); @@ -1388,7 +1397,7 @@ public void testChildrenListAfterAddViewPublish() { e.clear(); UIComponent t3 = createComponent(); c2.getChildren().add(t3); - assertTrue("Expected Event queue size of 0, found: " + e.size(), e.isEmpty()); + assertEquals(0, e.size()); application.unsubscribeFromEvent(PostAddToViewEvent.class, listener); @@ -1403,17 +1412,18 @@ public void testChildrenListAfterAddViewPublish() { // to t1, t2, or c4 should result in no events being fired e.clear(); t1.getChildren().add(temp); - assertTrue("AfterAddToView events queued after a sub-tree was removed from the view, and a child added to the sub-view", e.isEmpty()); + assertEquals(0, e.size()); t1.getChildren().remove(temp); t2.getChildren().add(temp); - assertTrue("AfterAddToView events queued after a sub-tree was removed from the view, and a child added to the sub-view", e.isEmpty()); + assertEquals(0, e.size()); t2.getChildren().remove(temp); c4.getChildren().add(temp); - assertTrue("AfterAddToView events queued after a sub-tree was removed from the view, and a child added to the sub-view", e.isEmpty()); + assertEquals(0, e.size()); c4.getChildren().remove(temp); } + @Test public void testEncodeBeginPublish() throws Exception { Listener listener = new Listener(); @@ -1537,7 +1547,6 @@ public static final class CustomAbortProcessingException extends AbortProcessing private static final long serialVersionUID = 1L; public CustomAbortProcessingException() { - super(); } public CustomAbortProcessingException(String message) { diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentTestCase.java b/impl/src/test/java/jakarta/faces/component/UIComponentTestCase.java index 9143f7ae71..0e3eb7f9f9 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentTestCase.java @@ -16,6 +16,12 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; @@ -27,6 +33,10 @@ import java.util.Map; import java.util.Set; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.faces.junit.JUnitFacesTestCaseBase; import com.sun.faces.mock.MockRenderKit; @@ -41,8 +51,6 @@ import jakarta.faces.render.RenderKitFactory; import jakarta.faces.validator.Validator; import jakarta.faces.validator.ValidatorException; -import junit.framework.Test; -import junit.framework.TestSuite; /** *

@@ -101,15 +109,10 @@ public UIComponent setValue(UIComponent value) { }; - // ------------------------------------------------------------ Constructors - // Construct a new instance of this test case. - public UIComponentTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); @@ -133,13 +136,9 @@ public void setUp() throws Exception { component = new ComponentTestImpl(expectedId); } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UIComponentTestCase.class); - } - // Tear down instance variables required by this test case. @Override + @AfterEach public void tearDown() throws Exception { component = null; @@ -154,6 +153,7 @@ public void tearDown() throws Exception { } // ------------------------------------------------- Individual Test Methods + @Test public void testValidationEvents() { Listener prelistener = new Listener(); Listener postlistener = new Listener(); @@ -196,12 +196,13 @@ public void testValidationEvents() { ((UIInput) col.getChildren().get(0)).setSubmittedValue("hello"); data.setRowIndex(-1); root.processValidators(facesContext); - assertEquals("root/out/form/data/in/", "root/out/form/data/in/", prelistener.getResults()); - assertEquals("out/*/in/data/form/root/", "out/*/in/data/form/root/", postlistener.getResults()); + assertEquals("root/out/form/data/in/", prelistener.getResults()); + assertEquals("out/*/in/data/form/root/", postlistener.getResults()); } // Test behavior of Map returned by getAttributes() + @Test public void testAttributesMap() { // Initialize some attributes @@ -218,12 +219,12 @@ public void testAttributesMap() { assertTrue(!attributes.containsKey("parent")); // Property name // Test get() - assertEquals("bar", (String) attributes.get("foo")); - assertEquals("bop", (String) attributes.get("baz")); + assertEquals("bar", attributes.get("foo")); + assertEquals("bop", attributes.get("baz")); assertNull(attributes.get("bar")); assertNull(attributes.get("bop")); component.setId("oldvalue"); - assertEquals("oldvalue", (String) attributes.get("id")); // Property + assertEquals("oldvalue", attributes.get("id")); // Property component.setRendered(false); assertTrue(!((Boolean) attributes.get("rendered")).booleanValue()); component.setRendered(true); @@ -249,7 +250,7 @@ public void testAttributesMap() { // Expected result } attributes.put("id", "newvalue"); - assertEquals("newvalue", (String) attributes.get("id")); + assertEquals("newvalue", attributes.get("id")); assertEquals("newvalue", component.getId()); attributes.put("rendered", Boolean.TRUE); assertTrue(component.isRendered()); @@ -270,6 +271,7 @@ public void testAttributesMap() { } // Negative tests on attribute methods + @Test public void testAttributesNegative() { // getAttributes().get() - null @@ -291,6 +293,7 @@ public void testAttributesNegative() { } // Positive tests on attribute methods + @Test public void testAttributesPositive() { checkAttributeCount(component, expectedAttributes.length); @@ -320,13 +323,14 @@ public void testAttributesPositive() { } // Test attribute-property transparency + @Test public void testAttributesTransparency() { assertEquals(component.getChildren(), component.getAttributes().get("children")); assertEquals(component.getFacets(), component.getAttributes().get("facets")); - assertEquals(component.getId(), (String) component.getAttributes().get("id")); + assertEquals(component.getId(), component.getAttributes().get("id")); assertEquals(component.getParent(), component.getAttributes().get("parent")); @@ -341,7 +345,7 @@ public void testAttributesTransparency() { assertTrue(component.isRendered()); component.setRendererType("foo"); - assertEquals("foo", (String) component.getAttributes().get("rendererType")); + assertEquals("foo", component.getAttributes().get("rendererType")); component.setRendererType(null); assertNull(component.getAttributes().get("rendererType")); component.getAttributes().put("rendererType", "bar"); @@ -354,6 +358,7 @@ public void testAttributesTransparency() { } // Test getChildren().iterator() + @Test public void testChildrenIterator() { Iterator kids; @@ -407,6 +412,7 @@ public void testChildrenIterator() { } // Test getChildren().listIterator() + @Test public void testChildrenListIterator() { ListIterator kids; @@ -581,6 +587,7 @@ public void testChildrenListIterator() { } // Negative tests on children methods + @Test public void testChidrenNegative() { // Construct components we will need @@ -694,6 +701,7 @@ public void testChidrenNegative() { } // Positive tests on children methods + @Test public void testChildrenPositive() { // Construct components we will need @@ -861,6 +869,7 @@ public void testChildrenPositive() { } // Test replacing a child with a new one that has the same id + @Test public void testChidrenReplace() { ComponentTestImpl child1 = new ComponentTestImpl("child"); @@ -881,6 +890,7 @@ public void testChidrenReplace() { } // Test Set returned by getFacets().entrySet() + @Test public void testFacetsMapEntrySet() { Map facets; @@ -1067,6 +1077,7 @@ public void testFacetsMapEntrySet() { } // Test Set returned by getFacets().keySet() + @Test public void testFacetsMapKeySet() { Map facets; @@ -1220,6 +1231,7 @@ public void testFacetsMapKeySet() { } // Test Collection returned by getFacets().values() + @Test public void testFacetsMapValues() { Map facets; @@ -1398,6 +1410,7 @@ public void testFacetsMapValues() { } // Negative tests on facet methods + @Test public void testFacetsNegative() { // Construct components we will need @@ -1441,6 +1454,7 @@ public void testFacetsNegative() { } // Positive tests on facet methods + @Test public void testFacetsPositive() { // Construct components we will need @@ -1517,6 +1531,7 @@ public void testFacetsPositive() { } // Test a pristine UIComponent instance + @Test public void testPristine() { // Validate attributes @@ -1526,28 +1541,29 @@ public void testPristine() { } // Validate properties - assertEquals("expected family", expectedFamily, component.getFamily()); - assertEquals("expected id", expectedId, component.getId()); - assertNull("no parent", component.getParent()); - assertEquals("expected rendered", expectedRendered, component.isRendered()); - assertEquals("expected rendererType", expectedRendererType, component.getRendererType()); - assertEquals("expected rendersChildren", expectedRendersChildren, component.getRendersChildren()); + assertEquals(expectedFamily, component.getFamily()); + assertEquals(expectedId, component.getId()); + assertNull(component.getParent()); + assertEquals(expectedRendered, component.isRendered()); + assertEquals(expectedRendererType, component.getRendererType()); + assertEquals(expectedRendersChildren, component.getRendersChildren()); // Validate children and facets checkChildCount(component, 0); checkFacetCount(component, 0); int n = 0; Iterator items = component.getFacetsAndChildren(); - assertNotNull("iterator returned", items); + assertNotNull(items); while (items.hasNext()) { items.next(); n++; } - assertEquals("facets and children", 0, n); + assertEquals(0, n); } // Test setting properties to invalid values + @Test public void testPropertiesInvalid() throws Exception { // id - zero length @@ -1593,28 +1609,29 @@ public void testPropertiesInvalid() throws Exception { } // Test setting properties to valid values + @Test public void testPropertiesValid() throws Exception { // id - simple name component.setId("foo"); - assertEquals("expected id", "foo", component.getId()); + assertEquals("foo", component.getId()); // id - complex name component.setId("a123-bcd_e"); - assertEquals("expected id", "a123-bcd_e", component.getId()); + assertEquals("a123-bcd_e", component.getId()); // parent UIComponent parent = new ComponentTestImpl("parent"); component.setParent(parent); - assertEquals("expected parent", parent, component.getParent()); + assertEquals(parent, component.getParent()); // rendered component.setRendered(!expectedRendered); - assertEquals("expected rendered", !expectedRendered, component.isRendered()); + assertEquals(!expectedRendered, component.isRendered()); // rendererType component.setRendererType("foo"); - assertEquals("expected rendererType", "foo", component.getRendererType()); + assertEquals("foo", component.getRendererType()); } @@ -1627,12 +1644,12 @@ protected void checkAttributeCount(UIComponent component, int count) { names.next(); result++; } - assertEquals("attribute count", count, result); + assertEquals(count, result); } // Validate that the specified attribute name is not present protected void checkAttributeMissing(UIComponent component, String name) { - assertNull("Attribute " + name + " should be missing", component.getAttributes().get(name)); + assertNull(component.getAttributes().get(name), "Attribute " + name + " should be missing"); Iterator keys = component.getAttributes().keySet().iterator(); while (keys.hasNext()) { String key = (String) keys.next(); @@ -1645,16 +1662,16 @@ protected void checkAttributeMissing(UIComponent component, String name) { // Validate that the specified attribute name is present with the // specified value (if value is not null) protected void checkAttributePresent(UIComponent component, String name, Object value) { - assertNotNull("attribute " + name + " should be present", component.getAttributes().get(name)); + assertNotNull(component.getAttributes().get(name), "attribute " + name + " should be present"); if (value != null) { - assertEquals("attribute " + name + " value should be equal", value, component.getAttributes().get(name)); + assertEquals(value, component.getAttributes().get(name)); } Iterator keys = component.getAttributes().keySet().iterator(); while (keys.hasNext()) { String key = (String) keys.next(); if (name.equals(key)) { if (value != null) { - assertEquals("attribute " + name + " value should match", value, component.getAttributes().get(name)); + assertEquals(value, component.getAttributes().get(name)); } return; } @@ -1665,22 +1682,22 @@ protected void checkAttributePresent(UIComponent component, String name, Object // Validate that the specified number of children are present protected void checkChildCount(UIComponent component, int count) { - assertEquals("child count 1", count, component.getChildCount()); - assertEquals("child count 2", count, component.getChildren().size()); - assertEquals("child count 3", count, component.getChildCount()); + assertEquals(count, component.getChildCount()); + assertEquals(count, component.getChildren().size()); + assertEquals(count, component.getChildCount()); if (count == 0) { - assertTrue("children empty", component.getChildren().isEmpty()); + assertTrue(component.getChildren().isEmpty()); } else { - assertTrue("children not empty", !component.getChildren().isEmpty()); + assertTrue(!component.getChildren().isEmpty()); } } // Validate that the specified child is not present protected void checkChildMissing(UIComponent component, UIComponent child) { - assertNull("child " + child + " has no parent", child.getParent()); + assertNull(child.getParent(), "child " + child + " has no parent"); List children = component.getChildren(); - assertTrue("child " + child + " should not be contained", !children.contains(child)); - assertEquals("child " + child + " should not be found by indexOf", -1, children.indexOf(child)); + assertTrue(!children.contains(child), "child " + child + " should not be contained"); + assertEquals(-1, children.indexOf(child)); for (int i = 0; i < children.size(); i++) { if (child.equals(children.get(i))) { fail("child " + child + " should be missing"); @@ -1691,31 +1708,31 @@ protected void checkChildMissing(UIComponent component, UIComponent child) { // Validate that the specified child is present at the specified index protected void checkChildPresent(UIComponent component, UIComponent child, int index) { List children = component.getChildren(); - assertTrue("child " + child + " should be contained", children.contains(child)); - assertEquals("child " + child + " should be found by indexOf", index, children.indexOf(child)); + assertTrue(children.contains(child), "child " + child + " should be contained"); + assertEquals(index, children.indexOf(child)); UIComponent kid = children.get(index); - assertEquals("child " + child + " should be present", child, kid); - assertEquals("child " + child + " has correct parent", component, kid.getParent()); + assertEquals(child, kid); + assertEquals(component, kid.getParent()); } // Validate that the specified number of facets is present protected void checkFacetCount(UIComponent component, int count) { - assertEquals("facet count", count, component.getFacets().size()); + assertEquals(count, component.getFacets().size()); if (count == 0) { - assertTrue("facets empty", component.getFacets().isEmpty()); + assertTrue(component.getFacets().isEmpty()); } else { - assertTrue("facets not empty", !component.getFacets().isEmpty()); + assertTrue(!component.getFacets().isEmpty()); } } // Validate that the specified facet is not present protected void checkFacetMissing(UIComponent component, String name, UIComponent facet) { - assertNull("facet " + name + " has no parent", facet.getParent()); + assertNull(facet.getParent(), "facet " + name + " has no parent"); Map facets = component.getFacets(); - assertTrue("facet " + name + " key not present", !facets.containsKey(name)); - assertTrue("facet " + name + " value not present", !facets.containsValue(facet)); - assertNull("facet " + name + " key not found by get", facets.get(name)); - assertNull("facet " + name + " not returned by getFacet(String)", component.getFacet(name)); + assertTrue(!facets.containsKey(name), "facet " + name + " key not present"); + assertTrue(!facets.containsValue(facet), "facet " + name + " value not present"); + assertNull(facets.get(name), "facet " + name + " key not found by get"); + assertNull(component.getFacet(name), "facet " + name + " not returned by getFacet(String)"); Iterator keys = facets.keySet().iterator(); while (keys.hasNext()) { String key = keys.next(); @@ -1735,12 +1752,12 @@ protected void checkFacetMissing(UIComponent component, String name, UIComponent // Validate that the specified facet is present protected void checkFacetPresent(UIComponent component, String name, UIComponent facet) { - assertEquals("facet " + name + " has correct parent", component, facet.getParent()); + assertEquals(component, facet.getParent()); Map facets = component.getFacets(); - assertTrue("facet " + name + " key is present", facets.containsKey(name)); - assertTrue("facet " + name + " value is present", facets.containsValue(facet)); - assertEquals("facet " + name + " has correct value", facet, facets.get(name)); - assertTrue("facet " + name + " returned by getFacet(String)", facet == component.getFacet(name)); + assertTrue(facets.containsKey(name), "facet " + name + " key is present"); + assertTrue(facets.containsValue(facet), "facet " + name + " value is present"); + assertEquals(facet, facets.get(name)); + assertTrue(facet == component.getFacet(name), "facet " + name + " returned by getFacet(String)"); boolean found = false; Iterator keys = facets.keySet().iterator(); while (keys.hasNext()) { diff --git a/impl/src/test/java/jakarta/faces/component/UIDataTest.java b/impl/src/test/java/jakarta/faces/component/UIDataTest.java index 392d89a727..7b91edecb3 100644 --- a/impl/src/test/java/jakarta/faces/component/UIDataTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIDataTest.java @@ -21,14 +21,11 @@ import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.powermock.api.easymock.PowerMock.createNicePartialMockAndInvokeDefaultConstructor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.powermock.reflect.Whitebox; import jakarta.faces.context.FacesContext; @@ -96,6 +93,6 @@ public void setRowIndex(int rowIndex) { data.invokeOnComponent(context, "differentId", (contextInLambda, target) -> { }); - assertThat(context.getAttributes().get("setRowIndexCalled"), is(nullValue())); + assertNull(context.getAttributes().get("setRowIndexCalled")); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIGraphicTestCase.java b/impl/src/test/java/jakarta/faces/component/UIGraphicTestCase.java index e3399e052f..01380c37da 100644 --- a/impl/src/test/java/jakarta/faces/component/UIGraphicTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UIGraphicTestCase.java @@ -16,8 +16,11 @@ package jakarta.faces.component; -import junit.framework.Test; -import junit.framework.TestSuite; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** *

@@ -26,19 +29,10 @@ */ public class UIGraphicTestCase extends UIComponentBaseTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public UIGraphicTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); component = new UIGraphic(); @@ -47,14 +41,10 @@ public void setUp() throws Exception { expectedRendererType = "jakarta.faces.Image"; } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UIGraphicTestCase.class); - } - // ------------------------------------------------- Individual Test Methods // Test attribute-property transparency @Override + @Test public void testAttributesTransparency() { super.testAttributesTransparency(); @@ -62,7 +52,7 @@ public void testAttributesTransparency() { assertEquals(graphic.getValue(), component.getAttributes().get("value")); graphic.setValue("foo"); - assertEquals("foo", (String) component.getAttributes().get("value")); + assertEquals("foo", component.getAttributes().get("value")); graphic.setValue(null); assertNull(component.getAttributes().get("value")); component.getAttributes().put("value", "bar"); @@ -70,9 +60,9 @@ public void testAttributesTransparency() { component.getAttributes().put("value", null); assertNull(graphic.getValue()); - assertEquals(graphic.getUrl(), (String) graphic.getAttributes().get("url")); + assertEquals(graphic.getUrl(), graphic.getAttributes().get("url")); graphic.setUrl("foo"); - assertEquals("foo", (String) graphic.getAttributes().get("url")); + assertEquals("foo", graphic.getAttributes().get("url")); graphic.setUrl(null); assertNull(graphic.getAttributes().get("url")); graphic.getAttributes().put("url", "bar"); @@ -83,21 +73,24 @@ public void testAttributesTransparency() { // Suppress lifecycle tests since we do not have a renderer @Override + @Test public void testLifecycleManagement() { } // Test a pristine UIGraphic instance @Override + @Test public void testPristine() { super.testPristine(); UIGraphic graphic = (UIGraphic) component; - assertNull("no value", graphic.getValue()); - assertNull("no url", graphic.getUrl()); + assertNull(graphic.getValue()); + assertNull(graphic.getUrl()); } // Test setting properties to invalid values @Override + @Test public void testPropertiesInvalid() throws Exception { super.testPropertiesInvalid(); } diff --git a/impl/src/test/java/jakarta/faces/component/UIInputTest.java b/impl/src/test/java/jakarta/faces/component/UIInputTest.java index 173c294502..80c174175a 100644 --- a/impl/src/test/java/jakarta/faces/component/UIInputTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIInputTest.java @@ -18,12 +18,13 @@ import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.easymock.EasyMock; -import org.junit.Test; +import org.junit.jupiter.api.Test; import jakarta.faces.context.FacesContext; import jakarta.faces.validator.LengthValidator; @@ -44,10 +45,10 @@ public void testSaveState() { verify(context); } - @Test(expected = NullPointerException.class) + @Test public void testSaveState2() { UIInput input = new UIInput(); - input.saveState(null); + assertThrows(NullPointerException.class, () -> input.saveState(null)); } @Test @@ -89,12 +90,12 @@ public void testRestoreState() { verify(context); } - @Test(expected = NullPointerException.class) + @Test public void testRestoreState2() { FacesContext context = EasyMock.createMock(FacesContext.class); UIInput input = new UIInput(); replay(context); - input.restoreState(null, null); + assertThrows(NullPointerException.class, () -> input.restoreState(null, null)); verify(context); } diff --git a/impl/src/test/java/jakarta/faces/component/UIInputTestCase.java b/impl/src/test/java/jakarta/faces/component/UIInputTestCase.java index 339ff2d173..1013cd5732 100644 --- a/impl/src/test/java/jakarta/faces/component/UIInputTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UIInputTestCase.java @@ -16,16 +16,22 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Iterator; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import jakarta.faces.application.FacesMessage; import jakarta.faces.context.FacesContext; import jakarta.faces.event.PhaseId; import jakarta.faces.event.ValueChangeEvent; import jakarta.faces.event.ValueChangeListener; import jakarta.faces.validator.Validator; -import junit.framework.Test; -import junit.framework.TestSuite; /** *

@@ -34,19 +40,10 @@ */ public class UIInputTestCase extends UIOutputTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public UIInputTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); component = new UIInput(); @@ -54,21 +51,17 @@ public void setUp() throws Exception { expectedRendererType = "jakarta.faces.Text"; } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UIInputTestCase.class); - } - // ------------------------------------------------- Individual Test Methods // Test attribute-property transparency @Override + @Test public void testAttributesTransparency() { super.testAttributesTransparency(); UIInput input = (UIInput) component; assertEquals(input.getSubmittedValue(), input.getAttributes().get("submittedValue")); input.setSubmittedValue("foo"); - assertEquals("foo", (String) input.getAttributes().get("submittedValue")); + assertEquals("foo", input.getAttributes().get("submittedValue")); input.setSubmittedValue(null); assertNull(input.getAttributes().get("submittedValue")); input.getAttributes().put("submittedValue", "bar"); @@ -95,6 +88,7 @@ public void testAttributesTransparency() { } // Test the compareValues() method + @Test public void testCompareValues() { InputTestImpl input = new InputTestImpl(); Object value1a = "foo"; @@ -115,6 +109,7 @@ public void testCompareValues() { } // Test event queuing and broadcasting (any phase listeners) + @Test public void testEventsGeneric() { UIInput input = (UIInput) component; ValueChangeEvent event = new ValueChangeEvent(input, null, null); @@ -131,6 +126,7 @@ public void testEventsGeneric() { } // Test event queuing and broadcasting (mixed phase listeners) + @Test public void testEventsMixed() { UIInput input = (UIInput) component; input.setRendererType(null); @@ -164,6 +160,7 @@ public void testEventsMixed() { } // Test listener registration and deregistration + @Test public void testListeners() { InputTestImpl input = new InputTestImpl(); @@ -181,6 +178,7 @@ public void testListeners() { } // Test empty listener list + @Test public void testEmptyListeners() { InputTestImpl input = new InputTestImpl(); @@ -191,24 +189,27 @@ public void testEmptyListeners() { // Test a pristine UIInput instance @Override + @Test public void testPristine() { super.testPristine(); UIInput input = (UIInput) component; - assertNull("no submittedValue", input.getSubmittedValue()); - assertTrue("not required", !input.isRequired()); - assertTrue("is valid", input.isValid()); - assertTrue("is not immediate", !input.isImmediate()); + assertNull(input.getSubmittedValue()); + assertTrue(!input.isRequired()); + assertTrue(input.isValid()); + assertTrue(!input.isImmediate()); } // Test setting properties to invalid values @Override + @Test public void testPropertiesInvalid() throws Exception { super.testPropertiesInvalid(); UIInput input = (UIInput) component; } // Test validation of a required field + @Test public void testValidateRequired() throws Exception { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); root.getChildren().add(component); @@ -245,6 +246,7 @@ public void testValidateRequired() throws Exception { assertTrue(input.isValid()); } + @Test public void testGetValueChangeListeners() throws Exception { UIInput command = (UIInput) component; UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); @@ -269,11 +271,11 @@ protected void checkMessages(int expected) { Iterator messages = facesContext.getMessages(); while (messages.hasNext()) { FacesMessage message = messages.next(); - assertEquals("Severity == ERROR", FacesMessage.SEVERITY_ERROR, message.getSeverity()); + assertEquals(FacesMessage.SEVERITY_ERROR, message.getSeverity()); n++; // System.err.println(message.getSummary()); } - assertEquals("expected message count", expected, n); + assertEquals(expected, n); } // Create a pristine component of the type to be used in state holder tests diff --git a/impl/src/test/java/jakarta/faces/component/UIOutputAttachedObjectStateTestCase.java b/impl/src/test/java/jakarta/faces/component/UIOutputAttachedObjectStateTestCase.java index 4f99e07294..cabd4b5704 100644 --- a/impl/src/test/java/jakarta/faces/component/UIOutputAttachedObjectStateTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UIOutputAttachedObjectStateTestCase.java @@ -16,8 +16,17 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.lang.reflect.Method; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.faces.mock.MockExternalContext; import com.sun.faces.mock.MockFacesContext; import com.sun.faces.mock.MockHttpServletRequest; @@ -28,29 +37,16 @@ import jakarta.faces.FactoryFinder; import jakarta.faces.convert.Converter; import jakarta.faces.convert.DateTimeConverter; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -public class UIOutputAttachedObjectStateTestCase extends TestCase { +public class UIOutputAttachedObjectStateTestCase { private MockFacesContext facesContext = null; private MockServletContext servletContext; private MockHttpServletRequest request; private MockHttpServletResponse response; - public UIOutputAttachedObjectStateTestCase(String arg0) { - super(arg0); - } - - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UIOutputAttachedObjectStateTestCase.class); - } - - @Override + @BeforeEach public void setUp() throws Exception { - super.setUp(); facesContext = new MockFacesContext(); facesContext = new MockFacesContext(); @@ -66,9 +62,8 @@ public void setUp() throws Exception { } - @Override + @AfterEach protected void tearDown() throws Exception { - super.tearDown(); FactoryFinder.releaseFactories(); Method reInitializeFactoryManager = FactoryFinder.class.getDeclaredMethod("reInitializeFactoryManager", (Class[]) null); reInitializeFactoryManager.setAccessible(true); @@ -76,6 +71,8 @@ protected void tearDown() throws Exception { } // ------------------------------------------------------------ Test Methods + + @Test public void testConverterState() { UIOutput output = new UIOutput(); DateTimeConverter converter = new DateTimeConverter(); @@ -124,7 +121,7 @@ public void testConverterState() { // for the component. output.restoreState(facesContext, state); assertTrue(output.getConverter() != null); - assertTrue("dd-MM-yy".equals(converter.getPattern())); + assertEquals("dd-MM-yy", converter.getPattern()); // now validate the case where UIOutput has some event // that adds a converter *after* initial state has been @@ -154,6 +151,6 @@ public void testConverterState() { assertNotNull(c); assertTrue(c instanceof DateTimeConverter); converter = (DateTimeConverter) c; - assertTrue("dd-MM-yy".equals(converter.getPattern())); + assertEquals("dd-MM-yy", converter.getPattern()); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIOutputTestCase.java b/impl/src/test/java/jakarta/faces/component/UIOutputTestCase.java index e8520ade88..c5a620a011 100644 --- a/impl/src/test/java/jakarta/faces/component/UIOutputTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UIOutputTestCase.java @@ -16,8 +16,8 @@ package jakarta.faces.component; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** *

@@ -26,19 +26,10 @@ */ public class UIOutputTestCase extends ValueHolderTestCaseBase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public UIOutputTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); component = new UIOutput(); @@ -47,14 +38,10 @@ public void setUp() throws Exception { expectedRendererType = "jakarta.faces.Text"; } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UIOutputTestCase.class); - } - // ------------------------------------------------- Individual Test Methods // Suppress lifecycle tests since we do not have a renderer @Override + @Test public void testLifecycleManagement() { } diff --git a/impl/src/test/java/jakarta/faces/component/UIPanelTestCase.java b/impl/src/test/java/jakarta/faces/component/UIPanelTestCase.java index e79b15d395..d551eaaa97 100644 --- a/impl/src/test/java/jakarta/faces/component/UIPanelTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UIPanelTestCase.java @@ -16,8 +16,8 @@ package jakarta.faces.component; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** *

@@ -26,19 +26,10 @@ */ public class UIPanelTestCase extends UIComponentBaseTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public UIPanelTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); component = new UIPanel(); @@ -48,14 +39,10 @@ public void setUp() throws Exception { expectedRendersChildren = false; } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UIPanelTestCase.class); - } - // ------------------------------------------------- Individual Test Methods // Suppress lifecycle tests since we do not have a renderer @Override + @Test public void testLifecycleManagement() { } diff --git a/impl/src/test/java/jakarta/faces/component/UIParameterTest.java b/impl/src/test/java/jakarta/faces/component/UIParameterTest.java index 9b53117b78..8fa156263a 100644 --- a/impl/src/test/java/jakarta/faces/component/UIParameterTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIParameterTest.java @@ -19,11 +19,11 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.powermock.api.easymock.PowerMock; import jakarta.el.ELContext; diff --git a/impl/src/test/java/jakarta/faces/component/UIParameterTestCase.java b/impl/src/test/java/jakarta/faces/component/UIParameterTestCase.java index d720720e29..a8b312a8cb 100644 --- a/impl/src/test/java/jakarta/faces/component/UIParameterTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UIParameterTestCase.java @@ -16,8 +16,11 @@ package jakarta.faces.component; -import junit.framework.Test; -import junit.framework.TestSuite; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** *

@@ -26,19 +29,10 @@ */ public class UIParameterTestCase extends UIComponentBaseTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public UIParameterTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); component = new UIParameter(); @@ -47,21 +41,17 @@ public void setUp() throws Exception { expectedRendererType = null; } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UIParameterTestCase.class); - } - // ------------------------------------------------- Individual Test Methods // Test attribute-property transparency @Override + @Test public void testAttributesTransparency() { super.testAttributesTransparency(); UIParameter parameter = (UIParameter) component; assertEquals(parameter.getValue(), component.getAttributes().get("value")); parameter.setValue("foo"); - assertEquals("foo", (String) component.getAttributes().get("value")); + assertEquals("foo", component.getAttributes().get("value")); parameter.setValue(null); assertNull(component.getAttributes().get("value")); component.getAttributes().put("value", "bar"); @@ -69,9 +59,9 @@ public void testAttributesTransparency() { component.getAttributes().put("value", null); assertNull(parameter.getValue()); - assertEquals(parameter.getName(), (String) parameter.getAttributes().get("name")); + assertEquals(parameter.getName(), parameter.getAttributes().get("name")); parameter.setName("foo"); - assertEquals("foo", (String) parameter.getAttributes().get("name")); + assertEquals("foo", parameter.getAttributes().get("name")); parameter.setName(null); assertNull(parameter.getAttributes().get("name")); parameter.getAttributes().put("name", "bar"); @@ -82,30 +72,33 @@ public void testAttributesTransparency() { // Suppress lifecycle tests since we do not have a renderer @Override + @Test public void testLifecycleManagement() { } // Test a pristine UIParameter instance @Override + @Test public void testPristine() { super.testPristine(); UIParameter parameter = (UIParameter) component; - assertNull("no value", parameter.getValue()); - assertNull("no name", parameter.getName()); + assertNull(parameter.getValue()); + assertNull(parameter.getName()); } // Test setting properties to valid values @Override + @Test public void testPropertiesValid() throws Exception { super.testPropertiesValid(); UIParameter parameter = (UIParameter) component; // value parameter.setValue("foo.bar"); - assertEquals("expected value", "foo.bar", parameter.getValue()); + assertEquals("foo.bar", parameter.getValue()); parameter.setValue(null); - assertNull("erased value", parameter.getValue()); + assertNull(parameter.getValue()); parameter.setName("foo"); assertEquals("foo", parameter.getName()); diff --git a/impl/src/test/java/jakarta/faces/component/UISelectBooleanTestCase.java b/impl/src/test/java/jakarta/faces/component/UISelectBooleanTestCase.java index 00e01b26bf..423bf4c708 100644 --- a/impl/src/test/java/jakarta/faces/component/UISelectBooleanTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UISelectBooleanTestCase.java @@ -16,8 +16,11 @@ package jakarta.faces.component; -import junit.framework.Test; -import junit.framework.TestSuite; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** *

@@ -26,19 +29,10 @@ */ public class UISelectBooleanTestCase extends UIInputTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public UISelectBooleanTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); component = new UISelectBoolean(); @@ -46,14 +40,10 @@ public void setUp() throws Exception { expectedRendererType = "jakarta.faces.Checkbox"; } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UISelectBooleanTestCase.class); - } - // ------------------------------------------------- Individual Test Methods // Test attribute-property transparency @Override + @Test public void testAttributesTransparency() { super.testAttributesTransparency(); UISelectBoolean selectBoolean = (UISelectBoolean) component; @@ -70,10 +60,11 @@ public void testAttributesTransparency() { // Test a pristine UISelectBoolean instance @Override + @Test public void testPristine() { super.testPristine(); UISelectBoolean selectBoolean = (UISelectBoolean) component; - assertTrue("not selected", !selectBoolean.isSelected()); + assertTrue(!selectBoolean.isSelected()); } // --------------------------------------------------------- Support Methods diff --git a/impl/src/test/java/jakarta/faces/component/UISelectItemSub.java b/impl/src/test/java/jakarta/faces/component/UISelectItemSub.java index fd58550a6d..bdb949ae80 100644 --- a/impl/src/test/java/jakarta/faces/component/UISelectItemSub.java +++ b/impl/src/test/java/jakarta/faces/component/UISelectItemSub.java @@ -19,7 +19,6 @@ public class UISelectItemSub extends UISelectItem { public UISelectItemSub(String value, String label, String description) { - super(); setItemValue(value); setItemLabel(label); setItemDescription(description); diff --git a/impl/src/test/java/jakarta/faces/component/UISelectItemTestCase.java b/impl/src/test/java/jakarta/faces/component/UISelectItemTestCase.java index ead566ec80..4cb3712e38 100644 --- a/impl/src/test/java/jakarta/faces/component/UISelectItemTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UISelectItemTestCase.java @@ -16,9 +16,15 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import jakarta.faces.model.SelectItem; -import junit.framework.Test; -import junit.framework.TestSuite; /** *

@@ -27,19 +33,10 @@ */ public class UISelectItemTestCase extends UIComponentBaseTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public UISelectItemTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); component = new UISelectItem(); @@ -48,19 +45,16 @@ public void setUp() throws Exception { expectedRendererType = null; } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UISelectItemTestCase.class); - } - // ------------------------------------------------- Individual Test Methods // Suppress lifecycle tests since we do not have a renderer @Override + @Test public void testLifecycleManagement() { } // Test attribute-property transparency @Override + @Test public void testAttributesTransparency() { super.testAttributesTransparency(); UISelectItem selectItem = (UISelectItem) component; @@ -77,9 +71,9 @@ public void testAttributesTransparency() { component.getAttributes().put("value", null); assertNull(selectItem.getValue()); - assertEquals(selectItem.getItemDescription(), (String) selectItem.getAttributes().get("itemDescription")); + assertEquals(selectItem.getItemDescription(), selectItem.getAttributes().get("itemDescription")); selectItem.setItemDescription("foo"); - assertEquals("foo", (String) selectItem.getAttributes().get("itemDescription")); + assertEquals("foo", selectItem.getAttributes().get("itemDescription")); selectItem.setItemDescription(null); assertNull(selectItem.getAttributes().get("itemDescription")); selectItem.getAttributes().put("itemDescription", "bar"); @@ -97,9 +91,9 @@ public void testAttributesTransparency() { selectItem.getAttributes().put("itemDisabled", Boolean.TRUE); assertTrue(selectItem.isItemDisabled()); - assertEquals(selectItem.getItemLabel(), (String) selectItem.getAttributes().get("itemLabel")); + assertEquals(selectItem.getItemLabel(), selectItem.getAttributes().get("itemLabel")); selectItem.setItemLabel("foo"); - assertEquals("foo", (String) selectItem.getAttributes().get("itemLabel")); + assertEquals("foo", selectItem.getAttributes().get("itemLabel")); selectItem.setItemLabel(null); assertNull(selectItem.getAttributes().get("itemLabel")); selectItem.getAttributes().put("itemLabel", "bar"); @@ -109,7 +103,7 @@ public void testAttributesTransparency() { assertEquals(selectItem.getItemValue(), selectItem.getAttributes().get("itemValue")); selectItem.setItemValue("foo"); - assertEquals("foo", (String) selectItem.getAttributes().get("itemValue")); + assertEquals("foo", selectItem.getAttributes().get("itemValue")); selectItem.setItemValue(null); assertNull(selectItem.getAttributes().get("itemValue")); selectItem.getAttributes().put("itemValue", "bar"); @@ -120,19 +114,21 @@ public void testAttributesTransparency() { // Test a pristine UISelectItem instance @Override + @Test public void testPristine() { super.testPristine(); UISelectItem selectItem = (UISelectItem) component; - assertNull("no value", selectItem.getValue()); - assertNull("no itemDescription", selectItem.getItemDescription()); - assertFalse("no itemDisabled", selectItem.isItemDisabled()); - assertNull("no itemLabel", selectItem.getItemLabel()); - assertNull("no itemValue", selectItem.getItemValue()); + assertNull(selectItem.getValue()); + assertNull(selectItem.getItemDescription()); + assertFalse(selectItem.isItemDisabled()); + assertNull(selectItem.getItemLabel()); + assertNull(selectItem.getItemValue()); } // Test setting properties to valid values @Override + @Test public void testPropertiesValid() throws Exception { super.testPropertiesValid(); UISelectItem selectItem = (UISelectItem) component; @@ -140,9 +136,9 @@ public void testPropertiesValid() throws Exception { // value SelectItem item = new SelectItem("foo"); selectItem.setValue(item); - assertEquals("expected value", item, selectItem.getValue()); + assertEquals(item, selectItem.getValue()); selectItem.setValue(null); - assertNull("erased value", selectItem.getValue()); + assertNull(selectItem.getValue()); selectItem.setItemDescription("foo"); assertEquals("foo", selectItem.getItemDescription()); diff --git a/impl/src/test/java/jakarta/faces/component/UISelectItemsTestCase.java b/impl/src/test/java/jakarta/faces/component/UISelectItemsTestCase.java index a4a6bc9c36..cde6a1e6b1 100644 --- a/impl/src/test/java/jakarta/faces/component/UISelectItemsTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UISelectItemsTestCase.java @@ -16,9 +16,13 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import jakarta.faces.model.SelectItem; -import junit.framework.Test; -import junit.framework.TestSuite; /** *

@@ -27,19 +31,10 @@ */ public class UISelectItemsTestCase extends UIComponentBaseTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public UISelectItemsTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); component = new UISelectItems(); @@ -48,14 +43,10 @@ public void setUp() throws Exception { expectedRendererType = null; } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UISelectItemsTestCase.class); - } - // ------------------------------------------------- Individual Test Methods // Test attribute-property transparency @Override + @Test public void testAttributesTransparency() { super.testAttributesTransparency(); UISelectItems selectItems = (UISelectItems) component; @@ -74,19 +65,22 @@ public void testAttributesTransparency() { // Suppress lifecycle tests since we do not have a renderer @Override + @Test public void testLifecycleManagement() { } // Test a pristine UISelectItems instance @Override + @Test public void testPristine() { super.testPristine(); UISelectItems selectItems = (UISelectItems) component; - assertNull("no value", selectItems.getValue()); + assertNull(selectItems.getValue()); } // Test setting properties to valid values @Override + @Test public void testPropertiesValid() throws Exception { super.testPropertiesValid(); UISelectItems selectItems = (UISelectItems) component; @@ -94,9 +88,9 @@ public void testPropertiesValid() throws Exception { // value SelectItem item = new SelectItem("foo"); selectItems.setValue(item); - assertEquals("expected value", item, selectItems.getValue()); + assertEquals(item, selectItems.getValue()); selectItems.setValue(null); - assertNull("erased value", selectItems.getValue()); + assertNull(selectItems.getValue()); } // --------------------------------------------------------- Support Methods diff --git a/impl/src/test/java/jakarta/faces/component/UISelectManyTestCase.java b/impl/src/test/java/jakarta/faces/component/UISelectManyTestCase.java index d7f6bec985..019f132a87 100644 --- a/impl/src/test/java/jakarta/faces/component/UISelectManyTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UISelectManyTestCase.java @@ -16,6 +16,12 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -27,14 +33,15 @@ import java.util.NoSuchElementException; import java.util.Set; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.faces.renderkit.SelectItemsIterator; import jakarta.faces.application.FacesMessage; import jakarta.faces.model.ListDataModel; import jakarta.faces.model.SelectItem; import jakarta.faces.model.SelectItemGroup; -import junit.framework.Test; -import junit.framework.TestSuite; /** *

@@ -43,19 +50,10 @@ */ public class UISelectManyTestCase extends UIInputTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public UISelectManyTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); component = new UISelectMany(); @@ -63,14 +61,10 @@ public void setUp() throws Exception { expectedRendererType = "jakarta.faces.Listbox"; } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UISelectManyTestCase.class); - } - // ------------------------------------------------- Individual Test Methods // Test the compareValues() method @Override + @Test public void testCompareValues() { SelectManyTestImpl selectMany = new SelectManyTestImpl(); Object values1a[] = new Object[] { "foo", "bar", "baz" }; @@ -99,20 +93,23 @@ public void testCompareValues() { // Test a pristine UISelectMany instance @Override + @Test public void testPristine() { super.testPristine(); UISelectMany selectMany = (UISelectMany) component; - assertNull("no selectedValues", selectMany.getSelectedValues()); + assertNull(selectMany.getSelectedValues()); } // Test setting properties to invalid values @Override + @Test public void testPropertiesInvalid() throws Exception { super.testPropertiesInvalid(); } // Test validation of value against the valid list + @Test public void testValidation() throws Exception { // Put our component under test in a tree under a UIViewRoot UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); @@ -146,6 +143,7 @@ public void testValidation() throws Exception { } // Test validation of component with UISelectItems pointing to map + @Test public void testValidation2() throws Exception { // Put our component under test in a tree under a UIViewRoot UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); @@ -177,6 +175,7 @@ public void testValidation2() throws Exception { // Test validation of component with UISelectItems pointing to Set and the // value of the component is Set + @Test public void testValidation3() throws Exception { Set items = new HashSet<>(); items.add(new SelectItem("foo")); @@ -192,6 +191,7 @@ public void testValidation3() throws Exception { } // Test validation of component with UISelectItems pointing to List + @Test public void testValidation4() throws Exception { List items = new ArrayList<>(); items.add(new SelectItem("foo")); @@ -207,6 +207,7 @@ public void testValidation4() throws Exception { } // Test validation of component with UISelectItems pointing to an Array + @Test public void testValidation5() throws Exception { // Put our component under test in a tree under a UIViewRoot UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); @@ -260,6 +261,7 @@ private void testValidateWithCollection(Collection selectItems, Obje private String illegalValues[] = { "D1", "D2", "Group A", "Group B", "Group C" }; // Test validation against a nested list of available options + @Test public void testValidateNested() throws Exception { // Set up UISelectMany with nested UISelectItems UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); @@ -276,7 +278,7 @@ public void testValidateNested() throws Exception { selectMany.setValid(true); selectMany.setSubmittedValue(new Object[] { legalValues[0], legalValues[i] }); selectMany.validate(facesContext); - assertTrue("Value '" + legalValues[i] + "' found", selectMany.isValid()); + assertTrue(selectMany.isValid(), "Value '" + legalValues[i] + "' found"); checkMessages(0); } @@ -285,12 +287,13 @@ public void testValidateNested() throws Exception { selectMany.setValid(true); selectMany.setSubmittedValue(new Object[] { legalValues[0], illegalValues[i] }); selectMany.validate(facesContext); - assertTrue("Value '" + illegalValues[i] + "' not found", !selectMany.isValid()); + assertTrue(!selectMany.isValid(), "Value '" + illegalValues[i] + "' not found"); checkMessages(i + 1); } } // Test validation against a nested Set of available options + @Test public void testValidateNestedSet() throws Exception { // Set up UISelectMany with nested UISelectItems UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); @@ -307,7 +310,7 @@ public void testValidateNestedSet() throws Exception { selectMany.setValid(true); selectMany.setSubmittedValue(new Object[] { legalValues[0], legalValues[i] }); selectMany.validate(facesContext); - assertTrue("Value '" + legalValues[i] + "' found", selectMany.isValid()); + assertTrue(selectMany.isValid(), "Value '" + legalValues[i] + "' found"); checkMessages(0); } @@ -316,13 +319,14 @@ public void testValidateNestedSet() throws Exception { selectMany.setValid(true); selectMany.setSubmittedValue(new Object[] { legalValues[0], illegalValues[i] }); selectMany.validate(facesContext); - assertTrue("Value '" + illegalValues[i] + "' not found", !selectMany.isValid()); + assertTrue(!selectMany.isValid(), "Value '" + illegalValues[i] + "' not found"); checkMessages(i + 1); } } // Test validation of a required field @Override + @Test public void testValidateRequired() throws Exception { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); root.getChildren().add(component); @@ -361,6 +365,7 @@ public void testValidateRequired() throws Exception { assertTrue(selectMany.isValid()); } + @Test public void testSelectItemsIterator() { // sub test 1: non-selectitem at end UISelectMany selectMany = (UISelectMany) component; diff --git a/impl/src/test/java/jakarta/faces/component/UISelectOneTestCase.java b/impl/src/test/java/jakarta/faces/component/UISelectOneTestCase.java index 26f5e4f42a..dae1499e7f 100644 --- a/impl/src/test/java/jakarta/faces/component/UISelectOneTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UISelectOneTestCase.java @@ -16,6 +16,8 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -25,11 +27,12 @@ import java.util.Map; import java.util.Set; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import jakarta.faces.application.FacesMessage; import jakarta.faces.model.SelectItem; import jakarta.faces.model.SelectItemGroup; -import junit.framework.Test; -import junit.framework.TestSuite; /** *

@@ -38,19 +41,10 @@ */ public class UISelectOneTestCase extends UIInputTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public UISelectOneTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); component = new UISelectOne(); @@ -58,13 +52,9 @@ public void setUp() throws Exception { expectedRendererType = "jakarta.faces.Menu"; } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(UISelectOneTestCase.class); - } - // ------------------------------------------------- Individual Test Methods // Test validation of value against the valid list + @Test public void testValidation() throws Exception { // Put our component under test in a tree under a UIViewRoot UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); @@ -97,6 +87,7 @@ public void testValidation() throws Exception { } // Test validation of component with UISelectItems pointing to map + @Test public void testValidation2() throws Exception { // Put our component under test in a tree under a UIViewRoot UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); @@ -126,6 +117,7 @@ public void testValidation2() throws Exception { } // Test validation of component with UISelectItems pointing to Set + @Test public void testValidation3() throws Exception { Set items = new HashSet<>(); items.add(new SelectItem("foo")); @@ -136,6 +128,7 @@ public void testValidation3() throws Exception { } // Test validation of component with UISelectItems pointing to List + @Test public void testValidation4() throws Exception { List items = new ArrayList<>(); items.add(new SelectItem("foo")); @@ -146,6 +139,7 @@ public void testValidation4() throws Exception { } // Test validation of component with UISelectItems pointing to an Array + @Test public void testValidation5() throws Exception { // Put our component under test in a tree under a UIViewRoot UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); @@ -198,6 +192,7 @@ private void testValidateWithCollection(Collection selectItems, Stri private String illegalValues[] = { "D1", "D2", "Group A", "Group B", "Group C" }; // Test validation against a nested list of available options + @Test public void testValidateNested() throws Exception { // Set up UISelectOne with nested UISelectItems UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); @@ -214,7 +209,7 @@ public void testValidateNested() throws Exception { selectOne.setValid(true); selectOne.setSubmittedValue(legalValues[i]); selectOne.validate(facesContext); - assertTrue("Value '" + legalValues[i] + "' found", selectOne.isValid()); + assertTrue(selectOne.isValid(), "Value '" + legalValues[i] + "' found"); checkMessages(0); } @@ -223,13 +218,14 @@ public void testValidateNested() throws Exception { selectOne.setValid(true); selectOne.setSubmittedValue(illegalValues[i]); selectOne.validate(facesContext); - assertTrue("Value '" + illegalValues[i] + "' not found", !selectOne.isValid()); + assertTrue(!selectOne.isValid(), "Value '" + illegalValues[i] + "' not found"); checkMessages(i + 1); } } // Test validation of a required field @Override + @Test public void testValidateRequired() throws Exception { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); root.getChildren().add(component); @@ -260,6 +256,7 @@ public void testValidateRequired() throws Exception { assertTrue(selectOne.isValid()); } + @Test public void testSelectItemsIterator() { // sub test 1 : non-selectItem at end UISelectOne selectOne = (UISelectOne) component; diff --git a/impl/src/test/java/jakarta/faces/component/UIViewRootTest.java b/impl/src/test/java/jakarta/faces/component/UIViewRootTest.java index ff3fd11a97..c3125e3659 100644 --- a/impl/src/test/java/jakarta/faces/component/UIViewRootTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIViewRootTest.java @@ -20,15 +20,15 @@ import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.reset; import static org.easymock.EasyMock.verify; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; import org.easymock.EasyMock; -import org.junit.Test; +import org.junit.jupiter.api.Test; import jakarta.faces.application.Application; import jakarta.faces.application.ProjectStage; diff --git a/impl/src/test/java/jakarta/faces/component/UIViewRootTestCase.java b/impl/src/test/java/jakarta/faces/component/UIViewRootTestCase.java index 8137f695e2..8f4b1b8972 100644 --- a/impl/src/test/java/jakarta/faces/component/UIViewRootTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UIViewRootTestCase.java @@ -16,11 +16,21 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.IOException; import java.lang.reflect.Field; import java.util.List; import java.util.Locale; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.faces.mock.MockRenderKit; import jakarta.el.MethodExpression; @@ -34,8 +44,6 @@ import jakarta.faces.event.PostRestoreStateEvent; import jakarta.faces.render.RenderKit; import jakarta.faces.render.RenderKitFactory; -import junit.framework.Test; -import junit.framework.TestSuite; /** *

@@ -44,30 +52,13 @@ */ public class UIViewRootTestCase extends UIComponentBaseTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public UIViewRootTestCase(String name) { - super(name); - } - - // ---------------------------------------------------- Overall Test Methods - /** - * Return the tests included in this test suite. - */ - public static Test suite() { - return new TestSuite(UIViewRootTestCase.class); - } - public static String FACTORIES[][] = { { FactoryFinder.APPLICATION_FACTORY, "com.sun.faces.mock.MockApplicationFactory" }, { FactoryFinder.FACES_CONTEXT_FACTORY, "com.sun.faces.mock.MockFacesContextFactory" }, { FactoryFinder.LIFECYCLE_FACTORY, "com.sun.faces.mock.MockLifecycleFactory" }, { FactoryFinder.RENDER_KIT_FACTORY, "com.sun.faces.mock.MockRenderKitFactory" } }; @Override + @BeforeEach public void setUp() throws Exception { FactoryFinder.releaseFactories(); super.setUp(); @@ -100,12 +91,14 @@ public void setUp() throws Exception { * @throws java.lang.Exception */ @Override + @AfterEach public void tearDown() throws Exception { component = null; super.tearDown(); } // ------------------------------------------------- Individual Test Methods + @Test public void testAddGetComponentResources() { application.addComponent("jakarta.faces.ComponentResourceContainer", Container.class.getName()); UIViewRoot root = new UIViewRoot(); @@ -147,6 +140,7 @@ public void testAddGetComponentResources() { } // Tests that the resources are rendered again if renderall, @all, is set + @Test public void testRenderAllComponentResources() { application.addComponent("jakarta.faces.ComponentResourceContainer", Container.class.getName()); UIViewRoot previousRoot = facesContext.getViewRoot(); @@ -169,13 +163,13 @@ public void testRenderAllComponentResources() { postRestoreStateEvent.setComponent(root); root.processEvent(postRestoreStateEvent); - assertFalse("Resource should not be marked as rendered", resourceHandler.isResourceRendered(facesContext, "scriptTest", "scriptLibrary")); + assertFalse(resourceHandler.isResourceRendered(facesContext, "scriptTest", "scriptLibrary")); // partial update i.e. @form facesContext.getPartialViewContext().setRenderAll(false); root.processEvent(postRestoreStateEvent); - assertTrue("Resource should be marked as rendered", resourceHandler.isResourceRendered(facesContext, "scriptTest", "scriptLibrary")); + assertTrue(resourceHandler.isResourceRendered(facesContext, "scriptTest", "scriptLibrary")); facesContext.getPartialViewContext().setPartialRequest(false); facesContext.getPartialViewContext().setRenderAll(false); @@ -184,6 +178,7 @@ public void testRenderAllComponentResources() { } // Test AbortProcessingException support + @Test public void testAbortProcessingException() { // Register three listeners, with the second one set to abort UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); @@ -205,6 +200,7 @@ public void testAbortProcessingException() { } // Test event queuing and dequeuing during broadcasting + @Test public void testEventBroadcasting() { // Register a listener that will conditionally queue a new event UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); @@ -233,6 +229,7 @@ public void testEventBroadcasting() { } // Test event queuing and broadcasting + @Test public void testEventQueuing() { // Check for correct ifecycle management processing of event broadcast checkEventQueueing(PhaseId.APPLY_REQUEST_VALUES); @@ -242,6 +239,7 @@ public void testEventQueuing() { checkEventQueueing(PhaseId.ANY_PHASE); } + @Test public void testLocaleFromVB() throws Exception { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); facesContext.setViewRoot(root); @@ -263,6 +261,7 @@ public void testLocaleFromVB() throws Exception { assertEquals(Locale.CANADA_FRENCH, root.getLocale()); } + @Test public void testUninitializedInstance() throws Exception { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); facesContext.setViewRoot(root); @@ -270,42 +269,49 @@ public void testUninitializedInstance() throws Exception { assertEquals(Locale.getDefault(), root.getLocale()); } + @Test public void testPhaseMethExpression() throws Exception { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); facesContext.setViewRoot(root); doTestPhaseMethodExpression(root, false); } + @Test public void testPhaseMethExpressionSkipping() throws Exception { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); facesContext.setViewRoot(root); doTestPhaseMethodExpression(root, true); } + @Test public void testPhaseListener() throws Exception { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); facesContext.setViewRoot(root); doTestPhaseListener(root, false); } + @Test public void testPhaseListenerSkipping() throws Exception { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); facesContext.setViewRoot(root); doTestPhaseListener(root, true); } + @Test public void testPhaseMethodExpressionAndListener() throws Exception { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); facesContext.setViewRoot(root); doTestPhaseMethodExpressionAndListener(root, false); } + @Test public void testPhaseMethodExpressionAndListenerSkipping() throws Exception { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); facesContext.setViewRoot(root); doTestPhaseMethodExpressionAndListener(root, true); } + @Test public void testPhaseMethExpressionState() throws Exception { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); facesContext.setViewRoot(root); @@ -317,6 +323,7 @@ public void testPhaseMethExpressionState() throws Exception { doTestPhaseMethodExpression(root, false); } + @Test public void testPhaseListenerState() throws Exception { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); facesContext.setViewRoot(root); @@ -328,6 +335,7 @@ public void testPhaseListenerState() throws Exception { doTestPhaseListener(root, false); } + @Test public void testPhaseMethodExpressionAndListenerState() throws Exception { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); facesContext.setViewRoot(root); @@ -339,6 +347,7 @@ public void testPhaseMethodExpressionAndListenerState() throws Exception { doTestPhaseMethodExpressionAndListener(root, false); } + @Test public void testPhaseListenerExceptions() throws Exception { PhaseId[] ids = { PhaseId.APPLY_REQUEST_VALUES, PhaseId.PROCESS_VALIDATIONS, PhaseId.UPDATE_MODEL_VALUES, PhaseId.INVOKE_APPLICATION, PhaseId.RENDER_RESPONSE }; @@ -518,16 +527,17 @@ public void doTestPhaseMethodExpressionAndListenerWithPhaseId(UIViewRoot root, P private void checkEventQueuesSizes(List events, int applyEventsSize, int valEventsSize, int updateEventsSize, int appEventsSize) { List applyEvents = events.get(PhaseId.APPLY_REQUEST_VALUES.getOrdinal()); - assertEquals("Apply-Request-Values Event Count", applyEventsSize, applyEvents.size()); + assertEquals(applyEventsSize, applyEvents.size()); List valEvents = events.get(PhaseId.PROCESS_VALIDATIONS.getOrdinal()); - assertEquals("Process-Validations Event Count", valEventsSize, valEvents.size()); + assertEquals(valEventsSize, valEvents.size()); List updateEvents = events.get(PhaseId.UPDATE_MODEL_VALUES.getOrdinal()); - assertEquals("Update-Model Event Count", updateEventsSize, updateEvents.size()); + assertEquals(updateEventsSize, updateEvents.size()); List appEvents = events.get(PhaseId.INVOKE_APPLICATION.getOrdinal()); - assertEquals("Invoke-Application Event Count", appEventsSize, appEvents.size()); + assertEquals(appEventsSize, appEvents.size()); } // Test Events List Clearing + @Test public void testEventsListClear() { UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); facesContext.setViewRoot(root); @@ -646,7 +656,7 @@ public void testEventsListClear() { } catch (Exception e) { assertTrue(false); } - assertNull("events", events); + assertNull(events); } private void callRightLifecycleMethodGivenPhaseId(UIViewRoot root, PhaseId phaseId) throws Exception { @@ -720,30 +730,35 @@ private void checkEventQueueing(PhaseId phaseId) { // These overrides are necessary because our normal setup // calls releaseFactories, which makes it impossible to get clientIds. @Override + @Test public void testInvokeOnComponentPositive() throws Exception { super.setUp(); super.testInvokeOnComponentPositive(); } @Override + @Test public void testInvokeOnComponentNegative() throws Exception { super.setUp(); super.testInvokeOnComponentNegative(); } @Override + @Test public void testInvokeOnComponentWithPrependId() throws Exception { super.setUp(); super.testInvokeOnComponentWithPrependId(); } @Override + @Test public void testChildrenListAfterAddViewPublish() { // overridding to do nothing. UIViewRoot is a special cases // and there should always only be on UIViewRoot in a tree } @Override + @Test public void testFacetMapAfterAddViewPublish() { // overridding to do nothing. UIViewRoot is a special cases // and there should always only be on UIViewRoot in a tree diff --git a/impl/src/test/java/jakarta/faces/component/ValueHolderTestCaseBase.java b/impl/src/test/java/jakarta/faces/component/ValueHolderTestCaseBase.java index 8b5db25fea..0e7bda4afc 100644 --- a/impl/src/test/java/jakarta/faces/component/ValueHolderTestCaseBase.java +++ b/impl/src/test/java/jakarta/faces/component/ValueHolderTestCaseBase.java @@ -16,12 +16,19 @@ package jakarta.faces.component; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import jakarta.faces.component.html.HtmlInputText; import jakarta.faces.convert.LongConverter; import jakarta.faces.convert.NumberConverter; import jakarta.faces.convert.ShortConverter; -import junit.framework.Test; -import junit.framework.TestSuite; /** *

@@ -31,19 +38,10 @@ */ public abstract class ValueHolderTestCaseBase extends UIComponentBaseTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public ValueHolderTestCaseBase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); component = new UIOutput(); @@ -51,12 +49,8 @@ public void setUp() throws Exception { expectedRendererType = "Text"; } - // Return the tests included in this test case. - public static Test suite() { - return new TestSuite(ValueHolderTestCaseBase.class); - } - // ------------------------------------------------- Individual Test Methods + @Test public void testAttributesTransparencyNonDeterministic() throws Exception { final int numThreads = 30; final Boolean outcomes[] = new Boolean[numThreads]; @@ -130,6 +124,7 @@ public void run() { } @Override + @Test public void testAttributesTransparency() { super.testAttributesTransparency(); ValueHolder vh = (ValueHolder) component; @@ -140,7 +135,7 @@ public void testAttributesTransparency() { public boolean doTestAttributesTransparency(ValueHolder vh, UIComponent newComp) { assertEquals(vh.getValue(), newComp.getAttributes().get("value")); vh.setValue("foo"); - assertEquals("foo", (String) newComp.getAttributes().get("value")); + assertEquals("foo", newComp.getAttributes().get("value")); vh.setValue(null); assertNull(newComp.getAttributes().get("value")); newComp.getAttributes().put("value", "bar"); @@ -165,37 +160,40 @@ public boolean doTestAttributesTransparency(ValueHolder vh, UIComponent newComp) // Suppress lifecycle tests since we do not have a renderer @Override + @Test public void testLifecycleManagement() { } // Test a pristine ValueHolderBase instance @Override + @Test public void testPristine() { super.testPristine(); ValueHolder vh = (ValueHolder) component; // Validate properties - assertNull("no value", vh.getValue()); - assertNull("no converter", vh.getConverter()); + assertNull(vh.getValue()); + assertNull(vh.getConverter()); } // Test setting properties to valid values @Override + @Test public void testPropertiesValid() throws Exception { super.testPropertiesValid(); ValueHolder vh = (ValueHolder) component; // value vh.setValue("foo.bar"); - assertEquals("expected value", "foo.bar", vh.getValue()); + assertEquals("foo.bar", vh.getValue()); vh.setValue(null); - assertNull("erased value", vh.getValue()); + assertNull(vh.getValue()); // converter vh.setConverter(new LongConverter()); - assertTrue("expected converter", vh.getConverter() instanceof LongConverter); + assertTrue(vh.getConverter() instanceof LongConverter); vh.setConverter(null); - assertNull("erased converter", vh.getConverter()); + assertNull(vh.getConverter()); } // --------------------------------------------------------- Support Methods diff --git a/impl/src/test/java/jakarta/faces/convert/BigIntegerConverterTest.java b/impl/src/test/java/jakarta/faces/convert/BigIntegerConverterTest.java index a6d919db2c..7e4d08756b 100644 --- a/impl/src/test/java/jakarta/faces/convert/BigIntegerConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/BigIntegerConverterTest.java @@ -16,14 +16,15 @@ package jakarta.faces.convert; -import java.math.BigInteger; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.math.BigInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.powermock.api.easymock.PowerMock; import jakarta.faces.component.UIPanel; @@ -37,10 +38,10 @@ public class BigIntegerConverterTest { /** * Test getAsObject method. */ - @Test(expected = NullPointerException.class) + @Test public void testGetAsObject() { BigIntegerConverter converter = new BigIntegerConverter(); - converter.getAsObject(null, null, null); + assertThrows(NullPointerException.class, () -> converter.getAsObject(null, null, null)); } /** @@ -82,10 +83,10 @@ public void testGetAsObject4() { /** * Test getAsString method. */ - @Test(expected = NullPointerException.class) + @Test public void testGetAsString() { BigIntegerConverter converter = new BigIntegerConverter(); - converter.getAsString(null, null, null); + assertThrows(NullPointerException.class, () -> converter.getAsString(null, null, null)); } /** diff --git a/impl/src/test/java/jakarta/faces/convert/DoubleConverterTest.java b/impl/src/test/java/jakarta/faces/convert/DoubleConverterTest.java index b033eca4fe..9b1eb1b120 100644 --- a/impl/src/test/java/jakarta/faces/convert/DoubleConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/DoubleConverterTest.java @@ -16,12 +16,13 @@ package jakarta.faces.convert; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.powermock.api.easymock.PowerMock; import jakarta.faces.component.UIPanel; @@ -35,10 +36,10 @@ public class DoubleConverterTest { /** * Test getAsObject method. */ - @Test(expected = NullPointerException.class) + @Test public void testGetAsObject() { DoubleConverter converter = new DoubleConverter(); - converter.getAsObject(null, null, null); + assertThrows(NullPointerException.class, () -> converter.getAsObject(null, null, null)); } /** @@ -80,10 +81,10 @@ public void testGetAsObject4() { /** * Test getAsString method. */ - @Test(expected = NullPointerException.class) + @Test public void testGetAsString() { DoubleConverter converter = new DoubleConverter(); - converter.getAsString(null, null, null); + assertThrows(NullPointerException.class, () -> converter.getAsString(null, null, null)); } /** diff --git a/impl/src/test/java/jakarta/faces/convert/FloatConverterTest.java b/impl/src/test/java/jakarta/faces/convert/FloatConverterTest.java index e62c4bf86c..97493b625e 100644 --- a/impl/src/test/java/jakarta/faces/convert/FloatConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/FloatConverterTest.java @@ -16,12 +16,13 @@ package jakarta.faces.convert; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.powermock.api.easymock.PowerMock; import jakarta.faces.component.UIPanel; @@ -35,10 +36,10 @@ public class FloatConverterTest { /** * Test getAsObject method. */ - @Test(expected = NullPointerException.class) + @Test public void testGetAsObject() { FloatConverter converter = new FloatConverter(); - converter.getAsObject(null, null, null); + assertThrows(NullPointerException.class, () -> converter.getAsObject(null, null, null)); } /** @@ -80,10 +81,10 @@ public void testGetAsObject4() { /** * Test getAsString method. */ - @Test(expected = NullPointerException.class) + @Test public void testGetAsString() { FloatConverter converter = new FloatConverter(); - converter.getAsString(null, null, null); + assertThrows(NullPointerException.class, () -> converter.getAsString(null, null, null)); } /** diff --git a/impl/src/test/java/jakarta/faces/convert/IntegerConverterTest.java b/impl/src/test/java/jakarta/faces/convert/IntegerConverterTest.java index a554dde147..5975ab76bc 100644 --- a/impl/src/test/java/jakarta/faces/convert/IntegerConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/IntegerConverterTest.java @@ -16,12 +16,13 @@ package jakarta.faces.convert; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.powermock.api.easymock.PowerMock; import jakarta.faces.component.UIPanel; @@ -35,10 +36,10 @@ public class IntegerConverterTest { /** * Test getAsObject method. */ - @Test(expected = NullPointerException.class) + @Test public void testGetAsObject() { IntegerConverter converter = new IntegerConverter(); - converter.getAsObject(null, null, null); + assertThrows(NullPointerException.class, () -> converter.getAsObject(null, null, null)); } /** @@ -80,10 +81,10 @@ public void testGetAsObject4() { /** * Test getAsString method. */ - @Test(expected = NullPointerException.class) + @Test public void testGetAsString() { IntegerConverter converter = new IntegerConverter(); - converter.getAsString(null, null, null); + assertThrows(NullPointerException.class, () -> converter.getAsString(null, null, null)); } /** diff --git a/impl/src/test/java/jakarta/faces/convert/LongConverterTest.java b/impl/src/test/java/jakarta/faces/convert/LongConverterTest.java index 3e6f07afca..4dba1ea725 100644 --- a/impl/src/test/java/jakarta/faces/convert/LongConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/LongConverterTest.java @@ -16,12 +16,13 @@ package jakarta.faces.convert; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.powermock.api.easymock.PowerMock; import jakarta.faces.component.UIPanel; @@ -35,10 +36,10 @@ public class LongConverterTest { /** * Test getAsObject method. */ - @Test(expected = NullPointerException.class) + @Test public void testGetAsObject() { LongConverter converter = new LongConverter(); - converter.getAsObject(null, null, null); + assertThrows(NullPointerException.class, () -> converter.getAsObject(null, null, null)); } /** @@ -80,10 +81,10 @@ public void testGetAsObject4() { /** * Test getAsString method. */ - @Test(expected = NullPointerException.class) + @Test public void testGetAsString() { LongConverter converter = new LongConverter(); - converter.getAsString(null, null, null); + assertThrows(NullPointerException.class, () -> converter.getAsString(null, null, null)); } /** diff --git a/impl/src/test/java/jakarta/faces/convert/ShortConverterTest.java b/impl/src/test/java/jakarta/faces/convert/ShortConverterTest.java index d7b23aa1a8..50fb3cff1c 100644 --- a/impl/src/test/java/jakarta/faces/convert/ShortConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/ShortConverterTest.java @@ -16,12 +16,13 @@ package jakarta.faces.convert; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.powermock.api.easymock.PowerMock; import jakarta.faces.component.UIPanel; @@ -35,10 +36,10 @@ public class ShortConverterTest { /** * Test getAsObject method. */ - @Test(expected = NullPointerException.class) + @Test public void testGetAsObject() { ShortConverter converter = new ShortConverter(); - converter.getAsObject(null, null, null); + assertThrows(NullPointerException.class, () -> converter.getAsObject(null, null, null)); } /** @@ -80,10 +81,10 @@ public void testGetAsObject4() { /** * Test getAsString method. */ - @Test(expected = NullPointerException.class) + @Test public void testGetAsString() { ShortConverter converter = new ShortConverter(); - converter.getAsString(null, null, null); + assertThrows(NullPointerException.class, () -> converter.getAsString(null, null, null)); } /** diff --git a/impl/src/test/java/jakarta/faces/event/PhaseIdTest.java b/impl/src/test/java/jakarta/faces/event/PhaseIdTest.java index c7f93f8e49..e8174cb3f0 100644 --- a/impl/src/test/java/jakarta/faces/event/PhaseIdTest.java +++ b/impl/src/test/java/jakarta/faces/event/PhaseIdTest.java @@ -16,40 +16,20 @@ package jakarta.faces.event; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Iterator; -public class PhaseIdTest extends TestCase { -// -// Protected Constants -// - -// -// Class Variables -// -// -// Instance Variables -// -// Attribute Instance Variables -// Relationship Instance Variables -// -// Constructors and Initializers -// - public PhaseIdTest() { - super(); - } +import org.junit.jupiter.api.Test; + +public class PhaseIdTest { -// -// Class methods -// -// -// General Methods -// + @Test public void testToString() { Iterator valueIter = PhaseId.VALUES.iterator(); String cur = null; while (valueIter.hasNext()) { - cur = (String) valueIter.next().toString(); + cur = valueIter.next().toString(); System.out.println(cur); assertTrue(cur.length() > 3); } diff --git a/impl/src/test/java/jakarta/faces/model/ArrayDataModelTestCase.java b/impl/src/test/java/jakarta/faces/model/ArrayDataModelTestCase.java index 7a79e80404..2e179c117a 100644 --- a/impl/src/test/java/jakarta/faces/model/ArrayDataModelTestCase.java +++ b/impl/src/test/java/jakarta/faces/model/ArrayDataModelTestCase.java @@ -16,8 +16,7 @@ package jakarta.faces.model; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.BeforeEach; /** *

@@ -25,20 +24,10 @@ */ public class ArrayDataModelTestCase extends DataModelTestCaseBase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public ArrayDataModelTestCase(String name) { - super(name); - } - // ------------------------------------------------------ Instance Variables // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. - @Override + @BeforeEach public void setUp() throws Exception { beans = new BeanTestImpl[5]; for (int i = 0; i < beans.length; i++) { @@ -46,12 +35,6 @@ public void setUp() throws Exception { } configure(); model = new ArrayDataModel(beans); - super.setUp(); - } - - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(ArrayDataModelTestCase.class)); } // ------------------------------------------------- Individual Test Methods diff --git a/impl/src/test/java/jakarta/faces/model/CollectionDataModelTest.java b/impl/src/test/java/jakarta/faces/model/CollectionDataModelTest.java index 6dbe5e658d..ea45e8dce4 100644 --- a/impl/src/test/java/jakarta/faces/model/CollectionDataModelTest.java +++ b/impl/src/test/java/jakarta/faces/model/CollectionDataModelTest.java @@ -16,10 +16,12 @@ package jakarta.faces.model; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + import java.util.ArrayList; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; /** * The JUnit tests for CollectionDataModel. diff --git a/impl/src/test/java/jakarta/faces/model/DataModelTestCaseBase.java b/impl/src/test/java/jakarta/faces/model/DataModelTestCaseBase.java index b22f6987bb..5784515f72 100644 --- a/impl/src/test/java/jakarta/faces/model/DataModelTestCaseBase.java +++ b/impl/src/test/java/jakarta/faces/model/DataModelTestCaseBase.java @@ -16,32 +16,24 @@ package jakarta.faces.model; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import java.lang.reflect.Method; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; -import java.lang.reflect.Method; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** *

* Abstract base class for {@link DataModel} tests.

*/ -public abstract class DataModelTestCaseBase extends TestCase { - - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public DataModelTestCaseBase(String name) { - - super(name); - - } +public abstract class DataModelTestCaseBase { // ------------------------------------------------------ Instance Variables // The array of beans we will be wrapping (must be initialized before setUp) @@ -58,35 +50,18 @@ protected void configure() { bean.setBooleanProperty((i % 2) == 0); bean.setBooleanSecond(!bean.getBooleanProperty()); bean.setByteProperty((byte) i); - bean.setDoubleProperty(((double) i) * 100.0); - bean.setFloatProperty(((float) i) * ((float) 10.0)); + bean.setDoubleProperty((i) * 100.0); + bean.setFloatProperty((i) * ((float) 10.0)); bean.setIntProperty(1000 * i); bean.setLongProperty((long) 10000 * (long) i); bean.setStringProperty("This is string " + i); } } - // Set up instance variables required by this test case. - @Override - public void setUp() throws Exception { - // Subclasses must create "beans", call "configure()", create "model" - super.setUp(); - } - - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(DataModelTestCaseBase.class)); - } - - // Tear down instance variables required by ths test case - public void tearDown() throws Exception { - super.tearDown(); - beans = null; - model = null; - } - // ------------------------------------------------- Individual Test Methods + // Test invalid arguments to listener methods + @Test public void testInvalidListeners() throws Exception { try { model.addDataModelListener(null); @@ -104,6 +79,7 @@ public void testInvalidListeners() throws Exception { } // Test positioning to all rows in ascending order + @Test public void testPositionAscending() throws Exception { StringBuffer sb = new StringBuffer(); model.setRowIndex(-1); @@ -119,6 +95,7 @@ public void testPositionAscending() throws Exception { } // Test positioning to all rows in descending order + @Test public void testPositionDescending() throws Exception { StringBuffer sb = new StringBuffer(); model.setRowIndex(-1); @@ -134,24 +111,26 @@ public void testPositionDescending() throws Exception { } // Test a pristine DataModel instance + @Test public void testPristine() throws Exception { // Unopened instance - assertNotNull("beans exists", beans); - assertNotNull("model exists", model); + assertNotNull(beans); + assertNotNull(model); // Correct row count if (model instanceof ResultSetDataModel) { - assertEquals("correct row count", -1, model.getRowCount()); + assertEquals(-1, model.getRowCount()); } else { - assertEquals("correct row count", beans.length, + assertEquals(beans.length, model.getRowCount()); } // Correct row index - assertEquals("correct row index", 0, model.getRowIndex()); + assertEquals(0, model.getRowIndex()); } // Test removing listener + @Test public void testRemoveListener() throws Exception { ListenerTestImpl listener = new ListenerTestImpl(); ListenerTestImpl.trace(null); @@ -166,6 +145,7 @@ public void testRemoveListener() throws Exception { } // Test resetting the wrapped data (should trigger an event + @Test public void testReset() throws Exception { ListenerTestImpl listener = new ListenerTestImpl(); ListenerTestImpl.trace(null); @@ -177,6 +157,7 @@ public void testReset() throws Exception { } // Test row available manipulations + @Test public void testRowAvailable() throws Exception { // Position to the "no current row" position model.setRowIndex(-1); @@ -192,6 +173,7 @@ public void testRowAvailable() throws Exception { } // Test the ability to update through the Map returned by getRowData() + @Test public void testRowData() throws Exception { // Retrieve the row data for row zero model.setRowIndex(0); @@ -246,8 +228,9 @@ public void testRowData() throws Exception { } // Test row index manipulations + @Test public void testRowIndex() throws Exception { - assertEquals("correct row index", 0, model.getRowIndex()); + assertEquals(0, model.getRowIndex()); // Positive setRowIndex() tests model.setRowIndex(0); @@ -262,6 +245,7 @@ public void testRowIndex() throws Exception { } } + @Test public void testIterator() { Iterator iterator = model.iterator(); if (!(model instanceof ScalarDataModel)) { @@ -285,6 +269,7 @@ public void testIterator() { } // Test resetting the wrapped data to null + @Test public void testWrapped() throws Exception { model.setWrappedData(null); assertTrue(!model.isRowAvailable()); @@ -306,42 +291,42 @@ protected void checkRow(int i) throws Exception { model.setRowIndex(i); String prompt = "Row " + i + " property "; BeanTestImpl bean = data(); - assertNotNull("Row " + i + " data", bean); - assertEquals(prompt + "booleanProperty", + assertNotNull(bean, "Row " + i + " data"); + assertEquals( beans[i].getBooleanProperty(), - bean.getBooleanProperty()); - assertEquals(prompt + "booleanSecond", + bean.getBooleanProperty(), prompt + "booleanProperty"); + assertEquals( beans[i].isBooleanSecond(), - bean.isBooleanSecond()); - assertEquals(prompt + "byteProperty", + bean.isBooleanSecond(), prompt + "booleanSecond"); + assertEquals( beans[i].getByteProperty(), - bean.getByteProperty()); - assertEquals(prompt + "doubleProperty", + bean.getByteProperty(), prompt + "byteProperty"); + assertEquals( "" + beans[i].getDoubleProperty(), - "" + bean.getDoubleProperty()); - assertEquals(prompt + "floatProperty", + "" + bean.getDoubleProperty(), prompt + "doubleProperty"); + assertEquals( "" + beans[i].getFloatProperty(), - "" + bean.getFloatProperty()); - assertEquals(prompt + "intProperty", + "" + bean.getFloatProperty(), prompt + "floatProperty"); + assertEquals( beans[i].getIntProperty(), - bean.getIntProperty()); - assertEquals(prompt + "longProperty", + bean.getIntProperty(), prompt + "intProperty"); + assertEquals( beans[i].getLongProperty(), - bean.getLongProperty()); - assertEquals(prompt + "nullProperty", + bean.getLongProperty(), prompt + "longProperty"); + assertEquals( beans[i].getNullProperty(), - bean.getNullProperty()); - assertEquals(prompt + "readOnlyProperty", + bean.getNullProperty(), prompt + "nullProperty"); + assertEquals( beans[i].getReadOnlyProperty(), - bean.getReadOnlyProperty()); - assertEquals(prompt + "shortProperty", + bean.getReadOnlyProperty(), prompt + "readOnlyProperty"); + assertEquals( beans[i].getShortProperty(), - bean.getShortProperty()); - assertEquals(prompt + "stringProperty", + bean.getShortProperty(), prompt + "shortProperty"); + assertEquals( beans[i].getStringProperty(), - bean.getStringProperty()); - assertEquals(prompt + "writeOnlyProperty", + bean.getStringProperty(), prompt + "stringProperty"); + assertEquals( beans[i].getWriteOnlyPropertyValue(), - bean.getWriteOnlyPropertyValue()); + bean.getWriteOnlyPropertyValue(), prompt + "writeOnlyProperty"); } } diff --git a/impl/src/test/java/jakarta/faces/model/ListDataModelTestCase.java b/impl/src/test/java/jakarta/faces/model/ListDataModelTestCase.java index 8da2e0b96e..552542f90e 100644 --- a/impl/src/test/java/jakarta/faces/model/ListDataModelTestCase.java +++ b/impl/src/test/java/jakarta/faces/model/ListDataModelTestCase.java @@ -19,8 +19,7 @@ import java.util.ArrayList; import java.util.List; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.BeforeEach; /** *

@@ -28,22 +27,10 @@ */ public class ListDataModelTestCase extends DataModelTestCaseBase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public ListDataModelTestCase(String name) { - - super(name); - - } - // ------------------------------------------------------ Instance Variables // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. - @Override + @BeforeEach public void setUp() throws Exception { List list = new ArrayList(); for (int i = 0; i < 5; i++) { @@ -52,12 +39,6 @@ public void setUp() throws Exception { beans = list.toArray(new BeanTestImpl[5]); configure(); model = new ListDataModel(list); - super.setUp(); - } - - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(ListDataModelTestCase.class)); } // ------------------------------------------------- Individual Test Methods diff --git a/impl/src/test/java/jakarta/faces/model/ResultSetDataModelTestCase.java b/impl/src/test/java/jakarta/faces/model/ResultSetDataModelTestCase.java index 8bf5a92c0d..635edacba9 100644 --- a/impl/src/test/java/jakarta/faces/model/ResultSetDataModelTestCase.java +++ b/impl/src/test/java/jakarta/faces/model/ResultSetDataModelTestCase.java @@ -16,16 +16,23 @@ package jakarta.faces.model; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; -import com.sun.faces.mock.MockResultSet; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.faces.mock.MockResultSet; /** *

@@ -33,23 +40,13 @@ */ public class ResultSetDataModelTestCase extends DataModelTestCaseBase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public ResultSetDataModelTestCase(String name) { - super(name); - } - // ------------------------------------------------------ Instance Variables // The ResultSet passed to our ResultSetDataModel protected MockResultSet result = null; // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. - @Override + @BeforeEach public void setUp() throws Exception { beans = new BeanTestImpl[5]; for (int i = 0; i < beans.length; i++) { @@ -58,16 +55,11 @@ public void setUp() throws Exception { configure(); result = new MockResultSet(beans); model = new ResultSetDataModel(result); - super.setUp(); - } - - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(ResultSetDataModelTestCase.class)); } // ------------------------------------------------- Individual Test Methods // Test ((Map) getRowData()).containsKey() + @Test public void testRowDataContainsKey() throws Exception { // Position to row 1 and retrieve the corresponding Map model.setRowIndex(1); @@ -105,6 +97,7 @@ public void testRowDataContainsKey() throws Exception { } // Test ((Map) getRowData()).containsValue() + @Test public void testRowDataContainsValue() throws Exception { // Position to row 1 and retrieve the corresponding Map model.setRowIndex(1); @@ -130,6 +123,7 @@ public void testRowDataContainsValue() throws Exception { } // Test ((Map) getRowData()).entrySet() + @Test public void testRowDataEntrySet() throws Exception { // Position to row 1 and retrieve the corresponding Map model.setRowIndex(1); @@ -180,15 +174,16 @@ public void testRowDataEntrySet() throws Exception { assertEquals("This is string 1 modified", beans[1].getStringProperty()); assertEquals("This is string 1 modified", - (String) map.get("stringProperty")); + map.get("stringProperty")); assertEquals("This is string 1 modified", - (String) map.get("stringPROPERTY")); + map.get("stringPROPERTY")); result.absolute(2); // ResultSet indexing is one-relative assertEquals("This is string 1 modified", - (String) result.getObject("stringProperty")); + result.getObject("stringProperty")); } // Test ((Map) getRowData()).get() + @Test public void testRowDataGet() throws Exception { // Position to row 1 and retrieve the corresponding Map model.setRowIndex(1); @@ -206,7 +201,7 @@ public void testRowDataGet() throws Exception { assertEquals(Float.valueOf((float) 10.0), map.get("floatProperty")); assertEquals(Integer.valueOf(1000), map.get("intProperty")); assertEquals(Long.valueOf(10000l), map.get("longProperty")); - assertEquals("This is string 1", (String) map.get("stringProperty")); + assertEquals("This is string 1", map.get("stringProperty")); // Test inexact match on column names assertEquals(Boolean.FALSE, map.get("booleanPROPERTY")); @@ -216,7 +211,7 @@ public void testRowDataGet() throws Exception { assertEquals(Float.valueOf((float) 10.0), map.get("floatPROPERTY")); assertEquals(Integer.valueOf(1000), map.get("intPROPERTY")); assertEquals(Long.valueOf(10000l), map.get("longPROPERTY")); - assertEquals("This is string 1", (String) map.get("stringPROPERTY")); + assertEquals("This is string 1", map.get("stringPROPERTY")); // Test null return on non-existent column names assertNull(map.get("foo")); @@ -226,6 +221,7 @@ public void testRowDataGet() throws Exception { } // Test ((Map) getRowData()).keySet() + @Test public void testRowDataKeySet() throws Exception { // Position to row 1 and retrieve the corresponding Map model.setRowIndex(1); @@ -267,6 +263,7 @@ public void testRowDataKeySet() throws Exception { } // Test ((Map) getRowData()).put() + @Test public void testRowDataPut() throws Exception { // Position to row 1 and retrieve the corresponding Map model.setRowIndex(1); @@ -278,6 +275,7 @@ public void testRowDataPut() throws Exception { } // Test unsupported operations on ((Map) getRowData()) + @Test public void testRowDataUnsupported() throws Exception { // Position to row 1 and retrieve the corresponding Map model.setRowIndex(1); @@ -456,6 +454,7 @@ public void testRowDataUnsupported() throws Exception { } // Test ((Map) getRowData()).values() + @Test public void testRowDataValues() throws Exception { // Position to row 1 and retrieve the corresponding Map model.setRowIndex(1); diff --git a/impl/src/test/java/jakarta/faces/model/ScalarDataModelTestCase.java b/impl/src/test/java/jakarta/faces/model/ScalarDataModelTestCase.java index a99295c7d0..96d6cba224 100644 --- a/impl/src/test/java/jakarta/faces/model/ScalarDataModelTestCase.java +++ b/impl/src/test/java/jakarta/faces/model/ScalarDataModelTestCase.java @@ -16,8 +16,7 @@ package jakarta.faces.model; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.BeforeEach; /** *

@@ -25,31 +24,15 @@ */ public class ScalarDataModelTestCase extends DataModelTestCaseBase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public ScalarDataModelTestCase(String name) { - super(name); - } - // ------------------------------------------------------ Instance Variables // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. - @Override + @BeforeEach public void setUp() throws Exception { beans = new BeanTestImpl[1]; beans[0] = new BeanTestImpl(); configure(); model = new ScalarDataModel(beans[0]); - super.setUp(); - } - - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(ScalarDataModelTestCase.class)); } // ------------------------------------------------- Individual Test Methods diff --git a/impl/src/test/java/jakarta/faces/validator/BeanValidatorTestCase.java b/impl/src/test/java/jakarta/faces/validator/BeanValidatorTestCase.java index 78be58d7ba..f711dc736a 100644 --- a/impl/src/test/java/jakarta/faces/validator/BeanValidatorTestCase.java +++ b/impl/src/test/java/jakarta/faces/validator/BeanValidatorTestCase.java @@ -16,13 +16,14 @@ package jakarta.faces.validator; +import java.util.Locale; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + import jakarta.faces.component.UIInput; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; -import java.util.Locale; -import junit.framework.Test; -import junit.framework.TestSuite; -import org.junit.Assert; /** *

Unit tests for {@link BeanValidator}.

@@ -49,23 +50,8 @@ public void setMessage(String message) { } } - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public BeanValidatorTestCase(String name) { - super(name); - } - - // ---------------------------------------------------- Overall Test Methods - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(BeanValidatorTestCase.class)); - } - // ------------------------------------------------- Individual Test Methods + @Test public void testMessageOK() { BeanValidator validator = new BeanValidator(); Locale.setDefault(Locale.US); @@ -77,6 +63,7 @@ public void testMessageOK() { validator.validate(facesContext, component, "something"); } + @Test public void testMessageKO() { BeanValidator validator = new BeanValidator(); Locale.setDefault(Locale.US); @@ -87,12 +74,13 @@ public void testMessageKO() { try { validator.validate(facesContext, component, ""); - Assert.fail("ValidatorException expected"); + Assertions.fail("ValidatorException expected"); } catch (ValidatorException e) { - Assert.assertEquals("size must be between 1 and 64", e.getMessage()); + Assertions.assertEquals("size must be between 1 and 64", e.getMessage()); } } + @Test public void testNoBase() { BeanValidator validator = new BeanValidator(); Locale.setDefault(Locale.US); diff --git a/impl/src/test/java/jakarta/faces/validator/CastingValidatorTestCase.java b/impl/src/test/java/jakarta/faces/validator/CastingValidatorTestCase.java index 1e4c7ef6bb..63aeaa206a 100644 --- a/impl/src/test/java/jakarta/faces/validator/CastingValidatorTestCase.java +++ b/impl/src/test/java/jakarta/faces/validator/CastingValidatorTestCase.java @@ -16,8 +16,7 @@ package jakarta.faces.validator; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** *

@@ -25,28 +24,13 @@ */ public class CastingValidatorTestCase extends ValidatorTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public CastingValidatorTestCase(String name) { - super(name); - } - - // ---------------------------------------------------- Overall Test Methods - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(CastingValidatorTestCase.class)); - } - // ------------------------------------------------- Individual Test Methods + @Test public void testWithGenericCanCastToRaw() { - + Validator validatorWithGeneric = (context, component, value) -> {}; - + Validator validatorRaw = validatorWithGeneric; } - + } diff --git a/impl/src/test/java/jakarta/faces/validator/DoubleRangeValidatorTestCase.java b/impl/src/test/java/jakarta/faces/validator/DoubleRangeValidatorTestCase.java index ba0ac8f904..5daa37ed77 100644 --- a/impl/src/test/java/jakarta/faces/validator/DoubleRangeValidatorTestCase.java +++ b/impl/src/test/java/jakarta/faces/validator/DoubleRangeValidatorTestCase.java @@ -16,11 +16,14 @@ package jakarta.faces.validator; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.Locale; +import org.junit.jupiter.api.Test; + import jakarta.faces.component.UIInput; -import junit.framework.Test; -import junit.framework.TestSuite; /** *

@@ -28,23 +31,8 @@ */ public class DoubleRangeValidatorTestCase extends ValidatorTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public DoubleRangeValidatorTestCase(String name) { - super(name); - } - - // ---------------------------------------------------- Overall Test Methods - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(DoubleRangeValidatorTestCase.class)); - } - // ------------------------------------------------- Individual Test Methods + @Test public void testLocaleHonored() { DoubleRangeValidator validator = new DoubleRangeValidator(); validator.setMinimum(10.1); @@ -61,10 +49,10 @@ public void testLocaleHonored() { } catch (ValidatorException e) { exceptionThrown = true; message = e.getMessage(); - assertTrue("message: \"" + message + "\" missing localized chars.", - -1 != message.indexOf("10.1")); - assertTrue("message: \"" + message + "\" missing localized chars.", - -1 != message.indexOf("20.1")); + assertTrue( + -1 != message.indexOf("10.1"), "message: \"" + message + "\" missing localized chars."); + assertTrue( + -1 != message.indexOf("20.1"), "message: \"" + message + "\" missing localized chars."); } assertTrue(exceptionThrown); @@ -78,14 +66,15 @@ public void testLocaleHonored() { } catch (ValidatorException e) { exceptionThrown = true; message = e.getMessage(); - assertTrue("message: \"" + message + "\" missing localized chars.", - -1 != message.indexOf("10,1")); - assertTrue("message: \"" + message + "\" missing localized chars.", - -1 != message.indexOf("20,1")); + assertTrue( + -1 != message.indexOf("10,1"), "message: \"" + message + "\" missing localized chars."); + assertTrue( + -1 != message.indexOf("20,1"), "message: \"" + message + "\" missing localized chars."); } assertTrue(exceptionThrown); } + @Test public void testHashCode() { DoubleRangeValidator validator1 = new DoubleRangeValidator(); DoubleRangeValidator validator2 = new DoubleRangeValidator(); diff --git a/impl/src/test/java/jakarta/faces/validator/LengthValidatorTestCase.java b/impl/src/test/java/jakarta/faces/validator/LengthValidatorTestCase.java index b86a29092d..97e4414b3f 100644 --- a/impl/src/test/java/jakarta/faces/validator/LengthValidatorTestCase.java +++ b/impl/src/test/java/jakarta/faces/validator/LengthValidatorTestCase.java @@ -16,12 +16,14 @@ package jakarta.faces.validator; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.Locale; -import jakarta.faces.component.UIInput; +import org.junit.jupiter.api.Test; -import junit.framework.Test; -import junit.framework.TestSuite; +import jakarta.faces.component.UIInput; /** *

@@ -29,23 +31,8 @@ */ public class LengthValidatorTestCase extends ValidatorTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public LengthValidatorTestCase(String name) { - super(name); - } - - // ---------------------------------------------------- Overall Test Methods - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(LengthValidatorTestCase.class)); - } - // ------------------------------------------------- Individual Test Methods + @Test public void testLocaleHonored() { LengthValidator validator = new LengthValidator(); validator.setMinimum(1000); @@ -63,8 +50,8 @@ public void testLocaleHonored() { } catch (ValidatorException e) { exceptionThrown = true; message = e.getMessage(); - assertTrue("message: \"" + message + "\" missing localized chars.", - -1 != message.indexOf("1,000")); + assertTrue( + -1 != message.indexOf("1,000"), "message: \"" + message + "\" missing localized chars."); } assertTrue(exceptionThrown); @@ -79,12 +66,13 @@ public void testLocaleHonored() { } catch (ValidatorException e) { exceptionThrown = true; message = e.getMessage(); - assertTrue("message: \"" + message + "\" missing localized chars.", - -1 != message.indexOf("1.000")); + assertTrue( + -1 != message.indexOf("1.000"), "message: \"" + message + "\" missing localized chars."); } assertTrue(exceptionThrown); } + @Test public void testHashCode() { LengthValidator validator1 = new LengthValidator(); LengthValidator validator2 = new LengthValidator(); diff --git a/impl/src/test/java/jakarta/faces/validator/LongRangeValidatorTestCase.java b/impl/src/test/java/jakarta/faces/validator/LongRangeValidatorTestCase.java index e81464d226..c59b18fdcc 100644 --- a/impl/src/test/java/jakarta/faces/validator/LongRangeValidatorTestCase.java +++ b/impl/src/test/java/jakarta/faces/validator/LongRangeValidatorTestCase.java @@ -16,12 +16,14 @@ package jakarta.faces.validator; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.Locale; -import jakarta.faces.component.UIInput; +import org.junit.jupiter.api.Test; -import junit.framework.Test; -import junit.framework.TestSuite; +import jakarta.faces.component.UIInput; /** *

@@ -29,23 +31,8 @@ */ public class LongRangeValidatorTestCase extends ValidatorTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public LongRangeValidatorTestCase(String name) { - super(name); - } - - // ---------------------------------------------------- Overall Test Methods - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(LongRangeValidatorTestCase.class)); - } - // ------------------------------------------------- Individual Test Methods + @Test public void testLocaleHonored() { LongRangeValidator validator = new LongRangeValidator(); validator.setMinimum(10100); @@ -62,10 +49,10 @@ public void testLocaleHonored() { } catch (ValidatorException e) { exceptionThrown = true; message = e.getMessage(); - assertTrue("message: \"" + message + "\" missing localized chars.", - -1 != message.indexOf("10,100")); - assertTrue("message: \"" + message + "\" missing localized chars.", - -1 != message.indexOf("20,100")); + assertTrue( + -1 != message.indexOf("10,100"), "message: \"" + message + "\" missing localized chars."); + assertTrue( + -1 != message.indexOf("20,100"), "message: \"" + message + "\" missing localized chars."); } assertTrue(exceptionThrown); @@ -79,14 +66,15 @@ public void testLocaleHonored() { } catch (ValidatorException e) { exceptionThrown = true; message = e.getMessage(); - assertTrue("message: \"" + message + "\" missing localized chars.", - -1 != message.indexOf("10.100")); - assertTrue("message: \"" + message + "\" missing localized chars.", - -1 != message.indexOf("20.100")); + assertTrue( + -1 != message.indexOf("10.100"), "message: \"" + message + "\" missing localized chars."); + assertTrue( + -1 != message.indexOf("20.100"), "message: \"" + message + "\" missing localized chars."); } assertTrue(exceptionThrown); } + @Test public void testHashCode() { LongRangeValidator validator1 = new LongRangeValidator(); LongRangeValidator validator2 = new LongRangeValidator(); diff --git a/impl/src/test/java/jakarta/faces/validator/RegexValidatorTestCase.java b/impl/src/test/java/jakarta/faces/validator/RegexValidatorTestCase.java index 5ec275a53a..189ae63241 100644 --- a/impl/src/test/java/jakarta/faces/validator/RegexValidatorTestCase.java +++ b/impl/src/test/java/jakarta/faces/validator/RegexValidatorTestCase.java @@ -16,11 +16,14 @@ package jakarta.faces.validator; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.Locale; +import org.junit.jupiter.api.Test; + import jakarta.faces.component.UIInput; -import junit.framework.Test; -import junit.framework.TestSuite; /** *

@@ -28,23 +31,8 @@ */ public class RegexValidatorTestCase extends ValidatorTestCase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public RegexValidatorTestCase(String name) { - super(name); - } - - // ---------------------------------------------------- Overall Test Methods - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(RegexValidatorTestCase.class)); - } - // ------------------------------------------------- Individual Test Methods + @Test public void testPatternMatch() { String patternStr = "t.*"; RegexValidator validator = new RegexValidator(); @@ -59,6 +47,7 @@ public void testPatternMatch() { } } + @Test public void testPatterMismatch() { String patternStr = "t.*"; facesContext.getViewRoot().setLocale(Locale.US); diff --git a/impl/src/test/java/jakarta/faces/validator/RequiredValidatorTest.java b/impl/src/test/java/jakarta/faces/validator/RequiredValidatorTest.java index 9f9c50754b..4ed683411c 100644 --- a/impl/src/test/java/jakarta/faces/validator/RequiredValidatorTest.java +++ b/impl/src/test/java/jakarta/faces/validator/RequiredValidatorTest.java @@ -16,7 +16,7 @@ package jakarta.faces.validator; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * The JUnit tests for the RequiredValidator class. diff --git a/impl/src/test/java/jakarta/faces/validator/ValidatorTestCase.java b/impl/src/test/java/jakarta/faces/validator/ValidatorTestCase.java index ab884dc313..740b917d76 100644 --- a/impl/src/test/java/jakarta/faces/validator/ValidatorTestCase.java +++ b/impl/src/test/java/jakarta/faces/validator/ValidatorTestCase.java @@ -16,6 +16,9 @@ package jakarta.faces.validator; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.faces.junit.JUnitFacesTestCaseBase; import com.sun.faces.mock.MockRenderKit; @@ -23,8 +26,6 @@ import jakarta.faces.component.UIViewRoot; import jakarta.faces.render.RenderKit; import jakarta.faces.render.RenderKitFactory; -import junit.framework.Test; -import junit.framework.TestSuite; /** *

@@ -32,19 +33,10 @@ */ public class ValidatorTestCase extends JUnitFacesTestCaseBase { - // ------------------------------------------------------------ Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public ValidatorTestCase(String name) { - super(name); - } - // ---------------------------------------------------- Overall Test Methods // Set up instance variables required by this test case. @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); @@ -60,11 +52,7 @@ public void setUp() throws Exception { } - // Return the tests included in this test case. - public static Test suite() { - return (new TestSuite(ValidatorTestCase.class)); - } - + @Test public void testNoOp() { } } diff --git a/impl/src/test/java/jakarta/faces/webapp/ComponentTestImpl.java b/impl/src/test/java/jakarta/faces/webapp/ComponentTestImpl.java index 396ee61862..869fb33325 100644 --- a/impl/src/test/java/jakarta/faces/webapp/ComponentTestImpl.java +++ b/impl/src/test/java/jakarta/faces/webapp/ComponentTestImpl.java @@ -27,11 +27,9 @@ public class ComponentTestImpl extends UIComponentBase { public ComponentTestImpl() { - super(); } public ComponentTestImpl(String id) { - super(); setId(id); } diff --git a/impl/src/test/java/jakarta/faces/webapp/ConfigFileTestCase.java b/impl/src/test/java/jakarta/faces/webapp/ConfigFileTestCase.java index f61b75c244..13831245c6 100644 --- a/impl/src/test/java/jakarta/faces/webapp/ConfigFileTestCase.java +++ b/impl/src/test/java/jakarta/faces/webapp/ConfigFileTestCase.java @@ -16,26 +16,28 @@ package jakarta.faces.webapp; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + import java.io.File; import java.io.InputStream; import java.net.URL; import java.util.Map; import org.apache.commons.digester.Digester; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xml.sax.InputSource; import com.sun.faces.config.DigesterFactory; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - /** *

* Unit tests for Configuration File processing. *

*/ -public class ConfigFileTestCase extends TestCase { +public class ConfigFileTestCase { // The public identifier of our DTD protected String CONFIG_DTD_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"; @@ -46,43 +48,28 @@ public class ConfigFileTestCase extends TestCase { */ protected Digester digester = null; - // ----------------------------------------------------------- Constructors - /** - * Construct a new instance of this test case. - * - * @param name Name of the test case - */ - public ConfigFileTestCase(String name) { - super(name); - } - // --------------------------------------------------- Overall Test Methods /** * Set up instance variables required by this test case. * * @throws java.lang.Exception */ - @Override + @BeforeEach public void setUp() throws Exception { digester = createDigester(); configureRules(digester); } - /** - * Return the tests included in this test suite. - */ - public static Test suite() { - return (new TestSuite(ConfigFileTestCase.class)); - } - // ------------------------------------------------ Individual Test Methods // Test parsing an empty configuration file + @Test public void testEmpty() throws Exception { ConfigBase base = parseConfig(relativeURL("src/test/java/jakarta/faces/webapp/config-file-0.xml")); assertNotNull(base); } // Test parsing a full configuration file + @Test public void testFull() throws Exception { // Retrieve entire configuration metadata instance ConfigBase base = parseConfig(relativeURL("src/test/java/jakarta/faces/webapp/config-file-1.xml")); @@ -187,10 +174,6 @@ public void testFull() throws Exception { assertEquals("java.lang.String", cv2p1.getPropertyClass()); } - // Test a pristine Digester instance - public void testPristine() { - } - // ------------------------------------------------------ Protected Methods // Create a Digester instance with no rules yet protected Digester createDigester() throws Exception { diff --git a/impl/src/test/java/jakarta/faces/webapp/FacesServletTestCase.java b/impl/src/test/java/jakarta/faces/webapp/FacesServletTestCase.java index 84623ca640..7e9fa7ea6d 100644 --- a/impl/src/test/java/jakarta/faces/webapp/FacesServletTestCase.java +++ b/impl/src/test/java/jakarta/faces/webapp/FacesServletTestCase.java @@ -16,6 +16,11 @@ package jakarta.faces.webapp; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.faces.junit.JUnitFacesTestCaseBase; import com.sun.faces.mock.MockRenderKit; @@ -24,8 +29,6 @@ import jakarta.faces.render.RenderKit; import jakarta.faces.render.RenderKitFactory; import jakarta.servlet.http.HttpServletResponse; -import junit.framework.Test; -import junit.framework.TestSuite; public class FacesServletTestCase extends JUnitFacesTestCaseBase { @@ -33,15 +36,8 @@ public class FacesServletTestCase extends JUnitFacesTestCaseBase { private static final String ALLOWED_HTTP_METHODS_ATTR_COPY = "com.sun.faces.allowedHttpMethods"; - public FacesServletTestCase(String name) { - super(name); - } - - public static Test suite() { - return (new TestSuite(FacesServletTestCase.class)); - } - @Override + @BeforeEach public void setUp() throws Exception { super.setUp(); // Set up Servlet API Objects @@ -62,6 +58,7 @@ public void setUp() throws Exception { } } + @Test public void testPositiveInitWithNoContextParams() throws Exception { FacesServlet me = new FacesServlet(); me.init(config); @@ -83,6 +80,7 @@ public void testPositiveInitWithNoContextParams() throws Exception { assertEquals(HttpServletResponse.SC_OK, response.getStatus()); } + @Test public void testPositiveInitWithContextParamsOfKnownHttpMethods() throws Exception { FacesServlet me = new FacesServlet(); servletContext.addInitParameter(ALLOWED_HTTP_METHODS_ATTR_COPY, "GET POST"); @@ -105,6 +103,7 @@ public void testPositiveInitWithContextParamsOfKnownHttpMethods() throws Excepti assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus()); } + @Test public void testNegativeInitWithContextParamsOfKnownHttpMethods() throws Exception { FacesServlet me = new FacesServlet(); servletContext.addInitParameter(ALLOWED_HTTP_METHODS_ATTR_COPY, "GET POST GET POST"); @@ -127,6 +126,7 @@ public void testNegativeInitWithContextParamsOfKnownHttpMethods() throws Excepti assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus()); } + @Test public void testPositiveInitWithContextParamsOfWildcardHttpMethods() throws Exception { FacesServlet me = new FacesServlet(); servletContext.addInitParameter(ALLOWED_HTTP_METHODS_ATTR_COPY, "*"); @@ -151,6 +151,7 @@ public void testPositiveInitWithContextParamsOfWildcardHttpMethods() throws Exce assertEquals(HttpServletResponse.SC_OK, response.getStatus()); } + @Test public void testNegativeInitWithContextParamsOfWildcardHttpMethods() throws Exception { FacesServlet me = new FacesServlet(); servletContext.addInitParameter(ALLOWED_HTTP_METHODS_ATTR_COPY, "* * * *"); @@ -175,6 +176,7 @@ public void testNegativeInitWithContextParamsOfWildcardHttpMethods() throws Exce assertEquals(HttpServletResponse.SC_OK, response.getStatus()); } + @Test public void testPositiveInitWithContextParamsOfUnknownAndKnownHttpMethods() throws Exception { FacesServlet me = new FacesServlet(); servletContext.addInitParameter(ALLOWED_HTTP_METHODS_ATTR_COPY, "GET\tPOST\tGETAAAAA"); From 79f91ce42f957a7715d90975bad9ef54453dfa2d Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sat, 2 Mar 2024 12:37:17 -0400 Subject: [PATCH 2/9] Analyzed and fixed failing UIComponentBaseBehaviorTestCase; it was previously never invoked, so is actually activated for the first time; it however initially failed on 2 tests: 1) testAddBehavior(): the original assumption was that adding handler on unsupported behavior event would throw ISE but the impl never did this, and the javadoc also didn't say any word about this, so I adjusted the test itself 2) testGetBehaviors(): the original assumption was that getClientBehaviors() returns a mutable collection but this was not the case when no initial behaviors were added, and the javadoc also didn't say any word about this, so I adjusted the test itself --- .../UIComponentBaseBehaviorTestCase.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/impl/src/test/java/jakarta/faces/component/UIComponentBaseBehaviorTestCase.java b/impl/src/test/java/jakarta/faces/component/UIComponentBaseBehaviorTestCase.java index 2c8fd6a567..8fe128cc07 100644 --- a/impl/src/test/java/jakarta/faces/component/UIComponentBaseBehaviorTestCase.java +++ b/impl/src/test/java/jakarta/faces/component/UIComponentBaseBehaviorTestCase.java @@ -147,6 +147,7 @@ public String toString() { /** * Test method for {@link jakarta.faces.component.UIComponentBase#saveState(jakarta.faces.context.FacesContext)}. */ + @Test public void testSaveState() { BehaviorComponent comp = new BehaviorComponent(); // Cast component to the interface, to be sure about method definition. @@ -190,24 +191,25 @@ public void testNonClientBehaviorHolder() throws Exception { * Test method for * {@link jakarta.faces.component.UIComponentBase#addClientBehavior(java.lang.String, jakarta.faces.component.behavior.ClientBehavior)}. */ + @Test public void testAddBehavior() { BehaviorComponent comp = new BehaviorComponent(); // Cast component to the interface, to be sure about method definition. ClientBehaviorHolder holder = comp; holder.addClientBehavior(ONCLICK, new TestBehavior()); + assertTrue(holder.getClientBehaviors().containsKey(ONCLICK)); holder.addClientBehavior(ONCLICK, new TestBehavior()); + assertTrue(holder.getClientBehaviors().containsKey(ONCLICK)); holder.addClientBehavior(ONCHANGE, new TestBehavior()); - try { - holder.addClientBehavior("foo", new TestBehavior()); - } catch (IllegalArgumentException e) { - return; - } - assertFalse(true); + assertTrue(holder.getClientBehaviors().containsKey(ONCHANGE)); + holder.addClientBehavior("foo", new TestBehavior()); + assertFalse(holder.getClientBehaviors().containsKey("foo")); } /** * Test method for {@link jakarta.faces.component.UIComponentBase#getEventNames()}. */ + @Test public void testGetEventNames() { BehaviorComponent comp = new BehaviorComponent(); ClientBehaviorHolder holder = comp; @@ -217,6 +219,7 @@ public void testGetEventNames() { /** * Test method for {@link jakarta.faces.component.UIComponentBase#getClientBehaviors()}. */ + @Test public void testGetBehaviors() { BehaviorComponent comp = new BehaviorComponent(); // Cast component to the interface, to be sure about method definition. @@ -229,6 +232,7 @@ public void testGetBehaviors() { holder.addClientBehavior(ONCLICK, new TestBehavior()); holder.addClientBehavior(ONCLICK, new TestBehavior()); holder.addClientBehavior(ONCHANGE, new TestBehavior()); + behaviors = holder.getClientBehaviors(); assertFalse(behaviors.isEmpty()); assertTrue(behaviors.containsKey(ONCLICK)); assertTrue(behaviors.containsKey(ONCHANGE)); @@ -243,6 +247,7 @@ public void testGetBehaviors() { /** * Test method for {@link jakarta.faces.component.UIComponentBase#getDefaultEventName()}. */ + @Test public void testGetDefaultEventName() { BehaviorComponent comp = new BehaviorComponent(); // Cast component to the interface, to be sure about method definition. From 64f1ceee07ea74997c7306106eedd1679b367f89 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sat, 2 Mar 2024 13:09:13 -0400 Subject: [PATCH 3/9] migrated EasyMock/PoweMock to Mockito --- impl/pom.xml | 13 +-- .../context/ExternalContextImplTest.java | 66 ++++++-------- ...siteComponentAttributesELResolverTest.java | 33 +++---- .../facelets/component/UIRepeatTest.java | 23 +++-- .../html_basic/BodyRendererTest.java | 38 ++++---- .../html_basic/HeadRendererTest.java | 22 +++-- .../com/sun/faces/util/FacesLoggerTest.java | 6 +- .../jakarta/faces/component/UIDataTest.java | 29 +++--- .../jakarta/faces/component/UIInputTest.java | 36 ++------ .../faces/component/UIParameterTest.java | 24 +++-- .../faces/component/UIViewRootTest.java | 89 +++++++------------ .../convert/BigIntegerConverterTest.java | 28 ++---- .../faces/convert/DoubleConverterTest.java | 28 ++---- .../faces/convert/FloatConverterTest.java | 28 ++---- .../faces/convert/IntegerConverterTest.java | 28 ++---- .../faces/convert/LongConverterTest.java | 28 ++---- .../faces/convert/ShortConverterTest.java | 28 ++---- 17 files changed, 193 insertions(+), 354 deletions(-) diff --git a/impl/pom.xml b/impl/pom.xml index 889f7ec9e2..24122e2103 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -149,16 +149,9 @@ - org.easymock - easymockclassextension - 3.2 - test - - - - org.powermock - powermock-api-easymock - 2.0.9 + org.mockito + mockito-core + 5.11.0 test diff --git a/impl/src/test/java/com/sun/faces/context/ExternalContextImplTest.java b/impl/src/test/java/com/sun/faces/context/ExternalContextImplTest.java index a7757995c2..c532c1f1ae 100644 --- a/impl/src/test/java/com/sun/faces/context/ExternalContextImplTest.java +++ b/impl/src/test/java/com/sun/faces/context/ExternalContextImplTest.java @@ -16,12 +16,10 @@ package com.sun.faces.context; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import static org.mockito.Mockito.when; import java.util.HashMap; import java.util.Iterator; @@ -31,7 +29,7 @@ import java.util.function.Supplier; import org.junit.jupiter.api.Test; -import org.powermock.api.easymock.PowerMock; +import org.mockito.Mockito; import jakarta.servlet.ServletContext; import jakarta.servlet.http.Cookie; @@ -48,14 +46,12 @@ public class ExternalContextImplTest { */ @Test public void testGetRequestCookieMap() { - ServletContext servletContext = PowerMock.createNiceMock(ServletContext.class); - HttpServletRequest request = PowerMock.createNiceMock(HttpServletRequest.class); - HttpServletResponse response = PowerMock.createNiceMock(HttpServletResponse.class); - replay(servletContext, request, response); - + ServletContext servletContext = Mockito.mock(ServletContext.class); + HttpServletRequest request = Mockito.mock(HttpServletRequest.class); + HttpServletResponse response = Mockito.mock(HttpServletResponse.class); + ExternalContextImpl externalContext = new ExternalContextImpl(servletContext, request, response); - verify(servletContext, request, response); - + assertNotNull(externalContext.getRequestCookieMap()); } @@ -64,19 +60,17 @@ public void testGetRequestCookieMap() { */ @Test public void testGetRequestCookieMap2() { - ServletContext servletContext = PowerMock.createNiceMock(ServletContext.class); - HttpServletRequest request = PowerMock.createNiceMock(HttpServletRequest.class); - HttpServletResponse response = PowerMock.createNiceMock(HttpServletResponse.class); + ServletContext servletContext = Mockito.mock(ServletContext.class); + HttpServletRequest request = Mockito.mock(HttpServletRequest.class); + HttpServletResponse response = Mockito.mock(HttpServletResponse.class); Cookie cookie = new Cookie("foo", "bar"); - expect(request.getCookies()).andReturn(new Cookie[]{cookie}).anyTimes(); - replay(servletContext, request, response); - + when(request.getCookies()).thenReturn(new Cookie[]{cookie}); + ExternalContextImpl externalContext = new ExternalContextImpl(servletContext, request, response); - verify(servletContext, request, response); Map requestCookieMap = externalContext.getRequestCookieMap(); assertTrue(requestCookieMap.get("foo") instanceof Cookie); Cookie value = (Cookie) requestCookieMap.get("foo"); - + assertTrue(value.getValue().equals("bar")); assertTrue(requestCookieMap.containsKey("foo")); assertTrue(requestCookieMap.containsValue(requestCookieMap.get("foo"))); @@ -93,15 +87,13 @@ public void testGetRequestCookieMap2() { */ @Test public void testGetRequestCookieMap3() { - ServletContext servletContext = PowerMock.createNiceMock(ServletContext.class); - HttpServletRequest request = PowerMock.createNiceMock(HttpServletRequest.class); - HttpServletResponse response = PowerMock.createNiceMock(HttpServletResponse.class); + ServletContext servletContext = Mockito.mock(ServletContext.class); + HttpServletRequest request = Mockito.mock(HttpServletRequest.class); + HttpServletResponse response = Mockito.mock(HttpServletResponse.class); Cookie cookie = new Cookie("foo", "bar"); - expect(request.getCookies()).andReturn(new Cookie[]{cookie}).anyTimes(); - replay(servletContext, request, response); - + when(request.getCookies()).thenReturn(new Cookie[]{cookie}); + ExternalContextImpl externalContext = new ExternalContextImpl(servletContext, request, response); - verify(servletContext, request, response); Map requestCookieMap = externalContext.getRequestCookieMap(); Iterator> entryIterator = requestCookieMap.entrySet().iterator(); @@ -160,15 +152,13 @@ public void testGetRequestCookieMap3() { @SuppressWarnings("unchecked") @Test public void testGetRequestCookieMap4() { - ServletContext servletContext = PowerMock.createNiceMock(ServletContext.class); - HttpServletRequest request = PowerMock.createNiceMock(HttpServletRequest.class); - HttpServletResponse response = PowerMock.createNiceMock(HttpServletResponse.class); + ServletContext servletContext = Mockito.mock(ServletContext.class); + HttpServletRequest request = Mockito.mock(HttpServletRequest.class); + HttpServletResponse response = Mockito.mock(HttpServletResponse.class); Cookie cookie = new Cookie("foo", "bar"); - expect(request.getCookies()).andReturn(new Cookie[]{cookie}).anyTimes(); - replay(servletContext, request, response); - + when(request.getCookies()).thenReturn(new Cookie[]{cookie}); + ExternalContextImpl externalContext = new ExternalContextImpl(servletContext, request, response); - verify(servletContext, request, response); Map requestCookieMap = externalContext.getRequestCookieMap(); boolean exceptionThrown = false; try { @@ -176,7 +166,7 @@ public void testGetRequestCookieMap4() { } catch (UnsupportedOperationException e) { exceptionThrown = true; } - + assertTrue(exceptionThrown); verifySupplier(() -> requestCookieMap.put("foot", "bar")); verifyConsumer(m -> requestCookieMap.putAll((Map) m), new HashMap<>()); @@ -191,13 +181,13 @@ public void testGetRequestCookieMap4() { */ private void verifyConsumer(Consumer consumer, Object argument) { boolean exceptionThrown = false; - + try { consumer.accept(argument); } catch (UnsupportedOperationException e) { exceptionThrown = true; } - + assertTrue(exceptionThrown); } @@ -208,13 +198,13 @@ private void verifyConsumer(Consumer consumer, Object argument) { */ private void verifySupplier(Supplier supplier) { boolean exceptionThrown = false; - + try { supplier.get(); } catch (UnsupportedOperationException e) { exceptionThrown = true; } - + assertTrue(exceptionThrown); } } diff --git a/impl/src/test/java/com/sun/faces/el/CompositeComponentAttributesELResolverTest.java b/impl/src/test/java/com/sun/faces/el/CompositeComponentAttributesELResolverTest.java index 3b48ca894f..4d0799b397 100644 --- a/impl/src/test/java/com/sun/faces/el/CompositeComponentAttributesELResolverTest.java +++ b/impl/src/test/java/com/sun/faces/el/CompositeComponentAttributesELResolverTest.java @@ -16,19 +16,17 @@ package com.sun.faces.el; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.when; import java.beans.BeanDescriptor; import java.lang.reflect.Field; import java.util.HashMap; import java.util.Map; -import org.easymock.EasyMock; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; import com.sun.faces.facelets.tag.composite.CompositeComponentBeanInfo; @@ -50,11 +48,11 @@ public class CompositeComponentAttributesELResolverTest { */ @Test public void testGetValue() throws Exception { - ELContext elContext1 = EasyMock.createNiceMock(ELContext.class); - FacesContext facesContext1 = EasyMock.createNiceMock(FacesContext.class); - ELContext elContext2 = EasyMock.createNiceMock(ELContext.class); - FacesContext facesContext2 = EasyMock.createNiceMock(FacesContext.class); - + ELContext elContext1 = Mockito.mock(ELContext.class); + FacesContext facesContext1 = Mockito.mock(FacesContext.class); + ELContext elContext2 = Mockito.mock(ELContext.class); + FacesContext facesContext2 = Mockito.mock(FacesContext.class); + HashMap ctxAttributes1 = new HashMap(); UIPanel composite = new UIPanel(); CompositeComponentBeanInfo compositeBeanInfo = new CompositeComponentBeanInfo(); @@ -64,20 +62,19 @@ public void testGetValue() throws Exception { composite.getAttributes().put(UIComponent.BEANINFO_KEY, compositeBeanInfo); String property = "attrs"; - expect(elContext1.getContext(FacesContext.class)).andReturn(facesContext1); - expect(facesContext1.getAttributes()).andReturn(ctxAttributes1); - expect(elContext2.getContext(FacesContext.class)).andReturn(facesContext2); - expect(facesContext2.getAttributes()).andReturn(ctxAttributes1); - replay(elContext1, facesContext1, elContext2, facesContext2); - + when(elContext1.getContext(FacesContext.class)).thenReturn(facesContext1); + when(facesContext1.getAttributes()).thenReturn(ctxAttributes1); + when(elContext2.getContext(FacesContext.class)).thenReturn(facesContext2); + when(facesContext2.getAttributes()).thenReturn(ctxAttributes1); + CompositeComponentAttributesELResolver elResolver = new CompositeComponentAttributesELResolver(); Map evalMap1 = (Map) elResolver.getValue(elContext1, composite, property); assertNotNull(evalMap1); Map evalMap2 = (Map) elResolver.getValue(elContext2, composite, property); assertNotNull(evalMap2); - + Field ctxField1 = evalMap1.getClass().getDeclaredField("ctx"); - ctxField1.setAccessible(true); + ctxField1.setAccessible(true); Field ctxField2 = evalMap2.getClass().getDeclaredField("ctx"); ctxField2.setAccessible(true); @@ -86,7 +83,5 @@ public void testGetValue() throws Exception { assertTrue(facesContext2 == ctxField1.get(evalMap1)); assertTrue(facesContext1 != ctxField2.get(evalMap2)); assertTrue(facesContext2 == ctxField2.get(evalMap2)); - - verify(elContext1, facesContext1, elContext2, facesContext2); } } diff --git a/impl/src/test/java/com/sun/faces/facelets/component/UIRepeatTest.java b/impl/src/test/java/com/sun/faces/facelets/component/UIRepeatTest.java index 9fc48eecc8..564c220d54 100644 --- a/impl/src/test/java/com/sun/faces/facelets/component/UIRepeatTest.java +++ b/impl/src/test/java/com/sun/faces/facelets/component/UIRepeatTest.java @@ -16,15 +16,15 @@ package com.sun.faces.facelets.component; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; import java.lang.reflect.Method; -import org.easymock.EasyMock; -import org.easymock.IAnswer; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; import jakarta.faces.application.FacesMessage; import jakarta.faces.application.FacesMessage.Severity; @@ -40,14 +40,13 @@ public class UIRepeatTest { @Test public void testHasErrorMessages() throws Exception { - ctx = EasyMock.createMock(FacesContext.class); - expect(ctx.getMaximumSeverity()).andAnswer(new IAnswer() { - @Override - public Severity answer() throws Throwable { - return maximumSeverity; - } - }).anyTimes(); - replay(ctx); + ctx = Mockito.mock(FacesContext.class); + when(ctx.getMaximumSeverity()).thenAnswer(new Answer() { + @Override + public Severity answer(InvocationOnMock invocation) throws Throwable { + return maximumSeverity; + } + }); maximumSeverity = FacesMessage.SEVERITY_WARN; assertEquals(false, hasErrorMessages(ctx)); diff --git a/impl/src/test/java/com/sun/faces/renderkit/html_basic/BodyRendererTest.java b/impl/src/test/java/com/sun/faces/renderkit/html_basic/BodyRendererTest.java index 2f5b39dfb8..bf156463db 100644 --- a/impl/src/test/java/com/sun/faces/renderkit/html_basic/BodyRendererTest.java +++ b/impl/src/test/java/com/sun/faces/renderkit/html_basic/BodyRendererTest.java @@ -16,15 +16,15 @@ package com.sun.faces.renderkit.html_basic; -import static org.easymock.EasyMock.expect; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.when; import java.io.StringWriter; import java.util.Collections; import org.junit.jupiter.api.Test; -import org.powermock.api.easymock.PowerMock; +import org.mockito.Mockito; import jakarta.faces.application.Application; import jakarta.faces.application.ProjectStage; @@ -56,16 +56,14 @@ public void testDecode() { public void testEncodeBegin() throws Exception { StringWriter writer = new StringWriter(); ResponseWriter testResponseWriter = new TestResponseWriter(writer); - FacesContext facesContext = PowerMock.createPartialMock(FacesContext.class, "getResponseWriter"); + FacesContext facesContext = Mockito.mock(FacesContext.class); BodyRenderer bodyRenderer = new BodyRenderer(); HtmlBody htmlBody = new HtmlBody(); htmlBody.getAttributes().put("styleClass", "myclass"); - - expect(facesContext.getResponseWriter()).andReturn(testResponseWriter).anyTimes(); - - PowerMock.replay(facesContext); + + when(facesContext.getResponseWriter()).thenReturn(testResponseWriter); + bodyRenderer.encodeBegin(facesContext, htmlBody); - PowerMock.verify(facesContext); String html = writer.toString(); assertTrue(html.contains("")); } diff --git a/impl/src/test/java/com/sun/faces/renderkit/html_basic/HeadRendererTest.java b/impl/src/test/java/com/sun/faces/renderkit/html_basic/HeadRendererTest.java index b8d0ef7758..4797a39a7c 100644 --- a/impl/src/test/java/com/sun/faces/renderkit/html_basic/HeadRendererTest.java +++ b/impl/src/test/java/com/sun/faces/renderkit/html_basic/HeadRendererTest.java @@ -16,14 +16,14 @@ package com.sun.faces.renderkit.html_basic; -import static org.easymock.EasyMock.expect; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.when; import java.io.StringWriter; import java.util.Collections; import org.junit.jupiter.api.Test; -import org.powermock.api.easymock.PowerMock; +import org.mockito.Mockito; import jakarta.faces.component.UIViewRoot; import jakarta.faces.component.html.HtmlHead; @@ -52,7 +52,7 @@ public void testDecode() { @Test public void testEncodeBegin() throws Exception { // - // TODO: Note we are not testing this method as its complexity is too + // TODO: Note we are not testing this method as its complexity is too // high, because it uses WebConfiguration.getInstance to get // configuration information that should be readily available to the // renderer through either the FacesContext or the component being @@ -86,18 +86,16 @@ public void testEncodeChildren() throws Exception { public void testEncodeEnd() throws Exception { StringWriter writer = new StringWriter(); ResponseWriter testResponseWriter = new TestResponseWriter(writer); - FacesContext facesContext = PowerMock.createPartialMockForAllMethodsExcept(FacesContext.class, "getCurrentInstance"); - UIViewRoot viewRoot = PowerMock.createMock(UIViewRoot.class); + FacesContext facesContext = Mockito.mock(FacesContext.class); + UIViewRoot viewRoot = Mockito.mock(UIViewRoot.class); HeadRenderer headRenderer = new HeadRenderer(); HtmlHead htmlHead = new HtmlHead(); - - expect(facesContext.getResponseWriter()).andReturn(testResponseWriter).anyTimes(); - expect(facesContext.getViewRoot()).andReturn(viewRoot).anyTimes(); - expect(viewRoot.getComponentResources(facesContext, "head")).andReturn(Collections.EMPTY_LIST).anyTimes(); - - PowerMock.replay(facesContext, viewRoot); + + when(facesContext.getResponseWriter()).thenReturn(testResponseWriter); + when(facesContext.getViewRoot()).thenReturn(viewRoot); + when(viewRoot.getComponentResources(facesContext, "head")).thenReturn(Collections.EMPTY_LIST); + headRenderer.encodeEnd(facesContext, htmlHead); - PowerMock.verify(facesContext, viewRoot); String html = writer.toString(); assertTrue(html.contains("")); } diff --git a/impl/src/test/java/com/sun/faces/util/FacesLoggerTest.java b/impl/src/test/java/com/sun/faces/util/FacesLoggerTest.java index 95244f8e4c..badfa24957 100644 --- a/impl/src/test/java/com/sun/faces/util/FacesLoggerTest.java +++ b/impl/src/test/java/com/sun/faces/util/FacesLoggerTest.java @@ -2,9 +2,9 @@ import java.util.Locale; -import org.easymock.EasyMock; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; import com.sun.faces.mock.MockApplication; import com.sun.faces.mock.MockFacesContext; @@ -18,7 +18,7 @@ public class FacesLoggerTest { public void unresolvedNavigationUS() { MockFacesContext facesContext = new MockFacesContext(); facesContext.setApplication(new MockApplication()); - facesContext.setELContext(EasyMock.createMock(ELContext.class)); + facesContext.setELContext(Mockito.mock(ELContext.class)); UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); root.setLocale(Locale.US); facesContext.setViewRoot(root); @@ -33,7 +33,7 @@ public void unresolvedNavigationUS() { public void unresolvedNavigationGermany() { MockFacesContext facesContext = new MockFacesContext(); facesContext.setApplication(new MockApplication()); - facesContext.setELContext(EasyMock.createMock(ELContext.class)); + facesContext.setELContext(Mockito.mock(ELContext.class)); UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null); root.setLocale(Locale.GERMANY); facesContext.setViewRoot(root); diff --git a/impl/src/test/java/jakarta/faces/component/UIDataTest.java b/impl/src/test/java/jakarta/faces/component/UIDataTest.java index 7b91edecb3..5804801c20 100644 --- a/impl/src/test/java/jakarta/faces/component/UIDataTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIDataTest.java @@ -18,17 +18,16 @@ import static jakarta.faces.component.NamingContainer.SEPARATOR_CHAR; import static jakarta.faces.component.UINamingContainer.SEPARATOR_CHAR_PARAM_NAME; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -import static org.powermock.api.easymock.PowerMock.createNicePartialMockAndInvokeDefaultConstructor; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import org.junit.jupiter.api.Test; -import org.powermock.reflect.Whitebox; +import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; +import jakarta.faces.render.RenderKit; /** * @author Manfred Riem (manfred.riem@oracle.com) @@ -40,12 +39,10 @@ public class UIDataTest { */ @Test public void testSaveState() { - FacesContext context = createMock(FacesContext.class); + FacesContext context = mock(FacesContext.class); UIData data = new UIData(); data.markInitialState(); - replay(context); assertNull(data.saveState(context)); - verify(context); } /** @@ -53,11 +50,9 @@ public void testSaveState() { */ @Test public void testSaveState2() { - FacesContext context = createMock(FacesContext.class); + FacesContext context = mock(FacesContext.class); UIData data = new UIData(); - replay(context); assertNotNull(data.saveState(context)); - verify(context); } /** @@ -65,18 +60,20 @@ public void testSaveState2() { */ @Test public void testSaveState3() { - FacesContext context = createMock(FacesContext.class); + FacesContext context = mock(FacesContext.class); UIData data = new UIData(); data.markInitialState(); data.setRowIndex(4); - replay(context); assertNotNull(data.saveState(context)); - verify(context); } @Test public void testInvokeOnComponentMustNotCallSetRowIndexIfNotTouched() throws Exception { - FacesContext context = createNicePartialMockAndInvokeDefaultConstructor(FacesContext.class, "getRenderKit"); + FacesContext context = mock(FacesContext.class); + ExternalContext externalContext = mock(ExternalContext.class); + when(context.getExternalContext()).thenReturn(externalContext); + RenderKit renderKit = mock(RenderKit.class); + when(context.getRenderKit()).thenReturn(renderKit); context.getAttributes().put(SEPARATOR_CHAR_PARAM_NAME, SEPARATOR_CHAR); UIData data = new UIData() { @@ -87,8 +84,6 @@ public void setRowIndex(int rowIndex) { }; data.setId("data"); - // simple way. otherwise, we have to mock the renderkit and whatever. - Whitebox.setInternalState(data, "clientId", data.getId()); data.invokeOnComponent(context, "differentId", (contextInLambda, target) -> { }); diff --git a/impl/src/test/java/jakarta/faces/component/UIInputTest.java b/impl/src/test/java/jakarta/faces/component/UIInputTest.java index 80c174175a..9646a002d3 100644 --- a/impl/src/test/java/jakarta/faces/component/UIInputTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIInputTest.java @@ -16,15 +16,13 @@ package jakarta.faces.component; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import org.easymock.EasyMock; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; import jakarta.faces.context.FacesContext; import jakarta.faces.validator.LengthValidator; @@ -38,11 +36,9 @@ public class UIInputTest { @Test public void testSaveState() { - FacesContext context = EasyMock.createMock(FacesContext.class); + FacesContext context = Mockito.mock(FacesContext.class); UIInput input = new UIInput(); - replay(context); assertNotNull(input.saveState(context)); - verify(context); } @Test @@ -53,21 +49,18 @@ public void testSaveState2() { @Test public void testSaveState3() { - FacesContext context = EasyMock.createMock(FacesContext.class); + FacesContext context = Mockito.mock(FacesContext.class); UIInput input = new UIInput(); - replay(context); input.markInitialState(); assertNull(input.saveState(context)); - verify(context); } @Test public void testSaveState4() { - FacesContext context = EasyMock.createMock(FacesContext.class); + FacesContext context = Mockito.mock(FacesContext.class); UIInput input = new UIInput(); LengthValidator l1 = new LengthValidator(); LengthValidator l2 = new LengthValidator(); - replay(context); input.addValidator(l1); input.addValidator(l2); l1.setMinimum(1); @@ -78,58 +71,48 @@ public void testSaveState4() { assertTrue(l2.initialStateMarked()); Object state = input.saveState(context); assertNull(state); - verify(context); } @Test public void testRestoreState() { - FacesContext context = EasyMock.createMock(FacesContext.class); + FacesContext context = Mockito.mock(FacesContext.class); UIInput input = new UIInput(); - replay(context); input.restoreState(context, null); - verify(context); } @Test public void testRestoreState2() { - FacesContext context = EasyMock.createMock(FacesContext.class); + FacesContext context = Mockito.mock(FacesContext.class); UIInput input = new UIInput(); - replay(context); assertThrows(NullPointerException.class, () -> input.restoreState(null, null)); - verify(context); } @Test public void testRestoreState3() { - FacesContext context = EasyMock.createMock(FacesContext.class); + FacesContext context = Mockito.mock(FacesContext.class); UIInput input = new UIInput(); - replay(context); Object state = input.saveState(context); assertNotNull(state); input.restoreState(context, state); - verify(context); } @Test public void testRestoreState4() { - FacesContext context = EasyMock.createMock(FacesContext.class); + FacesContext context = Mockito.mock(FacesContext.class); UIInput input = new UIInput(); input.addValidator(new LongRangeValidator()); - replay(context); Object state = input.saveState(context); assertNotNull(state); input = new UIInput(); input.restoreState(context, state); - verify(context); } @Test public void testRestoreState5() { - FacesContext context = EasyMock.createMock(FacesContext.class); + FacesContext context = Mockito.mock(FacesContext.class); UIInput input = new UIInput(); LengthValidator l1 = new LengthValidator(); LengthValidator l2 = new LengthValidator(); - replay(context); input.addValidator(l1); input.addValidator(l2); l1.setMinimum(1); @@ -206,6 +189,5 @@ public void testRestoreState5() { assertTrue(v.getMinimum() == i + 1); } - verify(context); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIParameterTest.java b/impl/src/test/java/jakarta/faces/component/UIParameterTest.java index 8fa156263a..e5f4c5f8c4 100644 --- a/impl/src/test/java/jakarta/faces/component/UIParameterTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIParameterTest.java @@ -16,15 +16,13 @@ package jakarta.faces.component; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.when; import java.lang.reflect.Method; import org.junit.jupiter.api.Test; -import org.powermock.api.easymock.PowerMock; +import org.mockito.Mockito; import jakarta.el.ELContext; import jakarta.el.ValueExpression; @@ -37,7 +35,7 @@ public class UIParameterTest { */ @Test public void testIsDisable() throws Exception { - FacesContext facesContext = PowerMock.createNicePartialMockForAllMethodsExcept(FacesContext.class, "getCurrentInstance", "setCurrentInstance"); + FacesContext facesContext = Mockito.mock(FacesContext.class); Method method = FacesContext.class.getDeclaredMethod("setCurrentInstance", FacesContext.class); method.setAccessible(true); method.invoke(null, facesContext); @@ -52,21 +50,19 @@ public void testIsDisable() throws Exception { */ @Test public void testIsDisable2() throws Exception { - ELContext elContext = PowerMock.createMock(ELContext.class); - FacesContext facesContext = PowerMock.createPartialMockForAllMethodsExcept(FacesContext.class, "getCurrentInstance", "setCurrentInstance"); - ValueExpression valueExpression = PowerMock.createMock(ValueExpression.class); + ELContext elContext = Mockito.mock(ELContext.class); + FacesContext facesContext = Mockito.mock(FacesContext.class); + ValueExpression valueExpression = Mockito.mock(ValueExpression.class); Method method = FacesContext.class.getDeclaredMethod("setCurrentInstance", FacesContext.class); method.setAccessible(true); method.invoke(null, facesContext); - expect(facesContext.getExternalContext()).andReturn(null).anyTimes(); - expect(valueExpression.isLiteralText()).andReturn(false).anyTimes(); - expect(facesContext.getELContext()).andReturn(elContext); - expect(valueExpression.getValue(elContext)).andReturn(true); - replay(elContext, facesContext, valueExpression); + when(facesContext.getExternalContext()).thenReturn(null); + when(valueExpression.isLiteralText()).thenReturn(false); + when(facesContext.getELContext()).thenReturn(elContext); + when(valueExpression.getValue(elContext)).thenReturn(true); UIParameter parameter = new UIParameter(); parameter.setValueExpression("disable", valueExpression); assertTrue(parameter.isDisable()); - verify(elContext, facesContext, valueExpression); method.invoke(null, (FacesContext) null); } } diff --git a/impl/src/test/java/jakarta/faces/component/UIViewRootTest.java b/impl/src/test/java/jakarta/faces/component/UIViewRootTest.java index c3125e3659..e6b4d66545 100644 --- a/impl/src/test/java/jakarta/faces/component/UIViewRootTest.java +++ b/impl/src/test/java/jakarta/faces/component/UIViewRootTest.java @@ -16,19 +16,16 @@ package jakarta.faces.component; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.reset; -import static org.easymock.EasyMock.verify; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.when; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; -import org.easymock.EasyMock; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; import jakarta.faces.application.Application; import jakarta.faces.application.ProjectStage; @@ -42,99 +39,82 @@ public class UIViewRootTest { @Test public void testViewMapPostConstructViewMapEvent() { - FacesContext facesContext = EasyMock.createMock(FacesContext.class); - Application application = EasyMock.createMock(Application.class); - ExternalContext externalContext = EasyMock.createMock(ExternalContext.class); - HttpSession httpSession = EasyMock.createMock(HttpSession.class); + FacesContext facesContext = Mockito.mock(FacesContext.class); + Application application = Mockito.mock(Application.class); + ExternalContext externalContext = Mockito.mock(ExternalContext.class); + HttpSession httpSession = Mockito.mock(HttpSession.class); setFacesContext(facesContext); - expect(facesContext.getExternalContext()).andReturn(externalContext).anyTimes(); - expect(externalContext.getApplicationMap()).andReturn(null).anyTimes(); - replay(facesContext, externalContext); + when(facesContext.getExternalContext()).thenReturn(externalContext); + when(externalContext.getApplicationMap()).thenReturn(null); UIViewRoot viewRoot = new UIViewRoot(); - verify(facesContext, externalContext); - reset(facesContext, externalContext); - expect(facesContext.getApplication()).andReturn(application).anyTimes(); - expect(application.getProjectStage()).andReturn(ProjectStage.UnitTest); + when(facesContext.getApplication()).thenReturn(application); + when(application.getProjectStage()).thenReturn(ProjectStage.UnitTest); application.publishEvent(facesContext, PostConstructViewMapEvent.class, UIViewRoot.class, viewRoot); - replay(facesContext, application, externalContext, httpSession); Map viewMap = viewRoot.getViewMap(); assertNotNull(viewMap); - verify(facesContext, application, externalContext, httpSession); setFacesContext(null); } @Test public void testViewMapPreDestroyViewMapEvent() { - FacesContext facesContext = EasyMock.createMock(FacesContext.class); - Application application = EasyMock.createMock(Application.class); - ExternalContext externalContext = EasyMock.createMock(ExternalContext.class); - HttpSession httpSession = EasyMock.createMock(HttpSession.class); + FacesContext facesContext = Mockito.mock(FacesContext.class); + Application application = Mockito.mock(Application.class); + ExternalContext externalContext = Mockito.mock(ExternalContext.class); + HttpSession httpSession = Mockito.mock(HttpSession.class); setFacesContext(facesContext); - expect(facesContext.getExternalContext()).andReturn(externalContext).anyTimes(); - expect(externalContext.getApplicationMap()).andReturn(null).anyTimes(); - replay(facesContext, externalContext); + when(facesContext.getExternalContext()).thenReturn(externalContext); + when(externalContext.getApplicationMap()).thenReturn(null); UIViewRoot viewRoot = new UIViewRoot(); - verify(facesContext, externalContext); - reset(facesContext, externalContext); - expect(facesContext.getApplication()).andReturn(application).anyTimes(); - expect(application.getProjectStage()).andReturn(ProjectStage.UnitTest); + when(facesContext.getApplication()).thenReturn(application); + when(application.getProjectStage()).thenReturn(ProjectStage.UnitTest); application.publishEvent(facesContext, PostConstructViewMapEvent.class, UIViewRoot.class, viewRoot); - expect(facesContext.getViewRoot()).andReturn(viewRoot); + when(facesContext.getViewRoot()).thenReturn(viewRoot); application.publishEvent(facesContext, PreDestroyViewMapEvent.class, UIViewRoot.class, viewRoot); - expect(facesContext.getViewRoot()).andReturn(viewRoot); + when(facesContext.getViewRoot()).thenReturn(viewRoot); application.publishEvent(facesContext, PreDestroyViewMapEvent.class, UIViewRoot.class, viewRoot); - replay(facesContext, application, externalContext, httpSession); Map viewMap = viewRoot.getViewMap(); assertNotNull(viewMap); viewRoot.getViewMap().clear(); viewRoot.getViewMap().clear(); - verify(facesContext, application, externalContext, httpSession); setFacesContext(null); } @Test public void testViewMapSaveAndRestoreState() { - FacesContext facesContext = EasyMock.createMock(FacesContext.class); - Application application = EasyMock.createMock(Application.class); - ExternalContext externalContext = EasyMock.createMock(ExternalContext.class); - HttpSession httpSession = EasyMock.createMock(HttpSession.class); + FacesContext facesContext = Mockito.mock(FacesContext.class); + Application application = Mockito.mock(Application.class); + ExternalContext externalContext = Mockito.mock(ExternalContext.class); + HttpSession httpSession = Mockito.mock(HttpSession.class); HashMap attributes = new HashMap<>(); HashMap sessionMap = new HashMap<>(); setFacesContext(facesContext); - expect(facesContext.getExternalContext()).andReturn(externalContext).anyTimes(); - expect(externalContext.getApplicationMap()).andReturn(null).anyTimes(); - replay(facesContext, externalContext); + when(facesContext.getExternalContext()).thenReturn(externalContext); + when(externalContext.getApplicationMap()).thenReturn(null); UIViewRoot viewRoot1 = new UIViewRoot(); - verify(facesContext, externalContext); - reset(facesContext, externalContext); - expect(facesContext.getExternalContext()).andReturn(externalContext).anyTimes(); - expect(externalContext.getApplicationMap()).andReturn(null).anyTimes(); - replay(facesContext, externalContext); + when(facesContext.getExternalContext()).thenReturn(externalContext); + when(externalContext.getApplicationMap()).thenReturn(null); UIViewRoot viewRoot2 = new UIViewRoot(); - verify(facesContext, externalContext); - reset(facesContext, externalContext); - - expect(facesContext.getAttributes()).andReturn(attributes).anyTimes(); - expect(facesContext.getApplication()).andReturn(application).anyTimes(); - expect(application.getProjectStage()).andReturn(ProjectStage.UnitTest).anyTimes(); - expect(facesContext.getExternalContext()).andReturn(externalContext).anyTimes(); - expect(externalContext.getSessionMap()).andReturn(sessionMap).anyTimes(); + + when(facesContext.getAttributes()).thenReturn(attributes); + when(facesContext.getApplication()).thenReturn(application); + when(application.getProjectStage()).thenReturn(ProjectStage.UnitTest); + when(facesContext.getExternalContext()).thenReturn(externalContext); + when(externalContext.getSessionMap()).thenReturn(sessionMap); application.publishEvent(facesContext, PostConstructViewMapEvent.class, UIViewRoot.class, viewRoot1); - replay(facesContext, application, externalContext, httpSession); Map viewMap = viewRoot1.getViewMap(); viewMap.put("one", "one"); Object saved = viewRoot1.saveState(facesContext); @@ -149,7 +129,6 @@ public void testViewMapSaveAndRestoreState() { viewRoot2.restoreState(facesContext, saved); viewMap = viewRoot2.getViewMap(); assertEquals("one", viewMap.get("one")); - verify(facesContext, application, externalContext, httpSession); setFacesContext(null); } diff --git a/impl/src/test/java/jakarta/faces/convert/BigIntegerConverterTest.java b/impl/src/test/java/jakarta/faces/convert/BigIntegerConverterTest.java index 7e4d08756b..70f8a6c468 100644 --- a/impl/src/test/java/jakarta/faces/convert/BigIntegerConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/BigIntegerConverterTest.java @@ -16,8 +16,6 @@ package jakarta.faces.convert; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -25,7 +23,7 @@ import java.math.BigInteger; import org.junit.jupiter.api.Test; -import org.powermock.api.easymock.PowerMock; +import org.mockito.Mockito; import jakarta.faces.component.UIPanel; import jakarta.faces.context.FacesContext; @@ -50,10 +48,8 @@ public void testGetAsObject() { @Test public void testGetAsObject2() { BigIntegerConverter converter = new BigIntegerConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertNull(converter.getAsObject(facesContext, new UIPanel(), null)); - verify(facesContext); } /** @@ -62,10 +58,8 @@ public void testGetAsObject2() { @Test public void testGetAsObject3() { BigIntegerConverter converter = new BigIntegerConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertNull(converter.getAsObject(facesContext, new UIPanel(), " ")); - verify(facesContext); } /** @@ -74,10 +68,8 @@ public void testGetAsObject3() { @Test public void testGetAsObject4() { BigIntegerConverter converter = new BigIntegerConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals(BigInteger.valueOf(123), converter.getAsObject(facesContext, new UIPanel(), "123")); - verify(facesContext); } /** @@ -95,10 +87,8 @@ public void testGetAsString() { @Test public void testGetAsString2() { BigIntegerConverter converter = new BigIntegerConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("", converter.getAsString(facesContext, new UIPanel(), null)); - verify(facesContext); } /** @@ -107,10 +97,8 @@ public void testGetAsString2() { @Test public void testGetAsString3() { BigIntegerConverter converter = new BigIntegerConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("123", converter.getAsString(facesContext, new UIPanel(), "123")); - verify(facesContext); } /** @@ -119,9 +107,7 @@ public void testGetAsString3() { @Test public void testGetAsString4() { BigIntegerConverter converter = new BigIntegerConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("123", converter.getAsString(facesContext, new UIPanel(), BigInteger.valueOf(123))); - verify(facesContext); } } diff --git a/impl/src/test/java/jakarta/faces/convert/DoubleConverterTest.java b/impl/src/test/java/jakarta/faces/convert/DoubleConverterTest.java index 9b1eb1b120..976600b158 100644 --- a/impl/src/test/java/jakarta/faces/convert/DoubleConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/DoubleConverterTest.java @@ -16,14 +16,12 @@ package jakarta.faces.convert; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; -import org.powermock.api.easymock.PowerMock; +import org.mockito.Mockito; import jakarta.faces.component.UIPanel; import jakarta.faces.context.FacesContext; @@ -48,10 +46,8 @@ public void testGetAsObject() { @Test public void testGetAsObject2() { DoubleConverter converter = new DoubleConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertNull(converter.getAsObject(facesContext, new UIPanel(), null)); - verify(facesContext); } /** @@ -60,10 +56,8 @@ public void testGetAsObject2() { @Test public void testGetAsObject3() { DoubleConverter converter = new DoubleConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertNull(converter.getAsObject(facesContext, new UIPanel(), " ")); - verify(facesContext); } /** @@ -72,10 +66,8 @@ public void testGetAsObject3() { @Test public void testGetAsObject4() { DoubleConverter converter = new DoubleConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals(Double.valueOf("12.3"), converter.getAsObject(facesContext, new UIPanel(), "12.3")); - verify(facesContext); } /** @@ -93,10 +85,8 @@ public void testGetAsString() { @Test public void testGetAsString2() { DoubleConverter converter = new DoubleConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("", converter.getAsString(facesContext, new UIPanel(), null)); - verify(facesContext); } /** @@ -105,10 +95,8 @@ public void testGetAsString2() { @Test public void testGetAsString3() { DoubleConverter converter = new DoubleConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("12.3", converter.getAsString(facesContext, new UIPanel(), "12.3")); - verify(facesContext); } /** @@ -117,9 +105,7 @@ public void testGetAsString3() { @Test public void testGetAsString4() { DoubleConverter converter = new DoubleConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("12.3", converter.getAsString(facesContext, new UIPanel(), Double.valueOf("12.3"))); - verify(facesContext); } } diff --git a/impl/src/test/java/jakarta/faces/convert/FloatConverterTest.java b/impl/src/test/java/jakarta/faces/convert/FloatConverterTest.java index 97493b625e..446940f431 100644 --- a/impl/src/test/java/jakarta/faces/convert/FloatConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/FloatConverterTest.java @@ -16,14 +16,12 @@ package jakarta.faces.convert; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; -import org.powermock.api.easymock.PowerMock; +import org.mockito.Mockito; import jakarta.faces.component.UIPanel; import jakarta.faces.context.FacesContext; @@ -48,10 +46,8 @@ public void testGetAsObject() { @Test public void testGetAsObject2() { FloatConverter converter = new FloatConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertNull(converter.getAsObject(facesContext, new UIPanel(), null)); - verify(facesContext); } /** @@ -60,10 +56,8 @@ public void testGetAsObject2() { @Test public void testGetAsObject3() { FloatConverter converter = new FloatConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertNull(converter.getAsObject(facesContext, new UIPanel(), " ")); - verify(facesContext); } /** @@ -72,10 +66,8 @@ public void testGetAsObject3() { @Test public void testGetAsObject4() { FloatConverter converter = new FloatConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals(Float.valueOf("12.3"), converter.getAsObject(facesContext, new UIPanel(), "12.3")); - verify(facesContext); } /** @@ -93,10 +85,8 @@ public void testGetAsString() { @Test public void testGetAsString2() { FloatConverter converter = new FloatConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("", converter.getAsString(facesContext, new UIPanel(), null)); - verify(facesContext); } /** @@ -105,10 +95,8 @@ public void testGetAsString2() { @Test public void testGetAsString3() { FloatConverter converter = new FloatConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("12.3", converter.getAsString(facesContext, new UIPanel(), "12.3")); - verify(facesContext); } /** @@ -117,9 +105,7 @@ public void testGetAsString3() { @Test public void testGetAsString4() { FloatConverter converter = new FloatConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("12.3", converter.getAsString(facesContext, new UIPanel(), Float.valueOf("12.3"))); - verify(facesContext); } } diff --git a/impl/src/test/java/jakarta/faces/convert/IntegerConverterTest.java b/impl/src/test/java/jakarta/faces/convert/IntegerConverterTest.java index 5975ab76bc..4427b9441d 100644 --- a/impl/src/test/java/jakarta/faces/convert/IntegerConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/IntegerConverterTest.java @@ -16,14 +16,12 @@ package jakarta.faces.convert; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; -import org.powermock.api.easymock.PowerMock; +import org.mockito.Mockito; import jakarta.faces.component.UIPanel; import jakarta.faces.context.FacesContext; @@ -48,10 +46,8 @@ public void testGetAsObject() { @Test public void testGetAsObject2() { IntegerConverter converter = new IntegerConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertNull(converter.getAsObject(facesContext, new UIPanel(), null)); - verify(facesContext); } /** @@ -60,10 +56,8 @@ public void testGetAsObject2() { @Test public void testGetAsObject3() { IntegerConverter converter = new IntegerConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertNull(converter.getAsObject(facesContext, new UIPanel(), " ")); - verify(facesContext); } /** @@ -72,10 +66,8 @@ public void testGetAsObject3() { @Test public void testGetAsObject4() { IntegerConverter converter = new IntegerConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals(Integer.valueOf("123"), converter.getAsObject(facesContext, new UIPanel(), "123")); - verify(facesContext); } /** @@ -93,10 +85,8 @@ public void testGetAsString() { @Test public void testGetAsString2() { IntegerConverter converter = new IntegerConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("", converter.getAsString(facesContext, new UIPanel(), null)); - verify(facesContext); } /** @@ -105,10 +95,8 @@ public void testGetAsString2() { @Test public void testGetAsString3() { IntegerConverter converter = new IntegerConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("123", converter.getAsString(facesContext, new UIPanel(), "123")); - verify(facesContext); } /** @@ -117,9 +105,7 @@ public void testGetAsString3() { @Test public void testGetAsString4() { IntegerConverter converter = new IntegerConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("123", converter.getAsString(facesContext, new UIPanel(), Integer.valueOf("123"))); - verify(facesContext); } } diff --git a/impl/src/test/java/jakarta/faces/convert/LongConverterTest.java b/impl/src/test/java/jakarta/faces/convert/LongConverterTest.java index 4dba1ea725..27e7f8fa6f 100644 --- a/impl/src/test/java/jakarta/faces/convert/LongConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/LongConverterTest.java @@ -16,14 +16,12 @@ package jakarta.faces.convert; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; -import org.powermock.api.easymock.PowerMock; +import org.mockito.Mockito; import jakarta.faces.component.UIPanel; import jakarta.faces.context.FacesContext; @@ -48,10 +46,8 @@ public void testGetAsObject() { @Test public void testGetAsObject2() { LongConverter converter = new LongConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertNull(converter.getAsObject(facesContext, new UIPanel(), null)); - verify(facesContext); } /** @@ -60,10 +56,8 @@ public void testGetAsObject2() { @Test public void testGetAsObject3() { LongConverter converter = new LongConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertNull(converter.getAsObject(facesContext, new UIPanel(), " ")); - verify(facesContext); } /** @@ -72,10 +66,8 @@ public void testGetAsObject3() { @Test public void testGetAsObject4() { LongConverter converter = new LongConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals(Long.valueOf("123"), converter.getAsObject(facesContext, new UIPanel(), "123")); - verify(facesContext); } /** @@ -93,10 +85,8 @@ public void testGetAsString() { @Test public void testGetAsString2() { LongConverter converter = new LongConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("", converter.getAsString(facesContext, new UIPanel(), null)); - verify(facesContext); } /** @@ -105,10 +95,8 @@ public void testGetAsString2() { @Test public void testGetAsString3() { LongConverter converter = new LongConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("123", converter.getAsString(facesContext, new UIPanel(), "123")); - verify(facesContext); } /** @@ -117,9 +105,7 @@ public void testGetAsString3() { @Test public void testGetAsString4() { LongConverter converter = new LongConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("123", converter.getAsString(facesContext, new UIPanel(), Long.valueOf("123"))); - verify(facesContext); } } diff --git a/impl/src/test/java/jakarta/faces/convert/ShortConverterTest.java b/impl/src/test/java/jakarta/faces/convert/ShortConverterTest.java index 50fb3cff1c..5223c7cb6d 100644 --- a/impl/src/test/java/jakarta/faces/convert/ShortConverterTest.java +++ b/impl/src/test/java/jakarta/faces/convert/ShortConverterTest.java @@ -16,14 +16,12 @@ package jakarta.faces.convert; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; -import org.powermock.api.easymock.PowerMock; +import org.mockito.Mockito; import jakarta.faces.component.UIPanel; import jakarta.faces.context.FacesContext; @@ -48,10 +46,8 @@ public void testGetAsObject() { @Test public void testGetAsObject2() { ShortConverter converter = new ShortConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertNull(converter.getAsObject(facesContext, new UIPanel(), null)); - verify(facesContext); } /** @@ -60,10 +56,8 @@ public void testGetAsObject2() { @Test public void testGetAsObject3() { ShortConverter converter = new ShortConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertNull(converter.getAsObject(facesContext, new UIPanel(), " ")); - verify(facesContext); } /** @@ -72,10 +66,8 @@ public void testGetAsObject3() { @Test public void testGetAsObject4() { ShortConverter converter = new ShortConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals(Short.valueOf("123"), converter.getAsObject(facesContext, new UIPanel(), "123")); - verify(facesContext); } /** @@ -93,10 +85,8 @@ public void testGetAsString() { @Test public void testGetAsString2() { ShortConverter converter = new ShortConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("", converter.getAsString(facesContext, new UIPanel(), null)); - verify(facesContext); } /** @@ -105,10 +95,8 @@ public void testGetAsString2() { @Test public void testGetAsString3() { ShortConverter converter = new ShortConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("123", converter.getAsString(facesContext, new UIPanel(), "123")); - verify(facesContext); } /** @@ -117,9 +105,7 @@ public void testGetAsString3() { @Test public void testGetAsString4() { ShortConverter converter = new ShortConverter(); - FacesContext facesContext = PowerMock.createMock(FacesContext.class); - replay(facesContext); + FacesContext facesContext = Mockito.mock(FacesContext.class); assertEquals("123", converter.getAsString(facesContext, new UIPanel(), Short.valueOf("123"))); - verify(facesContext); } } From 2ec61a15d2675b12c7e18fcd275f6063a34de4d9 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sat, 2 Mar 2024 13:38:32 -0400 Subject: [PATCH 4/9] Micro optimization to clarify intent of code https://github.com/eclipse-ee4j/mojarra/issues/5408 --- impl/src/main/java/com/sun/faces/context/FacesContextImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impl/src/main/java/com/sun/faces/context/FacesContextImpl.java b/impl/src/main/java/com/sun/faces/context/FacesContextImpl.java index a75013b10d..64657f1b46 100644 --- a/impl/src/main/java/com/sun/faces/context/FacesContextImpl.java +++ b/impl/src/main/java/com/sun/faces/context/FacesContextImpl.java @@ -424,7 +424,7 @@ public void setViewRoot(UIViewRoot root) { if (viewRoot != null && !viewRoot.equals(root)) { Map viewMap = viewRoot.getViewMap(false); if (viewMap != null) { - viewRoot.getViewMap().clear(); + viewMap.clear(); } RequestStateManager.clearAttributesOnChangeOfView(this); } From 5ed5652531f37dffa5670fd006ffc8de23c28b27 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sat, 2 Mar 2024 13:49:36 -0400 Subject: [PATCH 5/9] Reduce logging level of exception which is already rethrown during processing a lifecycle phase -- this only causes duplicate logs https://github.com/eclipse-ee4j/mojarra/issues/5404 --- .../java/com/sun/faces/lifecycle/ApplyRequestValuesPhase.java | 4 ++-- .../java/com/sun/faces/lifecycle/InvokeApplicationPhase.java | 4 ++-- .../java/com/sun/faces/lifecycle/ProcessValidationsPhase.java | 4 ++-- .../java/com/sun/faces/lifecycle/UpdateModelValuesPhase.java | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/impl/src/main/java/com/sun/faces/lifecycle/ApplyRequestValuesPhase.java b/impl/src/main/java/com/sun/faces/lifecycle/ApplyRequestValuesPhase.java index a2dfb81fb7..29726ae126 100644 --- a/impl/src/main/java/com/sun/faces/lifecycle/ApplyRequestValuesPhase.java +++ b/impl/src/main/java/com/sun/faces/lifecycle/ApplyRequestValuesPhase.java @@ -52,8 +52,8 @@ public void execute(FacesContext facesContext) throws FacesException { } catch (RuntimeException re) { String exceptionMessage = re.getMessage(); if (null != exceptionMessage) { - if (LOGGER.isLoggable(Level.WARNING)) { - LOGGER.log(Level.WARNING, exceptionMessage, re); + if (LOGGER.isLoggable(Level.FINE)) { + LOGGER.log(Level.FINE, exceptionMessage, re); } } throw new FacesException(exceptionMessage, re); diff --git a/impl/src/main/java/com/sun/faces/lifecycle/InvokeApplicationPhase.java b/impl/src/main/java/com/sun/faces/lifecycle/InvokeApplicationPhase.java index 1ccd7d919f..717714835d 100644 --- a/impl/src/main/java/com/sun/faces/lifecycle/InvokeApplicationPhase.java +++ b/impl/src/main/java/com/sun/faces/lifecycle/InvokeApplicationPhase.java @@ -57,8 +57,8 @@ public void execute(FacesContext facesContext) throws FacesException { } catch (RuntimeException re) { String exceptionMessage = re.getMessage(); if (null != exceptionMessage) { - if (LOGGER.isLoggable(Level.WARNING)) { - LOGGER.log(Level.WARNING, exceptionMessage, re); + if (LOGGER.isLoggable(Level.FINE)) { + LOGGER.log(Level.FINE, exceptionMessage, re); } } throw new FacesException(exceptionMessage, re); diff --git a/impl/src/main/java/com/sun/faces/lifecycle/ProcessValidationsPhase.java b/impl/src/main/java/com/sun/faces/lifecycle/ProcessValidationsPhase.java index 9eb4a8cf1e..675a95754a 100644 --- a/impl/src/main/java/com/sun/faces/lifecycle/ProcessValidationsPhase.java +++ b/impl/src/main/java/com/sun/faces/lifecycle/ProcessValidationsPhase.java @@ -50,8 +50,8 @@ public void execute(FacesContext facesContext) throws FacesException { } catch (RuntimeException re) { String exceptionMessage = re.getMessage(); if (null != exceptionMessage) { - if (LOGGER.isLoggable(Level.WARNING)) { - LOGGER.log(Level.WARNING, exceptionMessage, re); + if (LOGGER.isLoggable(Level.FINE)) { + LOGGER.log(Level.FINE, exceptionMessage, re); } } throw new FacesException(exceptionMessage, re); diff --git a/impl/src/main/java/com/sun/faces/lifecycle/UpdateModelValuesPhase.java b/impl/src/main/java/com/sun/faces/lifecycle/UpdateModelValuesPhase.java index b4cf5b56e9..adf3edb904 100644 --- a/impl/src/main/java/com/sun/faces/lifecycle/UpdateModelValuesPhase.java +++ b/impl/src/main/java/com/sun/faces/lifecycle/UpdateModelValuesPhase.java @@ -51,8 +51,8 @@ public void execute(FacesContext facesContext) { } catch (RuntimeException re) { String exceptionMessage = re.getMessage(); if (null != exceptionMessage) { - if (LOGGER.isLoggable(Level.WARNING)) { - LOGGER.log(Level.WARNING, exceptionMessage, re); + if (LOGGER.isLoggable(Level.FINE)) { + LOGGER.log(Level.FINE, exceptionMessage, re); } } throw new FacesException(exceptionMessage, re); From bbc402c708ef4ef487b5884b2a4474007e49e10b Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sun, 3 Mar 2024 10:55:27 -0400 Subject: [PATCH 6/9] add xsds for 4.1 --- .../sun/faces/config/manager/FacesSchema.java | 31 +- .../resources/com/sun/faces/jakartaee_11.xsd | 3073 +++++++++++++++ .../taglib/faces.composite.taglib.xml | 4 +- .../metadata/taglib/faces.core.taglib.xml | 4 +- .../metadata/taglib/faces.facelets.taglib.xml | 4 +- .../metadata/taglib/faces.html.taglib.xml | 4 +- .../taglib/faces.passthrough.taglib.xml | 4 +- .../faces/metadata/taglib/faces.taglib.xml | 4 +- .../metadata/taglib/tags.core.taglib.xml | 4 +- .../metadata/taglib/tags.functions.taglib.xml | 4 +- .../sun/faces/web-facelettaglibrary_4_1.xsd | 751 ++++ .../com/sun/faces/web-facesconfig_4_1.xsd | 3447 +++++++++++++++++ .../com/sun/faces/web-partialresponse_4_1.xsd | 403 ++ 13 files changed, 7720 insertions(+), 17 deletions(-) create mode 100644 impl/src/main/resources/com/sun/faces/jakartaee_11.xsd create mode 100644 impl/src/main/resources/com/sun/faces/web-facelettaglibrary_4_1.xsd create mode 100644 impl/src/main/resources/com/sun/faces/web-facesconfig_4_1.xsd create mode 100644 impl/src/main/resources/com/sun/faces/web-partialresponse_4_1.xsd diff --git a/impl/src/main/java/com/sun/faces/config/manager/FacesSchema.java b/impl/src/main/java/com/sun/faces/config/manager/FacesSchema.java index fe3ff0ab59..88e518ae44 100644 --- a/impl/src/main/java/com/sun/faces/config/manager/FacesSchema.java +++ b/impl/src/main/java/com/sun/faces/config/manager/FacesSchema.java @@ -30,6 +30,8 @@ import static com.sun.faces.config.manager.FacesSchema.Schemas.FACES_3_0_XSD_FILE; import static com.sun.faces.config.manager.FacesSchema.Schemas.FACES_4_0_XSD; import static com.sun.faces.config.manager.FacesSchema.Schemas.FACES_4_0_XSD_FILE; +import static com.sun.faces.config.manager.FacesSchema.Schemas.FACES_4_1_XSD; +import static com.sun.faces.config.manager.FacesSchema.Schemas.FACES_4_1_XSD_FILE; import static com.sun.faces.config.manager.FacesSchema.Schemas.FACES_CONFIG_1_X_DEFAULT_NS; import static com.sun.faces.config.manager.FacesSchema.Schemas.JAKARTAEE_SCHEMA_DEFAULT_NS; import static com.sun.faces.config.manager.FacesSchema.Schemas.JAVAEE_SCHEMA_DEFAULT_NS; @@ -63,13 +65,15 @@ public enum FacesSchema { FACES_23(FACES_2_3_XSD, FACES_2_3_XSD_FILE), FACES_30(FACES_3_0_XSD, FACES_3_0_XSD_FILE), FACES_40(FACES_4_0_XSD, FACES_4_0_XSD_FILE), + FACES_41(FACES_4_1_XSD, FACES_4_1_XSD_FILE), // taglib.xml FACELET_TAGLIB_20(Schemas.FACELET_TAGLIB_2_0_XSD, Schemas.FACELET_TAGLIB_2_0_XSD_FILE), FACELET_TAGLIB_22(Schemas.FACELET_TAGLIB_2_2_XSD, Schemas.FACELET_TAGLIB_2_2_XSD_FILE), FACELET_TAGLIB_23(Schemas.FACELET_TAGLIB_2_3_XSD, Schemas.FACELET_TAGLIB_2_3_XSD_FILE), FACELET_TAGLIB_30(Schemas.FACELET_TAGLIB_3_0_XSD, Schemas.FACELET_TAGLIB_3_0_XSD_FILE), - FACELET_TAGLIB_40(Schemas.FACELET_TAGLIB_4_0_XSD, Schemas.FACELET_TAGLIB_4_0_XSD_FILE); + FACELET_TAGLIB_40(Schemas.FACELET_TAGLIB_4_0_XSD, Schemas.FACELET_TAGLIB_4_0_XSD_FILE), + FACELET_TAGLIB_41(Schemas.FACELET_TAGLIB_4_1_XSD, Schemas.FACELET_TAGLIB_4_1_XSD_FILE); /** * Constants for individual schema files @@ -90,6 +94,7 @@ public static class Schemas { public static final String FACELET_TAGLIB_2_3_XSD = "/com/sun/faces/web-facelettaglibrary_2_3.xsd"; public static final String FACELET_TAGLIB_3_0_XSD = "/com/sun/faces/web-facelettaglibrary_3_0.xsd"; public static final String FACELET_TAGLIB_4_0_XSD = "/com/sun/faces/web-facelettaglibrary_4_0.xsd"; + public static final String FACELET_TAGLIB_4_1_XSD = "/com/sun/faces/web-facelettaglibrary_4_1.xsd"; public static final String FACES_1_2_XSD = "/com/sun/faces/web-facesconfig_1_2.xsd"; public static final String FACES_1_1_XSD = "/com/sun/faces/web-facesconfig_1_1.xsd"; @@ -99,12 +104,14 @@ public static class Schemas { public static final String FACES_2_3_XSD = "/com/sun/faces/web-facesconfig_2_3.xsd"; public static final String FACES_3_0_XSD = "/com/sun/faces/web-facesconfig_3_0.xsd"; public static final String FACES_4_0_XSD = "/com/sun/faces/web-facesconfig_4_0.xsd"; + public static final String FACES_4_1_XSD = "/com/sun/faces/web-facesconfig_4_1.xsd"; public static final String FACELET_TAGLIB_2_0_XSD_FILE = AS_SCHEMA_DIR + "web-facelettaglibrary_2_0.xsd"; public static final String FACELET_TAGLIB_2_2_XSD_FILE = AS_SCHEMA_DIR + "web-facelettaglibrary_2_2.xsd"; public static final String FACELET_TAGLIB_2_3_XSD_FILE = AS_SCHEMA_DIR + "web-facelettaglibrary_2_3.xsd"; public static final String FACELET_TAGLIB_3_0_XSD_FILE = AS_SCHEMA_DIR + "web-facelettaglibrary_3_0.xsd"; public static final String FACELET_TAGLIB_4_0_XSD_FILE = AS_SCHEMA_DIR + "web-facelettaglibrary_4_0.xsd"; + public static final String FACELET_TAGLIB_4_1_XSD_FILE = AS_SCHEMA_DIR + "web-facelettaglibrary_4_1.xsd"; // #### faces-config.xml XSDs within GlassFish @@ -115,6 +122,7 @@ public static class Schemas { public static final String FACES_2_3_XSD_FILE = AS_SCHEMA_DIR + "web-facesconfig_2_3.xsd"; public static final String FACES_3_0_XSD_FILE = AS_SCHEMA_DIR + "web-facesconfig_3_0.xsd"; public static final String FACES_4_0_XSD_FILE = AS_SCHEMA_DIR + "web-facesconfig_4_0.xsd"; + public static final String FACES_4_1_XSD_FILE = AS_SCHEMA_DIR + "web-facesconfig_4_1.xsd"; /** * Contains associations between grammar name and the physical resource. @@ -160,6 +168,11 @@ public static class Schemas { FACES_4_0_XSD, FACES_4_0_XSD_FILE }, + { + "web-facesconfig_4_1.xsd", + FACES_4_1_XSD, + FACES_4_1_XSD_FILE + }, { "facelet-taglib_1_0.dtd", "/com/sun/faces/facelet-taglib_1_0.dtd", @@ -190,6 +203,11 @@ public static class Schemas { FACELET_TAGLIB_4_0_XSD, FACELET_TAGLIB_4_0_XSD_FILE }, + { + "web-facelettaglibrary_4_1.xsd", + FACELET_TAGLIB_4_1_XSD, + FACELET_TAGLIB_4_1_XSD_FILE + }, { "web-facesconfig_1_2.xsd", FACES_1_2_XSD, @@ -230,6 +248,11 @@ public static class Schemas { "/com/sun/faces/jakartaee_10.xsd", AS_SCHEMA_DIR + "jakartaee_10.xsd" }, + { + "jakartaee_11.xsd", + "/com/sun/faces/jakartaee_11.xsd", + AS_SCHEMA_DIR + "jakartaee_11.xsd" + }, { "javaee_web_services_client_1_2.xsd", "/com/sun/faces/javaee_web_services_client_1_2.xsd", @@ -293,6 +316,12 @@ public static FacesSchema fromDocumentId(String documentNS, String version, Stri switch (documentNS) { case JAKARTAEE_SCHEMA_DEFAULT_NS: { switch (version) { + case "4.1": + if ("facelet-taglib".equals(localName)) { + return FACELET_TAGLIB_41; + } else { + return FACES_41; + } case "4.0": if ("facelet-taglib".equals(localName)) { return FACELET_TAGLIB_40; diff --git a/impl/src/main/resources/com/sun/faces/jakartaee_11.xsd b/impl/src/main/resources/com/sun/faces/jakartaee_11.xsd new file mode 100644 index 0000000000..a198bfff00 --- /dev/null +++ b/impl/src/main/resources/com/sun/faces/jakartaee_11.xsd @@ -0,0 +1,3073 @@ + + + + + + Copyright (c) 2009, 2024 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + + + + + + + + The following definitions that appear in the common + shareable schema(s) of Jakarta EE deployment descriptors should be + interpreted with respect to the context they are included: + + Deployment Component may indicate one of the following: + Jakarta EE application; + application client; + web application; + enterprise bean; + resource adapter; + + Deployment File may indicate one of the following: + ear file; + war file; + jar file; + rar file; + + + + + + + + + + + + + This group keeps the usage of the contained description related + elements consistent across Jakarta EE deployment descriptors. + + All elements may occur multiple times with different languages, + to support localization of the content. + + + + + + + + + + + + + + + This group keeps the usage of the contained JNDI environment + reference elements consistent across Jakarta EE deployment descriptors. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This group collects elements that are common to most + JNDI resource elements. + + + + + + + + + + The JNDI name to be looked up to resolve a resource reference. + + + + + + + + + + + + This group collects elements that are common to all the + JNDI resource elements. It does not include the lookup-name + element, that is only applicable to some resource elements. + + + + + + + + + A product specific name that this resource should be + mapped to. The name of this resource, as defined by the + resource's name element or defaulted, is a name that is + local to the application component using the resource. + (It's a name in the JNDI java:comp/env namespace.) Many + application servers provide a way to map these local + names to names of resources known to the application + server. This mapped name is often a global JNDI name, + but may be a name of any form. + + Application servers are not required to support any + particular form or type of mapped name, nor the ability + to use mapped names. The mapped name is + product-dependent and often installation-dependent. No + use of a mapped name is portable. + + + + + + + + + + + + + + + + Configuration of an administered object. + + + + + + + + + Description of this administered object. + + + + + + + + + The name element specifies the JNDI name of the + administered object being defined. + + + + + + + + + The administered object's interface type. + + + + + + + + + The administered object's class name. + + + + + + + + + Resource adapter name. + + + + + + + + + Property of the administered object property. This may be a + vendor-specific property. + + + + + + + + + + + + + + + + Configuration of a Connector Connection Factory resource. + + + + + + + + + Description of this resource. + + + + + + + + + The name element specifies the JNDI name of the + resource being defined. + + + + + + + + + The fully qualified class name of the connection factory + interface. + + + + + + + + + Resource adapter name. + + + + + + + + + Maximum number of connections that should be concurrently + allocated for a connection pool. + + + + + + + + + Minimum number of connections that should be concurrently + allocated for a connection pool. + + + + + + + + + The level of transaction support the connection factory + needs to support. + + + + + + + + + Resource property. This may be a vendor-specific + property. + + + + + + + + + + + + + + + + Configuration of a DataSource. + + + + + + + + + Description of this DataSource. + + + + + + + + + The name element specifies the JNDI name of the + data source being defined. + + + + + + + + + DataSource, XADataSource or ConnectionPoolDataSource + implementation class. + + + + + + + + + Database server name. + + + + + + + + + Port number where a server is listening for requests. + + + + + + + + + Name of a database on a server. + + + + + + + + url property is specified + along with other standard DataSource properties + such as serverName, databaseName + and portNumber, the more specific properties will + take precedence and url will be ignored. + + ]]> + + + + + + + + User name to use for connection authentication. + + + + + + + + + Password to use for connection authentication. + + + + + + + + + JDBC DataSource property. This may be a vendor-specific + property or a less commonly used DataSource property. + + + + + + + + + Sets the maximum time in seconds that this data source + will wait while attempting to connect to a database. + + + + + + + + + Set to false if connections should not participate in + transactions. + + + + + + + + + Isolation level for connections. + + + + + + + + + Number of connections that should be created when a + connection pool is initialized. + + + + + + + + + Maximum number of connections that should be concurrently + allocated for a connection pool. + + + + + + + + + Minimum number of connections that should be concurrently + allocated for a connection pool. + + + + + + + + + The number of seconds that a physical connection should + remain unused in the pool before the connection is + closed for a connection pool. + + + + + + + + + The total number of statements that a connection pool + should keep open. + + + + + + + + + + + + + + + + The description type is used by a description element to + provide text describing the parent element. The elements + that use this type should include any information that the + Deployment Component's Deployment File file producer wants + to provide to the consumer of the Deployment Component's + Deployment File (i.e., to the Deployer). Typically, the + tools used by such a Deployment File consumer will display + the description when processing the parent element that + contains the description. + + The lang attribute defines the language that the + description is provided in. The default value is "en" (English). + + + + + + + + + + + + + + + This type defines a dewey decimal that is used + to describe versions of documents. + + + + + + + + + + + + + + + + Employee Self Service + + + The value of the xml:lang attribute is "en" (English) by default. + + ]]> + + + + + + + + + + + + + + + + EmployeeRecord + + ../products/product.jar#ProductEJB + + ]]> + + + + + + + + + + + + + + + The ejb-local-refType is used by ejb-local-ref elements for + the declaration of a reference to an enterprise bean's local + home or to the local business interface of a 3.0 bean. + The declaration consists of: + + - an optional description + - the enterprise bean's reference name used in the code of the + Deployment Component that's referencing the enterprise bean. + - the optional expected type of the referenced enterprise bean + - the optional expected local interface of the referenced + enterprise bean or the local business interface of the + referenced enterprise bean. + - the optional expected local home interface of the referenced + enterprise bean. Not applicable if this ejb-local-ref refers + to the local business interface of a 3.0 bean. + - optional ejb-link information, used to specify the + referenced enterprise bean + - optional elements to define injection of the named enterprise + bean into a component field or property. + + + + + + + + + + + + + + + + + + + + + + ejb/Payroll + + ]]> + + + + + + + + + + + + + + + The ejb-refType is used by ejb-ref elements for the + declaration of a reference to an enterprise bean's home or + to the remote business interface of a 3.0 bean. + The declaration consists of: + + - an optional description + - the enterprise bean's reference name used in the code of + the Deployment Component that's referencing the enterprise + bean. + - the optional expected type of the referenced enterprise bean + - the optional remote interface of the referenced enterprise bean + or the remote business interface of the referenced enterprise + bean + - the optional expected home interface of the referenced + enterprise bean. Not applicable if this ejb-ref + refers to the remote business interface of a 3.0 bean. + - optional ejb-link information, used to specify the + referenced enterprise bean + - optional elements to define injection of the named enterprise + bean into a component field or property + + + + + + + + + + + + + + + + + + + + + + + The ejb-ref-typeType contains the expected type of the + referenced enterprise bean. + + The ejb-ref-type designates a value + that must be one of the following: + + Entity + Session + + + + + + + + + + + + + + + + + + + This type is used to designate an empty + element when used. + + + + + + + + + + + + + + The env-entryType is used to declare an application's + environment entry. The declaration consists of an optional + description, the name of the environment entry, a type + (optional if the value is injected, otherwise required), and + an optional value. + + It also includes optional elements to define injection of + the named resource into fields or JavaBeans properties. + + If a value is not specified and injection is requested, + no injection will occur and no entry of the specified name + will be created. This allows an initial value to be + specified in the source code without being incorrectly + changed when no override has been specified. + + If a value is not specified and no injection is requested, + a value must be supplied during deployment. + + This type is used by env-entry elements. + + + + + + + + + minAmount + + ]]> + + + + + + + java.lang.Integer + + ]]> + + + + + + + 100.00 + + ]]> + + + + + + + + + + + + + + + java.lang.Boolean + java.lang.Class + com.example.Color + + ]]> + + + + + + + + + + + + + + + The elements that use this type designate the name of a + Java class or interface. The name is in the form of a + "binary name", as defined in the JLS. This is the form + of name used in Class.forName(). Tools that need the + canonical name (the name used in source code) will need + to convert this binary name to the canonical name. + + + + + + + + + + + + + + + + This type defines four different values which can designate + boolean values. This includes values yes and no which are + not designated by xsd:boolean + + + + + + + + + + + + + + + + + + + + + The icon type contains small-icon and large-icon elements + that specify the file names for small and large GIF, JPEG, + or PNG icon images used to represent the parent element in a + GUI tool. + + The xml:lang attribute defines the language that the + icon file names are provided in. Its value is "en" (English) + by default. + + + + + + + + employee-service-icon16x16.jpg + + ]]> + + + + + + + employee-service-icon32x32.jpg + + ]]> + + + + + + + + + + + + + + + + An injection target specifies a class and a name within + that class into which a resource should be injected. + + The injection target class specifies the fully qualified + class name that is the target of the injection. The + Jakarta EE specifications describe which classes can be an + injection target. + + The injection target name specifies the target within + the specified class. The target is first looked for as a + JavaBeans property name. If not found, the target is + looked for as a field name. + + The specified resource will be injected into the target + during initialization of the class by either calling the + set method for the target property or by setting a value + into the named field. + + + + + + + + + + + + + + The following transaction isolation levels are allowed + (see documentation for the java.sql.Connection interface): + TRANSACTION_READ_UNCOMMITTED + TRANSACTION_READ_COMMITTED + TRANSACTION_REPEATABLE_READ + TRANSACTION_SERIALIZABLE + + + + + + + + + + + + + + + + + + + The java-identifierType defines a Java identifier. + The users of this type should further verify that + the content does not contain Java reserved keywords. + + + + + + + + + + + + + + + + + + This is a generic type that designates a Java primitive + type or a fully qualified name of a Java interface/type, + or an array of such types. + + + + + + + + + + + + + + + + + : + + Example: + + jdbc:mysql://localhost:3307/testdb + + ]]> + + + + + + + + + + + + + + + + + Configuration of a Messaging Connection Factory. + + + + + + + + + Description of this Messaging Connection Factory. + + + + + + + + + The name element specifies the JNDI name of the + messaging connection factory being defined. + + + + + + + + + Fully-qualified name of the messaging connection factory + interface. Permitted values are jakarta.jms.ConnectionFactory, + jakarta.jms.QueueConnectionFactory, or + jakarta.jms.TopicConnectionFactory. If not specified, + jakarta.jms.ConnectionFactory will be used. + + + + + + + + + Fully-qualified name of the messaging connection factory + implementation class. Ignored if a resource adapter + is used. + + + + + + + + + Resource adapter name. If not specified, the application + server will define the default behavior, which may or may + not involve the use of a resource adapter. + + + + + + + + + User name to use for connection authentication. + + + + + + + + + Password to use for connection authentication. + + + + + + + + + Client id to use for connection. + + + + + + + + + Messaging Connection Factory property. This may be a vendor-specific + property or a less commonly used ConnectionFactory property. + + + + + + + + + Set to false if connections should not participate in + transactions. + + + + + + + + + Maximum number of connections that should be concurrently + allocated for a connection pool. + + + + + + + + + Minimum number of connections that should be concurrently + allocated for a connection pool. + + + + + + + + + + + + + + + + Configuration of a Messaging Destination. + + + + + + + + + Description of this Messaging Destination. + + + + + + + + + The name element specifies the JNDI name of the + messaging destination being defined. + + + + + + + + + Fully-qualified name of the messaging destination interface. + Permitted values are jakarta.jms.Queue and jakarta.jms.Topic + + + + + + + + + Fully-qualified name of the messaging destination implementation + class. Ignored if a resource adapter is used unless the + resource adapter defines more than one destination implementation + class for the specified interface. + + + + + + + + + Resource adapter name. If not specified, the application + server will define the default behavior, which may or may + not involve the use of a resource adapter. + + + + + + + + + Name of the queue or topic. + + + + + + + + + Messaging Destination property. This may be a vendor-specific + property or a less commonly used Destination property. + + + + + + + + + + + + + + + + The jndi-nameType type designates a JNDI name in the + Deployment Component's environment and is relative to the + java:comp/env context. A JNDI name must be unique within the + Deployment Component. + + + + + + + + + + + + + + + com.aardvark.payroll.PayrollHome + + ]]> + + + + + + + + + + + + + + + The lifecycle-callback type specifies a method on a + class to be called when a lifecycle event occurs. + Note that each class may have only one lifecycle callback + method for any given event and that the method may not + be overloaded. + + If the lifefycle-callback-class element is missing then + the class defining the callback is assumed to be the + component class in scope at the place in the descriptor + in which the callback definition appears. + + + + + + + + + + + + + + + + + The listenerType indicates the deployment properties for a web + application listener bean. + + + + + + + + + + The listener-class element declares a class in the + application must be registered as a web + application listener bean. The value is the fully + qualified classname of the listener class. + + + + + + + + + + + + + + + + The localType defines the fully-qualified name of an + enterprise bean's local interface. + + + + + + + + + + + + + + + + The local-homeType defines the fully-qualified + name of an enterprise bean's local home interface. + + + + + + + + + + + + + + + + Configuration of a Mail Session resource. + + + + + + + + + Description of this Mail Session resource. + + + + + + + + + The name element specifies the JNDI name of the + Mail Session resource being defined. + + + + + + + + + Storage protocol. + + + + + + + + + Service provider store protocol implementation class + + + + + + + + + Transport protocol. + + + + + + + + + Service provider transport protocol implementation class + + + + + + + + + Mail server host name. + + + + + + + + + Mail server user name. + + + + + + + + + Password. + + + + + + + + + Email address to indicate the message sender. + + + + + + + + + Mail server property. This may be a vendor-specific + property. + + + + + + + + + + + + + + + + This type is a general type that can be used to declare + parameter/value lists. + + + + + + + + + + The param-name element contains the name of a + parameter. + + + + + + + + + The param-value element contains the value of a + parameter. + + + + + + + + + + + + + + + + The elements that use this type designate either a relative + path or an absolute path starting with a "/". + + In elements that specify a pathname to a file within the + same Deployment File, relative filenames (i.e., those not + starting with "/") are considered relative to the root of + the Deployment File's namespace. Absolute filenames (i.e., + those starting with "/") also specify names in the root of + the Deployment File's namespace. In general, relative names + are preferred. The exception is .war files where absolute + names are preferred for consistency with the Servlet API. + + + + + + + + + + + + + + + + myPersistenceContext + + + + + myPersistenceContext + + PersistenceUnit1 + + Extended + + + ]]> + + + + + + + + + The persistence-context-ref-name element specifies + the name of a persistence context reference; its + value is the environment entry name used in + Deployment Component code. The name is a JNDI name + relative to the java:comp/env context. + + + + + + + + + The Application Assembler(or BeanProvider) may use the + following syntax to avoid the need to rename persistence + units to have unique names within a Jakarta EE application. + + The Application Assembler specifies the pathname of the + root of the persistence.xml file for the referenced + persistence unit and appends the name of the persistence + unit separated from the pathname by #. The pathname is + relative to the referencing application component jar file. + In this manner, multiple persistence units with the same + persistence unit name may be uniquely identified when the + Application Assembler cannot change persistence unit names. + + + + + + + + + + + Used to specify properties for the container or persistence + provider. Vendor-specific properties may be included in + the set of properties. Properties that are not recognized + by a vendor must be ignored. Entries that make use of the + namespace jakarta.persistence and its subnamespaces must not + be used for vendor-specific properties. The namespace + jakarta.persistence is reserved for use by the specification. + + + + + + + + + + + + + + + + + The persistence-context-synchronizationType specifies + whether a container-managed persistence context is automatically + synchronized with the current transaction. + + The value of the persistence-context-synchronization element + must be one of the following: + Synchronized + Unsynchronized + + + + + + + + + + + + + + + + + + + The persistence-context-typeType specifies the transactional + nature of a persistence context reference. + + The value of the persistence-context-type element must be + one of the following: + Transaction + Extended + + + + + + + + + + + + + + + + + + + Specifies a name/value pair. + + + + + + + + + + + + + + + + + + + + myPersistenceUnit + + + + + myPersistenceUnit + + PersistenceUnit1 + + + + ]]> + + + + + + + + + The persistence-unit-ref-name element specifies + the name of a persistence unit reference; its + value is the environment entry name used in + Deployment Component code. The name is a JNDI name + relative to the java:comp/env context. + + + + + + + + + The Application Assembler(or BeanProvider) may use the + following syntax to avoid the need to rename persistence + units to have unique names within a Jakarta EE application. + + The Application Assembler specifies the pathname of the + root of the persistence.xml file for the referenced + persistence unit and appends the name of the persistence + unit separated from the pathname by #. The pathname is + relative to the referencing application component jar file. + In this manner, multiple persistence units with the same + persistence unit name may be uniquely identified when the + Application Assembler cannot change persistence unit names. + + + + + + + + + + + + + + + + com.wombat.empl.EmployeeService + + ]]> + + + + + + + + + + + + + + + jms/StockQueue + + jakarta.jms.Queue + + + + ]]> + + + + + + + + + The resource-env-ref-name element specifies the name + of a resource environment reference; its value is + the environment entry name used in + the Deployment Component code. The name is a JNDI + name relative to the java:comp/env context and must + be unique within a Deployment Component. + + + + + + + + + The resource-env-ref-type element specifies the type + of a resource environment reference. It is the + fully qualified name of a Java language class or + interface. + + + + + + + + + + + + + + + + + jdbc/EmployeeAppDB + javax.sql.DataSource + Container + Shareable + + + ]]> + + + + + + + + + The res-ref-name element specifies the name of a + resource manager connection factory reference. + The name is a JNDI name relative to the + java:comp/env context. + The name must be unique within a Deployment File. + + + + + + + + + The res-type element specifies the type of the data + source. The type is specified by the fully qualified + Java language class or interface + expected to be implemented by the data source. + + + + + + + + + + + + + + + + + + + The res-authType specifies whether the Deployment Component + code signs on programmatically to the resource manager, or + whether the Container will sign on to the resource manager + on behalf of the Deployment Component. In the latter case, + the Container uses information that is supplied by the + Deployer. + + The value must be one of the two following: + + Application + Container + + + + + + + + + + + + + + + + + + + The res-sharing-scope type specifies whether connections + obtained through the given resource manager connection + factory reference can be shared. The value, if specified, + must be one of the two following: + + Shareable + Unshareable + + The default value is Shareable. + + + + + + + + + + + + + + + + + + + The run-asType specifies the run-as identity to be + used for the execution of a component. It contains an + optional description, and the name of a security role. + + + + + + + + + + + + + + + + + + The role-nameType designates the name of a security role. + + The name must conform to the lexical rules for a token. + + + + + + + + + + + + + + + + + This role includes all employees who are authorized + to access the employee service application. + + employee + + + ]]> + + + + + + + + + + + + + + + + + The security-role-refType contains the declaration of a + security role reference in a component's or a + Deployment Component's code. The declaration consists of an + optional description, the security role name used in the + code, and an optional link to a security role. If the + security role is not specified, the Deployer must choose an + appropriate security role. + + + + + + + + + + The value of the role-name element must be the String used + as the parameter to the + EJBContext.isCallerInRole(String roleName) method or the + HttpServletRequest.isUserInRole(String role) method. + + + + + + + + + The role-link element is a reference to a defined + security role. The role-link element must contain + the name of one of the security roles defined in the + security-role elements. + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:QName. + + + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:boolean. + + + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:NMTOKEN. + + + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:anyURI. + + + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:integer. + + + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:positiveInteger. + + + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:nonNegativeInteger. + + + + + + + + + + + + + + + + + + This type adds an "id" attribute to xsd:string. + + + + + + + + + + + + + + + + + + This is a special string datatype that is defined by Jakarta EE as + a base type for defining collapsed strings. When schemas + require trailing/leading space elimination as well as + collapsing the existing whitespace, this base type may be + used. + + + + + + + + + + + + + + + + + + This simple type designates a boolean with only two + permissible values + + - true + - false + + + + + + + + + + + + + + + + + + The url-patternType contains the url pattern of the mapping. + It must follow the rules specified in Section 11.2 of the + Servlet API Specification. This pattern is assumed to be in + URL-decoded form and must not contain CR(#xD) or LF(#xA). + If it contains those characters, the container must inform + the developer with a descriptive error message. + The container must preserve all characters including whitespaces. + + + + + + + + + + + + + + + + CorporateStocks + + + + ]]> + + + + + + + + + The message-destination-name element specifies a + name for a message destination. This name must be + unique among the names of message destinations + within the Deployment File. + + + + + + + + + A product specific name that this message destination + should be mapped to. Each message-destination-ref + element that references this message destination will + define a name in the namespace of the referencing + component or in one of the other predefined namespaces. + Many application servers provide a way to map these + local names to names of resources known to the + application server. This mapped name is often a global + JNDI name, but may be a name of any form. Each of the + local names should be mapped to this same global name. + + Application servers are not required to support any + particular form or type of mapped name, nor the ability + to use mapped names. The mapped name is + product-dependent and often installation-dependent. No + use of a mapped name is portable. + + + + + + + + + The JNDI name to be looked up to resolve the message destination. + + + + + + + + + + + + + + + + jms/StockQueue + + jakarta.jms.Queue + + Consumes + + CorporateStocks + + + + ]]> + + + + + + + + + The message-destination-ref-name element specifies + the name of a message destination reference; its + value is the environment entry name used in + Deployment Component code. + + + + + + + + + + + + + + + + + + + + The message-destination-usageType specifies the use of the + message destination indicated by the reference. The value + indicates whether messages are consumed from the message + destination, produced for the destination, or both. The + Assembler makes use of this information in linking producers + of a destination with its consumers. + + The value of the message-destination-usage element must be + one of the following: + Consumes + Produces + ConsumesProduces + + + + + + + + + + + + + + + + + + + jakarta.jms.Queue + + + ]]> + + + + + + + + + + + + + + + The message-destination-linkType is used to link a message + destination reference or message-driven bean to a message + destination. + + The Assembler sets the value to reflect the flow of messages + between producers and consumers in the application. + + The value must be the message-destination-name of a message + destination in the same Deployment File or in another + Deployment File in the same Jakarta EE application unit. + + Alternatively, the value may be composed of a path name + specifying a Deployment File containing the referenced + message destination with the message-destination-name of the + destination appended and separated from the path name by + "#". The path name is relative to the Deployment File + containing Deployment Component that is referencing the + message destination. This allows multiple message + destinations with the same name to be uniquely identified. + + + + + + + + + + + + + + + + The transaction-supportType specifies the level of + transaction support provided by the resource adapter. It is + used by transaction-support elements. + + The value must be one of the following: + + NoTransaction + LocalTransaction + XATransaction + + + + + + + + + + + + + diff --git a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.composite.taglib.xml b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.composite.taglib.xml index d29c06a9a6..d811047a54 100644 --- a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.composite.taglib.xml +++ b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.composite.taglib.xml @@ -20,8 +20,8 @@ Jakarta Faces Composite Components Tag Library

diff --git a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.core.taglib.xml b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.core.taglib.xml index fc008a3046..2459297ef5 100644 --- a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.core.taglib.xml +++ b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.core.taglib.xml @@ -20,8 +20,8 @@ Jakarta Faces Core Tag Library

diff --git a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.facelets.taglib.xml b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.facelets.taglib.xml index 0a71c260be..6430dac92a 100644 --- a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.facelets.taglib.xml +++ b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.facelets.taglib.xml @@ -20,8 +20,8 @@ Jakarta Faces Facelets Tag Library

diff --git a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.html.taglib.xml b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.html.taglib.xml index 8f884f9bf3..3f59ffd374 100644 --- a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.html.taglib.xml +++ b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.html.taglib.xml @@ -20,8 +20,8 @@ Jakarta Faces HTML Tag Library

diff --git a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.passthrough.taglib.xml b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.passthrough.taglib.xml index ce8b10ee2e..f8906bf893 100644 --- a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.passthrough.taglib.xml +++ b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.passthrough.taglib.xml @@ -20,8 +20,8 @@ Jakarta Faces Passthrough Attributes Tag Library

diff --git a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.taglib.xml b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.taglib.xml index f36f7849b8..38edfbb7a5 100644 --- a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.taglib.xml +++ b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.taglib.xml @@ -20,8 +20,8 @@ Jakarta Faces Passthrough Elements Tag Library

diff --git a/impl/src/main/resources/com/sun/faces/metadata/taglib/tags.core.taglib.xml b/impl/src/main/resources/com/sun/faces/metadata/taglib/tags.core.taglib.xml index d4de234080..a6942cc353 100644 --- a/impl/src/main/resources/com/sun/faces/metadata/taglib/tags.core.taglib.xml +++ b/impl/src/main/resources/com/sun/faces/metadata/taglib/tags.core.taglib.xml @@ -20,8 +20,8 @@ Jakarta Tags Core Tag Library

diff --git a/impl/src/main/resources/com/sun/faces/metadata/taglib/tags.functions.taglib.xml b/impl/src/main/resources/com/sun/faces/metadata/taglib/tags.functions.taglib.xml index e041bc93d5..bba2172b00 100644 --- a/impl/src/main/resources/com/sun/faces/metadata/taglib/tags.functions.taglib.xml +++ b/impl/src/main/resources/com/sun/faces/metadata/taglib/tags.functions.taglib.xml @@ -20,8 +20,8 @@ Jakarta Tags Functions Tag Library

diff --git a/impl/src/main/resources/com/sun/faces/web-facelettaglibrary_4_1.xsd b/impl/src/main/resources/com/sun/faces/web-facelettaglibrary_4_1.xsd new file mode 100644 index 0000000000..8346e03dc0 --- /dev/null +++ b/impl/src/main/resources/com/sun/faces/web-facelettaglibrary_4_1.xsd @@ -0,0 +1,751 @@ + + + + + + + + Copyright (c) 2024 Contributors to Eclipse Foundation. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + + + + + + + The XML Schema for the Tag Libraries in the Jakarta Faces + Standard Facelets View Declaration Language (Facelets VDL) + (Version 4.1).

+ +

Jakarta Faces 4.1 Facelet Tag Libraries that wish to conform to + this schema must declare it in the following manner.

+ + <facelet-taglib xmlns="https://jakarta.ee/xml/ns/jakartaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-facelettaglibrary_4_1.xsd" + version="4.1"> + + ... + + </facelet-taglib> + +

The instance documents may indicate the published + version of the schema using xsi:schemaLocation attribute + for jakartaee namespace with the following location:

+ +

https://jakarta.ee/xml/ns/jakartaee/web-facelettaglibrary_4_1.xsd

+ + ]]> +
+
+ + + + + + + + + + + tag-names must be unique within a document. + +

+ ]]> +
+
+ + +
+ + + + + + Behavior IDs must be unique within a document. + +

+ ]]> +
+
+ + +
+ + + + + + Converter IDs must be unique within a document. + +

+ ]]> +
+
+ + +
+ + + + + + Validator IDs must be unique within a document. + +

+ ]]> +
+
+ + +
+
+ + + + + + + + + + The top level XML element in a facelet tag library XML file. + +

+ ]]> +
+
+ + + + + + + + + + + + An advisory short name for usages of tags from this tag library. + +

+ ]]> +
+
+
+ + + + + +
+
+ +
+ + +
+ + + + + + + + + + Extension element for facelet-taglib. It may contain + implementation specific content. + +

+ ]]> +
+
+ + + + +
+ + + + + + + + If the tag library XML + file contains individual tag declarations rather than pointing + to a library-class or a declaring a composite-library name, the + individual tags are enclosed in tag elements.

+ + ]]> +
+
+ + + + + + + + + + + + + + +
+ + + + + + + + + +

The attribute element defines an attribute for the nesting + tag. The attribute element may have several subelements + defining:

+ +
+ +
description

a description of the attribute +

+ +
name

the name of the attribute +

+ +
required

whether the attribute is required or + optional +

+ +
type

the type of the attribute +

+ +
+ +

+ ]]> +
+
+ + + + + + + Defines if the nesting attribute is required or + optional.

+ +

If not present then the default is "false", i.e + the attribute is optional.

+ + ]]> +
+
+
+ + + + + + + Defines the Java type of the attributes + value. If this element is omitted, the + expected type is assumed to be + "java.lang.Object".

+ + ]]> +
+
+
+ + + + + + Defines the method signature for a MethodExpression- + enabled attribute. The syntax of the method-signature + element is as follows (taken from the function-signature + EBNF in web-jsptaglibrary_2_1.xsd):

+ + + +

MethodSignature ::= ReturnType S MethodName S? '(' S? Parameters? S? ')'

+ +

ReturnType ::= Type

+ +

MethodName ::= Identifier

+ +

Parameters ::= Parameter | ( Parameter S? ',' S? Parameters )

+ +

Parameter ::= Type

+ +
+ +

Where:

+ +
    + +
  • Type is a basic type or a fully qualified + Java class name (including package name), as per the 'Type' + production in the Java Language Specification, Second Edition, + Chapter 18.

  • + +
  • Identifier is a Java identifier, as per the + 'Identifier' production in the Java Language Specification, + Second Edition, Chapter 18.

  • + +
+ +

Example:

+ +

java.lang.String nickName( java.lang.String, int )

+ + ]]> +
+
+
+
+
+ +
+ + + + + + + + + + Extension element for tag It may contain + implementation specific content. + +

+ ]]> +
+
+ + + + +
+ + + + + + + + + + If the tag library XML file contains individual function + declarations rather than pointing to a library-class or a + declaring a composite-library name, the individual functions are + enclosed in function elements. + +

+ ]]> +
+
+ + + + + + +
+ + + + + + + + + + Within a tag element, the behavior element encapsulates + information specific to a Faces Behavior. + +

+ ]]> +
+
+ + + + + + +
+ + + + + + + + + + Extension element for behavior. It may contain + implementation specific content. + +

+ ]]> +
+
+ + + + +
+ + + + + + + + Within a tag element, the component + element encapsulates information specific to a Faces UIComponent.

+ +
+ +

As of 3.0 of the specification, this requirement is no longer + present: This element must have exactly one of + <component-type>, <resource-id>, + or <handler-class> among its child elements.

+ +
+ + ]]> +
+
+ + + + + + + + + A valid resource identifier + as specified in the Jakarta Faces Specification Document section 2.6.1.3 "Resource Identifiers". + For example:

+ +

<resource-id>myCC/ccName.xhtml</resource-id>

+ + ]]> +
+
+
+ +
+
+ + + + + + + + + + Extension element for component It may contain + implementation specific content. + +

+ ]]> +
+
+ + + + +
+ + + + + + + + + + Within a tag element, the converter element encapsulates + information specific to a Faces Converter. + +

+ ]]> +
+
+ + + + + + +
+ + + + + + + + + + Extension element for converter It may contain + implementation specific content. + +

+ ]]> +
+
+ + + + +
+ + + + + + + + + + Within a tag element, the validator element encapsulates + information specific to a Faces Validator. + +

+ ]]> +
+
+ + + + + + +
+ + + + + + + + + + Extension element for validator It may contain + implementation specific content. + +

+ ]]> +
+
+ + + + +
+ + + + + + + This type contains the recognized versions of + facelet-taglib supported. + +

+ ]]> +
+
+ + + +
+ + + + + + + + + +

Defines the canonical name of a tag or attribute being + defined.

+ +

The name must conform to the lexical rules for an NCName

+ +

+ ]]> +
+
+ + + + + +
+ +
diff --git a/impl/src/main/resources/com/sun/faces/web-facesconfig_4_1.xsd b/impl/src/main/resources/com/sun/faces/web-facesconfig_4_1.xsd new file mode 100644 index 0000000000..d2e129cf3b --- /dev/null +++ b/impl/src/main/resources/com/sun/faces/web-facesconfig_4_1.xsd @@ -0,0 +1,3447 @@ + + + + + + + + Copyright (c) 2024 Contributors to Eclipse Foundation. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + + + + + + + The XML Schema for the Jakarta Faces Application + Configuration File (Version 4.1).

+ +

All Jakarta Faces configuration files must indicate + the Jakarta Faces schema by indicating the + Jakarta Faces namespace:

+ +

https://jakarta.ee/xml/ns/jakartaee

+ +

and by indicating the version of the schema by + using the version element as shown below:

+ +
<faces-config xmlns="https://jakarta.ee/xml/ns/jakartaee"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xsi:schemaLocation="..."
+      version="4.1">
+      ...
+      </faces-config>
+ +

The instance documents may indicate the published + version of the schema using xsi:schemaLocation attribute + for jakartaee namespace with the following location:

+ +

https://jakarta.ee/xml/ns/jakartaee/web-facesconfig_4_1.xsd

+ + ]]> +
+
+ + + + + + + + The "faces-config" element is the root of the configuration + information hierarchy, and contains nested elements for all + of the other configuration settings.

+ + ]]> +
+
+ + + + Behavior IDs must be unique within a document.

+ + ]]> +
+
+ + +
+ + + + Converter IDs must be unique within a document.

+ + ]]> +
+
+ + +
+ + + + 'converter-for-class' element values must be unique + within a document.

+ + ]]> +
+
+ + +
+ + + + Validator IDs must be unique within a document.

+ + ]]> +
+
+ + +
+
+ + + + + + + + The "faces-config" element is the root of the configuration + information hierarchy, and contains nested elements for all + of the other configuration settings.

+ + ]]> +
+
+ + + + + + + + + + + + The "name" element + within the top level "faces-config" + element declares the name of this application + configuration resource. Such names are used + in the document ordering scheme specified in section + 11.3.8 "Ordering of Artifacts" of the Jakarta Faces Specification Document.

+ +

This value is taken to be the + defining document id of any <flow-definition> elements + defined in this Application Configuration Resource file. If this + element is not specified, the runtime must take the empty string + as its value.

+ + ]]> +
+
+
+ + + + + + + + +
+ + + + + The metadata-complete attribute defines whether this + Faces application is complete, or whether + the class files available to this module and packaged with + this application should be examined for annotations + that specify configuration information. + + This attribute is only inspected on the application + configuration resource file located at "WEB-INF/faces-config.xml". + The presence of this attribute on any application configuration + resource other than the one located at "WEB-INF/faces-config.xml", + including any files named using the jakarta.faces.CONFIG_FILES + attribute, must be ignored. + + If metadata-complete is set to "true", the Faces + runtime must ignore any annotations that specify configuration + information, which might be present in the class files + of the application. + + If metadata-complete is not specified or is set to + "false", the Faces runtime must examine the class + files of the application for annotations, as specified by + the specification. + + If "WEB-INF/faces-config.xml" is not present, the + Faces runtime will assume metadata-complete to be "false". + + The value of this attribute will have no impact on + runtime annotations such as @ResourceDependency or + @ListenerFor. + + + + + + +
+ + + + + + + + Extension element for faces-config. It may contain + implementation specific content.

+ + ]]> +
+
+ + + + +
+ + + + + + + + Please see section + 11.3.8 "Ordering of Artifacts" of the Jakarta Faces Specification Document + for the specification of this element.

+ + ]]> +
+
+ + + + + +
+ + + + + + + + This element contains a sequence of "id" elements, each of which + refers to an application configuration resource by the "id" + declared on its faces-config element. This element can also contain + a single "others" element which specifies that this document comes + before or after other documents within the application.

+ + ]]> +
+
+ + + + + +
+ + + + + + + + This element indicates that the ordering sub-element in which + it was placed should take special action regarding the ordering + of this application resource relative to other + application configuration resources. + See section 11.3.8 "Ordering of Artifacts" of the Jakarta Faces Specification Document + for the complete specification.

+ + ]]> +
+
+ +
+ + + + + + + + Only relevant if this is placed within the /WEB-INF/faces-config.xml. + Please see + section 11.3.8 "Ordering of Artifacts" of the Jakarta Faces Specification Document + for the specification for details.

+ + ]]> +
+
+ + + + + +
+ + + + + + + + The "application" element provides a mechanism to define the + various per-application-singleton implementation artifacts for + a particular web application that is utilizing + Jakarta Faces. For nested elements that are not specified, + the Jakarta Faces implementation must provide a suitable + default.

+ + ]]> +
+
+ + + + + The "action-listener" element contains the fully + qualified class name of the concrete + ActionListener implementation class that will be + called during the Invoke Application phase of the + request processing lifecycle.

+ + ]]> +
+
+
+ + + + The "default-render-kit-id" element allows the + application to define a renderkit to be used other + than the standard one.

+ + ]]> +
+
+
+ + + + The base name of a resource bundle representing + the message resources for this application. See + the JavaDocs for the "java.util.ResourceBundle" + class for more information on the syntax of + resource bundle names.

+ + ]]> +
+
+
+ + + + The "navigation-handler" element contains the + fully qualified class name of the concrete + NavigationHandler implementation class that will + be called during the Invoke Application phase + of the request processing lifecycle, if the + default ActionListener (provided by the Jakarta Faces + implementation) is used.

+ + ]]> +
+
+
+ + + + The "view-handler" element contains the fully + qualified class name of the concrete ViewHandler + implementation class that will be called during + the Restore View and Render Response phases of the + request processing lifecycle. The faces + implementation must provide a default + implementation of this class.

+ + ]]> +
+
+
+ + + + The "state-manager" element contains the fully + qualified class name of the concrete StateManager + implementation class that will be called during + the Restore View and Render Response phases of the + request processing lifecycle. The faces + implementation must provide a default + implementation of this class.

+ + ]]> +
+
+
+ + + + The "el-resolver" element contains the fully + qualified class name of the concrete + jakarta.el.ELResolver implementation class + that will be used during the processing of + EL expressions.

+ + ]]> +
+
+
+ + + + The "resource-handler" element contains the + fully qualified class name of the concrete + ResourceHandler implementation class that + will be used during rendering and decoding + of resource requests The standard + constructor based decorator pattern used for + other application singletons will be + honored.

+ + ]]> +
+
+
+ + + + The "resource-library-contracts" element + specifies the mappings between views in the application and resource + library contracts that, if present in the application, must be made + available for use as templates of the specified views. +

+ + ]]> +
+
+
+ + + + The "search-expression-handler" + element contains the fully qualified class name of the + concrete jakarta.faces.component.search.SearchExpressionHandler + implementation class that will be used for processing of a + search expression.

+ + ]]> +
+
+
+ + + + The "search-keyword-resolver" + element contains the fully qualified class name of the + concrete jakarta.faces.component.search.SearchKeywordResolver + implementation class that will be used during the processing + of a search expression keyword.

+ + ]]> +
+
+
+ + + + + +
+ +
+ + + + + + + + The resource-bundle element inside the application element + references a java.util.ResourceBundle instance by name + using the var element. ResourceBundles referenced in this + manner may be returned by a call to + Application.getResourceBundle() passing the current + FacesContext for this request and the value of the var + element below.

+ + ]]> +
+
+ + + + + + The fully qualified class name of the + java.util.ResourceBundle instance.

+ + ]]> +
+
+
+ + + + The name by which this ResourceBundle instance + is retrieved by a call to + Application.getResourceBundle().

+ + ]]> +
+
+
+
+ +
+ + + + + + + + The "resource-library-contracts" element + specifies the mappings between views in the application and resource + library contracts that, if present in the application, must be made + available for use as templates of the specified views. +

+ + ]]> +
+
+ + + + + + Declare a mapping between a collection + of views in the application and the list of contracts (if present in the application) + that may be used as a source for templates and resources for those views.

+ + ]]> +
+
+
+
+ +
+ + + + + + + + The "contract-mapping" element + specifies the mappings between a collection of views in the application and resource + library contracts that, if present in the application, must be made + available for use as templates of the specified views. +

+ + ]]> +
+
+ + + + + + The "url-pattern" element + specifies the collection of views in this application that + are allowed to use the corresponding contracts. +

+ + ]]> +
+
+
+ + + + The "contracts" element + is a comma separated list of resource library contracts that, + if available to the application, may be used by the views + matched by the corresponding "url-pattern" +

+ + ]]> +
+
+
+
+ +
+ + + + + + + + Extension element for application. It may contain + implementation specific content.

+ + ]]> +
+
+ + + + +
+ + + + + + + + The "factory" element provides a mechanism to define the + various Factories that comprise parts of the implementation + of Jakarta Faces. For nested elements that are not + specified, the Jakarta Faces implementation must provide a + suitable default.

+ + ]]> +
+
+ + + + + The "application-factory" element contains the + fully qualified class name of the concrete + ApplicationFactory implementation class that will + be called when + FactoryFinder.getFactory(APPLICATION_FACTORY) is + called.

+ + ]]> +
+
+
+ + + + The "exception-handler-factory" element contains the + fully qualified class name of the concrete + ExceptionHandlerFactory implementation class that will + be called when + FactoryFinder.getFactory(EXCEPTION_HANDLER_FACTORY) + is called.

+ + ]]> +
+
+
+ + + + The "external-context-factory" element contains the + fully qualified class name of the concrete + ExternalContextFactory implementation class that will + be called when + FactoryFinder.getFactory(EXTERNAL_CONTEXT_FACTORY) + is called.

+ + ]]> +
+
+
+ + + + The "faces-context-factory" element contains the + fully qualified class name of the concrete + FacesContextFactory implementation class that will + be called when + FactoryFinder.getFactory(FACES_CONTEXT_FACTORY) + is called.

+ + ]]> +
+
+
+ + + + The "facelet-cache-factory" element contains the + fully qualified class name of the concrete + FaceletCacheFactory implementation class that will + be called when + FactoryFinder.getFactory(FACELET_CACHE_FACTORY) + is called.

+ + ]]> +
+
+
+ + + + The "partial-view-context-factory" element contains the + fully qualified class name of the concrete + PartialViewContextFactory implementation class that will + be called when FactoryFinder.getFactory + (FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY) is called.

+ + ]]> +
+
+
+ + + + The "lifecycle-factory" element contains the fully + qualified class name of the concrete LifecycleFactory + implementation class that will be called when + FactoryFinder.getFactory(LIFECYCLE_FACTORY) is called.

+ + ]]> +
+
+
+ + + + The "view-declaration-language-factory" element contains + the fully qualified class name of the concrete + ViewDeclarationLanguageFactory + implementation class that will be called when + FactoryFinder.getFactory(VIEW_DECLARATION_FACTORY) is called.

+ + ]]> +
+
+
+ + + + The "tag-handler-delegate-factory" element contains + the fully qualified class name of the concrete + ViewDeclarationLanguageFactory + implementation class that will be called when + FactoryFinder.getFactory(TAG_HANDLER_DELEGATE_FACTORY) is called.

+ + ]]> +
+
+
+ + + + The "render-kit-factory" element contains the fully + qualified class name of the concrete RenderKitFactory + implementation class that will be called when + FactoryFinder.getFactory(RENDER_KIT_FACTORY) is + called.

+ + ]]> +
+
+
+ + + + The "visit-context-factory" element contains the fully + qualified class name of the concrete VisitContextFactory + implementation class that will be called when + FactoryFinder.getFactory(VISIT_CONTEXT_FACTORY) is + called.

+ + ]]> +
+
+
+ + + + The "flash-factory" element contains the + fully qualified class name of the concrete + FaceletFactory implementation class that will + be called when + FactoryFinder.getFactory(FLASH_FACTORY) is + called.

+ + ]]> +
+
+
+ + + + The "flow-handler-factory" element contains the + fully qualified class name of the concrete + FlowHandlerFactory implementation class that will + be called when + FactoryFinder.getFactory(FLOW_HANDLER_FACTORY) is + called.

+ + ]]> +
+
+
+ + + + The "client-window-factory" element contains the fully + qualified class name of the concrete ClientWindowFactory implementation class that + will be called when FactoryFinder.getFactory(CLIENT_WINDOW_FACTORY) is called.

+ + ]]> +
+
+
+ + + + The + "search-expression-context-factory" element contains the + fully qualified class name of the concrete + SearchExpressionContextFactory implementation class that will + be called when + FactoryFinder.getFactory(SEARCH_EXPRESSION_CONTEXT_FACTORY) + is called.

+ + ]]> +
+
+
+ +
+ +
+ + + + + + + + Extension element for factory. It may contain + implementation specific content.

+ + ]]> +
+
+ + + + +
+ + + + + + + + The "attribute" element represents a named, typed, value + associated with the parent UIComponent via the generic + attributes mechanism.

+ +

Attribute names must be unique within the scope of the parent + (or related) component.

+ + ]]> +
+
+ + + + + + The "attribute-name" element represents the name under + which the corresponding value will be stored, in the + generic attributes of the UIComponent we are related + to.

+ + ]]> +
+
+
+ + + + The "attribute-class" element represents the Java type + of the value associated with this attribute name.

+ + ]]> +
+
+
+ + + +
+ +
+ + + + + + + + Extension element for attribute. It may contain + implementation specific content.

+ + ]]> +
+
+ + + + +
+ + + + + + + + The "component" element represents a concrete UIComponent + implementation class that should be registered under the + specified type identifier, along with its associated + properties and attributes. Component types must be unique + within the entire web application.

+ +

Nested "attribute" elements identify generic attributes that + are recognized by the implementation logic of this component. + Nested "property" elements identify JavaBeans properties of + the component class that may be exposed for manipulation + via tools.

+ + ]]> +
+
+ + + + + + The "component-type" element represents the name under + which the corresponding UIComponent class should be + registered.

+ + ]]> +
+
+
+ + + + The "component-class" element represents the fully + qualified class name of a concrete UIComponent + implementation class.

+ + ]]> +
+
+
+ + + + +
+ +
+ + + + + + + + Extension element for component. It may contain + implementation specific content.

+ + ]]> +
+
+ + + + +
+ + + + + + + + The "default-locale" element declares the default locale + for this application instance.

+ +

+ To facilitate BCP 47 this element first needs to be parsed by the + Locale.forLanguageTag method. If it does not return a Locale with + a language the old specification below needs to take effect. +

+ +

It must be specified as :language:[_:country:[_:variant:]] + without the colons, for example "ja_JP_SJIS". The + separators between the segments may be '-' or '_'.

+ + ]]> +
+
+ + + + + +
+ + + + + + + + The "default-value" contains the value for the property or + attribute in which this element resides. This value differs + from the "suggested-value" in that the property or attribute + must take the value, whereas in "suggested-value" taking the + value is optional.

+ + ]]> +
+
+ + + + + +
+ + + + + EL expressions present within a faces config file + must start with the character sequence of '#{' and + end with '}'.

+ + ]]> +
+
+ + + +
+ + + + + + + + Define the name and other design-time information for a facet + that is associated with a renderer or a component.

+ + ]]> +
+
+ + + + + + The "facet-name" element represents the facet name + under which a UIComponent will be added to its parent. + It must be of type "Identifier".

+ + ]]> +
+
+
+ +
+ +
+ + + + + + + + Extension element for facet. It may contain implementation + specific content.

+ + ]]> +
+
+ + + + +
+ + + + + + + + The + value of from-view-id must contain one of the following + values:

+ +
    + +
  • The exact match for a view identifier that is recognized + by the the ViewHandler implementation being used (such as + "/index.jsp" if you are using the default ViewHandler).

  • + +
  • The exact match of a flow node id + in the current flow, or a flow id of another flow.

  • + +
  • A proper prefix of a view identifier, plus a trailing + "*" character. This pattern indicates that all view + identifiers that match the portion of the pattern up to the + asterisk will match the surrounding rule. When more than one + match exists, the match with the longest pattern is selected. +

  • + +
  • An "*" character, which means that this pattern applies + to all view identifiers.

  • + +
+ + ]]> +
+
+ + + + + +
+ + + + + + + + The "from-action" element contains an action reference + expression that must have been executed (by the default + ActionListener for handling application level events) + in order to select the navigation rule. If not specified, + this rule will be relevant no matter which action reference + was executed (or if no action reference was executed).

+ + ]]> +
+
+ + + + + +
+ + + + + + + + The "if" element defines a condition that must resolve + to true in order for the navigation case on which it is + defined to be matched, with the existing match criteria + (action method and outcome) as a prerequiste, if present. + The condition is defined declaratively using a value + expression in the body of this element. The expression is + evaluated at the time the navigation case is being matched. + If the "from-outcome" is omitted and this element is + present, the navigation handler will match a null outcome + and use the condition return value to determine if the + case should be considered a match.

+ +
+ +

When used in a <switch> within a flow, if the + expresion returns true, the + <from-outcome> sibling element's outcome is used as + the id of the node in the flow graph to which control must be + passed.

+ +
+ + ]]> +
+
+ + + + + +
+ + + + + + + +

+ +
+ +
+ + ]]> +
+
+ + + + + +
+ + + + + + + + The "converter" element represents a concrete Converter + implementation class that should be registered under the + specified converter identifier. Converter identifiers must + be unique within the entire web application.

+ +

Nested "attribute" elements identify generic attributes that + may be configured on the corresponding UIComponent in order + to affect the operation of the Converter. Nested "property" + elements identify JavaBeans properties of the Converter + implementation class that may be configured to affect the + operation of the Converter. "attribute" and "property" + elements are intended to allow component developers to + more completely describe their components to tools and users. + These elements have no required runtime semantics.

+ + ]]> +
+
+ + + + + + + The "converter-id" element represents the + identifier under which the corresponding + Converter class should be registered.

+ + ]]> +
+
+
+ + + + The "converter-for-class" element represents the + fully qualified class name for which a Converter + class will be registered.

+ + ]]> +
+
+
+
+ + + + The "converter-class" element represents the fully + qualified class name of a concrete Converter + implementation class.

+ + ]]> +
+
+
+ + + + Nested "attribute" elements identify generic + attributes that may be configured on the + corresponding UIComponent in order to affect the + operation of the Converter. This attribute is + primarily for design-time tools and is not + specified to have any meaning at runtime.

+ + ]]> +
+
+
+ + + + Nested "property" elements identify JavaBeans + properties of the Converter implementation class + that may be configured to affect the operation of + the Converter. This attribute is primarily for + design-time tools and is not specified to have + any meaning at runtime.

+ + ]]> +
+
+
+ +
+ +
+ + + + + + + + Extension element for converter. It may contain + implementation specific content.

+ + ]]> +
+
+ + + + +
+ + + + + + + + The "lifecycle" element provides a mechanism to specify + modifications to the behaviour of the default Lifecycle + implementation for this web application.

+ + ]]> +
+
+ + + + + The "phase-listener" element contains the fully + qualified class name of the concrete PhaseListener + implementation class that will be registered on + the Lifecycle.

+ + ]]> +
+
+
+ +
+ +
+ + + + + + + + Extension element for lifecycle. It may contain + implementation specific content.

+ + ]]> +
+
+ + + + +
+ + + + + The localeType defines valid locale defined by ISO-639-1 + and ISO-3166.

+ + ]]> +
+
+ + + +
+ + + + + + + + The "locale-config" element allows the app developer to + declare the supported locales for this application.

+ + ]]> +
+
+ + + + + +
+ + + + + + + + The "default-validators" element allows the app developer to + register a set of validators, referenced by identifier, that + are automatically assigned to any EditableValueHolder component + in the application, unless overridden or disabled locally.

+ + ]]> +
+
+ + + + + The "validator-id" element represents the identifier + of a registered validator.

+ + ]]> +
+
+
+
+ +
+ + + + + + + + + Top level element for a flow + definition.

+ +
+ +

If there is no <start-node> element declared, it + is assumed to be <flowName>.xhtml.

+ +
+ + ]]> +
+
+ + + + + + Declare the id of the starting node in the + flow graph. The start node may be any of the node types mentioned in + the class javadocs for FlowHandler.

+ + ]]> +
+
+
+ + + + + + + + + +
+ + + + The id of this flow. The id + must be unique within the Application configuration Resource + file in which this flow is defined. The value of this attribute, + combined with the value of the <faces-config><name> element + must globally identify the flow within the application.

+ + ]]> + + + + + + + + + + + + Invoke a method, passing parameters if necessary. + The return from the method is used as the outcome for where to go next in the + flow. If the method is a void method, the default outcome is used.

+ + ]]> + + + + + + + + + A parameter to pass when calling the method + identified in the "method" element that is a sibling of this element.

+ + ]]> + + + + + + + + + + + + + + + + + + + + + + + + A parameter to pass when calling the method + identified in the "method" element that is a sibling of this element.

+ + ]]> + + + + + + + The optional "class" element within a "parameter" element + will be interpreted as the fully qualified class name for the type + of the "value" element.

+ + ]]> +
+
+ + + + + The "value" element within an "parameter" + must be a literal string or an EL Expression whose "get" will be called when the "method" + associated with this element is invoked.

+ + ]]> +
+
+
+ +
+ + + + + + + + Define a view node in a flow graph.

+ +

This element must contain exactly one + <vdl-document> element.

+ + ]]> +
+
+ + + + + + Define the path to the vdl-document for the enclosing view. +

+ + ]]> + + + + + + + + The id of this view. It must be + unique within the flow.

+ + ]]> +
+
+ +
+ + + + + + + + Define a switch node in a flow graph.

+ +
+ +

This element must contain one or more + <case> elements. When control passes to the + <switch> node, each of the cases must be considered + in order and control must past to the <from-outcome> + of the first one whose <if> expression evaluates to + true.

+ +
+ + ]]> +
+
+ + + + + Defines a case that must be + considered in the list of cases in the + <switch>.

+ + ]]> +
+
+
+ + + + Defines the default case that will + be taken if none of the other cases in the + <switch> are taken.

+ + ]]> +
+
+
+
+ + + + The id of this switch. It must be + unique within the flow.

+ + ]]> +
+
+
+
+ + + + + + + + Defines a case that will + be considered in the <switch>.

+ + ]]> +
+
+ + + + + + If this EL expression evaluates to + true, the corresponding from-outcome will + be the outcome taken by the enclosing <switch>

+ + ]]> +
+
+
+ + + + The "from-outcome" element contains a logical outcome + string returned by the execution of an application + action method selected via an "actionRef" property + (or a literal value specified by an "action" property) + of a UICommand component. If specified, this rule + will be relevant only if the outcome value matches + this element's value. If not specified, this rule + will be relevant if the outcome value is non-null + or, if the "if" element is present, will be relevant + for any outcome value, with the assumption that the + condition specified in the "if" element ultimately + determines if this rule is a match.

+ +

If used in a faces flow, this element + represents the node id to which control will be passed.

+ + ]]> +
+
+
+
+ + +
+ + + + + + + + Define a return node in a flow graph.

+ +
+ +

This element must contain exactly one <from-outcome> element.

+
+ + ]]> +
+
+ + + + + This element + represents the node id to which control will be passed.

+ + ]]> +
+
+
+
+ + + + The id of this flow-return.

+ + ]]> +
+
+
+
+ + + + + + + + Define a call node in a flow graph.

+ +
+ +

This element must contain exactly one <flow-reference> element, + which must contain exactly one <flow-id> element.

+
+ + ]]> +
+
+ + + + + The flow id of the called flow.

+ + ]]> + + + + + + + A parameter to pass when calling the flow + identified in the "flow-reference" element that is a sibling of this element.

+ + ]]> + + + + + + + + The id of this flow-return.

+ + ]]> +
+
+ +
+ + + + + + + + Identifiy the called flow.

+ +
+ +
+ + ]]> +
+
+ + + + + The document id of the called flow.

+ + ]]> +
+
+
+ + + + The id of the called flow.

+ + ]]> +
+
+
+
+
+ + + + + + + + A MethodExpression that will be invoked when the flow is entered.

+ + ]]> + + + + + + + + + + + + + + + + A MethodExpression that will be invoked when the flow is exited.

+ + ]]> + + + + + + + + + + + + + + + + A named parameter whose value will be populated + with a correspondingly named parameter within an "outbound-parameter" element.

+ + ]]> + + + + + + + The "name" element within an "inbound-parameter" + element declares the name of this parameter + to be passed into a flow. There must be + a sibling "value" element in the same parent as this element.

+ + ]]> +
+
+ + + + + The "value" element within an "inbound-parameter" + must be an EL Expression whose value will be set with the correspondingly + named "outbound-parameter" when this flow is entered, if such a + parameter exists.

+ + ]]> +
+
+
+ +
+ + + + + + + + A named parameter whose value will be + passed to a correspondingly named parameter within an "inbound-parameter" element + on the target flow.

+ + ]]> + + + + + + + The "name" element within an "outbound-parameter" element + declares the name of this parameter to be passed out of a flow. There must be + a sibling "value" element in the same parent as this element.

+ + ]]> +
+
+ + + + + The "value" element within an "outbound-parameter" + must be a literal string or an EL Expression whose "get" will be called when the "flow-call" + containing this element is traversed to go to a new flow.

+ + ]]> +
+
+
+ +
+ + + + + + + + + The + "navigation-case" element describes a particular + combination of conditions that must match for this case to + be executed, and the view id of the component tree that + should be selected next.

+ + ]]> +
+
+ + + + + + + The "from-outcome" element contains a logical outcome + string returned by the execution of an application + action method selected via an "actionRef" property + (or a literal value specified by an "action" property) + of a UICommand component. If specified, this rule + will be relevant only if the outcome value matches + this element's value. If not specified, this rule + will be relevant if the outcome value is non-null + or, if the "if" element is present, will be relevant + for any outcome value, with the assumption that the + condition specified in the "if" element ultimately + determines if this rule is a match.

+ + ]]> +
+
+
+ + + + Please see section 7.4.2 "Default NavigationHandler Algorithm" of the Jakarta Faces Specification Document + for the specification of this element.

+ + ]]> +
+
+
+ + + + The "to-view-id" element + contains the view identifier (or + flow node id, or flow id) + of the next view (or flow node or + flow) that should be displayed if this + navigation rule is matched. If the contents is a + value expression, it should be resolved by the + navigation handler to obtain the view ( + or flow node or flow) + identifier.

+ + ]]> +
+
+
+ + + + The document id of the called flow. + If this element appears in a <navigation-case> nested within + a <flow-definition>, it must be ignored because navigation + cases within flows may only navigate among the view nodes of that + flow.

+ + ]]> +
+
+
+ +
+ +
+ + + + + + + + The "navigation-rule" element represents an individual + decision rule that will be utilized by the default + NavigationHandler implementation to make decisions on + what view should be displayed next, based on the + view id being processed.

+ + ]]> +
+
+ + + + + + + +
+ + + + + + + + Extension element for navigation-rule. It may contain + implementation specific content.

+ + ]]> +
+
+ + + + +
+ + + + + + + + The "null-value" element indicates that the managed + property in which we are nested will be explicitly + set to null if our managed bean is automatically + created. This is different from omitting the managed + property element entirely, which will cause no + property setter to be called for this property.

+ +

The "null-value" element can only be used when the + associated "property-class" identifies a Java class, + not a Java primitive.

+ + ]]> +
+
+ +
+ + + + + + + + The "property" element represents a JavaBean property of the + Java class represented by our parent element.

+ +

Property names must be unique within the scope of the Java + class that is represented by the parent element, and must + correspond to property names that will be recognized when + performing introspection against that class via + java.beans.Introspector.

+ + ]]> +
+
+ + + + + + The "property-name" element represents the JavaBeans + property name under which the corresponding value + may be stored.

+ + ]]> +
+
+
+ + + + The "property-class" element represents the Java type + of the value associated with this property name. + If not specified, it can be inferred from existing + classes; however, this element should be specified if + the configuration file is going to be the source for + generating the corresponding classes.

+ + ]]> +
+
+
+ + + +
+ +
+ + + + + + + + Any view that matches any of the + url-patterns in this element may only be reached from another Jakarta Faces + view in the same web application. Because the runtime is aware of + which views are protected, any navigation from an unprotected + view to a protected view is automatically subject to + protection.

+ + ]]> +
+
+ + + +
+ + + + + + + + Extension element for property. It may contain + implementation specific content.

+ + ]]> +
+
+ + + + +
+ + + + + + + + The "redirect" element indicates that navigation to the + specified "to-view-id" should be accomplished by + performing an HTTP redirect rather than the usual + ViewHandler mechanisms.

+ + ]]> +
+
+ + + + + +
+ + + + + + + + This element was introduced due to a specification + error, and is now deprecated. The correct name for + this element is "redirect-param" and its meaning is + documented therein. The "view-param" element is + maintained to preserve backwards compatibility. + Implementations must treat this element the same as + "redirect-param".

+ + ]]> +
+
+ + + + + +
+ + + + + + + + The "redirect-param" element, only valid within + a "redirect" element, contains child "name" + and "value" elements that must be included in the + redirect url when the redirect is performed.

+ + ]]> +
+
+ + + + + +
+ + + + + + + + The "referenced-bean" element represents at design time the + promise that a Java object of the specified type will exist at + runtime in some scope, under the specified key. This can be + used by design time tools to construct user interface dialogs + based on the properties of the specified class. The presence + or absence of a referenced bean element has no impact on the + Jakarta Faces runtime environment inside a web application.

+ + ]]> +
+
+ + + + + + The "referenced-bean-name" element represents the + attribute name under which the corresponding + referenced bean may be assumed to be stored, in one + of 'request', 'session', 'view', 'application' + or a custom scope.

+ + ]]> +
+
+
+ + + + The "referenced-bean-class" element represents the + fully qualified class name of the Java class + (either abstract or concrete) or Java interface + implemented by the corresponding referenced bean.

+ + ]]> +
+
+
+
+ +
+ + + + + + + + The "render-kit" element represents a concrete RenderKit + implementation that should be registered under the specified + render-kit-id. If no render-kit-id is specified, the + identifier of the default RenderKit + (RenderKitFactory.DEFAULT_RENDER_KIT) is assumed.

+ + ]]> +
+
+ + + + + + The "render-kit-id" element represents an identifier + for the RenderKit represented by the parent + "render-kit" element.

+ + ]]> +
+
+
+ + + + The "render-kit-class" element represents the fully + qualified class name of a concrete RenderKit + implementation class.

+ + ]]> +
+
+
+ + + +
+ +
+ + + + + + + + The "client-behavior-renderer" element represents a concrete + ClientBehaviorRenderer implementation class that should be + registered under the specified behavior renderer type identifier, + in the RenderKit associated with the parent "render-kit" + element. Client Behavior renderer type must be unique within the RenderKit + associated with the parent "render-kit" element.

+ +

Nested "attribute" elements identify generic component + attributes that are recognized by this renderer.

+ + ]]> +
+
+ + + + + The "client-behavior-renderer-type" element represents a renderer type + identifier for the Client Behavior Renderer represented by the parent + "client-behavior-renderer" element.

+ + ]]> +
+
+
+ + + + The "client-behavior-renderer-class" element represents the fully + qualified class name of a concrete Client Behavior Renderer + implementation class.

+ + ]]> +
+
+
+
+ +
+ + + + + + + + The "renderer" element represents a concrete Renderer + implementation class that should be registered under the + specified component family and renderer type identifiers, + in the RenderKit associated with the parent "render-kit" + element. Combinations of component family and + renderer type must be unique within the RenderKit + associated with the parent "render-kit" element.

+ +

Nested "attribute" elements identify generic component + attributes that are recognized by this renderer.

+ + ]]> +
+
+ + + + + + The "component-family" element represents the + component family for which the Renderer represented + by the parent "renderer" element will be used.

+ + ]]> +
+
+
+ + + + The "renderer-type" element represents a renderer type + identifier for the Renderer represented by the parent + "renderer" element.

+ + ]]> +
+
+
+ + + + The "renderer-class" element represents the fully + qualified class name of a concrete Renderer + implementation class.

+ + ]]> +
+
+
+ + + +
+ +
+ + + + + + + + Extension element for renderer. It may contain implementation + specific content.

+ + ]]> +
+
+ + + + +
+ + + + + + + + Extension element for render-kit. It may contain + implementation specific content.

+ + ]]> +
+
+ + + + +
+ + + + + + + + The "suggested-value" contains the value for the property or + attribute in which this element resides. This value is + advisory only and is intended for tools to use when + populating pallettes.

+ + ]]> +
+
+ + + +
+ + + + + + + + The "supported-locale" element allows authors to declare + which locales are supported in this application instance.

+ +

+ To facilitate BCP 47 this element first needs to be parsed by the + Locale.forLanguageTag method. If it does not return a Locale with + a language the old specification below needs to take effect. +

+ +

It must be specified as :language:[_:country:[_:variant:]] + without the colons, for example "ja_JP_SJIS". The + separators between the segments may be '-' or '_'.

+ + ]]> +
+
+ + + + + +
+ + + + + + + + The "behavior" element represents a concrete Behavior + implementation class that should be registered under the + specified behavior identifier. Behavior identifiers must + be unique within the entire web application.

+ +

Nested "attribute" elements identify generic attributes that + may be configured on the corresponding UIComponent in order + to affect the operation of the Behavior. Nested "property" + elements identify JavaBeans properties of the Behavior + implementation class that may be configured to affect the + operation of the Behavior. "attribute" and "property" + elements are intended to allow component developers to + more completely describe their components to tools and users. + These elements have no required runtime semantics.

+ + ]]> +
+
+ + + + + + The "behavior-id" element represents the identifier + under which the corresponding Behavior class should + be registered.

+ + ]]> +
+
+
+ + + + The "behavior-class" element represents the fully + qualified class name of a concrete Behavior + implementation class.

+ + ]]> +
+
+
+ + + + Nested "attribute" elements identify generic + attributes that may be configured on the + corresponding UIComponent in order to affect the + operation of the Behavior. This attribute is + primarily for design-time tools and is not + specified to have any meaning at runtime.

+ + ]]> +
+
+
+ + + + Nested "property" elements identify JavaBeans + properties of the Behavior implementation class + that may be configured to affect the operation of + the Behavior. This attribute is primarily for + design-time tools and is not specified to have + any meaning at runtime.

+ + ]]> +
+
+
+ +
+ +
+ + + + + + + + Extension element for behavior. It may contain + implementation specific content.

+ + ]]> +
+
+ + + + +
+ + + + + + + + The "validator" element represents a concrete Validator + implementation class that should be registered under the + specified validator identifier. Validator identifiers must + be unique within the entire web application.

+ +

Nested "attribute" elements identify generic attributes that + may be configured on the corresponding UIComponent in order + to affect the operation of the Validator. Nested "property" + elements identify JavaBeans properties of the Validator + implementation class that may be configured to affect the + operation of the Validator. "attribute" and "property" + elements are intended to allow component developers to + more completely describe their components to tools and users. + These elements have no required runtime semantics.

+ + ]]> +
+
+ + + + + + The "validator-id" element represents the identifier + under which the corresponding Validator class should + be registered.

+ + ]]> +
+
+
+ + + + The "validator-class" element represents the fully + qualified class name of a concrete Validator + implementation class.

+ + ]]> +
+
+
+ + + + Nested "attribute" elements identify generic + attributes that may be configured on the + corresponding UIComponent in order to affect the + operation of the Validator. This attribute is + primarily for design-time tools and is not + specified to have any meaning at runtime.

+ + ]]> +
+
+
+ + + + Nested "property" elements identify JavaBeans + properties of the Validator implementation class + that may be configured to affect the operation of + the Validator. This attribute is primarily for + design-time tools and is not specified to have + any meaning at runtime.

+ + ]]> +
+
+
+ +
+ +
+ + + + + + + + Extension element for validator. It may contain + implementation specific content.

+ + ]]> +
+
+ + + + +
+ + + + + The "value" element is the String representation of + a literal value to which a scalar managed property + will be set, or a value binding expression ("#{...}") + that will be used to calculate the required value. + It will be converted as specified for the actual + property type.

+ + ]]> +
+
+ +
+ + + + + + + + The presence of this element within the "application" element in + an application configuration resource file indicates the + developer wants to add an SystemEventListener to this + application instance. Elements nested within this element allow + selecting the kinds of events that will be delivered to the + listener instance, and allow selecting the kinds of classes that + can be the source of events that are delivered to the listener + instance.

+ + ]]> +
+
+ + + + + The "system-event-listener-class" element contains + the fully qualified class name of the concrete + SystemEventListener implementation class that will be + called when events of the type specified by the + "system-event-class" are sent by the runtime.

+ + ]]> +
+
+
+ + + + The "system-event-class" element contains the fully + qualified class name of the SystemEvent subclass for + which events will be delivered to the class whose fully + qualified class name is given by the + "system-event-listener-class" element.

+ + ]]> +
+
+
+ + + + The "source-class" element, if present, contains the + fully qualified class name of the class that will be the + source for the event to be delivered to the class whose + fully qualified class name is given by the + "system-event-listener-class" element.

+ + ]]> +
+
+
+
+ +
+ + + + + This type contains the recognized versions of + faces-config supported.

+ + ]]> +
+
+ + + +
+ +
diff --git a/impl/src/main/resources/com/sun/faces/web-partialresponse_4_1.xsd b/impl/src/main/resources/com/sun/faces/web-partialresponse_4_1.xsd new file mode 100644 index 0000000000..35064f1383 --- /dev/null +++ b/impl/src/main/resources/com/sun/faces/web-partialresponse_4_1.xsd @@ -0,0 +1,403 @@ + + + + + + + + Copyright (c) 2024 Contributors to Eclipse Foundation. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + + + + + + + + + The XML Schema for the Jakarta Faces (Version 4.1) + Partial Response used in Jakarta Faces Ajax frameworks. + +

+ + ]]> +
+
+ + + + + + + + + + The "partial-response" element is the root of the + partial response information hierarchy, and contains + nested elements for all possible elements that can exist + in the response.

+ +

This element must have an "id" attribute whose value + is the return from calling getContainerClientId() on the + UIViewRoot to which this response pertains. + +

+ + ]]> +
+
+
+ + + + + + + + + + The "partial-response" element is the root of the + partial response information hierarchy, and contains + nested elements for all possible elements that can exist + in the response. + +

+ +

+ + ]]> +
+
+ + + + + + + + + This element must have an "id" attribute whose value + is the return from calling getContainerClientId() on the + UIViewRoot to which this response pertains.

+ + ]]> + + + + + + + + + + + + + + The "changes" element contains a collection of child elements, + each of which describes a different change to be applied to the + view in the user agent. + +

+ + ]]> +
+
+ + + + + + + + + + + The "eval" element enables this element's + contents to be executed as JavaScript. + +

+ + ]]> +
+
+
+ +
+
+ + + + + + + + + + The "update" element enables DOM elements matching the "id" + attribute to be updated with the contents of this element. + +

+ + ]]> +
+
+ + + + +
+ + + + + + + + + + The "insert" element enables content to be inserted into the DOM + before or after an existing DOM element as specified by the + nested "before" or "after" elements. The elements "before" and + "after" are mutually exclusive - one of them must be specified. + +

+ + ]]> +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + The "delete" element enables DOM elements matching the "id" + attribute to be removed. + +

+ + ]]> +
+
+ +
+ + + + + + + + + + The "attributes" element enables attributes of DOM elements matching the "id" + attribute to be updated. If this element is used, then it must contain at + least one "attribute" element. + +

+ + ]]> +
+
+ + + + + + + + + + + + +
+ + + + + + + + + + The "redirect" element enables a redirect to the location as specified by the + "url" attribute. + +

+ + ]]> +
+
+ +
+ + + + + + + + + + The "error" element contains error information from the server. + +

+ + ]]> +
+
+ + + + +
+ + + + + + + + + Extension element for partial response. It may contain + implementation specific content. +

+ + ]]> +
+
+ + + + +
+ +
From 6eaaec4e4ee69a1374c31f5b64c6dbf499a51035 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sun, 3 Mar 2024 14:07:44 -0400 Subject: [PATCH 7/9] discovered while writing TCK: the UUIDConverter wasn't properly registered on converterId; while at it took opportunity to refactor hardcoded converter IDs --- .../applicationimpl/InstanceFactory.java | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java b/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java index 2c6e702683..e328c494ad 100644 --- a/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java +++ b/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java @@ -53,20 +53,11 @@ import java.util.Map; import java.util.Set; import java.util.TimeZone; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; -import com.sun.faces.application.ApplicationAssociate; -import com.sun.faces.application.ConverterPropertyEditorFactory; -import com.sun.faces.application.ViewMemberInstanceFactoryMetadataMap; -import com.sun.faces.cdi.CdiUtils; -import com.sun.faces.config.WebConfiguration; -import com.sun.faces.util.FacesLogger; -import com.sun.faces.util.MessageUtils; -import com.sun.faces.util.ReflectionUtils; -import com.sun.faces.util.Util; - import jakarta.el.ExpressionFactory; import jakarta.el.ValueExpression; import jakarta.enterprise.inject.spi.BeanManager; @@ -76,13 +67,32 @@ import jakarta.faces.component.UIComponent; import jakarta.faces.component.behavior.Behavior; import jakarta.faces.context.FacesContext; +import jakarta.faces.convert.BooleanConverter; +import jakarta.faces.convert.ByteConverter; +import jakarta.faces.convert.CharacterConverter; import jakarta.faces.convert.Converter; import jakarta.faces.convert.DateTimeConverter; +import jakarta.faces.convert.DoubleConverter; +import jakarta.faces.convert.FloatConverter; +import jakarta.faces.convert.IntegerConverter; +import jakarta.faces.convert.LongConverter; +import jakarta.faces.convert.ShortConverter; +import jakarta.faces.convert.UUIDConverter; import jakarta.faces.render.RenderKit; import jakarta.faces.render.Renderer; import jakarta.faces.validator.Validator; import jakarta.faces.view.ViewDeclarationLanguage; +import com.sun.faces.application.ApplicationAssociate; +import com.sun.faces.application.ConverterPropertyEditorFactory; +import com.sun.faces.application.ViewMemberInstanceFactoryMetadataMap; +import com.sun.faces.cdi.CdiUtils; +import com.sun.faces.config.WebConfiguration; +import com.sun.faces.util.FacesLogger; +import com.sun.faces.util.MessageUtils; +import com.sun.faces.util.ReflectionUtils; +import com.sun.faces.util.Util; + public class InstanceFactory { // Log instance for this class @@ -97,14 +107,15 @@ public class InstanceFactory { private static final Map, String> STANDARD_TYPE_TO_CONV_ID_MAP = new HashMap<>(16, 1.0f); static { - STANDARD_CONV_ID_TO_TYPE_MAP.put("jakarta.faces.Byte", new Class[] { Byte.TYPE, Byte.class }); - STANDARD_CONV_ID_TO_TYPE_MAP.put("jakarta.faces.Boolean", new Class[] { Boolean.TYPE, Boolean.class }); - STANDARD_CONV_ID_TO_TYPE_MAP.put("jakarta.faces.Character", new Class[] { Character.TYPE, Character.class }); - STANDARD_CONV_ID_TO_TYPE_MAP.put("jakarta.faces.Short", new Class[] { Short.TYPE, Short.class }); - STANDARD_CONV_ID_TO_TYPE_MAP.put("jakarta.faces.Integer", new Class[] { Integer.TYPE, Integer.class }); - STANDARD_CONV_ID_TO_TYPE_MAP.put("jakarta.faces.Long", new Class[] { Long.TYPE, Long.class }); - STANDARD_CONV_ID_TO_TYPE_MAP.put("jakarta.faces.Float", new Class[] { Float.TYPE, Float.class }); - STANDARD_CONV_ID_TO_TYPE_MAP.put("jakarta.faces.Double", new Class[] { Double.TYPE, Double.class }); + STANDARD_CONV_ID_TO_TYPE_MAP.put(ByteConverter.CONVERTER_ID, new Class[] { Byte.TYPE, Byte.class }); + STANDARD_CONV_ID_TO_TYPE_MAP.put(BooleanConverter.CONVERTER_ID, new Class[] { Boolean.TYPE, Boolean.class }); + STANDARD_CONV_ID_TO_TYPE_MAP.put(CharacterConverter.CONVERTER_ID, new Class[] { Character.TYPE, Character.class }); + STANDARD_CONV_ID_TO_TYPE_MAP.put(ShortConverter.CONVERTER_ID, new Class[] { Short.TYPE, Short.class }); + STANDARD_CONV_ID_TO_TYPE_MAP.put(IntegerConverter.CONVERTER_ID, new Class[] { Integer.TYPE, Integer.class }); + STANDARD_CONV_ID_TO_TYPE_MAP.put(LongConverter.CONVERTER_ID, new Class[] { Long.TYPE, Long.class }); + STANDARD_CONV_ID_TO_TYPE_MAP.put(FloatConverter.CONVERTER_ID, new Class[] { Float.TYPE, Float.class }); + STANDARD_CONV_ID_TO_TYPE_MAP.put(DoubleConverter.CONVERTER_ID, new Class[] { Double.TYPE, Double.class }); + STANDARD_CONV_ID_TO_TYPE_MAP.put(UUIDConverter.CONVERTER_ID, new Class[] { UUID.class }); for (Map.Entry[]> entry : STANDARD_CONV_ID_TO_TYPE_MAP.entrySet()) { Class[] types = entry.getValue(); String key = entry.getKey(); From 11d05f523b1e1a8d9f00256e21ab13970320bed4 Mon Sep 17 00:00:00 2001 From: Arjan Tijms Date: Tue, 5 Mar 2024 15:42:45 +0100 Subject: [PATCH 8/9] Update dependencies Specifically, update to those of the Jakarta 11 wave 1-4 release Signed-off-by: Arjan Tijms --- action/pom.xml | 6 +++--- cdi/pom.xml | 4 ++-- impl/pom.xml | 18 +++++++++--------- .../faces/util/ELAwareBeanManagerWrapper.java | 12 +++++++++++- .../com/sun/faces/mock/MockBeanManager.java | 10 ++++++++++ pom.xml | 4 ++-- rest/pom.xml | 6 +++--- 7 files changed, 40 insertions(+), 20 deletions(-) diff --git a/action/pom.xml b/action/pom.xml index 3db281341c..5acbfe2bb6 100644 --- a/action/pom.xml +++ b/action/pom.xml @@ -1,7 +1,7 @@ maven-compiler-plugin - 3.11.0 + 3.12.1 17 -Xlint:unchecked diff --git a/rest/pom.xml b/rest/pom.xml index ce36007ff7..e4d1f4b49f 100644 --- a/rest/pom.xml +++ b/rest/pom.xml @@ -1,7 +1,7 @@