Author: hardy.ferentschik
Date: 2009-06-25 06:10:13 -0400 (Thu, 25 Jun 2009)
New Revision: 16948
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/CustomProviderResolverTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ExplicitCustomProviderBootstrapTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinConstraintsTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinValidatorOverrideTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/ConstraintDefinitionsTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Fubar.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.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/PropertyDescriptorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/Actor.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ActorArrayBased.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/PlayedWith.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateValueTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/customconstraint/CustomConstraintValidatorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/TraversableResolverTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MyConstraint.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MySecondConstraint.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MySecondConstraintValidator.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/EmptyXmlConfigurationTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/InvalidXmlConfigurationTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
Log:
Updated the tests to be independend of a string comparison when comparing path
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/CustomProviderResolverTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/CustomProviderResolverTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/CustomProviderResolverTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -43,7 +43,7 @@
* the Bean Validation API itself!?
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class CustomProviderResolverTest extends AbstractTest {
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ExplicitCustomProviderBootstrapTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ExplicitCustomProviderBootstrapTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ExplicitCustomProviderBootstrapTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -38,7 +38,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
@Resource( source = "javax.validation.spi.ValidationProvider", destination =
"WEB-INF/classes/META-INF/services/javax.validation.spi.ValidationProvider")
@IntegrationTest
public class ExplicitCustomProviderBootstrapTest extends AbstractTest {
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -58,7 +58,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class BootstrapTest extends AbstractTest {
private static final String SERVICES_FILE = "META-INF/services/" +
ValidationProvider.class.getName();
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -41,7 +41,7 @@
@Artifact(artifactType = ArtifactType.JSR303)
@Resource(source = "empty-constraints.xml",
destination =
"WEB-INF/classes/org/hibernate/jsr303/tck/tests/configuration/empty-constraints.xml")
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class MappingStreamHandlingTest extends AbstractTest {
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinConstraintsTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinConstraintsTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinConstraintsTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -62,7 +62,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class BuiltinConstraintsTest extends AbstractTest {
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinValidatorOverrideTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinValidatorOverrideTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinValidatorOverrideTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -43,7 +43,7 @@
@Artifact(artifactType = ArtifactType.JSR303)
@Resource(source = "builtin-constraints-override.xml",
destination =
"WEB-INF/classes/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/builtin-constraints-override.xml")
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class BuiltinValidatorOverrideTest extends AbstractTest {
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -54,7 +54,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class ConstraintCompositionTest extends AbstractTest {
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/ConstraintDefinitionsTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/ConstraintDefinitionsTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/ConstraintDefinitionsTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -39,7 +39,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class ConstraintDefinitionsTest extends AbstractTest {
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -49,7 +49,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class DefaultGroupRedefinitionTest extends AbstractTest {
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -39,6 +39,7 @@
import org.hibernate.jsr303.tck.util.TestUtil;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertEqualPaths;
/**
* Tests for the group and group sequence feature.
@@ -46,7 +47,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
public class GroupTest extends AbstractTest {
@Test
@@ -182,7 +183,7 @@
assertEquals( constraintViolations.size(), 1, "Wrong number of constraints"
);
assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity"
);
assertEquals( constraintViolation.getInvalidValue(), book.getTitle(), "Wrong
value" );
- assertEquals( constraintViolation.getPropertyPath().toString(), "title",
"Wrong propertyName" );
+ assertCorrectPropertyPaths( constraintViolations, "title" );
book.setTitle( "Hibernate Persistence with JPA" );
book.setSubtitle( "Revised Edition of Hibernate in Action" );
@@ -193,7 +194,7 @@
assertEquals( constraintViolation.getMessage(), "size must be between 0 and
30", "Wrong message" );
assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity"
);
assertEquals( constraintViolation.getInvalidValue(), book.getSubtitle(), "Wrong
value" );
- assertCorrectPropertyPaths(constraintViolations, "subtitle");
+ assertCorrectPropertyPaths( constraintViolations, "subtitle" );
book.setSubtitle( "Revised Edition" );
author.setCompany( "JBoss a divison of RedHat" );
@@ -204,7 +205,7 @@
assertEquals( constraintViolation.getMessage(), "size must be between 0 and
20" );
assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity"
);
assertEquals( constraintViolation.getInvalidValue(), author.getCompany(), "Wrong
value" );
- assertCorrectPropertyPaths(constraintViolations, "author.company");
+ assertCorrectPropertyPaths( constraintViolations, "author.company" );
author.setCompany( "JBoss" );
@@ -234,7 +235,7 @@
assertEquals( constraintViolation.getMessage(), "may not be null",
"Wrong message" );
assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity"
);
assertEquals( constraintViolation.getInvalidValue(), book.getTitle(), "Wrong
value" );
- assertCorrectPropertyPaths(constraintViolations, "title");
+ assertCorrectPropertyPaths( constraintViolations, "title" );
book.setTitle( "Hibernate Persistence with JPA" );
book.setSubtitle( "Revised Edition of Hibernate in Action" );
@@ -306,7 +307,9 @@
);
for ( ConstraintViolation<User> constraintViolation : constraintViolations ) {
- if ( constraintViolation.getPropertyPath().toString().equals(
"defaultCreditCard" ) ) {
+ if ( assertEqualPaths(
+ constraintViolation.getPropertyPath(), TestUtil.PathImpl.createPathFromString(
"defaultCreditCard" )
+ ) ) {
TestUtil.assertConstraintViolation(
constraintViolation,
User.class,
@@ -314,7 +317,9 @@
"defaultCreditCard"
);
}
- else if ( constraintViolation.getPropertyPath().toString().equals(
"phoneNumber" ) ) {
+ else if ( assertEqualPaths(
+ constraintViolation.getPropertyPath(), TestUtil.PathImpl.createPathFromString(
"phoneNumber" )
+ ) ) {
TestUtil.assertConstraintViolation(
constraintViolation,
User.class,
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -38,7 +38,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class ConstraintInheritanceTest extends AbstractTest {
@Test
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Fubar.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -35,7 +35,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class InvalidConstraintDefinitionsTest extends AbstractTest {
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -43,7 +43,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class ValidatorResolutionTest {
@Test
Modified:
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 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -42,7 +42,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class BeanDescriptorTest extends AbstractTest {
@Test
Modified:
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 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -44,7 +44,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class ConstraintDescriptorTest extends AbstractTest {
@Test
Modified:
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 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/PropertyDescriptorTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -37,7 +37,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class PropertyDescriptorTest extends AbstractTest {
@Test
@SpecAssertion(section = "5.4", id = "a")
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/Actor.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/Actor.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/Actor.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -1,4 +1,4 @@
-// $Id: ActorListBased.java 16840 2009-06-19 11:38:29Z hardy.ferentschik $
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/Actor.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ActorArrayBased.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ActorArrayBased.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ActorArrayBased.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -1,4 +1,4 @@
-// $Id: ActorListBased.java 16840 2009-06-19 11:38:29Z hardy.ferentschik $
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ActorArrayBased.java
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/PlayedWith.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -1,4 +1,4 @@
-// $Id: ValidateTest.java 16824 2009-06-17 20:57:08Z hardy.ferentschik $
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -44,7 +44,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class ValidatePropertyTest extends AbstractTest {
//TODO Needs verification
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -49,7 +49,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class ValidateTest extends AbstractTest {
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateValueTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateValueTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateValueTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -1,4 +1,4 @@
-// $Id: ValidateTest.java 16824 2009-06-17 20:57:08Z hardy.ferentschik $
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -38,7 +38,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class ValidateValueTest extends AbstractTest {
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateValueTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/customconstraint/CustomConstraintValidatorTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/customconstraint/CustomConstraintValidatorTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/customconstraint/CustomConstraintValidatorTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -42,7 +42,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class CustomConstraintValidatorTest extends AbstractTest {
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -38,7 +38,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class GraphNavigationTest extends AbstractTest {
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/TraversableResolverTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/TraversableResolverTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/TraversableResolverTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -36,7 +36,7 @@
* @author Emmanuel Bernard
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class TraversableResolverTest extends AbstractTest {
@Test
public void testCorrectPathsAreRequested() {
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -34,12 +34,13 @@
import org.hibernate.jsr303.tck.util.TestUtil;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertEqualPaths;
/**
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
public class ConstraintValidatorContextTest extends AbstractTest {
@Test
@@ -107,10 +108,12 @@
boolean validatedNestedBean = false;
for ( ConstraintViolation<DummyBean> violation : constraintViolations ) {
- if ( violation.getPropertyPath().toString().equals( "value" ) ) {
+ if ( assertEqualPaths( violation.getPropertyPath(),
TestUtil.PathImpl.createPathFromString( "value" ) ) ) {
assertEquals( "dummy message", violation.getMessage(), "Wrong
message" );
}
- else if ( violation.getPropertyPath().toString().equals( "nestedDummy.value"
) ) {
+ else if ( assertEqualPaths(
+ violation.getPropertyPath(), TestUtil.PathImpl.createPathFromString(
"nestedDummy.value" )
+ ) ) {
assertEquals( "dummy message", violation.getMessage(), "Wrong
message" );
validatedNestedBean = true;
}
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -1,4 +1,4 @@
-// $Id: CustomConstraintValidatorTest.java 16835 2009-06-18 16:29:46Z hardy.ferentschik
$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -38,7 +38,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
public class CustomConstraintValidatorTest extends AbstractTest {
@SpecAssertion(section = "2.5", id = "a")
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MyConstraint.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MyConstraint.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MyConstraint.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -1,4 +1,4 @@
-// $Id: MyConstraint.java 16835 2009-06-18 16:29:46Z hardy.ferentschik $
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MyConstraint.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MySecondConstraint.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MySecondConstraint.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MySecondConstraint.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -1,4 +1,4 @@
-// $Id: MyConstraint.java 16835 2009-06-18 16:29:46Z hardy.ferentschik $
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MySecondConstraint.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MySecondConstraintValidator.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MySecondConstraintValidator.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MySecondConstraintValidator.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -1,4 +1,4 @@
-// $Id: MyConstraintValidator.java 16835 2009-06-18 16:29:46Z hardy.ferentschik $
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/MySecondConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/EmptyXmlConfigurationTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/EmptyXmlConfigurationTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/EmptyXmlConfigurationTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -35,7 +35,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
@ValidationXml(value = "validation-no-additional-config.xml")
@Resource(source = "order-constraints-no-additional-config.xml",
destination =
"WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/order-constraints-no-additional-config.xml")
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/InvalidXmlConfigurationTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/InvalidXmlConfigurationTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/InvalidXmlConfigurationTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -34,7 +34,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
@ValidationXml(value = "validation-invalid-xml.xml")
public class InvalidXmlConfigurationTest extends AbstractTest {
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java 2009-06-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -38,7 +38,7 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
+(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
@ValidationXml(value = "validation.xml")
@Resources(
{
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-24
17:39:28 UTC (rev 16947)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-06-25
10:10:13 UTC (rev 16948)
@@ -20,8 +20,11 @@
import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.validation.ConstraintViolation;
import javax.validation.Path;
import javax.validation.Validation;
@@ -32,6 +35,7 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
+import static org.testng.FileAssert.fail;
/**
* @author Hardy Ferentschik
@@ -82,26 +86,32 @@
}
public static <T> void
assertCorrectPropertyPaths(Set<ConstraintViolation<T>> violations, String...
propertyPaths) {
- List<String> propertyPathsOfViolations = new ArrayList<String>();
+ List<Path> propertyPathsOfViolations = new ArrayList<Path>();
for ( ConstraintViolation<?> violation : violations ) {
- propertyPathsOfViolations.add( violation.getPropertyPath().toString() );
+ propertyPathsOfViolations.add( violation.getPropertyPath() );
}
for ( String propertyPath : propertyPaths ) {
- assertTrue(
- propertyPathsOfViolations.contains( propertyPath ),
- propertyPath + " should be used in at least one constraint violation"
- );
+ Path expectedPath = PathImpl.createPathFromString( propertyPath );
+ boolean containsPath = false;
+ for ( Path actualPath : propertyPathsOfViolations ) {
+ if ( assertEqualPaths( expectedPath, actualPath ) ) {
+ containsPath = true;
+ break;
+ }
+ }
+ if ( !containsPath ) {
+ fail( expectedPath + " is not in the list of path instances contained in the
actual constraint violations" );
+ }
}
}
public static <T> void assertConstraintViolation(ConstraintViolation<T>
violation, Class<?> rootBean, Object invalidValue, String propertyPath) {
+ if ( !assertEqualPaths( violation.getPropertyPath(), PathImpl.createPathFromString(
propertyPath ) ) ) {
+ fail( "Property paths differ." );
+ }
+
assertEquals(
- violation.getPropertyPath().toString(),
- propertyPath,
- "Wrong propertyPath."
- );
- assertEquals(
violation.getRootBean().getClass(),
rootBean,
"Wrong root bean."
@@ -113,6 +123,53 @@
);
}
+ public static boolean assertEqualPaths(Path p1, Path p2) {
+ Iterator<Path.Node> p1Iterator = p1.iterator();
+ Iterator<Path.Node> p2Iterator = p2.iterator();
+ while ( p1Iterator.hasNext() ) {
+ Path.Node p1Node = p1Iterator.next();
+ if ( !p2Iterator.hasNext() ) {
+ return false;
+ }
+ Path.Node p2Node = p2Iterator.next();
+
+ // do the comparison on the node values
+ if ( p2Node.getName() == null ) {
+ if ( p1Node.getName() != null ) {
+ return false;
+ }
+ }
+ else if ( !p2Node.getName().equals( p1Node.getName() ) ) {
+ return false;
+ }
+
+ if ( p2Node.isInIterable() != p1Node.isInIterable() ) {
+ return false;
+ }
+
+
+ if ( p2Node.getIndex() == null ) {
+ if ( p1Node.getIndex() != null ) {
+ return false;
+ }
+ }
+ else if ( !p2Node.getIndex().equals( p1Node.getIndex() ) ) {
+ return false;
+ }
+
+ if ( p2Node.getKey() == null ) {
+ if ( p1Node.getKey() != null ) {
+ return false;
+ }
+ }
+ else if ( !p2Node.getKey().equals( p1Node.getKey() ) ) {
+ return false;
+ }
+ }
+
+ return !p2Iterator.hasNext();
+ }
+
public static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String
property) {
Validator validator = getDefaultValidator();
return validator.getConstraintsForClass( clazz ).getConstraintsForProperty( property
);
@@ -133,4 +190,167 @@
}
return inputStream;
}
+
+ public static class PathImpl implements Path {
+
+ /**
+ * Regular expression used to split a string path into its elements.
+ *
+ * @see <a
href="http://www.regexplanet.com/simple/index.jsp">Regular
expression tester</a>
+ */
+ private static final Pattern pathPattern = Pattern.compile(
"(\\w+)(\\[(\\w?)\\])?(\\.(.*))*" );
+
+ private static final String PROPERTY_PATH_SEPERATOR = ".";
+
+ private static final Node ROOT_NODE = new NodeImpl( ( String ) null );
+
+ private final List<Node> nodeList;
+
+ public static PathImpl createPathFromString(String propertyPath) {
+ if ( propertyPath == null ) {
+ throw new IllegalArgumentException( "null is not allowed as property path."
);
+ }
+
+ if ( propertyPath.length() == 0 ) {
+ return createNewRootPath();
+ }
+
+ return parseProperty( propertyPath );
+ }
+
+ public static PathImpl createNewRootPath() {
+ return new PathImpl();
+ }
+
+ private PathImpl() {
+ nodeList = new ArrayList<Node>();
+ nodeList.add( ROOT_NODE );
+ }
+
+ public void addNode(Node node) {
+ nodeList.add( node );
+ }
+
+ public Iterator<Path.Node> iterator() {
+ return nodeList.iterator();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ Iterator<Path.Node> iter = iterator();
+ while ( iter.hasNext() ) {
+ Node node = iter.next();
+ if ( ROOT_NODE.equals( node ) ) {
+ continue;
+ }
+ builder.append( node.toString() );
+ if ( iter.hasNext() ) {
+ builder.append( PROPERTY_PATH_SEPERATOR );
+ }
+ }
+ return builder.toString();
+ }
+
+ private static PathImpl parseProperty(String property) {
+ PathImpl path = new PathImpl();
+ String tmp = property;
+ do {
+ Matcher matcher = pathPattern.matcher( tmp );
+ if ( matcher.matches() ) {
+ String value = matcher.group( 1 );
+ String indexed = matcher.group( 2 );
+ String index = matcher.group( 3 );
+ NodeImpl node = new NodeImpl( value );
+ if ( indexed != null ) {
+ node.setInIterable( true );
+ }
+ if ( index != null && index.length() > 0 ) {
+ try {
+ Integer i = Integer.parseInt( index );
+ node.setIndex( i );
+ }
+ catch ( NumberFormatException e ) {
+ node.setKey( index );
+ }
+ }
+ path.addNode( node );
+ tmp = matcher.group( 5 );
+ }
+ else {
+ throw new IllegalArgumentException( "Unable to parse property path " +
property );
+ }
+ } while ( tmp != null );
+ return path;
+ }
+ }
+
+ public static class NodeImpl implements Path.Node {
+
+ private static final String INDEX_OPEN = "[";
+ private static final String INDEX_CLOSE = "]";
+
+ private final String name;
+ private boolean isInIterable;
+ private Integer index;
+ private Object key;
+
+
+ public NodeImpl(String name) {
+ this.name = name;
+ }
+
+ NodeImpl(Path.Node node) {
+ this.name = node.getName();
+ this.isInIterable = node.isInIterable();
+ this.index = node.getIndex();
+ this.key = node.getKey();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean isInIterable() {
+ return isInIterable;
+ }
+
+ public void setInIterable(boolean inIterable) {
+ isInIterable = inIterable;
+ }
+
+ public Integer getIndex() {
+ return index;
+ }
+
+ public void setIndex(Integer index) {
+ isInIterable = true;
+ this.index = index;
+ }
+
+ public Object getKey() {
+ return key;
+ }
+
+ public void setKey(Object key) {
+ isInIterable = true;
+ this.key = key;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder( name == null ? "" : name );
+ if ( isInIterable ) {
+ builder.append( INDEX_OPEN );
+ if ( getIndex() != null ) {
+ builder.append( getIndex() );
+ }
+ else if ( getKey() != null ) {
+ builder.append( getKey() );
+ }
+ builder.append( INDEX_CLOSE );
+ }
+ return builder.toString();
+ }
+ }
}