Repository: deltaspike Updated Branches: refs/heads/master c447e841c -> 993c0565e
DELTASPIKE-725 - tests for converter/validator injection Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/993c0565 Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/993c0565 Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/993c0565 Branch: refs/heads/master Commit: 993c0565e1ac79a29b36d234ad9a01c487e57785 Parents: c447e84 Author: Rafael Benevides <[email protected]> Authored: Fri Oct 10 11:46:04 2014 -0300 Committer: Rafael Benevides <[email protected]> Committed: Fri Oct 10 11:46:04 2014 -0300 ---------------------------------------------------------------------- .../jsf/impl/injection/uc001/AnotherBean.java | 68 +++++++++++ .../injection/uc001/AnotherBeanConverter.java | 63 ++++++++++ .../injection/uc001/InjectionDroneTest.java | 115 ++++++++++++++++++ .../test/jsf/impl/injection/uc001/MyBean.java | 63 ++++++++++ .../impl/injection/uc001/MyBeanValidator.java | 50 ++++++++ .../jsf/impl/injection/uc002/AnotherBean.java | 68 +++++++++++ .../injection/uc002/AnotherBeanConverter.java | 65 ++++++++++ .../injection/uc002/InjectionDroneTest.java | 115 ++++++++++++++++++ .../test/jsf/impl/injection/uc002/MyBean.java | 63 ++++++++++ .../impl/injection/uc002/MyBeanValidator.java | 52 ++++++++ .../injection/uc003/AbstractStateHolder.java | 55 +++++++++ .../jsf/impl/injection/uc003/AnotherBean.java | 68 +++++++++++ .../injection/uc003/AnotherBeanConverter.java | 63 ++++++++++ .../injection/uc003/InjectionDroneTest.java | 118 +++++++++++++++++++ .../test/jsf/impl/injection/uc003/MyBean.java | 63 ++++++++++ .../impl/injection/uc003/MyBeanValidator.java | 53 +++++++++ .../src/test/resources/META-INF/test.taglib.xml | 35 ++++++ .../injection/testValidatorConverter.xhtml | 50 ++++++++ .../injection/testValidatorConverterTag.xhtml | 51 ++++++++ 19 files changed, 1278 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/AnotherBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/AnotherBean.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/AnotherBean.java new file mode 100644 index 0000000..8ac3b0e --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/AnotherBean.java @@ -0,0 +1,68 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc001; + +public class AnotherBean +{ + + private String value; + + public AnotherBean() + { + + } + + public AnotherBean(String value) + { + this.value = value; + } + + public String getValue() + { + return value; + } + + public void setValue(String value) + { + this.value = value; + } + + public Object getAsObject(String value) + { + if (value != null && !value.isEmpty()) + { + return new AnotherBean(value); + } + else + { + return null; + } + } + + public String getAsString(Object object) + { + if (object instanceof AnotherBean) + { + AnotherBean myValue = (AnotherBean) object; + return myValue.getValue(); + } + return null; + } + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/AnotherBeanConverter.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/AnotherBeanConverter.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/AnotherBeanConverter.java new file mode 100644 index 0000000..885923d --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/AnotherBeanConverter.java @@ -0,0 +1,63 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc001; + +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.ConverterException; +import javax.faces.convert.FacesConverter; +import javax.inject.Inject; + +@FacesConverter("myValueConveter") +public class AnotherBeanConverter implements Converter +{ + + @Inject + private AnotherBean myValue; + + @Override + public Object getAsObject(FacesContext context, UIComponent component, + String value) + { + try + { + if (value == null || value.isEmpty()) + { + return null; + } + Integer.parseInt(value); + return myValue.getAsObject(value); + } + catch (NumberFormatException e) + { + throw new ConverterException(new FacesMessage("Value is not an Integer")); + } + + } + + @Override + public String getAsString(FacesContext context, UIComponent component, + Object value) + { + return myValue.getAsString(value); + } + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/InjectionDroneTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/InjectionDroneTest.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/InjectionDroneTest.java new file mode 100644 index 0000000..d253fa6 --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/InjectionDroneTest.java @@ -0,0 +1,115 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc001; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.apache.deltaspike.test.category.WebProfileCategory; +import org.apache.deltaspike.test.jsf.impl.util.ArchiveUtils; +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.junit.Arquillian; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.arquillian.warp.WarpTest; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assert; +import org.junit.Test; +import org.junit.experimental.categories.Category; +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.ui.ExpectedConditions; + +@WarpTest +@RunWith(Arquillian.class) +@Category(WebProfileCategory.class) +public class InjectionDroneTest +{ + @Drone + private WebDriver driver; + + @ArquillianResource + private URL contextPath; + + @Deployment + public static WebArchive deploy() + { + return ShrinkWrap + .create(WebArchive.class, "injection-uc001.war") + .addPackage(MyBean.class.getPackage()) + .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJsfArchive()) + .addAsLibraries(ArchiveUtils.getDeltaSpikeSecurityArchive()) + .addAsWebResource("injection/testValidatorConverter.xhtml", "/testValidatorConverter.xhtml") + .addAsWebInfResource("default/WEB-INF/web.xml", "web.xml") + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + @RunAsClient + public void testConverter() throws MalformedURLException + { + driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); + WebElement convertedValue = driver.findElement(By.id("converter:convertedValue")); + convertedValue.sendKeys("123"); + WebElement testConveterButton = driver.findElement(By.id("converter:testConveterButton")); + testConveterButton.click(); + Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("messages"), "Worked").apply(driver)); + } + + @Test + @RunAsClient + public void testConverterWithError() throws MalformedURLException + { + driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); + WebElement convertedValue = driver.findElement(By.id("converter:convertedValue")); + convertedValue.sendKeys("String Value"); + WebElement testConveterButton = driver.findElement(By.id("converter:testConveterButton")); + testConveterButton.click(); + Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("converter:errorMessage"), "Value is not an Integer").apply(driver)); + } + + @Test + @RunAsClient + public void testValidator() throws MalformedURLException + { + driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); + WebElement convertedValue = driver.findElement(By.id("validator:stringValue")); + convertedValue.sendKeys("DeltaSpike"); + WebElement testConveterButton = driver.findElement(By.id("validator:testValidatorButton")); + testConveterButton.click(); + Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("messages"), "Worked").apply(driver)); + } + + @Test + @RunAsClient + public void testValidatorWithError() throws MalformedURLException + { + driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); + WebElement convertedValue = driver.findElement(By.id("validator:stringValue")); + convertedValue.sendKeys("Wrong Value"); + WebElement testConveterButton = driver.findElement(By.id("validator:testValidatorButton")); + testConveterButton.click(); + Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("validator:errorMessage"), "Not a valid value").apply(driver)); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/MyBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/MyBean.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/MyBean.java new file mode 100644 index 0000000..e3e010e --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/MyBean.java @@ -0,0 +1,63 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc001; + +import javax.enterprise.inject.Model; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; + +@Model +public class MyBean +{ + + private String stringValue; + + private AnotherBean convertedValue; + + public String getStringValue() + { + return stringValue; + } + + public void setStringValue(String stringValue) + { + this.stringValue = stringValue; + } + + public AnotherBean getConvertedValue() + { + return convertedValue; + } + + public void setConvertedValue(AnotherBean convertedValue) + { + this.convertedValue = convertedValue; + } + + public void testAction() + { + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Worked")); + } + + public boolean isValid(String value) + { + return "DeltaSpike".equals(value); + } + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/MyBeanValidator.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/MyBeanValidator.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/MyBeanValidator.java new file mode 100644 index 0000000..bee0707 --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc001/MyBeanValidator.java @@ -0,0 +1,50 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc001; + +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("myBeanValidator") +public class MyBeanValidator implements Validator +{ + + @Inject + private MyBean myBean; + + @Override + public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException + { + if (value instanceof String) + { + String valueAString = (String) value; + if (!myBean.isValid(valueAString)) + { + throw new ValidatorException(new FacesMessage("Not a valid value")); + } + + } + } + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/AnotherBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/AnotherBean.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/AnotherBean.java new file mode 100644 index 0000000..3d950d2 --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/AnotherBean.java @@ -0,0 +1,68 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc002; + +public class AnotherBean +{ + + private String value; + + public AnotherBean() + { + + } + + public AnotherBean(String value) + { + this.value = value; + } + + public String getValue() + { + return value; + } + + public void setValue(String value) + { + this.value = value; + } + + public Object getAsObject(String value) + { + if (value != null && !value.isEmpty()) + { + return new AnotherBean(value); + } + else + { + return null; + } + } + + public String getAsString(Object object) + { + if (object instanceof AnotherBean) + { + AnotherBean myValue = (AnotherBean) object; + return myValue.getValue(); + } + return null; + } + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/AnotherBeanConverter.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/AnotherBeanConverter.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/AnotherBeanConverter.java new file mode 100644 index 0000000..d4aea0b --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/AnotherBeanConverter.java @@ -0,0 +1,65 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc002; + +import javax.enterprise.context.RequestScoped; +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.ConverterException; +import javax.faces.convert.FacesConverter; +import javax.inject.Inject; + +@RequestScoped +@FacesConverter("myValueConveter") +public class AnotherBeanConverter implements Converter +{ + + @Inject + private AnotherBean myValue; + + @Override + public Object getAsObject(FacesContext context, UIComponent component, + String value) + { + try + { + if (value == null || value.isEmpty()) + { + return null; + } + Integer.parseInt(value); + return myValue.getAsObject(value); + } + catch (NumberFormatException e) + { + throw new ConverterException(new FacesMessage("Value is not an Integer")); + } + + } + + @Override + public String getAsString(FacesContext context, UIComponent component, + Object value) + { + return myValue.getAsString(value); + } + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/InjectionDroneTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/InjectionDroneTest.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/InjectionDroneTest.java new file mode 100644 index 0000000..1e08e8f --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/InjectionDroneTest.java @@ -0,0 +1,115 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc002; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.apache.deltaspike.test.category.WebProfileCategory; +import org.apache.deltaspike.test.jsf.impl.util.ArchiveUtils; +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.junit.Arquillian; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.arquillian.warp.WarpTest; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assert; +import org.junit.Test; +import org.junit.experimental.categories.Category; +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.ui.ExpectedConditions; + +@WarpTest +@RunWith(Arquillian.class) +@Category(WebProfileCategory.class) +public class InjectionDroneTest +{ + @Drone + private WebDriver driver; + + @ArquillianResource + private URL contextPath; + + @Deployment + public static WebArchive deploy() + { + return ShrinkWrap + .create(WebArchive.class, "injection-uc002.war") + .addPackage(MyBean.class.getPackage()) + .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJsfArchive()) + .addAsLibraries(ArchiveUtils.getDeltaSpikeSecurityArchive()) + .addAsWebResource("injection/testValidatorConverter.xhtml", "/testValidatorConverter.xhtml") + .addAsWebInfResource("default/WEB-INF/web.xml", "web.xml") + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + @RunAsClient + public void testConverter() throws MalformedURLException + { + driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); + WebElement convertedValue = driver.findElement(By.id("converter:convertedValue")); + convertedValue.sendKeys("123"); + WebElement testConveterButton = driver.findElement(By.id("converter:testConveterButton")); + testConveterButton.click(); + Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("messages"), "Worked").apply(driver)); + } + + @Test + @RunAsClient + public void testConverterWithError() throws MalformedURLException + { + driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); + WebElement convertedValue = driver.findElement(By.id("converter:convertedValue")); + convertedValue.sendKeys("String Value"); + WebElement testConveterButton = driver.findElement(By.id("converter:testConveterButton")); + testConveterButton.click(); + Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("converter:errorMessage"), "Value is not an Integer").apply(driver)); + } + + @Test + @RunAsClient + public void testValidator() throws MalformedURLException + { + driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); + WebElement convertedValue = driver.findElement(By.id("validator:stringValue")); + convertedValue.sendKeys("DeltaSpike"); + WebElement testConveterButton = driver.findElement(By.id("validator:testValidatorButton")); + testConveterButton.click(); + Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("messages"), "Worked").apply(driver)); + } + + @Test + @RunAsClient + public void testValidatorWithError() throws MalformedURLException + { + driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); + WebElement convertedValue = driver.findElement(By.id("validator:stringValue")); + convertedValue.sendKeys("Wrong Value"); + WebElement testConveterButton = driver.findElement(By.id("validator:testValidatorButton")); + testConveterButton.click(); + Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("validator:errorMessage"), "Not a valid value").apply(driver)); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/MyBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/MyBean.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/MyBean.java new file mode 100644 index 0000000..9fdfd39 --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/MyBean.java @@ -0,0 +1,63 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc002; + +import javax.enterprise.inject.Model; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; + +@Model +public class MyBean +{ + + private String stringValue; + + private AnotherBean convertedValue; + + public String getStringValue() + { + return stringValue; + } + + public void setStringValue(String stringValue) + { + this.stringValue = stringValue; + } + + public AnotherBean getConvertedValue() + { + return convertedValue; + } + + public void setConvertedValue(AnotherBean convertedValue) + { + this.convertedValue = convertedValue; + } + + public void testAction() + { + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Worked")); + } + + public boolean isValid(String value) + { + return "DeltaSpike".equals(value); + } + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/MyBeanValidator.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/MyBeanValidator.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/MyBeanValidator.java new file mode 100644 index 0000000..5de5fe6 --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc002/MyBeanValidator.java @@ -0,0 +1,52 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc002; + +import javax.enterprise.context.RequestScoped; +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; + +@RequestScoped +@FacesValidator("myBeanValidator") +public class MyBeanValidator implements Validator +{ + + @Inject + private MyBean myBean; + + @Override + public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException + { + if (value instanceof String) + { + String valueAString = (String) value; + if (!myBean.isValid(valueAString)) + { + throw new ValidatorException(new FacesMessage("Not a valid value")); + } + + } + } + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/AbstractStateHolder.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/AbstractStateHolder.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/AbstractStateHolder.java new file mode 100644 index 0000000..dab1bff --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/AbstractStateHolder.java @@ -0,0 +1,55 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc003; + +import javax.faces.component.StateHolder; +import javax.faces.context.FacesContext; + +public abstract class AbstractStateHolder implements StateHolder +{ + + private boolean isTransient; + + @Override + public Object saveState(FacesContext context) + { + // no need to really save the state + return null; + } + + @Override + public void restoreState(FacesContext context, Object state) + { + // no need to really restore the state + } + + @Override + public boolean isTransient() + { + return isTransient; + } + + @Override + public void setTransient(boolean newTransientValue) + { + this.isTransient = newTransientValue; + + } + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/AnotherBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/AnotherBean.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/AnotherBean.java new file mode 100644 index 0000000..d14f296 --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/AnotherBean.java @@ -0,0 +1,68 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc003; + +public class AnotherBean +{ + + private String value; + + public AnotherBean() + { + + } + + public AnotherBean(String value) + { + this.value = value; + } + + public String getValue() + { + return value; + } + + public void setValue(String value) + { + this.value = value; + } + + public Object getAsObject(String value) + { + if (value != null && !value.isEmpty()) + { + return new AnotherBean(value); + } + else + { + return null; + } + } + + public String getAsString(Object object) + { + if (object instanceof AnotherBean) + { + AnotherBean myValue = (AnotherBean) object; + return myValue.getValue(); + } + return null; + } + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/AnotherBeanConverter.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/AnotherBeanConverter.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/AnotherBeanConverter.java new file mode 100644 index 0000000..640caaa --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/AnotherBeanConverter.java @@ -0,0 +1,63 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc003; + +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.ConverterException; +import javax.faces.convert.FacesConverter; +import javax.inject.Inject; + +@FacesConverter("myValueConveter") +public class AnotherBeanConverter extends AbstractStateHolder implements Converter +{ + + @Inject + private AnotherBean myValue; + + @Override + public Object getAsObject(FacesContext context, UIComponent component, + String value) + { + try + { + if (value == null || value.isEmpty()) + { + return null; + } + Integer.parseInt(value); + return myValue.getAsObject(value); + } + catch (NumberFormatException e) + { + throw new ConverterException(new FacesMessage("Value is not an Integer")); + } + + } + + @Override + public String getAsString(FacesContext context, UIComponent component, + Object value) + { + return myValue.getAsString(value); + } + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/InjectionDroneTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/InjectionDroneTest.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/InjectionDroneTest.java new file mode 100644 index 0000000..20d83f1 --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/InjectionDroneTest.java @@ -0,0 +1,118 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc003; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.apache.deltaspike.test.category.WebProfileCategory; +import org.apache.deltaspike.test.jsf.impl.util.ArchiveUtils; +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.junit.Arquillian; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.arquillian.warp.WarpTest; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assert; +import org.junit.Test; +import org.junit.experimental.categories.Category; +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.ui.ExpectedConditions; + +@WarpTest +@RunWith(Arquillian.class) +@Category(WebProfileCategory.class) +public class InjectionDroneTest +{ + @Drone + private WebDriver driver; + + @ArquillianResource + private URL contextPath; + + @Deployment + public static WebArchive deploy() + { + return ShrinkWrap + .create(WebArchive.class, "injection-uc003.war") + .addPackage(MyBean.class.getPackage()) + .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJsfArchive()) + .addAsLibraries(ArchiveUtils.getDeltaSpikeSecurityArchive()) + .addAsManifestResource("META-INF/test.taglib.xml", "test.taglib.xml") + .addAsWebResource("injection/testValidatorConverterTag.xhtml", "/testValidatorConverter.xhtml") + .addAsWebInfResource("default/WEB-INF/web.xml", "web.xml") + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + @RunAsClient + public void testConverter() throws MalformedURLException + { + driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); + WebElement convertedValue = driver.findElement(By.id("converter:convertedValue")); + convertedValue.sendKeys("123"); + WebElement testConveterButton = driver.findElement(By.id("converter:testConveterButton")); + testConveterButton.click(); + Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("messages"), "Worked").apply(driver)); + } + + @Test + @RunAsClient + public void testConverterWithError() throws MalformedURLException + { + driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); + WebElement convertedValue = driver.findElement(By.id("converter:convertedValue")); + convertedValue.sendKeys("String Value"); + WebElement testConveterButton = driver.findElement(By.id("converter:testConveterButton")); + testConveterButton.click(); + Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("converter:errorMessage"), + "Value is not an Integer").apply(driver)); + } + + @Test + @RunAsClient + public void testValidator() throws MalformedURLException + { + driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); + WebElement convertedValue = driver.findElement(By.id("validator:stringValue")); + convertedValue.sendKeys("DeltaSpike"); + WebElement testConveterButton = driver.findElement(By.id("validator:testValidatorButton")); + testConveterButton.click(); + Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("messages"), "Worked").apply(driver)); + } + + @Test + @RunAsClient + public void testValidatorWithError() throws MalformedURLException + { + driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); + WebElement convertedValue = driver.findElement(By.id("validator:stringValue")); + convertedValue.sendKeys("Wrong Value"); + WebElement testConveterButton = driver.findElement(By.id("validator:testValidatorButton")); + testConveterButton.click(); + Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("validator:errorMessage"), + "Not a valid value").apply(driver)); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/MyBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/MyBean.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/MyBean.java new file mode 100644 index 0000000..5f1cb3d --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/MyBean.java @@ -0,0 +1,63 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc003; + +import javax.enterprise.inject.Model; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; + +@Model +public class MyBean +{ + + private String stringValue; + + private AnotherBean convertedValue; + + public String getStringValue() + { + return stringValue; + } + + public void setStringValue(String stringValue) + { + this.stringValue = stringValue; + } + + public AnotherBean getConvertedValue() + { + return convertedValue; + } + + public void setConvertedValue(AnotherBean convertedValue) + { + this.convertedValue = convertedValue; + } + + public void testAction() + { + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Worked")); + } + + public boolean isValid(String value) + { + return "DeltaSpike".equals(value); + } + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/MyBeanValidator.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/MyBeanValidator.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/MyBeanValidator.java new file mode 100644 index 0000000..805a939 --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/injection/uc003/MyBeanValidator.java @@ -0,0 +1,53 @@ +/* + * 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.deltaspike.test.jsf.impl.injection.uc003; + +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("myBeanValidator") +public class MyBeanValidator extends AbstractStateHolder implements Validator +{ + + @Inject + private MyBean myBean; + + + @Override + public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException + { + if (value instanceof String) + { + String valueAString = (String) value; + if (!myBean.isValid(valueAString)) + { + throw new ValidatorException(new FacesMessage("Not a valid value")); + } + + } + } + + + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/resources/META-INF/test.taglib.xml ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/resources/META-INF/test.taglib.xml b/deltaspike/modules/jsf/impl/src/test/resources/META-INF/test.taglib.xml new file mode 100644 index 0000000..6f567b1 --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/resources/META-INF/test.taglib.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "facelet-taglib_1_0.dtd"> +<facelet-taglib> + <namespace>http://deltaspike.apache.org/tags</namespace> + <tag> + <tag-name>myBeanValidator</tag-name> + <validator> + <validator-id>myBeanValidator</validator-id> + </validator> + </tag> + <tag> + <tag-name>myValueConveter</tag-name> + <converter> + <converter-id>myValueConveter</converter-id> + </converter> + </tag> +</facelet-taglib> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/resources/injection/testValidatorConverter.xhtml ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/resources/injection/testValidatorConverter.xhtml b/deltaspike/modules/jsf/impl/src/test/resources/injection/testValidatorConverter.xhtml new file mode 100644 index 0000000..ad8cabe --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/resources/injection/testValidatorConverter.xhtml @@ -0,0 +1,50 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<!-- + 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. +--> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:h="http://java.sun.com/jsf/html"> + +<h:head></h:head> +<body> + <h:messages id="messages" globalOnly="true" /> + <br /> + <h:form id="converter"> + Converterd Value : + <h:inputText id="convertedValue" value="#{myBean.convertedValue}"> + <f:converter converterId="myValueConveter" /> + </h:inputText> + <h:message id="errorMessage" for="convertedValue" /> + <br /> + <h:commandButton id="testConveterButton" + action="#{myBean.testAction()}" value="Test Conveter" /> + </h:form> + <h:form id="validator"> + Value String: + <h:inputText id="stringValue" value="#{myBean.stringValue}"> + <f:validator validatorId="myBeanValidator" /> + </h:inputText> + <h:message id="errorMessage" for="stringValue" /> + <br /> + <h:commandButton id="testValidatorButton" + action="#{myBean.testAction()}" value="Test Validator" /> + </h:form> +</body> +</html> http://git-wip-us.apache.org/repos/asf/deltaspike/blob/993c0565/deltaspike/modules/jsf/impl/src/test/resources/injection/testValidatorConverterTag.xhtml ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jsf/impl/src/test/resources/injection/testValidatorConverterTag.xhtml b/deltaspike/modules/jsf/impl/src/test/resources/injection/testValidatorConverterTag.xhtml new file mode 100644 index 0000000..a8430f7 --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/test/resources/injection/testValidatorConverterTag.xhtml @@ -0,0 +1,51 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<!-- + 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. +--> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:d="http://deltaspike.apache.org/tags"> + +<h:head></h:head> +<body> + <h:messages id="messages" globalOnly="true" /> + <br /> + <h:form id="converter"> + Converterd Value : + <h:inputText id="convertedValue" value="#{myBean.convertedValue}"> + <d:myValueConveter /> + </h:inputText> + <h:message id="errorMessage" for="convertedValue" /> + <br /> + <h:commandButton id="testConveterButton" + action="#{myBean.testAction()}" value="Test Conveter" /> + </h:form> + <h:form id="validator"> + Value String: + <h:inputText id="stringValue" value="#{myBean.stringValue}"> + <d:myBeanValidator /> + </h:inputText> + <h:message id="errorMessage" for="stringValue" /> + <br /> + <h:commandButton id="testValidatorButton" + action="#{myBean.testAction()}" value="Test Validator" /> + </h:form> +</body> +</html>
