diff --git a/integration-tests/myfaces4623/pom.xml b/integration-tests/myfaces4623/pom.xml new file mode 100644 index 0000000000..7e2c7fcb8c --- /dev/null +++ b/integration-tests/myfaces4623/pom.xml @@ -0,0 +1,33 @@ + + + + + org.apache.myfaces.core + myfaces-integration-tests + 5.0.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + + org.apache.myfaces.core.integration-tests + myfaces4623 + Apache MyFaces Core 5.0 - Integration Tests - protectedViews + war + + diff --git a/integration-tests/myfaces4623/src/main/java/org/apache/myfaces/core/integrationtests/Bean.java b/integration-tests/myfaces4623/src/main/java/org/apache/myfaces/core/integrationtests/Bean.java new file mode 100644 index 0000000000..32fa4e9664 --- /dev/null +++ b/integration-tests/myfaces4623/src/main/java/org/apache/myfaces/core/integrationtests/Bean.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.myfaces.core.integrationtests; + +import jakarta.inject.Named; + +import jakarta.enterprise.context.SessionScoped; + +@SessionScoped +@Named("bean") +public class Bean implements java.io.Serializable +{ + + private Integer arraySize = 0; + + public Integer[] getCount() + { + if(arraySize == 1) + { + return new Integer[]{1}; + } + return new Integer[]{}; + } + + public void setToOne() + { + this.arraySize = 1; + } + + public void resetToZero() + { + this.arraySize = 0; + } + +} diff --git a/integration-tests/myfaces4623/src/main/java/org/apache/myfaces/core/integrationtests/CustomComponent.java b/integration-tests/myfaces4623/src/main/java/org/apache/myfaces/core/integrationtests/CustomComponent.java new file mode 100644 index 0000000000..f7a7bc8523 --- /dev/null +++ b/integration-tests/myfaces4623/src/main/java/org/apache/myfaces/core/integrationtests/CustomComponent.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.myfaces.core.integrationtests; + +import jakarta.faces.application.ResourceDependency; +import jakarta.faces.component.FacesComponent; +import jakarta.faces.component.html.HtmlOutputText; +import jakarta.faces.event.ComponentSystemEvent; + +@FacesComponent( + createTag = true, + namespace = "test" +) +@ResourceDependency( + library = "default", + name = "js/test.js" +) +public class CustomComponent extends HtmlOutputText +{ + public void processEvent(ComponentSystemEvent event) + { + super.processEvent(event); + } +} diff --git a/integration-tests/myfaces4623/src/main/webapp/WEB-INF/beans.xml b/integration-tests/myfaces4623/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000000..ece154ff06 --- /dev/null +++ b/integration-tests/myfaces4623/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,24 @@ + + + + diff --git a/integration-tests/myfaces4623/src/main/webapp/WEB-INF/faces-config.xml b/integration-tests/myfaces4623/src/main/webapp/WEB-INF/faces-config.xml new file mode 100644 index 0000000000..ec35a6c5cc --- /dev/null +++ b/integration-tests/myfaces4623/src/main/webapp/WEB-INF/faces-config.xml @@ -0,0 +1,26 @@ + + + + + + diff --git a/integration-tests/myfaces4623/src/main/webapp/WEB-INF/web.xml b/integration-tests/myfaces4623/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..863cf46052 --- /dev/null +++ b/integration-tests/myfaces4623/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,54 @@ + + + + + + jakarta.faces.PROJECT_STAGE + Development + + + + Faces Servlet + jakarta.faces.webapp.FacesServlet + 1 + + + + Faces Servlet + *.xhtml + + + + index.xhtml + + + + org.apache.myfaces.STRICT_JSF_2_FACELETS_COMPATIBILITY + true + + + + org.apache.myfaces.CHECK_ID_PRODUCTION_MODE + true + + + \ No newline at end of file diff --git a/integration-tests/myfaces4623/src/main/webapp/index.xhtml b/integration-tests/myfaces4623/src/main/webapp/index.xhtml new file mode 100644 index 0000000000..445f057320 --- /dev/null +++ b/integration-tests/myfaces4623/src/main/webapp/index.xhtml @@ -0,0 +1,55 @@ + + + + + Test DupId with c:ForEach + + + + + + +
+ + + +
+ + + + + + + + + +
+
+ +
+ + \ No newline at end of file diff --git a/integration-tests/myfaces4623/src/main/webapp/resources/default/js/test.js b/integration-tests/myfaces4623/src/main/webapp/resources/default/js/test.js new file mode 100644 index 0000000000..3cc4872296 --- /dev/null +++ b/integration-tests/myfaces4623/src/main/webapp/resources/default/js/test.js @@ -0,0 +1,19 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +console.log("js resource added succesfully!"); diff --git a/integration-tests/myfaces4623/src/test/java/org/apache/myfaces/core/integrationtests/IntegrationTest.java b/integration-tests/myfaces4623/src/test/java/org/apache/myfaces/core/integrationtests/IntegrationTest.java new file mode 100644 index 0000000000..8dee9f7248 --- /dev/null +++ b/integration-tests/myfaces4623/src/test/java/org/apache/myfaces/core/integrationtests/IntegrationTest.java @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.myfaces.core.integrationtests; + +import java.io.File; +import java.net.URL; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.drone.api.annotation.Drone; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.importer.ZipImporter; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ByIdOrName; +import org.openqa.selenium.support.ui.ExpectedCondition; +import org.openqa.selenium.support.ui.WebDriverWait; + +import java.time.Duration; + +@RunWith(Arquillian.class) +@RunAsClient +public class IntegrationTest +{ + @Deployment(testable = false) + public static WebArchive createDeployment() + { + // Fix for 'Failed to scan serializer.jar' error message + String key = "tomcat.util.scan.StandardJarScanFilter.jarsToSkip"; + String value = "bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,annotations-api.jar,el-api.jar,jsp-api.jar," + + "servlet-api.jar,websocket-api.jar,jaspic-api.jar,catalina.jar,catalina-ant.jar,catalina-ha.jar," + + "catalina-storeconfig.jar,catalina-tribes.jar,jasper.jar,jasper-el.jar,ecj-*.jar,tomcat-api.jar," + + "tomcat-util.jar,tomcat-util-scan.jar,tomcat-coyote.jar,tomcat-dbcp.jar,tomcat-jni.jar," + + "tomcat-websocket.jar,tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar," + + "tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,tomcat-jdbc.jar,tools.jar," + + "commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,commons-dbcp*.jar," + + "commons-digester*.jar,commons-fileupload*.jar,commons-httpclient*.jar,commons-io*.jar," + + "commons-lang*.jar,commons-logging*.jar,commons-math*.jar,commons-pool*.jar,jstl.jar," + + "taglibs-standard-spec-*.jar,geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,ant.jar,ant-junit*.jar," + + "aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,jmx-tools.jar,jta*.jar,log4j*.jar," + + "mail*.jar,slf4j*.jar,xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,junit.jar,junit-*.jar," + + "ant-launcher.jar,cobertura-*.jar,asm-*.jar,dom4j-*.jar,icu4j-*.jar,jaxen-*.jar,jdom-*.jar," + + "jetty-*.jar,oro-*.jar,servlet-api-*.jar,tagsoup-*.jar,xmlParserAPIs-*.jar,xom-*.jar,serializer.jar"; + System.setProperty(key, value); + + return ShrinkWrap.create(ZipImporter.class, "myfaces4623.war") + .importFrom(new File("target/myfaces4623.war")) + .as(WebArchive.class); + } + + @Drone + protected WebDriver webDriver; + + @ArquillianResource + protected URL contextPath; + + @Before + public void before() + { + } + + @After + public void after() + { + webDriver.manage().deleteAllCookies(); + } + + /* + * Test for https://issues.apache.org/jira/browse/MYFACES-4623 + */ + @Test + public void test() + { + webDriver.get(contextPath + "index.xhtml"); + + Assert.assertTrue(webDriver.getPageSource().contains("display")); + Assert.assertTrue(webDriver.getPageSource().contains("close")); + + trigger("form1:display", webDriver -> + { + return webDriver.getPageSource().contains("DISPLAYING COMPONENT"); + }); + Assert.assertTrue(webDriver.getPageSource().contains("DISPLAYING COMPONENT")); + + trigger("form1:close", webDriver -> + { + return !webDriver.getPageSource().contains("DISPLAYING COMPONENT"); + }); + Assert.assertFalse(webDriver.getPageSource().contains("DuplicateIdException")); + } + + + /** + * taken from ajax test + * recurring trigger, wait until ajax processing is done function + * + * @param id the trigger element id + * @param condition a condition resolver which should return true if the condition is met + */ + void trigger(String id, ExpectedCondition condition) + { + webDriver.findElement(By.id(id)).click(); + WebDriverWait wait = new WebDriverWait(webDriver, Duration.ofMillis(200)); + wait.until(condition); + } + +} diff --git a/integration-tests/myfaces4623/src/test/resources/arquillian.xml b/integration-tests/myfaces4623/src/test/resources/arquillian.xml new file mode 100644 index 0000000000..b472092b6b --- /dev/null +++ b/integration-tests/myfaces4623/src/test/resources/arquillian.xml @@ -0,0 +1,39 @@ + + + + + chromeHeadless + 100 + ${chromeDriverVersion:} + + + + + target/tomcat-embedded-10 + work + 8888 + true + arquillian-tomcat-embedded-10 + + +