Author: hardy.ferentschik
Date: 2009-05-11 08:28:36 -0400 (Mon, 11 May 2009)
New Revision: 16530
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java
Log:
make annotation complie again with java 5
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java 2009-05-11
12:19:43 UTC (rev 16529)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java 2009-05-11
12:28:36 UTC (rev 16530)
@@ -1,5 +1,6 @@
package org.hibernate.test.annotations.beanvalidation;
+import java.lang.annotation.Annotation;
import java.math.BigDecimal;
import javax.validation.ConstraintViolationException;
import javax.validation.constraints.NotNull;
@@ -8,7 +9,6 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.annotations.reflection.XMLContext;
import org.hibernate.test.annotations.TestCase;
/**
@@ -18,32 +18,39 @@
public void testListeners() {
CupHolder ch = new CupHolder();
ch.setRadius( new BigDecimal( "12" ) );
- Session s = openSession( );
+ Session s = openSession();
Transaction tx = s.beginTransaction();
try {
s.persist( ch );
s.flush();
}
catch ( ConstraintViolationException e ) {
- fail("invalid object should not be validated");
+ fail( "invalid object should not be validated" );
}
try {
ch.setRadius( null );
s.flush();
}
catch ( ConstraintViolationException e ) {
- fail("invalid object should not be validated");
+ fail( "invalid object should not be validated" );
}
try {
s.delete( ch );
s.flush();
- fail("invalid object should not be persisted");
+ fail( "invalid object should not be persisted" );
}
catch ( ConstraintViolationException e ) {
assertEquals( 1, e.getConstraintViolations().size() );
- assertEquals( NotNull.class,
- e.getConstraintViolations().iterator().next().getConstraintDescriptor().getAnnotation().annotationType()
- );
+ // TODO - seems this explicit case is necessary with JDK 5 (at least on Mac). With
Java 6 there is no problem
+ Annotation annotation = (Annotation) e.getConstraintViolations()
+ .iterator()
+ .next()
+ .getConstraintDescriptor()
+ .getAnnotation();
+ assertEquals(
+ NotNull.class,
+ annotation.annotationType()
+ );
}
tx.rollback();
s.close();
@@ -52,12 +59,18 @@
@Override
protected void configure(Configuration cfg) {
super.configure( cfg );
- cfg.setProperty( "javax.persistence.validation.group.pre-persist",
- "" );
- cfg.setProperty( "javax.persistence.validation.group.pre-update",
- "" );
- cfg.setProperty( "javax.persistence.validation.group.pre-remove",
- Default.class.getName() + ", " + Strict.class.getName() );
+ cfg.setProperty(
+ "javax.persistence.validation.group.pre-persist",
+ ""
+ );
+ cfg.setProperty(
+ "javax.persistence.validation.group.pre-update",
+ ""
+ );
+ cfg.setProperty(
+ "javax.persistence.validation.group.pre-remove",
+ Default.class.getName() + ", " + Strict.class.getName()
+ );
}
protected Class<?>[] getMappings() {
Show replies by date