Hibernate SVN: r15982 - in beanvalidation/trunk/validation-api/src/main/java/javax/validation: bootstrap and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-02-17 05:14:09 -0500 (Tue, 17 Feb 2009)
New Revision: 15982
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Configuration.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ElementDescriptor.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ValidatorContext.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/bootstrap/ProviderSpecificBootstrap.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ConfigurationState.java
Log:
BVAL-118 getGroups return Default and javadoc enhancements + typos
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java 2009-02-17 07:55:44 UTC (rev 15981)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java 2009-02-17 10:14:09 UTC (rev 15982)
@@ -20,8 +20,10 @@
boolean isBeanConstrained();
/**
- * Return the property level constraints for a given propertyName
- * or null if either the property does not exist or has no constraint
+ * Return the property descriptor for a given property.
+ * Return null if the property does not exist or has no
+ * constraint nor is marked as cascaded (see {@link #getConstrainedProperties()} )
+ *
* The returned object (and associated objects including ConstraintDescriptors)
* are immutable.
*
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/Configuration.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/Configuration.java 2009-02-17 07:55:44 UTC (rev 15981)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/Configuration.java 2009-02-17 10:14:09 UTC (rev 15982)
@@ -69,6 +69,9 @@
/**
* Defines the message interpolator used. Has priority over the configuration
* based message interpolator.
+ * If null is passed, the default message interpolator
+ * (defined in XML or the specification default)
+ * is used.
*
* @param interpolator message interpolator implementation.
*
@@ -79,6 +82,9 @@
/**
* Defines the traversable resolver used. Has priority over the configuration
* based traversable resolver.
+ * If null is passed, the default traversable resolver
+ * (defined in XML or the specification default)
+ * is used.
*
* @param resolver traversable resolver implementation.
*
@@ -89,6 +95,9 @@
/**
* Defines the constraint validator factory. Has priority over the configuration
* based constraint factory.
+ * If null is passed, the default constraint validator factory
+ * (defined in XML or the specification default)
+ * is used.
*
* @param constraintValidatorFactory constraint factory inmplementation.
*
@@ -107,6 +116,7 @@
* @param stream XML mapping stream.
*
* @return <code>this</code> following the chaining method pattern.
+ * @throws IllegalArgumentException if <code>stream</code> is null
*/
T addMapping(InputStream stream);
@@ -131,9 +141,14 @@
* If a property with a given name is defined both via this method and in the
* XML configuration, the value set programmatically has priority.
*
+ * If null is passed as a value, the value defined in XML is used. If no value
+ * is defined in XML, the property is considered unset.
+ *
* @param name property name.
* @param value property value.
* @return <code>this</code> following the chaining method pattern.
+ *
+ * @throws IllegalArgumentException if <code>name</code> is null
*/
T addProperty(String name, String value);
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java 2009-02-17 07:55:44 UTC (rev 15981)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java 2009-02-17 10:14:09 UTC (rev 15982)
@@ -39,6 +39,10 @@
Annotation getAnnotation();
/**
+ * The Set of groups the constraint is applied on.
+ * If the constraint declares no group, the <code>Default</code>
+ * group is returned.
+ *
* @return The groups the constraint is applied on.
*/
Set<Class<?>> getGroups();
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java 2009-02-17 07:55:44 UTC (rev 15981)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java 2009-02-17 10:14:09 UTC (rev 15982)
@@ -42,13 +42,13 @@
/**
* Implement the validation logic.
- * <code>object</code> state must not be changed by a Constraint implementation
+ * <code>value</code> state must not be changed by a Constraint implementation
*
- * @param object object to validate
+ * @param value object to validate
* @param constraintValidatorContext context in which the constraint is evaluated
*
- * @return false if <code>object</code> does not pass the constraint
+ * @return false if <code>value</code> does not pass the constraint
*/
- boolean isValid(T object, ConstraintValidatorContext constraintValidatorContext);
+ boolean isValid(T value, ConstraintValidatorContext constraintValidatorContext);
}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ElementDescriptor.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ElementDescriptor.java 2009-02-17 07:55:44 UTC (rev 15981)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ElementDescriptor.java 2009-02-17 10:14:09 UTC (rev 15982)
@@ -40,7 +40,10 @@
Class<?> getType();
/**
- * @return All the constraint descriptors for this element.
+ * Return all constraint descriptors for this element or an
+ * empty Set if none are present.
+ *
+ * @return Set of constraint descriptors for this element
*/
Set<ConstraintDescriptor> getConstraintDescriptors();
}
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ValidatorContext.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ValidatorContext.java 2009-02-17 07:55:44 UTC (rev 15981)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ValidatorContext.java 2009-02-17 10:14:09 UTC (rev 15982)
@@ -8,7 +8,8 @@
public interface ValidatorContext {
/**
* Defines the message interpolator implementation used by the Validator.
- * If unset, the message interpolator of the ValidatorFactory is used.
+ * If not set or if null is passed as a parameter,
+ * the message interpolator of the ValidatorFactory is used.
*
* @return self following the chaining method pattern
*/
@@ -16,7 +17,8 @@
/**
* Defines the traversable resolver implementation used by the Validator.
- * If unset, the traversable resolver of the ValidatorFactory is used.
+ * If not set or if null is passed as a parameter,
+ * the traversable resolver of the ValidatorFactory is used.
*
* @return self following the chaining method pattern
*/
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/bootstrap/ProviderSpecificBootstrap.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/bootstrap/ProviderSpecificBootstrap.java 2009-02-17 07:55:44 UTC (rev 15981)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/bootstrap/ProviderSpecificBootstrap.java 2009-02-17 10:14:09 UTC (rev 15982)
@@ -29,7 +29,7 @@
public ProviderSpecificBootstrap<T> providerResolver(ValidationProviderResolver resolver);
/**
- * Determine the provider implementation suitable for configurationType and delegate
+ * Determine the provider implementation suitable for T and delegate
* the creation of this specific Configuration subclass to the provider.
*
* @return a Configuration sub interface implementation
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ConfigurationState.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ConfigurationState.java 2009-02-17 07:55:44 UTC (rev 15981)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ConfigurationState.java 2009-02-17 10:14:09 UTC (rev 15982)
@@ -43,7 +43,7 @@
boolean isIgnoreXmlConfiguration();
/**
- * Message interpolator as defined in the following decresing priority:
+ * Message interpolator as defined in the following decreasing priority:
* - set via the Configuration programmatic API
* - defined in META-INF/validation.xml provided that ignoredXmlConfiguration
* is false. In this case the instance is created via its no-arg constructor.
@@ -81,7 +81,7 @@
ConstraintValidatorFactory getConstraintValidatorFactory();
/**
- * TraversableResolver as defined in the following decresing priority:
+ * TraversableResolver as defined in the following decreasing priority:
* - set via the Configuration programmatic API
* - defined in META-INF/validation.xml provided that ignoredXmlConfiguration
* is false. In this case the instance is created via its no-arg constructor.
16 years, 10 months
Hibernate SVN: r15981 - in validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck: config and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-02-17 02:55:44 -0500 (Tue, 17 Feb 2009)
New Revision: 15981
Added:
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/EnumerationIterable.java
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/EnumerationIterator.java
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/ResourceLoadingException.java
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/RuntimeProperties.java
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/SimpleResourceLoader.java
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/Strings.java
Modified:
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageProcessor.java
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
Log:
support for fisheye and svn urls
Added: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/EnumerationIterable.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/EnumerationIterable.java (rev 0)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/EnumerationIterable.java 2009-02-17 07:55:44 UTC (rev 15981)
@@ -0,0 +1,37 @@
+package org.hibernate.tck.config;
+
+import java.util.Enumeration;
+import java.util.Iterator;
+
+/**
+ * An Enumeration -> Iterable adaptor
+ *
+ * @author Pete Muir
+ * @see org.jboss.webbeans.util.EnumerationIterator
+ */
+class EnumerationIterable<T> implements Iterable<T>
+{
+ // The enumeration-iteartor
+ private EnumerationIterator<T> iterator;
+
+ /**
+ * Constructor
+ *
+ * @param enumeration The enumeration
+ */
+ public EnumerationIterable(Enumeration<T> enumeration)
+ {
+ this.iterator = new EnumerationIterator<T>(enumeration);
+ }
+
+ /**
+ * Gets an iterator
+ *
+ * @return The iterator
+ */
+ public Iterator<T> iterator()
+ {
+ return iterator;
+ }
+
+}
\ No newline at end of file
Added: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/EnumerationIterator.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/EnumerationIterator.java (rev 0)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/EnumerationIterator.java 2009-02-17 07:55:44 UTC (rev 15981)
@@ -0,0 +1,55 @@
+package org.hibernate.tck.config;
+
+import java.util.Enumeration;
+import java.util.Iterator;
+
+/**
+ * An enumeration -> iterator adapter
+ *
+ * @author Pete Muir
+ */
+@SuppressWarnings("unchecked")
+class EnumerationIterator<T> implements Iterator<T>
+{
+ // The enumeration
+ private Enumeration e;
+
+ /**
+ * Constructor
+ *
+ * @param e The enumeration
+ */
+ public EnumerationIterator(Enumeration e)
+ {
+ this.e = e;
+ }
+
+ /**
+ * Indicates if there are more items to iterate
+ *
+ * @return True if more, false otherwise
+ */
+ public boolean hasNext()
+ {
+ return e.hasMoreElements();
+ }
+
+ /**
+ * Gets the next item
+ *
+ * @return The next items
+ */
+ public T next()
+ {
+ return (T) e.nextElement();
+ }
+
+ /**
+ * Removes an item. Not supported
+ */
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+}
\ No newline at end of file
Added: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/ResourceLoadingException.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/ResourceLoadingException.java (rev 0)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/ResourceLoadingException.java 2009-02-17 07:55:44 UTC (rev 15981)
@@ -0,0 +1,52 @@
+package org.hibernate.tck.config;
+
+/**
+ * Exception thrown when errors occur while loading resource
+ *
+ * @author Pete Muir
+ *
+ */
+class ResourceLoadingException extends RuntimeException
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor
+ */
+ public ResourceLoadingException()
+ {
+ super();
+ }
+
+ /**
+ * Constructor
+ *
+ * @param message The message
+ * @param throwable The exception
+ */
+ public ResourceLoadingException(String message, Throwable throwable)
+ {
+ super(message, throwable);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param message The message
+ */
+ public ResourceLoadingException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param throwable The exception
+ */
+ public ResourceLoadingException(Throwable throwable)
+ {
+ super(throwable);
+ }
+
+}
\ No newline at end of file
Added: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/RuntimeProperties.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/RuntimeProperties.java (rev 0)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/RuntimeProperties.java 2009-02-17 07:55:44 UTC (rev 15981)
@@ -0,0 +1,232 @@
+package org.hibernate.tck.config;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * Utility class to load deployment properties
+ *
+ * @author Pete Muir
+ */
+public class RuntimeProperties
+{
+ // The resource bundle used to control tck unit runtime properties
+ public static final String RESOURCE_BUNDLE = "META-INF/tck-unit.properties";
+
+ //private static final Logger log = Logger.getLogger(DeploymentProperties.class);
+
+ // The class to work from
+ private SimpleResourceLoader resourceLoader;
+
+ /**
+ * Constructor
+ *
+ * @param classLoader The classloader to work on
+ */
+ public RuntimeProperties()
+ {
+ this.resourceLoader = new SimpleResourceLoader();
+ }
+
+ /**
+ * Get a list of possible values for a given key.
+ *
+ * First, System properties are tried, followed by the specified resource
+ * bundle (first in classpath only).
+ *
+ * @param key The key to search for
+ * @return A list of possible values. An empty list is returned if there are
+ * no matches.
+ */
+ public List<String> getPropertyValues(String key)
+ {
+ List<String> values = new ArrayList<String>();
+ addPropertiesFromSystem(key, values);
+ addPropertiesFromResourceBundle(key, values);
+ return values;
+ }
+
+ /**
+ * Adds matches from system properties
+ *
+ * @param key The key to match
+ * @param values The currently found values
+ */
+ private void addPropertiesFromSystem(String key, List<String> values)
+ {
+ addProperty(key, System.getProperty(key), values);
+ }
+
+ /**
+ * Adds matches from detected resource bundles
+ *
+ * @param key The key to match
+ * @param values The currently found values
+ */
+ private void addPropertiesFromResourceBundle(String key, List<String> values)
+ {
+ try
+ {
+ for (URL url : resourceLoader.getResources(RESOURCE_BUNDLE))
+ {
+ Properties properties = new Properties();
+ InputStream propertyStream = url.openStream();
+ try
+ {
+ properties.load(propertyStream);
+ addProperty(key, properties.getProperty(key), values);
+ }
+ finally
+ {
+ if (propertyStream != null)
+ {
+ propertyStream.close();
+ }
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ // No - op, file is optional
+ }
+ }
+
+ /**
+ * Add the property to the set of properties only if it hasn't already been
+ * added
+ *
+ * @param key The key searched for
+ * @param value The value of the property
+ * @param values The currently found values
+ */
+ private void addProperty(String key, String value, List<String> values)
+ {
+ if (value != null)
+ {
+ //String[] properties = Strings.split(value, "[^\\]:");
+ //for (String property : properties)
+ //{
+ //values.add(property);
+ //}
+ values.add(value);
+
+ }
+ }
+
+ /**
+ * Gets the possible implementation class for a given property for which the
+ * values are classanames
+ *
+ * @param deploymentProperties The deployment properties object to use
+ * @param resourceLoader The resource laoder to use to attempt
+ * @param propertyName The name of the property to load
+ * @return A set of classes specified
+ */
+ @SuppressWarnings("unchecked")
+ public <T> Set<Class<T>> getClasses(String propertyName, Class<T> expectedType)
+ {
+ Set<Class<T>> classes = new HashSet<Class<T>>();
+ for (String className : getPropertyValues(propertyName))
+ {
+ try
+ {
+ classes.add((Class<T>) resourceLoader.classForName(className));
+ }
+ catch (ResourceLoadingException e)
+ {
+ //log.debug("Unable to load class " + className + " for property " + propertyName, e);
+ }
+ }
+ return classes;
+ }
+
+ public <T> Class<T> getClassValue(String propertyName, Class<T> expectedType, boolean required)
+ {
+ Set<Class<T>> classes = getClasses(propertyName, expectedType);
+ if (classes.size() == 0)
+ {
+ if (required)
+ {
+ throw new IllegalArgumentException("Cannot find any implementations of " + expectedType.getSimpleName() + ", check that " + propertyName + " is specified");
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else if (classes.size() > 1)
+ {
+ throw new IllegalArgumentException("More than one implementation of " + expectedType.getSimpleName() + " specified by " + propertyName + ", not sure which one to use!");
+ }
+ else
+ {
+ return classes.iterator().next();
+ }
+ }
+
+ public <T> T getInstanceValue(String propertyName, Class<T> expectedType, boolean required)
+ {
+ Class<T> clazz = getClassValue(propertyName, expectedType, required);
+ if (clazz != null)
+ {
+ try
+ {
+ return clazz.newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new IllegalStateException("Error instantiating " + clazz + " specified by " + propertyName, e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new IllegalStateException("Error instantiating " + clazz + " specified by " + propertyName, e);
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public boolean getBooleanValue(String propertyName, boolean _default, boolean required)
+ {
+ return Boolean.valueOf(getStringValue(propertyName, _default ? "true" : "false", required));
+ }
+
+ public int getIntValue(String propertyName, int _default, boolean required)
+ {
+ return Integer.valueOf(getStringValue(propertyName, Integer.toString(_default), required)).intValue();
+ }
+
+ public String getStringValue(String propertyName, String _default, boolean required)
+ {
+ List<String> values = getPropertyValues(propertyName);
+
+ if (values.size() == 0)
+ {
+ if (required)
+ {
+ throw new IllegalArgumentException("Cannot find required property " + propertyName + ", check that it is specified");
+ }
+ else
+ {
+ return _default;
+ }
+ }
+ else if (values.size() > 1)
+ {
+ throw new IllegalArgumentException("More than one value given for " + propertyName + ", not sure which one to use!");
+ }
+ else
+ {
+ return values.iterator().next();
+ }
+ }
+
+}
\ No newline at end of file
Added: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/SimpleResourceLoader.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/SimpleResourceLoader.java (rev 0)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/SimpleResourceLoader.java 2009-02-17 07:55:44 UTC (rev 15981)
@@ -0,0 +1,43 @@
+package org.hibernate.tck.config;
+
+import java.io.IOException;
+import java.net.URL;
+
+class SimpleResourceLoader
+{
+
+ public Class<?> classForName(String name)
+ {
+
+ try
+ {
+ return Class.forName(name);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new ResourceLoadingException(e);
+ }
+ catch (NoClassDefFoundError e)
+ {
+ throw new ResourceLoadingException(e);
+ }
+ }
+
+ public URL getResource(String name)
+ {
+ return getClass().getResource(name);
+ }
+
+ public Iterable<URL> getResources(String name)
+ {
+ try
+ {
+ return new EnumerationIterable<URL>(getClass().getClassLoader().getResources(name));
+ }
+ catch (IOException e)
+ {
+ throw new ResourceLoadingException(e);
+ }
+ }
+
+}
\ No newline at end of file
Added: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/Strings.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/Strings.java (rev 0)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/config/Strings.java 2009-02-17 07:55:44 UTC (rev 15981)
@@ -0,0 +1,30 @@
+package org.hibernate.tck.config;
+
+import java.util.StringTokenizer;
+
+public class Strings
+{
+ static String[] split(String strings, String delims)
+ {
+ if (strings == null)
+ {
+ return new String[0];
+ }
+ else
+ {
+ StringTokenizer tokens = new StringTokenizer(strings, delims);
+ String[] result = new String[tokens.countTokens()];
+ int i = 0;
+ while (tokens.hasMoreTokens())
+ {
+ result[i++] = tokens.nextToken();
+ }
+ return result;
+ }
+ }
+
+ public static boolean isEmpty(String string)
+ {
+ return string == null || string.length() == 0;
+ }
+}
Modified: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageProcessor.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageProcessor.java 2009-02-17 06:20:23 UTC (rev 15980)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageProcessor.java 2009-02-17 07:55:44 UTC (rev 15981)
@@ -106,7 +106,7 @@
if (baseDirName == null) {
baseDirName = getCurrentWorkingDirectory() + "target";
System.out.println(
- "No output directory specided using " + baseDirName + " instead."
+ "No output directory specified, using " + baseDirName + " instead."
);
}
else
Modified: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-02-17 06:20:23 UTC (rev 15980)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-02-17 07:55:44 UTC (rev 15981)
@@ -9,18 +9,31 @@
import java.util.List;
import java.util.Map;
+import org.hibernate.tck.config.RuntimeProperties;
+
/**
* Generates the TCK spec coverage report
*
* @author Shane Bryzak
*/
public class CoverageReport {
+
+ public static final String FISHEYE_BASE_URL_PROPERTY = "fisheye_base_url";
+
+ public static final String SVN_BASE_URL_PROPERTY = "svn_base_url";
+
/*
* References to the spec assertions made by the tck tests
*/
private final Map<String, List<SpecReference>> references;
private AuditParser auditParser;
+
+ private RuntimeProperties properties;
+
+ private String fisheyeBaseUrl = null;
+
+ private String svnBaseUrl = null;
public CoverageReport(List<SpecReference> references, AuditParser auditParser) {
this.references = new HashMap<String, List<SpecReference>>();
@@ -34,6 +47,29 @@
}
this.auditParser = auditParser;
+
+ this.properties = new RuntimeProperties();
+
+ try
+ {
+ fisheyeBaseUrl = this.properties.getStringValue(FISHEYE_BASE_URL_PROPERTY, null, false);
+
+ if (!fisheyeBaseUrl.endsWith("/"))
+ {
+ fisheyeBaseUrl = fisheyeBaseUrl + "/";
+ }
+
+ svnBaseUrl = this.properties.getStringValue(SVN_BASE_URL_PROPERTY, null, false);
+
+ if (!svnBaseUrl.endsWith("/"))
+ {
+ svnBaseUrl = svnBaseUrl + "/";
+ }
+ }
+ catch (Exception ex)
+ {
+ // swallow
+ }
}
public void generate(OutputStream out) throws IOException {
@@ -62,6 +98,14 @@
sb.append(" width: 50px;\n");
sb.append(" margin-top: 0px;\n");
sb.append(" height: 100%; }\n");
+ sb.append(" a.external, a.external:visited, a.external:hover {\n");
+ sb.append(" color: #0000ff;\n");
+ sb.append(" font-size: 9px;\n");
+ sb.append(" font-style: normal;\n");
+ sb.append(" padding-left: 2px;\n");
+ sb.append(" margin-left: 6px;\n");
+ sb.append(" margin-right: 6px;\n");
+ sb.append(" padding-right: 2px; }\n");
sb.append(" .results {\n");
sb.append(" margin-left: 50px; }\n");
sb.append(" .description {\n");
@@ -106,6 +150,8 @@
private void writeCoverage(OutputStream out) throws IOException {
+ out.write("<h3>Coverage Detail</h3>\n".getBytes());
+
for (String sectionId : auditParser.getSectionIds()) {
List<AuditAssertion> sectionAssertions = auditParser.getAssertionsForSection(sectionId);
@@ -153,6 +199,34 @@
sb.append(".");
sb.append(ref.getMethodName());
sb.append("()");
+
+ if (fisheyeBaseUrl != null)
+ {
+ sb.append("<a class=\"external\" target=\"_blank\" href=\"");
+ sb.append(fisheyeBaseUrl);
+ sb.append(currentPackageName.replace('.', '/'));
+ sb.append("/");
+ sb.append(ref.getClassName());
+ sb.append(".java");
+ sb.append("\">fisheye</a>");
+ }
+
+ if (svnBaseUrl != null)
+ {
+ if (fisheyeBaseUrl != null)
+ {
+ sb.append("|");
+ }
+
+ sb.append("<a class=\"external\" target=\"_blank\" href=\"");
+ sb.append(svnBaseUrl);
+ sb.append(currentPackageName.replace('.', '/'));
+ sb.append("/");
+ sb.append(ref.getClassName());
+ sb.append(".java");
+ sb.append("\">svn</a>");
+ }
+
sb.append("</div>\n");
}
}
16 years, 10 months
Hibernate SVN: r15980 - in validator/trunk/hibernate-validator/src/main/docbook/en-US: modules and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-02-17 01:20:23 -0500 (Tue, 17 Feb 2009)
New Revision: 15980
Modified:
validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml
Log:
Added Gunnar's updates to 'Creating custom constraints' chapter
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2009-02-16 16:54:15 UTC (rev 15979)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2009-02-17 06:20:23 UTC (rev 15980)
@@ -133,12 +133,13 @@
<!--xi:include href="modules/introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /-->
- <xi:include href="modules/gettingstarted.xml"
- xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="modules/gettingstarted.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<!--
<xi:include href="modules/usingvalidator.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+-->
<xi:include href="modules/customconstraints.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+<!--
<xi:include href="modules/xmlconfiguration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="modules/integration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="modules/extendedri.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml 2009-02-16 16:54:15 UTC (rev 15979)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml 2009-02-17 06:20:23 UTC (rev 15980)
@@ -27,31 +27,377 @@
<chapter id="validator-customconstraints">
<title>Creating custom constraints</title>
- <para>The Bean Validation API doesn't restrict you to the constraints
- specified by the API itself, but rather allows you to create your own custom
- constraints in a simple and timely manner.</para>
+ <para>Though the Bean Validation API defines a whole bunch of standard
+ constraint annotations such as @NotNull, @Size, @Min or @AssertTrue, one can
+ easily think of situations, for which these standard annotations won't
+ suffice.</para>
+ <para>But as the specification was designed with extensibility in mind, you
+ are able to create custom constraints tailored to your specific validation
+ requirements in a simple and timely manner. To create a custom constraint,
+ the following three steps are required, which will be explained in the
+ following:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>Create a constraint annotation</para>
+ </listitem>
+
+ <listitem>
+ <para>Implement a validator, that's able to evaluate that
+ annotation</para>
+ </listitem>
+
+ <listitem>
+ <para>Define a default error message</para>
+ </listitem>
+ </itemizedlist>
+
<section id="validator-customconstraints-constraintannotation" revision="1">
- <title>Create a constraint annotation</title>
+ <title>Creating a constraint annotation</title>
- <para></para>
+ <para>Let's write a constraint annotation, that can be used to express
+ that a given String shall either be upper case or lower case. We'll apply
+ it later on to ensure, that the licensePlate field of the Car class from
+ the <link linkend="validator-gettingstarted">Getting started</link>
+ chapter is always an upper-case String.</para>
+
+ <para>First we need a way to express the two case modes. We might use
+ String constants, but a better way to go is to use a Java 5 enum for that
+ purpose:</para>
+
+ <programlisting>package com.mycompany;
+
+public enum CaseMode {
+
+ UPPER,
+
+ LOWER;
+
+}</programlisting>
+
+ <para>Now we can define the actual constraint annotation. If you've never
+ designed an annotation before, this may look a bit scary, but actually
+ it's not that hard:</para>
+
+ <programlisting>package com.mycompany;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+
+@Target( { METHOD, FIELD, ANNOTATION_TYPE })
+@Retention(RUNTIME)
+@Constraint(validatedBy = CheckCaseValidator.class)
+@Documented
+public @interface CheckCase {
+
+ String message() default "{validator.checkcase}";
+
+ Class<?>[] groups() default {};
+
+ CaseMode value();
+
+}</programlisting>
+
+ <para>An annotation type is defined using the @interface keyword. All
+ attributes of an annotation type are declared in a method-like manner. The
+ specification of the Bean Validation API demands, that any constraint
+ annotation defines</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>an attribute "message" that returns the default key for creating
+ error messages in case the constraint is violated</para>
+ </listitem>
+
+ <listitem>
+ <para>an attribute "groups" that allows the specification of
+ validation groups, to which this constraint belongs (see section
+ "Using validation groups" for further details, TODO GM: link). This
+ must default to an empty array of type Class<?>.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>Besides those two mandatory attributes we add another one allowing
+ for the required case mode to be specified. The name "value" is a special
+ one, which can be omitted upon using the annotation, if it is the only
+ attribute specified, as e.g. in @CheckCase(CaseMode.UPPER).</para>
+
+ <para>In addition we annotate the annotation type with a couple of
+ so-called meta annotations:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>@Target({ METHOD, FIELD, ANNOTATION_TYPE }): Says, that methods,
+ fields and annotation declarations may be annotated with @CheckCase
+ (but not type declarations e.g.)</para>
+ </listitem>
+
+ <listitem>
+ <para>@Retention(RUNTIME): Specifies, that annotations of this type
+ will be available at runtime by the means of reflection</para>
+ </listitem>
+
+ <listitem>
+ <para>@Constraint(validatedBy = CheckCaseValidator.class): Specifies
+ the validator to be used to validate elements annotated with
+ @CheckCase</para>
+ </listitem>
+
+ <listitem>
+ <para>@Documented: Says, that the use of @CheckCase will be contained
+ in the JavaDoc of elements annotated with it</para>
+ </listitem>
+ </itemizedlist>
</section>
<section id="validator-customconstraints-validator" revision="1">
- <title>Implement the constraint validator</title>
+ <title>Implementing the constraint validator</title>
- <para></para>
+ <para>Next, we need to implement a constraint validator, that's able to
+ validate elements with a @CheckCase annotation. To do so, we implement the
+ interface ConstraintValidator as shown below:</para>
+
+ <programlisting>package com.mycompany;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+public class CheckCaseValidator implements ConstraintValidator<CheckCase, String> {
+
+ private CaseMode caseMode;
+
+ public void initialize(CheckCase constraintAnnotation) {
+ this.caseMode = constraintAnnotation.value();
+ }
+
+ public boolean isValid(String object, ConstraintValidatorContext constraintContext) {
+
+ if (object == null)
+ return true;
+
+ if (caseMode == CaseMode.UPPER)
+ return object.equals(object.toUpperCase());
+ else
+ return object.equals(object.toLowerCase());
+ }
+
+}</programlisting>
+
+ <para>The ConstraintValidator interface defines two type parameters, which
+ we set in our implementation. The first one specifies the annotation type
+ to be validated (in our example CheckCase), the second one the type of
+ elements, which the validator can handle (here String).</para>
+
+ <para>In case a constraint annotation is allowed at elements of different
+ types, a ConstraintValidator for each allowed type has to be implemented
+ and registered at the constraint annotation as shown above.</para>
+
+ <para>The implementation of the validator is straightforward. The
+ initialize() method gives us access to the attribute values of the
+ annotation to be validated. In the example we store the CaseMode in a
+ field of the validator for further usage.</para>
+
+ <para>In the isValid() method we implement the logic, that determines,
+ whether a String is valid according to a given @CheckCase annotation or
+ not. This decision depends on the case mode retrieved in initialize(). As
+ the Bean Validation specification recommends, we consider null values as
+ being valid. If null is not a valid value for an element, it should be
+ annotated with @NotNull explicitely.</para>
+
+ <para>The passed-in ConstraintValidatorContext could be used to raise any
+ custom validation errors, but as we are fine with the default behavior, we
+ can ignore that parameter for now (TODO GM: example for usage).</para>
</section>
<section id="validator-customconstraints-errormessage" revision="1">
- <title>Define the error message</title>
+ <title>Defining the error message</title>
- <para></para>
+ <para>Finally we need to specify the error message, that shall be used, in
+ case a @CheckCase constraint is violated. To do so, we create a file named
+ ValidationMessages.properties under src/main/resources with the following
+ content:</para>
+
+ <programlisting>validator.checkcase=Case mode must be {value}.</programlisting>
+
+ <para>If a validation error occurs, the validation runtime will use the
+ default value, that we specified for the message attribute of the
+ @CheckCase annotation to look up the error message in this file.</para>
+
+ <para>Now that our first custom constraint is completed, we can use it in
+ the Car class from the <link linkend="validator-gettingstarted">Getting
+ started</link> chapter to specify that the licensePlate field shall only
+ contain upper-case Strings:</para>
+
+ <programlisting>package com.mycompany;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+public class Car {
+
+ @NotNull
+ private String manufacturer;
+
+ @NotNull
+ @Size(min = 2, max = 14)
+ @CheckCase(CaseMode.UPPER)
+ private String licensePlate;
+
+ @Min(2)
+ private int seatCount;
+
+ public Car(String manufacturer, String licencePlate, int seatCount) {
+
+ this.manufacturer = manufacturer;
+ this.licensePlate = licencePlate;
+ this.seatCount = seatCount;
+ }
+
+ //getters and setters ...
+
+}</programlisting>
+
+ <para>Finally let's demonstrate in a little test that the @CheckCase
+ constraint is properly validated:</para>
+
+ <programlisting>package com.mycompany;
+
+import static org.junit.Assert.*;
+
+import java.util.Set;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CarTest {
+
+ private static Validator validator;
+
+ @BeforeClass
+ public static void setUp() {
+ ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
+ validator = factory.getValidator();
+ }
+
+ @Test
+ public void testLicensePlateNotUpperCase() {
+
+ Car car = new Car("Morris", "dd-ab-123", 4);
+
+ Set<ConstraintViolation<Car>> constraintViolations =
+ validator.validate(car);
+ assertEquals(1, constraintViolations.size());
+ assertEquals(
+ "Case mode must be UPPER.",
+ constraintViolations.iterator().next().getInterpolatedMessage());
+ }
+
+ @Test
+ public void carIsValid() {
+
+ Car car = new Car("Morris", "DD-AB-123", 4);
+
+ Set<ConstraintViolation<Car>> constraintViolations =
+ validator.validate(car);
+
+ assertEquals(0, constraintViolations.size());
+ }
+}</programlisting>
</section>
<section id="validator-customconstraints-compound" revision="1">
- <title>Compound constraints</title>
+ <title>Constraint composition</title>
- <para></para>
+ <para>Looking at the licensePlate field of the Car class, we see three
+ constraint annotations already. In complexer scenarios, where even more
+ constraints could be applied to one element, this might become a bit
+ confusing easily. Furthermore, if we had a licensePlate field in another
+ class, we would have to copy all constraint declarations to the other
+ class as well, violating the DRY principle.</para>
+
+ <para>This problem can be tackled using compound constraints. In the
+ following we create a new constraint annotation @ValidLicensePlate, that
+ comprises the constraints @NotNull, @Size and @CheckCase:</para>
+
+ <programlisting>package com.mycompany;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+@NotNull
+@Size(min = 2, max = 14)
+(a)CheckCase(CaseMode.UPPER)
+@Target( { METHOD, FIELD, ANNOTATION_TYPE })
+@Retention(RUNTIME)
+@Constraint(validatedBy = {})
+@Documented
+public @interface ValidLicensePlate {
+
+ String message() default "{validator.validlicenseplate}";
+
+ Class<?>[] groups() default {};
+
+}</programlisting>
+
+ <para>To do so, we just have to annotate the constraint declaration with
+ its comprising constraints (btw. that's exactly why we allowed annotation
+ types as target for the @CheckCase annotation). As no additional
+ validation is required for the @ValidLicensePlate annotation itself, we
+ don't declare a validator within the @Constraint meta annotation.</para>
+
+ <para>TODO GM: Specifying no validator does not yet work.</para>
+
+ <para>Using the new compound constraint at the licensePlate field now is
+ fully equivalent to the previous version, where we declared the three
+ constraints directly at the field itself:</para>
+
+ <programlisting>package com.mycompany;
+
+public class Car {
+
+ @ValidLicensePlate
+ private String licensePlate;
+
+ //...
+
+}</programlisting>
+
+ <para>The set of ConstraintViolations retrieved when validating a Car
+ instance will contain an entry for each violated composing constraint of
+ the @ValidLicensePlate constraint. If you rather prefer a single
+ ConstraintViolation in case any of the composing constraints is violated,
+ the @ReportAsSingleViolation meta constraint can be used as
+ follows:</para>
+
+ <programlisting>//...
+@ReportAsSingleViolation
+public @interface ValidLicensePlate {
+
+ String message() default "{validator.validlicenseplate}";
+
+ Class<?>[] groups() default {};
+
+}</programlisting>
</section>
</chapter>
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml 2009-02-16 16:54:15 UTC (rev 15979)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml 2009-02-17 06:20:23 UTC (rev 15980)
@@ -26,7 +26,7 @@
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="validator-gettingstarted">
- <title>Getting started in 5 minutes</title>
+ <title id="getting-started">Getting started in 5 minutes</title>
<para>This chapter will show you how to quickly get started with the
reference implementation (RI) of the Bean Validation API as specified by JSR
@@ -104,17 +104,24 @@
<para>Finally confirm all entered values and change into the newly created
project directory. All properties of a Maven project (such as its
dependencies to other libraries, the steps to be performed during build
- etc.) are described in a file contained pom.xml (project object model),
+ etc.) are described in a file called pom.xml (project object model),
located in the project's root directory. Now open the project's pom.xml
and perform the following changes:</para>
<itemizedlist>
<listitem>
- <para>Add the dependencies to the Bean Validation API and the
- reference implementation</para>
+ <para>Add the dependency to hibernate-validator</para>
</listitem>
<listitem>
+ <para>Add an SLF4J binding. As Hibernate Validator uses the logging
+ facade <ulink url="http://www.slf4j.org/">SLF4J</ulink>, it can make
+ use of your preferred logging API. In the following the binding to
+ <ulink url="http://logging.apache.org/log4j/">log4j</ulink> is
+ used.</para>
+ </listitem>
+
+ <listitem>
<para>Set the compiler level to 1.5 (as we want to use
annotations)</para>
</listitem>
16 years, 10 months
Hibernate SVN: r15979 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-02-16 11:54:15 -0500 (Mon, 16 Feb 2009)
New Revision: 15979
Removed:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/GroupSequences.java
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Dictonary.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/EnglishDictonary.java
Log:
Removed obsolete GroupSequences
Deleted: beanvalidation/trunk/validation-api/src/main/java/javax/validation/GroupSequences.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/GroupSequences.java 2009-02-16 13:33:16 UTC (rev 15978)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/GroupSequences.java 2009-02-16 16:54:15 UTC (rev 15979)
@@ -1,33 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed 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 javax.validation;
-
-import static java.lang.annotation.ElementType.TYPE;
-import java.lang.annotation.Retention;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import java.lang.annotation.Target;
-
-/**
- * @author Hardy Ferentschik
- * FIXME remove that annotation
- */
-@Target({ TYPE })
-@Retention(RUNTIME)
-public @interface GroupSequences {
- GroupSequence[] value();
-}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-02-16 13:33:16 UTC (rev 15978)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-02-16 16:54:15 UTC (rev 15979)
@@ -28,7 +28,6 @@
import java.util.Map;
import javax.validation.BeanDescriptor;
import javax.validation.GroupSequence;
-import javax.validation.GroupSequences;
import javax.validation.PropertyDescriptor;
import javax.validation.Valid;
import javax.validation.ValidationException;
@@ -141,13 +140,6 @@
addGroupSequence( groupSequenceAnnotation );
}
- GroupSequences groupSequencesAnnotation = clazz.getAnnotation( GroupSequences.class );
- if ( groupSequencesAnnotation != null ) {
- for ( GroupSequence group : groupSequencesAnnotation.value() ) {
- addGroupSequence( group );
- }
- }
-
for ( Map.Entry<Class<?>, List<Class<?>>> mapEntry : groupSequences.entrySet() ) {
List<Class<?>> groups = mapEntry.getValue();
List<Class<?>> expandedGroups = new ArrayList<Class<?>>();
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-02-16 13:33:16 UTC (rev 15978)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-02-16 16:54:15 UTC (rev 15979)
@@ -98,7 +98,6 @@
* @return List of invalid constraints.
*
* @todo Currently we iterate the cascaded fields multiple times. Maybe we should change to an approach where we iterate the object graph only once.
- * @todo Context root bean can be a different object than the current Validator<T> hence two different generics variables
*/
private <T> List<ConstraintViolationImpl<T>> validateInContext(ExecutionContext<T> context, List<Class<?>> groups) {
if ( context.peekValidatedObject() == null ) {
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Dictonary.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Dictonary.java 2009-02-16 13:33:16 UTC (rev 15978)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Dictonary.java 2009-02-16 16:54:15 UTC (rev 15979)
@@ -18,20 +18,15 @@
package org.hibernate.validation.eg;
import javax.validation.GroupSequence;
-import javax.validation.GroupSequences;
-import javax.validation.groups.Default;
import javax.validation.constraints.NotNull;
+import javax.validation.groups.Default;
import org.hibernate.validation.constraints.NotEmpty;
-import org.hibernate.validation.eg.groups.All;
/**
* @author Hardy Ferentschik
*/
-@GroupSequences({
- @GroupSequence(name = DefaultAlias.class, sequence = { Default.class }),
- @GroupSequence(name = All.class, sequence = { Default.class, Dictonary.Translate.class })
-})
+@GroupSequence(name = DefaultAlias.class, sequence = { Default.class })
public class Dictonary extends Book {
@NotNull(groups = Translate.class)
@NotEmpty(groups = Translate.class)
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/EnglishDictonary.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/EnglishDictonary.java 2009-02-16 13:33:16 UTC (rev 15978)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/EnglishDictonary.java 2009-02-16 16:54:15 UTC (rev 15979)
@@ -18,7 +18,6 @@
package org.hibernate.validation.eg;
import javax.validation.GroupSequence;
-import javax.validation.GroupSequences;
import javax.validation.groups.Default;
import org.hibernate.validation.eg.groups.First;
@@ -26,8 +25,6 @@
/**
* @author Hardy Ferentschik
*/
-@GroupSequences({
- @GroupSequence(name = Default.class, sequence = { First.class }) // illegal - default is already defined in Book
-})
+@GroupSequence(name = Default.class, sequence = { First.class }) // illegal - default is already defined in Book
public class EnglishDictonary extends Dictonary {
}
\ No newline at end of file
16 years, 10 months
Hibernate SVN: r15978 - validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-02-16 08:33:16 -0500 (Mon, 16 Feb 2009)
New Revision: 15978
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java
Log:
removed test which might fail on some machines
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java 2009-02-16 12:06:17 UTC (rev 15977)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java 2009-02-16 13:33:16 UTC (rev 15978)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -24,6 +24,10 @@
import org.junit.BeforeClass;
import org.junit.Test;
+/**
+ * @author Alaa Nassef
+ * @author Hardy Ferentschik
+ */
public class FutureValidatorForCalendarTest {
private static FutureValidatorForCalendar constraint;
@@ -39,7 +43,6 @@
Calendar pastDate = getPastDate();
assertTrue( constraint.isValid( null, null ) );
assertTrue( constraint.isValid( futureDate, null ) );
- assertFalse( constraint.isValid( Calendar.getInstance(), null ) );
assertFalse( constraint.isValid( pastDate, null ) );
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java 2009-02-16 12:06:17 UTC (rev 15977)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java 2009-02-16 13:33:16 UTC (rev 15978)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -24,6 +24,10 @@
import org.junit.BeforeClass;
import org.junit.Test;
+/**
+ * @author Alaa Nassef
+ * @author Hardy Ferentschik
+ */
public class PastValidatorForCalendarTest {
private static PastValidatorForCalendar constraint;
@@ -39,7 +43,6 @@
Calendar pastDate = getPastDate();
assertTrue( constraint.isValid( null, null ) );
assertTrue( constraint.isValid( pastDate, null ) );
- assertFalse( constraint.isValid( Calendar.getInstance(), null ) );
assertFalse( constraint.isValid( futureDate, null ) );
}
@@ -56,5 +59,4 @@
cal.set( Calendar.YEAR, year - 1 );
return cal;
}
-
}
16 years, 10 months
Hibernate SVN: r15977 - branches/Branch_3_2/HibernateExt/tools.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2009-02-16 07:06:17 -0500 (Mon, 16 Feb 2009)
New Revision: 15977
Added:
branches/Branch_3_2/HibernateExt/tools/.classpath
branches/Branch_3_2/HibernateExt/tools/.project
Log:
add .project/.classpath since we need it 98% of the time anyway
Added: branches/Branch_3_2/HibernateExt/tools/.classpath
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/.classpath (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/.classpath 2009-02-16 12:06:17 UTC (rev 15977)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/test"/>
+ <classpathentry kind="src" path="src/testsupport"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/freemarker.jar"/>
+ <classpathentry kind="lib" path="lib/jtidy-r8-20060801.jar"/>
+ <classpathentry kind="lib" path="lib/org.eclipse.core.runtime_3.2.0.v20060603.jar"/>
+ <classpathentry kind="lib" path="lib/org.eclipse.equinox.common_3.2.0.v20060603.jar"/>
+ <classpathentry kind="lib" path="lib/org.eclipse.jdt.core_3.2.0.v_671.jar"/>
+ <classpathentry kind="lib" path="lib/org.eclipse.text_3.2.0.v20060605-1400.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/hibernate-3.2"/>
+ <classpathentry kind="lib" path="/hibernate-3.2/lib/commons-logging-1.0.4.jar"/>
+ <classpathentry kind="lib" path="/hibernate-3.2/lib/dom4j-1.6.1.jar"/>
+ <classpathentry kind="lib" path="/hibernate-3.2/lib/ant-1.6.5.jar"/>
+ <classpathentry kind="lib" path="/hibernate-3.2/lib/antlr-2.7.6.jar"/>
+ <classpathentry kind="lib" path="/hibernate-3.2/lib/cglib-2.1.3.jar"/>
+ <classpathentry kind="lib" path="lib/testlibs/commons-collections-2.1.1.jar"/>
+ <classpathentry kind="lib" path="lib/testlibs/commons-logging-1.0.4.jar"/>
+ <classpathentry kind="lib" path="lib/testlibs/dom4j-1.6.1.jar"/>
+ <classpathentry kind="lib" path="lib/testlibs/ejb3-persistence.jar"/>
+ <classpathentry kind="lib" path="lib/testlibs/hibernate3.jar"/>
+ <classpathentry kind="lib" path="lib/testlibs/hibernate-annotations.jar"/>
+ <classpathentry kind="lib" path="lib/testlibs/hibernate-commons-annotations.jar"/>
+ <classpathentry kind="lib" path="lib/testlibs/hibernate-entitymanager.jar"/>
+ <classpathentry kind="lib" path="lib/testlibs/javassist.jar"/>
+ <classpathentry kind="lib" path="lib/testlibs/jboss-annotations-ejb3.jar"/>
+ <classpathentry kind="lib" path="lib/testlibs/jboss-archive-browsing.jar"/>
+ <classpathentry kind="lib" path="lib/testlibs/jboss-ejb3x.jar"/>
+ <classpathentry kind="lib" path="etc"/>
+ <classpathentry kind="lib" path="C:/work/documents/presentations/eclipsecon2008/database/lib/hsqldb.jar"/>
+ <classpathentry kind="output" path="build/classes"/>
+</classpath>
Added: branches/Branch_3_2/HibernateExt/tools/.project
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/.project (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/.project 2009-02-16 12:06:17 UTC (rev 15977)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>hibernateext.tools</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
16 years, 10 months
Hibernate SVN: r15976 - validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report.
by hibernate-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-02-15 23:42:16 -0500 (Sun, 15 Feb 2009)
New Revision: 15976
Modified:
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
Log:
fix package names
Modified: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-02-15 13:52:15 UTC (rev 15975)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-02-16 04:42:16 UTC (rev 15976)
@@ -115,8 +115,6 @@
out.write(("<div class=\"sectionHeader\">Section " + sectionId + " - " +
auditParser.getSectionTitle(sectionId) + "</div>\n").getBytes());
-
- String currentPackageName = null;
for (AuditAssertion assertion : sectionAssertions) {
List<SpecReference> coverage = getCoverageForAssertion(sectionId, assertion.getId());
@@ -135,6 +133,8 @@
sb.append(" <div class=\"coverage\">\n");
sb.append(" <p class=\"coverageHeader\">Coverage</p>\n");
+
+ String currentPackageName = null;
if (coverage.isEmpty()) {
sb.append(" <p class=\"noCoverage\">No tests exist for this assertion</p>\n");
16 years, 10 months
Hibernate SVN: r15975 - validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report.
by hibernate-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-02-15 08:52:15 -0500 (Sun, 15 Feb 2009)
New Revision: 15975
Modified:
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageProcessor.java
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/SpecReference.java
Log:
report styling, add package names
Modified: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageProcessor.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageProcessor.java 2009-02-14 23:46:56 UTC (rev 15974)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageProcessor.java 2009-02-15 13:52:15 UTC (rev 15975)
@@ -20,6 +20,7 @@
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import org.hibernate.tck.annotations.SpecAssertion;
@@ -168,6 +169,9 @@
Map<? extends ExecutableElement, ? extends AnnotationValue> annotationParameters) {
SpecReference ref = new SpecReference();
+
+ PackageElement packageElement = getEnclosingPackageElement(methodElement);
+ ref.setPackageName(packageElement.getQualifiedName().toString());
ref.setClassName(methodElement.getEnclosingElement().getSimpleName().toString());
ref.setMethodName(methodElement.getSimpleName().toString());
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotationParameters.entrySet()) {
@@ -180,5 +184,17 @@
}
}
references.add(ref);
+ }
+
+ private PackageElement getEnclosingPackageElement(ExecutableElement methodElement) {
+ Element classElement = methodElement.getEnclosingElement();
+
+ Element enclosingElement = classElement.getEnclosingElement();
+
+ while (!(enclosingElement instanceof PackageElement) && enclosingElement != null) {
+ enclosingElement = enclosingElement.getEnclosingElement();
+ }
+
+ return (PackageElement) enclosingElement;
}
}
Modified: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-02-14 23:46:56 UTC (rev 15974)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-02-15 13:52:15 UTC (rev 15975)
@@ -53,6 +53,9 @@
sb.append("<head><title>JSR-299 TCK Coverage Report</title>\n");
sb.append("<style type=\"text/css\">\n");
+ sb.append(" body {\n");
+ sb.append(" font-family: verdana, arial, sans-serif;\n");
+ sb.append(" font-size: 11px; }\n");
sb.append(" .code {\n");
sb.append(" float: left;\n");
sb.append(" font-weight: bold;\n");
@@ -65,7 +68,13 @@
sb.append(" margin-top: 2px;\n");
sb.append(" margin-bottom: 2px; }\n");
sb.append(" .sectionHeader {\n");
+ sb.append(" border-bottom: 1px solid #cccccc;\n");
+ sb.append(" margin-top: 8px;\n");
sb.append(" font-weight: bold; }\n");
+ sb.append(" .packageName {\n");
+ sb.append(" color: #999999;\n");
+ sb.append(" font-size: 9px;\n");
+ sb.append(" font-weight: bold; }\n");
sb.append(" .noCoverage {\n");
sb.append(" margin-top: 2px;\n");
sb.append(" margin-bottom: 2px;\n");
@@ -96,6 +105,7 @@
}
private void writeCoverage(OutputStream out) throws IOException {
+
for (String sectionId : auditParser.getSectionIds()) {
List<AuditAssertion> sectionAssertions = auditParser.getAssertionsForSection(sectionId);
@@ -105,6 +115,8 @@
out.write(("<div class=\"sectionHeader\">Section " + sectionId + " - " +
auditParser.getSectionTitle(sectionId) + "</div>\n").getBytes());
+
+ String currentPackageName = null;
for (AuditAssertion assertion : sectionAssertions) {
List<SpecReference> coverage = getCoverageForAssertion(sectionId, assertion.getId());
@@ -128,6 +140,14 @@
sb.append(" <p class=\"noCoverage\">No tests exist for this assertion</p>\n");
} else {
for (SpecReference ref : coverage) {
+ if (!ref.getPackageName().equals(currentPackageName))
+ {
+ currentPackageName = ref.getPackageName();
+ sb.append(" <div class=\"packageName\">");
+ sb.append(currentPackageName);
+ sb.append(" </div>\n");
+ }
+
sb.append(" <div class=\"coverageMethod\">");
sb.append(ref.getClassName());
sb.append(".");
@@ -179,6 +199,9 @@
sb.append("</td>");
sb.append("<td>");
+ sb.append("<div class=\"packageName\">");
+ sb.append(ref.getPackageName());
+ sb.append("</div>");
sb.append(ref.getClassName());
sb.append("</td>");
Modified: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/SpecReference.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/SpecReference.java 2009-02-14 23:46:56 UTC (rev 15974)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/SpecReference.java 2009-02-15 13:52:15 UTC (rev 15975)
@@ -8,6 +8,7 @@
public class SpecReference {
private String section;
private String assertion;
+ private String packageName;
private String className;
private String methodName;
@@ -18,6 +19,10 @@
public void setAssertion(String assertion) {
this.assertion = assertion;
}
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
public void setClassName(String className) {
this.className = className;
@@ -34,6 +39,10 @@
public String getAssertion() {
return assertion;
}
+
+ public String getPackageName() {
+ return packageName;
+ }
public String getClassName() {
return className;
@@ -47,6 +56,6 @@
public String toString()
{
return "SpecReference[section=" + section + ";assertion=" + assertion +
- ";class=" + className + ";method=" + methodName + "]";
+ ";class=" + packageName + "." + className + ";method=" + methodName + "]";
}
}
16 years, 10 months
Hibernate SVN: r15974 - validator/trunk/tck-utils/api/src/main/resources.
by hibernate-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-02-14 18:46:56 -0500 (Sat, 14 Feb 2009)
New Revision: 15974
Modified:
validator/trunk/tck-utils/api/src/main/resources/tck-audit.xsd
Log:
fix xsd
Modified: validator/trunk/tck-utils/api/src/main/resources/tck-audit.xsd
===================================================================
--- validator/trunk/tck-utils/api/src/main/resources/tck-audit.xsd 2009-02-14 23:34:23 UTC (rev 15973)
+++ validator/trunk/tck-utils/api/src/main/resources/tck-audit.xsd 2009-02-14 23:46:56 UTC (rev 15974)
@@ -9,7 +9,7 @@
<xs:documentation> The specification tag is the root element for tck-audit.xml. </xs:documentation>
</xs:annotation>
<xs:complexType>
- <xs:sequence>
+ <xs:sequence maxOccurs="unbounded">
<xs:element ref="audit:section"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
16 years, 10 months
Hibernate SVN: r15973 - validator/trunk/tck-utils/api/src/main/resources.
by hibernate-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-02-14 18:34:23 -0500 (Sat, 14 Feb 2009)
New Revision: 15973
Modified:
validator/trunk/tck-utils/api/src/main/resources/tck-audit.xsd
Log:
Fix xsd
Modified: validator/trunk/tck-utils/api/src/main/resources/tck-audit.xsd
===================================================================
--- validator/trunk/tck-utils/api/src/main/resources/tck-audit.xsd 2009-02-14 23:17:29 UTC (rev 15972)
+++ validator/trunk/tck-utils/api/src/main/resources/tck-audit.xsd 2009-02-14 23:34:23 UTC (rev 15973)
@@ -12,6 +12,8 @@
<xs:sequence>
<xs:element ref="audit:section"/>
</xs:sequence>
+ <xs:attribute name="name" type="xs:string"/>
+ <xs:attribute name="version" type="xs:string"/>
</xs:complexType>
</xs:element>
16 years, 10 months