Hibernate SVN: r16179 - in validator/trunk/hibernate-validator: src/main/java/org/hibernate/validation/engine and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-03-18 07:08:10 -0400 (Wed, 18 Mar 2009)
New Revision: 16179
Modified:
validator/trunk/hibernate-validator/pom.xml
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/IdentitySet.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java
validator/trunk/hibernate-validator/src/test/resources/log4j.properties
Log:
HV-126 added support for one validation per group AND path
Modified: validator/trunk/hibernate-validator/pom.xml
===================================================================
--- validator/trunk/hibernate-validator/pom.xml 2009-03-18 10:28:42 UTC (rev 16178)
+++ validator/trunk/hibernate-validator/pom.xml 2009-03-18 11:08:10 UTC (rev 16179)
@@ -22,7 +22,7 @@
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
- <version>1.0.CR1-SNAPSHOT</version>
+ <version>1.0.CR1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java 2009-03-18 10:28:42 UTC (rev 16178)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java 2009-03-18 11:08:10 UTC (rev 16179)
@@ -19,8 +19,11 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.Stack;
import javax.validation.ConstraintDescriptor;
import javax.validation.ConstraintValidatorContext;
@@ -51,12 +54,17 @@
private final T rootBean;
/**
- * Maps for each group to an identity set to keep track of already validated objects. We have to make sure
- * that each object gets only validated once (per group).
+ * Maps a group to an identity set to keep track of already validated objects. We have to make sure
+ * that each object gets only validated once per group and property path.
*/
private final Map<Class<?>, IdentitySet> processedObjects;
/**
+ * Maps an object to a list of paths in which it has been invalidated.
+ */
+ private final Map<Object, Set<String>> processedPaths;
+
+ /**
* A list of all failing constraints so far.
*/
private final List<ConstraintViolationImpl<T>> failingConstraintViolations;
@@ -83,6 +91,13 @@
private Stack<Object> beanStack = new Stack<Object>();
/**
+ * Flag indicating whether an object can only be validated once per group or once per group AND validation path.
+ *
+ * @todo Make this boolean a configurable item.
+ */
+ private boolean allowOneValidationPerPath = true;
+
+ /**
* The message resolver which should be used in this context.
*/
private final MessageInterpolator messageInterpolator;
@@ -109,6 +124,7 @@
beanStack.push( object );
processedObjects = new HashMap<Class<?>, IdentitySet>();
+ processedPaths = new IdentityHashMap<Object, Set<String>>();
propertyPath = new ArrayList<String>();
failingConstraintViolations = new ArrayList<ConstraintViolationImpl<T>>();
}
@@ -168,31 +184,42 @@
public void setCurrentGroup(Class<?> currentGroup) {
this.currentGroup = currentGroup;
+ markProcessed();
}
- public void markProcessedForCurrentGroup() {
- if ( processedObjects.containsKey( currentGroup ) ) {
- processedObjects.get( currentGroup ).add( beanStack.peek() );
+ /**
+ * Returns <code>true</code> if the specified value has already been validated, <code>false</code> otherwise.
+ * Each object can only be validated once per group and validation path. The flag {@link #allowOneValidationPerPath}
+ * determines whether an object can only be validated once per group or once per group and validation path.�
+ *
+ * @param value The value to be validated.
+ *
+ * @return Returns <code>true</code> if the specified value has already been validated, <code>false</code> otherwise.
+ */
+ public boolean isAlreadyValidated(Object value) {
+ boolean alreadyValidated;
+ alreadyValidated = isAlreadyValidatedForCurrentGroup( value );
+
+ if ( alreadyValidated && allowOneValidationPerPath ) {
+ alreadyValidated = isAlreadyValidatedForPath( value );
}
- else {
- IdentitySet set = new IdentitySet();
- set.add( beanStack.peek() );
- processedObjects.put( currentGroup, set );
+ return alreadyValidated;
+ }
+
+ private boolean isAlreadyValidatedForPath(Object value) {
+ for ( String path : processedPaths.get( value ) ) {
+ if ( path.contains( peekPropertyPath() ) || peekPropertyPath().contains( path ) ) {
+ return true;
+ }
}
+ return false;
}
- public boolean isValidatedAgainstCurrentGroup(Object value) {
+ private boolean isAlreadyValidatedForCurrentGroup(Object value) {
final IdentitySet objectsProcessedInCurrentGroups = processedObjects.get( currentGroup );
return objectsProcessedInCurrentGroups != null && objectsProcessedInCurrentGroups.contains( value );
}
- private void addConstraintFailure(ConstraintViolationImpl<T> failingConstraintViolation) {
- int i = failingConstraintViolations.indexOf( failingConstraintViolation );
- if ( i == -1 ) {
- failingConstraintViolations.add( failingConstraintViolation );
- }
- }
-
public void addConstraintFailures(List<ConstraintViolationImpl<T>> failingConstraintViolations) {
for ( ConstraintViolationImpl<T> violation : failingConstraintViolations ) {
addConstraintFailure( violation );
@@ -226,15 +253,16 @@
public void markCurrentPropertyAsIndexed() {
String property = peekProperty();
property += "[]";
- popProperty();
+ propertyPath.remove( propertyPath.size() - 1 );
pushProperty( property );
}
- public void replacePropertyIndex(String index) {
+ public void setPropertyIndex(String index) {
+ String property = peekProperty();
+
// replace the last occurance of [<oldIndex>] with [<index>]
- String property = peekProperty();
property = property.replaceAll( "\\[[0-9]*\\]$", "[" + index + "]" );
- popProperty();
+ propertyPath.remove( propertyPath.size() - 1 );
pushProperty( property );
}
@@ -297,12 +325,48 @@
);
}
+ private void markProcessed() {
+ markProcessForCurrentGroup();
+ if ( allowOneValidationPerPath ) {
+ markProcessedForCurrentPath();
+ }
+ }
+
+ private void markProcessedForCurrentPath() {
+ if ( processedPaths.containsKey( peekCurrentBean() ) ) {
+ processedPaths.get( peekCurrentBean() ).add( peekPropertyPath() );
+ }
+ else {
+ Set<String> set = new HashSet<String>();
+ set.add( peekPropertyPath() );
+ processedPaths.put( peekCurrentBean(), set );
+ }
+ }
+
+ private void markProcessForCurrentGroup() {
+ if ( processedObjects.containsKey( currentGroup ) ) {
+ processedObjects.get( currentGroup ).add( peekCurrentBean() );
+ }
+ else {
+ IdentitySet set = new IdentitySet();
+ set.add( peekCurrentBean() );
+ processedObjects.put( currentGroup, set );
+ }
+ }
+
+ private void addConstraintFailure(ConstraintViolationImpl<T> failingConstraintViolation) {
+ int i = failingConstraintViolations.indexOf( failingConstraintViolation );
+ if ( i == -1 ) {
+ failingConstraintViolations.add( failingConstraintViolation );
+ }
+ }
+
class ValidatedProperty {
private final List<ErrorMessage> errorMessages = new ArrayList<ErrorMessage>( 3 );
private final String property;
private final String propertyParent;
- private ConstraintDescriptor constraintDescriptor;
+ private ConstraintDescriptor<?> constraintDescriptor;
private boolean defaultDisabled;
@@ -311,11 +375,11 @@
this.propertyParent = propertyParent;
}
- public void setConstraintDescriptor(ConstraintDescriptor constraintDescriptor) {
+ public void setConstraintDescriptor(ConstraintDescriptor<?> constraintDescriptor) {
this.constraintDescriptor = constraintDescriptor;
}
- public ConstraintDescriptor getConstraintDescriptor() {
+ public ConstraintDescriptor<?> getConstraintDescriptor() {
return constraintDescriptor;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java 2009-03-18 10:28:42 UTC (rev 16178)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java 2009-03-18 11:08:10 UTC (rev 16179)
@@ -21,7 +21,6 @@
import java.lang.annotation.ElementType;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
-import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
@@ -46,11 +45,6 @@
private final ConstraintTree<A> constraintTree;
/**
- * The type the constraint was defined on.
- */
- private final Type type;
-
- /**
* The member the constraint was defined on.
*/
private final Member member;
@@ -71,12 +65,11 @@
*/
private final Class<T> beanClass;
- public MetaConstraint(Type type, ConstraintDescriptor<A> constraintDescriptor) {
- this.type = type;
+ public MetaConstraint(Class<T> beanClass, ConstraintDescriptor<A> constraintDescriptor) {
this.elementType = ElementType.TYPE;
this.member = null;
this.propertyName = "";
- this.beanClass = ( Class<T> ) type.getClass();
+ this.beanClass = beanClass;
constraintTree = new ConstraintTree<A>( constraintDescriptor );
}
@@ -90,7 +83,6 @@
else {
throw new IllegalArgumentException( "Non allowed member type: " + member );
}
- this.type = null;
this.member = member;
this.propertyName = ReflectionHelper.getPropertyName( member );
this.beanClass = beanClass;
@@ -170,7 +162,7 @@
Type t;
switch ( elementType ) {
case TYPE: {
- t = type;
+ t = beanClass;
break;
}
default: {
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-03-18 10:28:42 UTC (rev 16178)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-03-18 11:08:10 UTC (rev 16179)
@@ -201,7 +201,7 @@
validateCascadedConstraints( context );
}
- // process sequences depth-first to guarantee that groups following a violation within a group won't get executed.
+ // process group sequences depth-first to guarantee that groups following a violation within a group won't get executed.
Iterator<List<Group>> sequenceIterator = groupChain.getSequenceIterator();
while ( sequenceIterator.hasNext() ) {
List<Group> sequence = sequenceIterator.next();
@@ -270,7 +270,6 @@
}
executionContext.popProperty();
}
- executionContext.markProcessedForCurrentGroup();
return validationSuccessful;
}
@@ -339,14 +338,11 @@
actualValue = ( ( Map.Entry ) actualValue ).getValue();
}
- if ( !context.isValidatedAgainstCurrentGroup( actualValue ) ) {
- context.replacePropertyIndex( propertyIndex );
-
+ if ( !context.isAlreadyValidated( actualValue ) ) {
+ context.setPropertyIndex( propertyIndex );
context.pushCurrentBean( actualValue );
- validateInContext(
- context,
- groupChainGenerator.getGroupChainFor( Arrays.asList( new Class<?>[] { context.getCurrentGroup() } ) )
- );
+ GroupChain groupChain = groupChainGenerator.getGroupChainFor( Arrays.asList( new Class<?>[] { context.getCurrentGroup() } ) );
+ validateInContext( context, groupChain );
context.popCurrentBean();
}
i++;
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/IdentitySet.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/IdentitySet.java 2009-03-18 10:28:42 UTC (rev 16178)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/IdentitySet.java 2009-03-18 11:08:10 UTC (rev 16179)
@@ -24,7 +24,7 @@
import java.util.Set;
/**
- * Set that compares object by identity rather than equality.
+ * Set that compares object by identity rather than equality. Wraps around a <code>IdentityHashMap</code>
*
* @author Emmanuel Bernard
*/
@@ -104,4 +104,11 @@
public Object[] toArray(Object[] a) {
return map.keySet().toArray( a );
}
+
+ @Override
+ public String toString() {
+ return "IdentitySet{" +
+ "map=" + map +
+ '}';
+ }
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java 2009-03-18 10:28:42 UTC (rev 16178)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java 2009-03-18 11:08:10 UTC (rev 16179)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -58,6 +58,6 @@
Validator validator = TestUtil.getValidator();
Set<ConstraintViolation<Order>> constraintViolations = validator.validate( order );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
+ assertEquals( "Wrong number of constraints", 3, constraintViolations.size() );
}
}
Modified: validator/trunk/hibernate-validator/src/test/resources/log4j.properties
===================================================================
--- validator/trunk/hibernate-validator/src/test/resources/log4j.properties 2009-03-18 10:28:42 UTC (rev 16178)
+++ validator/trunk/hibernate-validator/src/test/resources/log4j.properties 2009-03-18 11:08:10 UTC (rev 16179)
@@ -21,6 +21,5 @@
log4j.rootLogger=debug, stdout
log4j.logger.org.hibernate.validation.engine.ValidatorImpl=trace
-log4j.logger.org.hibernate.validation.engine.ConstraintTree=trace
-org.hibernate.validation.engine.ResourceBundleMessageInterpolator=info
-
+#log4j.logger.org.hibernate.validation.engine.ConstraintTree=trace
+log4j.logger.org.hibernate.validation.engine.ResourceBundleMessageInterpolator=info
15 years, 9 months
Hibernate SVN: r16178 - validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report.
by hibernate-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-03-18 06:28:42 -0400 (Wed, 18 Mar 2009)
New Revision: 16178
Modified:
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
Log:
support for literals
Modified: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-03-17 23:49:59 UTC (rev 16177)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-03-18 10:28:42 UTC (rev 16178)
@@ -34,7 +34,8 @@
public static final String SVN_BASE_URL_PROPERTY = "svn_base_url";
private static final Pattern PATTERN_BOLD = Pattern.compile("([_][^_]*[_])");
- private static final Pattern PATTERN_STRIKETHROUGH = Pattern.compile("([~][^~]*[~])");
+ private static final Pattern PATTERN_STRIKETHROUGH = Pattern.compile("([~][^~]*[~])");
+ private static final Pattern PATTERN_LITERAL = Pattern.compile("([|][^|]*[|])");
private static final String REPORT_FILE_NAME = "coverage.html";
private static final String COLOUR_SHADE_GREEN = "#ddffdd";
@@ -212,6 +213,8 @@
sb.append(" font-style: italic; }\n");
sb.append(" .highlight {\n");
sb.append(" background-color: #ffff00; }\n");
+ sb.append(" .literal {\n");
+ sb.append(" font-family: courier new; }\n");
sb.append(" .implied {\n");
sb.append(" color: #fff;\n");
sb.append(" font-weight: bold;\n");
@@ -643,7 +646,7 @@
copyFile(imageFile, new File(imageTargetDir, imageFilename));
}
- String assertionText = parseStrikethrough(parseBold(assertion.getText()));
+ String assertionText = parseStrikethrough(parseBold(parseLiteral(assertion.getText())));
if (!Strings.isEmpty(assertion.getNote()))
{
@@ -767,6 +770,20 @@
}
return result;
}
+
+ private String parseLiteral(String text)
+ {
+ Matcher m = PATTERN_LITERAL.matcher(text);
+
+ String result = text;
+ while (m.find())
+ {
+ String replacement = "<span class=\"literal\">" + m.group().substring(1, m.group().length() - 1) + "</span>";
+ result = m.replaceFirst(replacement);
+ m.reset(result);
+ }
+ return result;
+ }
private void writeUnmatched(OutputStream out) throws IOException {
if (unmatched.isEmpty()) return;
15 years, 9 months
Hibernate SVN: r16177 - beanvalidation/trunk/validation-api.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-03-17 19:49:59 -0400 (Tue, 17 Mar 2009)
New Revision: 16177
Modified:
beanvalidation/trunk/validation-api/pom.xml
Log:
snapshot
Modified: beanvalidation/trunk/validation-api/pom.xml
===================================================================
--- beanvalidation/trunk/validation-api/pom.xml 2009-03-17 23:49:27 UTC (rev 16176)
+++ beanvalidation/trunk/validation-api/pom.xml 2009-03-17 23:49:59 UTC (rev 16177)
@@ -6,7 +6,7 @@
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
- <version>1.0.CR1</version>
+ <version>1.0.CR2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Bean Validation API</name>
15 years, 9 months
Hibernate SVN: r16176 - beanvalidation/tags.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-03-17 19:49:27 -0400 (Tue, 17 Mar 2009)
New Revision: 16176
Added:
beanvalidation/tags/v1_0_CR1/
Log:
CR1 Proposed final draft - redoing
Copied: beanvalidation/tags/v1_0_CR1 (from rev 16175, beanvalidation/trunk)
15 years, 9 months
Hibernate SVN: r16175 - beanvalidation/tags.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-03-17 19:49:12 -0400 (Tue, 17 Mar 2009)
New Revision: 16175
Removed:
beanvalidation/tags/v1_0_CR1/
Log:
remove wrong tag
15 years, 9 months
Hibernate SVN: r16174 - beanvalidation/trunk/validation-api.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-03-17 19:48:04 -0400 (Tue, 17 Mar 2009)
New Revision: 16174
Modified:
beanvalidation/trunk/validation-api/pom.xml
Log:
release with version number
Modified: beanvalidation/trunk/validation-api/pom.xml
===================================================================
--- beanvalidation/trunk/validation-api/pom.xml 2009-03-17 19:16:57 UTC (rev 16173)
+++ beanvalidation/trunk/validation-api/pom.xml 2009-03-17 23:48:04 UTC (rev 16174)
@@ -6,7 +6,7 @@
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
- <version>1.0.CR1-SNAPSHOT</version>
+ <version>1.0.CR1</version>
<packaging>jar</packaging>
<name>Bean Validation API</name>
15 years, 9 months
Hibernate SVN: r16173 - core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2009-03-17 15:16:57 -0400 (Tue, 17 Mar 2009)
New Revision: 16173
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticEntityReplicationTest.java
Log:
Clean up compiler warns
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticEntityReplicationTest.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticEntityReplicationTest.java 2009-03-17 19:16:06 UTC (rev 16172)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticEntityReplicationTest.java 2009-03-17 19:16:57 UTC (rev 16173)
@@ -24,21 +24,17 @@
package org.hibernate.test.cache.jbc2.functional;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import javax.transaction.TransactionManager;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
-import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.jbc2.builder.MultiplexingCacheInstanceManager;
import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
import org.hibernate.test.cache.jbc2.functional.util.DualNodeTestUtil;
import org.hibernate.test.cache.jbc2.functional.util.TestCacheInstanceManager;
import org.hibernate.test.cache.jbc2.functional.util.TestJBossCacheRegionFactory;
-import org.hibernate.transaction.CMTTransactionFactory;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheManager;
import org.jboss.cache.Fqn;
@@ -70,7 +66,7 @@
}
@Override
- protected Class getCacheRegionFactory()
+ protected Class<?> getCacheRegionFactory()
{
return TestJBossCacheRegionFactory.class;
}
@@ -100,7 +96,7 @@
// Bind a listener to the "local" cache
// Our region factory makes its CacheManager available to us
CacheManager localManager = TestCacheInstanceManager.getTestCacheManager(DualNodeTestUtil.LOCAL);
- Cache localCache = localManager.getCache(getEntityCacheConfigName(), true);
+ Cache<Object, Object> localCache = localManager.getCache(getEntityCacheConfigName(), true);
MyListener localListener = new MyListener();
localCache.addCacheListener(localListener);
@@ -108,7 +104,7 @@
// Bind a listener to the "remote" cache
CacheManager remoteManager = TestCacheInstanceManager.getTestCacheManager(DualNodeTestUtil.REMOTE);
- Cache remoteCache = remoteManager.getCache(getEntityCacheConfigName(), true);
+ Cache<Object, Object> remoteCache = remoteManager.getCache(getEntityCacheConfigName(), true);
MyListener remoteListener = new MyListener();
remoteCache.addCacheListener(remoteListener);
@@ -191,7 +187,7 @@
IdContainer ids = new IdContainer();
ids.customerId = customer.getId();
- Set contactIds = new HashSet();
+ Set<Integer> contactIds = new HashSet<Integer>();
contactIds.add(kabir.getId());
contactIds.add(bill.getId());
ids.contactIds = contactIds;
@@ -226,8 +222,8 @@
Session session = sessionFactory.getCurrentSession();
Customer customer = (Customer) session.get(Customer.class, id);
// Access all the contacts
- for (Iterator it = customer.getContacts().iterator(); it.hasNext();) {
- ((Contact) it.next()).getName();
+ for (Contact contact : customer.getContacts()) {
+ contact.getName();
}
tm.commit();
return customer;
@@ -257,9 +253,8 @@
Customer c = (Customer) session.get(Customer.class, CUSTOMER_ID);
if (c != null)
{
- Set contacts = c.getContacts();
- for (Iterator it = contacts.iterator(); it.hasNext();)
- session.delete(it.next());
+ for (Contact contact : c.getContacts())
+ session.delete(contact);
c.setContacts(null);
session.delete(c);
}
@@ -278,11 +273,10 @@
}
}
- private void assertLoadedFromCache(MyListener listener, Integer custId, Set contactIds)
+ private void assertLoadedFromCache(MyListener listener, Integer custId, Set<Integer> contactIds)
{
assertTrue("Customer#" + custId + " was in cache", listener.visited.contains("Customer#" + custId));
- for (Iterator it = contactIds.iterator(); it.hasNext();) {
- Integer contactId = (Integer) it.next();
+ for (Integer contactId : contactIds) {
assertTrue("Contact#"+ contactId + " was in cache", listener.visited.contains("Contact#"+ contactId));
assertTrue("Contact#"+ contactId + " was in cache", listener.visited.contains("Contact#"+ contactId));
}
@@ -307,6 +301,7 @@
if (!event.isPre())
{
+ @SuppressWarnings("unchecked")
Fqn fqn = event.getFqn();
System.out.println("MyListener - Visiting node " + fqn.toString());
String name = fqn.toString();
@@ -325,6 +320,6 @@
private class IdContainer {
Integer customerId;
- Set contactIds;
+ Set<Integer> contactIds;
}
}
15 years, 9 months
Hibernate SVN: r16172 - core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2009-03-17 15:16:06 -0400 (Tue, 17 Mar 2009)
New Revision: 16172
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/MVCCJBossCacheTest.java
Log:
Minor javadoc
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/MVCCJBossCacheTest.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/MVCCJBossCacheTest.java 2009-03-17 19:12:11 UTC (rev 16171)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/MVCCJBossCacheTest.java 2009-03-17 19:16:06 UTC (rev 16172)
@@ -32,7 +32,7 @@
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
- * Basic functional test of a pessimistic locking entity + query cache.
+ * Basic functional test of a MVCC locking entity + query cache.
*
* @author Brian Stansberry
*/
15 years, 9 months
Hibernate SVN: r16171 - core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2009-03-17 15:12:11 -0400 (Tue, 17 Mar 2009)
New Revision: 16171
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticSessionRefreshTest.java
Log:
Clean up compiler warns
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticSessionRefreshTest.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticSessionRefreshTest.java 2009-03-17 19:07:17 UTC (rev 16170)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticSessionRefreshTest.java 2009-03-17 19:12:11 UTC (rev 16171)
@@ -60,7 +60,7 @@
static int test = 0;
- private Cache localCache;
+ private Cache<Object, Object> localCache;
/**
* Create a new PessimisticSessionRefreshTest.
@@ -100,7 +100,7 @@
}
@Override
- protected Class getCacheRegionFactory()
+ protected Class<?> getCacheRegionFactory()
{
return TestJBossCacheRegionFactory.class;
}
15 years, 9 months
Hibernate SVN: r16170 - core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2009-03-17 15:07:17 -0400 (Tue, 17 Mar 2009)
New Revision: 16170
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/DualNodeTestCaseBase.java
Log:
Clean up compiler warns
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/DualNodeTestCaseBase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/DualNodeTestCaseBase.java 2009-03-17 19:04:10 UTC (rev 16169)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/DualNodeTestCaseBase.java 2009-03-17 19:07:17 UTC (rev 16170)
@@ -87,17 +87,17 @@
}
@Override
- protected Class getConnectionProviderClass() {
+ protected Class<?> getConnectionProviderClass() {
return DualNodeConnectionProviderImpl.class;
}
@Override
- protected Class getTransactionManagerLookupClass() {
+ protected Class<?> getTransactionManagerLookupClass() {
return DualNodeTransactionManagerLookup.class;
}
@Override
- protected Class getTransactionFactoryClass() {
+ protected Class<?> getTransactionFactoryClass() {
return CMTTransactionFactory.class;
}
15 years, 9 months