Author: epbernard
Date: 2007-08-11 02:47:32 -0400 (Sat, 11 Aug 2007)
New Revision: 12922
Removed:
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ValidatorIntegrationTest.java
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ejb3configuration/EventOverridingTest.java
Modified:
trunk/HibernateExt/entitymanager/build.properties.dist
trunk/HibernateExt/entitymanager/build.xml
trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/EventListenerConfigurator.java
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/Cat.java
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java
Log:
Remove dependency in tests from em -> validator
Modified: trunk/HibernateExt/entitymanager/build.properties.dist
===================================================================
--- trunk/HibernateExt/entitymanager/build.properties.dist 2007-08-11 06:47:02 UTC (rev
12921)
+++ trunk/HibernateExt/entitymanager/build.properties.dist 2007-08-11 06:47:32 UTC (rev
12922)
@@ -8,6 +8,5 @@
#locally present jars
jpa-api.jar=./lib/ejb3-persistence.jar
-validator.jar=./lib/hibernate-validator.jar
commons-annotations.jar=./lib/hibernate-commons-annotations.jar
annotations.jar=./lib/hibernate-annotations.jar
\ No newline at end of file
Modified: trunk/HibernateExt/entitymanager/build.xml
===================================================================
--- trunk/HibernateExt/entitymanager/build.xml 2007-08-11 06:47:02 UTC (rev 12921)
+++ trunk/HibernateExt/entitymanager/build.xml 2007-08-11 06:47:32 UTC (rev 12922)
@@ -28,8 +28,6 @@
<property name="jpa-api.jar"
value="${basedir}/../jpa-api/build/ejb3-persistence.jar"/>
<property name="annotations.jar"
value="${basedir}/../annotations/target/hibernate-annotations/hibernate-annotations.jar"/>
- <property name="validator.jar"
-
value="${basedir}/../validator/target/hibernate-validator/hibernate-validator.jar"/>
<property name="commons-annotations.jar"
value="${basedir}/../commons-annotations/target/hibernate-commons-annotations/hibernate-commons-annotations.jar"/>
@@ -46,7 +44,6 @@
<pathelement location="${jpa-api.jar}"/>
<pathelement location="${commons-annotations.jar}"/>
<pathelement location="${annotations.jar}"/>
- <pathelement location="${validator.jar}"/>
</path>
<path id="junit.moduleclasspath">
<pathelement location="${src.dir}"/>
@@ -67,7 +64,6 @@
<available file="${jpa-api.jar}" type="file"
property="jpa-api.jar.available"/>
<available file="${commons-annotations.jar}" type="file"
property="commons-annotations.jar.available"/>
<available file="${annotations.jar}" type="file"
property="annotations.jar.available"/>
- <available file="${validator.jar}" type="file"
property="validator.jar.available"/>
<mkdir dir="${lib.dir}/test"/>
</target>
@@ -86,12 +82,7 @@
<ant inheritall="false" dir="${basedir}/../annotations"
target="jar"/>
</target>
- <target name="get.validator" depends="init"
unless="validator.jar.available">
- <ant inheritall="false" dir="${basedir}/../validator"
target="clean"/>
- <ant inheritall="false" dir="${basedir}/../validator"
target="jar"/>
- </target>
-
- <target name="compile"
depends="init,get.jpa-api,get.commons-annotations,get.annotations,get.validator"
description="Compile the Java source code">
+ <target name="compile"
depends="init,get.jpa-api,get.commons-annotations,get.annotations"
description="Compile the Java source code">
<available
classname="org.eclipse.core.launcher.Main"
property="build.compiler"
@@ -334,7 +325,6 @@
<fileset file="${jpa-api.jar}"/>
<fileset file="${commons-annotations.jar}"/>
<fileset file="${annotations.jar}"/>
- <fileset file="${validator.jar}"/>
</copy>
<mkdir dir="${dist.lib.dir}/test"/>
Modified:
trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/EventListenerConfigurator.java
===================================================================
---
trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/EventListenerConfigurator.java 2007-08-11
06:47:02 UTC (rev 12921)
+++
trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/EventListenerConfigurator.java 2007-08-11
06:47:32 UTC (rev 12922)
@@ -14,6 +14,7 @@
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
+import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.ejb.event.CallbackHandlerConsumer;
import org.hibernate.ejb.event.EJB3AutoFlushEventListener;
import org.hibernate.ejb.event.EJB3DeleteEventListener;
@@ -46,13 +47,11 @@
import org.hibernate.event.PreUpdateEventListener;
import org.hibernate.event.SaveOrUpdateEventListener;
import org.hibernate.mapping.PersistentClass;
-import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.secure.JACCPreDeleteEventListener;
import org.hibernate.secure.JACCPreInsertEventListener;
import org.hibernate.secure.JACCPreLoadEventListener;
import org.hibernate.secure.JACCPreUpdateEventListener;
import org.hibernate.secure.JACCSecurityListener;
-import org.hibernate.validator.event.ValidateEventListener;
/**
* @author Emmanuel Bernard
@@ -69,57 +68,57 @@
//Action event
//EJB3-specific ops listeners
- listenerConfig.setFlushEventListeners( new
FlushEventListener[]{EJB3FlushEventListener.INSTANCE} );
+ listenerConfig.setFlushEventListeners( new FlushEventListener[] {
EJB3FlushEventListener.INSTANCE } );
//EJB3-specific ops listeners
- listenerConfig.setAutoFlushEventListeners( new
AutoFlushEventListener[]{EJB3AutoFlushEventListener.INSTANCE} );
- listenerConfig.setDeleteEventListeners( new DeleteEventListener[]{new
EJB3DeleteEventListener()} );
+ listenerConfig.setAutoFlushEventListeners( new AutoFlushEventListener[] {
EJB3AutoFlushEventListener.INSTANCE } );
+ listenerConfig.setDeleteEventListeners( new DeleteEventListener[] { new
EJB3DeleteEventListener() } );
listenerConfig.setFlushEntityEventListeners(
- new FlushEntityEventListener[]{new EJB3FlushEntityEventListener()}
+ new FlushEntityEventListener[] { new EJB3FlushEntityEventListener() }
);
- listenerConfig.setMergeEventListeners( new MergeEventListener[]{new
EJB3MergeEventListener()} );
- listenerConfig.setPersistEventListeners( new PersistEventListener[]{new
EJB3PersistEventListener()} );
+ listenerConfig.setMergeEventListeners( new MergeEventListener[] { new
EJB3MergeEventListener() } );
+ listenerConfig.setPersistEventListeners( new PersistEventListener[] { new
EJB3PersistEventListener() } );
listenerConfig.setPersistOnFlushEventListeners(
- new PersistEventListener[]{new EJB3PersistOnFlushEventListener()}
+ new PersistEventListener[] { new EJB3PersistOnFlushEventListener() }
);
- listenerConfig.setSaveEventListeners( new SaveOrUpdateEventListener[]{new
EJB3SaveEventListener()} );
+ listenerConfig.setSaveEventListeners( new SaveOrUpdateEventListener[] { new
EJB3SaveEventListener() } );
listenerConfig.setSaveOrUpdateEventListeners(
- new SaveOrUpdateEventListener[]{new EJB3SaveOrUpdateEventListener()}
+ new SaveOrUpdateEventListener[] { new EJB3SaveOrUpdateEventListener() }
);
//Pre events
listenerConfig.setPreInsertEventListeners(
- new PreInsertEventListener[]{
+ new PreInsertEventListener[] {
new JACCPreInsertEventListener(),
}
);
listenerConfig.setPreUpdateEventListeners(
- new PreUpdateEventListener[]{
+ new PreUpdateEventListener[] {
new JACCPreUpdateEventListener(),
}
);
listenerConfig.setPreDeleteEventListeners(
- new PreDeleteEventListener[]{
+ new PreDeleteEventListener[] {
new JACCPreDeleteEventListener()
}
);
listenerConfig.setPreLoadEventListeners(
- new PreLoadEventListener[]{
+ new PreLoadEventListener[] {
new JACCPreLoadEventListener()
}
);
//post events
listenerConfig.setPostDeleteEventListeners(
- new PostDeleteEventListener[]{new EJB3PostDeleteEventListener()}
+ new PostDeleteEventListener[] { new EJB3PostDeleteEventListener() }
);
listenerConfig.setPostInsertEventListeners(
- new PostInsertEventListener[]{new EJB3PostInsertEventListener()}
+ new PostInsertEventListener[] { new EJB3PostInsertEventListener() }
);
listenerConfig.setPostLoadEventListeners(
- new PostLoadEventListener[]{new EJB3PostLoadEventListener()}
+ new PostLoadEventListener[] { new EJB3PostLoadEventListener() }
);
listenerConfig.setPostUpdateEventListeners(
- new PostUpdateEventListener[]{new EJB3PostUpdateEventListener()}
+ new PostUpdateEventListener[] { new EJB3PostUpdateEventListener() }
);
}
@@ -138,7 +137,7 @@
while ( st.hasMoreElements() ) {
listeners.add( (String) st.nextElement() );
}
- configuration.setListeners( type, listeners.toArray( new String[ listeners.size() ] )
);
+ configuration.setListeners( type, listeners.toArray( new String[listeners.size()] )
);
}
}
}
@@ -158,7 +157,7 @@
callbackHandler.add( reflectionManager.classForName( clazz.getClassName(),
this.getClass() ), reflectionManager );
}
catch (ClassNotFoundException e) {
- throw new MappingException("entity class not found: " +
clazz.getNodeName(), e);
+ throw new MappingException( "entity class not found: " +
clazz.getNodeName(), e );
}
}
}
@@ -170,7 +169,7 @@
beanInfo = Introspector.getBeanInfo( listenerConfig.getClass(), Object.class );
PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
try {
- for ( int i = 0, max = pds.length; i < max ; i++ ) {
+ for (int i = 0, max = pds.length; i < max; i++) {
final Object listeners = pds[i].getReadMethod().invoke( listenerConfig,
READER_METHOD_ARGS );
if ( listeners == null ) {
throw new HibernateException( "Listener [" + pds[i].getName() + "]
was null" );
@@ -178,7 +177,7 @@
if ( listeners instanceof Object[] ) {
int securityListenersNbr = 0;
Object[] listenersArray = (Object[]) listeners;
- for ( Object listener : listenersArray ) {
+ for (Object listener : listenersArray) {
if ( listener != null && listener instanceof CallbackHandlerConsumer ) {
( (CallbackHandlerConsumer) listener ).setCallbackHandler( callbackHandler );
}
@@ -192,8 +191,8 @@
Class clazz = pds[i].getReadMethod().getReturnType().getComponentType();
Object newArray = Array.newInstance( clazz, listenersArray.length -
securityListenersNbr );
int index = 0;
- for ( Object listener : listenersArray ) {
- if ( ! ( listener != null && listener instanceof JACCSecurityListener ) )
{
+ for (Object listener : listenersArray) {
+ if ( !( listener != null && listener instanceof JACCSecurityListener ) )
{
Array.set( newArray, index++, listener );
}
}
Modified: trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/Cat.java
===================================================================
--- trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/Cat.java 2007-08-11
06:47:02 UTC (rev 12921)
+++ trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/Cat.java 2007-08-11
06:47:32 UTC (rev 12922)
@@ -20,14 +20,11 @@
import javax.persistence.TemporalType;
import javax.persistence.Transient;
-import org.hibernate.validator.Length;
-import org.hibernate.validator.Min;
-
/**
* @author Emmanuel Bernard
*/
@Entity
-(a)EntityListeners(LastUpdateListener.class)
+@EntityListeners( LastUpdateListener.class )
public class Cat implements Serializable {
private Integer id;
private String name;
@@ -49,7 +46,6 @@
this.id = id;
}
- @Length(min = 4)
public String getName() {
return name;
}
@@ -84,7 +80,7 @@
}
@Basic
- @Temporal(TemporalType.TIMESTAMP)
+ @Temporal( TemporalType.TIMESTAMP )
public Date getLastUpdate() {
return lastUpdate;
}
@@ -128,7 +124,6 @@
return Collections.unmodifiableList( ids );
}
- @Min(0)
public long getLength() {
return length;
}
Modified:
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java
===================================================================
---
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java 2007-08-11
06:47:02 UTC (rev 12921)
+++
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java 2007-08-11
06:47:32 UTC (rev 12922)
@@ -22,13 +22,11 @@
import org.hibernate.ejb.test.pack.explodedpar.Elephant;
import org.hibernate.ejb.test.pack.externaljar.Scooter;
import org.hibernate.ejb.test.pack.spacepar.Bug;
-import org.hibernate.ejb.test.pack.various.Seat;
import org.hibernate.ejb.test.pack.various.Airplane;
-import org.hibernate.stat.Statistics;
-import org.hibernate.validator.InvalidStateException;
-import org.hibernate.JDBCException;
-import org.hibernate.event.EventListeners;
+import org.hibernate.ejb.test.pack.various.Seat;
import org.hibernate.engine.SessionImplementor;
+import org.hibernate.event.EventListeners;
+import org.hibernate.stat.Statistics;
//$Id$
@@ -38,7 +36,7 @@
public class PackagedEntityManagerTest extends TestCase {
public Class[] getAnnotatedClasses() {
- return new Class[]{
+ return new Class[] {
};
}
@@ -141,7 +139,7 @@
if ( nested == null ) throw e;
nested = nested.getCause();
if ( nested == null ) throw e;
- if ( ! ( nested instanceof ClassNotFoundException ) ) throw e;
+ if ( !( nested instanceof ClassNotFoundException ) ) throw e;
fail( "Try to process hbm file: " + e.getMessage() );
}
EntityManager em = emf.createEntityManager();
@@ -184,7 +182,7 @@
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "space
par", new HashMap() );
EntityManager em = emf.createEntityManager();
Bug bug = new Bug();
- bug.setSubject( "Spaces in directory name don't play well on Windows");
+ bug.setSubject( "Spaces in directory name don't play well on Windows" );
em.getTransaction().begin();
em.persist( bug );
em.flush();
@@ -205,7 +203,7 @@
EntityManagerFactory emf = Persistence.createEntityManagerFactory(
"overridenpar", properties );
EntityManager em = emf.createEntityManager();
org.hibernate.ejb.test.pack.overridenpar.Bug bug = new
org.hibernate.ejb.test.pack.overridenpar.Bug();
- bug.setSubject( "Allow DS overriding");
+ bug.setSubject( "Allow DS overriding" );
em.getTransaction().begin();
em.persist( bug );
em.flush();
@@ -221,10 +219,10 @@
EntityManagerFactory emf = Persistence.createEntityManagerFactory(
"manager1", new HashMap() );
EntityManager em = emf.createEntityManager();
EventListeners eventListeners = ( (SessionImplementor) em.getDelegate()
).getListeners();
- assertEquals(
+ assertEquals(
"Explicit pre-insert event through hibernate.ejb.event.pre-insert does not
work",
eventListeners.getPreInsertEventListeners().length,
- eventListeners.getPreUpdateEventListeners().length + 1);
+ eventListeners.getPreUpdateEventListeners().length + 1 );
em.close();
emf.close();
@@ -388,7 +386,7 @@
second = em.find( Item.class, item.getName() );
assertEquals( 1, second.getDistributors().size() );
assertEquals( 3, stats.getSecondLevelCacheHitCount() );
- for ( Distributor distro : second.getDistributors() ) {
+ for (Distributor distro : second.getDistributors()) {
em.remove( distro );
}
em.remove( second );
@@ -422,7 +420,7 @@
Seat seat = new Seat();
seat.setNumber( "3B" );
Airplane plane = new Airplane();
- plane.setSerialNumber( "75924418409052355");
+ plane.setSerialNumber( "75924418409052355" );
em.getTransaction().begin();
em.persist( seat );
em.persist( plane );
Deleted:
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ValidatorIntegrationTest.java
===================================================================
---
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ValidatorIntegrationTest.java 2007-08-11
06:47:02 UTC (rev 12921)
+++
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ValidatorIntegrationTest.java 2007-08-11
06:47:32 UTC (rev 12922)
@@ -1,41 +0,0 @@
-//$Id$
-package org.hibernate.ejb.test;
-
-import java.util.Date;
-import javax.persistence.EntityManager;
-
-import org.hibernate.validator.InvalidStateException;
-
-/**
- * @author Emmanuel Bernard
- */
-public class ValidatorIntegrationTest extends TestCase {
-
- public void testPropertyValidation() throws Exception {
- EntityManager em = factory.createEntityManager();
- Cat cat = new Cat();
- cat.setAge( 33 );
- cat.setDateOfBirth( new Date() );
- cat.setName( "iti" );
- em.getTransaction().begin();
- try {
- em.persist( cat );
- em.flush();
- fail( "No validation" );
- }
- catch (InvalidStateException e) {
- //success
- }
- finally {
- em.getTransaction().rollback();
- em.close();
- }
-
- }
-
- public Class[] getAnnotatedClasses() {
- return new Class[]{
- Cat.class
- };
- }
-}
Deleted:
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ejb3configuration/EventOverridingTest.java
===================================================================
---
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ejb3configuration/EventOverridingTest.java 2007-08-11
06:47:02 UTC (rev 12921)
+++
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ejb3configuration/EventOverridingTest.java 2007-08-11
06:47:32 UTC (rev 12922)
@@ -1,50 +0,0 @@
-//$Id$
-package org.hibernate.ejb.test.ejb3configuration;
-
-import java.util.HashMap;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-
-import org.hibernate.ejb.test.Cat;
-import org.hibernate.ejb.HibernateEntityManagerFactory;
-import org.hibernate.event.EventListeners;
-import org.hibernate.event.PreInsertEventListener;
-import org.hibernate.Session;
-import org.hibernate.engine.SessionImplementor;
-
-/**
- * @author Emmanuel Bernard
- */
-public class EventOverridingTest extends TestCase {
-
- public void testEventOverriding() throws Exception {
- EventListeners eventListeners = configuration.getEventListeners();
- assertEquals( 1, eventListeners.getPreInsertEventListeners().length );
- eventListeners.setPreInsertEventListeners( new PreInsertEventListener[]{} );
- Cat cat = new Cat();
- cat.setLength( 3 );
- cat.setAge( 34 );
- cat.setName( "Did" ); //should raise a validation exception
- EntityManagerFactory entityManagerFactory =
configuration.createEntityManagerFactory();
- EntityManager em = entityManagerFactory.createEntityManager();
- assertEquals( "only validator should be present", 1,
- ( (SessionImplementor) em.getDelegate()
).getListeners().getPreInsertEventListeners().length);
- em.close();
- }
-
- public void testEventPerProperties() throws Exception {
- EntityManagerFactory emf = Persistence.createEntityManagerFactory(
"manager1", new HashMap() );
- EntityManager em = emf.createEntityManager();
- assertEquals( "Only validator and explicit NoOp should be present", 2,
- ( (SessionImplementor) em.getDelegate()
).getListeners().getPreInsertEventListeners().length);
- em.close();
- emf.close();
- }
-
- public Class[] getAnnotatedClasses() {
- return new Class[]{
- Cat.class
- };
- }
-}