Skip to content

Commit

Permalink
improvements after self-review
Browse files Browse the repository at this point in the history
  • Loading branch information
BalusC committed Mar 3, 2024
1 parent 3aeed5d commit fd82528
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 10 deletions.
Expand Up @@ -42,7 +42,6 @@
<servlet-mapping>
<servlet-name>facesServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
<url-pattern>*.xhtmlAsHtml5</url-pattern>
<url-pattern>*.xhtmlAsXhtml</url-pattern>
<url-pattern>*.xhtmlAsXml</url-pattern>
</servlet-mapping>
Expand Down
Expand Up @@ -18,14 +18,14 @@
-->
<html xmlns:h="jakarta.faces.html">
<h:head>
<title>Spec1819: explicit conversion</title>
<title>Spec1819: explicit conversion via attribute</title>
</h:head>
<h:body>
<h:form id="form">
<h:inputText id="input" value="#{spec1819.uuid}" converterId="jakarta.faces.UUID" />
<h:inputText id="input" value="#{spec1819.uuid}" converter="jakarta.faces.UUID" />
<h:commandButton id="submit" value="submit" />
<h:messages id="messages" />
<h:outputText id="output" value="#{spec1819.uuid}" converterId="jakarta.faces.UUID" />
<h:outputText id="output" value="#{spec1819.uuid}" converter="jakarta.faces.UUID" />
</h:form>
</h:body>
</html>
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<!--
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
-->
<html xmlns:h="jakarta.faces.html" xmlns:f="jakarta.faces.core">
<h:head>
<title>Spec1819: explicit conversion via tag</title>
</h:head>
<h:body>
<h:form id="form">
<h:inputText id="input" value="#{spec1819.uuid}">
<f:converter converterId="jakarta.faces.UUID" />
</h:inputText>
<h:commandButton id="submit" value="submit" />
<h:messages id="messages" />
<h:outputText id="output" value="#{spec1819.uuid}">
<f:converter converterId="jakarta.faces.UUID" />
</h:outputText>
</h:form>
</h:body>
</html>
Expand Up @@ -86,8 +86,8 @@ public void testEmptyImplicitUUID() {
* @see https://github.com/jakartaee/faces/issues/1819
*/
@Test
public void testValidExplicitUUID() {
WebPage page = getPage("spec1819explicitConversion.xhtml");
public void testValidExplicitUUIDviaAttribute() {
WebPage page = getPage("spec1819explicitConversionViaAttribute.xhtml");
WebElement input = page.findElement(By.id("form:input"));
input.sendKeys(TEST_UUID);
WebElement submit = page.findElement(By.id("form:submit"));
Expand All @@ -103,8 +103,8 @@ public void testValidExplicitUUID() {
* @see https://github.com/jakartaee/faces/issues/1819
*/
@Test
public void testInvalidExplicitUUID() {
WebPage page = getPage("spec1819explicitConversion.xhtml");
public void testInvalidExplicitUUIDviaAttribute() {
WebPage page = getPage("spec1819explicitConversionViaAttribute.xhtml");
WebElement input = page.findElement(By.id("form:input"));
input.sendKeys("fubar");
WebElement submit = page.findElement(By.id("form:submit"));
Expand All @@ -120,8 +120,59 @@ public void testInvalidExplicitUUID() {
* @see https://github.com/jakartaee/faces/issues/1819
*/
@Test
public void testEmptyExplicitUUID() {
WebPage page = getPage("spec1819explicitConversion.xhtml");
public void testEmptyExplicitUUIDviaAttribute() {
WebPage page = getPage("spec1819explicitConversionViaAttribute.xhtml");
WebElement input = page.findElement(By.id("form:input"));
input.sendKeys("");
WebElement submit = page.findElement(By.id("form:submit"));
submit.click();
WebElement messages = page.findElement(By.id("form:messages"));
assertEquals("", messages.getText());
WebElement output = page.findElement(By.id("form:output"));
assertEquals("", output.getText());
}

/**
* @see UUIDConverter
* @see https://github.com/jakartaee/faces/issues/1819
*/
@Test
public void testValidExplicitUUIDviaTag() {
WebPage page = getPage("spec1819explicitConversionViaTag.xhtml");
WebElement input = page.findElement(By.id("form:input"));
input.sendKeys(TEST_UUID);
WebElement submit = page.findElement(By.id("form:submit"));
submit.click();
WebElement messages = page.findElement(By.id("form:messages"));
assertEquals("", messages.getText());
WebElement output = page.findElement(By.id("form:output"));
assertEquals(TEST_UUID, output.getText());
}

/**
* @see UUIDConverter
* @see https://github.com/jakartaee/faces/issues/1819
*/
@Test
public void testInvalidExplicitUUIDviaTag() {
WebPage page = getPage("spec1819explicitConversionViaTag.xhtml");
WebElement input = page.findElement(By.id("form:input"));
input.sendKeys("fubar");
WebElement submit = page.findElement(By.id("form:submit"));
submit.click();
WebElement messages = page.findElement(By.id("form:messages"));
assertEquals("form:input: 'fubar' must be a UUID.", messages.getText());
WebElement output = page.findElement(By.id("form:output"));
assertEquals("", output.getText());
}

/**
* @see UUIDConverter
* @see https://github.com/jakartaee/faces/issues/1819
*/
@Test
public void testEmptyExplicitUUIDviaTag() {
WebPage page = getPage("spec1819explicitConversionViaTag.xhtml");
WebElement input = page.findElement(By.id("form:input"));
input.sendKeys("");
WebElement submit = page.findElement(By.id("form:submit"));
Expand Down

0 comments on commit fd82528

Please sign in to comment.