You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by ra...@apache.org on 2018/10/12 15:00:51 UTC
svn commit: r1843674 [3/22] - in /tomee/deps/branches/bval-2: ./ bundle/
bundle/src/ bundle/src/main/ bundle/src/main/appended-resources/
bundle/src/main/appended-resources/META-INF/ bval-extras/ bval-extras/src/
bval-extras/src/main/ bval-extras/src/m...
Added: tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/DomainValidator.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/DomainValidator.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/DomainValidator.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/DomainValidator.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,456 @@
+/*
+ * 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.extras.constraints.net;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import java.util.Arrays;
+import java.util.HashSet;
+
+/**
+ * <p><b>Domain name</b> validation routines.</p>
+ *
+ * <p>
+ * This validator provides methods for validating Internet domain names
+ * and top-level domains.
+ * </p>
+ *
+ * <p>Domain names are evaluated according
+ * to the standards <a href="http://www.ietf.org/rfc/rfc1034.txt">RFC1034</a>,
+ * section 3, and <a href="http://www.ietf.org/rfc/rfc1123.txt">RFC1123</a>,
+ * section 2.1. No accomodation is provided for the specialized needs of
+ * other applications; if the domain name has been URL-encoded, for example,
+ * validation will fail even though the equivalent plaintext version of the
+ * same name would have passed.
+ * </p>
+ *
+ * <p>
+ * Validation is also provided for top-level domains (TLDs) as defined and
+ * maintained by the Internet Assigned Numbers Authority (IANA):
+ * </p>
+ *
+ * <ul>
+ * <li>{@link #isValidInfrastructureTld} - validates infrastructure TLDs
+ * (<code>.arpa</code>, etc.)</li>
+ * <li>{@link #isValidGenericTld} - validates generic TLDs
+ * (<code>.com, .org</code>, etc.)</li>
+ * <li>{@link #isValidCountryCodeTld} - validates country code TLDs
+ * (<code>.us, .uk, .cn</code>, etc.)</li>
+ * </ul>
+ *
+ * <p>
+ * (<b>NOTE</b>: This class does not provide IP address lookup for domain names or
+ * methods to ensure that a given domain name matches a specific IP; see
+ * {@link java.net.InetAddress} for that functionality.)
+ * </p>
+ */
+public class DomainValidator implements ConstraintValidator<Domain, CharSequence> {
+
+ private boolean allowLocal;
+
+ // Regular expression strings for hostnames (derived from RFC2396 and RFC 1123)
+ private static final Pattern DOMAIN_LABEL = Pattern.compile("\\p{Alnum}(?>[\\p{Alnum}-]*\\p{Alnum})*");
+
+ private static final Pattern DOMAIN_NAME_REGEX =
+ Pattern.compile("^(?:" + DOMAIN_LABEL.pattern() + "\\.)+(\\p{Alpha}{2,})$");
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isValid(CharSequence domain, ConstraintValidatorContext context) {
+ Matcher matcher = DOMAIN_NAME_REGEX.matcher(domain);
+ if (matcher.matches()) {
+ domain = matcher.group(1);
+ return isValidTld(domain.toString());
+ }
+ return allowLocal && DOMAIN_LABEL.matcher(domain).matches();
+ }
+
+ /**
+ * Returns true if the specified <code>String</code> matches any
+ * IANA-defined top-level domain. Leading dots are ignored if present.
+ * The search is case-sensitive.
+ *
+ * @param tld the parameter to check for TLD status
+ * @return true if the parameter is a TLD
+ */
+ boolean isValidTld(String tld) {
+ if (allowLocal && isValidLocalTld(tld)) {
+ return true;
+ }
+
+ tld = chompLeadingDot(tld).toLowerCase();
+ return isValidInfrastructureTld(tld) || isValidGenericTld(tld) || isValidCountryCodeTld(tld);
+ }
+
+ /**
+ * Returns true if the specified <code>String</code> matches any
+ * IANA-defined infrastructure top-level domain. Leading dots are
+ * ignored if present. The search is case-sensitive.
+ *
+ * @param iTld the parameter to check for infrastructure TLD status
+ * @return true if the parameter is an infrastructure TLD
+ */
+ static boolean isValidInfrastructureTld(String iTld) {
+ return INFRASTRUCTURE_TLDS.contains(iTld);
+ }
+
+ /**
+ * Returns true if the specified <code>String</code> matches any
+ * IANA-defined generic top-level domain. Leading dots are ignored
+ * if present. The search is case-sensitive.
+ *
+ * @param gTld the parameter to check for generic TLD status
+ * @return true if the parameter is a generic TLD
+ */
+ static boolean isValidGenericTld(String gTld) {
+ return GENERIC_TLDS.contains(gTld);
+ }
+
+ /**
+ * Returns true if the specified <code>String</code> matches any
+ * IANA-defined country code top-level domain. Leading dots are
+ * ignored if present. The search is case-sensitive.
+ *
+ * @param ccTld the parameter to check for country code TLD status
+ * @return true if the parameter is a country code TLD
+ */
+ static boolean isValidCountryCodeTld(String ccTld) {
+ return COUNTRY_CODE_TLDS.contains(ccTld);
+ }
+
+ /**
+ * Returns true if the specified <code>String</code> matches any
+ * widely used "local" domains (localhost or localdomain). Leading dots are
+ * ignored if present. The search is case-sensitive.
+ *
+ * @param iTld the parameter to check for local TLD status
+ * @return true if the parameter is an local TLD
+ */
+ static boolean isValidLocalTld(String iTld) {
+ return LOCAL_TLDS.contains(iTld);
+ }
+
+ private static String chompLeadingDot(String str) {
+ if (str.charAt(0) == '.') {
+ return str.substring(1);
+ }
+ return str;
+ }
+
+ // ---------------------------------------------
+ // ----- TLDs defined by IANA
+ // ----- Authoritative and comprehensive list at:
+ // ----- http://data.iana.org/TLD/tlds-alpha-by-domain.txt
+
+ private static final Set<String> INFRASTRUCTURE_TLDS = new HashSet<>(Arrays.asList("arpa", // internet infrastructure
+ "root" // diagnostic marker for non-truncated root zone
+ ));
+
+ private static final Set<String> GENERIC_TLDS = new HashSet<>(Arrays.asList("aero", // air transport industry
+ "asia", // Pan-Asia/Asia Pacific
+ "biz", // businesses
+ "cat", // Catalan linguistic/cultural community
+ "com", // commercial enterprises
+ "coop", // cooperative associations
+ "info", // informational sites
+ "jobs", // Human Resource managers
+ "mobi", // mobile products and services
+ "museum", // museums, surprisingly enough
+ "name", // individuals' sites
+ "net", // internet support infrastructure/business
+ "org", // noncommercial organizations
+ "pro", // credentialed professionals and entities
+ "tel", // contact data for businesses and individuals
+ "travel", // entities in the travel industry
+ "gov", // United States Government
+ "edu", // accredited postsecondary US education entities
+ "mil", // United States Military
+ "int" // organizations established by international treaty
+ ));
+
+ private static final Set<String> COUNTRY_CODE_TLDS = new HashSet<>(Arrays.asList("ac", // Ascension Island
+ "ad", // Andorra
+ "ae", // United Arab Emirates
+ "af", // Afghanistan
+ "ag", // Antigua and Barbuda
+ "ai", // Anguilla
+ "al", // Albania
+ "am", // Armenia
+ "an", // Netherlands Antilles
+ "ao", // Angola
+ "aq", // Antarctica
+ "ar", // Argentina
+ "as", // American Samoa
+ "at", // Austria
+ "au", // Australia (includes Ashmore and Cartier Islands and Coral Sea Islands)
+ "aw", // Aruba
+ "ax", // Ã
land
+ "az", // Azerbaijan
+ "ba", // Bosnia and Herzegovina
+ "bb", // Barbados
+ "bd", // Bangladesh
+ "be", // Belgium
+ "bf", // Burkina Faso
+ "bg", // Bulgaria
+ "bh", // Bahrain
+ "bi", // Burundi
+ "bj", // Benin
+ "bm", // Bermuda
+ "bn", // Brunei Darussalam
+ "bo", // Bolivia
+ "br", // Brazil
+ "bs", // Bahamas
+ "bt", // Bhutan
+ "bv", // Bouvet Island
+ "bw", // Botswana
+ "by", // Belarus
+ "bz", // Belize
+ "ca", // Canada
+ "cc", // Cocos (Keeling) Islands
+ "cd", // Democratic Republic of the Congo (formerly Zaire)
+ "cf", // Central African Republic
+ "cg", // Republic of the Congo
+ "ch", // Switzerland
+ "ci", // Côte d'Ivoire
+ "ck", // Cook Islands
+ "cl", // Chile
+ "cm", // Cameroon
+ "cn", // China, mainland
+ "co", // Colombia
+ "cr", // Costa Rica
+ "cu", // Cuba
+ "cv", // Cape Verde
+ "cx", // Christmas Island
+ "cy", // Cyprus
+ "cz", // Czech Republic
+ "de", // Germany
+ "dj", // Djibouti
+ "dk", // Denmark
+ "dm", // Dominica
+ "do", // Dominican Republic
+ "dz", // Algeria
+ "ec", // Ecuador
+ "ee", // Estonia
+ "eg", // Egypt
+ "er", // Eritrea
+ "es", // Spain
+ "et", // Ethiopia
+ "eu", // European Union
+ "fi", // Finland
+ "fj", // Fiji
+ "fk", // Falkland Islands
+ "fm", // Federated States of Micronesia
+ "fo", // Faroe Islands
+ "fr", // France
+ "ga", // Gabon
+ "gb", // Great Britain (United Kingdom)
+ "gd", // Grenada
+ "ge", // Georgia
+ "gf", // French Guiana
+ "gg", // Guernsey
+ "gh", // Ghana
+ "gi", // Gibraltar
+ "gl", // Greenland
+ "gm", // The Gambia
+ "gn", // Guinea
+ "gp", // Guadeloupe
+ "gq", // Equatorial Guinea
+ "gr", // Greece
+ "gs", // South Georgia and the South Sandwich Islands
+ "gt", // Guatemala
+ "gu", // Guam
+ "gw", // Guinea-Bissau
+ "gy", // Guyana
+ "hk", // Hong Kong
+ "hm", // Heard Island and McDonald Islands
+ "hn", // Honduras
+ "hr", // Croatia (Hrvatska)
+ "ht", // Haiti
+ "hu", // Hungary
+ "id", // Indonesia
+ "ie", // Ireland (Ãire)
+ "il", // Israel
+ "im", // Isle of Man
+ "in", // India
+ "io", // British Indian Ocean Territory
+ "iq", // Iraq
+ "ir", // Iran
+ "is", // Iceland
+ "it", // Italy
+ "je", // Jersey
+ "jm", // Jamaica
+ "jo", // Jordan
+ "jp", // Japan
+ "ke", // Kenya
+ "kg", // Kyrgyzstan
+ "kh", // Cambodia (Khmer)
+ "ki", // Kiribati
+ "km", // Comoros
+ "kn", // Saint Kitts and Nevis
+ "kp", // North Korea
+ "kr", // South Korea
+ "kw", // Kuwait
+ "ky", // Cayman Islands
+ "kz", // Kazakhstan
+ "la", // Laos (currently being marketed as the official domain for Los Angeles)
+ "lb", // Lebanon
+ "lc", // Saint Lucia
+ "li", // Liechtenstein
+ "lk", // Sri Lanka
+ "lr", // Liberia
+ "ls", // Lesotho
+ "lt", // Lithuania
+ "lu", // Luxembourg
+ "lv", // Latvia
+ "ly", // Libya
+ "ma", // Morocco
+ "mc", // Monaco
+ "md", // Moldova
+ "me", // Montenegro
+ "mg", // Madagascar
+ "mh", // Marshall Islands
+ "mk", // Republic of Macedonia
+ "ml", // Mali
+ "mm", // Myanmar
+ "mn", // Mongolia
+ "mo", // Macau
+ "mp", // Northern Mariana Islands
+ "mq", // Martinique
+ "mr", // Mauritania
+ "ms", // Montserrat
+ "mt", // Malta
+ "mu", // Mauritius
+ "mv", // Maldives
+ "mw", // Malawi
+ "mx", // Mexico
+ "my", // Malaysia
+ "mz", // Mozambique
+ "na", // Namibia
+ "nc", // New Caledonia
+ "ne", // Niger
+ "nf", // Norfolk Island
+ "ng", // Nigeria
+ "ni", // Nicaragua
+ "nl", // Netherlands
+ "no", // Norway
+ "np", // Nepal
+ "nr", // Nauru
+ "nu", // Niue
+ "nz", // New Zealand
+ "om", // Oman
+ "pa", // Panama
+ "pe", // Peru
+ "pf", // French Polynesia With Clipperton Island
+ "pg", // Papua New Guinea
+ "ph", // Philippines
+ "pk", // Pakistan
+ "pl", // Poland
+ "pm", // Saint-Pierre and Miquelon
+ "pn", // Pitcairn Islands
+ "pr", // Puerto Rico
+ "ps", // Palestinian territories (PA-controlled West Bank and Gaza Strip)
+ "pt", // Portugal
+ "pw", // Palau
+ "py", // Paraguay
+ "qa", // Qatar
+ "re", // Réunion
+ "ro", // Romania
+ "rs", // Serbia
+ "ru", // Russia
+ "rw", // Rwanda
+ "sa", // Saudi Arabia
+ "sb", // Solomon Islands
+ "sc", // Seychelles
+ "sd", // Sudan
+ "se", // Sweden
+ "sg", // Singapore
+ "sh", // Saint Helena
+ "si", // Slovenia
+ "sj", // Svalbard and Jan Mayen Islands Not in use (Norwegian dependencies; see .no)
+ "sk", // Slovakia
+ "sl", // Sierra Leone
+ "sm", // San Marino
+ "sn", // Senegal
+ "so", // Somalia
+ "sr", // Suriname
+ "st", // São Tomé and PrÃncipe
+ "su", // Soviet Union (deprecated)
+ "sv", // El Salvador
+ "sy", // Syria
+ "sz", // Swaziland
+ "tc", // Turks and Caicos Islands
+ "td", // Chad
+ "tf", // French Southern and Antarctic Lands
+ "tg", // Togo
+ "th", // Thailand
+ "tj", // Tajikistan
+ "tk", // Tokelau
+ "tl", // East Timor (deprecated old code)
+ "tm", // Turkmenistan
+ "tn", // Tunisia
+ "to", // Tonga
+ "tp", // East Timor
+ "tr", // Turkey
+ "tt", // Trinidad and Tobago
+ "tv", // Tuvalu
+ "tw", // Taiwan, Republic of China
+ "tz", // Tanzania
+ "ua", // Ukraine
+ "ug", // Uganda
+ "uk", // United Kingdom
+ "um", // United States Minor Outlying Islands
+ "us", // United States of America
+ "uy", // Uruguay
+ "uz", // Uzbekistan
+ "va", // Vatican City State
+ "vc", // Saint Vincent and the Grenadines
+ "ve", // Venezuela
+ "vg", // British Virgin Islands
+ "vi", // U.S. Virgin Islands
+ "vn", // Vietnam
+ "vu", // Vanuatu
+ "wf", // Wallis and Futuna
+ "ws", // Samoa (formerly Western Samoa)
+ "ye", // Yemen
+ "yt", // Mayotte
+ "yu", // Serbia and Montenegro (originally Yugoslavia)
+ "za", // South Africa
+ "zm", // Zambia
+ "zw" // Zimbabwe
+ ));
+
+ private static final Set<String> LOCAL_TLDS = new HashSet<>(Arrays.asList("localhost", // RFC2606 defined
+ "localdomain" // Also widely used as localhost.localdomain
+ ));
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void initialize(Domain domain) {
+ allowLocal = domain.allowLocal();
+ }
+
+}
Added: tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/InetAddress.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/InetAddress.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/InetAddress.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/InetAddress.java Fri Oct 12 15:00:48 2018
@@ -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.bval.extras.constraints.net;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * <p>
+ * --
+ * TODO - This class is NOT part of the bean_validation spec and might disappear
+ * as soon as a final version of the specification contains a similar functionality.
+ * --
+ * </p>
+ * Description: annotation to validate a java.io.File is a directory<br/>
+ */
+@Documented
+@Constraint(validatedBy = InetAddressValidator.class)
+@Target({ FIELD, ANNOTATION_TYPE, PARAMETER })
+@Retention(RUNTIME)
+public @interface InetAddress {
+
+ Class<?>[] groups() default {};
+
+ String message() default "{org.apache.bval.extras.constraints.net.InetAddress.message}";
+
+ Class<? extends Payload>[] payload() default {};
+
+}
Added: tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/InetAddressValidator.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/InetAddressValidator.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/InetAddressValidator.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/InetAddressValidator.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,56 @@
+/*
+ * 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.extras.constraints.net;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import java.util.regex.Pattern;
+
+/**
+ * <p><b>InetAddress</b> validation and conversion routines (<code>java.net.InetAddress</code>).</p>
+ *
+ * <p>This class provides methods to validate a candidate IP address.
+ */
+public class InetAddressValidator implements ConstraintValidator<InetAddress, CharSequence> {
+
+ private static final Pattern IPV4_PATTERN =
+ Pattern.compile("^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
+ + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$");
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isValid(CharSequence value, ConstraintValidatorContext context) {
+ if (!IPV4_PATTERN.matcher(value).matches()) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void initialize(InetAddress parameters) {
+ // do nothing (as long as InetAddress has no properties)
+ }
+
+}
Added: tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/package-info.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/package-info.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/package-info.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/net/package-info.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * net constraints validators.
+ */
+package org.apache.bval.extras.constraints.net;
Added: tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/package-info.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/package-info.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/package-info.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/main/java/org/apache/bval/extras/constraints/package-info.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+/**
+ * Contains constraints that are NOT part of the Bean Validation specification
+ * and might disappear as soon as a final version of the specification contains
+ * similar functionalities.
+ */
+package org.apache.bval.extras.constraints;
Added: tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/ABANumberValidatorTest.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/ABANumberValidatorTest.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/ABANumberValidatorTest.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/ABANumberValidatorTest.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,37 @@
+/*
+ * 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.extras.constraints.checkdigit;
+
+import javax.validation.ConstraintValidator;
+import java.lang.annotation.Annotation;
+
+/**
+ * ABA Number Validator Test.
+ */
+public class ABANumberValidatorTest extends AbstractCheckDigitTest {
+
+ @Override
+ protected ConstraintValidator<? extends Annotation, ? super String> getConstraint() {
+ return new ABANumberValidator();
+ }
+
+ @Override
+ protected String[] getValid() {
+ return new String[] { "123456780", "123123123", "011000015", "111000038", "231381116", "121181976" };
+ }
+
+}
Added: tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/AbstractCheckDigitTest.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/AbstractCheckDigitTest.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/AbstractCheckDigitTest.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/AbstractCheckDigitTest.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,190 @@
+/*
+ * 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.extras.constraints.checkdigit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.validation.ConstraintValidator;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ *
+ */
+public abstract class AbstractCheckDigitTest {
+
+ /** Check digit routine being tested */
+ private int checkDigitLth;
+
+ /** Check digit routine being tested */
+ private ConstraintValidator<? extends Annotation, ? super String> routine;
+
+ /** Array of valid code values */
+ private String[] valid;
+
+ /** Array of invalid code values */
+ private String[] invalid;
+
+ /** code value which sums to zero */
+ private String zeroSum;
+
+ /** Prefix for error messages */
+ private String missingMessage;
+
+ public int getCheckDigitLth() {
+ return 1;
+ }
+
+ protected abstract ConstraintValidator<? extends Annotation, ? super String> getConstraint();
+
+ protected abstract String[] getValid();
+
+ protected String[] getInvalid() {
+ return new String[] { "12345678A" };
+ }
+
+ protected String getZeroSum() {
+ return "0000000000";
+ }
+
+ public String getMissingMessage() {
+ return "Code is missing";
+ }
+
+ @Before
+ public void setUp() {
+ checkDigitLth = getCheckDigitLth();
+ routine = getConstraint();
+ valid = getValid();
+ invalid = getInvalid();
+ zeroSum = getZeroSum();
+ missingMessage = getMissingMessage();
+ }
+
+ /**
+ * Tear Down - clears routine and valid codes.
+ */
+ @After
+ public void tearDown() {
+ valid = null;
+ routine = null;
+ }
+
+ /**
+ * Test isValid() for valid values.
+ */
+ @Test
+ public void testIsValidTrue() {
+ // test valid values
+ for (int i = 0; i < valid.length; i++) {
+ assertTrue("valid[" + i + "]: " + valid[i], routine.isValid(valid[i], null));
+ }
+ }
+
+ /**
+ * Test isValid() for invalid values.
+ */
+ @Test
+ public void testIsValidFalse() {
+ // test invalid code values
+ for (int i = 0; i < invalid.length; i++) {
+ assertFalse("invalid[" + i + "]: " + invalid[i], routine.isValid(invalid[i], null));
+ }
+
+ // test invalid check digit values
+ String[] invalidCheckDigits = createInvalidCodes(valid);
+ for (int i = 0; i < invalidCheckDigits.length; i++) {
+ assertFalse("invalid check digit[" + i + "]: " + invalidCheckDigits[i],
+ routine.isValid(invalidCheckDigits[i], null));
+ }
+ }
+
+ /**
+ * Test missing code
+ */
+ @Test
+ public void testMissingCode() {
+ // isValid() zero length
+ assertFalse("isValid() Zero Length", routine.isValid("", null));
+ }
+
+ /**
+ * Test zero sum
+ */
+ @Test
+ public void testZeroSum() {
+ assertFalse("isValid() Zero Sum", routine.isValid(zeroSum, null));
+ }
+
+ /**
+ * Returns an array of codes with invalid check digits.
+ *
+ * @param codes Codes with valid check digits
+ * @return Codes with invalid check digits
+ */
+ protected String[] createInvalidCodes(String[] codes) {
+ List<String> list = new ArrayList<String>();
+
+ // create invalid check digit values
+ for (int i = 0; i < codes.length; i++) {
+ String code = removeCheckDigit(codes[i]);
+ String check = checkDigit(codes[i]);
+ for (int j = 0; j < 10; j++) {
+ String curr = "" + Character.forDigit(j, 10);
+ if (!curr.equals(check)) {
+ list.add(code + curr);
+ }
+ }
+ }
+
+ return list.toArray(new String[list.size()]);
+ }
+
+ /**
+ * Returns a code with the Check Digit (i.e. last character) removed.
+ *
+ * @param code The code
+ * @return The code without the check digit
+ */
+ protected String removeCheckDigit(String code) {
+ if (code == null || code.length() <= checkDigitLth) {
+ return null;
+ }
+ return code.substring(0, code.length() - checkDigitLth);
+ }
+
+ /**
+ * Returns the check digit (i.e. last character) for a code.
+ *
+ * @param code The code
+ * @return The check digit
+ */
+ protected String checkDigit(String code) {
+ if (code == null || code.length() <= checkDigitLth) {
+ return "";
+ }
+ int start = code.length() - checkDigitLth;
+ return code.substring(start);
+ }
+
+}
Added: tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/CUSIPValidatorTest.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/CUSIPValidatorTest.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/CUSIPValidatorTest.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/CUSIPValidatorTest.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,42 @@
+/*
+ * 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.extras.constraints.checkdigit;
+
+import javax.validation.ConstraintValidator;
+import java.lang.annotation.Annotation;
+
+/**
+ * CUSIP Check Digit Test.
+ */
+public class CUSIPValidatorTest extends AbstractCheckDigitTest {
+
+ @Override
+ protected ConstraintValidator<? extends Annotation, ? super String> getConstraint() {
+ return new CUSIPValidator();
+ }
+
+ @Override
+ protected String[] getValid() {
+ return new String[] { "037833100", "931142103", "837649128", "392690QT3", "594918104", "86770G101", "Y8295N109",
+ "G8572F100" };
+ }
+
+ @Override
+ protected String[] getInvalid() {
+ return new String[] { "0378#3100" };
+ }
+}
Added: tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/EAN13CheckDigitTest.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/EAN13CheckDigitTest.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/EAN13CheckDigitTest.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/EAN13CheckDigitTest.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,42 @@
+/*
+ * 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.extras.constraints.checkdigit;
+
+import javax.validation.ConstraintValidator;
+import java.lang.annotation.Annotation;
+
+/**
+ * EAN-13 Check Digit Test.
+ */
+public class EAN13CheckDigitTest extends AbstractCheckDigitTest {
+
+ @Override
+ protected ConstraintValidator<? extends Annotation, ? super String> getConstraint() {
+ return new EAN13Validator();
+ }
+
+ @Override
+ protected String[] getValid() {
+ return new String[] {
+ "9780072129519",
+ "9780764558313",
+ "4025515373438",
+ "0095673400332"
+ };
+ }
+
+}
Added: tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/IBANCheckDigitTest.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/IBANCheckDigitTest.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/IBANCheckDigitTest.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/IBANCheckDigitTest.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,150 @@
+/*
+ * 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.extras.constraints.checkdigit;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import javax.validation.ConstraintValidator;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * IVAN Check Digit Test.
+ */
+public class IBANCheckDigitTest extends AbstractCheckDigitTest {
+
+ @Override
+ public int getCheckDigitLth() {
+ return 2;
+ }
+
+ @Override
+ protected ConstraintValidator<? extends Annotation, ? super String> getConstraint() {
+ return new IBANValidator();
+ }
+
+ @Override
+ protected String[] getValid() {
+ return new String[] {
+ "AD1200012030200359100100",
+ "AT611904300234573201",
+ "AT611904300234573201",
+ "BE68539007547034",
+ "BE62510007547061",
+ "CY17002001280000001200527600",
+ "CZ6508000000192000145399",
+ "DK5000400440116243",
+ "EE382200221020145685",
+ "FI2112345600000785",
+ "FR1420041010050500013M02606",
+ "DE89370400440532013000",
+ "GI75NWBK000000007099453",
+ "GR1601101250000000012300695",
+ "HU42117730161111101800000000",
+ "IS140159260076545510730339",
+ "IE29AIBK93115212345678",
+ "IT60X0542811101000000123456",
+ "LV80BANK0000435195001",
+ "LT121000011101001000",
+ "LU280019400644750000",
+ "NL91ABNA0417164300",
+ "NO9386011117947",
+ "PL27114020040000300201355387",
+ "PT50000201231234567890154",
+ "SK3112000000198742637541",
+ "SI56191000000123438",
+ "ES8023100001180000012345",
+ "SE3550000000054910000003",
+ "CH3900700115201849173",
+ "GB29NWBK60161331926819"
+ };
+ }
+
+ @Override
+ protected String[] getInvalid() {
+ return new String[] {"510007+47061BE63"};
+ }
+
+ @Override
+ protected String getZeroSum() {
+ return null;
+ }
+
+ @Override
+ public String getMissingMessage() {
+ return "Invalid Code length=0";
+ }
+
+ /**
+ * Test zero sum
+ */
+ @Override
+ @Test
+ @Ignore
+ public void testZeroSum() {
+ // ignore, don't run this test
+ }
+
+ @Override
+ protected String[] createInvalidCodes( String[] codes ) {
+ List<String> list = new ArrayList<String>();
+
+ // create invalid check digit values
+ for (int i = 0; i < codes.length; i++) {
+ String code = removeCheckDigit(codes[i]);
+ String check = checkDigit(codes[i]);
+ for (int j = 0; j < 96; j++) {
+ String curr = j > 9 ? "" + j : "0" + j;
+ if (!curr.equals(check)) {
+ list.add(code.substring(0, 2) + curr + code.substring(4));
+ }
+ }
+ }
+
+ return list.toArray(new String[list.size()]);
+ }
+
+
+
+ /**
+ * Returns a code with the Check Digit (i.e. last character) removed.
+ *
+ * @param code The code
+ * @return The code without the check digit
+ */
+ @Override
+ protected String removeCheckDigit(String code) {
+ return code.substring(0, 2) + "00" + code.substring(4);
+ }
+
+ /**
+ * Returns the check digit (i.e. last character) for a code.
+ *
+ * @param code The code
+ * @return The check digit
+ */
+ @Override
+ protected String checkDigit(String code) {
+ if (code == null || code.length() <= getCheckDigitLth()) {
+ return "";
+ }
+ return code.substring(2, 4);
+ }
+
+}
Added: tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/ISBN10CheckDigitTest.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/ISBN10CheckDigitTest.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/ISBN10CheckDigitTest.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/ISBN10CheckDigitTest.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,42 @@
+/*
+ * 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.extras.constraints.checkdigit;
+
+import javax.validation.ConstraintValidator;
+import java.lang.annotation.Annotation;
+
+/**
+ * ISBN-10 Check Digit Test.
+ */
+public class ISBN10CheckDigitTest extends AbstractCheckDigitTest {
+
+ @Override
+ protected ConstraintValidator<? extends Annotation, ? super String> getConstraint() {
+ return new ISBN10Validator();
+ }
+
+ @Override
+ protected String[] getValid() {
+ return new String[] {
+ "1930110995",
+ "020163385X",
+ "1932394354",
+ "1590596277"
+ };
+ }
+
+}
Added: tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/LuhnCheckDigitTest.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/LuhnCheckDigitTest.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/LuhnCheckDigitTest.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/LuhnCheckDigitTest.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,56 @@
+/*
+ * 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.extras.constraints.checkdigit;
+
+import javax.validation.ConstraintValidator;
+import java.lang.annotation.Annotation;
+
+/**
+ * Luhn Check Digit Test.
+ */
+public class LuhnCheckDigitTest extends AbstractCheckDigitTest {
+
+ private static final String VALID_VISA = "4417123456789113";
+
+ private static final String VALID_SHORT_VISA = "4222222222222";
+
+ private static final String VALID_AMEX = "378282246310005";
+
+ private static final String VALID_MASTERCARD = "5105105105105100";
+
+ private static final String VALID_DISCOVER = "6011000990139424";
+
+ private static final String VALID_DINERS = "30569309025904";
+
+ @Override
+ protected ConstraintValidator<? extends Annotation, ? super String> getConstraint() {
+ return new LuhnValidator();
+ }
+
+ @Override
+ protected String[] getValid() {
+ return new String[] {
+ VALID_VISA,
+ VALID_SHORT_VISA,
+ VALID_AMEX,
+ VALID_MASTERCARD,
+ VALID_DISCOVER,
+ VALID_DINERS
+ };
+ }
+
+}
Added: tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/SedolCheckDigitTest.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/SedolCheckDigitTest.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/SedolCheckDigitTest.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/SedolCheckDigitTest.java Fri Oct 12 15:00:48 2018
@@ -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.bval.extras.constraints.checkdigit;
+
+import javax.validation.ConstraintValidator;
+import java.lang.annotation.Annotation;
+
+/**
+ * Sedol Check Digit Test.
+ */
+public class SedolCheckDigitTest extends AbstractCheckDigitTest {
+
+ @Override
+ protected ConstraintValidator<? extends Annotation, ? super String> getConstraint() {
+ return new SedolValidator();
+ }
+
+ @Override
+ protected String[] getValid() {
+ return new String[] {
+ "0263494",
+ "0870612",
+ "B06LQ97",
+ "3437575",
+ "B07LF55",
+ };
+ }
+
+ @Override
+ protected String[] getInvalid() {
+ return new String[] {"123#567"};
+ }
+
+ @Override
+ protected String getZeroSum() {
+ return "0000000";
+ }
+
+}
Added: tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/VerhoeffCheckDigitTest.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/VerhoeffCheckDigitTest.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/VerhoeffCheckDigitTest.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/VerhoeffCheckDigitTest.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,54 @@
+/*
+ * 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.extras.constraints.checkdigit;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import javax.validation.ConstraintValidator;
+import java.lang.annotation.Annotation;
+
+/**
+ * Verhoeff Check Digit Test.
+ */
+public class VerhoeffCheckDigitTest extends AbstractCheckDigitTest {
+
+ @Override
+ protected ConstraintValidator<? extends Annotation, ? super String> getConstraint() {
+ return new VerhoeffValidator();
+ }
+
+ @Override
+ protected String[] getValid() {
+ return new String[] {
+ "15",
+ "1428570",
+ "12345678902"
+ };
+ }
+
+ /**
+ * Test zero sum
+ */
+ @Override
+ @Test
+ @Ignore
+ public void testZeroSum() {
+ // ignore, don't run this test
+ }
+
+}
Added: tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/net/DomainValidatorTest.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/net/DomainValidatorTest.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/net/DomainValidatorTest.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/net/DomainValidatorTest.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,154 @@
+/*
+ * 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.extras.constraints.net;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.validation.Payload;
+import java.lang.annotation.Annotation;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests for the DomainValidator.
+ */
+public class DomainValidatorTest {
+
+ private DomainValidator validator;
+
+ @Before
+ public void setUp() {
+ validator = new DomainValidator();
+ }
+
+ @Test
+ public void testValidDomains() {
+ assertTrue("apache.org should validate", validator.isValid("apache.org", null));
+ assertTrue("www.google.com should validate", validator.isValid("www.google.com", null));
+
+ assertTrue("test-domain.com should validate", validator.isValid("test-domain.com", null));
+ assertTrue("test---domain.com should validate", validator.isValid("test---domain.com", null));
+ assertTrue("test-d-o-m-ain.com should validate", validator.isValid("test-d-o-m-ain.com", null));
+ assertTrue("two-letter domain label should validate", validator.isValid("as.uk", null));
+
+ assertTrue("case-insensitive ApAchE.Org should validate", validator.isValid("ApAchE.Org", null));
+
+ assertTrue("single-character domain label should validate", validator.isValid("z.com", null));
+
+ assertTrue("i.have.an-example.domain.name should validate",
+ validator.isValid("i.have.an-example.domain.name", null));
+ }
+
+ @Test
+ public void testInvalidDomains() {
+ assertFalse("bare TLD .org shouldn't validate", validator.isValid(".org", null));
+ assertFalse("domain name with spaces shouldn't validate", validator.isValid(" apache.org ", null));
+ assertFalse("domain name containing spaces shouldn't validate", validator.isValid("apa che.org", null));
+ assertFalse("domain name starting with dash shouldn't validate", validator.isValid("-testdomain.name", null));
+ assertFalse("domain name ending with dash shouldn't validate", validator.isValid("testdomain-.name", null));
+ assertFalse("domain name starting with multiple dashes shouldn't validate",
+ validator.isValid("---c.com", null));
+ assertFalse("domain name ending with multiple dashes shouldn't validate", validator.isValid("c--.com", null));
+ assertFalse("domain name with invalid TLD shouldn't validate", validator.isValid("apache.rog", null));
+
+ assertFalse("URL shouldn't validate", validator.isValid("http://www.apache.org", null));
+ assertFalse("Empty string shouldn't validate as domain name", validator.isValid(" ", null));
+ }
+
+ @Test
+ public void testTopLevelDomains() {
+ // infrastructure TLDs
+ assertTrue(".arpa should validate as iTLD", DomainValidator.isValidInfrastructureTld("arpa"));
+ assertFalse(".com shouldn't validate as iTLD", DomainValidator.isValidInfrastructureTld("com"));
+
+ // generic TLDs
+ assertTrue(".name should validate as gTLD", DomainValidator.isValidGenericTld("name"));
+ assertFalse(".us shouldn't validate as gTLD", DomainValidator.isValidGenericTld("us"));
+
+ // country code TLDs
+ assertTrue(".uk should validate as ccTLD", DomainValidator.isValidCountryCodeTld("uk"));
+ assertFalse(".org shouldn't validate as ccTLD", DomainValidator.isValidCountryCodeTld("org"));
+
+ // case-insensitive
+ assertTrue(".COM should validate as TLD", validator.isValidTld("COM"));
+ assertTrue(".BiZ should validate as TLD", validator.isValidTld("BiZ"));
+
+ // corner cases
+ assertFalse("invalid TLD shouldn't validate", validator.isValid("nope", null));
+ assertFalse("empty string shouldn't validate as TLD", validator.isValid("", null));
+ }
+
+ @Test
+ public void testAllowLocal() {
+ DomainValidator noLocal = new DomainValidator();
+ DomainValidator allowLocal = new DomainValidator();
+ allowLocal.initialize(new Domain() {
+
+ @Override
+ public Class<? extends Annotation> annotationType() {
+ // not needed
+ return null;
+ }
+
+ @Override
+ public Class<? extends Payload>[] payload() {
+ // not needed
+ return null;
+ }
+
+ @Override
+ public String message() {
+ // not needed
+ return null;
+ }
+
+ @Override
+ public Class<?>[] groups() {
+ // not needed
+ return null;
+ }
+
+ @Override
+ public boolean allowLocal() {
+ // enable the local
+ return true;
+ }
+ });
+
+ // Default won't allow local
+ assertFalse("localhost.localdomain should validate", noLocal.isValid("localhost.localdomain", null));
+ assertFalse("localhost should validate", noLocal.isValid("localhost", null));
+
+ // But it may be requested
+ assertTrue("localhost.localdomain should validate", allowLocal.isValid("localhost.localdomain", null));
+ assertTrue("localhost should validate", allowLocal.isValid("localhost", null));
+ assertTrue("hostname should validate", allowLocal.isValid("hostname", null));
+ assertTrue("machinename should validate", allowLocal.isValid("machinename", null));
+
+ // Check the localhost one with a few others
+ assertTrue("apache.org should validate", allowLocal.isValid("apache.org", null));
+ assertFalse("domain name with spaces shouldn't validate", allowLocal.isValid(" apache.org ", null));
+ }
+
+ @Test
+ public void testIDN() {
+ assertTrue("b\u00fccher.ch in IDN should validate", validator.isValid("www.xn--bcher-kva.ch", null));
+ }
+
+}
Added: tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/net/InetAddressValidatorTest.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/net/InetAddressValidatorTest.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/net/InetAddressValidatorTest.java (added)
+++ tomee/deps/branches/bval-2/bval-extras/src/test/java/org/apache/bval/extras/constraints/net/InetAddressValidatorTest.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,90 @@
+/*
+ * 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.extras.constraints.net;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test cases for InetAddressValidator.
+ */
+public class InetAddressValidatorTest {
+
+ private InetAddressValidator validator;
+
+ @Before
+ public void setUp() {
+ validator = new InetAddressValidator();
+ }
+
+ /**
+ * Test IPs that point to real, well-known hosts (without actually looking them up).
+ */
+ @Test
+ public void testInetAddressesFromTheWild() {
+ assertTrue("www.apache.org IP should be valid", validator.isValid("140.211.11.130", null));
+ assertTrue("www.l.google.com IP should be valid", validator.isValid("72.14.253.103", null));
+ assertTrue("fsf.org IP should be valid", validator.isValid("199.232.41.5", null));
+ assertTrue("appscs.ign.com IP should be valid", validator.isValid("216.35.123.87", null));
+ }
+
+ /**
+ * Test valid and invalid IPs from each address class.
+ */
+ @Test
+ public void testInetAddressesByClass() {
+ assertTrue("class A IP should be valid", validator.isValid("24.25.231.12", null));
+ assertFalse("illegal class A IP should be invalid", validator.isValid("2.41.32.324", null));
+
+ assertTrue("class B IP should be valid", validator.isValid("135.14.44.12", null));
+ assertFalse("illegal class B IP should be invalid", validator.isValid("154.123.441.123", null));
+
+ assertTrue("class C IP should be valid", validator.isValid("213.25.224.32", null));
+ assertFalse("illegal class C IP should be invalid", validator.isValid("201.543.23.11", null));
+
+ assertTrue("class D IP should be valid", validator.isValid("229.35.159.6", null));
+ assertFalse("illegal class D IP should be invalid", validator.isValid("231.54.11.987", null));
+
+ assertTrue("class E IP should be valid", validator.isValid("248.85.24.92", null));
+ assertFalse("illegal class E IP should be invalid", validator.isValid("250.21.323.48", null));
+ }
+
+ /**
+ * Test reserved IPs.
+ */
+ @Test
+ public void testReservedInetAddresses() {
+ assertTrue("localhost IP should be valid", validator.isValid("127.0.0.1", null));
+ assertTrue("broadcast IP should be valid", validator.isValid("255.255.255.255", null));
+ }
+
+ /**
+ * Test obviously broken IPs.
+ */
+ @Test
+ public void testBrokenInetAddresses() {
+ assertFalse("IP with characters should be invalid", validator.isValid("124.14.32.abc", null));
+ assertFalse("IP with three groups should be invalid", validator.isValid("23.64.12", null));
+ assertFalse("IP with five groups should be invalid", validator.isValid("26.34.23.77.234", null));
+ }
+
+}
Added: tomee/deps/branches/bval-2/bval-jsr/pom.xml
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/pom.xml?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/pom.xml (added)
+++ tomee/deps/branches/bval-2/bval-jsr/pom.xml Fri Oct 12 15:00:48 2018
@@ -0,0 +1,331 @@
+<?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.
+-->
+<!--
+ Maven release plugin requires the project tag to be on a single line.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.bval</groupId>
+ <artifactId>bval-parent</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>bval-jsr</artifactId>
+ <name>Apache BVal :: bval-jsr</name>
+ <packaging>jar</packaging>
+
+ <description>Implementation specific classes for JSR 349 Bean Validation 1.1</description>
+
+ <properties>
+ <jaxb.version>2.2.6</jaxb.version>
+ </properties>
+ <profiles>
+ <!--
+ default profile using geronimo-validation_2.0_spec.jar active when
+ property "ri" is not present.
+ -->
+ <profile>
+ <id>geronimo</id>
+ <activation>
+ <property>
+ <name>!ri</name>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-validation_2.0_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ <!--
+ optional profile using javax.validation/validation-api.jar from RI
+ manually active when property "-Dri" is provided.
+ -->
+ <profile>
+ <id>ri</id>
+ <activation>
+ <property>
+ <name>ri</name>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ <!-- allow users to choose an API provider -->
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>sec</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-testResources</id>
+ <phase />
+ <goals>
+ <goal>testResources</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter-testResources</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target>
+ <mkdir dir="${project.build.testOutputDirectory}" />
+ <condition property="slash" value="/" else="">
+ <os family="windows" />
+ </condition>
+ <copy todir="${project.build.testOutputDirectory}" overwrite="true">
+ <fileset dir="${project.basedir}/src/test/resources" excludes="java.policy" />
+ </copy>
+ <copy todir="${project.build.testOutputDirectory}" overwrite="true">
+ <fileset file="${project.basedir}/src/test/resources/java.policy" />
+ <filterchain>
+ <expandproperties />
+ <!-- append extra slash on windows only -->
+ <replacestring from="file://" to="file://${slash}" />
+ <replacestring from="${file.separator}" to="/" />
+ </filterchain>
+ </copy>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.9.3</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <argLine>-Djava.security.manager -Djava.security.policy=${project.build.testOutputDirectory}/java.policy</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-weaver-privilizer-api</artifactId>
+ </dependency>
+ <!-- optional dependencies -->
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
+ <!-- allow users to choose an API provider -->
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jcdi_2.0_spec</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-el-api</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-annotation_1.3_spec</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-interceptor_1.2_spec</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Testing dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ <resource>
+ <directory>src/main/xsd</directory>
+ <targetPath>META-INF</targetPath>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxb2-maven-plugin</artifactId>
+ <version>2.3.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>xjc</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <packageName>org.apache.bval.jsr.xml</packageName>
+ <extension>true</extension>
+ <enableIntrospection>true</enableIntrospection>
+ <sources>
+ <source>${project.basedir}/src/main/xsd/validation-configuration-2.0.xsd</source>
+ <source>${project.basedir}/src/main/xsd/validation-mapping-2.0.xsd</source>
+ </sources>
+ </configuration>
+ </plugin>
+
+ <!-- create mainClass attribute -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ <configuration>
+ <archive>
+ <manifest>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ <mainClass>org.apache.bval.util.BValVersion</mainClass>
+ </manifest>
+ <manifestEntries>
+ <Implementation-Build>${buildNumber}</Implementation-Build>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test-jar</id>
+ <phase>package</phase>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ <inherited>false</inherited>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ <include>**/*TestCase.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-weaver-maven-plugin</artifactId>
+ </plugin>
+ <!--
+ get the project version
+ and set it in a properties file for later retrieval
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>set version info</id>
+ <phase>compile</phase>
+ <configuration>
+ <target>
+ <echo>Version: ${project.version}</echo>
+ <echo>Date: ${timestamp}</echo>
+ <mkdir dir="${project.build.outputDirectory}/META-INF" />
+ <echo file="${project.build.outputDirectory}/META-INF/org.apache.bval.revision.properties">
+# Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
+project.name=Apache BVal
+project.version=${project.version}
+build.timestamp=${timestamp}
+ </echo>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: tomee/deps/branches/bval-2/bval-jsr/src/main/appended-resources/META-INF/NOTICE.vm
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/appended-resources/META-INF/NOTICE.vm?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/appended-resources/META-INF/NOTICE.vm (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/appended-resources/META-INF/NOTICE.vm Fri Oct 12 15:00:48 2018
@@ -0,0 +1,26 @@
+##
+## 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.
+##
+
+
+The following copyright notice(s) were affixed to portions of this code
+with which this file is now or was at one time distributed.
+
+This product includes software developed by agimatec GmbH.
+Copyright 2007-2010 Agimatec GmbH. All rights reserved.
+
Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/AnyLiteral.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/AnyLiteral.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/AnyLiteral.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/AnyLiteral.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,36 @@
+/*
+ * 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.cdi;
+
+import javax.enterprise.inject.Any;
+
+public class AnyLiteral extends EmptyAnnotationLiteral<Any> implements Any {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Statically available instance.
+ */
+ public static final AnyLiteral INSTANCE = new AnyLiteral();
+
+ @Override
+ public String toString() {
+ return String.format("@%s()", Any.class.getName());
+ }
+
+}
Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValAnnotatedType.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValAnnotatedType.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValAnnotatedType.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValAnnotatedType.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,98 @@
+/*
+ * 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.cdi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+public class BValAnnotatedType<A> implements AnnotatedType<A> {
+ private final AnnotatedType<A> delegate;
+ private final Set<Annotation> annotations;
+
+ public BValAnnotatedType(final AnnotatedType<A> annotatedType) {
+ delegate = annotatedType;
+
+ annotations = new HashSet<>(annotatedType.getAnnotations());
+ annotations.add(BValBindingLiteral.INSTANCE);
+ }
+
+ @Override
+ public Class<A> getJavaClass() {
+ return delegate.getJavaClass();
+ }
+
+ @Override
+ public Set<AnnotatedConstructor<A>> getConstructors() {
+ return delegate.getConstructors();
+ }
+
+ @Override
+ public Set<AnnotatedMethod<? super A>> getMethods() {
+ return delegate.getMethods();
+ }
+
+ @Override
+ public Set<AnnotatedField<? super A>> getFields() {
+ return delegate.getFields();
+ }
+
+ @Override
+ public Type getBaseType() {
+ return delegate.getBaseType();
+ }
+
+ @Override
+ public Set<Type> getTypeClosure() {
+ return delegate.getTypeClosure();
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(final Class<T> annotationType) {
+ return annotations.stream().filter(ann -> ann.annotationType().equals(annotationType)).map(annotationType::cast)
+ .findFirst().orElse(null);
+ }
+
+ @Override
+ public Set<Annotation> getAnnotations() {
+ return annotations;
+ }
+
+ @Override
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
+ return annotations.stream().anyMatch(ann -> ann.annotationType().equals(annotationType));
+ }
+
+ public static class BValBindingLiteral extends EmptyAnnotationLiteral<BValBinding> implements BValBinding {
+ private static final long serialVersionUID = 1L;
+
+ public static final Annotation INSTANCE = new BValBindingLiteral();
+
+ @Override
+ public String toString() {
+ return String.format("@%s()", BValBinding.class.getName());
+ }
+ }
+}
Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValBinding.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValBinding.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValBinding.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValBinding.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,34 @@
+/*
+ * 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.cdi;
+
+import javax.interceptor.InterceptorBinding;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Custom {@link InterceptorBinding} to invoke executable validations on CDI beans.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ ElementType.TYPE })
+@InterceptorBinding
+public @interface BValBinding {
+}