Return-Path: Delivered-To: apmail-incubator-bval-commits-archive@minotaur.apache.org Received: (qmail 77649 invoked from network); 2 Apr 2010 15:00:35 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Apr 2010 15:00:35 -0000 Received: (qmail 11024 invoked by uid 500); 2 Apr 2010 15:00:35 -0000 Delivered-To: apmail-incubator-bval-commits-archive@incubator.apache.org Received: (qmail 10994 invoked by uid 500); 2 Apr 2010 15:00:35 -0000 Mailing-List: contact bval-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: bval-dev@incubator.apache.org Delivered-To: mailing list bval-commits@incubator.apache.org Received: (qmail 10987 invoked by uid 99); 2 Apr 2010 15:00:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Apr 2010 15:00:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Apr 2010 15:00:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 398A72388A5E; Fri, 2 Apr 2010 15:00:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r930290 - in /incubator/bval/sandbox/guice-integration: ./ src/main/java/org/apache/bval/extentions/guice/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/bval/ src/test/java/org/apache/bval/extentions/ src/test/java/o... Date: Fri, 02 Apr 2010 15:00:11 -0000 To: bval-commits@incubator.apache.org From: simonetripodi@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100402150011.398A72388A5E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: simonetripodi Date: Fri Apr 2 15:00:10 2010 New Revision: 930290 URL: http://svn.apache.org/viewvc?rev=930290&view=rev Log: added first working test case removed useless constraints bindings Added: incubator/bval/sandbox/guice-integration/src/test/java/org/ incubator/bval/sandbox/guice-integration/src/test/java/org/apache/ incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/ incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/ incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/ incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Country.java (with props) incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/GuiceAwareValidationTestCase.java (with props) Modified: incubator/bval/sandbox/guice-integration/pom.xml incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ConfigurationStateProvider.java incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidationModule.java Modified: incubator/bval/sandbox/guice-integration/pom.xml URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/pom.xml?rev=930290&r1=930289&r2=930290&view=diff ============================================================================== --- incubator/bval/sandbox/guice-integration/pom.xml (original) +++ incubator/bval/sandbox/guice-integration/pom.xml Fri Apr 2 15:00:10 2010 @@ -63,6 +63,12 @@ 1.0 compile + + + junit + junit + test + Modified: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ConfigurationStateProvider.java URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ConfigurationStateProvider.java?rev=930290&r1=930289&r2=930290&view=diff ============================================================================== --- incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ConfigurationStateProvider.java (original) +++ incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ConfigurationStateProvider.java Fri Apr 2 15:00:10 2010 @@ -39,7 +39,7 @@ public final class ConfigurationStatePro private final ConfigurationImpl configurationState; @Inject - public ConfigurationStateProvider(ValidationProvider aProvider) { + public ConfigurationStateProvider(ValidationProvider aProvider) { this.configurationState = new ConfigurationImpl(null, aProvider); } Modified: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidationModule.java URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidationModule.java?rev=930290&r1=930289&r2=930290&view=diff ============================================================================== --- incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidationModule.java (original) +++ incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidationModule.java Fri Apr 2 15:00:10 2010 @@ -24,43 +24,6 @@ import javax.validation.ValidatorFactory import javax.validation.spi.ConfigurationState; import javax.validation.spi.ValidationProvider; -import org.apache.bval.constraints.AssertFalseValidator; -import org.apache.bval.constraints.AssertTrueValidator; -import org.apache.bval.constraints.DecimalMaxValidatorForNumber; -import org.apache.bval.constraints.DecimalMaxValidatorForString; -import org.apache.bval.constraints.DecimalMinValidatorForNumber; -import org.apache.bval.constraints.DecimalMinValidatorForString; -import org.apache.bval.constraints.DigitsValidatorForNumber; -import org.apache.bval.constraints.DigitsValidatorForString; -import org.apache.bval.constraints.EmailValidator; -import org.apache.bval.constraints.FutureValidatorForCalendar; -import org.apache.bval.constraints.FutureValidatorForDate; -import org.apache.bval.constraints.MaxValidatorForNumber; -import org.apache.bval.constraints.MaxValidatorForString; -import org.apache.bval.constraints.MinValidatorForNumber; -import org.apache.bval.constraints.MinValidatorForString; -import org.apache.bval.constraints.NotEmptyValidator; -import org.apache.bval.constraints.NotEmptyValidatorForCollection; -import org.apache.bval.constraints.NotEmptyValidatorForMap; -import org.apache.bval.constraints.NotEmptyValidatorForString; -import org.apache.bval.constraints.NotNullValidator; -import org.apache.bval.constraints.NullValidator; -import org.apache.bval.constraints.PastValidatorForCalendar; -import org.apache.bval.constraints.PastValidatorForDate; -import org.apache.bval.constraints.PatternValidator; -import org.apache.bval.constraints.SizeValidator; -import org.apache.bval.constraints.SizeValidatorForArrayOfBoolean; -import org.apache.bval.constraints.SizeValidatorForArrayOfByte; -import org.apache.bval.constraints.SizeValidatorForArrayOfChar; -import org.apache.bval.constraints.SizeValidatorForArrayOfDouble; -import org.apache.bval.constraints.SizeValidatorForArrayOfFloat; -import org.apache.bval.constraints.SizeValidatorForArrayOfInt; -import org.apache.bval.constraints.SizeValidatorForArrayOfLong; -import org.apache.bval.constraints.SizeValidatorForArrayOfObject; -import org.apache.bval.constraints.SizeValidatorForArrayOfShort; -import org.apache.bval.constraints.SizeValidatorForCollection; -import org.apache.bval.constraints.SizeValidatorForMap; -import org.apache.bval.constraints.SizeValidatorForString; import org.apache.bval.jsr303.ApacheValidationProvider; import org.apache.bval.jsr303.DefaultMessageInterpolator; import org.apache.bval.jsr303.resolver.DefaultTraversableResolver; @@ -80,46 +43,6 @@ public final class ValidationModule exte */ @Override protected void configure() { - // constraints - this.bind(AssertFalseValidator.class).in(Scopes.SINGLETON); - this.bind(AssertTrueValidator.class).in(Scopes.SINGLETON); - this.bind(DecimalMaxValidatorForNumber.class).in(Scopes.SINGLETON); - this.bind(DecimalMaxValidatorForString.class).in(Scopes.SINGLETON); - this.bind(DecimalMinValidatorForNumber.class).in(Scopes.SINGLETON); - this.bind(DecimalMinValidatorForString.class).in(Scopes.SINGLETON); - this.bind(DigitsValidatorForNumber.class).in(Scopes.SINGLETON); - this.bind(DigitsValidatorForString.class).in(Scopes.SINGLETON); - this.bind(EmailValidator.class).in(Scopes.SINGLETON); - this.bind(FutureValidatorForCalendar.class).in(Scopes.SINGLETON); - this.bind(FutureValidatorForDate.class).in(Scopes.SINGLETON); - this.bind(MaxValidatorForNumber.class).in(Scopes.SINGLETON); - this.bind(MaxValidatorForString.class).in(Scopes.SINGLETON); - this.bind(MinValidatorForNumber.class).in(Scopes.SINGLETON); - this.bind(MinValidatorForString.class).in(Scopes.SINGLETON); - this.bind(NotEmptyValidator.class).in(Scopes.SINGLETON); - this.bind(NotEmptyValidatorForCollection.class).in(Scopes.SINGLETON); - this.bind(NotEmptyValidatorForMap.class).in(Scopes.SINGLETON); - this.bind(NotEmptyValidatorForString.class).in(Scopes.SINGLETON); - this.bind(NotNullValidator.class).in(Scopes.SINGLETON); - this.bind(NullValidator.class).in(Scopes.SINGLETON); - this.bind(PastValidatorForCalendar.class).in(Scopes.SINGLETON); - this.bind(PastValidatorForDate.class).in(Scopes.SINGLETON); - this.bind(PatternValidator.class).in(Scopes.SINGLETON); - this.bind(SizeValidator.class).in(Scopes.SINGLETON); - this.bind(SizeValidatorForArrayOfBoolean.class).in(Scopes.SINGLETON); - this.bind(SizeValidatorForArrayOfByte.class).in(Scopes.SINGLETON); - this.bind(SizeValidatorForArrayOfChar.class).in(Scopes.SINGLETON); - this.bind(SizeValidatorForArrayOfDouble.class).in(Scopes.SINGLETON); - this.bind(SizeValidatorForArrayOfFloat.class).in(Scopes.SINGLETON); - this.bind(SizeValidatorForArrayOfInt.class).in(Scopes.SINGLETON); - this.bind(SizeValidatorForArrayOfLong.class).in(Scopes.SINGLETON); - this.bind(SizeValidatorForArrayOfObject.class).in(Scopes.SINGLETON); - this.bind(SizeValidatorForArrayOfShort.class).in(Scopes.SINGLETON); - this.bind(SizeValidatorForCollection.class).in(Scopes.SINGLETON); - this.bind(SizeValidatorForMap.class).in(Scopes.SINGLETON); - this.bind(SizeValidatorForString.class).in(Scopes.SINGLETON); - - // bootstrap this.bind(MessageInterpolator.class).to(DefaultMessageInterpolator.class).in(Scopes.SINGLETON); this.bind(TraversableResolver.class).to(DefaultTraversableResolver.class).in(Scopes.SINGLETON); this.bind(ConstraintValidatorFactory.class).to(GuiceAwareConstraintValidatorFactory.class); Added: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Country.java URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Country.java?rev=930290&view=auto ============================================================================== --- incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Country.java (added) +++ incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Country.java Fri Apr 2 15:00:10 2010 @@ -0,0 +1,64 @@ +/* + * 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.bval.extentions.guice; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +/** + * + * + * @version $Id$ + */ +public class Country { + + @NotNull + private String name; + + @Size(max = 2) + private String iso2Code; + + @Size(max = 3) + private String iso3Code; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getIso2Code() { + return iso2Code; + } + + public void setIso2Code(String iso2Code) { + this.iso2Code = iso2Code; + } + + public String getIso3Code() { + return iso3Code; + } + + public void setIso3Code(String iso3Code) { + this.iso3Code = iso3Code; + } + +} \ No newline at end of file Propchange: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Country.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Country.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Country.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/GuiceAwareValidationTestCase.java URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/GuiceAwareValidationTestCase.java?rev=930290&view=auto ============================================================================== --- incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/GuiceAwareValidationTestCase.java (added) +++ incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/GuiceAwareValidationTestCase.java Fri Apr 2 15:00:10 2010 @@ -0,0 +1,49 @@ +/* + * 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.bval.extentions.guice; + +import java.util.Set; + +import javax.validation.ConstraintViolation; +import javax.validation.Validator; + +import junit.framework.TestCase; + +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * + * + * @version $Id$ + */ +public final class GuiceAwareValidationTestCase extends TestCase { + + public void testInjectedValidation() { + Country country = new Country(); + country.setName("Italy"); + country.setIso2Code("it"); + country.setIso3Code("ita"); + + Injector injector = Guice.createInjector(new ValidationModule()); + Validator validator = injector.getInstance(Validator.class); + + Set> violations = validator.validate(country); + assertTrue(violations.isEmpty()); + } + +} Propchange: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/GuiceAwareValidationTestCase.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/GuiceAwareValidationTestCase.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/GuiceAwareValidationTestCase.java ------------------------------------------------------------------------------ svn:mime-type = text/plain