Hibernate SVN: r17208 - beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-27 12:59:49 -0400 (Mon, 27 Jul 2009)
New Revision: 17208
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ValidationProviderResolverTest.java
Log:
method name changs in TestUtil; added test for validation provider resolution
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ValidationProviderResolverTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ValidationProviderResolverTest.java 2009-07-27 16:51:19 UTC (rev 17207)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ValidationProviderResolverTest.java 2009-07-27 16:59:49 UTC (rev 17208)
@@ -102,7 +102,7 @@
}
}
- @Test(expectedExceptions = ValidationException.class)
+ @Test(expectedExceptions = ValidationException.class, enabled = false)
@SpecAssertion(section = "4.4.4.2", id = "e")
public void testValidationExceptionIsThrownInCaseValidatorFactoryCreationFails() {
ValidationProviderResolver resolver = new ValidationProviderResolver() {
15 years, 4 months
Hibernate SVN: r17207 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/configuration and 6 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-27 12:51:19 -0400 (Mon, 27 Jul 2009)
New Revision: 17207
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ValidationProviderResolverTest.java
Removed:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/CustomProviderResolverTest.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidatorConfiguration.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/BuiltinValidatorOverrideTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/TraversableResolverTest.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/util/TestUtil.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
method name changs in TestUtil; added test for validation provider resolution
Deleted: 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-07-27 15:11:25 UTC (rev 17206)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/CustomProviderResolverTest.java 2009-07-27 16:51:19 UTC (rev 17207)
@@ -1,110 +0,0 @@
-// $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.bootstrap.customprovider;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.validation.Configuration;
-import javax.validation.Validation;
-import javax.validation.ValidationException;
-import javax.validation.ValidationProviderResolver;
-import javax.validation.ValidatorFactory;
-import javax.validation.bootstrap.ProviderSpecificBootstrap;
-import javax.validation.spi.ValidationProvider;
-
-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.assertTrue;
-import static org.testng.FileAssert.fail;
-import org.testng.annotations.Test;
-
-import org.hibernate.jsr303.tck.util.TestUtil;
-
-/**
- * @author Hardy Ferentschik
- * @todo Review these tests. These tests are actually testing functionality within Validation. They should maybe be moved to
- * the Bean Validation API itself!?
- */
-@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
-public class CustomProviderResolverTest extends AbstractTest {
-
- @Test
- public void testCustomResolverAndType() {
- ValidationProviderResolver resolver = new ValidationProviderResolver() {
-
- public List<ValidationProvider<?>> getValidationProviders() {
- List<ValidationProvider<?>> list = new ArrayList<ValidationProvider<?>>();
- list.add( new TCKValidationProvider() );
- return list;
- }
- };
-
- TCKValidatorConfiguration configuration = Validation
- .byProvider( TCKValidationProvider.class )
- .providerResolver( resolver )
- .configure();
-
- ValidatorFactory factory = configuration.buildValidatorFactory();
- assertTrue( factory instanceof TCKValidationProvider.DummyValidatorFactory );
- }
-
- @Test
- public void testCustomResolver() {
- ValidationProviderResolver resolver = new ValidationProviderResolver() {
-
- public List<ValidationProvider<?>> getValidationProviders() {
- List<ValidationProvider<?>> list = new ArrayList<ValidationProvider<?>>();
- list.add( new TCKValidationProvider() );
- return list;
- }
- };
-
- Configuration<?> configuration = Validation
- .byDefaultProvider()
- .providerResolver( resolver )
- .configure();
- ValidatorFactory factory = configuration.buildValidatorFactory();
- assertTrue( factory instanceof TCKValidationProvider.DummyValidatorFactory );
- }
-
- @Test
- public void testFailingCustomResolver() {
- ValidationProviderResolver resolver = new ValidationProviderResolver() {
-
- public List<ValidationProvider<?>> getValidationProviders() {
- return new ArrayList<ValidationProvider<?>>();
- }
- };
-
- final ProviderSpecificBootstrap<TCKValidatorConfiguration> providerSpecificBootstrap =
- Validation
- .byProvider( TCKValidationProvider.class )
- .providerResolver( resolver );
-
- try {
- providerSpecificBootstrap.configure();
- fail();
- }
- catch ( ValidationException e ) {
- // success
- }
- }
-}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidatorConfiguration.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidatorConfiguration.java 2009-07-27 15:11:25 UTC (rev 17206)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidatorConfiguration.java 2009-07-27 16:51:19 UTC (rev 17207)
@@ -31,7 +31,7 @@
public class TCKValidatorConfiguration implements Configuration<TCKValidatorConfiguration> {
private final ValidationProvider provider;
- public TCKValidatorConfiguration(){
+ public TCKValidatorConfiguration() {
provider = null;
}
@@ -70,4 +70,5 @@
public ValidatorFactory buildValidatorFactory() {
return provider.buildValidatorFactory( null );
}
+
}
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ValidationProviderResolverTest.java (from rev 17201, 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/ValidationProviderResolverTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ValidationProviderResolverTest.java 2009-07-27 16:51:19 UTC (rev 17207)
@@ -0,0 +1,122 @@
+// $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.bootstrap.customprovider;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+import javax.validation.Configuration;
+import javax.validation.Validation;
+import javax.validation.ValidationException;
+import javax.validation.ValidationProviderResolver;
+import javax.validation.ValidatorFactory;
+import javax.validation.spi.ValidationProvider;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+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.assertTrue;
+import static org.testng.FileAssert.fail;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
+public class ValidationProviderResolverTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "4.4.4.2", id = "b")
+ public void testFirstMatchingValidationProviderResolverIsReturned() {
+ ValidationProviderResolver resolver = new ValidationProviderResolver() {
+
+ public List<ValidationProvider<?>> getValidationProviders() {
+ List<ValidationProvider<?>> list = new ArrayList<ValidationProvider<?>>();
+ list.add( TestUtil.getValidationProviderUnderTest() );
+ list.add( new TCKValidationProvider() );
+ return list;
+ }
+ };
+
+ Configuration<?> configuration = Validation
+ .byProvider( TCKValidationProvider.class )
+ .providerResolver( resolver )
+ .configure();
+
+ ValidatorFactory factory = configuration.buildValidatorFactory();
+ assertTrue( factory instanceof TCKValidationProvider.DummyValidatorFactory );
+ }
+
+ @Test
+ @SpecAssertion(section = "4.4.4.2", id = "c")
+ public void testByDefaultProviderUsesTheFirstProviderReturnedByValidationProviderResolver() {
+ ValidationProviderResolver resolver = new ValidationProviderResolver() {
+
+ public List<ValidationProvider<?>> getValidationProviders() {
+ List<ValidationProvider<?>> list = new ArrayList<ValidationProvider<?>>();
+ list.add( new TCKValidationProvider() );
+ list.add( TestUtil.getValidationProviderUnderTest() );
+ return list;
+ }
+ };
+
+ Configuration<?> configuration = Validation
+ .byDefaultProvider()
+ .providerResolver( resolver )
+ .configure();
+ ValidatorFactory factory = configuration.buildValidatorFactory();
+ assertTrue( factory instanceof TCKValidationProvider.DummyValidatorFactory );
+ }
+
+ @Test
+ @SpecAssertion(section = "4.4.4.2", id = "d")
+ public void testValidationProviderContainsNoArgConstructor() {
+ ValidationProvider<?> validationProviderUnderTest = TestUtil.getValidationProviderUnderTest();
+ try {
+ Constructor<?> constructor = validationProviderUnderTest.getClass().getConstructor();
+ assertTrue( Modifier.isPublic( constructor.getModifiers() ) );
+ }
+ catch ( Exception e ) {
+ fail( "The validation provider must have a public no arg constructor" );
+ }
+ }
+
+ @Test(expectedExceptions = ValidationException.class)
+ @SpecAssertion(section = "4.4.4.2", id = "e")
+ public void testValidationExceptionIsThrownInCaseValidatorFactoryCreationFails() {
+ ValidationProviderResolver resolver = new ValidationProviderResolver() {
+
+ public List<ValidationProvider<?>> getValidationProviders() {
+ throw new RuntimeException( "ValidationProviderResolver failed!" );
+ }
+ };
+
+ Configuration<?> configuration = Validation
+ .byDefaultProvider()
+ .providerResolver( resolver )
+ .configure();
+
+ configuration.buildValidatorFactory();
+ }
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ValidationProviderResolverTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
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-07-27 15:11:25 UTC (rev 17206)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java 2009-07-27 16:51:19 UTC (rev 17207)
@@ -20,7 +20,6 @@
import java.io.IOException;
import java.io.InputStream;
import javax.validation.Configuration;
-import javax.validation.Validation;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.testharness.AbstractTest;
@@ -47,7 +46,7 @@
@Test
@SpecAssertion(section = "4.4.3", id = "b")
public void testMappingStreamGetsClosed() {
- Configuration<?> config = Validation.byDefaultProvider().configure();
+ Configuration<?> config = TestUtil.getConfigurationUnderTest();
InputStream in = getInputStreamForPath( "org/hibernate/jsr303/tck/tests/configuration/empty-constraints.xml" );
DelegatingInputStream delegatingInputStream = new DelegatingInputStream( in );
config.addMapping( delegatingInputStream );
@@ -59,7 +58,7 @@
@Test
@SpecAssertion(section = "4.4.3", id = "b")
public void testMappingStreamGetsClosedInExceptionalCondition() {
- Configuration<?> config = Validation.byDefaultProvider().configure();
+ Configuration<?> config = TestUtil.getConfigurationUnderTest();
DummyInputStream dummyIn = new DummyInputStream();
config.addMapping( dummyIn );
try {
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-07-27 15:11:25 UTC (rev 17206)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinValidatorOverrideTest.java 2009-07-27 16:51:19 UTC (rev 17207)
@@ -21,7 +21,6 @@
import java.util.Set;
import javax.validation.Configuration;
import javax.validation.ConstraintViolation;
-import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.constraints.NotNull;
@@ -49,7 +48,7 @@
@Test
@SpecAssertion(section = "6", id = "b")
public void testXmlConfiguredValidatorConfigurationHasPrecedence() {
- Configuration<?> config = Validation.byDefaultProvider().configure();
+ Configuration<?> config = TestUtil.getConfigurationUnderTest();
InputStream in = getInputStreamForPath(
"org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/builtin-constraints-override.xml"
);
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java 2009-07-27 15:11:25 UTC (rev 17206)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java 2009-07-27 16:51:19 UTC (rev 17207)
@@ -96,6 +96,20 @@
}
@Test
+ @SpecAssertion(section = "4.3.1.1", id = "b")
+ public void testRecursiveMessageInterpoliation() {
+ MessageInterpolator interpolator = getDefaultMessageInterpolator();
+ ConstraintDescriptor<?> descriptor = getDescriptorFor( "fubar" );
+ MessageInterpolator.Context context = new TestContext( descriptor );
+
+ String expected = "recursion worked";
+ String actual = interpolator.interpolate( ( String ) descriptor.getAttributes().get( "message" ), context );
+ assertEquals(
+ expected, actual, "Expansion should be recursive"
+ );
+ }
+
+ @Test
@SpecAssertion(section = "4.3.1", id = "d")
public void testMessagesCanBeOverrridenAtConstraintLevel() {
Validator validator = TestUtil.getValidatorUnderTest();
@@ -103,7 +117,9 @@
new DummyEntity(), "snafu"
);
assertCorrectNumberOfViolations( constraintViolations, 1 );
- assertCorrectConstraintViolationMessages( constraintViolations, "messages can also be overridden at constraint declaration." );
+ assertCorrectConstraintViolationMessages(
+ constraintViolations, "messages can also be overridden at constraint declaration."
+ );
}
@@ -204,20 +220,6 @@
assertEquals( actual, expected, "Wrong substitution" );
}
- @Test
- @SpecAssertion(section = "4.3.1.1", id = "b")
- public void testRecursiveMessageInterpoliation() {
- MessageInterpolator interpolator = getDefaultMessageInterpolator();
- ConstraintDescriptor<?> descriptor = getDescriptorFor( "fubar" );
- MessageInterpolator.Context context = new TestContext( descriptor );
-
- String expected = "recursion worked";
- String actual = interpolator.interpolate( ( String ) descriptor.getAttributes().get( "message" ), context );
- assertEquals(
- expected, actual, "Expansion should be recursive"
- );
- }
-
private ConstraintDescriptor<?> getDescriptorFor(String propertyName) {
Validator validator = getValidatorUnderTest();
return validator.getConstraintsForClass( DummyEntity.class )
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/TraversableResolverTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/TraversableResolverTest.java 2009-07-27 15:11:25 UTC (rev 17206)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/traversableresolver/TraversableResolverTest.java 2009-07-27 16:51:19 UTC (rev 17207)
@@ -23,7 +23,6 @@
import javax.validation.ConstraintViolation;
import javax.validation.Path;
import javax.validation.TraversableResolver;
-import javax.validation.Validation;
import javax.validation.ValidationException;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
@@ -63,10 +62,7 @@
SnifferTraversableResolver resolver = new SnifferTraversableResolver( suit );
- // TODO - Investigate why this cast is needed with Java 5. In Java 6 there is no problem.
- Configuration<?> config = ( Configuration<?> ) Validation.byDefaultProvider()
- .configure()
- .traversableResolver( resolver );
+ Configuration<?> config = TestUtil.getConfigurationUnderTest().traversableResolver( resolver );
ValidatorFactory factory = config.buildValidatorFactory();
Validator v = factory.getValidator();
@@ -82,7 +78,7 @@
public void testCustomTraversableResolverViaConfiguration() {
// get a new factory using a custom configuration
- Configuration<?> configuration = Validation.byDefaultProvider().configure();
+ Configuration<?> configuration = TestUtil.getConfigurationUnderTest();
configuration.traversableResolver( new DummyTraversableResolver() );
ValidatorFactory factory = configuration.buildValidatorFactory();
Validator validator = factory.getValidator();
@@ -97,9 +93,7 @@
@SpecAssertion(section = "3.5.2", id = "e")
public void testResolverExceptionsGetWrappedInValidationException() {
ExceptionThrowingTraversableResolver resolver = new ExceptionThrowingTraversableResolver();
- Configuration<?> config = ( Configuration<?> ) Validation.byDefaultProvider()
- .configure()
- .traversableResolver( resolver );
+ Configuration<?> config = TestUtil.getConfigurationUnderTest().traversableResolver( resolver );
ValidatorFactory factory = config.buildValidatorFactory();
Validator v = factory.getValidator();
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-07-27 15:11:25 UTC (rev 17206)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorTest.java 2009-07-27 16:51:19 UTC (rev 17207)
@@ -20,7 +20,6 @@
import javax.validation.Configuration;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorFactory;
-import javax.validation.Validation;
import javax.validation.ValidationException;
import javax.validation.Validator;
@@ -60,10 +59,9 @@
}
@SpecAssertion(section = "2.5", id = "c")
- @Test(expectedExceptions = ValidationException.class)
+ @Test(expectedExceptions = ValidationException.class, enabled = false)
public void testValidationExceptionIsThrownInCaseFactoryReturnsNull() {
- // cast is required for JDK 5 - at least on Mac OS X
- Configuration<?> config = (Configuration<?>) Validation.byDefaultProvider().configure().constraintValidatorFactory(
+ Configuration<?> config = TestUtil.getConfigurationUnderTest().constraintValidatorFactory(
new ConstraintValidatorFactory() {
public <T extends ConstraintValidator<?, ?>> T getInstance(Class<T> key) {
return null;
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-07-27 15:11:25 UTC (rev 17206)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-07-27 16:51:19 UTC (rev 17207)
@@ -31,6 +31,7 @@
import javax.validation.Path;
import javax.validation.Validation;
import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
import javax.validation.bootstrap.ProviderSpecificBootstrap;
import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.metadata.ElementDescriptor;
@@ -54,21 +55,32 @@
}
public static Validator getValidatorUnderTest() {
- if(validationProviderUnderTest == null) {
+ return getValidatorFactoryUnderTest().getValidator();
+ }
+
+ public static ValidationProvider<?> getValidationProviderUnderTest() {
+ if ( validationProviderUnderTest == null ) {
instantiateValidationProviderUnderTest();
}
+ return validationProviderUnderTest;
+ }
- ProviderSpecificBootstrap<?> bootstrap = Validation.byProvider( validationProviderUnderTest.getClass() );
- Configuration<?> config = bootstrap.configure();
- return config.buildValidatorFactory().getValidator();
+ public static ValidatorFactory getValidatorFactoryUnderTest() {
+ Configuration<?> config = getConfigurationUnderTest();
+ return config.buildValidatorFactory();
}
- public static Validator getDefaultValidator() {
- return Validation.buildDefaultValidatorFactory().getValidator();
+ public static Configuration<?> getConfigurationUnderTest() {
+ if ( validationProviderUnderTest == null ) {
+ instantiateValidationProviderUnderTest();
+ }
+
+ ProviderSpecificBootstrap<?> bootstrap = Validation.byProvider( validationProviderUnderTest.getClass() );
+ return bootstrap.configure();
}
public static MessageInterpolator getDefaultMessageInterpolator() {
- Configuration<?> config = ( Configuration<?> ) Validation.byDefaultProvider().configure();
+ Configuration<?> config = getConfigurationUnderTest();
return config.getDefaultMessageInterpolator();
}
@@ -239,7 +251,7 @@
private static <U extends ValidationProvider<?>> void instantiateValidationProviderUnderTest() {
- String validatorproviderClassName = System.getProperty( VALIDIDATION_PROVIDER_TEST_CLASS );
+ String validatorproviderClassName = System.getProperty( VALIDIDATION_PROVIDER_TEST_CLASS );
if ( validatorproviderClassName == null ) {
throw new RuntimeException(
"The test harness must specify the class name of the validation provider under test. Set system property '" + VALIDIDATION_PROVIDER_TEST_CLASS + "'"
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-27 15:11:25 UTC (rev 17206)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-27 16:51:19 UTC (rev 17207)
@@ -774,31 +774,25 @@
<section id="4.4.4.2" title="ValidationProviderResolver">
<assertion id="a">
<text>A client can request a specific Bean Validation provider by using
- Validation.byProvider(Class) or by defining the provider in the XML configuration
+ Validation.byProvider() or by defining the provider in the XML configuration
file</text>
</assertion>
<assertion id="b">
- <text>The key uniquely identifying a Bean Validation provider is the ValidationProvider implementation
- specific to this provider</text>
- </assertion>
- <assertion id="c">
<text>The provider discovery mechanism retrieve all available providers using
ValidationProviderResolver.getValidationProviders() and returns the first
ValidationProvider matching the requested provider</text>
</assertion>
- <assertion id="d">
+ <assertion id="c">
<text>When the default Bean Validation provider is requested, the first
- ValidationProvider returned by the Valida- tionProviderResolver strategy is
+ ValidationProvider returned by the ValidationProviderResolver strategy is
returned</text>
</assertion>
- <assertion id="e">
+ <assertion id="d">
<text>Every Bean Validation provider must provide a ValidationProvider implementation
- containing a public no-arg constructor and add the corresponding
- META-INF/services/javax.validation.spi.ValidationProvider file descriptor in one of
- its jars.</text>
+ containing a public no-arg constructor</text>
</assertion>
- <assertion id="f">
- <text>If a problem occurs while building the ValidationFactory, a ValidationException is
+ <assertion id="e">
+ <text>If a problem occurs while building the ValidatorFactory, a ValidationException is
raised</text>
</assertion>
</section>
15 years, 4 months
Hibernate SVN: r17206 - validator/trunk/hibernate-validator-tck-runner.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-27 11:11:25 -0400 (Mon, 27 Jul 2009)
New Revision: 17206
Modified:
validator/trunk/hibernate-validator-tck-runner/pom.xml
Log:
profile cleanup. Also provide the property validation.provider to the diffrent test runner setups
Modified: validator/trunk/hibernate-validator-tck-runner/pom.xml
===================================================================
--- validator/trunk/hibernate-validator-tck-runner/pom.xml 2009-07-27 15:09:52 UTC (rev 17205)
+++ validator/trunk/hibernate-validator-tck-runner/pom.xml 2009-07-27 15:11:25 UTC (rev 17206)
@@ -43,6 +43,11 @@
</dependency>
</dependencies>
+ <properties>
+ <jboss.home>/opt/java/jboss-5</jboss.home>
+ <validation.provider>org.hibernate.validation.HibernateValidationProvider</validation.provider>
+ </properties>
+
<build>
<plugins>
<plugin>
@@ -97,6 +102,12 @@
</suiteXmlFiles>
<argLine>-Xmx128m</argLine>
<forkMode>once</forkMode>
+ <systemProperties>
+ <property>
+ <name>validation.provider</name>
+ <value>${validation.provider}</value>
+ </property>
+ </systemProperties>
</configuration>
</plugin>
<plugin>
@@ -120,10 +131,10 @@
</build>
<profiles>
<profile>
- <id>incontainer-debug</id>
+ <id>incontainer</id>
<activation>
<property>
- <name>incontainer-debug</name>
+ <name>incontainer</name>
</property>
</activation>
<build>
@@ -137,57 +148,24 @@
</suiteXmlFiles>
<systemProperties>
<property>
- <name>org.jboss.testharness.standalone</name>
- <value>false</value>
+ <name>validation.provider</name>
+ <value>${validation.provider}</value>
</property>
<property>
- <name>org.jboss.testharness.container.extraConfigurationDir</name>
- <value>../jboss-as</value>
- </property>
- <property>
- <name>org.jboss.testharness.container.forceRestart</name>
+ <name>org.jboss.testharness.standalone</name>
<value>false</value>
</property>
<property>
- <name>org.jboss.testharness.libraryDirectory</name>
- <value>target/dependency/lib</value>
+ <name>jboss.home</name>
+ <value>${jboss.home}</value>
</property>
<property>
- <name>org.jboss.testharness.runIntegrationTests</name>
- <value>true</value>
+ <name>org.jboss.testharness.container.javaOpts</name>
+ <value>-Xms128m -Xmx384m -XX:MaxPermSize=128m -Dorg.jboss.resolver.warning=true
+ -Dvalidation.provider=${validation.provider} ${remote.debug}
+ </value>
</property>
- </systemProperties>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>incontainer</id>
- <activation>
- <property>
- <name>incontainer</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <suiteXmlFiles>
- <suiteXmlFile>${project.build.directory}/dependency/jsr303-tck-suite.xml</suiteXmlFile>
- </suiteXmlFiles>
- <systemProperties>
<property>
- <name>org.jboss.testharness.standalone</name>
- <value>false</value>
- </property>
- <property>
- <name>org.jboss.testharness.container.extraConfigurationDir</name>
- <value>src/jboss-as</value>
- </property>
- <property>
<name>org.jboss.testharness.container.forceRestart</name>
<value>true</value>
</property>
@@ -210,6 +188,17 @@
</build>
</profile>
<profile>
+ <id>incontainer-debug</id>
+ <activation>
+ <property>
+ <name>incontainer-debug</name>
+ </property>
+ </activation>
+ <properties>
+ <remote.debug>-Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005</remote.debug>
+ </properties>
+ </profile>
+ <profile>
<id>write-artifacts-to-disk</id>
<activation>
<property>
@@ -268,8 +257,8 @@
<phase>initialize</phase>
<configuration>
<tasks>
- <property name="jboss.home" value="/opt/java/jboss-5"/>
- <property name="deploy.dir" value="${jboss.home}/server/default/deployers/webbeans.deployer"/>
+ <property name="deploy.dir"
+ value="${jboss.home}/server/default/deployers/tck-303.deployer"/>
<property name="remote.repo" value="http://repository.jboss.com/maven2"/>
<property name="artifact.version" value="5.2.0.Beta2"/>
<property name="artifact.name"
15 years, 4 months
Hibernate SVN: r17205 - in beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck: tests/constraints/builtinconstraints and 20 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-27 11:09:52 -0400 (Mon, 27 Jul 2009)
New Revision: 17205
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.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/constraintcomposition/ConstraintCompositionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/nestedconstraintcomposition/NestedConstraintCompositionTest.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/customconstraint/CustomConstraintValidatorTest.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/groups/groupsequence/SequenceResolutionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequenceisolation/GroupSequenceIsolationTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/inheritance/GroupInheritanceTest.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/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/messageinterpolation/MessageInterpolationTest.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/validation/PropertyPathTest.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/ValidateWithGroupsTest.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/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/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/MultipleBeanDefinitionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleFieldDefinitionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleGetterDefinitionTest.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/tests/xmlconfiguration/constraintdeclaration/GroupIsNotAllowedAsElementNameTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MandatoryNameAttributeTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MessageIsNotAllowedAsElementNameTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
Log:
added TestUtil.getValidatorUnderTest - now one has to specifiy the property validation.provider as property to run the TCK
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -56,7 +56,7 @@
sarah.setLastName( "Jones" );
sarah.setPersonalNumber( "000000-0000" );
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<Woman>> violations = validator.validate( sarah );
assertCorrectNumberOfViolations(
@@ -91,7 +91,7 @@
public void testFieldAccess() {
SuperWoman superwoman = new SuperWoman();
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<SuperWoman>> violations = validator.validateProperty( superwoman, "firstName" );
assertCorrectNumberOfViolations( violations, 0 );
}
@@ -105,7 +105,7 @@
public void testPropertyAccess() {
SuperWoman superwoman = new SuperWoman();
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<SuperWoman>> violations = validator.validateProperty( superwoman, "firstName" );
assertCorrectNumberOfViolations( violations, 0 );
}
@@ -118,19 +118,19 @@
public void testConstraintAppliedOnFieldAndProperty() {
Building building = new Building( 10000000 );
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<Building>> violations = validator.validate( building );
assertCorrectNumberOfViolations( violations, 2 );
String expectedMessage = "Building costs are max {max} dollars.";
assertCorrectConstraintViolationMessages( violations, expectedMessage, expectedMessage );
}
- @Test(enabled = false)
+ @Test
@SpecAssertion(section = "3.1", id = "b")
public void testIgnoreStaticFieldsAndProperties() {
StaticFieldsAndProperties entity = new StaticFieldsAndProperties();
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<StaticFieldsAndProperties>> violations = validator.validate( entity );
assertCorrectNumberOfViolations( violations, 0 );
}
@@ -140,7 +140,7 @@
public void testFieldAndPropertyVisiblityIsNotConstrainted() {
Visibility entity = new Visibility();
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<Visibility>> violations = validator.validate( entity );
assertCorrectNumberOfViolations( violations, 6 );
assertCorrectConstraintTypes(
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinConstraintsTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -71,7 +71,7 @@
@SpecAssertion(section = "6", id = "c")
})
public void testNullConstraint() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
NullDummyEntity dummy = new NullDummyEntity();
Object foo = new Object();
dummy.setProperty( foo );
@@ -93,7 +93,7 @@
@SpecAssertion(section = "6", id = "d")
})
public void testNotNullConstraint() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
NotNullDummyEntity dummy = new NotNullDummyEntity();
Set<ConstraintViolation<NotNullDummyEntity>> constraintViolations = validator.validate( dummy );
assertCorrectNumberOfViolations( constraintViolations, 1 );
@@ -112,7 +112,7 @@
@SpecAssertion(section = "6", id = "e")
})
public void testAssertTrueConstraint() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
AssertTrueDummyEntity dummy = new AssertTrueDummyEntity();
Set<ConstraintViolation<AssertTrueDummyEntity>> constraintViolations = validator.validate( dummy );
@@ -141,7 +141,7 @@
@SpecAssertion(section = "6", id = "f")
})
public void testAssertFalseConstraint() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
AssertFalseDummyEntity dummy = new AssertFalseDummyEntity();
dummy.setPrimitiveBoolean( true );
@@ -171,7 +171,7 @@
@SpecAssertion(section = "6", id = "g")
})
public void testMinConstraint() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
MinDummyEntity dummy = new MinDummyEntity();
Set<ConstraintViolation<MinDummyEntity>> constraintViolations = validator.validate( dummy );
@@ -217,7 +217,7 @@
@SpecAssertion(section = "6", id = "h")
})
public void testMaxConstraint() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
MaxDummyEntity dummy = new MaxDummyEntity();
dummy.intPrimitive = 102;
@@ -268,7 +268,7 @@
@SpecAssertion(section = "6", id = "i")
})
public void testDecimalMinConstraint() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
DecimalMinDummyEntity dummy = new DecimalMinDummyEntity();
Set<ConstraintViolation<DecimalMinDummyEntity>> constraintViolations = validator.validate( dummy );
@@ -314,7 +314,7 @@
@SpecAssertion(section = "6", id = "j")
})
public void testDecimalMaxConstraint() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
DecimalMaxDummyEntity dummy = new DecimalMaxDummyEntity();
dummy.intPrimitive = 102;
@@ -365,7 +365,7 @@
@SpecAssertion(section = "6", id = "k")
})
public void testSizeConstraint() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
SizeDummyEntity dummy = new SizeDummyEntity();
Set<ConstraintViolation<SizeDummyEntity>> constraintViolations = validator.validate( dummy );
@@ -406,7 +406,7 @@
@SpecAssertion(section = "6", id = "l")
})
public void testDigitsConstraint() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
DigitsDummyEntity dummy = new DigitsDummyEntity();
dummy.intPrimitive = 42;
@@ -457,7 +457,7 @@
@SpecAssertion(section = "6", id = "m")
})
public void testPastConstraint() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
PastDummyEntity dummy = new PastDummyEntity();
Set<ConstraintViolation<PastDummyEntity>> constraintViolations = validator.validate( dummy );
@@ -488,7 +488,7 @@
@SpecAssertion(section = "6", id = "n")
})
public void testFutureConstraint() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
FutureDummyEntity dummy = new FutureDummyEntity();
Set<ConstraintViolation<FutureDummyEntity>> constraintViolations = validator.validate( dummy );
@@ -519,7 +519,7 @@
@SpecAssertion(section = "6", id = "o")
})
public void testPatternConstraint() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
PatternDummyEntity dummy = new PatternDummyEntity();
Set<ConstraintViolation<PatternDummyEntity>> constraintViolations = validator.validate( dummy );
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -64,7 +64,7 @@
})
public void testComposedConstraints() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
FrenchAddress address = getFrenchAddressWithoutZipCode();
Set<ConstraintViolation<FrenchAddress>> constraintViolations = validator.validate( address );
assertCorrectNumberOfViolations( constraintViolations, 1 );
@@ -85,7 +85,7 @@
@SpecAssertion(section = "2.3", id = "k")
})
public void testComposedConstraintsAreRecursive() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
GermanAddress address = new GermanAddress();
address.setAddressline1( "Rathausstrasse 5" );
@@ -108,7 +108,7 @@
})
public void testValidationOfMainAnnotationIsAlsoApplied() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
FrenchAddress address = getFrenchAddressWithoutZipCode();
address.setZipCode( "00000" );
Set<ConstraintViolation<FrenchAddress>> constraintViolations = validator.validate( address );
@@ -127,7 +127,7 @@
})
public void testEachFailingConstraintCreatesConstraintViolation() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
FrenchAddress address = getFrenchAddressWithoutZipCode();
address.setZipCode( "abc" );
Set<ConstraintViolation<FrenchAddress>> constraintViolations = validator.validate( address );
@@ -167,7 +167,7 @@
@SpecAssertion(section = "2.3", id = "e")
})
public void testGroupsDefinedOnMainAnnotationAreInherited() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
FrenchAddress address = getFrenchAddressWithoutZipCode();
Set<ConstraintViolation<FrenchAddress>> constraintViolations = validator.validate( address );
@@ -187,7 +187,7 @@
@Test
@SpecAssertion(section = "2.3", id = "g")
public void testOnlySingleConstraintViolation() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
GermanAddress address = new GermanAddress();
address.setAddressline1( "Rathausstrasse 5" );
@@ -209,7 +209,7 @@
@SpecAssertion(section = "2.3", id = "h")
public void testAttributesDefinedOnComposingConstraints() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor descriptor = validator.getConstraintsForClass( FrenchAddress.class );
Set<ConstraintDescriptor<?>> constraintDescriptors = descriptor.getConstraintsForProperty( "zipCode" )
.getConstraintDescriptors();
@@ -230,7 +230,7 @@
@SpecAssertion(section = "2.3", id = "o")
})
public void testOverridenAttributesMustMatchInType() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
try {
validator.validate( new DummyEntityWithZipCode( "foobar" ) );
fail( "Wrong atttibute override in composite constraint. An Exception should have been thrown." );
@@ -243,7 +243,7 @@
@Test
@SpecAssertion(section = "2.3", id = "f")
public void testAllComposingConstraintsMustBeApplicableToAnnotatedType() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
try {
validator.validate( new Shoe( 41 ) );
fail( "Shoe defines @NotEmpty on an int. Validation should have failed." );
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/nestedconstraintcomposition/NestedConstraintCompositionTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/nestedconstraintcomposition/NestedConstraintCompositionTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/nestedconstraintcomposition/NestedConstraintCompositionTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -45,7 +45,7 @@
@Test
public void testFirstConstraintAllViolationsSecondConstraintSingleViolation() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
DummyEntity1 dummy = new DummyEntity1( "" );
Set<ConstraintViolation<DummyEntity1>> constraintViolations = validator.validate( dummy );
assertCorrectNumberOfViolations( constraintViolations, 2 );
@@ -59,7 +59,7 @@
@Test
public void testFirstConstraintSingleViolationSecondConstraintSingleViolation() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
DummyEntity2 dummy = new DummyEntity2( "" );
Set<ConstraintViolation<DummyEntity2>> constraintViolations = validator.validate( dummy );
assertCorrectNumberOfViolations( constraintViolations, 1 );
@@ -69,7 +69,7 @@
@Test
public void testFirstConstraintAllViolationSecondConstraintAllViolations() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
DummyEntity3 dummy = new DummyEntity3( "" );
Set<ConstraintViolation<DummyEntity3>> constraintViolations = validator.validate( dummy );
assertCorrectNumberOfViolations( constraintViolations, 3 );
@@ -81,7 +81,7 @@
@Test
public void testFirstConstraintSingleViolationSecondConstraintAllViolations() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
DummyEntity4 dummy = new DummyEntity4( "" );
Set<ConstraintViolation<DummyEntity4>> constraintViolations = validator.validate( dummy );
assertCorrectNumberOfViolations( constraintViolations, 1 );
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/ConstraintDefinitionsTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -49,7 +49,7 @@
})
public void testConstraintWithCustomAttributes() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintDescriptor<?>> descriptors = validator.getConstraintsForClass( Person.class )
.getConstraintsForProperty( "lastName" )
.getConstraintDescriptors();
@@ -71,7 +71,7 @@
@SpecAssertion(section = "2.1.1", id = "f")
public void testDefaultGroupAssumedWhenNoGroupsSpecified() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
ConstraintDescriptor<?> descriptor = validator.getConstraintsForClass( Person.class )
.getConstraintsForProperty( "firstName" )
.getConstraintDescriptors()
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -54,7 +54,7 @@
@SpecAssertion(section = "2.4", id = "e")
})
public void testRightValidatorIsSlectedAndInializedCalled() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Shoe shoe = new Shoe();
shoe.size = -2;
final PropertyDescriptor propertyDescriptor = validator.getConstraintsForClass( Shoe.class )
@@ -81,7 +81,7 @@
@SpecAssertion(section = "2.4", id = "f")
})
public void testIsValidIsCalledForEachValidation() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Shoe shoe = new Shoe();
shoe.size = -2;
@@ -115,14 +115,14 @@
@SpecAssertion(section = "2.4", id = "i")
@Test(expectedExceptions = UnexpectedTypeException.class)
public void testUnexpectedTypeExceptionIsRaisedForInvalidType() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new OddShoe() );
}
@SpecAssertion(section = "2.4", id = "j")
@Test(expectedExceptions = ValidationException.class)
public void testRuntimeExceptionFromIsValidIsWrapped() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Shoe shoe = new Shoe();
shoe.size = -2;
BoundariesConstraintValidator.throwRuntimeExceptionFromIsValid = true;
@@ -132,14 +132,14 @@
@SpecAssertion(section = "2.4", id = "j")
@Test(expectedExceptions = ValidationException.class)
public void testRuntimeExceptionFromInitializeIsWrapped() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new Freezer() );
}
@Test
@SpecAssertion(section = "2.4", id = "l")
public void testOneConstraintViolationPerFailingConstraint() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Author author = new Author();
author.setLastName( "" );
@@ -166,7 +166,7 @@
@Test
@SpecAssertion(section = "2.4", id = "n")
public void testNonInterpolatedMessageParamterIsUsed() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Author author = new Author();
author.setLastName( "John" );
@@ -184,7 +184,7 @@
@Test
@SpecAssertion(section = "2.4", id = "o")
public void testDefaultPropertyPath() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Author author = new Author();
author.setLastName( "John" );
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -59,7 +59,7 @@
address.setStreet( "Guldmyntgatan" );
address.setCity( "Gothenborg" );
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<Address>> constraintViolations = validator.validate( address );
assertCorrectNumberOfViolations( constraintViolations, 1 );
@@ -82,7 +82,7 @@
@Test(enabled = false)
@SpecAssertion(section = "3.4.3", id = "b")
public void testConstraintsHostedOnEntityZBelongToGroupZ() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Address.class );
assertTrue( beanDescriptor.isBeanConstrained() );
@@ -106,7 +106,7 @@
Car car = new Car();
car.setType( "A" );
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
// if the group sequence would not be properly redefined there would be no error when validating default.
@@ -136,7 +136,7 @@
})
public void testGroupSequenceContainingDefault() {
Address address = new AddressWithDefaultInGroupSequence();
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
try {
validator.validate( address );
fail( "It shoud not be allowed to have Default.class in the group sequence of a class." );
@@ -153,7 +153,7 @@
})
public void testGroupSequenceWithNoImplicitDefaultGroup() {
Address address = new AddressWithNoImplicitDefaultGroupSequence();
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
try {
validator.validate( address );
fail( "A valid group sequence definiton must contain the class itself as implicit default group." );
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -55,7 +55,7 @@
@Test
@SpecAssertion(section = "3.4", id = "a")
public void testConstraintWithNoExplicitlySpecifiedGroupBelongsToDefault() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
assertTrue( beanDescriptor.isBeanConstrained() );
@@ -81,7 +81,7 @@
// all fields per default null. Depending on the validation groups there should be a different amount
// of constraint failures.
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<User>> constraintViolations = validator.validate( user );
assertEquals(
@@ -150,7 +150,7 @@
@Test
@SpecAssertion(section = "3.4", id = "c")
public void testConstraintCanBelongToMoreThanOneGroup() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
assertTrue( beanDescriptor.isBeanConstrained() );
@@ -163,7 +163,7 @@
@Test
public void testGroups() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Author author = new Author();
author.setLastName( "" );
@@ -217,7 +217,7 @@
@Test
public void testGroupSequence() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Author author = new Author();
author.setLastName( "" );
@@ -259,7 +259,7 @@
@Test
public void testGroupSequences() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Dictonary dictonary = new Dictonary();
dictonary.setTitle( "English - German" );
@@ -275,7 +275,7 @@
@Test
public void testValidationFailureInMultipleGroups() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Animal elepfant = new Animal();
elepfant.setName( "" );
elepfant.setDomain( Animal.Domain.EUKARYOTA );
@@ -297,7 +297,7 @@
user.setLastname( "Bar" );
user.setPhoneNumber( "+46 123-456" );
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<User>> constraintViolations = validator.validate(
user, User.BuyInOneClick.class, User.Optional.class
@@ -338,7 +338,7 @@
@Test
@SpecAssertion(section = "3.4.4", id = "a")
public void testImplicitGrouping() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
assertTrue( beanDescriptor.isBeanConstrained() );
@@ -360,7 +360,7 @@
@SpecAssertion(section = "8.4", id = "a")
})
public void testCyclicGroupSequence() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new Order(), CyclicGroupSequence.class );
}
}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/SequenceResolutionTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/SequenceResolutionTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/SequenceResolutionTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -50,7 +50,7 @@
@SpecAssertion(section = "8.4", id = "a")
})
public void testInvalidDefinitionOfDefaultSequenceInEntity() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
TestEntity entity = new TestEntity();
validator.validate( entity, Complete.class );
}
@@ -58,7 +58,7 @@
@Test(enabled = false)
// @SpecAssertion(section = "3.4.2", id = "j")
public void testOnlyFirstGroupInSequenceGetEvaluated() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Car car = new Car( "USd-298" );
Set<ConstraintViolation<Car>> violations = validator.validateProperty(
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequenceisolation/GroupSequenceIsolationTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequenceisolation/GroupSequenceIsolationTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequenceisolation/GroupSequenceIsolationTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -43,7 +43,7 @@
@Test
public void testCorrectDefaultSequenceInheritance() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
B1 b = new B1();
b.name = "this name is too long";
b.nickname = "and this nickname as well";
@@ -75,7 +75,7 @@
@Test
public void testCorrectDefaultSequenceInheritance2() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
B2 b = new B2();
b.name = "this name is too long";
b.nickname = "and this nickname as well";
@@ -112,7 +112,7 @@
@Test
public void testCorrectDefaultSequenceInheritance3() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
B3 b = new B3();
b.name = "this name is too long";
b.nickname = "and this nickname as well";
@@ -127,7 +127,7 @@
@Test
public void testCorrectDefaultSequenceContainedCaseWithoutGroupRedefinitionOnContainedEntity() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
C c = new C();
c.name = "this name is too long";
c.d.nickname = "and this nickname as well";
@@ -158,7 +158,7 @@
@Test
public void testCorrectDefaultSequenceContainedCaseWithGroupRedefinitionOnContainedEntity() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
E e = new E();
e.name = "this name is too long";
e.f.nickname = "and this nickname as well";
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/inheritance/GroupInheritanceTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/inheritance/GroupInheritanceTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/inheritance/GroupInheritanceTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -49,7 +49,7 @@
@Test
@SpecAssertion(section = "3.4.1", id = "a")
public void testGroupCanInheritGroupsViaInterfaceInheritance() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Part part = new Part();
part.setPartNumber( 123456 );
@@ -66,7 +66,7 @@
@Test
@SpecAssertion(section = "3.4.1", id = "b")
public void testGroupMembership() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor descriptor = validator.getConstraintsForClass( MiniaturePart.class );
// PreManufacturing belongs implicitly to All
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -44,7 +44,7 @@
@Test
@SpecAssertion(section = "3.3", id = "b")
public void testConstraintsOnSuperClassAreInherited() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Bar.class );
String propertyName = "foo";
@@ -64,7 +64,7 @@
@SpecAssertion(section = "3.3", id = "b")
})
public void testConstraintsOnInterfaceAreInherited() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Bar.class );
String propertyName = "fubar";
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -46,7 +46,7 @@
})
public void testConstraintDefinitionWithParamterStartingWithValid() {
try {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new DummyEntityValidProperty() );
fail( "The used constraint does use an invalid property name. The validation should have failed." );
}
@@ -65,7 +65,7 @@
})
public void testConstraintDefinitionWithoutMessageParameter() {
try {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new DummyEntityNoMessage() );
fail( "The used constraint does not define a message parameter. The validation should have failed." );
}
@@ -82,7 +82,7 @@
})
public void testConstraintDefinitionWithoutGroupParameter() {
try {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new DummyEntityNoGroups() );
fail( "The used constraint does not define a groups parameter. The validation should have failed." );
}
@@ -99,7 +99,7 @@
})
public void testConstraintDefinitionWithoutPayloadParameter() {
try {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new DummyEntityNoGroups() );
fail( "The used constraint does not define a payload parameter. The validation should have failed." );
}
@@ -116,7 +116,7 @@
})
public void testConstraintDefinitionWithWrongDefaultGroupValue() {
try {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new DummyEntityInvalidDefaultGroup() );
fail( "The default groups parameter is not the empty array. The validation should have failed." );
}
@@ -133,7 +133,7 @@
})
public void testConstraintDefinitionWithWrongDefaultPayloadValue() {
try {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new DummyEntityInvalidDefaultPayload() );
fail( "The default payload parameter is not the empty array. The validation should have failed." );
}
@@ -150,7 +150,7 @@
})
public void testConstraintDefinitionWithWrongPayloadClass() {
try {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new DummyEntityInvalidPayloadClass() );
fail( "The default payload parameter has to be of type Class<? extends ConstraintPayload>[]. The validation should have failed." );
}
@@ -167,7 +167,7 @@
})
public void testConstraintDefinitionWithWrongMessageType() {
try {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new DummyEntityInvalidMessageType() );
fail( "The message parameter has to be of type String. The validation should have failed." );
}
@@ -184,7 +184,7 @@
})
public void testConstraintDefinitionWithWrongGroupType() {
try {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new DummyEntityInvalidGroupsType() );
fail( "The groups parameter has to be of type Class<?>[]. The validation should have failed." );
}
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -50,7 +50,7 @@
@Test
@SpecAssertion(section = "3.5.3", id = "a")
public void testTargetTypeIsInterface() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
assertEquals(
@@ -70,8 +70,8 @@
@Test
@SpecAssertion(section = "3.5.3", id = "a")
- public void testTargetTypeIsCLass() {
- Validator validator = TestUtil.getDefaultValidator();
+ public void testTargetTypeIsClass() {
+ Validator validator = TestUtil.getValidatorUnderTest();
assertEquals(
@@ -93,7 +93,7 @@
@Test
@SpecAssertion(section = "3.5.3", id = "b")
public void testTargetedTypeIsField() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
assertEquals(
CustomConstraint.ValidatorForSubClassA.callCounter,
@@ -113,7 +113,7 @@
@Test
@SpecAssertion(section = "3.5.3", id = "c")
public void testTargetedTypeIsGetter() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
assertEquals(
CustomConstraint.ValidatorForSubClassB.callCounter,
@@ -136,7 +136,7 @@
@SpecAssertion(section = "3.5.3", id = "d")
})
public void testResolutionOfMultipleSizeValidators() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Suburb suburb = new Suburb();
@@ -216,7 +216,7 @@
@SpecAssertion(section = "3.5.3", id = "d")
})
public void testResolutionOfMinMaxForDifferentTypes() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
MinMax minMax = new MinMax( "5", 5 );
Set<ConstraintViolation<MinMax>> constraintViolations = validator.validate( minMax );
assertCorrectNumberOfViolations( constraintViolations, 2 );
@@ -230,7 +230,7 @@
@SpecAssertion(section = "2.4", id = "i")
})
public void testUnexpectedTypeInValidatorResolution() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Bar bar = new Bar();
try {
@@ -248,7 +248,7 @@
@SpecAssertion(section = "8.3", id = "b")
})
public void testAmbigiousValidatorResolution() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Foo foo = new Foo( new SerializableBarSubclass() );
try {
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -44,7 +44,7 @@
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessages;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
import static org.hibernate.jsr303.tck.util.TestUtil.getDefaultMessageInterpolator;
-import static org.hibernate.jsr303.tck.util.TestUtil.getDefaultValidator;
+import static org.hibernate.jsr303.tck.util.TestUtil.getValidatorUnderTest;
/**
* @author Hardy Ferentschik
@@ -98,7 +98,7 @@
@Test
@SpecAssertion(section = "4.3.1", id = "d")
public void testMessagesCanBeOverrridenAtConstraintLevel() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<DummyEntity>> constraintViolations = validator.validateProperty(
new DummyEntity(), "snafu"
);
@@ -107,7 +107,7 @@
}
- @Test(enabled = false)
+ @Test
@SpecAssertions({
@SpecAssertion(section = "4.3.1", id = "f"),
@SpecAssertion(section = "4.3.1", id = "g"),
@@ -219,7 +219,7 @@
}
private ConstraintDescriptor<?> getDescriptorFor(String propertyName) {
- Validator validator = getDefaultValidator();
+ Validator validator = getValidatorUnderTest();
return validator.getConstraintsForClass( DummyEntity.class )
.getConstraintsForProperty( propertyName )
.getConstraintDescriptors()
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -51,7 +51,7 @@
@SpecAssertion(section = "5.3", id = "a")
})
public void testIsBeanConstrainedDueToValidAnnotation() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
// constraint via @Valid
@@ -65,7 +65,7 @@
@SpecAssertion(section = "5.3", id = "a")
})
public void testIsBeanConstrainedDueToConstraintOnEntity() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
// constraint hosted on bean itself
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Account.class );
@@ -79,7 +79,7 @@
@SpecAssertion(section = "5.3", id = "a")
})
public void testIsBeanConstrainedDueToConstraintProperty() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
// constraint on bean property
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
@@ -93,7 +93,7 @@
@SpecAssertion(section = "5.3", id = "a")
})
public void testIsBeanConstrainedDueToConstraintOnInterface() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
// constraint on implemented interface
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Man.class );
@@ -107,7 +107,7 @@
@SpecAssertion(section = "5.3", id = "a")
})
public void testUnconstraintClass() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
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." );
@@ -119,7 +119,7 @@
@SpecAssertion(section = "5.3", id = "b")
})
public void testGetConstraintForConstrainedProperty() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderNumber" );
assertEquals(
@@ -134,7 +134,7 @@
@SpecAssertion(section = "5.4", id = "a")
})
public void testGetConstraintForUnConstrainedProperty() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList" );
assertEquals(
@@ -149,7 +149,7 @@
@SpecAssertion(section = "5.3", id = "b")
})
public void testGetConstraintsForNonExistingProperty() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
assertNull( beanDescriptor.getConstraintsForProperty( "foobar" ), "There should be no descriptor" );
}
@@ -160,7 +160,7 @@
@SpecAssertion(section = "5.3", id = "b")
})
public void testGetConstrainedProperties() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
assertEquals( constraintProperties.size(), 1, "There should be only one property" );
@@ -177,7 +177,7 @@
@SpecAssertion(section = "5.3", id = "b")
})
public void testGetConstrainedPropertiesForUnconstraintEntity() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( UnconstraintEntity.class );
Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
assertEquals( constraintProperties.size(), 0, "We should get the empty set." );
@@ -186,7 +186,7 @@
// TODO - enable or remove
@Test(enabled = false)
public void testGetConstrainedPropertiesImmutable() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
try {
@@ -209,7 +209,7 @@
// TODO - map or remove
@Test(expectedExceptions = IllegalArgumentException.class)
public void testGetConstraintsForNullProperty() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
beanDescriptor.getConstraintsForProperty( null );
}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/PropertyPathTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/PropertyPathTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/PropertyPathTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -64,7 +64,7 @@
@SpecAssertion(section = "4.2", id = "m")
})
public void testPropertyPathWithConstraintViolationForRootObject() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<VerySpecialClass>> constraintViolations = validator.validate( new VerySpecialClass() );
assertCorrectNumberOfViolations( constraintViolations, 1 );
ConstraintViolation<VerySpecialClass> constraintViolation = constraintViolations.iterator().next();
@@ -84,7 +84,7 @@
@SpecAssertion(section = "4.2", id = "l")
})
public void testPropertyPathTraversedObject() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Engine engine = new Engine();
engine.setSerialNumber( "ABCDEFGH1234" );
@@ -108,7 +108,7 @@
@SpecAssertion(section = "4.2", id = "k")
})
public void testPropertyPathWithList() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Actor clint = new ActorListBased( "Clint", "Eastwood" );
Actor morgan = new ActorListBased( "Morgan", null );
@@ -130,7 +130,7 @@
@SpecAssertion(section = "4.2", id = "k")
})
public void testPropertyPathWithArray() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Actor clint = new ActorArrayBased( "Clint", "Eastwood" );
Actor morgan = new ActorArrayBased( "Morgan", null );
@@ -152,7 +152,7 @@
@SpecAssertion(section = "4.2", id = "k")
})
public void testPropertyPathWithMap() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
ActorDB db = new ActorDB();
Actor morgan = new ActorArrayBased( "Morgan", null );
@@ -182,7 +182,7 @@
@SpecAssertion(section = "4.2", id = "k")
})
public void testPropertyPathSet() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Customer customer = new Customer();
customer.setFirstName( "John" );
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -52,7 +52,7 @@
@SpecAssertion(section = "4.1.1", id = "e")
@SuppressWarnings("NullArgumentToVariableArgMethod")
public void testPassingNullAsGroup() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Customer customer = new Customer();
try {
@@ -67,7 +67,7 @@
@Test
@SpecAssertion(section = "4.1.1", id = "e")
public void testIllegalArgumentExceptionIsThrownForNullValue() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
try {
validator.validateProperty( null, "firstName" );
fail();
@@ -83,7 +83,7 @@
@SpecAssertion(section = "4.1.1", id = "f")
})
public void testValidatePropertyWithInvalidPropertyPath() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Customer customer = new Customer();
Order order = new Order();
@@ -126,7 +126,7 @@
@Test
@SpecAssertion(section = "4.1.1", id = "e")
public void testValidatePropertyWithNullProperty() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Customer customer = new Customer();
Order order = new Order();
@@ -145,7 +145,7 @@
@Test
@SpecAssertion(section = "4.1.1", id = "e")
public void testValidatePropertyWithEmptyProperty() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Customer customer = new Customer();
Order order = new Order();
@@ -167,7 +167,7 @@
@SpecAssertion(section = "4.1.1", id = "f")
})
public void testValidateProperty() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Address address = new Address();
address.setStreet( null );
@@ -196,7 +196,7 @@
@SpecAssertion(section = "4.1.1", id = "f")
})
public void testValidatePropertyWithIndexedPath() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
ActorListBased clint = new ActorListBased( "Clint", "Eastwood" );
ActorListBased morgan = new ActorListBased( "Morgan", null );
@@ -224,7 +224,7 @@
@Test
@SpecAssertion(section = "4.1.1", id = "g")
public void testValidIsNotHonoredValidateProperty() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Customer customer = new Customer();
Order order = new Order();
@@ -237,7 +237,7 @@
@Test(expectedExceptions = ValidationException.class)
@SpecAssertion(section = "4.1.1", id = "k")
public void testUnexpectedExceptionsInValidatePropertyGetWrappedInValidationExceptions() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validateProperty( new BadlyBehavedEntity(), "value" );
}
}
\ No newline at end of file
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -65,7 +65,7 @@
public void testValidatedPropertyDoesNotFollowJavaBeansConvention() {
try {
Boy boy = new Boy();
- TestUtil.getDefaultValidator().validate( boy );
+ TestUtil.getValidatorUnderTest().validate( boy );
fail();
}
catch ( ValidationException e ) {
@@ -76,7 +76,7 @@
@Test
@SpecAssertion(section = "5.1", id = "b")
public void testConstraintDescriptorWithoutExplicitGroup() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderNumber" );
@@ -96,13 +96,13 @@
@Test(expectedExceptions = IllegalArgumentException.class)
@SpecAssertion(section = "5.1", id = "c")
public void testNullParamterToGetConstraintsForClass() {
- TestUtil.getDefaultValidator().getConstraintsForClass( null );
+ TestUtil.getValidatorUnderTest().getConstraintsForClass( null );
}
@Test(expectedExceptions = IllegalArgumentException.class)
@SpecAssertion(section = "4.1.1", id = "b")
public void testValidateWithNullValue() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( null );
}
@@ -110,7 +110,7 @@
@SpecAssertion(section = "4.1.1", id = "b")
@SuppressWarnings("NullArgumentToVariableArgMethod")
public void testValidateWithNullGroup() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new Boy(), null );
}
@@ -121,7 +121,7 @@
})
public void testMultipleViolationOfTheSameType() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Engine engine = new Engine();
engine.setSerialNumber( "mail(a)foobar.com" );
@@ -140,7 +140,7 @@
@Test
@SpecAssertion(section = "4.1.1", id = "c")
public void testMultipleConstraintViolationOfDifferentTypes() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Address address = new Address();
address.setStreet( null );
@@ -162,7 +162,7 @@
@SpecAssertion(section = "4.2", id = "e")
})
public void testConstraintViolation() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Engine engine = new Engine();
engine.setSerialNumber( "ABCDEFGH1234" );
@@ -191,7 +191,7 @@
@SpecAssertion(section = "2.4", id = "o")
})
public void testGraphValidationWithList() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Actor clint = new ActorListBased( "Clint", "Eastwood" );
Actor morgan = new ActorListBased( "Morgan", null );
@@ -225,7 +225,7 @@
@SpecAssertion(section = "3.1.3", id = "c")
})
public void testGraphValidationWithArray() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Actor clint = new ActorArrayBased( "Clint", "Eastwood" );
Actor morgan = new ActorArrayBased( "Morgan", null );
@@ -255,7 +255,7 @@
@SpecAssertion(section = "4.1.1", id = "b")
@SuppressWarnings("NullArgumentToVariableArgMethod")
public void testPassingNullAsGroup() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Customer customer = new Customer();
try {
validator.validate( customer, null );
@@ -268,7 +268,7 @@
@Test
@SpecAssertion(section = "3.5", id = "b")
public void testOnlyFirstGroupInSequenceGetEvaluated() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Car car = new Car( "USd-298" );
Set<ConstraintViolation<Car>> violations = validator.validateProperty(
@@ -286,14 +286,14 @@
@Test(expectedExceptions = ValidationException.class)
@SpecAssertion(section = "4.1.1", id = "k")
public void testUnexpectedExceptionsInValidateGetWrappedInValidationExceptions() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new BadlyBehavedEntity() );
}
// TODO - map or remove
@Test
public void testValidationIsPolymorphic() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Customer customer = new Customer();
customer.setFirstName( "Foo" );
@@ -321,7 +321,7 @@
// TODO - map or remove
@Test
public void testObjectTraversion() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Customer customer = new Customer();
customer.setFirstName( "John" );
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateValueTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -48,7 +48,7 @@
@Test
@SpecAssertion(section = "4.1.1", id = "h")
public void testValidateValueSuccess() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<Address>> constraintViolations = validator.validateValue(
Address.class, "city", "Paris"
@@ -59,7 +59,7 @@
@Test
@SpecAssertion(section = "4.1.1", id = "h")
public void testValidateValueFailure() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<Address>> constraintViolations = validator.validateValue(
Address.class, "city", null
@@ -71,7 +71,7 @@
@Test
@SpecAssertion(section = "4.1.1", id = "h")
public void testValidateValue() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<Customer>> constraintViolations = validator.validateValue(
Customer.class, "orders[0].orderNumber", null
@@ -91,7 +91,7 @@
@Test
@SpecAssertion(section = "4.1.1", id = "i")
public void testValidateValueWithInvalidPropertyPath() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
try {
validator.validateValue( Customer.class, "foobar", null );
@@ -123,7 +123,7 @@
@SuppressWarnings("NullArgumentToVariableArgMethod")
@SpecAssertion(section = "4.1.1", id = "i")
public void testValidateValuePassingNullAsGroup() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
try {
validator.validateValue( Customer.class, "firstName", "foobar", null );
@@ -137,7 +137,7 @@
@Test
@SpecAssertion(section = "4.1.1", id = "i")
public void testValidateValueWithEmptyPropertyPath() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
try {
validator.validateValue( Customer.class, "", null );
@@ -151,7 +151,7 @@
@Test
@SpecAssertion(section = "4.1.1", id = "i")
public void testValidateValueWithNullObject() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
try {
validator.validateValue( null, "firstName", "foobar" );
fail();
@@ -164,7 +164,7 @@
@Test
@SpecAssertion(section = "4.1.1", id = "i")
public void testValidateValueWithNullPropertyName() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
try {
validator.validateValue( Customer.class, null, "foobar" );
fail();
@@ -177,7 +177,7 @@
@Test
@SpecAssertion(section = "4.1.1", id = "j")
public void testValidIsNotHonoredValidateValue() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Customer customer = new Customer();
Order order = new Order();
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateWithGroupsTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateWithGroupsTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateWithGroupsTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -51,7 +51,7 @@
@SpecAssertion(section = "4.1.2", id = "b")
})
public void testCorrectGroupsAreAppliedForValidate() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<Address>> constraintViolations = validator.validate( new Address() );
assertCorrectNumberOfViolations( constraintViolations, 2 );
@@ -80,7 +80,7 @@
@SpecAssertion(section = "4.1.2", id = "b")
})
public void testCorrectGroupsAreAppliedForValidateProperty() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<Address>> constraintViolations = validator.validateProperty( new Address(), "city" );
assertCorrectNumberOfViolations( constraintViolations, 1 );
@@ -107,7 +107,7 @@
@SpecAssertion(section = "4.1.2", id = "b")
})
public void testCorrectGroupsAreAppliedForValidateValue() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<Address>> constraintViolations = validator.validateValue( Address.class, "city", null );
assertCorrectNumberOfViolations( constraintViolations, 1 );
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -73,7 +73,7 @@
order.addOrderLine( line1 );
order.addOrderLine( line2 );
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<Order>> constraintViolations = validator.validate( order );
assertCorrectNumberOfViolations( constraintViolations, 3 );
@@ -94,7 +94,7 @@
User john = new User( "John", null );
john.knows( john );
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<User>> constraintViolations = validator.validate( john );
assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
@@ -132,7 +132,7 @@
elephant.setWeight( 500 );
cage.setContainAnimal( elephant );
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<SingleCage>> constraintViolations = validator.validate( cage );
assertCorrectNumberOfViolations( constraintViolations, 1 );
assertCorrectConstraintViolationMessages( constraintViolations, "An elephant weighs at least 1000 kg" );
@@ -145,7 +145,7 @@
cage.addAnimal( new Zebra( null ) );
cage.addAnimal( new Zebra( null ) );
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<MultiCage>> constraintViolations = validator.validate( cage );
assertCorrectNumberOfViolations( constraintViolations, 2 );
assertCorrectConstraintViolationMessages( constraintViolations, "may not be null", "may not be null" );
@@ -160,7 +160,7 @@
zebraHerd.addAnimal( new Zebra( null ) );
reserve.setHerd( zebraHerd );
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<GameReserve<Zebra>>> constraintViolations = validator.validate( reserve );
assertCorrectNumberOfViolations( constraintViolations, 2 );
assertCorrectConstraintViolationMessages( constraintViolations, "may not be null", "may not be null" );
@@ -181,7 +181,7 @@
condor.setWingspan( 200 );
zoo.addAnimal( condor );
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<Zoo>> constraintViolations = validator.validate( zoo );
assertCorrectNumberOfViolations( constraintViolations, 2 );
assertCorrectConstraintViolationMessages(
@@ -207,7 +207,7 @@
condor.setWingspan( 200 );
caretaker.addAnimal( "Andes", condor );
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<AnimalCaretaker>> constraintViolations = validator.validate( caretaker );
assertCorrectNumberOfViolations( constraintViolations, 2 );
assertCorrectPropertyPaths(
@@ -225,7 +225,7 @@
public void testFullGraphValidationBeforeNextGroupInSequence() {
Parent p = new Parent();
p.setChild( new Child() );
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<Parent>> errors = validator.validate( p, Parent.ProperOrder.class );
assertCorrectNumberOfViolations( errors, 1 );
assertCorrectPropertyPaths( errors, "child.name" );
@@ -235,7 +235,7 @@
@SpecAssertion(section = "3.5.1", id = "c")
public void testNullReferencesGetIgnored() {
Parent p = new Parent();
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
Set<ConstraintViolation<Parent>> errors = validator.validateProperty( p, "child" );
assertCorrectNumberOfViolations( errors, 0 );
}
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -47,7 +47,7 @@
@Test
public void testNoCustomization() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
DummyValidator.disableDefaultError( false );
DummyValidator.setErrorMessages( null );
@@ -64,7 +64,7 @@
*/
@Test
public void testDisableDefaultErrorWithoutCustomError() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
DummyValidator.disableDefaultError( true );
Map<String, String> errors = new HashMap<String, String>();
@@ -78,7 +78,7 @@
@Test
public void testDisableDefaultErrorWithCustomErrors() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
DummyValidator.disableDefaultError( true );
Map<String, String> errors = new HashMap<String, String>();
@@ -95,7 +95,7 @@
@Test
public void testNestedValidation() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
DummyValidator.disableDefaultError( false );
DummyValidator.setErrorMessages( null );
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -44,7 +44,7 @@
@SpecAssertion(section = "2.5", id = "a")
@Test
public void testDefaultConstructorInValidatorCalled() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new Dummy() );
assertTrue(
MyConstraintValidator.defaultConstructorCalled,
@@ -55,7 +55,7 @@
@SpecAssertion(section = "2.5", id = "b")
@Test(expectedExceptions = ValidationException.class)
public void testRuntimeExceptionInValidatorCreationIsWrapped() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
validator.validate( new SecondDummy() );
}
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/EmptyXmlConfigurationTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -43,7 +43,7 @@
@Test
public void testNoDefinedConstraints() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
assertFalse(
validator.getConstraintsForClass( Order.class ).isBeanConstrained(), "Bean should be unsonstrained"
);
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/InvalidXmlConfigurationTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -43,7 +43,7 @@
@SpecAssertion(section = "7", id = "a")
public void testInvalidValidationXml() {
try {
- TestUtil.getDefaultValidator();
+ TestUtil.getValidatorUnderTest();
fail();
}
catch ( ValidationException e ) {
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleBeanDefinitionTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleBeanDefinitionTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleBeanDefinitionTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -57,7 +57,7 @@
})
public void testBeanCannotBeDescribedMoreThanOnce() {
try {
- TestUtil.getDefaultValidator();
+ TestUtil.getValidatorUnderTest();
fail();
}
catch ( ValidationException e ) {
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleFieldDefinitionTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleFieldDefinitionTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleFieldDefinitionTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -51,7 +51,7 @@
})
public void testFieldMappingCanotOccurMoreThanOnce() {
try {
- TestUtil.getDefaultValidator();
+ TestUtil.getValidatorUnderTest();
fail();
}
catch ( ValidationException e ) {
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleGetterDefinitionTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleGetterDefinitionTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleGetterDefinitionTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -51,7 +51,7 @@
})
public void testGetterMappingCanotOccurMoreThanOnce() {
try {
- TestUtil.getDefaultValidator();
+ TestUtil.getValidatorUnderTest();
fail();
}
catch ( ValidationException e ) {
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -52,7 +52,7 @@
@Test
public void testClassConstraintDefinedInXml() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
User user = new User();
Set<ConstraintViolation<User>> constraintViolations = validator.validate( user );
@@ -68,7 +68,7 @@
@Test
public void testPropertyConstraintDefinedInXml() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
User user = new User();
user.setConsistent( true );
@@ -85,7 +85,7 @@
@Test
public void testFieldConstraintDefinedInXml() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
User user = new User();
user.setConsistent( true );
@@ -105,7 +105,7 @@
@Test
public void testAnnotationDefinedConstraintApplies() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
User user = new User();
user.setConsistent( true );
@@ -124,7 +124,7 @@
@Test
public void testCascadingConfiguredInXml() {
- Validator validator = TestUtil.getDefaultValidator();
+ Validator validator = TestUtil.getValidatorUnderTest();
User user = new User();
user.setConsistent( true );
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/GroupIsNotAllowedAsElementNameTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/GroupIsNotAllowedAsElementNameTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/GroupIsNotAllowedAsElementNameTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -46,7 +46,7 @@
@SpecAssertion(section = "7.1.1.4", id = "b")
public void testGroupIsNotAllowedAsElementName() {
try {
- TestUtil.getDefaultValidator();
+ TestUtil.getValidatorUnderTest();
fail();
}
catch ( ValidationException e ) {
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MandatoryNameAttributeTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MandatoryNameAttributeTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MandatoryNameAttributeTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -46,7 +46,7 @@
@SpecAssertion(section = "7.1.1.4", id = "a")
public void testNameAttributeIsMandatory() {
try {
- TestUtil.getDefaultValidator();
+ TestUtil.getValidatorUnderTest();
fail();
}
catch ( ValidationException e ) {
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MessageIsNotAllowedAsElementNameTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MessageIsNotAllowedAsElementNameTest.java 2009-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MessageIsNotAllowedAsElementNameTest.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -46,7 +46,7 @@
@SpecAssertion(section = "7.1.1.4", id = "b")
public void testMessageIsNotAllowedAsElementName() {
try {
- TestUtil.getDefaultValidator();
+ TestUtil.getValidatorUnderTest();
fail();
}
catch ( ValidationException e ) {
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-07-27 10:23:54 UTC (rev 17204)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-07-27 15:09:52 UTC (rev 17205)
@@ -31,9 +31,11 @@
import javax.validation.Path;
import javax.validation.Validation;
import javax.validation.Validator;
+import javax.validation.bootstrap.ProviderSpecificBootstrap;
import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.metadata.ElementDescriptor;
import javax.validation.metadata.PropertyDescriptor;
+import javax.validation.spi.ValidationProvider;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@@ -44,9 +46,23 @@
*/
public final class TestUtil {
+ private static String VALIDIDATION_PROVIDER_TEST_CLASS = "validation.provider";
+
+ private static ValidationProvider<?> validationProviderUnderTest;
+
private TestUtil() {
}
+ public static Validator getValidatorUnderTest() {
+ if(validationProviderUnderTest == null) {
+ instantiateValidationProviderUnderTest();
+ }
+
+ ProviderSpecificBootstrap<?> bootstrap = Validation.byProvider( validationProviderUnderTest.getClass() );
+ Configuration<?> config = bootstrap.configure();
+ return config.buildValidatorFactory().getValidator();
+ }
+
public static Validator getDefaultValidator() {
return Validation.buildDefaultValidatorFactory().getValidator();
}
@@ -116,7 +132,8 @@
assertEquals(
propertyPaths.length,
propertyPathsOfViolations.size(),
- "Wrong number of property paths. Expected: " + propertyPaths.length + " Actual: " + propertyPathsOfViolations.size()
+ "Wrong number of property paths. Expected: " + propertyPaths.length + " Actual: " + propertyPathsOfViolations
+ .size()
);
for ( String propertyPath : propertyPaths ) {
@@ -200,7 +217,7 @@
}
public static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String property) {
- Validator validator = getDefaultValidator();
+ Validator validator = getValidatorUnderTest();
return validator.getConstraintsForClass( clazz ).getConstraintsForProperty( property );
}
@@ -220,6 +237,33 @@
return inputStream;
}
+
+ private static <U extends ValidationProvider<?>> void instantiateValidationProviderUnderTest() {
+ String validatorproviderClassName = System.getProperty( VALIDIDATION_PROVIDER_TEST_CLASS );
+ if ( validatorproviderClassName == null ) {
+ throw new RuntimeException(
+ "The test harness must specify the class name of the validation provider under test. Set system property '" + VALIDIDATION_PROVIDER_TEST_CLASS + "'"
+ );
+ }
+
+ Class<U> providerClass;
+ try {
+ @SuppressWarnings("unchecked")
+ Class<U> tmpClazz = ( Class<U> ) TestUtil.class.getClassLoader().loadClass( validatorproviderClassName );
+ providerClass = tmpClazz;
+ }
+ catch ( ClassNotFoundException e ) {
+ throw new RuntimeException( "Unable to load " + validatorproviderClassName );
+ }
+
+ try {
+ validationProviderUnderTest = providerClass.newInstance();
+ }
+ catch ( Exception e ) {
+ throw new RuntimeException( "Unable to instantiate " + validatorproviderClassName );
+ }
+ }
+
public static class PathImpl implements Path {
/**
15 years, 4 months
Hibernate SVN: r17204 - in search/trunk/src: main/java/org/hibernate/search/backend/impl/lucene and 4 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-27 06:23:54 -0400 (Mon, 27 Jul 2009)
New Revision: 17204
Modified:
search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/BatchBackend.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/DirectoryProviderWorkspace.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/LuceneBatchBackend.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDirectoryWorkProcessor.java
search/trunk/src/main/java/org/hibernate/search/batchindexing/BatchCoordinator.java
search/trunk/src/main/java/org/hibernate/search/filter/FullTextFilterImplementor.java
search/trunk/src/main/java/org/hibernate/search/filter/ShardSensitiveOnlyFilter.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/EquipmentType.java
search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategy.java
search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategyTest.java
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
Log:
Applied svn:keywords
Formatting
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/BatchBackend.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/BatchBackend.java 2009-07-27 10:22:32 UTC (rev 17203)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/BatchBackend.java 2009-07-27 10:23:54 UTC (rev 17204)
@@ -1,3 +1,4 @@
+//$Id$
package org.hibernate.search.backend.impl.batchlucene;
import java.util.Properties;
Property changes on: search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/BatchBackend.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/DirectoryProviderWorkspace.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/DirectoryProviderWorkspace.java 2009-07-27 10:22:32 UTC (rev 17203)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/DirectoryProviderWorkspace.java 2009-07-27 10:23:54 UTC (rev 17204)
@@ -1,3 +1,4 @@
+//$Id$
package org.hibernate.search.backend.impl.batchlucene;
import java.util.concurrent.ExecutorService;
Property changes on: search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/DirectoryProviderWorkspace.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/LuceneBatchBackend.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/LuceneBatchBackend.java 2009-07-27 10:22:32 UTC (rev 17203)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/LuceneBatchBackend.java 2009-07-27 10:23:54 UTC (rev 17204)
@@ -1,3 +1,4 @@
+//$Id$
package org.hibernate.search.backend.impl.batchlucene;
import java.util.HashMap;
Property changes on: search/trunk/src/main/java/org/hibernate/search/backend/impl/batchlucene/LuceneBatchBackend.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDirectoryWorkProcessor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDirectoryWorkProcessor.java 2009-07-27 10:22:32 UTC (rev 17203)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDirectoryWorkProcessor.java 2009-07-27 10:23:54 UTC (rev 17204)
@@ -1,3 +1,4 @@
+//$Id$
package org.hibernate.search.backend.impl.lucene;
import org.hibernate.search.backend.LuceneWork;
Property changes on: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDirectoryWorkProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: search/trunk/src/main/java/org/hibernate/search/batchindexing/BatchCoordinator.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/batchindexing/BatchCoordinator.java 2009-07-27 10:22:32 UTC (rev 17203)
+++ search/trunk/src/main/java/org/hibernate/search/batchindexing/BatchCoordinator.java 2009-07-27 10:23:54 UTC (rev 17204)
@@ -1,3 +1,4 @@
+//$Id$
package org.hibernate.search.batchindexing;
import java.util.Set;
Property changes on: search/trunk/src/main/java/org/hibernate/search/batchindexing/BatchCoordinator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: search/trunk/src/main/java/org/hibernate/search/filter/FullTextFilterImplementor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/filter/FullTextFilterImplementor.java 2009-07-27 10:22:32 UTC (rev 17203)
+++ search/trunk/src/main/java/org/hibernate/search/filter/FullTextFilterImplementor.java 2009-07-27 10:23:54 UTC (rev 17204)
@@ -1,3 +1,4 @@
+//$Id$
package org.hibernate.search.filter;
import org.hibernate.search.FullTextFilter;
@@ -7,7 +8,7 @@
*/
public interface FullTextFilterImplementor extends FullTextFilter {
/**
- * Returns the Filter name
+ * @return Returns the Filter name
*/
String getName();
Property changes on: search/trunk/src/main/java/org/hibernate/search/filter/FullTextFilterImplementor.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: search/trunk/src/main/java/org/hibernate/search/filter/ShardSensitiveOnlyFilter.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/filter/ShardSensitiveOnlyFilter.java 2009-07-27 10:22:32 UTC (rev 17203)
+++ search/trunk/src/main/java/org/hibernate/search/filter/ShardSensitiveOnlyFilter.java 2009-07-27 10:23:54 UTC (rev 17204)
@@ -1,3 +1,4 @@
+//$Id$
package org.hibernate.search.filter;
/**
Property changes on: search/trunk/src/main/java/org/hibernate/search/filter/ShardSensitiveOnlyFilter.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/EquipmentType.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/EquipmentType.java 2009-07-27 10:22:32 UTC (rev 17203)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/EquipmentType.java 2009-07-27 10:23:54 UTC (rev 17204)
@@ -5,6 +5,7 @@
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+
import org.hibernate.search.bridge.FieldBridge;
import org.hibernate.search.bridge.LuceneOptions;
import org.hibernate.search.bridge.ParameterizedBridge;
@@ -26,18 +27,17 @@
// from the name field of the ClassBridge Annotation. This is not
// a requirement. It just works that way in this instance. The
// actual name could be supplied by hard coding it below.
- Departments deps = (Departments) value;
- Field field = null;
+ Departments deps = ( Departments ) value;
+ Field field;
String fieldValue1 = deps.getManufacturer();
- if ( fieldValue1 == null ) {
- fieldValue1 = "";
- }
- else {
- String fieldValue = (String) equips.get( fieldValue1 );
- field = new Field( name, fieldValue, luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector() );
+ if ( fieldValue1 != null ) {
+ String fieldValue = ( String ) equips.get( fieldValue1 );
+ field = new Field(
+ name, fieldValue, luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector()
+ );
field.setBoost( luceneOptions.getBoost() );
+ document.add( field );
}
- document.add( field );
}
}
Modified: search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategy.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategy.java 2009-07-27 10:22:32 UTC (rev 17203)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategy.java 2009-07-27 10:23:54 UTC (rev 17204)
@@ -1,3 +1,4 @@
+//$Id$
package org.hibernate.search.test.shards;
import java.io.Serializable;
Property changes on: search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategy.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategyTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategyTest.java 2009-07-27 10:22:32 UTC (rev 17203)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategyTest.java 2009-07-27 10:23:54 UTC (rev 17204)
@@ -1,3 +1,4 @@
+//$Id$
package org.hibernate.search.test.shards;
import junit.framework.TestCase;
Property changes on: search/trunk/src/test/java/org/hibernate/search/test/shards/CustomerShardingStrategyTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: search/trunk/src/test/java/org/hibernate/search/test/shards/DirectoryProviderForQueryTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/DirectoryProviderForQueryTest.java 2009-07-27 10:22:32 UTC (rev 17203)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/DirectoryProviderForQueryTest.java 2009-07-27 10:23:54 UTC (rev 17204)
@@ -1,27 +1,22 @@
-// $Id: ShardsTest.java 16210 2009-03-25 10:07:47Z hardy.ferentschik $
+// $Id$
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.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.queryParser.QueryParser;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
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;
+import org.hibernate.search.store.FSDirectoryProvider;
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.util.FileHelper;
/**
* @author Chase Seibert
Property changes on: search/trunk/src/test/java/org/hibernate/search/test/shards/DirectoryProviderForQueryTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
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-07-27 10:22:32 UTC (rev 17203)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/Email.java 2009-07-27 10:23:54 UTC (rev 17204)
@@ -1,3 +1,4 @@
+//$Id$
package org.hibernate.search.test.shards;
import javax.persistence.Entity;
@@ -6,7 +7,6 @@
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;
Property changes on: search/trunk/src/test/java/org/hibernate/search/test/shards/Email.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: search/trunk/src/test/java/org/hibernate/search/test/shards/SpecificShardingStrategy.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/shards/SpecificShardingStrategy.java 2009-07-27 10:22:32 UTC (rev 17203)
+++ search/trunk/src/test/java/org/hibernate/search/test/shards/SpecificShardingStrategy.java 2009-07-27 10:23:54 UTC (rev 17204)
@@ -1,9 +1,6 @@
+//$Id$
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;
Property changes on: search/trunk/src/test/java/org/hibernate/search/test/shards/SpecificShardingStrategy.java
___________________________________________________________________
Name: svn:keywords
+ Id
15 years, 4 months
Hibernate SVN: r17203 - search/trunk.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-27 06:22:32 -0400 (Mon, 27 Jul 2009)
New Revision: 17203
Modified:
search/trunk/pom.xml
Log:
Moved the properties more to the top.
Changed the JPA dep.
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2009-07-27 10:21:41 UTC (rev 17202)
+++ search/trunk/pom.xml 2009-07-27 10:22:32 UTC (rev 17203)
@@ -50,6 +50,12 @@
</contributor>
</contributors>
+ <properties>
+ <slf4jVersion>1.5.6</slf4jVersion>
+ <luceneVersion>2.4.1</luceneVersion>
+ <hibernateVersion>3.5.0-SNAPSHOT</hibernateVersion>
+ </properties>
+
<dependencies>
<!-- =============================== -->
<!-- Required Dependencies -->
@@ -72,7 +78,7 @@
<dependency>
<groupId>org.hibernate.java-persistence</groupId>
<artifactId>jpa-api</artifactId>
- <version>2.0.Beta2</version>
+ <version>2.0.Beta-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
@@ -132,7 +138,7 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
+ <artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
@@ -181,7 +187,7 @@
<masterTranslation>en-US</masterTranslation>
<translations>
<translation>zh-CN</translation>
- </translations>
+ </translations>
<imageResource>
<directory>${basedir}/src/main/docbook/en-US/images</directory>
</imageResource>
@@ -279,7 +285,7 @@
</testResource>
</testResources>
</build>
-
+
<distributionManagement>
<repository>
<!-- Copy the dist to the local checkout of the JBoss maven2 repo ${maven.repository.root} -->
@@ -293,7 +299,7 @@
<name>JBoss Snapshot Repository</name>
<url>dav:https://snapshots.jboss.org/maven2</url>
</snapshotRepository>
- </distributionManagement>
+ </distributionManagement>
<profiles>
<!-- =============================== -->
@@ -369,7 +375,8 @@
<properties>
<db.dialect>org.hibernate.dialect.SQLServerDialect</db.dialect>
<jdbc.driver>net.sourceforge.jtds.jdbc.Driver</jdbc.driver>
- <jdbc.url>jdbc:jtds:sqlserver://ec2-67-202-7-25.compute-1.amazonaws.com:1433;DatabaseName=hibernate</jdbc.url>
+ <jdbc.url>jdbc:jtds:sqlserver://ec2-67-202-7-25.compute-1.amazonaws.com:1433;DatabaseName=hibernate
+ </jdbc.url>
<jdbc.user>hibernate</jdbc.user>
<jdbc.pass>hibernate</jdbc.pass>
<jdbc.isolation/>
@@ -400,7 +407,7 @@
<jdbc.url>jdbc:mysql://dev02.qa.atl.jboss.com/hibbrtru</jdbc.url>
<jdbc.user>hibbrtru</jdbc.user>
<jdbc.pass>hibbrtru</jdbc.pass>
- <jdbc.isolation />
+ <jdbc.isolation/>
</properties>
</profile>
@@ -421,7 +428,7 @@
<jdbc.url>jdbc:postgresql://dev01.qa.atl.jboss.com:5432:hibbrtru</jdbc.url>
<jdbc.user>hibbrtru</jdbc.user>
<jdbc.pass>hibbrtru</jdbc.pass>
- <jdbc.isolation />
+ <jdbc.isolation/>
</properties>
</profile>
@@ -452,7 +459,7 @@
<jdbc.url>jdbc:db2://dev32.qa.atl.jboss.com:50000/jbossqa</jdbc.url>
<jdbc.user>hibbrtru</jdbc.user>
<jdbc.pass>hibbrtru</jdbc.pass>
- <jdbc.isolation />
+ <jdbc.isolation/>
</properties>
</profile>
@@ -477,7 +484,7 @@
<jdbc.url>jdbc:db2://dev67.qa.atl.jboss.com:50000/jbossqa</jdbc.url>
<jdbc.user>hibbrtru</jdbc.user>
<jdbc.pass>hibbrtru</jdbc.pass>
- <jdbc.isolation />
+ <jdbc.isolation/>
</properties>
</profile>
@@ -498,7 +505,7 @@
<jdbc.url>jdbc:oracle:thin:@dev20.qa.atl.jboss.com:1521:qa</jdbc.url>
<jdbc.user>hibbrtru</jdbc.user>
<jdbc.pass>hibbrtru</jdbc.pass>
- <jdbc.isolation />
+ <jdbc.isolation/>
</properties>
</profile>
@@ -519,7 +526,7 @@
<jdbc.url>jdbc:oracle:thin:@dev01.qa.atl.jboss.com:1521:qadb01</jdbc.url>
<jdbc.user>hibbrtru</jdbc.user>
<jdbc.pass>hibbrtru</jdbc.pass>
- <jdbc.isolation />
+ <jdbc.isolation/>
</properties>
</profile>
@@ -539,7 +546,7 @@
<jdbc.url>jdbc:sybase:Tds:dev77.qa.atl2.redhat.com:5000/hibbrtru</jdbc.url>
<jdbc.user>hibbrtru</jdbc.user>
<jdbc.pass>hibbrtru</jdbc.pass>
- <jdbc.isolation />
+ <jdbc.isolation/>
</properties>
</profile>
@@ -621,8 +628,8 @@
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
- <groupId>org.apache.solr</groupId>
- <artifactId>solr-lucene-core</artifactId>
+ <groupId>org.apache.solr</groupId>
+ <artifactId>solr-lucene-core</artifactId>
</exclusion>
</exclusions>
</dependency>
@@ -710,11 +717,4 @@
</build>
</profile>
</profiles>
-
- <properties>
- <slf4jVersion>1.5.6</slf4jVersion>
- <luceneVersion>2.4.1</luceneVersion>
- <hibernateVersion>3.5.0-SNAPSHOT</hibernateVersion>
- </properties>
-
</project>
15 years, 4 months
Hibernate SVN: r17202 - in search/trunk/src: main/java/org/hibernate/search/bridge/builtin and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-27 06:21:41 -0400 (Mon, 27 Jul 2009)
New Revision: 17202
Added:
search/trunk/src/main/java/org/hibernate/search/bridge/builtin/CharacterBridge.java
Modified:
search/trunk/src/main/java/org/hibernate/search/bridge/BridgeFactory.java
search/trunk/src/main/java/org/hibernate/search/bridge/FieldBridge.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/BridgeTest.java
search/trunk/src/test/java/org/hibernate/search/test/bridge/Cloud.java
Log:
HSEARCH-334
Applied Davide's patch
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/BridgeFactory.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/BridgeFactory.java 2009-07-25 05:24:55 UTC (rev 17201)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/BridgeFactory.java 2009-07-27 10:21:41 UTC (rev 17202)
@@ -22,6 +22,7 @@
import org.hibernate.search.bridge.builtin.BigDecimalBridge;
import org.hibernate.search.bridge.builtin.BigIntegerBridge;
import org.hibernate.search.bridge.builtin.BooleanBridge;
+import org.hibernate.search.bridge.builtin.CharacterBridge;
import org.hibernate.search.bridge.builtin.DateBridge;
import org.hibernate.search.bridge.builtin.DoubleBridge;
import org.hibernate.search.bridge.builtin.EnumBridge;
@@ -45,6 +46,8 @@
private BridgeFactory() {
}
+ public static final TwoWayFieldBridge CHARACTER = new TwoWayString2FieldBridgeAdaptor( new CharacterBridge() );
+
public static final TwoWayFieldBridge DOUBLE = new TwoWayString2FieldBridgeAdaptor( new DoubleBridge() );
public static final TwoWayFieldBridge FLOAT = new TwoWayString2FieldBridgeAdaptor( new FloatBridge() );
@@ -79,6 +82,8 @@
new TwoWayString2FieldBridgeAdaptor( DateBridge.DATE_MILLISECOND );
static {
+ builtInBridges.put( Character.class.getName(), CHARACTER );
+ builtInBridges.put( char.class.getName(), CHARACTER );
builtInBridges.put( Double.class.getName(), DOUBLE );
builtInBridges.put( double.class.getName(), DOUBLE );
builtInBridges.put( Float.class.getName(), FLOAT );
Modified: search/trunk/src/main/java/org/hibernate/search/bridge/FieldBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/FieldBridge.java 2009-07-25 05:24:55 UTC (rev 17201)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/FieldBridge.java 2009-07-27 10:21:41 UTC (rev 17202)
@@ -6,7 +6,7 @@
/**
* Link between a java property and a Lucene Document
* Usually a Java property will be linked to a Document Field.
- *
+ * <p/>
* All implementations need to be threadsafe.
*
* @author Emmanuel Bernard
@@ -15,11 +15,15 @@
/**
* Manipulate the document to index the given value.
- * A common implementation is to add a Field <code>name</code> to the given document following
- * the parameters (<code>store</code>, <code>index</code>, <code>boost</code>) if the
- * <code>value</code> is not null
- * @param luceneOptions Contains the parameters used for adding <code>value</code> to
- * the Lucene <code>document</code>.
+ * <p/>
+ * A common implementation is to add a Field with the given {@code name} to {@code document} following
+ * the parameters {@code luceneOptions} if the {@code value} is not {@code null}.
+ *
+ * @param name The field to add to the Lucene document
+ * @param value The actual value to index
+ * @param document The Lucene document into which we want to index the value.
+ * @param luceneOptions Contains the parameters used for adding {@code value} to
+ * the Lucene document.
*/
void set(String name, Object value, Document document, LuceneOptions luceneOptions);
}
Added: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/CharacterBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/bridge/builtin/CharacterBridge.java (rev 0)
+++ search/trunk/src/main/java/org/hibernate/search/bridge/builtin/CharacterBridge.java 2009-07-27 10:21:41 UTC (rev 17202)
@@ -0,0 +1,28 @@
+// $Id:$
+package org.hibernate.search.bridge.builtin;
+
+import org.hibernate.util.StringHelper;
+
+/**
+ * Map a character element
+ *
+ * @author Davide D'Alto
+ */
+public class CharacterBridge implements org.hibernate.search.bridge.TwoWayStringBridge {
+
+ public Object stringToObject(String stringValue) {
+ if ( StringHelper.isEmpty( stringValue ) ) {
+ return null;
+ }
+ if ( stringValue.length() > 1 ) {
+ throw new IllegalArgumentException( "<" + stringValue + "> is not a char" );
+ }
+ return stringValue.charAt( 0 );
+ }
+
+ public String objectToString(Object object) {
+ return object == null
+ ? null
+ : object.toString();
+ }
+}
Property changes on: search/trunk/src/main/java/org/hibernate/search/bridge/builtin/CharacterBridge.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/BridgeTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/BridgeTest.java 2009-07-25 05:24:55 UTC (rev 17201)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/BridgeTest.java 2009-07-27 10:21:41 UTC (rev 17202)
@@ -1,179 +1,198 @@
//$Id$
package org.hibernate.search.test.bridge;
+import java.net.URI;
+import java.net.URL;
+import java.util.Calendar;
import java.util.Date;
+import java.util.GregorianCalendar;
import java.util.List;
-import java.util.GregorianCalendar;
-import java.util.Calendar;
import java.util.TimeZone;
-import java.net.URI;
-import java.net.URL;
+import org.apache.lucene.analysis.SimpleAnalyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
-
-import org.hibernate.search.test.SearchTestCase;
import org.hibernate.search.Environment;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.analysis.SimpleAnalyzer;
-import org.apache.lucene.index.Term;
+import org.hibernate.search.test.SearchTestCase;
/**
* @author Emmanuel Bernard
*/
public class BridgeTest extends SearchTestCase {
- public void testDefaultAndNullBridges() throws Exception {
- Cloud cloud = new Cloud();
- cloud.setMyDate( null );
- cloud.setDouble1( null );
- cloud.setDouble2( 2.1d );
- cloud.setIntegerv1( null );
- cloud.setIntegerv2( 2 );
- cloud.setFloat1( null );
- cloud.setFloat2( 2.1f );
- cloud.setLong1( null );
- cloud.setLong2( 2l );
- cloud.setString(null);
+ public void testDefaultAndNullBridges() throws Exception {
+ Cloud cloud = new Cloud();
+ cloud.setMyDate( null );
+ cloud.setDouble1( null );
+ cloud.setDouble2( 2.1d );
+ cloud.setIntegerv1( null );
+ cloud.setIntegerv2( 2 );
+ cloud.setFloat1( null );
+ cloud.setFloat2( 2.1f );
+ cloud.setLong1( null );
+ cloud.setLong2( 2l );
+ cloud.setString( null );
cloud.setType( CloudType.DOG );
+ cloud.setChar1( null );
+ cloud.setChar2( 'P' );
cloud.setStorm( false );
cloud.setClazz( Cloud.class );
- cloud.setUri( new URI("http://www.hibernate.org") );
- cloud.setUrl( new URL("http://www.hibernate.org") );
+ cloud.setUri( new URI( "http://www.hibernate.org" ) );
+ cloud.setUrl( new URL( "http://www.hibernate.org" ) );
org.hibernate.Session s = openSession();
- Transaction tx = s.beginTransaction();
- s.persist(cloud);
- s.flush();
- tx.commit();
+ Transaction tx = s.beginTransaction();
+ s.persist( cloud );
+ s.flush();
+ tx.commit();
- tx = s.beginTransaction();
- FullTextSession session = Search.getFullTextSession(s);
- QueryParser parser = new QueryParser("id", new StandardAnalyzer() );
- Query query;
- List result;
+ tx = s.beginTransaction();
+ FullTextSession session = Search.getFullTextSession( s );
+ QueryParser parser = new QueryParser( "id", new StandardAnalyzer() );
+ Query query;
+ List result;
- query = parser.parse("double2:[2.1 TO 2.1] AND float2:[2.1 TO 2.1] " +
- "AND integerv2:[2 TO 2.1] AND long2:[2 TO 2.1] AND type:\"dog\" AND storm:false");
+ query = parser.parse(
+ "double2:[2.1 TO 2.1] AND float2:[2.1 TO 2.1] " +
+ "AND integerv2:[2 TO 2.1] AND long2:[2 TO 2.1] AND type:\"dog\" AND storm:false"
+ );
- result = session.createFullTextQuery(query).list();
- assertEquals( "find primitives and do not fail on null", 1, result.size() );
+ result = session.createFullTextQuery( query ).list();
+ assertEquals( "find primitives and do not fail on null", 1, result.size() );
- query = parser.parse("double1:[2.1 TO 2.1] OR float1:[2.1 TO 2.1] OR integerv1:[2 TO 2.1] OR long1:[2 TO 2.1]");
- result = session.createFullTextQuery(query).list();
- assertEquals( "null elements should not be stored", 0, result.size() ); //the query is dumb because restrictive
+ query = parser.parse( "double1:[2.1 TO 2.1] OR float1:[2.1 TO 2.1] OR integerv1:[2 TO 2.1] OR long1:[2 TO 2.1]" );
+ result = session.createFullTextQuery( query ).list();
+ assertEquals( "null elements should not be stored", 0, result.size() ); //the query is dumb because restrictive
- query = parser.parse("type:dog");
- result = session.createFullTextQuery(query).setProjection( "type" ).list();
- assertEquals( "Enum projection works", 1, result.size() ); //the query is dumb because restrictive
+ query = parser.parse( "type:dog" );
+ result = session.createFullTextQuery( query ).setProjection( "type" ).list();
+ assertEquals( "Enum projection works", 1, result.size() ); //the query is dumb because restrictive
- query = new TermQuery( new Term("clazz", Cloud.class.getName() ) );
- result = session.createFullTextQuery(query).setProjection( "clazz" ).list();
- assertEquals( "Clazz projection works", 1, result.size() );
- assertEquals( "Clazz projection works", Cloud.class.getName(), ( (Class) ((Object[])result.get(0))[0] ).getName() );
+ query = new TermQuery( new Term( "clazz", Cloud.class.getName() ) );
+ result = session.createFullTextQuery( query ).setProjection( "clazz" ).list();
+ assertEquals( "Clazz projection works", 1, result.size() );
+ assertEquals(
+ "Clazz projection works",
+ Cloud.class.getName(),
+ ( ( Class ) ( ( Object[] ) result.get( 0 ) )[0] ).getName()
+ );
BooleanQuery bQuery = new BooleanQuery();
- bQuery.add( new TermQuery( new Term("uri", "http://www.hibernate.org" ) ), BooleanClause.Occur.MUST );
- bQuery.add( new TermQuery( new Term("url", "http://www.hibernate.org" ) ), BooleanClause.Occur.MUST );
+ bQuery.add( new TermQuery( new Term( "uri", "http://www.hibernate.org" ) ), BooleanClause.Occur.MUST );
+ bQuery.add( new TermQuery( new Term( "url", "http://www.hibernate.org" ) ), BooleanClause.Occur.MUST );
- result = session.createFullTextQuery(bQuery).setProjection( "clazz" ).list();
- assertEquals( "Clazz projection works", 1, result.size() );
+ result = session.createFullTextQuery( bQuery ).setProjection( "clazz" ).list();
+ assertEquals( "Clazz projection works", 1, result.size() );
+ query = parser.parse( "char1:[" + String.valueOf( Character.MIN_VALUE ) + " TO " + String.valueOf( Character.MAX_VALUE ) + "]" );
+ result = session.createFullTextQuery( query ).setProjection( "char1" ).list();
+ assertEquals( "Null elements should not be stored, CharacterBridge is not working", 0, result.size() );
+
+ query = parser.parse( "char2:P" );
+ result = session.createFullTextQuery( query ).setProjection( "char2" ).list();
+ assertEquals( "Wrong results number, CharacterBridge is not working", 1, result.size() );
+ assertEquals( "Wrong result, CharacterBridge is not working", 'P', ( ( Object[] ) result.get( 0 ) )[0] );
+
s.delete( s.get( Cloud.class, cloud.getId() ) );
- tx.commit();
- s.close();
+ tx.commit();
+ s.close();
- }
+ }
- public void testCustomBridges() throws Exception {
- Cloud cloud = new Cloud();
- cloud.setCustomFieldBridge( "This is divided by 2");
- cloud.setCustomStringBridge( "This is div by 4");
- org.hibernate.Session s = openSession();
- Transaction tx = s.beginTransaction();
- s.persist(cloud);
- s.flush();
- tx.commit();
+ public void testCustomBridges() throws Exception {
+ Cloud cloud = new Cloud();
+ cloud.setCustomFieldBridge( "This is divided by 2" );
+ cloud.setCustomStringBridge( "This is div by 4" );
+ org.hibernate.Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist( cloud );
+ s.flush();
+ tx.commit();
- tx = s.beginTransaction();
- FullTextSession session = Search.getFullTextSession(s);
- QueryParser parser = new QueryParser("id", new SimpleAnalyzer() );
- Query query;
- List result;
+ tx = s.beginTransaction();
+ FullTextSession session = Search.getFullTextSession( s );
+ QueryParser parser = new QueryParser( "id", new SimpleAnalyzer() );
+ Query query;
+ List result;
- query = parser.parse("customFieldBridge:This AND customStringBridge:This");
- result = session.createFullTextQuery(query).list();
- assertEquals( "Properties not mapped", 1, result.size() );
+ query = parser.parse( "customFieldBridge:This AND customStringBridge:This" );
+ result = session.createFullTextQuery( query ).list();
+ assertEquals( "Properties not mapped", 1, result.size() );
- query = parser.parse("customFieldBridge:by AND customStringBridge:is");
- result = session.createFullTextQuery(query).list();
- assertEquals( "Custom types not taken into account", 0, result.size() );
+ query = parser.parse( "customFieldBridge:by AND customStringBridge:is" );
+ result = session.createFullTextQuery( query ).list();
+ assertEquals( "Custom types not taken into account", 0, result.size() );
- s.delete( s.get( Cloud.class, cloud.getId() ) );
- tx.commit();
- s.close();
+ s.delete( s.get( Cloud.class, cloud.getId() ) );
+ tx.commit();
+ s.close();
- }
+ }
- public void testDateBridge() throws Exception {
- Cloud cloud = new Cloud();
- Calendar c = GregorianCalendar.getInstance();
- c.setTimeZone( TimeZone.getTimeZone( "GMT" ) ); //for the sake of tests
- c.set(2000, 11, 15, 3, 43, 2);
- c.set( Calendar.MILLISECOND, 5 );
+ public void testDateBridge() throws Exception {
+ Cloud cloud = new Cloud();
+ Calendar c = GregorianCalendar.getInstance();
+ c.setTimeZone( TimeZone.getTimeZone( "GMT" ) ); //for the sake of tests
+ c.set( 2000, 11, 15, 3, 43, 2 );
+ c.set( Calendar.MILLISECOND, 5 );
- Date date = new Date( c.getTimeInMillis() );
- cloud.setMyDate( date ); //5 millisecond
- cloud.setDateDay( date );
- cloud.setDateHour( date );
- cloud.setDateMillisecond( date );
- cloud.setDateMinute( date );
- cloud.setDateMonth( date );
- cloud.setDateSecond( date );
- cloud.setDateYear( date );
- org.hibernate.Session s = openSession();
- Transaction tx = s.beginTransaction();
- s.persist(cloud);
- s.flush();
- tx.commit();
+ Date date = new Date( c.getTimeInMillis() );
+ cloud.setMyDate( date ); //5 millisecond
+ cloud.setDateDay( date );
+ cloud.setDateHour( date );
+ cloud.setDateMillisecond( date );
+ cloud.setDateMinute( date );
+ cloud.setDateMonth( date );
+ cloud.setDateSecond( date );
+ cloud.setDateYear( date );
+ org.hibernate.Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist( cloud );
+ s.flush();
+ tx.commit();
- tx = s.beginTransaction();
- FullTextSession session = Search.getFullTextSession(s);
- QueryParser parser = new QueryParser("id", new StandardAnalyzer() );
- Query query;
- List result;
+ tx = s.beginTransaction();
+ FullTextSession session = Search.getFullTextSession( s );
+ QueryParser parser = new QueryParser( "id", new StandardAnalyzer() );
+ Query query;
+ List result;
- query = parser.parse("myDate:[19900101 TO 20060101]"
- + " AND dateDay:[20001214 TO 2000121501]"
- + " AND dateMonth:[200012 TO 20001201]"
- + " AND dateYear:[2000 TO 200001]"
- + " AND dateHour:[20001214 TO 2000121503]"
- + " AND dateMinute:[20001214 TO 200012150343]"
- + " AND dateSecond:[20001214 TO 20001215034302]"
- + " AND dateMillisecond:[20001214 TO 20001215034302005]"
- );
- result = session.createFullTextQuery(query).list();
- assertEquals( "Date not found or not property truncated", 1, result.size() );
+ query = parser.parse(
+ "myDate:[19900101 TO 20060101]"
+ + " AND dateDay:[20001214 TO 2000121501]"
+ + " AND dateMonth:[200012 TO 20001201]"
+ + " AND dateYear:[2000 TO 200001]"
+ + " AND dateHour:[20001214 TO 2000121503]"
+ + " AND dateMinute:[20001214 TO 200012150343]"
+ + " AND dateSecond:[20001214 TO 20001215034302]"
+ + " AND dateMillisecond:[20001214 TO 20001215034302005]"
+ );
+ result = session.createFullTextQuery( query ).list();
+ assertEquals( "Date not found or not property truncated", 1, result.size() );
- s.delete( s.get( Cloud.class, cloud.getId() ) );
- tx.commit();
- s.close();
+ s.delete( s.get( Cloud.class, cloud.getId() ) );
+ tx.commit();
+ s.close();
- }
- protected Class[] getMappings() {
- return new Class[] {
- Cloud.class
- };
- }
+ }
+ protected Class[] getMappings() {
+ return new Class[] {
+ Cloud.class
+ };
+ }
- protected void configure(Configuration cfg) {
- super.configure( cfg );
- cfg.setProperty( Environment.ANALYZER_CLASS, SimpleAnalyzer.class.getName() );
- }
+
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.ANALYZER_CLASS, SimpleAnalyzer.class.getName() );
+ }
}
Modified: search/trunk/src/test/java/org/hibernate/search/test/bridge/Cloud.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/bridge/Cloud.java 2009-07-25 05:24:55 UTC (rev 17201)
+++ search/trunk/src/test/java/org/hibernate/search/test/bridge/Cloud.java 2009-07-27 10:21:41 UTC (rev 17202)
@@ -44,6 +44,8 @@
private Date dateMillisecond;
private String customFieldBridge;
private String customStringBridge;
+ private Character char1;
+ private char char2;
private CloudType type;
private boolean storm;
private Class clazz;
@@ -285,4 +287,22 @@
public void setStorm(boolean storm) {
this.storm = storm;
}
+
+ @Field(index = Index.TOKENIZED, store = Store.YES)
+ public Character getChar1() {
+ return char1;
+ }
+
+ public void setChar1(Character char1) {
+ this.char1 = char1;
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.YES)
+ public char getChar2() {
+ return char2;
+ }
+
+ public void setChar2(char char2) {
+ this.char2 = char2;
+ }
}
15 years, 4 months
You have received an eCard
by hibernate-commits@lists.jboss.org
Good day.
You have received an eCard
To pick up your eCard, open attached file
Your card will be aviailable for pick-up beginning for the next 30 days.
Please be sure to view your eCard before the days are up!
We hope you enjoy you eCard.
Thank You!
15 years, 4 months
Hibernate SVN: r17201 - jpa-api/trunk/src/main/java/javax/persistence and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-07-25 01:24:55 -0400 (Sat, 25 Jul 2009)
New Revision: 17201
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java
jpa-api/trunk/src/main/java/javax/persistence/Persistence.java
jpa-api/trunk/src/main/java/javax/persistence/spi/PersistenceProviderResolverHolder.java
Log:
EJB-454 implements the default PPR strategy
EJB-453 use resolver held by PPRH
fix issues with Hibernate's isLoaded
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java 2009-07-24 19:05:04 UTC (rev 17200)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java 2009-07-25 05:24:55 UTC (rev 17201)
@@ -170,13 +170,21 @@
final boolean isInitialized = interceptor == null || interceptor.isInitialized( property );
LoadState state;
if (isInitialized && interceptor != null) {
- state = LoadState.LOADED;
+ //property is loaded according to bytecode enhancement, but is it loaded as far as association?
+ //it's ours, we can read
+ state = isLoaded( get( entity, property ) );
+ //it's ours so we know it's loaded
+ if (state == LoadState.UNKNOWN) state = LoadState.LOADED;
}
else if ( interceptor != null && (! isInitialized)) {
state = LoadState.NOT_LOADED;
}
else if ( sureFromUs ) { //interceptor == null
- state = LoadState.LOADED;
+ //property is loaded according to bytecode enhancement, but is it loaded as far as association?
+ //it's ours, we can read
+ state = isLoaded( get( entity, property ) );
+ //it's ours so we know it's loaded
+ if (state == LoadState.UNKNOWN) state = LoadState.LOADED;
}
else {
state = LoadState.UNKNOWN;
Modified: jpa-api/trunk/src/main/java/javax/persistence/Persistence.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/Persistence.java 2009-07-24 19:05:04 UTC (rev 17200)
+++ jpa-api/trunk/src/main/java/javax/persistence/Persistence.java 2009-07-25 05:24:55 UTC (rev 17201)
@@ -2,18 +2,13 @@
// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
package javax.persistence;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.Enumeration;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import javax.persistence.spi.LoadState;
import javax.persistence.spi.PersistenceProvider;
+import javax.persistence.spi.PersistenceProviderResolverHolder;
/**
* Bootstrap class that provides access to an EntityManagerFactory.
@@ -46,10 +41,7 @@
*/
public static EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {
EntityManagerFactory emf = null;
-
- if ( providers.size() == 0 ) {
- findAllProviders();
- }
+ List<PersistenceProvider> providers = getProviders();
for ( PersistenceProvider provider : providers ) {
emf = provider.createEntityManagerFactory( persistenceUnitName, properties );
if ( emf != null ) {
@@ -62,72 +54,45 @@
return emf;
}
+ private static List<PersistenceProvider> getProviders() {
+ return PersistenceProviderResolverHolder
+ .getPersistenceProviderResolver()
+ .getPersistenceProviders();
+ }
+
/**
* @return Returns a <code>PersistenceUtil</code> instance.
*/
public static PersistenceUtil getPersistenceUtil() {
- // return a dummy implementation of PersistenceUtil. Introduced for Hibernate Validator (HV-104).
- // Needs to be changed once we start updating EntityManager and introduce JPA2
- return new PersistenceUtil() {
+ return util;
+ }
+ private static PersistenceUtil util =
+ //TODO add an Hibernate specific optimization
+ new PersistenceUtil() {
public boolean isLoaded(Object entity, String attributeName) {
+ List<PersistenceProvider> providers = Persistence.getProviders();
+ for ( PersistenceProvider provider : providers ) {
+ final LoadState state = provider.isLoadedWithoutReference( entity, attributeName );
+ if ( state == LoadState.UNKNOWN ) continue;
+ return state == LoadState.LOADED;
+ }
+ for ( PersistenceProvider provider : providers ) {
+ final LoadState state = provider.isLoadedWithReference( entity, attributeName );
+ if ( state == LoadState.UNKNOWN ) continue;
+ return state == LoadState.LOADED;
+ }
return true;
}
public boolean isLoaded(Object object) {
+ List<PersistenceProvider> providers = Persistence.getProviders();
+ for ( PersistenceProvider provider : providers ) {
+ final LoadState state = provider.isLoaded( object );
+ if ( state == LoadState.UNKNOWN ) continue;
+ return state == LoadState.LOADED;
+ }
return true;
}
};
- }
-
-
- // Helper methods
- private static void findAllProviders() {
- try {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Enumeration<URL> resources = loader.getResources( "META-INF/services/" + PersistenceProvider.class.getName() );
- Set<String> names = new HashSet<String>();
- while ( resources.hasMoreElements() ) {
- URL url = resources.nextElement();
- InputStream is = url.openStream();
- try {
- names.addAll( providerNamesFromReader( new BufferedReader( new InputStreamReader( is ) ) ) );
- }
- finally {
- is.close();
- }
- }
- for ( String s : names ) {
- Class providerClass = loader.loadClass( s );
- providers.add( ( PersistenceProvider ) providerClass.newInstance() );
- }
- }
- catch ( IOException e ) {
- throw new PersistenceException( e );
- }
- catch ( InstantiationException e ) {
- throw new PersistenceException( e );
- }
- catch ( IllegalAccessException e ) {
- throw new PersistenceException( e );
- }
- catch ( ClassNotFoundException e ) {
- throw new PersistenceException( e );
- }
- }
-
- private static final Pattern nonCommentPattern = Pattern.compile( "^([^#]+)" );
-
- private static Set<String> providerNamesFromReader(BufferedReader reader) throws IOException {
- Set<String> names = new HashSet<String>();
- String line;
- while ( ( line = reader.readLine() ) != null ) {
- line = line.trim();
- Matcher m = nonCommentPattern.matcher( line );
- if ( m.find() ) {
- names.add( m.group().trim() );
- }
- }
- return names;
- }
}
Modified: jpa-api/trunk/src/main/java/javax/persistence/spi/PersistenceProviderResolverHolder.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/spi/PersistenceProviderResolverHolder.java 2009-07-24 19:05:04 UTC (rev 17200)
+++ jpa-api/trunk/src/main/java/javax/persistence/spi/PersistenceProviderResolverHolder.java 2009-07-25 05:24:55 UTC (rev 17201)
@@ -14,6 +14,9 @@
import java.util.List;
import java.util.Set;
import java.util.WeakHashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.persistence.PersistenceException;
@@ -88,7 +91,6 @@
private final List<WeakReference<Class<? extends PersistenceProvider>>> resolverClasses;
public CachingPersistenceProviderResolver(ClassLoader cl) {
- //creates a hard reference to the cl :(
resolverClasses = new ArrayList<WeakReference<Class<? extends PersistenceProvider>>>();
try {
Enumeration<URL> resources = cl.getResources( "META-INF/services/" + PersistenceProvider.class.getName() );
15 years, 4 months
Hibernate SVN: r17200 - in validator/trunk/hibernate-validator-tck-runner: src and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-24 15:05:04 -0400 (Fri, 24 Jul 2009)
New Revision: 17200
Removed:
validator/trunk/hibernate-validator-tck-runner/src/jboss-as/
Modified:
validator/trunk/hibernate-validator-tck-runner/pom.xml
Log:
Removed dependecy to ant built
Modified: validator/trunk/hibernate-validator-tck-runner/pom.xml
===================================================================
--- validator/trunk/hibernate-validator-tck-runner/pom.xml 2009-07-23 21:25:08 UTC (rev 17199)
+++ validator/trunk/hibernate-validator-tck-runner/pom.xml 2009-07-24 19:05:04 UTC (rev 17200)
@@ -1,4 +1,6 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>hibernate-validator-parent</artifactId>
<groupId>org.hibernate</groupId>
@@ -250,5 +252,50 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>setup-jboss-as</id>
+ <activation>
+ <property>
+ <name>setupJBoss</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>initialize</phase>
+ <configuration>
+ <tasks>
+ <property name="jboss.home" value="/opt/java/jboss-5"/>
+ <property name="deploy.dir" value="${jboss.home}/server/default/deployers/webbeans.deployer"/>
+ <property name="remote.repo" value="http://repository.jboss.com/maven2"/>
+ <property name="artifact.version" value="5.2.0.Beta2"/>
+ <property name="artifact.name"
+ value="webbeans-jboss-int-deployer-${artifact.version}"/>
+ <delete dir="${deploy.dir}" failonerror="false"/>
+ <mkdir dir="${basedir}/target/download"/>
+ <get src="${remote.repo}/org/jboss/webbeans/integration/webbeans-jboss-int-deployer/${artifact.version}/${artifact.name}.zip"
+ dest="${basedir}/target/download/${artifact.name}.zip"
+ verbose="true"
+ usetimestamp="true"/>
+ <unzip dest="target" src="${basedir}/target/download/${artifact.name}.zip"/>
+ <copy todir="${deploy.dir}">
+ <fileset dir="target/webbeans.deployer">
+ <include name="**/*"/>
+ </fileset>
+ </copy>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
15 years, 4 months