-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4552 from soul2zimate/issue-4551
Fix issue 4551, don't compare class name and skip CDIValidator
- Loading branch information
Showing
7 changed files
with
219 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
test/javaee8/cdi/src/main/java/com/sun/faces/test/javaee8/cdi/AnnotatedBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* 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 com.sun.faces.test.javaee8.cdi; | ||
|
||
import java.io.Serializable; | ||
|
||
import javax.enterprise.context.RequestScoped; | ||
import javax.inject.Named; | ||
|
||
@Named(value = "annotatedBean") | ||
@RequestScoped | ||
public class AnnotatedBean implements Serializable { | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append("AnnotatedBean"); | ||
return builder.toString(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
test/javaee8/cdi/src/main/java/com/sun/faces/test/javaee8/cdi/CustomBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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 com.sun.faces.test.javaee8.cdi; | ||
|
||
import java.io.Serializable; | ||
|
||
import javax.inject.Named; | ||
|
||
@Named(value = "customBean") | ||
public class CustomBean implements Serializable { | ||
|
||
private Long value; | ||
|
||
public Long getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(Long value) { | ||
this.value = value; | ||
} | ||
|
||
public String submit() { | ||
return ""; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
test/javaee8/cdi/src/main/java/com/sun/faces/test/javaee8/cdi/CustomValidator1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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 com.sun.faces.test.javaee8.cdi; | ||
|
||
import javax.faces.application.FacesMessage; | ||
import javax.faces.component.UIComponent; | ||
import javax.faces.context.FacesContext; | ||
import javax.faces.validator.FacesValidator; | ||
import javax.faces.validator.Validator; | ||
import javax.faces.validator.ValidatorException; | ||
import javax.inject.Inject; | ||
|
||
@FacesValidator(value = "validator.CustomValidator1", managed = true) | ||
public class CustomValidator1 implements Validator<String> { | ||
|
||
@Inject | ||
private AnnotatedBean annotatedBean; | ||
|
||
@Override | ||
public void validate(FacesContext context, UIComponent component, String value) throws ValidatorException { | ||
context.addMessage(component.getClientId(context), new FacesMessage("CustomValidator1 was validated with injected " + annotatedBean)); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
test/javaee8/cdi/src/main/java/com/sun/faces/test/javaee8/cdi/CustomValidator2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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 com.sun.faces.test.javaee8.cdi; | ||
|
||
import javax.faces.application.FacesMessage; | ||
import javax.faces.component.UIComponent; | ||
import javax.faces.context.FacesContext; | ||
import javax.faces.validator.FacesValidator; | ||
import javax.faces.validator.Validator; | ||
import javax.faces.validator.ValidatorException; | ||
import javax.inject.Inject; | ||
|
||
@FacesValidator(value = "validator.CustomValidator2", managed = true) | ||
public class CustomValidator2 implements Validator<String> { | ||
|
||
@Inject | ||
private AnnotatedBean annotatedBean; | ||
|
||
@Override | ||
public void validate(FacesContext context, UIComponent component, String value) throws ValidatorException { | ||
context.addMessage(component.getClientId(context), new FacesMessage("CustomValidator2 was validated with injected " + annotatedBean)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" | ||
xmlns:f="http://java.sun.com/jsf/core"> | ||
<h:head> | ||
<title>JAVASERVERFACES-4551 - Integration Test</title> | ||
</h:head> | ||
|
||
<h:body> | ||
<h:form id="form"> | ||
<h:inputText id="inputText" value="#{customBean.value}"> | ||
<f:validator validatorId="validator.CustomValidator1" /> | ||
<f:validator validatorId="validator.CustomValidator2" /> | ||
</h:inputText> | ||
<h:commandButton id="submit" action="#{customBean.submit}" value="Submit"/> | ||
</h:form> | ||
</h:body> | ||
</html> |
53 changes: 53 additions & 0 deletions
53
test/javaee8/cdi/src/test/java/com/sun/faces/test/javaee8/cdi/Issue4551IT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 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 com.sun.faces.test.javaee8.cdi; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import com.gargoylesoftware.htmlunit.WebClient; | ||
import com.gargoylesoftware.htmlunit.html.HtmlElement; | ||
import com.gargoylesoftware.htmlunit.html.HtmlPage; | ||
|
||
public class Issue4551IT { | ||
|
||
private String webUrl; | ||
private WebClient webClient; | ||
|
||
@Before | ||
public void setUp() { | ||
webUrl = System.getProperty("integration.url"); | ||
webClient = new WebClient(); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
webClient.close(); | ||
} | ||
|
||
@Test | ||
public void testTwoAnnotatedJSFValidatorsInvoked () throws Exception { | ||
HtmlPage page = webClient.getPage(webUrl + "faces/issue4551.xhtml"); | ||
HtmlElement submit = page.getHtmlElementById("form:submit"); | ||
page = submit.click(); | ||
assertTrue(page.asText().contains("CustomValidator1 was validated")); | ||
assertTrue(page.asText().contains("CustomValidator2 was validated")); | ||
} | ||
} |