Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/4.0' into 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
BalusC committed Sep 7, 2024
2 parents 1247819 + 8810b7f commit 63ee9d2
Show file tree
Hide file tree
Showing 23 changed files with 1,327 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,29 +171,17 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
*/
private static boolean wasClicked(FacesContext context, UIComponent component, String clientId) {

// Was our command the one that caused this submission?
// we don' have to worry about getting the value from request parameter
// because we just need to know if this command caused the submission. We
// can get the command name by calling currentValue. This way we can
// get around the IE bug.

if (clientId == null) {
clientId = component.getClientId(context);
}

if (context.getPartialViewContext().isAjaxRequest()) {
return BEHAVIOR_SOURCE_PARAM.getValue(context).equals(clientId);
return RenderKitUtils.isPartialOrBehaviorAction(context, clientId);
} else {
Map<String, String> requestParameterMap = context.getExternalContext().getRequestParameterMap();

if (requestParameterMap.get(clientId) == null) {

// Check to see whether we've got an action event
// as a result of a partial/behavior postback.
if (RenderKitUtils.isPartialOrBehaviorAction(context, clientId)) {
return true;
}

// Check to see whether we've got an action event from button of type="image"
StringBuilder builder = new StringBuilder(clientId);
String xValue = builder.append(".x").toString();
builder.setLength(clientId.length());
Expand Down
4 changes: 4 additions & 0 deletions impl/src/main/java/com/sun/faces/util/HtmlUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ private static int writeTextChar(Writer out, boolean escapeUnicode, boolean esca
// UNICODE entities: encode as needed
nextIndex = _writeDecRef(out, buff, buffIndex, buffLength, ch);
} else {
if (forXml && !isAllowedXmlCharacter(ch)) {
return buffIndex;
}

nextIndex = addToBuffer(out, buff, buffIndex, buffLength, ch);
}
}
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<module>impl</module>
<module>action</module>
<module>rest</module>
<module>test</module>
</modules>

<properties>
Expand Down
60 changes: 60 additions & 0 deletions test/base/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 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
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.eclipse.mojarra.test</groupId>
<artifactId>pom</artifactId>
<version>4.0.9-SNAPSHOT</version>
</parent>

<artifactId>base</artifactId>
<packaging>jar</packaging>

<name>Mojarra ${project.version} - INTEGRATION TESTS - ${project.artifactId}</name>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.3</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-container</artifactId>
<version>1.9.1.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.23.0</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.9.2</version>
</dependency>
</dependencies>
</project>
110 changes: 110 additions & 0 deletions test/base/src/main/java/org/eclipse/mojarra/test/base/BaseIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* Copyright (c) Contributors to the 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
* https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-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: GPL-2.0 with Classpath-exception-2.0 which
* is available at https://openjdk.java.net/legal/gplv2+ce.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 or Apache-2.0
*/
package org.eclipse.mojarra.test.base;

import static java.lang.System.getProperty;
import static java.time.Duration.ofSeconds;
import static org.jboss.shrinkwrap.api.ShrinkWrap.create;

import java.io.File;
import java.net.URL;
import java.util.UUID;
import java.util.function.BooleanSupplier;
import java.util.logging.Level;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit5.ArquillianExtension;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.importer.ZipImporter;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.junit.jupiter.api.extension.ExtendWith;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.WebDriverWait;

import io.github.bonigarcia.wdm.WebDriverManager;

@ExtendWith(ArquillianExtension.class)
@TestInstance(Lifecycle.PER_CLASS)
public abstract class BaseIT {

private WebDriver browser;

@ArquillianResource
private URL baseURL;

@Deployment(testable = false)
public static WebArchive createDeployment() {
String warFileName = getProperty("war.file.name") + ".war";
return create(ZipImporter.class, warFileName)
.importFrom(new File("target/" + warFileName))
.as(WebArchive.class);
}

@BeforeAll
public void setup() {
String arquillianBrowser = System.getProperty("arquillian.browser");

switch (arquillianBrowser) {
case "chrome":
WebDriverManager.chromedriver().setup();
ChromeDriver chrome = new ChromeDriver(new ChromeOptions().addArguments("--no-sandbox", "--headless"));
chrome.setLogLevel(Level.INFO);
browser = chrome;
break;
default:
throw new UnsupportedOperationException("arquillian.browser='" + arquillianBrowser + "' is not yet supported");
}

PageFactory.initElements(browser, this);
}

@AfterAll
public void teardown() {
browser.quit();
}

protected void open(String resource) {
browser.get(baseURL + resource);
}

protected String getPageSource() {
return browser.getPageSource();
}

protected void guardAjax(Runnable action) {
String uuid = UUID.randomUUID().toString();
executeScript("window.$ajax = true; faces.ajax.addOnEvent(data => { if (data.status == 'complete') window.$ajax = '" + uuid + "'; })");
action.run();
waitUntil(() -> executeScript("return window.$ajax == '" + uuid + "' || (!window.$ajax && document.readyState == 'complete');"));
}

@SuppressWarnings("unchecked")
private <T> T executeScript(String script) {
return (T) ((JavascriptExecutor) browser).executeScript(script);
}

private void waitUntil(BooleanSupplier predicate) {
new WebDriverWait(browser, ofSeconds(5)).until($ -> predicate.getAsBoolean());
}
}
41 changes: 41 additions & 0 deletions test/issue5460/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 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
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.eclipse.mojarra.test</groupId>
<artifactId>pom</artifactId>
<version>4.0.9-SNAPSHOT</version>
</parent>

<artifactId>issue5460</artifactId>
<packaging>war</packaging>

<name>Mojarra ${project.version} - INTEGRATION TESTS - ${project.artifactId}</name>

<dependencies>
<dependency>
<groupId>org.eclipse.mojarra.test</groupId>
<artifactId>base</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (c) Contributors to the 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
* https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-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: GPL-2.0 with Classpath-exception-2.0 which
* is available at https://openjdk.java.net/legal/gplv2+ce.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 or Apache-2.0
*/
package org.eclipse.mojarra.test.issue5460;

import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Named;

@Named
@RequestScoped
public class Issue5460Bean {

private String cc1;
private String cc2;
private String cc3;
private String cc4;
private String cc5;
private String cc6;

public String getCc1() {
return cc1;
}

public void setCc1(String cc1) {
this.cc1 = cc1;
}

public String getCc2() {
return cc2;
}

public void setCc2(String cc2) {
this.cc2 = cc2;
}

public String getCc3() {
return cc3;
}

public void setCc3(String cc3) {
this.cc3 = cc3;
}

public String getCc4() {
return cc4;
}

public void setCc4(String cc4) {
this.cc4 = cc4;
}

public String getCc5() {
return cc5;
}

public void setCc5(String cc5) {
this.cc5 = cc5;
}

public String getCc6() {
return cc6;
}

public void setCc6(String cc6) {
this.cc6 = cc6;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) Contributors to the 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
* https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-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: GPL-2.0 with Classpath-exception-2.0 which
* is available at https://openjdk.java.net/legal/gplv2+ce.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 or Apache-2.0
*/
package org.eclipse.mojarra.test.issue5460;

import jakarta.faces.component.FacesComponent;
import jakarta.faces.component.NamingContainer;
import jakarta.faces.component.UIInput;
import jakarta.faces.component.UINamingContainer;
import jakarta.faces.context.FacesContext;

@FacesComponent("issue5460Component")
public class Issue5460Component extends UIInput implements NamingContainer {

@Override
public String getFamily() {
return UINamingContainer.COMPONENT_FAMILY;
}

@Override
public void decode(FacesContext context) {
Object value = getValue();
setSubmittedValue(value == null ? "" : value);
super.decode(context);
}

public String getAttributeResults() {
return getAttributes().get("required") + " " + getAttributes().get("styleClass");
}
}
Loading

0 comments on commit 63ee9d2

Please sign in to comment.