Skip to content

Commit

Permalink
Merge pull request #1626 from jakartaee/add_base_class_for_integratio…
Browse files Browse the repository at this point in the history
…n_tests

Consolidate changes into master
  • Loading branch information
BalusC committed Feb 27, 2022
2 parents 3289518 + dab84f6 commit ad70a0f
Show file tree
Hide file tree
Showing 14 changed files with 283 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import ee.jakarta.tck.faces.test.util.htmlunit.IgnoringIncorrectnessListener;

import ee.jakarta.tck.faces.test.util.htmlunit.IgnoringIncorrectnessListener;
import jakarta.faces.component.UIViewRoot;

@RunWith(Arquillian.class)
Expand Down Expand Up @@ -84,7 +83,6 @@ public void testSpec1423Basic() throws Exception {
}

@Test
@Ignore // Fails due to FacesInitializer#onStartup(classes) being empty in current GlassFish version -- TODO: remove once GlassFish is fixed
public void testSpec1423() throws Exception {
HtmlPage page = webClient.getPage(webUrl + "spec1423.xhtml");
HtmlSubmitInput button;
Expand All @@ -102,8 +100,6 @@ public void testSpec1423() throws Exception {
page = button.click();
webClient.waitForBackgroundJavaScript(60000);

System.out.println(page.asXml());

assertTrue(page.getHtmlElementById("scriptResult").asNormalizedText().equals("addedViaInclude"));
assertTrue(page.getHtmlElementById("stylesheetResult").asNormalizedText().equals("rgb(255, 0, 0)"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
// Activates CDI build-in beans that provide the injection this project tests for.
// Note that this project has explicitly no FacesServlet mapping in web.xml as well as no faces-config.xml file.
// In other words, this test also assures that FacesInitializer is able to rely on solely this @FacesConfig annotated bean.

// TODO: a faces-config.xml file has been added because of FacesInitializer#onStartup(classes) being empty in current GlassFish version -- that file should be removed once GlassFish is fixed
)
public class ConfigurationBean {

Expand Down
38 changes: 38 additions & 0 deletions tck/faces23/flash/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 1997, 2018 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
-->


<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.glassfish.mojarra.faces23</groupId>
<artifactId>pom</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>

<artifactId>flash</artifactId>
<packaging>war</packaging>

<name>Mojarra ${project.version} - Test - Faces 2.3 - Flash</name>

<build>
<finalName>test-faces23-flash</finalName>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2017, 2018 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
*/

package ee.jakarta.tck.faces.test.javaee8.flash;

import jakarta.enterprise.inject.Model;
import jakarta.faces.context.FacesContext;
import jakarta.faces.context.Flash;

@Model
public class Issue4167 {

public String keepAndRedirect() {
FacesContext.getCurrentInstance().getExternalContext().getFlash().put("message", "issue4167");
return "issue4167?faces-redirect=true";
}

public String keepAndGet() {
Flash flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
flash.keep("message");
return (String) flash.get("message");
}

}
Empty file.
41 changes: 41 additions & 0 deletions tck/faces23/flash/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 1997, 2018 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
-->

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee web-app_3_1.xsd"
version="3.1"
>
<context-param>
<param-name>jakarta.faces.PROJECT_STAGE</param-name>
<param-value>${webapp.projectStage}</param-value>
</context-param>
<context-param>
<param-name>jakarta.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>${webapp.partialStateSaving}</param-value>
</context-param>
<context-param>
<param-name>jakarta.faces.STATE_SAVING_METHOD</param-name>
<param-value>${webapp.stateSavingMethod}</param-value>
</context-param>
<context-param>
<param-name>jakarta.faces.SERIALIZE_SERVER_STATE</param-name>
<param-value>${webapp.serializeServerState}</param-value>
</context-param>
</web-app>
38 changes: 38 additions & 0 deletions tck/faces23/flash/src/main/webapp/issue4167.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<!--
Copyright (c) 1997, 2018 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
-->

<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html">



<h:head>
<title>Issue4167IT - Flash#keep() should not remove current entry</title>
</h:head>
<h:body>
<h:form id="form">
<h:commandButton id="button" action="#{issue4167.keepAndRedirect}" />
</h:form>
<h:outputText id="result1" value="#{flash.message}" />
<h:outputText id="result2" value="#{issue4167.keepAndGet()}" />
<h:outputText id="result3" value="#{flash.message}" />
</h:body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 1997, 2018 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
*/

package ee.jakarta.tck.faces.test.javaee8.flash;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;

import ee.jakarta.tck.faces.test.util.arquillian.ITBase;
import jakarta.faces.context.Flash;

public class Issue4167IT extends ITBase {

/**
* @see Flash#keep(String)
* @see https://github.com/eclipse-ee4j/mojarra/issues/4171
*/
@Test
public void test() throws Exception {
HtmlPage page = getPage("issue4167.xhtml");

assertTrue(page.getHtmlElementById("result1").asNormalizedText().isEmpty());
assertTrue(page.getHtmlElementById("result2").asNormalizedText().isEmpty());
assertTrue(page.getHtmlElementById("result3").asNormalizedText().isEmpty());

HtmlSubmitInput button = (HtmlSubmitInput) page.getHtmlElementById("form:button");
page = button.click();

assertTrue(page.getHtmlElementById("result1").asNormalizedText().equals("issue4167"));
assertTrue(page.getHtmlElementById("result2").asNormalizedText().equals("issue4167"));
assertTrue(page.getHtmlElementById("result3").asNormalizedText().equals("issue4167"));
}

}
1 change: 1 addition & 0 deletions tck/faces23/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<module>faceletCacheFactory</module>
<module>facelets</module>
<module>facesConverter</module>
<module>flash</module>
<module>getViews</module>
<module>systemEvent</module>
<module>searchExpression</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@

import jakarta.faces.component.html.HtmlInputFile;

@Ignore // Failing because request.getParameter() returns null for all params since jakarta.servlet-api:6.0.0 (worked fine in 5.0.0!) -- TODO remove once Servlet API or GlassFish is fixed
@RunWith(Arquillian.class)
public class Spec1555IT {

Expand Down Expand Up @@ -119,7 +118,6 @@ private void testSingleSelection(String form) throws Exception {
* @see https://github.com/jakartaee/faces/issues/1555
*/
@Test
@Ignore
public void testMultipleSelectionNonAjax() throws Exception {
testMultipleSelection("multipleSelectionFormNonAjax");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void test() throws Exception {
assertEquals("http://xmlns.jcp.org/jsf/html works", "value", getValue(page.getElementById("h_jcp")));
assertEquals("http://xmlns.jcp.org/jsf/passthrough works", "email", page.getElementById("p_jcp").getChildElements().iterator().next().getAttribute("type"));
assertEquals("http://xmlns.jcp.org/jsf/composite works", "value", getValue(page.getElementById("cc_jcp")));
// assertEquals("http://xmlns.jcp.org/jsf/component works", "value", getValue(page.getElementById("comp_jcp")));
assertEquals("http://xmlns.jcp.org/jsf/component works", "value", getValue(page.getElementById("comp_jcp")));
assertEquals("http://xmlns.jcp.org/jsp/jstl/core works", "value", getValue(page.getElementById("c_jcp")));
assertEquals("http://xmlns.jcp.org/jsp/jstl/functions works", "value", getValue(page.getElementById("fn_jcp")));

Expand All @@ -99,26 +99,12 @@ public void test() throws Exception {
assertEquals("jakarta.faces.html works", "value", getValue(page.getElementById("h_jakarta")));
assertEquals("jakarta.faces.passthrough works", "email", page.getElementById("p_jakarta").getChildElements().iterator().next().getAttribute("type"));
assertEquals("jakarta.faces.composite works", "value", getValue(page.getElementById("cc_jakarta")));
// assertEquals("jakarta.faces.component works", "value", getValue(page.getElementById("comp_jakarta")));
assertEquals("jakarta.faces.component works", "value", getValue(page.getElementById("comp_jakarta")));
assertEquals("jakarta.tags.core works", "value", getValue(page.getElementById("c_jakarta")));
assertEquals("jakarta.tags.functions works", "value", getValue(page.getElementById("fn_jakarta")));

}

/**
* @see Facelet
* @see Application#createComponent(String)
* @see https://github.com/jakartaee/faces/issues/1553
*/
@Test
@Ignore // Fails due to FacesInitializer#onStartup(classes) being empty in current GlassFish version -- TODO: remove once GlassFish is fixed, see also outcomments above
public void testFacesComponent() throws Exception {
HtmlPage page = webClient.getPage(webUrl + "spec1553IT.xhtml");

assertEquals("http://xmlns.jcp.org/jsf/component works", "value", getValue(page.getElementById("comp_jcp")));
assertEquals("jakarta.faces.component works", "value", getValue(page.getElementById("comp_jakarta")));
}

private static String getValue(DomElement element) {
assertEquals("This element has no children", 0, element.getChildElementCount());
return element.asNormalizedText();
Expand Down
17 changes: 17 additions & 0 deletions tck/util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@
<name>Mojarra ${project.version} - Test - Util</name>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven-archive</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package ee.jakarta.tck.faces.test.util.arquillian;

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

import java.io.File;
import java.io.IOException;
import java.net.URL;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.importer.ZipImporter;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;

import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

import ee.jakarta.tck.faces.test.util.htmlunit.DebugOptions;
import ee.jakarta.tck.faces.test.util.htmlunit.IgnoringIncorrectnessListener;

@RunWith(Arquillian.class)
public abstract class ITBase {

@ArquillianResource
protected URL webUrl;
protected WebClient webClient;

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

@Before
public void setUp() {
webClient = new WebClient();
webClient.getOptions().setJavaScriptEnabled(true);
webClient.setJavaScriptTimeout(120000);
webClient.setIncorrectnessListener(new IgnoringIncorrectnessListener());
DebugOptions.setDebugOptions(webClient);
}

protected HtmlPage getPage(String viewId) throws IOException {
return webClient.getPage(webUrl + viewId);
}

@After
public void tearDown() {
webClient.close();
}

}

0 comments on commit ad70a0f

Please sign in to comment.