Hibernate SVN: r16784 - search/trunk.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-15 05:38:05 -0400 (Mon, 15 Jun 2009)
New Revision: 16784
Modified:
search/trunk/pom.xml
Log:
Added distribution management section to be able to deploy snapshots.
Explicitly configured the maven-source-plugin
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2009-06-14 22:23:14 UTC (rev 16783)
+++ search/trunk/pom.xml 2009-06-15 09:38:05 UTC (rev 16784)
@@ -222,6 +222,20 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<stylesheetfile>${basedir}/src/main/javadoc/jdstyle.css</stylesheetfile>
@@ -265,6 +279,21 @@
</testResource>
</testResources>
</build>
+
+ <distributionManagement>
+ <repository>
+ <!-- Copy the dist to the local checkout of the JBoss maven2 repo ${maven.repository.root} -->
+ <!-- It is anticipated that ${maven.repository.root} be set in user's settings.xml -->
+ <!-- todo : replace this with direct svn access once the svnkit providers are available -->
+ <id>repository.jboss.org</id>
+ <url>file://${maven.repository.root}</url>
+ </repository>
+ <snapshotRepository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <url>dav:https://snapshots.jboss.org/maven2</url>
+ </snapshotRepository>
+ </distributionManagement>
<profiles>
<!-- =============================== -->
15 years, 5 months
Hibernate SVN: r16783 - search/branches/Branch_3_1.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2009-06-14 18:23:14 -0400 (Sun, 14 Jun 2009)
New Revision: 16783
Modified:
search/branches/Branch_3_1/pom.xml
Log:
HSEARCH-380 exclude solr-lucene-core from transitive maven dependencies
Modified: search/branches/Branch_3_1/pom.xml
===================================================================
--- search/branches/Branch_3_1/pom.xml 2009-06-14 16:32:32 UTC (rev 16782)
+++ search/branches/Branch_3_1/pom.xml 2009-06-14 22:23:14 UTC (rev 16783)
@@ -597,6 +597,10 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.apache.solr</groupId>
+ <artifactId>solr-lucene-core</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
15 years, 5 months
Hibernate SVN: r16782 - search/trunk.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2009-06-14 12:32:32 -0400 (Sun, 14 Jun 2009)
New Revision: 16782
Modified:
search/trunk/pom.xml
Log:
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2009-06-13 01:52:01 UTC (rev 16781)
+++ search/trunk/pom.xml 2009-06-14 16:32:32 UTC (rev 16782)
@@ -591,6 +591,10 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.apache.solr</groupId>
+ <artifactId>solr-lucene-core</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
15 years, 5 months
Hibernate SVN: r16781 - search/trunk/src/test/java/org/hibernate/search/test/shards.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-06-12 21:52:01 -0400 (Fri, 12 Jun 2009)
New Revision: 16781
Modified:
search/trunk/src/test/java/org/hibernate/search/test/shards/Email.java
Log:
HSEARCH-251 add integration test
Modified: search/trunk/src/test/java/org/hibernate/search/test/shards/Email.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/Email.java 2009-06-13 01:48:33 UTC (rev 16780)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/Email.java 2009-06-13 01:52:01 UTC (rev 16781)
@@ -12,9 +12,7 @@
@Entity
@Indexed(index="Email")
-@FullTextFilterDefs( {
- @FullTextFilterDef(name="shard", impl= ShardSensitiveOnlyFilter.class)
-})
+@FullTextFilterDef(name="shard", impl= ShardSensitiveOnlyFilter.class)
public class Email {
@Id
15 years, 5 months
Hibernate SVN: r16780 - in search/trunk/src: test/java/org/hibernate/search/test/shards and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-06-12 21:48:33 -0400 (Fri, 12 Jun 2009)
New Revision: 16780
Added:
search/trunk/src/test/java/org/hibernate/search/test/shards/DirectoryProviderForQueryTest.java
search/trunk/src/test/java/org/hibernate/search/test/shards/Email.java
search/trunk/src/test/java/org/hibernate/search/test/shards/SpecificShardingStrategy.java
Modified:
search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java
Log:
HSEARCH-251 add integration test
Modified: search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java 2009-06-13 01:47:28 UTC (rev 16779)
+++ search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java 2009-06-13 01:48:33 UTC (rev 16780)
@@ -53,6 +53,7 @@
import org.hibernate.search.filter.CachingWrapperFilter;
import org.hibernate.search.filter.FilterCachingStrategy;
import org.hibernate.search.filter.MRUFilterCachingStrategy;
+import org.hibernate.search.filter.ShardSensitiveOnlyFilter;
import org.hibernate.search.reader.ReaderProvider;
import org.hibernate.search.reader.ReaderProviderFactory;
import org.hibernate.search.store.DirectoryProvider;
@@ -240,6 +241,11 @@
}
FilterDef filterDef = new FilterDef( defAnn );
+ if ( filterDef.getImpl().equals( ShardSensitiveOnlyFilter.class ) ) {
+ //this is a placeholder don't process regularly
+ filterDefinitions.put( defAnn.name(), filterDef );
+ return;
+ }
try {
filterDef.getImpl().newInstance();
}
Added: search/trunk/src/test/java/org/hibernate/search/test/shards/DirectoryProviderForQueryTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/DirectoryProviderForQueryTest.java (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/DirectoryProviderForQueryTest.java 2009-06-13 01:48:33 UTC (rev 16780)
@@ -0,0 +1,107 @@
+// $Id: ShardsTest.java 16210 2009-03-25 10:07:47Z hardy.ferentschik $
+package org.hibernate.search.test.shards;
+
+import java.io.File;
+import java.util.List;
+
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.util.FileHelper;
+import org.hibernate.search.store.RAMDirectoryProvider;
+import org.hibernate.search.store.FSDirectoryProvider;
+import org.hibernate.search.store.IdHashShardingStrategy;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.Environment;
+import org.hibernate.search.FullTextQuery;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.TermDocs;
+import org.apache.lucene.index.Term;
+
+/**
+ * @author Chase Seibert
+ */
+public class DirectoryProviderForQueryTest extends SearchTestCase {
+
+
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( "hibernate.search.default.directory_provider", FSDirectoryProvider.class.getName() );
+ File sub = getBaseIndexDir();
+ cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath() );
+ cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
+ // this strategy allows the caller to use a pre-search filter to define which index to hit
+ cfg.setProperty( "hibernate.search.Email.sharding_strategy", SpecificShardingStrategy.class.getCanonicalName() );
+ cfg.setProperty( "hibernate.search.Email.sharding_strategy.nbr_of_shards", "2" );
+ }
+
+ /**
+ * Test that you can filter by shard
+ */
+ public void testDirectoryProviderForQuery() throws Exception {
+
+ Session s = openSession( );
+ Transaction tx = s.beginTransaction();
+
+ Email a = new Email();
+ a.setId( 1 );
+ a.setBody( "corporate message" );
+ s.persist( a );
+
+ a = new Email();
+ a.setId( 2 );
+ a.setBody( "spam message" );
+ s.persist( a );
+
+ tx.commit();
+
+ s.clear();
+
+ tx = s.beginTransaction();
+ FullTextSession fts = Search.getFullTextSession( s );
+ QueryParser parser = new QueryParser("id", new StopAnalyzer() );
+
+ FullTextQuery fullTextQuery = fts.createFullTextQuery( parser.parse( "body:message" ) );
+ List results = fullTextQuery.list();
+ assertEquals( "Query with no filter should bring back results from both shards.", 2, results.size() );
+
+ // index is not a field on the entity; the only way to filter on this is by shard
+ fullTextQuery.enableFullTextFilter("shard").setParameter("index", 0);
+ assertEquals( "Query with filter should bring back results from only one shard.", 1, fullTextQuery.list().size() );
+
+ for (Object o : results) s.delete( o );
+ tx.commit();
+ s.close();
+ }
+
+ protected void setUp() throws Exception {
+ File sub = getBaseIndexDir();
+ sub.mkdir();
+ File[] files = sub.listFiles();
+ for (File file : files) {
+ if ( file.isDirectory() ) {
+ FileHelper.delete( file );
+ }
+ }
+ super.setUp(); //we need a fresh session factory each time for index set up
+ buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFiles() );
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ File sub = getBaseIndexDir();
+ FileHelper.delete( sub );
+ }
+
+ @SuppressWarnings("unchecked")
+ protected Class[] getMappings() {
+ return new Class[] {
+ Email.class
+ };
+ }
+}
Added: search/trunk/src/test/java/org/hibernate/search/test/shards/Email.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/Email.java (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/Email.java 2009-06-13 01:48:33 UTC (rev 16780)
@@ -0,0 +1,43 @@
+package org.hibernate.search.test.shards;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.FullTextFilterDef;
+import org.hibernate.search.annotations.FullTextFilterDefs;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.filter.ShardSensitiveOnlyFilter;
+
+@Entity
+@Indexed(index="Email")
+@FullTextFilterDefs( {
+ @FullTextFilterDef(name="shard", impl= ShardSensitiveOnlyFilter.class)
+})
+public class Email {
+
+ @Id
+ @DocumentId
+ private Integer id;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @Field
+ private String body;
+
+ public String getBody() {
+ return body;
+ }
+
+ public void setBody(String body) {
+ this.body = body;
+ }
+
+}
Added: search/trunk/src/test/java/org/hibernate/search/test/shards/SpecificShardingStrategy.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/SpecificShardingStrategy.java (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/SpecificShardingStrategy.java 2009-06-13 01:48:33 UTC (rev 16780)
@@ -0,0 +1,33 @@
+package org.hibernate.search.test.shards;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+import org.apache.lucene.document.Document;
+import org.hibernate.search.FullTextFilter;
+import org.hibernate.search.filter.FullTextFilterImplementor;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.store.IdHashShardingStrategy;
+
+public class SpecificShardingStrategy extends IdHashShardingStrategy {
+
+ @Override
+ public DirectoryProvider<?>[] getDirectoryProvidersForQuery(FullTextFilterImplementor[] filters) {
+
+ FullTextFilter filter = getFilter(filters, "shard");
+ if (filter == null) {
+ return getDirectoryProvidersForAllShards();
+ }
+ else {
+ return new DirectoryProvider[] { getDirectoryProvidersForAllShards()[Integer.parseInt(filter.getParameter("index").toString())] };
+ }
+ }
+
+ private FullTextFilter getFilter(FullTextFilterImplementor[] filters, String name) {
+ for (FullTextFilterImplementor filter: filters) {
+ if (filter.getName().equals(name)) return filter;
+ }
+ return null;
+ }
+
+}
15 years, 5 months
Hibernate SVN: r16779 - in search/trunk: src/main/java/org/hibernate/search/jpa/impl and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-06-12 21:47:28 -0400 (Fri, 12 Jun 2009)
New Revision: 16779
Modified:
search/trunk/pom.xml
search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java
search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java
Log:
HSEARCH-379 migrate to JPA 2 but no method has been implemented
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2009-06-12 21:22:09 UTC (rev 16778)
+++ search/trunk/pom.xml 2009-06-13 01:47:28 UTC (rev 16779)
@@ -64,10 +64,15 @@
<artifactId>hibernate-commons-annotations</artifactId>
<version>${hibernateVersion}</version>
</dependency>
- <dependency>
+ <!-- dependency>
<groupId>org.hibernate</groupId>
<artifactId>ejb3-persistence</artifactId>
<version>1.0.2.GA</version>
+ </dependency -->
+ <dependency>
+ <groupId>org.hibernate.java-persistence</groupId>
+ <artifactId>jpa-api</artifactId>
+ <version>2.0.Beta2</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
Modified: search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java 2009-06-12 21:22:09 UTC (rev 16778)
+++ search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java 2009-06-13 01:47:28 UTC (rev 16779)
@@ -2,11 +2,17 @@
package org.hibernate.search.jpa.impl;
import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
import javax.persistence.EntityManager;
import javax.persistence.FlushModeType;
import javax.persistence.LockModeType;
import javax.persistence.Query;
import javax.persistence.EntityTransaction;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.metamodel.Metamodel;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.QueryBuilder;
import org.hibernate.search.jpa.FullTextEntityManager;
import org.hibernate.search.jpa.FullTextQuery;
@@ -65,7 +71,7 @@
return ftSession;
}
- public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class... entities) {
+ public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class<?>... entities) {
FullTextSession ftSession = getFullTextSession();
return new FullTextQueryImpl( ftSession.createFullTextQuery( luceneQuery, entities ), ftSession );
}
@@ -106,6 +112,18 @@
return em.find( entityClass, primaryKey );
}
+ public <T> T find(Class<T> tClass, Object o, Map<String, Object> stringObjectMap) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public <T> T find(Class<T> tClass, Object o, LockModeType lockModeType) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public <T> T find(Class<T> tClass, Object o, LockModeType lockModeType, Map<String, Object> stringObjectMap) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public <T> T getReference(Class<T> entityClass, Object primaryKey) {
return em.getReference( entityClass, primaryKey );
}
@@ -126,22 +144,62 @@
em.lock( entity, lockMode );
}
+ public void lock(Object o, LockModeType lockModeType, Map<String, Object> stringObjectMap) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public void refresh(Object entity) {
em.refresh( entity );
}
+ public void refresh(Object o, Map<String, Object> stringObjectMap) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void refresh(Object o, LockModeType lockModeType) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void refresh(Object o, LockModeType lockModeType, Map<String, Object> stringObjectMap) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public void clear() {
em.clear();
}
+ public void detach(Object o) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public boolean contains(Object entity) {
return em.contains( entity );
}
+ public LockModeType getLockMode(Object o) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setProperty(String s, Object o) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Map<String, Object> getProperties() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Set<String> getSupportedProperties() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public Query createQuery(String ejbqlString) {
return em.createQuery( ejbqlString );
}
+ public Query createQuery(CriteriaQuery criteriaQuery) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public Query createNamedQuery(String name) {
return em.createNamedQuery( name );
}
@@ -162,6 +220,10 @@
em.joinTransaction();
}
+ public <T> T unwrap(Class<T> tClass) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public Object getDelegate() {
return em.getDelegate();
}
@@ -177,7 +239,19 @@
public EntityTransaction getTransaction() {
return em.getTransaction();
}
-
+
+ public EntityManagerFactory getEntityManagerFactory() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public QueryBuilder getQueryBuilder() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Metamodel getMetamodel() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public Indexer createIndexer(Class<?>... types) {
return getFullTextSession().createIndexer( types );
}
Modified: search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java 2009-06-12 21:22:09 UTC (rev 16778)
+++ search/trunk/src/main/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java 2009-06-13 01:47:28 UTC (rev 16779)
@@ -7,6 +7,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.Map;
import javax.persistence.EntityExistsException;
import javax.persistence.EntityNotFoundException;
import javax.persistence.FlushModeType;
@@ -16,6 +17,7 @@
import javax.persistence.PersistenceException;
import javax.persistence.Query;
import javax.persistence.TemporalType;
+import javax.persistence.LockModeType;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.Sort;
@@ -216,6 +218,10 @@
return this;
}
+ public int getMaxResults() {
+ return 0; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public Query setFirstResult(int firstResult) {
if ( firstResult < 0 ) {
throw new IllegalArgumentException(
@@ -228,6 +234,10 @@
return this;
}
+ public int getFirstResult() {
+ return 0; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public Explanation explain(int documentId) {
return query.explain( documentId );
}
@@ -240,6 +250,14 @@
return this;
}
+ public Map<String, Object> getHints() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Set<String> getSupportedHints() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public Query setParameter(String name, Object value) {
throw new UnsupportedOperationException( "parameters not supported in fullText queries");
}
@@ -264,6 +282,14 @@
throw new UnsupportedOperationException( "parameters not supported in fullText queries");
}
+ public Map<String, Object> getNamedParameters() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public List getPositionalParameters() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public Query setFlushMode(FlushModeType flushMode) {
if ( flushMode == FlushModeType.AUTO ) {
query.setFlushMode( FlushMode.AUTO );
@@ -273,4 +299,20 @@
}
return this;
}
+
+ public FlushModeType getFlushMode() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Query setLockMode(LockModeType lockModeType) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public LockModeType getLockMode() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public <T> T unwrap(Class<T> tClass) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
}
15 years, 5 months
Hibernate SVN: r16778 - in core/branches/INFINISPAN/cache-infinispan/src: test/java/org/hibernate and 6 other directories.
by hibernate-commits@lists.jboss.org
Author: cbredesen
Date: 2009-06-12 17:22:09 -0400 (Fri, 12 Jun 2009)
New Revision: 16778
Added:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanTest.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicEntityTest.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.hbm.xml
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java
Removed:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/cache/infinispan/
Modified:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseRegion.java
core/branches/INFINISPAN/cache-infinispan/src/test/resources/hibernate.properties
core/branches/INFINISPAN/cache-infinispan/src/test/resources/log4j.properties
Log:
Basic test added, read-only local entity cache works now
Modified: core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseRegion.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseRegion.java 2009-06-12 15:39:36 UTC (rev 16777)
+++ core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseRegion.java 2009-06-12 21:22:09 UTC (rev 16778)
@@ -8,8 +8,10 @@
import org.infinispan.Cache;
/**
- * Support for Infinispan {@link Region}s. Handles the management of a Cache
- * instance as well as basic peripheral operations.
+ * Support for Infinispan {@link Region}s. Handles common "utility" methods for
+ * an underlying named Cache. In other words, this implementation doesn't
+ * actually read or write data. Subclasses are expected to provide core cache
+ * interaction appropriate to the semantics needed.
*
* @author Chris Bredesen
*/
Copied: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanTest.java (from rev 16771, core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/cache/infinispan/InfinispanTest.java)
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanTest.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanTest.java 2009-06-12 21:22:09 UTC (rev 16778)
@@ -0,0 +1,38 @@
+package org.hibernate.test.cache.infinispan;
+
+import org.hibernate.cache.infinispan.InfinispanRegionFactory;
+import org.hibernate.test.cache.BaseRegionFactoryTestCase;
+
+public class InfinispanTest extends BaseRegionFactoryTestCase {
+
+ public InfinispanTest( String x ) {
+ super( x );
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Class getRegionFactory() {
+ return InfinispanRegionFactory.class;
+ }
+
+ @Override
+ protected String getConfigResourceKey() {
+ return null;
+ }
+
+ @Override
+ protected String getConfigResourceLocation() {
+ return null;
+ }
+
+ @Override
+ protected boolean useTransactionManager() {
+ return false;
+ }
+
+ @Override
+ public String getCacheConcurrencyStrategy() {
+ return "read-only";
+ }
+
+}
\ No newline at end of file
Property changes on: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicEntityTest.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicEntityTest.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicEntityTest.java 2009-06-12 21:22:09 UTC (rev 16778)
@@ -0,0 +1,45 @@
+package org.hibernate.test.cache.infinispan.functional;
+
+import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.stat.Statistics;
+
+public class BasicEntityTest extends FunctionalTestCase {
+
+ public BasicEntityTest( String string ) {
+ super( string );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "cache/infinispan/functional/Item.hbm.xml" };
+ }
+
+ @Override
+ public String getCacheConcurrencyStrategy() {
+ return "transactional";
+ }
+
+ public void testEntityCache() {
+ Item item = new Item();
+ item.setName( "chris" );
+ item.setDescription( "Chris's Item" );
+
+ Session s = openSession();
+ Statistics stats = s.getSessionFactory().getStatistics();
+ s.getTransaction().begin();
+ s.persist( item );
+ s.getTransaction().commit();
+ s.close();
+
+ stats.clear();
+ s = openSession();
+ Item found = (Item) s.load( Item.class, item.getId() );
+ System.out.println( stats );
+ assertEquals( item.getDescription(), found.getDescription() );
+ assertEquals( 0, stats.getSecondLevelCacheMissCount() );
+ assertEquals( 1, stats.getSecondLevelCacheHitCount() );
+ s.delete( found );
+ s.close();
+ }
+
+}
\ No newline at end of file
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.hbm.xml
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.hbm.xml (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.hbm.xml 2009-06-12 21:22:09 UTC (rev 16778)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+<hibernate-mapping
+ package="org.hibernate.test.cache.infinispan.functional">
+
+ <class name="Item" table="Items">
+ <id name="id">
+ <generator class="increment"/>
+ </id>
+ <property name="name" not-null="true"/>
+ <property name="description" not-null="true"/>
+ </class>
+
+ <class name="VersionedItem" table="VersionedItems">
+ <id name="id">
+ <generator class="increment"/>
+ </id>
+ <version name="version" type="long"/>
+ <property name="name" not-null="true"/>
+ <property name="description" not-null="true"/>
+ </class>
+
+</hibernate-mapping>
Property changes on: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.hbm.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.java 2009-06-12 21:22:09 UTC (rev 16778)
@@ -0,0 +1,57 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.infinispan.functional;
+
+/**
+ * @author Gavin King
+ */
+public class Item {
+ private Long id;
+ private String name;
+ private String description;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Property changes on: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/Item.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java 2009-06-12 21:22:09 UTC (rev 16778)
@@ -0,0 +1,39 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.infinispan.functional;
+
+/**
+ * @author Steve Ebersole
+ */
+public class VersionedItem extends Item {
+ private Long version;
+
+ public Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(Long version) {
+ this.version = version;
+ }
+}
Property changes on: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/VersionedItem.java
___________________________________________________________________
Name: svn:executable
+ *
Modified: core/branches/INFINISPAN/cache-infinispan/src/test/resources/hibernate.properties
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/resources/hibernate.properties 2009-06-12 15:39:36 UTC (rev 16777)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/resources/hibernate.properties 2009-06-12 21:22:09 UTC (rev 16778)
@@ -32,3 +32,8 @@
hibernate.format_sql true
hibernate.max_fetch_depth 5
+
+hibernate.generate_statistics true
+
+hibernate.cache.use_second_level_cache true
+hibernate.cache.region.factory_class org.hibernate.cache.infinispan.InfinispanRegionFactory
\ No newline at end of file
Modified: core/branches/INFINISPAN/cache-infinispan/src/test/resources/log4j.properties
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/resources/log4j.properties 2009-06-12 15:39:36 UTC (rev 16777)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/resources/log4j.properties 2009-06-12 21:22:09 UTC (rev 16778)
@@ -30,7 +30,8 @@
log4j.rootLogger=info, stdout
log4j.logger.org.hibernate.test=info
-log4j.logger.org.hibernate.cache=debug
+log4j.logger.org.hibernate.cache=trace
+log4j.logger.org.hibernate.SQL=debug
#log4j.logger.org.jgroups=info
#log4j.logger.org.jboss.cache=trace
#log4j.logger.org.jboss.cache.RegionManager=info
15 years, 5 months
Hibernate SVN: r16777 - in beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck: tests/metadata and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-12 11:39:36 -0400 (Fri, 12 Jun 2009)
New Revision: 16777
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Account.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/AccountChecker.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/AccountValidator.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Customer.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ElementDescriptorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/NotEmpty.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Order.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Person.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/PropertyDescriptorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/UnconstraintEntity.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
Log:
bean metadata tests
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Account.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Account.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Account.java 2009-06-12 15:39:36 UTC (rev 16777)
@@ -0,0 +1,46 @@
+// $Id: Account.java 16264 2009-04-06 15:10:53Z 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.jsr303.tck.tests.metadata;
+
+import javax.validation.Valid;
+
+/**
+ * Class with no constraints but with a cascade @Valid annotation
+ */
+@AccountChecker
+public class Account {
+ private String accountLogin;
+ private Customer customer;
+
+ public String getAccountLogin() {
+ return accountLogin;
+ }
+
+ public void setAccountLogin(String accountLogin) {
+ this.accountLogin = accountLogin;
+ }
+
+ @Valid
+ public Customer getCustomer() {
+ return customer;
+ }
+
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+}
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/AccountChecker.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/AccountChecker.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/AccountChecker.java 2009-06-12 15:39:36 UTC (rev 16777)
@@ -0,0 +1,41 @@
+// $Id: AccountChecker.java 16264 2009-04-06 15:10:53Z 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.jsr303.tck.tests.metadata;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Constraint(validatedBy = AccountValidator.class)
+@Documented
+@Target({ METHOD, FIELD, TYPE })
+@Retention(RUNTIME)
+public @interface AccountChecker {
+
+ public abstract String message() default "Account information inconsistent.";
+
+ public abstract Class<?>[] groups() default { };
+}
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/AccountValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/AccountValidator.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/AccountValidator.java 2009-06-12 15:39:36 UTC (rev 16777)
@@ -0,0 +1,34 @@
+// $Id: AccountValidator.java 16264 2009-04-06 15:10:53Z 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.jsr303.tck.tests.metadata;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class AccountValidator implements ConstraintValidator<AccountChecker, Account> {
+
+ public void initialize(AccountChecker parameters) {
+ }
+
+ public boolean isValid(Account account, ConstraintValidatorContext constraintValidatorContext) {
+ return false;
+ }
+}
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java 2009-06-12 15:39:36 UTC (rev 16777)
@@ -0,0 +1,161 @@
+// $Id: BeanDescriptorTest.java 16264 2009-04-06 15:10:53Z 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.jsr303.tck.tests.metadata;
+
+import java.util.Set;
+import javax.validation.BeanDescriptor;
+import javax.validation.PropertyDescriptor;
+import javax.validation.Validator;
+
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+(a)Classes(TestUtil.class)
+public class BeanDescriptorTest extends AbstractTest {
+
+ @Test
+ public void testIsBeanConstrained() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
+
+ // constraint via @Valid
+ assertFalse( beanDescriptor.hasConstraints(), "There should be no direct constraints on the specified bean." );
+ assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted due to @valid " );
+
+ // constraint hosted on bean itself
+ beanDescriptor = validator.getConstraintsForClass( Account.class );
+ assertTrue( beanDescriptor.hasConstraints(), "There should be direct constraints on the specified bean." );
+ assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted due to @valid" );
+
+ // constraint on bean property
+ beanDescriptor = validator.getConstraintsForClass( Order.class );
+ assertFalse( beanDescriptor.hasConstraints(), "There should be no direct constraints on the specified bean." );
+ assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted due to @NotNull" );
+ }
+
+ @Test
+ public void testUnconstraintClass() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( UnconstraintEntity.class );
+ assertFalse( beanDescriptor.hasConstraints(), "There should be no direct constraints on the specified bean." );
+ assertFalse( beanDescriptor.isBeanConstrained(), "Bean should be unconstrainted." );
+ }
+
+ @Test
+ public void testGetConstraintForExistingConstrainedProperty() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+ PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderNumber" );
+ assertEquals(
+ propertyDescriptor.getConstraintDescriptors().size(), 1, "There should be one constraint descriptor"
+ );
+
+ beanDescriptor = validator.getConstraintsForClass( Customer.class );
+ propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList" );
+ assertEquals(
+ propertyDescriptor.getConstraintDescriptors().size(), 0, "There should be no constraint descriptors"
+ );
+ assertTrue( propertyDescriptor.isCascaded(), "The property should be cascaded" );
+ }
+
+ @Test
+ public void testGetConstraintForUnConstrainedProperty() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
+ PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList" );
+ assertEquals(
+ propertyDescriptor.getConstraintDescriptors().size(), 0, "There should be no constraint descriptors"
+ );
+ assertTrue( propertyDescriptor.isCascaded(), "The property should be cascaded" );
+ }
+
+ @Test
+ public void testGetConstraintsForNonExistingProperty() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+ assertNull( beanDescriptor.getConstraintsForProperty( "foobar" ), "There should be no descriptor" );
+ }
+
+ /**
+ * @todo Is this corect or should we get a IllegalArgumentException
+ */
+ @Test
+ public void testGetConstraintsForNullProperty() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+ assertNull( beanDescriptor.getConstraintsForProperty( null ), "There should be no descriptor" );
+ }
+
+ @Test
+ public void testGetConstrainedProperties() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+ Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
+ assertEquals( constraintProperties.size(), 1, "There should be only one property" );
+ boolean hasOrderNumber = false;
+ for ( PropertyDescriptor pd : constraintProperties ) {
+ hasOrderNumber |= pd.getPropertyName().equals( "orderNumber" );
+ }
+ assertTrue( hasOrderNumber, "Wrong property" );
+ }
+
+ @Test
+ public void testGetConstrainedPropertiesImmutable() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+ Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
+ try {
+ constraintProperties.add( null );
+ fail( "Set should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+ // success
+ }
+
+ try {
+ constraintProperties.remove( constraintProperties.iterator().next() );
+ fail( "Set should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+ // success
+ }
+ }
+
+ @Test
+ public void testGetConstrainedPropertiesForUnconstraintEntity() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( UnconstraintEntity.class );
+ Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
+ assertEquals( constraintProperties.size(), 0, "We should get the empty set." );
+ }
+}
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java 2009-06-12 15:39:36 UTC (rev 16777)
@@ -0,0 +1,147 @@
+// $Id: ConstraintDescriptorTest.java 16748 2009-06-10 18:41:22Z epbernard $
+/*
+* 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.jsr303.tck.tests.metadata;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import java.util.Set;
+import javax.validation.ConstraintDescriptor;
+import javax.validation.constraints.NotNull;
+import javax.validation.groups.Default;
+
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.getConstraintDescriptorsFor;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+(a)Classes(TestUtil.class)
+public class ConstraintDescriptorTest extends AbstractTest {
+
+ @Test
+ public void testConstraintDescriptorImmutable() {
+ ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Order.class, "orderNumber" );
+
+ try {
+ descriptor.getGroups().add( Default.class );
+ fail( "Should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+ // success
+ }
+
+ try {
+ descriptor.getAttributes().put( "foo", "bar" );
+ fail( "Should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+ // success
+ }
+
+ try {
+ descriptor.getConstraintValidatorClasses().add( null );
+ fail( "Should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+ // success
+ }
+
+ try {
+ descriptor.getComposingConstraints().add( null );
+ fail( "Should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+ // success
+ }
+ }
+
+ @Test
+ public void testReportAsSingleViolation() {
+ ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Order.class, "orderNumber" );
+ assertFalse( descriptor.isReportAsSingleViolation() );
+
+ descriptor = getConstraintDescriptor( Person.class, "firstName" );
+ assertTrue( descriptor.isReportAsSingleViolation() );
+ }
+
+ @Test
+ public void testComposingConstraints() {
+ ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Order.class, "orderNumber" );
+ assertTrue( descriptor.getComposingConstraints().isEmpty() );
+ }
+
+ /**
+ * @todo Is getComposingConstraints() recursive and hence the result should be 4?
+ */
+ @Test
+ public void testEmptyComposingConstraints() {
+ ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Person.class, "firstName" );
+ assertEquals( descriptor.getComposingConstraints().size(), 2, "Wrong number of composing constraints" );
+ }
+
+ @Test
+ public void testGetAnnotation() {
+ ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Order.class, "orderNumber" );
+ Annotation annotation = descriptor.getAnnotation();
+ assertNotNull( annotation );
+ assertTrue( annotation instanceof NotNull );
+ }
+
+ @Test
+ public void testDefaultGroupIsReturned() {
+ ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Order.class, "orderNumber" );
+ Set<Class<?>> groups = descriptor.getGroups();
+ assertTrue( groups.size() == 1 );
+ assertEquals( groups.iterator().next(), Default.class, "Wrong group" );
+ }
+
+// @Test
+// public void testGetConstraintValidatorClasses() {
+// Set<ConstraintDescriptor<?>> descriptors = getConstraintDescriptorsFor( Order.class, "orderNumber" );
+// assertTrue( descriptors.size() == 1, "There should only by one descriptor." );
+// ConstraintDescriptor<?> descriptor = descriptors.iterator().next();
+// assertEquals( descriptor.getConstraintValidatorClasses().get( 0 ), NotNullValidator.class, "Wrong classes" );
+// }
+
+ @Test
+ public void testGetAttributes() {
+ ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Order.class, "orderNumber" );
+ Map<String, Object> attributes = descriptor.getAttributes();
+ assertTrue( attributes.containsKey( "message" ) );
+ assertTrue( attributes.containsKey( "groups" ) );
+ }
+
+ private ConstraintDescriptor<?> getConstraintDescriptor(Class<?> clazz, String property) {
+ Set<ConstraintDescriptor<?>> descriptors = getConstraintDescriptorsFor( clazz, property );
+ assertTrue( descriptors.size() == 1, "There should only by one descriptor." );
+ return descriptors.iterator().next();
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Customer.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Customer.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Customer.java 2009-06-12 15:39:36 UTC (rev 16777)
@@ -0,0 +1,67 @@
+// $Id: Customer.java 16264 2009-04-06 15:10:53Z 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.jsr303.tck.tests.metadata;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.validation.Valid;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Customer implements Person {
+
+ private String firstName;
+ private String middleName;
+ private String lastName;
+
+ @Valid
+ private List<Order> orderList = new ArrayList<Order>();
+
+ public void addOrder(Order order) {
+ orderList.add( order );
+ }
+
+ public List<Order> getOrderList() {
+ return orderList;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getMiddleName() {
+ return middleName;
+ }
+
+ public void setMiddleName(String middleName) {
+ this.middleName = middleName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+}
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ElementDescriptorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ElementDescriptorTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ElementDescriptorTest.java 2009-06-12 15:39:36 UTC (rev 16777)
@@ -0,0 +1,92 @@
+// $Id: ElementDescriptorTest.java 16264 2009-04-06 15:10:53Z 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.jsr303.tck.tests.metadata;
+
+import java.util.Set;
+import javax.validation.BeanDescriptor;
+import javax.validation.ConstraintDescriptor;
+import javax.validation.ElementDescriptor;
+import javax.validation.Validator;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+(a)Classes(TestUtil.class)
+public class ElementDescriptorTest extends AbstractTest {
+
+
+ @Test
+ public void testGetTypeForConstrainedBean() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
+ assertEquals( beanDescriptor.getType(), Customer.class, "Wrong type." );
+ }
+
+ @Test
+ public void testGetTypeForConstrainedProperty() {
+ ElementDescriptor elementDescriptor = TestUtil.getPropertyDescriptor( Order.class, "orderNumber" );
+ assertEquals( elementDescriptor.getType(), Integer.class, "Wrong type." );
+ }
+
+ /**
+ * HV-95
+ */
+ @Test
+ public void testElementDescriptorForProperty() {
+ ElementDescriptor elementDescriptor = TestUtil.getPropertyDescriptor( Order.class, "orderNumber" );
+ Set<ConstraintDescriptor<?>> constraintDescriptors = elementDescriptor.getConstraintDescriptors();
+ assertTrue( constraintDescriptors.size() == 1, "There should be a descriptor" );
+ }
+
+ /**
+ * HV-95
+ */
+ @Test
+ public void testElementDescriptorImmutable() {
+ ElementDescriptor elementDescriptor = TestUtil.getPropertyDescriptor( Order.class, "orderNumber" );
+ Set<ConstraintDescriptor<?>> constraintDescriptors = elementDescriptor.getConstraintDescriptors();
+
+ try {
+ constraintDescriptors.add( null );
+ fail( "Set should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+ // success
+ }
+
+ try {
+ constraintDescriptors.remove( null );
+ fail( "Set should be immutable" );
+ }
+ catch ( UnsupportedOperationException e ) {
+ // success
+ }
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/NotEmpty.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/NotEmpty.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/NotEmpty.java 2009-06-12 15:39:36 UTC (rev 16777)
@@ -0,0 +1,45 @@
+// $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.jsr303.tck.tests.metadata;
+
+import java.lang.annotation.Documented;
+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.ReportAsSingleViolation;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Documented
+@Constraint(validatedBy = {})
+@Target({ METHOD, FIELD })
+@Retention(RUNTIME)
+@ReportAsSingleViolation
+@NotNull
+@Size(min=1)
+public @interface NotEmpty {
+ public abstract String message() default "{org.hibernate.validation.constraints.NotEmpty.message}";
+
+ public abstract Class<?>[] groups() default { };
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/NotEmpty.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Order.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Order.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Order.java 2009-06-12 15:39:36 UTC (rev 16777)
@@ -0,0 +1,36 @@
+// $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.jsr303.tck.tests.metadata;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Order {
+ @NotNull
+ Integer orderNumber;
+
+ public Integer getOrderNumber() {
+ return orderNumber;
+ }
+
+ public void setOrderNumber(Integer orderNumber) {
+ this.orderNumber = orderNumber;
+ }
+}
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Order.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Person.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Person.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Person.java 2009-06-12 15:39:36 UTC (rev 16777)
@@ -0,0 +1,31 @@
+// $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.jsr303.tck.tests.metadata;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface Person {
+ @NotEmpty
+ String getFirstName();
+
+ String getMiddleName();
+
+ @NotEmpty
+ String getLastName();
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Person.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/PropertyDescriptorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/PropertyDescriptorTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/PropertyDescriptorTest.java 2009-06-12 15:39:36 UTC (rev 16777)
@@ -0,0 +1,59 @@
+// $Id: PropertyDescriptorTest.java 16264 2009-04-06 15:10:53Z 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.jsr303.tck.tests.metadata;
+
+import javax.validation.PropertyDescriptor;
+
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.getPropertyDescriptor;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+(a)Classes(TestUtil.class)
+public class PropertyDescriptorTest extends AbstractTest {
+ @Test
+ public void testIsNotCascaded() {
+ PropertyDescriptor descriptor = getPropertyDescriptor( Order.class, "orderNumber" );
+ assertFalse( descriptor.isCascaded(), "Should not be cascaded" );
+ }
+
+ @Test
+ public void testIsCascaded() {
+ PropertyDescriptor descriptor = getPropertyDescriptor( Customer.class, "orderList" );
+ assertTrue( descriptor.isCascaded(), "Should be cascaded" );
+ }
+
+ @Test
+ public void testPropertyName() {
+ String propertyName = "orderList";
+ PropertyDescriptor descriptor = getPropertyDescriptor( Customer.class, propertyName );
+ assertEquals( descriptor.getPropertyName(), propertyName, "Wrong property name" );
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/UnconstraintEntity.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/UnconstraintEntity.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/UnconstraintEntity.java 2009-06-12 15:39:36 UTC (rev 16777)
@@ -0,0 +1,26 @@
+// : Person.java 69 2008-09-08 11:05:07Z 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.jsr303.tck.tests.metadata;
+
+/**
+ * Empty un-constraint test class.
+ *
+ * @author Hardy Ferentschik
+ */
+public class UnconstraintEntity {
+}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-06-12 15:19:34 UTC (rev 16776)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-06-12 15:39:36 UTC (rev 16777)
@@ -21,7 +21,10 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import javax.validation.ConstraintDescriptor;
import javax.validation.ConstraintViolation;
+import javax.validation.ElementDescriptor;
+import javax.validation.PropertyDescriptor;
import javax.validation.Validation;
import javax.validation.Validator;
@@ -107,4 +110,15 @@
"Wrong invalid value."
);
}
+
+
+ public static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String property) {
+ Validator validator = getDefaultValidator();
+ return validator.getConstraintsForClass( clazz ).getConstraintsForProperty( property );
+ }
+
+ public static Set<ConstraintDescriptor<?>> getConstraintDescriptorsFor(Class<?> clazz, String property) {
+ ElementDescriptor elementDescriptor = getPropertyDescriptor( clazz, property );
+ return elementDescriptor.getConstraintDescriptors();
+ }
}
15 years, 5 months