[hibernate-commits] Hibernate SVN: r17576 - in validator/trunk/hibernate-validator/src: test/java/org/hibernate/validator/constraints and 1 other directory.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Mon Sep 28 12:09:36 EDT 2009


Author: hardy.ferentschik
Date: 2009-09-28 12:09:36 -0400 (Mon, 28 Sep 2009)
New Revision: 17576

Added:
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/Cloneable.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/CloneableConstraintValidator.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/Object.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/ObjectConstraintValidator.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/Serializable.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SerializableConstraintValidator.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SubType.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SuperType.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SuperTypeArray.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SuperTypeArrayValidator.java
Modified:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintTree.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/ValidatorResolutionTest.java
Log:
HV-233 Added tests for section 4.10.3 Subtyping among array types

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintTree.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintTree.java	2009-09-28 13:33:56 UTC (rev 17575)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintTree.java	2009-09-28 16:09:36 UTC (rev 17576)
@@ -220,7 +220,17 @@
 
 	private void verifyResolveWasUnique(Type valueClass, List<Type> assignableClasses) {
 		if ( assignableClasses.size() == 0 ) {
-			throw new UnexpectedTypeException( "No validator could be found for type: " + valueClass );
+			String className = valueClass.toString();
+			if ( valueClass instanceof Class ) {
+				Class<?> clazz = ( Class<?> ) valueClass;
+				if ( clazz.isArray() ) {
+					className = clazz.getComponentType().toString() + "[]";
+				}
+				else {
+					className = clazz.getName();
+				}
+			}
+			throw new UnexpectedTypeException( "No validator could be found for type: " + className );
 		}
 		else if ( assignableClasses.size() > 1 ) {
 			StringBuilder builder = new StringBuilder();

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/Cloneable.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/Cloneable.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/Cloneable.java	2009-09-28 16:09:36 UTC (rev 17576)
@@ -0,0 +1,44 @@
+// $Id: Positive.java 17421 2009-08-26 12:25:39Z hardy.ferentschik $
+/*
+* 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 org.hibernate.validator.constraints;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+ at Constraint(validatedBy = { CloneableConstraintValidator.class })
+ at Target({ METHOD, FIELD, ANNOTATION_TYPE })
+ at Retention(RUNTIME)
+ at Documented
+public @interface Cloneable {
+	public abstract String message() default "{org.hibernate.validator.constraints.Cloneable.message}";
+
+	public abstract Class<?>[] groups() default { };
+
+	public abstract Class<? extends Payload>[] payload() default { };
+}
\ No newline at end of file

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/CloneableConstraintValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/CloneableConstraintValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/CloneableConstraintValidator.java	2009-09-28 16:09:36 UTC (rev 17576)
@@ -0,0 +1,34 @@
+// $Id: PositiveConstraintValidator.java 17421 2009-08-26 12:25:39Z hardy.ferentschik $
+/*
+* 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 org.hibernate.validator.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class CloneableConstraintValidator implements ConstraintValidator<Cloneable, java.lang.Cloneable> {
+
+	public void initialize(Cloneable annotation) {
+	}
+
+	public boolean isValid(java.lang.Cloneable value, ConstraintValidatorContext constraintValidatorContext) {
+		return true;
+	}
+}
\ No newline at end of file

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/Object.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/Object.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/Object.java	2009-09-28 16:09:36 UTC (rev 17576)
@@ -0,0 +1,44 @@
+// $Id: Positive.java 17421 2009-08-26 12:25:39Z hardy.ferentschik $
+/*
+* 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 org.hibernate.validator.constraints;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+ at Constraint(validatedBy = { ObjectConstraintValidator.class })
+ at Target({ METHOD, FIELD, ANNOTATION_TYPE })
+ at Retention(RUNTIME)
+ at Documented
+public @interface Object {
+	String message() default "{org.hibernate.validator.constraints.Object.message}";
+
+	Class<?>[] groups() default { };
+
+	Class<? extends Payload>[] payload() default { };
+}
\ No newline at end of file

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/ObjectConstraintValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/ObjectConstraintValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/ObjectConstraintValidator.java	2009-09-28 16:09:36 UTC (rev 17576)
@@ -0,0 +1,34 @@
+// $Id: PositiveConstraintValidator.java 17421 2009-08-26 12:25:39Z hardy.ferentschik $
+/*
+* 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 org.hibernate.validator.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class ObjectConstraintValidator implements ConstraintValidator<Object, java.lang.Object> {
+
+	public void initialize(Object annotation) {
+	}
+
+	public boolean isValid(java.lang.Object value, ConstraintValidatorContext constraintValidatorContext) {
+		return true;
+	}
+}
\ No newline at end of file

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/Serializable.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/Serializable.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/Serializable.java	2009-09-28 16:09:36 UTC (rev 17576)
@@ -0,0 +1,44 @@
+// $Id: Positive.java 17421 2009-08-26 12:25:39Z hardy.ferentschik $
+/*
+* 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 org.hibernate.validator.constraints;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+ at Constraint(validatedBy = { SerializableConstraintValidator.class })
+ at Target({ METHOD, FIELD, ANNOTATION_TYPE })
+ at Retention(RUNTIME)
+ at Documented
+public @interface Serializable {
+	public abstract String message() default "{org.hibernate.validator.constraints.Serializable.message}";
+
+	public abstract Class<?>[] groups() default { };
+
+	public abstract Class<? extends Payload>[] payload() default { };
+}
\ No newline at end of file

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SerializableConstraintValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SerializableConstraintValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SerializableConstraintValidator.java	2009-09-28 16:09:36 UTC (rev 17576)
@@ -0,0 +1,34 @@
+// $Id: PositiveConstraintValidator.java 17421 2009-08-26 12:25:39Z hardy.ferentschik $
+/*
+* 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 org.hibernate.validator.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class SerializableConstraintValidator implements ConstraintValidator<Serializable, java.io.Serializable > {
+
+	public void initialize(Serializable annotation) {
+	}
+
+	public boolean isValid( java.io.Serializable value, ConstraintValidatorContext constraintValidatorContext) {
+		return true;
+	}
+}
\ No newline at end of file

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SubType.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SubType.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SubType.java	2009-09-28 16:09:36 UTC (rev 17576)
@@ -0,0 +1,24 @@
+// $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 org.hibernate.validator.constraints;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class SubType extends SuperType {
+}
\ No newline at end of file


Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SubType.java
___________________________________________________________________
Name: svn:keywords
   + Id

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SuperType.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SuperType.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SuperType.java	2009-09-28 16:09:36 UTC (rev 17576)
@@ -0,0 +1,24 @@
+// $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 org.hibernate.validator.constraints;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class SuperType {
+}

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SuperTypeArray.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SuperTypeArray.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SuperTypeArray.java	2009-09-28 16:09:36 UTC (rev 17576)
@@ -0,0 +1,44 @@
+// $Id: Positive.java 17421 2009-08-26 12:25:39Z hardy.ferentschik $
+/*
+* 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 org.hibernate.validator.constraints;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+ at Constraint(validatedBy = { SuperTypeArrayValidator.class })
+ at Target({ METHOD, FIELD, ANNOTATION_TYPE })
+ at Retention(RUNTIME)
+ at Documented
+public @interface SuperTypeArray {
+	public abstract String message() default "{org.hibernate.validator.constraints.SuperTypeArray.message}";
+
+	public abstract Class<?>[] groups() default { };
+
+	public abstract Class<? extends Payload>[] payload() default { };
+}
\ No newline at end of file

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SuperTypeArrayValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SuperTypeArrayValidator.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/SuperTypeArrayValidator.java	2009-09-28 16:09:36 UTC (rev 17576)
@@ -0,0 +1,34 @@
+// $Id: PositiveConstraintValidator.java 17421 2009-08-26 12:25:39Z hardy.ferentschik $
+/*
+* 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 org.hibernate.validator.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class SuperTypeArrayValidator implements ConstraintValidator<SuperTypeArray, SuperType[]> {
+
+	public void initialize(SuperTypeArray annotation) {
+	}
+
+	public boolean isValid(SuperType[] value, ConstraintValidatorContext constraintValidatorContext) {
+		return true;
+	}
+}
\ No newline at end of file

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/ValidatorResolutionTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/ValidatorResolutionTest.java	2009-09-28 13:33:56 UTC (rev 17575)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/constraints/ValidatorResolutionTest.java	2009-09-28 16:09:36 UTC (rev 17576)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
 /*
 * JBoss, Home of Professional Open Source
 * Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -113,4 +113,100 @@
 		constraintViolations = validator.validate( suburb );
 		assertNumberOfViolations( constraintViolations, 0 );
 	}
+
+	/**
+	 * HV-233
+	 */
+	@Test
+	public void testObjectArraysAndPrimitiveArraysAreSubtypesOfObject() {
+		Validator validator = TestUtil.getValidator();
+
+		Foo testEntity = new Foo( new Object[] { }, new int[] { } );
+		Set<ConstraintViolation<Foo>> constraintViolations = validator.validate( testEntity );
+		assertNumberOfViolations( constraintViolations, 0 );
+	}
+
+	/**
+	 * HV-233
+	 */
+	@Test
+	public void testObjectArraysAndPrimitiveArraysAreSubtypesOfClonable() {
+		Validator validator = TestUtil.getValidator();
+
+		Bar testEntity = new Bar( new Object[] { }, new int[] { } );
+		Set<ConstraintViolation<Bar>> constraintViolations = validator.validate( testEntity );
+		assertNumberOfViolations( constraintViolations, 0 );
+	}
+
+	/**
+	 * HV-233
+	 */
+	@Test
+	public void testObjectArraysAndPrimitiveArraysAreSubtypesOfSerializable() {
+		Validator validator = TestUtil.getValidator();
+
+		Fubar testEntity = new Fubar( new Object[] { }, new int[] { } );
+		Set<ConstraintViolation<Fubar>> constraintViolations = validator.validate( testEntity );
+		assertNumberOfViolations( constraintViolations, 0 );
+	}
+
+	/**
+	 * HV-233
+	 */
+	@Test
+	public void testSubTypeArrayIsSubtypeOfSuperTypeArray() {
+		Validator validator = TestUtil.getValidator();
+
+		SubTypeEntity testEntity = new SubTypeEntity( new SubType[] { } );
+		Set<ConstraintViolation<SubTypeEntity>> constraintViolations = validator.validate( testEntity );
+		assertNumberOfViolations( constraintViolations, 0 );
+	}
+
+	public class Foo {
+		@Object
+		private Object[] objectArray;
+
+		@Object
+		private int[] intArray;
+
+		public Foo(Object[] objectArray, int[] intArray) {
+			this.objectArray = objectArray;
+			this.intArray = intArray;
+		}
+	}
+
+	public class Bar {
+		@Cloneable
+		private Object[] objectArray;
+
+		@Cloneable
+		private int[] intArray;
+
+		public Bar(Object[] objectArray, int[] intArray) {
+			this.objectArray = objectArray;
+			this.intArray = intArray;
+		}
+	}
+
+	public class Fubar {
+		@Serializable
+		private Object[] objectArray;
+
+		@Serializable
+		private int[] intArray;
+
+		public Fubar(Object[] objectArray, int[] intArray) {
+			this.objectArray = objectArray;
+			this.intArray = intArray;
+		}
+	}
+
+	public class SubTypeEntity {
+		@SuperTypeArray
+		private SubType[] subTypeArray;
+
+		public SubTypeEntity(SubType[] subTypeArray) {
+			this.subTypeArray = subTypeArray;
+		}
+	}
 }



More information about the hibernate-commits mailing list