Hibernate SVN: r17358 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-19 08:48:52 -0400 (Wed, 19 Aug 2009)
New Revision: 17358
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java
Log:
made sure that the default package also applies for annotation
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java 2009-08-19 10:20:42 UTC (rev 17357)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java 2009-08-19 12:48:52 UTC (rev 17358)
@@ -91,8 +91,10 @@
public void parse(Set<InputStream> mappingStreams) {
for ( InputStream in : mappingStreams ) {
ConstraintMappingsType mapping = getValidationConfig( in );
- parseConstraintDefinitions( mapping.getConstraintDefinition() );
String defaultPackage = mapping.getDefaultPackage();
+
+ parseConstraintDefinitions( mapping.getConstraintDefinition(), defaultPackage );
+
for ( BeanType bean : mapping.getBean() ) {
Class<?> beanClass = getClass( bean.getClazz(), defaultPackage );
checkClassHasNotBeenProcessed( processedClasses, beanClass );
@@ -147,17 +149,15 @@
}
@SuppressWarnings("unchecked")
- private void parseConstraintDefinitions(List<ConstraintDefinitionType> constraintDefinitionList) {
+ private void parseConstraintDefinitions(List<ConstraintDefinitionType> constraintDefinitionList, String defaultPackage) {
for ( ConstraintDefinitionType constraintDefinition : constraintDefinitionList ) {
String annotationClassName = constraintDefinition.getAnnotation();
- Class<? extends Annotation> annotationClass;
- annotationClass = ( Class<? extends Annotation> ) loadClass(
- annotationClassName, this.getClass()
- );
- if ( !annotationClass.isAnnotation() ) {
+ Class<?> clazz = getClass( annotationClassName, defaultPackage );
+ if ( !clazz.isAnnotation() ) {
throw new ValidationException( annotationClassName + " is not an annotation" );
}
+ Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) clazz;
ValidatedByType validatedByType = constraintDefinition.getValidatedBy();
List<Class<? extends ConstraintValidator<? extends Annotation, ?>>> constraintValidatorClasses = new ArrayList<Class<? extends ConstraintValidator<? extends Annotation, ?>>>();
15 years, 6 months
Hibernate SVN: r17357 - in validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation: xml and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-19 06:20:42 -0400 (Wed, 19 Aug 2009)
New Revision: 17357
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConfigurationImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java
Log:
made sure that if xml configuration is ignored the right default values are used
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConfigurationImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConfigurationImpl.java 2009-08-19 10:20:17 UTC (rev 17356)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConfigurationImpl.java 2009-08-19 10:20:42 UTC (rev 17357)
@@ -34,10 +34,10 @@
import org.slf4j.Logger;
import org.hibernate.validation.engine.resolver.DefaultTraversableResolver;
+import org.hibernate.validation.util.LoggerFactory;
+import org.hibernate.validation.util.Version;
import org.hibernate.validation.xml.ValidationBootstrapParameters;
import org.hibernate.validation.xml.ValidationXmlParser;
-import org.hibernate.validation.util.LoggerFactory;
-import org.hibernate.validation.util.Version;
/**
* Hibernate specific <code>Configuration</code> implementation.
@@ -181,11 +181,21 @@
private void parseValidationXml() {
if ( ignoreXmlConfiguration ) {
log.info( "Ignoring XML configuration." );
- return;
+ // make sure we use the defaults in case they haven't been provided yet
+ if ( validationBootstrapParameters.messageInterpolator == null ) {
+ validationBootstrapParameters.messageInterpolator = defaultMessageInterpolator;
+ }
+ if ( validationBootstrapParameters.traversableResolver == null ) {
+ validationBootstrapParameters.traversableResolver = defaultTraversableResolver;
+ }
+ if ( validationBootstrapParameters.constraintValidatorFactory == null ) {
+ validationBootstrapParameters.constraintValidatorFactory = defaultValidatorFactory;
+ }
}
-
- ValidationBootstrapParameters xmlParameters = new ValidationXmlParser().parseValidationXml();
- applyXmlSettings( xmlParameters );
+ else {
+ ValidationBootstrapParameters xmlParameters = new ValidationXmlParser().parseValidationXml();
+ applyXmlSettings( xmlParameters );
+ }
}
private void applyXmlSettings(ValidationBootstrapParameters xmlParameters) {
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java 2009-08-19 10:20:17 UTC (rev 17356)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java 2009-08-19 10:20:42 UTC (rev 17357)
@@ -225,7 +225,7 @@
for ( FieldType fieldType : fields ) {
String fieldName = fieldType.getName();
if ( fieldNames.contains( fieldName ) ) {
- throw new ValidationException( fieldName + "is defined twice in mapping xml." );
+ throw new ValidationException( fieldName + " is defined twice in mapping xml for bean " + beanClass.getName() );
}
else {
fieldNames.add( fieldName );
@@ -276,7 +276,7 @@
for ( GetterType getterType : getters ) {
String getterName = getterType.getName();
if ( getterNames.contains( getterName ) ) {
- throw new ValidationException( getterName + "is defined twice in mapping xml." );
+ throw new ValidationException( getterName + " is defined twice in mapping xml for bean " + beanClass.getName() );
}
else {
getterNames.add( getterName );
15 years, 6 months
Hibernate SVN: r17356 - in beanvalidation/trunk/validation-tck/src/main: resources and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-19 06:20:17 -0400 (Wed, 19 Aug 2009)
New Revision: 17356
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/ConfigurationDefinedMessageInterpolator.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/DefaultProviderSpecifiedInValidationXmlTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MessageInterpolatorSpecifiedInValidationXmlTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/OptionalValidationXmlTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlDefinedMessageInterpolator.java
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleBeanDefinitionTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-DefaultProviderSpecifiedInValidationXmlTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MessageInterpolatorSpecifiedInValidationXmlTest.xml
Removed:
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-copy.xml
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/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/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleBeanDefinitionTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
xml configuration tests
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/ConfigurationDefinedMessageInterpolator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/ConfigurationDefinedMessageInterpolator.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/ConfigurationDefinedMessageInterpolator.java 2009-08-19 10:20:17 UTC (rev 17356)
@@ -0,0 +1,36 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jsr303.tck.tests.xmlconfiguration;
+
+import java.util.Locale;
+import javax.validation.MessageInterpolator;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class ConfigurationDefinedMessageInterpolator implements MessageInterpolator {
+ public static final String STATIC_INTERPOLATION_STRING = "Interpolator defined in Configuration was used.";
+
+ public String interpolate(String messageTemplate, Context context) {
+ return STATIC_INTERPOLATION_STRING;
+ }
+
+ public String interpolate(String messageTemplate, Context context, Locale locale) {
+ return STATIC_INTERPOLATION_STRING;
+ }
+}
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/DefaultProviderSpecifiedInValidationXmlTest.java (from rev 17352, 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/DefaultProviderSpecifiedInValidationXmlTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/DefaultProviderSpecifiedInValidationXmlTest.java 2009-08-19 10:20:17 UTC (rev 17356)
@@ -0,0 +1,81 @@
+// $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.xmlconfiguration;
+
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.validation.Configuration;
+import javax.validation.Validation;
+import javax.validation.ValidationProviderResolver;
+import javax.validation.ValidatorFactory;
+import javax.validation.spi.ValidationProvider;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.common.TCKValidationProvider;
+import org.hibernate.jsr303.tck.common.TCKValidatorConfiguration;
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({
+ TestUtil.class,
+ TestUtil.PathImpl.class,
+ TestUtil.NodeImpl.class,
+ TCKValidationProvider.class,
+ TCKValidatorConfiguration.class,
+ TCKValidationProvider.DummyValidatorFactory.class
+})
+@ValidationXml(value = "validation-DefaultProviderSpecifiedInValidationXmlTest.xml")
+public class DefaultProviderSpecifiedInValidationXmlTest extends AbstractTest {
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.4.6", id = "f"),
+ @SpecAssertion(section = "4.4.6", id = "j")
+ })
+ public void testProviderSpecifiedInValidationXml() {
+ 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
+ .byDefaultProvider()
+ .providerResolver( resolver )
+ .configure();
+ ValidatorFactory factory = configuration.buildValidatorFactory();
+ assertTrue( factory instanceof TCKValidationProvider.DummyValidatorFactory );
+ }
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/DefaultProviderSpecifiedInValidationXmlTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MessageInterpolatorSpecifiedInValidationXmlTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MessageInterpolatorSpecifiedInValidationXmlTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MessageInterpolatorSpecifiedInValidationXmlTest.java 2009-08-19 10:20:17 UTC (rev 17356)
@@ -0,0 +1,88 @@
+// $Id: InvalidXmlConfigurationTest.java 17352 2009-08-18 17:08:59Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jsr303.tck.tests.xmlconfiguration;
+
+
+import java.util.Set;
+import javax.validation.Configuration;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.common.TCKValidationProvider;
+import org.hibernate.jsr303.tck.common.TCKValidatorConfiguration;
+import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessages;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({
+ TestUtil.class,
+ TestUtil.PathImpl.class,
+ TestUtil.NodeImpl.class,
+ TCKValidationProvider.class,
+ TCKValidatorConfiguration.class,
+ TCKValidationProvider.DummyValidatorFactory.class
+})
+@ValidationXml(value = "validation-MessageInterpolatorSpecifiedInValidationXmlTest.xml")
+public class MessageInterpolatorSpecifiedInValidationXmlTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "4.4.6", id = "g")
+ public void testMessageInterpolatorSpecifiedInValidationXml() {
+ Validator validator = TestUtil.getValidatorUnderTest();
+
+ User user = new User();
+ Set<ConstraintViolation<User>> constraintViolations = validator.validate( user );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintViolationMessages(
+ constraintViolations, XmlDefinedMessageInterpolator.STATIC_INTERPOLATION_STRING
+ );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.4.6", id = "e"),
+ @SpecAssertion(section = "4.4.6", id = "g")
+ })
+ public void testMessageInterpolatorSpecifiedInValidationXmlCanBeOverridden() {
+ Configuration<?> configuration = Validation
+ .byDefaultProvider()
+ .configure().messageInterpolator( new ConfigurationDefinedMessageInterpolator() );
+ Validator validator = configuration.buildValidatorFactory().getValidator();
+
+ User user = new User();
+ Set<ConstraintViolation<User>> constraintViolations = validator.validate( user );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintViolationMessages(
+ constraintViolations, ConfigurationDefinedMessageInterpolator.STATIC_INTERPOLATION_STRING
+ );
+ }
+}
\ No newline at end of file
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-08-18 19:48:57 UTC (rev 17355)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleBeanDefinitionTest.java 2009-08-19 10:20:17 UTC (rev 17356)
@@ -26,6 +26,8 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
import static org.testng.Assert.fail;
import org.testng.annotations.Test;
@@ -38,6 +40,14 @@
@Artifact(artifactType = ArtifactType.JSR303)
@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
@ValidationXml(value = "validation-MultipleBeanDefinitionTest.xml")
+@Resources(
+ {
+ @Resource(source = "user-constraints.xml",
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints.xml"),
+ @Resource(source = "user-constraints-MultipleBeanDefinitionTest.xml",
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleBeanDefinitionTest.xml")
+ }
+)
public class MultipleBeanDefinitionTest extends AbstractTest {
@Test
@@ -48,7 +58,7 @@
public void testBeanCannotBeDescribedMoreThanOnce() {
try {
TestUtil.getValidatorUnderTest();
- fail();
+ fail( "You should not be able to define the same bean multiple times." );
}
catch ( ValidationException e ) {
// success
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-08-18 19:48:57 UTC (rev 17355)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleFieldDefinitionTest.java 2009-08-19 10:20:17 UTC (rev 17356)
@@ -26,6 +26,7 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.Resource;
import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
import static org.testng.Assert.fail;
import org.testng.annotations.Test;
@@ -38,6 +39,8 @@
@Artifact(artifactType = ArtifactType.JSR303)
@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
@ValidationXml(value = "validation-MultipleFieldDefinitionTest.xml")
+@Resource(source = "user-constraints-MultipleFieldDefinitionTest.xml",
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleFieldDefinitionTest.xml")
public class MultipleFieldDefinitionTest extends AbstractTest {
@Test
@@ -48,7 +51,7 @@
public void testFieldMappingCannotOccurMoreThanOnce() {
try {
TestUtil.getValidatorUnderTest();
- fail("You should not be able to define multiple field mappings per entity");
+ fail( "You should not be able to define multiple field mappings per entity" );
}
catch ( ValidationException e ) {
// success
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-08-18 19:48:57 UTC (rev 17355)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleGetterDefinitionTest.java 2009-08-19 10:20:17 UTC (rev 17356)
@@ -26,6 +26,7 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.Resource;
import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
import static org.testng.Assert.fail;
import org.testng.annotations.Test;
@@ -38,6 +39,8 @@
@Artifact(artifactType = ArtifactType.JSR303)
@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
@ValidationXml(value = "validation-MultipleGetterDefinitionTest.xml")
+@Resource(source = "user-constraints-MultipleGetterDefinitionTest.xml",
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleGetterDefinitionTest.xml")
public class MultipleGetterDefinitionTest extends AbstractTest {
@Test
@@ -48,7 +51,7 @@
public void testGetterMappingCannotOccurMoreThanOnce() {
try {
TestUtil.getValidatorUnderTest();
- fail("You should not be able to define multiple getter mappings per entity");
+ fail( "You should not be able to define multiple getter mappings per entity" );
}
catch ( ValidationException e ) {
// success
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/OptionalValidationXmlTest.java (from rev 17352, 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/OptionalValidationXmlTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/OptionalValidationXmlTest.java 2009-08-19 10:20:17 UTC (rev 17356)
@@ -0,0 +1,53 @@
+// $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.xmlconfiguration;
+
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
+public class OptionalValidationXmlTest extends AbstractTest {
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.4.6", id = "c")
+ })
+ public void testIgnoreValidationXml() {
+ Validator validator = TestUtil.getValidatorUnderTest();
+
+ Order order = new Order();
+ Set<ConstraintViolation<Order>> constraintViolations = validator.validate( order );
+ assertCorrectNumberOfViolations( constraintViolations, 0 );
+ }
+}
\ No newline at end of file
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-08-18 19:48:57 UTC (rev 17355)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java 2009-08-19 10:20:17 UTC (rev 17356)
@@ -18,9 +18,12 @@
package org.hibernate.jsr303.tck.tests.xmlconfiguration;
import java.util.Set;
+import javax.validation.Configuration;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
@@ -51,6 +54,9 @@
public class XmlConfigurationTest extends AbstractTest {
@Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.4.6", id = "a")
+ })
public void testClassConstraintDefinedInXml() {
Validator validator = TestUtil.getValidatorUnderTest();
@@ -67,6 +73,22 @@
}
@Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.4.6", id = "b")
+ })
+ public void testIgnoreValidationXml() {
+ Configuration<?> config = TestUtil.getConfigurationUnderTest();
+ Validator validator = config.ignoreXmlConfiguration().buildValidatorFactory().getValidator();
+
+ Order order = new Order();
+ Set<ConstraintViolation<Order>> constraintViolations = validator.validate( order );
+ assertCorrectNumberOfViolations( constraintViolations, 0 );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.4.6", id = "a")
+ })
public void testPropertyConstraintDefinedInXml() {
Validator validator = TestUtil.getValidatorUnderTest();
@@ -84,6 +106,9 @@
}
@Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.4.6", id = "a")
+ })
public void testFieldConstraintDefinedInXml() {
Validator validator = TestUtil.getValidatorUnderTest();
@@ -104,6 +129,9 @@
}
@Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.4.6", id = "a")
+ })
public void testAnnotationDefinedConstraintApplies() {
Validator validator = TestUtil.getValidatorUnderTest();
@@ -123,6 +151,9 @@
}
@Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.4.6", id = "a")
+ })
public void testCascadingConfiguredInXml() {
Validator validator = TestUtil.getValidatorUnderTest();
@@ -140,17 +171,4 @@
constraintViolations = validator.validate( user );
assertCorrectNumberOfViolations( constraintViolations, 0 );
}
-
-// @Test(expectedExceptions = ValidationException.class)
-// public void testInvalidValidationXml() {
-// getValidatorWithCustomConfiguration( "META-INF/validation-invalid-xmlconfiguration.xmlconfiguration" );
-// }
-//
-// @Test
-// public void testNoDefinedConstraints() {
-// Validator validator = getValidatorWithCustomConfiguration( "org/hibernate/validation/engine/xmlconfiguration/validation.xmlconfiguration" );
-// assertFalse(
-// validator.getConstraintsForClass( Order.class ).isBeanConstrained(), "Bean should be unsonstrained"
-// );
-// }
}
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlDefinedMessageInterpolator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlDefinedMessageInterpolator.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlDefinedMessageInterpolator.java 2009-08-19 10:20:17 UTC (rev 17356)
@@ -0,0 +1,36 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jsr303.tck.tests.xmlconfiguration;
+
+import java.util.Locale;
+import javax.validation.MessageInterpolator;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class XmlDefinedMessageInterpolator implements MessageInterpolator {
+ public static final String STATIC_INTERPOLATION_STRING = "Interpolator defined in xml was used.";
+
+ public String interpolate(String messageTemplate, Context context) {
+ return STATIC_INTERPOLATION_STRING;
+ }
+
+ public String interpolate(String messageTemplate, Context context, Locale locale) {
+ return STATIC_INTERPOLATION_STRING;
+ }
+}
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleBeanDefinitionTest.xml (from rev 17345, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-copy.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleBeanDefinitionTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleBeanDefinitionTest.xml 2009-08-19 10:20:17 UTC (rev 17356)
@@ -0,0 +1,60 @@
+<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
+ xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
+ <default-package>org.hibernate.jsr303.tck.tests.xmlconfiguration</default-package>
+ <bean class="User" ignore-annotations="false">
+ <class ignore-annotations="true">
+ <group-sequence>
+ <value>User</value>
+ <value>Optional</value>
+ </group-sequence>
+ <constraint annotation="org.hibernate.jsr303.tck.tests.xmlconfiguration.ConsistentUserInformation">
+ <message>Message from xml</message>
+ <groups>
+ <value>javax.validation.groups.Default</value>
+ </groups>
+ <element name="stringParam">foobar</element>
+ <element name="stringArrayParam">
+ <value>foo</value>
+ <value>bar</value>
+ </element>
+ <element name="intParam">
+ <value>42</value>
+ </element>
+ <element name="patterns">
+ <annotation>
+ <element name="regexp">myRegExp1</element>
+ </annotation>
+ <annotation>
+ <element name="regexp">myRegExp2</element>
+ </annotation>
+ </element>
+ <element name="userType">SELLER</element>
+ </constraint>
+ </class>
+ <field name="lastname">
+ <constraint annotation="javax.validation.constraints.Pattern">
+ <message>Last name has to start with with a capital letter.</message>
+ <element name="regexp">^[A-Z][a-z]+</element>
+ </constraint>
+ </field>
+ <field name="creditcard">
+ <valid/>
+ </field>
+ <getter name="firstname" ignore-annotations="true">
+ <constraint annotation="javax.validation.constraints.Size">
+ <message>Size is limited!</message>
+ <groups>
+ <value>org.hibernate.jsr303.tck.tests.xmlconfiguration.TestGroup</value>
+ <value>javax.validation.groups.Default</value>
+ </groups>
+ <element name="max">10</element>
+ </constraint>
+ </getter>
+ </bean>
+ <constraint-definition annotation="org.hibernate.jsr303.tck.tests.xmlconfiguration.ConsistentUserInformation">
+ <validated-by include-existing-validators="false">
+ <value>org.hibernate.jsr303.tck.tests.xmlconfiguration.CustomConsistentUserValidator</value>
+ </validated-by>
+ </constraint-definition>
+</constraint-mappings>
Property changes on: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleBeanDefinitionTest.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Deleted: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-copy.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-copy.xml 2009-08-18 19:48:57 UTC (rev 17355)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-copy.xml 2009-08-19 10:20:17 UTC (rev 17356)
@@ -1,60 +0,0 @@
-<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
- xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
- <default-package>org.hibernate.jsr303.tck.tests.xmlconfiguration</default-package>
- <bean class="User" ignore-annotations="false">
- <class ignore-annotations="true">
- <group-sequence>
- <value>User</value>
- <value>Optional</value>
- </group-sequence>
- <constraint annotation="org.hibernate.jsr303.tck.tests.xmlconfiguration.ConsistentUserInformation">
- <message>Message from xml</message>
- <groups>
- <value>javax.validation.groups.Default</value>
- </groups>
- <element name="stringParam">foobar</element>
- <element name="stringArrayParam">
- <value>foo</value>
- <value>bar</value>
- </element>
- <element name="intParam">
- <value>42</value>
- </element>
- <element name="patterns">
- <annotation>
- <element name="regexp">myRegExp1</element>
- </annotation>
- <annotation>
- <element name="regexp">myRegExp2</element>
- </annotation>
- </element>
- <element name="userType">SELLER</element>
- </constraint>
- </class>
- <field name="lastname">
- <constraint annotation="javax.validation.constraints.Pattern">
- <message>Last name has to start with with a capital letter.</message>
- <element name="regexp">^[A-Z][a-z]+</element>
- </constraint>
- </field>
- <field name="creditcard">
- <valid/>
- </field>
- <getter name="firstname" ignore-annotations="true">
- <constraint annotation="javax.validation.constraints.Size">
- <message>Size is limited!</message>
- <groups>
- <value>org.hibernate.jsr303.tck.tests.xmlconfiguration.TestGroup</value>
- <value>javax.validation.groups.Default</value>
- </groups>
- <element name="max">10</element>
- </constraint>
- </getter>
- </bean>
- <constraint-definition annotation="org.hibernate.jsr303.tck.tests.xmlconfiguration.ConsistentUserInformation">
- <validated-by include-existing-validators="false">
- <value>org.hibernate.jsr303.tck.tests.xmlconfiguration.CustomConsistentUserValidator</value>
- </validated-by>
- </constraint-definition>
-</constraint-mappings>
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-DefaultProviderSpecifiedInValidationXmlTest.xml (from rev 17352, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-EmptyXmlConfigurationTest.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-DefaultProviderSpecifiedInValidationXmlTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-DefaultProviderSpecifiedInValidationXmlTest.xml 2009-08-19 10:20:17 UTC (rev 17356)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<validation-config
+ xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd">
+
+ <default-provider>org.hibernate.jsr303.tck.common.TCKValidationProvider</default-provider>
+</validation-config>
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MessageInterpolatorSpecifiedInValidationXmlTest.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MessageInterpolatorSpecifiedInValidationXmlTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MessageInterpolatorSpecifiedInValidationXmlTest.xml 2009-08-19 10:20:17 UTC (rev 17356)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<validation-config
+ xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd">
+ <message-interpolator>org.hibernate.jsr303.tck.tests.xmlconfiguration.XmlDefinedMessageInterpolator</message-interpolator>
+</validation-config>
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleBeanDefinitionTest.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleBeanDefinitionTest.xml 2009-08-18 19:48:57 UTC (rev 17355)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleBeanDefinitionTest.xml 2009-08-19 10:20:17 UTC (rev 17356)
@@ -3,5 +3,5 @@
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<constraint-mapping>org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints.xml</constraint-mapping>
- <constraint-mapping>org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-copy.xml</constraint-mapping>
+ <constraint-mapping>org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleBeanDefinitionTest.xml</constraint-mapping>
</validation-config>
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-08-18 19:48:57 UTC (rev 17355)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-08-19 10:20:17 UTC (rev 17356)
@@ -826,62 +826,69 @@
</section>
<section id="4.4.6" title="XML Configuration">
<assertion id="a">
- <text>Unless explicitly ignored by calling Configuration.ignoreXMLConfiguration(), a
- Configuration takes into account the configuration available in
- META-INF/validation.xml</text>
+ <text>Unless explicitly ignored Configuration takes into account the configuration
+ available in META-INF/validation.xml</text>
</assertion>
- <assertion id="b">
+ <assertion id="b" implied="true">
+ <text>META-INF/validation.xml will be ignored if Configuration.ignoreXMLConfiguration()
+ is called.</text>
+ </assertion>
+ <assertion id="c">
<text>This configuration file is optional.</text>
</assertion>
- <assertion id="c">
+ <assertion id="d" testable="false">
<text>If more than one META-INF/validation.xml file is found in the classpath, a
ValidationException is raised. </text>
</assertion>
- <assertion id="d">
+ <assertion id="e">
<text>Unless stated otherwise, XML based configuration settings are overridden by values
- explicitly set via the Config- uration API</text>
+ explicitly set via the Configuration API</text>
</assertion>
- <assertion id="e">
- <text>default-provider: represents the class name of the provider specific Configuration
+ <assertion id="f">
+ <text>default-provider represents the class name of the provider specific Configuration
sub-interface. If defined, the provider suitable for this interface is used</text>
</assertion>
- <assertion id="f">
- <text>message-interpolator: represents the fully qualified class name of the
+ <assertion id="g">
+ <text>message-interpolator represents the fully qualified class name of the
MessageInterpolator implementation. When defined in XML, the implementation must
- have a public no-arg constructor. This element is optional</text>
+ have a public no-arg constructor.</text>
</assertion>
- <assertion id="g">
- <text>traversable-resolver: represents the fully qualified class name of the
+ <assertion id="h">
+ <text>traversable-resolver represents the fully qualified class name of the
TraversableResolver implementation. When defined in XML, the implementation must
- have a public no-arg constructor. This element is optional</text>
+ have a public no-arg constructor.</text>
</assertion>
- <assertion id="h">
- <text>constraint-validator-factory: represents the fully qualified class name of the
+ <assertion id="i">
+ <text>constraint-validator-factory represents the fully qualified class name of the
ConstraintValidatorFactory implementation. When defined in XML, the implementation
- must have a public no-arg constructor. This element is optional.</text>
+ must have a public no-arg constructor.</text>
</assertion>
- <assertion id="i">
- <text>constraint-mapping: represents the resource path of an XML mapping file</text>
+ <assertion id="j">
+ <text>message-interpolator, traversable-resolver and constraint-validator-factory are
+ optional.</text>
</assertion>
- <assertion id="j">
+ <assertion id="k">
+ <text>constraint-mapping represents the resource path of an XML mapping file</text>
+ </assertion>
+ <assertion id="l">
<text>More than one constraint-mapping element can be present</text>
</assertion>
- <assertion id="k">
+ <assertion id="m">
<text>Mappings provided via Configuration.addMapping(InputString) are added to the list
of mappings described via constraint-mapping</text>
</assertion>
- <assertion id="l">
+ <assertion id="n">
<text>The namespace javax.validation is reserved for use by this specification</text>
</assertion>
- <assertion id="m">
- <text>Properties defined via Configura- tion.addProperty(String, String) are added to
- the properties defined via property</text>
+ <assertion id="o">
+ <text>Properties defined via Configuration.addProperty(String, String) are added to the
+ properties defined via property</text>
</assertion>
- <assertion id="n">
+ <assertion id="p">
<text>If a property with the same name are defined in both XML and via the programmatic
- API, the value provided via programmatic API has prior- ity</text>
+ API, the value provided via programmatic API has priority</text>
</assertion>
- <assertion id="o">
+ <assertion id="q">
<text>If a public no-arg constructor is missing, a ValidationException is raised during
the Configuration.buildValidatorFactory() call</text>
</assertion>
15 years, 6 months
Hibernate SVN: r17355 - in core/branches/INFINISPAN/cache-infinispan/src: main/java/org/hibernate/cache/infinispan/collection and 13 other directories.
by hibernate-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2009-08-18 15:48:57 -0400 (Tue, 18 Aug 2009)
New Revision: 17355
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/TimestampTypeOverrides.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/tm/
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/tm/HibernateTransactionManagerLookup.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheHelper.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractNonFunctionalTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractRegionImplTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractFunctionalTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionImpl.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionManagerImpl.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionManagerLookup.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeTransactionManagerLookup.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/CacheTestSupport.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/CacheTestUtil.java
Removed:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanConfiguration.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/TimestampTypeOverrides.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractInfinispanTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/util/
Modified:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/InfinispanCollectionRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/InfinispanEntityRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseGeneralDataRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/InfinispanQueryResultsRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/InfinispanTimestampsRegion.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicReadOnlyTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeJtaTransactionImpl.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/EntityCollectionInvalidationTestCase.java
Log:
[ISPN-6] Infinispan now uses Hibernate's transaction manager.
Deleted: core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanConfiguration.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanConfiguration.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanConfiguration.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.hibernate.cache.infinispan;
-
-import org.infinispan.config.Configuration;
-
-/**
- * InfinispanConfiguration.
- *
- * @author Galder Zamarreño
- * @since 4.0
- */
-public class InfinispanConfiguration {
-
- private final Configuration configuration;
-
- public InfinispanConfiguration(Configuration configuration) {
- this.configuration = configuration;
- }
-}
Modified: core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -9,6 +9,8 @@
import java.util.Properties;
import java.util.Set;
+import javax.transaction.TransactionManager;
+
import org.hibernate.cache.CacheDataDescription;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.CollectionRegion;
@@ -20,7 +22,10 @@
import org.hibernate.cache.infinispan.entity.InfinispanEntityRegion;
import org.hibernate.cache.infinispan.query.InfinispanQueryResultsRegion;
import org.hibernate.cache.infinispan.timestamp.InfinispanTimestampsRegion;
+import org.hibernate.cache.infinispan.timestamp.TimestampTypeOverrides;
+import org.hibernate.cache.infinispan.tm.HibernateTransactionManagerLookup;
import org.hibernate.cfg.Settings;
+import org.hibernate.transaction.TransactionManagerLookup;
import org.hibernate.util.PropertiesHelper;
import org.infinispan.Cache;
import org.infinispan.config.Configuration;
@@ -126,6 +131,10 @@
private final Map<String, TypeOverrides> typeOverrides = new HashMap<String, TypeOverrides>();
private final Set<String> definedConfigurations = new HashSet<String>();
+
+ private org.infinispan.transaction.lookup.TransactionManagerLookup transactionManagerlookup;
+
+ private TransactionManager transactionManager;
/**
* Create a new instance using the default configuration.
@@ -143,46 +152,17 @@
}
/** {@inheritDoc} */
- public CollectionRegion buildCollectionRegion(String regionName, Properties properties,
- CacheDataDescription metadata) throws CacheException {
+ public CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata) throws CacheException {
log.debug("Building collection cache region [" + regionName + "]");
- Cache cache = getCache(regionName, COLLECTION_KEY);
- return new InfinispanCollectionRegion(cache, regionName, metadata);
+ Cache cache = getCache(regionName, COLLECTION_KEY, properties);
+ return new InfinispanCollectionRegion(cache, regionName, metadata, transactionManager);
}
/** {@inheritDoc} */
public EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata) throws CacheException {
if (log.isDebugEnabled()) log.debug("Building entity cache region [" + regionName + "]");
- Cache cache = getCache(regionName, ENTITY_KEY);
- return new InfinispanEntityRegion(cache, regionName, metadata);
-// TypeOverrides regionOverride = typeOverrides.get(regionName);
-// if (regionOverride != null) {
-// if (log.isDebugEnabled()) log.debug("Entity cache region specific configuration exists: " + regionOverride);
-// String cacheName = regionOverride.getCacheName();
-// String templateCacheName = null;
-// if (cacheName != null) {
-// // If override has been converted to cache configuration, it means that the cache configuration has
-// // already been defined and hence we only need to get the cache instance corresponding to that cache name
-// if (!regionOverride.isConvertedToInfinispanConfiguration()) {
-// templateCacheName = cacheName;
-// Configuration regionCacheCfg = regionOverride.createInfinispanConfiguration();
-// manager.defineConfiguration(cacheName, templateCacheName, regionCacheCfg);
-// }
-// cache = manager.getCache(cacheName);
-// } else {
-// // If cache name is null, the base configuration is the generic entity data type one
-// // and the cache name is the name of the region.
-// if (!regionOverride.isConvertedToInfinispanConfiguration()) {
-// templateCacheName = typeOverrides.get(ENTITY_KEY).getCacheName();
-// Configuration regionCacheCfg = regionOverride.createInfinispanConfiguration();
-// manager.defineConfiguration(regionName, templateCacheName, regionCacheCfg);
-// }
-// cache = manager.getCache(regionName);
-// }
-// } else {
-// // No region specific overrides, get a cache instance for the generic entity data type region
-// cache = manager.getCache(typeOverrides.get(ENTITY_KEY).getCacheName());
-// }
+ Cache cache = getCache(regionName, ENTITY_KEY, properties);
+ return new InfinispanEntityRegion(cache, regionName, metadata, transactionManager);
}
/**
@@ -192,7 +172,7 @@
throws CacheException {
log.debug("Building query results cache region [" + regionName + "]");
String cacheName = typeOverrides.get(QUERY_KEY).getCacheName();
- return new InfinispanQueryResultsRegion(manager.getCache(cacheName), regionName);
+ return new InfinispanQueryResultsRegion(manager.getCache(cacheName), regionName, properties, transactionManager);
}
/**
@@ -202,7 +182,7 @@
throws CacheException {
log.debug("Building timestamps cache region [" + regionName + "]");
String cacheName = typeOverrides.get(TIMESTAMPS_KEY).getCacheName();
- return new InfinispanTimestampsRegion(manager.getCache(cacheName), regionName);
+ return new InfinispanTimestampsRegion(manager.getCache(cacheName), regionName, transactionManager);
}
/**
@@ -233,6 +213,9 @@
public void start(Settings settings, Properties properties) throws CacheException {
log.debug("Starting Infinispan CacheManager");
try {
+ transactionManagerlookup = new HibernateTransactionManagerLookup(settings, properties);
+ transactionManager = transactionManagerlookup.getTransactionManager();
+
String configLoc = PropertiesHelper.getString(INFINISPAN_CONFIG_RESOURCE_PROP, properties, DEF_INFINISPAN_CONFIG_RESOURCE);
manager = createCacheManager(configLoc);
initGenericDataTypeOverrides();
@@ -244,51 +227,12 @@
dissectProperty(prefixLoc, key, properties);
}
}
- defineGenericDataTypeCacheConfigurations();
+ defineGenericDataTypeCacheConfigurations(settings, properties);
} catch (CacheException ce) {
throw ce;
} catch (Throwable t) {
throw new CacheException("Unable to start region factory", t);
}
-
-// if ((suffixLoc = key.indexOf(CONFIG_SUFFIX)) != -1) {
-// cfgOverride = getOrCreateConfig(key, prefixLoc, suffixLoc);
-// cfgOverride.setCache(PropertiesHelper.extractPropertyValue(key, properties));
-//// String name = key.substring(prefixLoc + PREFIX.length(), suffixLoc);
-//// cfgOverride = configs.get(name);
-//// if (cfgOverride == null) {
-//// cfgOverride = new DataTypeConfig();
-//// configs.put(name, cfgOverride);
-//// }
-//// String cache = null;
-//// if (name.equals(ENTITY_CACHE_RESOURCE_PROP)) {
-//// cache = PropertiesHelper.getString(ENTITY_CACHE_RESOURCE_PROP, properties, DEF_ENTITY_RESOURCE);
-//// } else if (name.equals(COLLECTION_CACHE_RESOURCE_PROP)) {
-//// cache = PropertiesHelper.getString(COLLECTION_CACHE_RESOURCE_PROP, properties, DEF_ENTITY_RESOURCE);
-//// } else if (name.equals(TIMESTAMP_CACHE_RESOURCE_PROP)) {
-//// cache = PropertiesHelper.getString(TIMESTAMP_CACHE_RESOURCE_PROP, properties, DEF_TIMESTAMP_RESOURCE);
-//// } else if (name.equals(QUERY_CACHE_RESOURCE_PROP)) {
-//// cache = PropertiesHelper.getString(QUERY_CACHE_RESOURCE_PROP, properties, DEF_QUERY_RESOURCE);
-//// } else {
-//// cache = PropertiesHelper.extractPropertyValue(key, properties);
-//// }
-//// cfgOverride.setCache(cache);
-// } else if ((suffixLoc = key.indexOf(STRATEGY_SUFFIX)) != -1) {
-// cfgOverride = getOrCreateConfig(key, prefixLoc, suffixLoc);
-// cfgOverride.setStrategy(PropertiesHelper.extractPropertyValue(key, properties));
-// } else if ((suffixLoc = key.indexOf(WAKE_UP_INTERVAL_SUFFIX)) != -1) {
-// cfgOverride = getOrCreateConfig(key, prefixLoc, suffixLoc);
-// cfgOverride.setWakeUpInterval(Long.parseLong(PropertiesHelper.extractPropertyValue(key, properties)));
-// } else if ((suffixLoc = key.indexOf(MAX_ENTRIES_SUFFIX)) != -1) {
-// cfgOverride = getOrCreateConfig(key, prefixLoc, suffixLoc);
-// cfgOverride.setMaxEntries(PropertiesHelper.getInt(key, properties, -1));
-// } else if ((suffixLoc = key.indexOf(LIFESPAN_SUFFIX)) != -1) {
-// cfgOverride = getOrCreateConfig(key, prefixLoc, suffixLoc);
-// cfgOverride.setLifespan(Long.parseLong(PropertiesHelper.extractPropertyValue(key, properties)));
-// } else if ((suffixLoc = key.indexOf(MAX_IDLE_SUFFIX)) != -1) {
-// cfgOverride = getOrCreateConfig(key, prefixLoc, suffixLoc);
-// cfgOverride.setMaxIdle(Long.parseLong(PropertiesHelper.extractPropertyValue(key, properties)));
-// }
}
/**
@@ -341,7 +285,7 @@
typeOverrides.put(QUERY_KEY, queryOverrides);
return typeOverrides;
}
-
+
// private boolean isGenericDataTypeProperty(String property) {
// return property.startsWith(PREFIX + ENTITY_KEY) || property.startsWith(PREFIX + COLLECTION_KEY)
// || property.startsWith(PREFIX + QUERY_KEY) || property.startsWith(PREFIX + TIMESTAMP_KEY);
@@ -358,7 +302,7 @@
cfgOverride.setEvictionStrategy(PropertiesHelper.extractPropertyValue(key, properties));
} else if ((suffixLoc = key.indexOf(WAKE_UP_INTERVAL_SUFFIX)) != -1) {
cfgOverride = getOrCreateConfig(prefixLoc, key, suffixLoc);
- cfgOverride.setEvictionWakeUpInterval(Long.parseLong(PropertiesHelper.extractPropertyValue(key, properties)));
+ cfgOverride.setEvictionWakeUpInterval(Long.parseLong(PropertiesHelper.extractPropertyValue(key, properties)));
} else if ((suffixLoc = key.indexOf(MAX_ENTRIES_SUFFIX)) != -1) {
cfgOverride = getOrCreateConfig(prefixLoc, key, suffixLoc);
cfgOverride.setEvictionMaxEntries(PropertiesHelper.getInt(key, properties, -1));
@@ -399,19 +343,23 @@
return cfgOverride;
}
- private void defineGenericDataTypeCacheConfigurations() throws CacheException {
+ private void defineGenericDataTypeCacheConfigurations(Settings settings, Properties properties) throws CacheException {
String[] defaultGenericDataTypes = new String[]{ENTITY_KEY, COLLECTION_KEY, TIMESTAMPS_KEY, QUERY_KEY};
for (String type : defaultGenericDataTypes) {
TypeOverrides override = typeOverrides.get(type);
String cacheName = override.getCacheName();
Configuration newCacheCfg = override.createInfinispanConfiguration();
+ // Apply overrides
Configuration cacheConfig = manager.defineConfiguration(cacheName, cacheName, newCacheCfg);
+ // Configure transaction manager
+ cacheConfig = configureTransactionManager(cacheConfig, cacheName, properties);
+ manager.defineConfiguration(cacheName, cacheName, cacheConfig);
definedConfigurations.add(cacheName);
override.validateInfinispanConfiguration(cacheConfig);
}
}
- private Cache getCache(String regionName, String typeKey) {
+ private Cache getCache(String regionName, String typeKey, Properties properties) {
TypeOverrides regionOverride = typeOverrides.get(regionName);
if (!definedConfigurations.contains(regionName)) {
String templateCacheName = null;
@@ -429,6 +377,9 @@
templateCacheName = typeOverrides.get(typeKey).getCacheName();
regionCacheCfg = typeOverrides.get(typeKey).createInfinispanConfiguration();
}
+ // Configure transaction manager
+ regionCacheCfg = configureTransactionManager(regionCacheCfg, templateCacheName, properties);
+ // Apply overrides
manager.defineConfiguration(regionName, templateCacheName, regionCacheCfg);
definedConfigurations.add(regionName);
}
@@ -467,4 +418,18 @@
// // No region specific overrides, get a cache instance for the generic entity data type region
// return manager.getCache(regionName);
}
+
+ private Configuration configureTransactionManager(Configuration regionOverrides, String templateCacheName, Properties properties) {
+ // Get existing configuration to verify whether a tm was configured or not.
+ Configuration templateConfig = manager.defineConfiguration(templateCacheName, new Configuration());
+ String ispnTmLookupClassName = templateConfig.getTransactionManagerLookupClass();
+ String hbTmLookupClassName = org.hibernate.cache.infinispan.tm.HibernateTransactionManagerLookup.class.getName();
+ if (ispnTmLookupClassName != null && !ispnTmLookupClassName.equals(hbTmLookupClassName)) {
+ log.debug("Infinispan is configured [" + ispnTmLookupClassName + "] with a different transaction manager lookup " +
+ "class than Hibernate [" + hbTmLookupClassName + "]");
+ } else {
+ regionOverrides.setTransactionManagerLookup(transactionManagerlookup);
+ }
+ return regionOverrides;
+ }
}
\ No newline at end of file
Deleted: core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/TimestampTypeOverrides.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/TimestampTypeOverrides.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/TimestampTypeOverrides.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.hibernate.cache.infinispan;
-
-import org.hibernate.cache.CacheException;
-import org.infinispan.config.Configuration;
-import org.infinispan.config.Configuration.CacheMode;
-
-/**
- * TimestampTypeOverrides.
- *
- * @author Galder Zamarreño
- * @since 4.0
- */
-public class TimestampTypeOverrides extends TypeOverrides {
- @Override
- public void validateInfinispanConfiguration(Configuration configuration) throws CacheException {
- CacheMode cacheMode = configuration.getCacheMode();
- if (cacheMode.equals(CacheMode.INVALIDATION_ASYNC) || cacheMode.equals(CacheMode.INVALIDATION_SYNC)) {
- throw new CacheException("Timestamp cache cannot be configured with invalidation");
- }
- }
-}
Modified: core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/InfinispanCollectionRegion.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/InfinispanCollectionRegion.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/InfinispanCollectionRegion.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -1,5 +1,9 @@
package org.hibernate.cache.infinispan.collection;
+import java.util.Properties;
+
+import javax.transaction.TransactionManager;
+
import org.hibernate.cache.CacheDataDescription;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.CollectionRegion;
@@ -14,8 +18,8 @@
*/
public class InfinispanCollectionRegion extends BaseTransactionalDataRegion implements CollectionRegion {
- public InfinispanCollectionRegion(Cache<Object, Object> cache, String name, CacheDataDescription metadata) {
- super(cache, name, metadata);
+ public InfinispanCollectionRegion(Cache<Object, Object> cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) {
+ super(cache, name, metadata, transactionManager);
}
public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
Modified: core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/InfinispanEntityRegion.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/InfinispanEntityRegion.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/InfinispanEntityRegion.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -1,5 +1,9 @@
package org.hibernate.cache.infinispan.entity;
+import java.util.Properties;
+
+import javax.transaction.TransactionManager;
+
import org.hibernate.cache.CacheDataDescription;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.EntityRegion;
@@ -14,8 +18,8 @@
*/
public class InfinispanEntityRegion extends BaseTransactionalDataRegion implements EntityRegion {
- public InfinispanEntityRegion(Cache<Object, Object> cache, String name, CacheDataDescription metadata) {
- super(cache, name, metadata);
+ public InfinispanEntityRegion(Cache<Object, Object> cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) {
+ super(cache, name, metadata, transactionManager);
}
public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
Modified: core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseGeneralDataRegion.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseGeneralDataRegion.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseGeneralDataRegion.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -1,5 +1,9 @@
package org.hibernate.cache.infinispan.impl;
+import java.util.Properties;
+
+import javax.transaction.TransactionManager;
+
import org.hibernate.cache.CacheException;
import org.hibernate.cache.GeneralDataRegion;
import org.infinispan.Cache;
@@ -11,8 +15,8 @@
*/
public abstract class BaseGeneralDataRegion extends BaseRegion implements GeneralDataRegion {
- public BaseGeneralDataRegion(Cache<Object, Object> cache, String name) {
- super(cache, name);
+ public BaseGeneralDataRegion(Cache<Object, Object> cache, String name, TransactionManager transactionManager) {
+ super(cache, name, transactionManager);
}
public void evict(Object key) throws CacheException {
Modified: core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseRegion.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -1,10 +1,20 @@
package org.hibernate.cache.infinispan.impl;
+import java.lang.reflect.Field;
import java.util.Map;
+import java.util.Properties;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
import org.hibernate.cache.CacheException;
import org.hibernate.cache.Region;
+import org.hibernate.cache.infinispan.util.CacheHelper;
+import org.hibernate.transaction.TransactionManagerLookupFactory;
import org.infinispan.Cache;
+import org.infinispan.context.Flag;
+import org.infinispan.factories.ComponentRegistry;
/**
* Support for Infinispan {@link Region}s. Handles common "utility" methods for an underlying named
@@ -17,10 +27,12 @@
abstract class BaseRegion implements Region {
private final Cache cache;
private final String name;
+ protected final TransactionManager transactionManager;
- public BaseRegion(Cache cache, String name) {
+ public BaseRegion(Cache cache, String name, TransactionManager transactionManager) {
this.cache = cache;
this.name = name;
+ this.transactionManager = transactionManager;
}
public Cache getCache() {
@@ -71,5 +83,100 @@
public void destroy() throws CacheException {
// TODO see if we need to do this even in spite of RF.shutdown()
}
+
+ /**
+ * Performs a JBoss Cache <code>get(Fqn, Object)</code> after first
+ * {@link #suspend suspending any ongoing transaction}. Wraps any exception
+ * in a {@link CacheException}. Ensures any ongoing transaction is resumed.
+ *
+ * @param key The key of the item to get
+ * @param opt any option to add to the get invocation. May be <code>null</code>
+ * @param suppressTimeout should any TimeoutException be suppressed?
+ * @return The retrieved object
+ * @throws CacheException issue managing transaction or talking to cache
+ */
+ protected Object suspendAndGet(Object key, Flag opt, boolean suppressTimeout) throws CacheException {
+ Transaction tx = suspend();
+ try {
+ if (suppressTimeout)
+ return CacheHelper.getAllowingTimeout(cache, key);
+ else
+ return CacheHelper.get(cache, key);
+ } finally {
+ resume(tx);
+ }
+ }
+
+ /**
+ * Tell the TransactionManager to suspend any ongoing transaction.
+ *
+ * @return the transaction that was suspended, or <code>null</code> if
+ * there wasn't one
+ */
+ protected Transaction suspend() {
+ Transaction tx = null;
+ try {
+ if (transactionManager != null) {
+ tx = transactionManager.suspend();
+ }
+ } catch (SystemException se) {
+ throw new CacheException("Could not suspend transaction", se);
+ }
+ return tx;
+ }
+
+ /**
+ * Tell the TransactionManager to resume the given transaction
+ *
+ * @param tx
+ * the transaction to suspend. May be <code>null</code>.
+ */
+ protected void resume(Transaction tx) {
+ try {
+ if (tx != null)
+ transactionManager.resume(tx);
+ } catch (Exception e) {
+ throw new CacheException("Could not resume transaction", e);
+ }
+ }
+
+// /**
+// * HACKY WAY TO GET THE TRANSACTION MANAGER, TODO: resolve it!
+// */
+// private static TransactionManager getTransactionManager(Properties properties) {
+//// return cache == null ? null : extractComponent(cache, TransactionManager.class);
+// return TransactionManagerLookupFactory.getTransactionManager(properties);
+// }
+//
+// public static <T> T extractComponent(Cache cache, Class<T> componentType) {
+// ComponentRegistry cr = extractComponentRegistry(cache);
+// return cr.getComponent(componentType);
+// }
+//
+// public static ComponentRegistry extractComponentRegistry(Cache cache) {
+// return (ComponentRegistry) extractField(cache, "componentRegistry");
+// }
+//
+// public static Object extractField(Object target, String fieldName) {
+// return extractField(target.getClass(), target, fieldName);
+// }
+//
+// public static Object extractField(Class type, Object target, String fieldName) {
+// Field field;
+// try {
+// field = type.getDeclaredField(fieldName);
+// field.setAccessible(true);
+// return field.get(target);
+// }
+// catch (Exception e) {
+// if (type.equals(Object.class)) {
+// e.printStackTrace();
+// return null;
+// } else {
+// // try with superclass!!
+// return extractField(type.getSuperclass(), target, fieldName);
+// }
+// }
+// }
}
\ No newline at end of file
Modified: core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -1,5 +1,9 @@
package org.hibernate.cache.infinispan.impl;
+import java.util.Properties;
+
+import javax.transaction.TransactionManager;
+
import org.hibernate.cache.CacheDataDescription;
import org.hibernate.cache.TransactionalDataRegion;
import org.infinispan.Cache;
@@ -13,8 +17,8 @@
private final CacheDataDescription metadata;
- public BaseTransactionalDataRegion(Cache<Object, Object> cache, String name, CacheDataDescription metadata) {
- super(cache, name);
+ public BaseTransactionalDataRegion(Cache<Object, Object> cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) {
+ super(cache, name, transactionManager);
this.metadata = metadata;
}
@@ -23,7 +27,7 @@
}
public boolean isTransactionAware() {
- return true;
+ return transactionManager != null;
}
}
\ No newline at end of file
Modified: core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/InfinispanQueryResultsRegion.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/InfinispanQueryResultsRegion.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/InfinispanQueryResultsRegion.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -1,16 +1,85 @@
package org.hibernate.cache.infinispan.query;
+import java.util.Properties;
+
+import javax.transaction.TransactionManager;
+
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cache.CacheException;
import org.hibernate.cache.QueryResultsRegion;
import org.hibernate.cache.infinispan.impl.BaseGeneralDataRegion;
+import org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion;
+import org.hibernate.cache.infinispan.util.CacheHelper;
+import org.hibernate.util.PropertiesHelper;
import org.infinispan.Cache;
+import org.infinispan.context.Flag;
/**
* @author Chris Bredesen
*/
-public class InfinispanQueryResultsRegion extends BaseGeneralDataRegion implements QueryResultsRegion {
+public class InfinispanQueryResultsRegion extends BaseTransactionalDataRegion implements QueryResultsRegion {
+ public static final String QUERY_CACHE_LOCAL_ONLY_PROP = "hibernate.cache.infinispan.query.localonly";
- public InfinispanQueryResultsRegion(Cache<Object, Object> cache, String name) {
- super(cache, name);
+ private boolean localOnly;
+
+ public InfinispanQueryResultsRegion(Cache<Object, Object> cache, String name, Properties properties, TransactionManager transactionManager) {
+ super(cache, name, null, transactionManager);
+
+ // If JBC is using INVALIDATION, we don't want to propagate changes.
+ // We use the Timestamps cache to manage invalidation
+ localOnly = CacheHelper.isClusteredInvalidation(cache);
+ if (!localOnly) {
+ // We don't want to waste effort setting an option if JBC is
+ // already in LOCAL mode. If JBC is REPL_(A)SYNC then check
+ // if they passed an config option to disable query replication
+ localOnly = CacheHelper.isClusteredReplication(cache)
+ && PropertiesHelper.getBoolean(QUERY_CACHE_LOCAL_ONLY_PROP, properties, false);
+ }
}
+ public void evict(Object key) throws CacheException {
+ if (localOnly)
+ CacheHelper.removeKey(getCache(), key, Flag.CACHE_MODE_LOCAL);
+ else
+ CacheHelper.removeKey(getCache(), key);
+ }
+
+ public void evictAll() throws CacheException {
+ if (localOnly)
+ CacheHelper.removeAll(getCache(), Flag.CACHE_MODE_LOCAL);
+ else
+ CacheHelper.removeAll(getCache());
+ }
+
+ public Object get(Object key) throws CacheException {
+ // Don't hold the JBC node lock throughout the tx, as that
+ // prevents updates
+ // Add a zero (or low) timeout option so we don't block
+ // waiting for tx's that did a put to commit
+ return suspendAndGet(key, Flag.ZERO_LOCK_ACQUISITION_TIMEOUT, true);
+ }
+
+ public void put(Object key, Object value) throws CacheException {
+ // Here we don't want to suspend the tx. If we do:
+ // 1) We might be caching query results that reflect uncommitted
+ // changes. No tx == no WL on cache node, so other threads
+ // can prematurely see those query results
+ // 2) No tx == immediate replication. More overhead, plus we
+ // spread issue #1 above around the cluster
+
+ // Add a zero (or quite low) timeout option so we don't block.
+ // Ignore any TimeoutException. Basically we forego caching the
+ // query result in order to avoid blocking.
+ // Reads are done with suspended tx, so they should not hold the
+ // lock for long. Not caching the query result is OK, since
+ // any subsequent read will just see the old result with its
+ // out-of-date timestamp; that result will be discarded and the
+ // db query performed again.
+ if (localOnly)
+ CacheHelper.putAllowingTimeout(getCache(), key, value, Flag.ZERO_LOCK_ACQUISITION_TIMEOUT, Flag.CACHE_MODE_LOCAL);
+ else
+ CacheHelper.putAllowingTimeout(getCache(), key, value, Flag.ZERO_LOCK_ACQUISITION_TIMEOUT);
+
+ }
+
}
\ No newline at end of file
Modified: core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/InfinispanTimestampsRegion.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/InfinispanTimestampsRegion.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/InfinispanTimestampsRegion.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -1,16 +1,120 @@
package org.hibernate.cache.infinispan.timestamp;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.hibernate.cache.CacheException;
import org.hibernate.cache.TimestampsRegion;
import org.hibernate.cache.infinispan.impl.BaseGeneralDataRegion;
+import org.hibernate.cache.infinispan.util.CacheHelper;
import org.infinispan.Cache;
+import org.infinispan.context.Flag;
+import org.infinispan.notifications.Listener;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryModified;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved;
+import org.infinispan.notifications.cachelistener.event.CacheEntryModifiedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryRemovedEvent;
/**
+ * Defines the behavior of the timestamps cache region for Infinispan.
+ *
* @author Chris Bredesen
+ * @author Galder Zamarreño
*/
+@Listener
public class InfinispanTimestampsRegion extends BaseGeneralDataRegion implements TimestampsRegion {
- public InfinispanTimestampsRegion(Cache<Object, Object> cache, String name) {
- super(cache, name);
+ private Map localCache = new ConcurrentHashMap();
+
+ public InfinispanTimestampsRegion(Cache<Object, Object> cache, String name, TransactionManager transactionManager) {
+ super(cache, name, transactionManager);
+ cache.addListener(this);
+ populateLocalCache();
}
+ @Override
+ public void evict(Object key) throws CacheException {
+ // TODO Is this a valid operation on a timestamps cache?
+ CacheHelper.evict(getCache(), key);
+ }
+
+ public void evictAll() throws CacheException {
+ // TODO Is this a valid operation on a timestamps cache?
+ CacheHelper.removeAll(getCache());
+ }
+
+ public Object get(Object key) throws CacheException {
+ Object value = localCache.get(key);
+ if (value == null) {
+ value = suspendAndGet(key, null, false);
+ if (value != null)
+ localCache.put(key, value);
+ }
+ return value;
+ }
+
+ public void put(Object key, Object value) throws CacheException {
+ // Don't hold the JBC node lock throughout the tx, as that
+ // prevents reads and other updates
+ Transaction tx = suspend();
+ try {
+ // We ensure ASYNC semantics (JBCACHE-1175)
+ CacheHelper.put(getCache(), key, value, Flag.FORCE_ASYNCHRONOUS);
+ } catch (Exception e) {
+ throw new CacheException(e);
+ } finally {
+ resume(tx);
+ }
+ }
+
+ @Override
+ public void destroy() throws CacheException {
+ localCache.clear();
+ getCache().removeListener(this);
+ super.destroy();
+ }
+
+ /**
+ * Monitors cache events and updates the local cache
+ *
+ * @param event
+ */
+ @CacheEntryModified
+ public void nodeModified(CacheEntryModifiedEvent event) {
+ if (event.isPre()) return;
+ localCache.put(event.getKey(), event.getValue());
+ }
+
+ /**
+ * Monitors cache events and updates the local cache
+ *
+ * @param event
+ */
+ @CacheEntryRemoved
+ public void nodeRemoved(CacheEntryRemovedEvent event) {
+ if (event.isPre()) return;
+ localCache.remove(event.getKey());
+// Fqn fqn = event.getFqn();
+// Fqn regFqn = getRegionFqn();
+// if (fqn.size() == regFqn.size() + 1 && fqn.isChildOf(regFqn)) {
+// Object key = fqn.get(regFqn.size());
+// localCache.remove(key);
+// } else if (fqn.equals(regFqn)) {
+// localCache.clear();
+// }
+ }
+
+ /**
+ * Brings all data from the distributed cache into our local cache.
+ */
+ private void populateLocalCache() {
+ Set children = CacheHelper.getKeySet(getCache());
+ for (Object key : children)
+ get(key);
+ }
+
}
\ No newline at end of file
Copied: core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/TimestampTypeOverrides.java (from rev 17297, core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/TimestampTypeOverrides.java)
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/TimestampTypeOverrides.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/TimestampTypeOverrides.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.hibernate.cache.infinispan.timestamp;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.infinispan.TypeOverrides;
+import org.infinispan.config.Configuration;
+import org.infinispan.config.Configuration.CacheMode;
+import org.infinispan.eviction.EvictionStrategy;
+
+/**
+ * TimestampTypeOverrides.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public class TimestampTypeOverrides extends TypeOverrides {
+ @Override
+ public void validateInfinispanConfiguration(Configuration configuration) throws CacheException {
+ CacheMode cacheMode = configuration.getCacheMode();
+ if (cacheMode.equals(CacheMode.INVALIDATION_ASYNC) || cacheMode.equals(CacheMode.INVALIDATION_SYNC)) {
+ throw new CacheException("Timestamp cache cannot be configured with invalidation");
+ }
+ EvictionStrategy strategy = configuration.getEvictionStrategy();
+ if (!strategy.equals(EvictionStrategy.NONE)) {
+ throw new CacheException("Timestamp cache cannot be configured with eviction");
+ }
+ }
+}
Added: core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/tm/HibernateTransactionManagerLookup.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/tm/HibernateTransactionManagerLookup.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/tm/HibernateTransactionManagerLookup.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.hibernate.cache.infinispan.tm;
+
+import java.util.Properties;
+
+import javax.transaction.TransactionManager;
+
+import org.hibernate.cfg.Settings;
+import org.hibernate.transaction.TransactionManagerLookup;
+
+/**
+ * HibernateTransactionManagerLookup.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public class HibernateTransactionManagerLookup implements org.infinispan.transaction.lookup.TransactionManagerLookup {
+ private final TransactionManagerLookup hibernateLookup;
+
+ private final Properties properties;
+
+ public HibernateTransactionManagerLookup(Settings settings, Properties properties) {
+ if (settings != null)
+ this.hibernateLookup = settings.getTransactionManagerLookup();
+ else
+ this.hibernateLookup = null;
+ this.properties = properties;
+ }
+
+ public TransactionManager getTransactionManager() throws Exception {
+ return hibernateLookup == null ? null : hibernateLookup.getTransactionManager(properties);
+ }
+
+}
Added: core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheHelper.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheHelper.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/util/CacheHelper.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,439 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.cache.infinispan.util;
+
+import java.util.Set;
+
+import org.hibernate.cache.CacheException;
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+import org.infinispan.context.Flag;
+import org.infinispan.util.concurrent.TimeoutException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Helper for dealing with Infinisan cache instances.
+ *
+ * @author Steve Ebersole
+ * @author Brian Stansberry
+ * @author Galder Zamarreño
+ */
+public class CacheHelper {
+
+ /** Key under which items are cached */
+ public static final String ITEM = "item";
+ /** Key and value used in a hack to create region root nodes */
+ public static final String DUMMY = "dummy";
+
+ private static final Logger log = LoggerFactory.getLogger(CacheHelper.class);
+
+ /**
+ * Disallow external instantiation of CacheHelper.
+ */
+ private CacheHelper() {
+ }
+
+ /**
+ * Is this cache participating in a cluster with invalidation?
+ *
+ * @param cache
+ * The cache to check.
+ * @return True if the cache is configured for synchronous/asynchronous invalidation; false
+ * otherwise.
+ */
+ public static boolean isClusteredInvalidation(Cache cache) {
+ return isClusteredInvalidation(cache.getConfiguration().getCacheMode());
+ }
+
+ /**
+ * Does this cache mode indicate clustered invalidation?
+ *
+ * @param cacheMode
+ * The cache to check
+ * @return True if the cache mode is confiogured for synchronous/asynchronous invalidation; false
+ * otherwise.
+ */
+ public static boolean isClusteredInvalidation(Configuration.CacheMode cacheMode) {
+ return cacheMode == Configuration.CacheMode.INVALIDATION_ASYNC
+ || cacheMode == Configuration.CacheMode.INVALIDATION_SYNC;
+ }
+
+ /**
+ * Is this cache participating in a cluster with replication?
+ *
+ * @param cache
+ * The cache to check.
+ * @return True if the cache is configured for synchronous/asynchronous invalidation; false
+ * otherwise.
+ */
+ public static boolean isClusteredReplication(Cache cache) {
+ return isClusteredReplication(cache.getConfiguration().getCacheMode());
+ }
+
+ /**
+ * Does this cache mode indicate clustered replication?
+ *
+ * @param cacheMode
+ * The cache to check
+ * @return True if the cache mode is confiogured for synchronous/asynchronous invalidation; false
+ * otherwise.
+ */
+ public static boolean isClusteredReplication(Configuration.CacheMode cacheMode) {
+ return cacheMode == Configuration.CacheMode.REPL_ASYNC || cacheMode == Configuration.CacheMode.REPL_SYNC;
+ }
+
+ public static boolean isSynchronous(Cache cache) {
+ return isSynchronous(cache.getConfiguration().getCacheMode());
+ }
+
+ public static boolean isSynchronous(Configuration.CacheMode cacheMode) {
+ return cacheMode == Configuration.CacheMode.REPL_SYNC || cacheMode == Configuration.CacheMode.INVALIDATION_SYNC;
+ }
+
+ public static Set getKeySet(Cache cache) {
+ return cache.keySet();
+ }
+
+ /**
+ * Builds an {@link Fqn} from <code>region</code> and <code>key</code> and performs a JBoss Cache
+ * <code>get(Fqn, Object)</code>, wrapping any exception in a {@link CacheException}.
+ *
+ * @param cache
+ * the cache to invoke on
+ * @param region
+ * base Fqn for the cache region
+ * @param key
+ * specific key to append to the <code>region</code> to form the full Fqn
+ */
+ public static Object get(Cache cache, Object key) throws CacheException {
+ try {
+ return cache.get(key);
+ } catch (Exception e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /**
+ * Builds an {@link Fqn} from <code>region</code> and <code>key</code> and performs a JBoss Cache
+ * <code>get(Fqn, Object)</code>, wrapping any exception in a {@link CacheException}.
+ *
+ * @param cache
+ * the cache to invoke on
+ * @param key
+ * specific key to append to the <code>region</code> to form the full Fqn
+ */
+ public static Object getAllowingTimeout(Cache cache, Object key) throws CacheException {
+ try {
+ return cache.get(key);
+ } catch (TimeoutException ignored) {
+ // ignore it
+ return null;
+ } catch (Exception e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /**
+ * Builds an {@link Fqn} from <code>region</code> and <code>key</code> and performs a JBoss Cache
+ * <code>put(Object, Object)</code>, wrapping any exception in a {@link CacheException}.
+ *
+ * @param cache
+ * the cache to invoke on
+ * @param region
+ * base Fqn for the cache region
+ * @param key
+ * specific key to append to the <code>region</code> to form the full Fqn
+ * @param value
+ * data to store in the cache node
+ */
+ public static void put(Cache cache, Object key, Object value) throws CacheException {
+ put(cache, key, value, null);
+ }
+
+ /**
+ * Builds an {@link Fqn} from <code>region</code> and <code>key</code> and performs a JBoss Cache
+ * <code>put(Object, Object)</code>, wrapping any exception in a {@link CacheException}.
+ *
+ * @param cache
+ * the cache to invoke on
+ * @param region
+ * base Fqn for the cache region
+ * @param key
+ * specific key to append to the <code>region</code> to form the full Fqn
+ * @param value
+ * data to store in the cache node
+ * @param option
+ * invocation Option to set for this invocation. May be <code>null</code>.
+ */
+ public static void put(Cache cache, Object key, Object value, Flag option) throws CacheException {
+ try {
+ cache.getAdvancedCache().put(key, value, option);
+ } catch (Exception e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /**
+ * Builds an {@link Fqn} from <code>region</code> and <code>key</code> and performs a JBoss Cache
+ * <code>put(Object, Object)</code>, ignoring any {@link TimeoutException} and wrapping any other
+ * exception in a {@link CacheException}.
+ *
+ * @param cache
+ * the cache to invoke on
+ * @param region
+ * base Fqn for the cache region
+ * @param key
+ * specific key to append to the <code>region</code> to form the full Fqn
+ * @param value
+ * data to store in the cache node
+ * @param option
+ * invocation Option to set for this invocation. May be <code>null</code>.
+ */
+ public static void putAllowingTimeout(Cache cache, Object key, Object value, Flag... option) throws CacheException {
+ try {
+ cache.getAdvancedCache().put(key, value, option);
+ } catch (TimeoutException allowed) {
+ // ignore it
+ } catch (Exception e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /**
+ * Builds an {@link Fqn} from <code>region</code> and <code>key</code> and performs a JBoss Cache
+ * <code>putForExternalRead(Object, Object)</code>, wrapping any exception in a
+ * {@link CacheException}. Ignores any JBoss Cache {@link TimeoutException}.
+ *
+ * @param cache
+ * the cache to invoke on
+ * @param region
+ * base Fqn for the cache region
+ * @param key
+ * specific key to append to the <code>region</code> to form the full Fqn
+ * @param value
+ * data to store in the cache node
+ */
+ public static boolean putForExternalRead(Cache cache, Object key, Object value) throws CacheException {
+ return putForExternalRead(cache, key, value, null);
+ }
+
+ /**
+ * Builds an {@link Fqn} from <code>region</code> and <code>key</code> and performs a JBoss Cache
+ * <code>putForExternalRead(Object, Object)</code>, wrapping any exception in a
+ * {@link CacheException}. Ignores any JBoss Cache {@link TimeoutException}.
+ *
+ * @param cache
+ * the cache to invoke on
+ * @param region
+ * base Fqn for the cache region
+ * @param key
+ * specific key to append to the <code>region</code> to form the full Fqn
+ * @param value
+ * data to store in the cache node
+ * @param option
+ * invocation Option to set for this invocation. May be <code>null</code>.
+ */
+ public static boolean putForExternalRead(Cache cache, Object key, Object value, Flag... option) throws CacheException {
+ try {
+ cache.getAdvancedCache().putForExternalRead(key, value, option);
+ return true;
+ } catch (TimeoutException te) {
+ // ignore!
+ log.debug("ignoring write lock acquisition failure");
+ return false;
+ } catch (Throwable t) {
+ throw new CacheException(t);
+ }
+ }
+
+ /**
+ * Builds an {@link Fqn} from <code>region</code> and <code>key</code> and performs a JBoss Cache
+ * <code>removeNode(Fqn)</code>, wrapping any exception in a {@link CacheException}.
+ *
+ * @param cache
+ * the cache to invoke on
+ * @param region
+ * base Fqn for the cache region
+ * @param key
+ * specific key to append to the <code>region</code> to form the full Fqn
+ */
+ public static void remove(Cache cache, Object key) throws CacheException {
+ remove(cache, key, null);
+ }
+
+ /**
+ * Builds an {@link Fqn} from <code>region</code> and <code>key</code> and performs a JBoss Cache
+ * <code>removeNode(Fqn)</code>, wrapping any exception in a {@link CacheException}.
+ *
+ * @param cache
+ * the cache to invoke on
+ * @param region
+ * base Fqn for the cache region
+ * @param key
+ * specific key to append to the <code>region</code> to form the full Fqn
+ * @param option
+ * invocation Option to set for this invocation. May be <code>null</code>.
+ */
+ public static void remove(Cache cache, Object key, Flag option) throws CacheException {
+ try {
+ cache.getAdvancedCache().remove(key, option);
+ } catch (Exception e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /**
+ * Performs a JBoss Cache <code>removeNode(Fqn)</code>, wrapping any exception in a
+ * {@link CacheException}.
+ *
+ * @param cache
+ * the cache to invoke on
+ * @param region
+ * base Fqn for the cache region
+ */
+ public static void removeAll(Cache cache) throws CacheException {
+ try {
+ cache.clear();
+ } catch (Exception e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /**
+ * Performs a JBoss Cache <code>removeNode(Fqn)</code>, wrapping any exception in a
+ * {@link CacheException}.
+ *
+ * @param cache
+ * the cache to invoke on
+ * @param region
+ * base Fqn for the cache region
+ * @param option
+ * invocation Option to set for this invocation. May be <code>null</code>.
+ */
+ public static void removeAll(Cache cache, Flag option) throws CacheException {
+ try {
+ cache.getAdvancedCache().clear(option);
+ } catch (Exception e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /**
+ * Performs a JBoss Cache <code>removeNode(Fqn)</code>, wrapping any exception in a
+ * {@link CacheException}.
+ *
+ * @param cache
+ * the cache to invoke on
+ * @param region
+ * base Fqn for the cache region
+ * @param option
+ * invocation Option to set for this invocation. May be <code>null</code>.
+ */
+ public static void removeKey(Cache cache, Object key, Flag option) throws CacheException {
+ try {
+ cache.getAdvancedCache().remove(key, option);
+ } catch (Exception e) {
+ throw new CacheException(e);
+ }
+ }
+
+ public static void removeKey(Cache cache, Object key) throws CacheException {
+ try {
+ cache.remove(key);
+ } catch (Exception e) {
+ throw new CacheException(e);
+ }
+ }
+
+ public static void evict(Cache cache, Object key) throws CacheException {
+ try {
+ cache.evict(key);
+ } catch (Exception e) {
+ throw new CacheException(e);
+ }
+ }
+
+
+// public static Node addNode(Cache cache, Fqn fqn, boolean localOnly, boolean resident) throws CacheException {
+// try {
+// Option option = null;
+// if (localOnly) {
+// option = new Option();
+// option.setCacheModeLocal(localOnly);
+// }
+//
+// Node root = cache.getRoot();
+// setInvocationOption(cache, option);
+// // FIXME hack to work around fact that calling
+// // Node added = root.addChild( fqn ); doesn't
+// // properly set the version on the node
+// Node added = null;
+// if (version == null) {
+// added = root.addChild(fqn);
+// } else {
+// cache.put(fqn, DUMMY, DUMMY);
+// added = root.getChild(fqn);
+// }
+// if (resident)
+// added.setResident(true);
+// return added;
+// } catch (Exception e) {
+// throw new CacheException(e);
+// }
+// }
+
+ /**
+// * Assigns the given Option to the cache's {@link InvocationContext}. Does nothing if
+// * <code>option</code> is <code>null</code>.
+// *
+// * @param cache
+// * the cache. Cannot be <code>null</code>.
+// * @param option
+// * the option. May be <code>null</code>.
+// *
+// * @see {@link Cache#getInvocationContext()}
+// * @see {@link InvocationContext#setOptionOverrides(Option)}
+// */
+// public static void setInvocationOption(Cache cache, Option option) {
+// if (option != null) {
+// cache.getInvocationContext().setOptionOverrides(option);
+// }
+// }
+
+// /**
+// * Creates an {@link Option} using the given {@link DataVersion} and passes it to
+// * {@link #setInvocationOption(Cache, Option)}.
+// *
+// * @param cache
+// * the cache to set the Option on. Cannot be <code>null</code>.
+// * @param version
+// * the DataVersion to set. Cannot be <code>null</code>.
+// */
+// public static void setDataVersionOption(Cache cache, DataVersion version) {
+// Option option = new Option();
+// option.setDataVersion(version);
+// setInvocationOption(cache, option);
+// }
+}
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,194 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.infinispan;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.GeneralDataRegion;
+import org.hibernate.cache.QueryResultsRegion;
+import org.hibernate.cache.Region;
+import org.hibernate.cache.infinispan.InfinispanRegionFactory;
+import org.hibernate.cache.infinispan.util.CacheHelper;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
+import org.infinispan.Cache;
+import org.infinispan.transaction.tm.BatchModeTransactionManager;
+
+/**
+ * Base class for tests of QueryResultsRegion and TimestampsRegion.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionImplTestCase {
+ protected static final String KEY = "Key";
+
+ protected static final String VALUE1 = "value1";
+ protected static final String VALUE2 = "value2";
+
+ public AbstractGeneralDataRegionTestCase(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void putInRegion(Region region, Object key, Object value) {
+ ((GeneralDataRegion) region).put(key, value);
+ }
+
+ @Override
+ protected void removeFromRegion(Region region, Object key) {
+ ((GeneralDataRegion) region).evict(key);
+ }
+
+ /**
+ * Test method for {@link QueryResultsRegion#evict(java.lang.Object)}.
+ *
+ * FIXME add testing of the "immediately without regard for transaction isolation" bit in the
+ * CollectionRegionAccessStrategy API.
+ */
+ public void testEvict() throws Exception {
+ evictOrRemoveTest();
+ }
+
+ private void evictOrRemoveTest() throws Exception {
+ Configuration cfg = createConfiguration();
+ InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
+ Cache localCache = getInfinispanCache(regionFactory);
+ boolean invalidation = CacheHelper.isClusteredInvalidation(localCache);
+
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
+ GeneralDataRegion localRegion = (GeneralDataRegion) createRegion(regionFactory,
+ getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
+
+ cfg = createConfiguration();
+ regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
+
+ GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory,
+ getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
+
+ assertNull("local is clean", localRegion.get(KEY));
+ assertNull("remote is clean", remoteRegion.get(KEY));
+
+ localRegion.put(KEY, VALUE1);
+ assertEquals(VALUE1, localRegion.get(KEY));
+
+ // allow async propagation
+ sleep(250);
+ Object expected = invalidation ? null : VALUE1;
+ assertEquals(expected, remoteRegion.get(KEY));
+
+ localRegion.evict(KEY);
+
+ assertEquals(null, localRegion.get(KEY));
+
+ assertEquals(null, remoteRegion.get(KEY));
+ }
+
+ protected abstract String getStandardRegionName(String regionPrefix);
+
+ /**
+ * Test method for {@link QueryResultsRegion#evictAll()}.
+ *
+ * FIXME add testing of the "immediately without regard for transaction isolation" bit in the
+ * CollectionRegionAccessStrategy API.
+ */
+ public void testEvictAll() throws Exception {
+ evictOrRemoveAllTest("entity");
+ }
+
+ private void evictOrRemoveAllTest(String configName) throws Exception {
+ Configuration cfg = createConfiguration();
+ InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
+ Cache localCache = getInfinispanCache(regionFactory);
+ boolean invalidation = CacheHelper.isClusteredInvalidation(localCache);
+
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
+ GeneralDataRegion localRegion = (GeneralDataRegion) createRegion(regionFactory,
+ getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
+
+ cfg = createConfiguration();
+ regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
+ Cache remoteCache = getInfinispanCache(regionFactory);
+
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
+ GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory,
+ getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
+ String regionName = REGION_PREFIX;
+
+ Set children = CacheHelper.getKeySet(localCache);
+ assertEquals("No children in " + children, 0, children.size());
+
+ children = CacheHelper.getKeySet(remoteCache);
+ assertEquals("No children in " + children, 0, children.size());
+
+ assertNull("local is clean", localRegion.get(KEY));
+ assertNull("remote is clean", remoteRegion.get(KEY));
+
+ localRegion.put(KEY, VALUE1);
+ assertEquals(VALUE1, localRegion.get(KEY));
+
+ // Allow async propagation
+ sleep(250);
+
+ remoteRegion.put(KEY, VALUE1);
+ assertEquals(VALUE1, remoteRegion.get(KEY));
+
+ // Allow async propagation
+ sleep(250);
+
+ localRegion.evictAll();
+
+ // This should re-establish the region root node in the optimistic case
+ assertNull(localRegion.get(KEY));
+
+ // Re-establishing the region root on the local node doesn't
+ // propagate it to other nodes. Do a get on the remote node to re-establish
+ // This only adds a node in the case of optimistic locking
+ assertEquals(null, remoteRegion.get(KEY));
+
+ assertEquals("local is clean", null, localRegion.get(KEY));
+ assertEquals("remote is clean", null, remoteRegion.get(KEY));
+ }
+
+ protected Configuration createConfiguration() {
+ Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, false, true);
+ return cfg;
+ }
+
+ protected void rollback() {
+ try {
+ BatchModeTransactionManager.getInstance().rollback();
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+ }
+}
\ No newline at end of file
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractNonFunctionalTestCase.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractNonFunctionalTestCase.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractNonFunctionalTestCase.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,97 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.infinispan;
+
+import org.hibernate.cache.RegionFactory;
+import org.hibernate.junit.UnitTestCase;
+import org.hibernate.test.cache.infinispan.util.CacheTestSupport;
+import org.infinispan.Cache;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Base class for all non-functional tests of Infinispan integration.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public abstract class AbstractNonFunctionalTestCase extends UnitTestCase {
+
+ public static final String REGION_PREFIX = "test";
+
+ private CacheTestSupport testSupport;
+ protected final Logger log = LoggerFactory.getLogger(getClass());
+
+ public AbstractNonFunctionalTestCase(String name) {
+ super(name);
+ testSupport = new CacheTestSupport(log);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ testSupport.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+
+ testSupport.tearDown();
+ }
+
+ protected void registerCache(Cache cache) {
+ testSupport.registerCache(cache);
+ }
+
+ protected void unregisterCache(Cache cache) {
+ testSupport.unregisterCache(cache);
+ }
+
+ protected void registerFactory(RegionFactory factory) {
+ testSupport.registerFactory(factory);
+ }
+
+ protected void unregisterFactory(RegionFactory factory) {
+ testSupport.unregisterFactory(factory);
+ }
+
+ protected CacheTestSupport getCacheTestSupport() {
+ return testSupport;
+ }
+
+ protected void sleep(long ms) {
+ try {
+ Thread.sleep(ms);
+ }
+ catch (InterruptedException e) {
+ log.warn("Interrupted during sleep", e);
+ }
+ }
+
+ protected void avoidConcurrentFlush() {
+ testSupport.avoidConcurrentFlush();
+ }
+}
\ No newline at end of file
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractRegionImplTestCase.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractRegionImplTestCase.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractRegionImplTestCase.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,64 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.infinispan;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cache.Region;
+import org.hibernate.cache.impl.CacheDataDescriptionImpl;
+import org.hibernate.cache.infinispan.InfinispanRegionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
+import org.hibernate.util.ComparableComparator;
+import org.infinispan.Cache;
+import org.infinispan.manager.DefaultCacheManager;
+import org.jgroups.JChannelFactory;
+
+/**
+ * Base class for tests of Region implementations.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public abstract class AbstractRegionImplTestCase extends AbstractNonFunctionalTestCase {
+
+ public AbstractRegionImplTestCase(String name) {
+ super(name);
+ }
+
+ protected abstract Cache getInfinispanCache(InfinispanRegionFactory regionFactory);
+
+ protected abstract Region createRegion(InfinispanRegionFactory regionFactory, String regionName, Properties properties, CacheDataDescription cdd);
+
+ protected abstract void putInRegion(Region region, Object key, Object value);
+
+ protected abstract void removeFromRegion(Region region, Object key);
+
+ protected CacheDataDescription getCacheDataDescription() {
+ return new CacheDataDescriptionImpl(true, true, ComparableComparator.INSTANCE);
+ }
+
+}
Modified: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -287,8 +287,6 @@
fail("Should have failed saying that invalidation is not allowed for timestamp caches.");
} catch(CacheException ce) {
}
-
- fail("Add more validations!");
}
public void testBuildDefaultTimestampsRegion() {
@@ -342,26 +340,62 @@
}
}
- public void testBuildTimestamRegionWithOverrides() {
+ public void testBuildTimestamRegionWithCacheNameOverride() {
final String timestamps = "org.hibernate.cache.UpdateTimestampsCache";
Properties p = new Properties();
InfinispanRegionFactory factory = new InfinispanRegionFactory();
p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "mytimestamps-cache");
- p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
- p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
- p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
factory.start(null, p);
CacheManager manager = factory.getCacheManager();
manager.getGlobalConfiguration().setTransportClass(null);
try {
InfinispanTimestampsRegion region = (InfinispanTimestampsRegion) factory.buildTimestampsRegion(timestamps, p);
- assertTrue(factory.getDefinedConfigurations().contains(timestamps));
+ assertTrue(factory.getDefinedConfigurations().contains("mytimestamps-cache"));
+ } finally {
+ factory.stop();
+ }
+ }
+
+ public void testBuildTimestamRegionWithFifoEvictionOverride() {
+ final String timestamps = "org.hibernate.cache.UpdateTimestampsCache";
+ Properties p = new Properties();
+ InfinispanRegionFactory factory = new InfinispanRegionFactory();
+ p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "mytimestamps-cache");
+ p.setProperty("hibernate.cache.infinispan.timestamps.eviction.strategy", "FIFO");
+ p.setProperty("hibernate.cache.infinispan.timestamps.eviction.wake_up_interval", "3000");
+ p.setProperty("hibernate.cache.infinispan.timestamps.eviction.max_entries", "10000");
+ try {
+ factory.start(null, p);
+ CacheManager manager = factory.getCacheManager();
+ manager.getGlobalConfiguration().setTransportClass(null);
+ InfinispanTimestampsRegion region = (InfinispanTimestampsRegion) factory.buildTimestampsRegion(timestamps, p);
+ assertTrue(factory.getDefinedConfigurations().contains("mytimestamps-cache"));
fail("Should fail cos no eviction configurations are allowed for timestamp caches");
+ } catch(CacheException ce) {
} finally {
factory.stop();
}
}
+ public void testBuildTimestamRegionWithNoneEvictionOverride() {
+ final String timestamps = "org.hibernate.cache.UpdateTimestampsCache";
+ Properties p = new Properties();
+ InfinispanRegionFactory factory = new InfinispanRegionFactory();
+ p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "timestamps-none-eviction");
+ p.setProperty("hibernate.cache.infinispan.timestamps.eviction.strategy", "NONE");
+ p.setProperty("hibernate.cache.infinispan.timestamps.eviction.wake_up_interval", "3000");
+ p.setProperty("hibernate.cache.infinispan.timestamps.eviction.max_entries", "10000");
+ factory.start(null, p);
+ CacheManager manager = factory.getCacheManager();
+ manager.getGlobalConfiguration().setTransportClass(null);
+ try {
+ InfinispanTimestampsRegion region = (InfinispanTimestampsRegion) factory.buildTimestampsRegion(timestamps, p);
+ assertTrue(factory.getDefinedConfigurations().contains("timestamps-none-eviction"));
+ } finally {
+ factory.stop();
+ }
+ }
+
public void testBuildQueryRegion() {
final String query = "org.hibernate.cache.StandardQueryCache";
Properties p = new Properties();
Copied: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractFunctionalTestCase.java (from rev 17244, core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractInfinispanTestCase.java)
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractFunctionalTestCase.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractFunctionalTestCase.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,104 @@
+package org.hibernate.test.cache.infinispan.functional;
+
+import java.util.Map;
+
+import org.hibernate.Session;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.stat.SecondLevelCacheStatistics;
+import org.hibernate.stat.Statistics;
+
+public abstract class AbstractFunctionalTestCase extends FunctionalTestCase {
+ private final String cacheConcurrencyStrategy;
+
+ public AbstractFunctionalTestCase(String string, String cacheConcurrencyStrategy) {
+ super(string);
+ this.cacheConcurrencyStrategy = cacheConcurrencyStrategy;
+ }
+
+ public String[] getMappings() {
+ return new String[] { "cache/infinispan/functional/Item.hbm.xml" };
+ }
+
+ @Override
+ public String getCacheConcurrencyStrategy() {
+ return cacheConcurrencyStrategy;
+ }
+
+ public void testEntityCache() {
+ Item item = new Item("chris", "Chris's Item");
+
+ Session s = openSession();
+ Statistics stats = s.getSessionFactory().getStatistics();
+ s.getTransaction().begin();
+ s.persist(item);
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ Item found = (Item) s.load(Item.class, item.getId());
+ System.out.println(stats);
+ assertEquals(item.getDescription(), found.getDescription());
+ assertEquals(0, stats.getSecondLevelCacheMissCount());
+ assertEquals(1, stats.getSecondLevelCacheHitCount());
+ s.delete(found);
+ s.close();
+ }
+
+ public void testQueryCache() {
+ Item item = new Item("chris", "Chris's Item");
+
+ Session s = openSession();
+ s.getTransaction().begin();
+ s.persist(item);
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.createQuery("from Item").setCacheable(true).list();
+ s.close();
+
+ s = openSession();
+ Statistics stats = s.getSessionFactory().getStatistics();
+ s.createQuery("from Item").setCacheable(true).list();
+ assertEquals(1, stats.getQueryCacheHitCount());
+ s.createQuery("delete from Item").executeUpdate();
+ s.close();
+ }
+
+ public void testCollectionCache() {
+ Item item = new Item("chris", "Chris's Item");
+ Item another = new Item("another", "Owned Item");
+ item.addItem(another);
+
+ Session s = openSession();
+ s.getTransaction().begin();
+ s.persist(item);
+ s.persist(another);
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ Statistics stats = s.getSessionFactory().getStatistics();
+ Item loaded = (Item) s.load(Item.class, item.getId());
+ assertEquals(1, loaded.getItems().size());
+ s.close();
+
+ s = openSession();
+ SecondLevelCacheStatistics cStats = stats.getSecondLevelCacheStatistics(Item.class.getName() + ".items");
+ Item loadedWithCachedCollection = (Item) s.load(Item.class, item.getId());
+ stats.logSummary();
+ assertEquals(item.getName(), loadedWithCachedCollection.getName());
+ assertEquals(item.getItems().size(), loadedWithCachedCollection.getItems().size());
+ assertEquals(1, cStats.getHitCount());
+ s.close();
+ }
+
+ public void testEmptySecondLevelCacheEntry() throws Exception {
+ getSessions().evictEntity(Item.class.getName());
+ Statistics stats = getSessions().getStatistics();
+ stats.clear();
+ SecondLevelCacheStatistics statistics = stats.getSecondLevelCacheStatistics(Item.class.getName() + ".items");
+ Map cacheEntries = statistics.getEntries();
+ assertEquals(0, cacheEntries.size());
+ }
+}
\ No newline at end of file
Deleted: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractInfinispanTestCase.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractInfinispanTestCase.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractInfinispanTestCase.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -1,104 +0,0 @@
-package org.hibernate.test.cache.infinispan.functional;
-
-import java.util.Map;
-
-import org.hibernate.Session;
-import org.hibernate.junit.functional.FunctionalTestCase;
-import org.hibernate.stat.SecondLevelCacheStatistics;
-import org.hibernate.stat.Statistics;
-
-public abstract class AbstractInfinispanTestCase extends FunctionalTestCase {
- private final String cacheConcurrencyStrategy;
-
- public AbstractInfinispanTestCase(String string, String cacheConcurrencyStrategy) {
- super(string);
- this.cacheConcurrencyStrategy = cacheConcurrencyStrategy;
- }
-
- public String[] getMappings() {
- return new String[] { "cache/infinispan/functional/Item.hbm.xml" };
- }
-
- @Override
- public String getCacheConcurrencyStrategy() {
- return cacheConcurrencyStrategy;
- }
-
- public void testEntityCache() {
- Item item = new Item("chris", "Chris's Item");
-
- Session s = openSession();
- Statistics stats = s.getSessionFactory().getStatistics();
- s.getTransaction().begin();
- s.persist(item);
- s.getTransaction().commit();
- s.close();
-
- s = openSession();
- Item found = (Item) s.load(Item.class, item.getId());
- System.out.println(stats);
- assertEquals(item.getDescription(), found.getDescription());
- assertEquals(0, stats.getSecondLevelCacheMissCount());
- assertEquals(1, stats.getSecondLevelCacheHitCount());
- s.delete(found);
- s.close();
- }
-
- public void testQueryCache() {
- Item item = new Item("chris", "Chris's Item");
-
- Session s = openSession();
- s.getTransaction().begin();
- s.persist(item);
- s.getTransaction().commit();
- s.close();
-
- s = openSession();
- s.createQuery("from Item").setCacheable(true).list();
- s.close();
-
- s = openSession();
- Statistics stats = s.getSessionFactory().getStatistics();
- s.createQuery("from Item").setCacheable(true).list();
- assertEquals(1, stats.getQueryCacheHitCount());
- s.createQuery("delete from Item").executeUpdate();
- s.close();
- }
-
- public void testCollectionCache() {
- Item item = new Item("chris", "Chris's Item");
- Item another = new Item("another", "Owned Item");
- item.addItem(another);
-
- Session s = openSession();
- s.getTransaction().begin();
- s.persist(item);
- s.persist(another);
- s.getTransaction().commit();
- s.close();
-
- s = openSession();
- Statistics stats = s.getSessionFactory().getStatistics();
- Item loaded = (Item) s.load(Item.class, item.getId());
- assertEquals(1, loaded.getItems().size());
- s.close();
-
- s = openSession();
- SecondLevelCacheStatistics cStats = stats.getSecondLevelCacheStatistics(Item.class.getName() + ".items");
- Item loadedWithCachedCollection = (Item) s.load(Item.class, item.getId());
- stats.logSummary();
- assertEquals(item.getName(), loadedWithCachedCollection.getName());
- assertEquals(item.getItems().size(), loadedWithCachedCollection.getItems().size());
- assertEquals(1, cStats.getHitCount());
- s.close();
- }
-
- public void testEmptySecondLevelCacheEntry() throws Exception {
- getSessions().evictEntity(Item.class.getName());
- Statistics stats = getSessions().getStatistics();
- stats.clear();
- SecondLevelCacheStatistics statistics = stats.getSecondLevelCacheStatistics(Item.class.getName() + ".items");
- Map cacheEntries = statistics.getEntries();
- assertEquals(0, cacheEntries.size());
- }
-}
\ No newline at end of file
Modified: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicReadOnlyTestCase.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicReadOnlyTestCase.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicReadOnlyTestCase.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -1,6 +1,6 @@
package org.hibernate.test.cache.infinispan.functional;
-public class BasicReadOnlyTestCase extends AbstractInfinispanTestCase {
+public class BasicReadOnlyTestCase extends AbstractFunctionalTestCase {
public BasicReadOnlyTestCase(String string) {
super(string, "read-only");
Modified: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -7,7 +7,7 @@
import org.hibernate.cache.entry.CacheEntry;
import org.hibernate.stat.SecondLevelCacheStatistics;
-public class BasicTransactionalTestCase extends AbstractInfinispanTestCase {
+public class BasicTransactionalTestCase extends AbstractFunctionalTestCase {
public BasicTransactionalTestCase(String string) {
super(string, "transactional");
Modified: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -25,6 +25,8 @@
import java.util.List;
import java.util.Set;
+import javax.transaction.TransactionManager;
+
import org.hibernate.FlushMode;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
@@ -34,6 +36,8 @@
import org.hibernate.test.cache.infinispan.functional.Customer;
import org.hibernate.test.tm.SimpleJtaTransactionManagerImpl;
import org.hibernate.transaction.CMTTransactionFactory;
+import org.hibernate.transaction.TransactionManagerLookup;
+import org.hibernate.util.ReflectHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,6 +50,8 @@
public class BulkOperationsTestCase extends FunctionalTestCase {
private static final Logger log = LoggerFactory.getLogger(BulkOperationsTestCase.class);
+
+ private TransactionManager tm;
public BulkOperationsTestCase(String string) {
super(string);
@@ -65,11 +71,13 @@
}
protected Class getConnectionProviderClass() {
- return org.hibernate.test.tm.ConnectionProviderImpl.class;
+// return org.hibernate.test.tm.ConnectionProviderImpl.class;
+ return org.hibernate.test.cache.infinispan.tm.XaConnectionProvider.class;
}
- protected Class getTransactionManagerLookupClass() {
- return org.hibernate.test.tm.TransactionManagerLookupImpl.class;
+ protected Class<? extends TransactionManagerLookup> getTransactionManagerLookupClass() {
+ return org.hibernate.test.cache.infinispan.tm.XaTransactionManagerLookup.class;
+// return org.hibernate.test.tm.TransactionManagerLookupImpl.class;
}
public void configure(Configuration cfg) {
@@ -84,9 +92,12 @@
cfg.setProperty( Environment.TRANSACTION_STRATEGY, transactionFactory.getName());
}
- public void testBulkOperations() throws Exception {
+ public void testBulkOperations() throws Throwable {
System.out.println("*** testBulkOperations()");
+ boolean cleanedUp = false;
try {
+ tm = getTransactionManagerLookupClass().newInstance().getTransactionManager(null);
+
createContacts();
List<Integer> rhContacts = getContactsByCustomer("Red Hat");
@@ -118,21 +129,30 @@
List<Integer> updated = getContactsByTLF("Updated");
assertNotNull("Got updated contacts", updated);
assertEquals("Updated contacts", 5, updated.size());
+ } catch(Throwable t) {
+ cleanedUp = true;
+ log.debug("Exceptional cleanup");
+ cleanup(true);
+ throw t;
} finally {
// cleanup the db so we can run this test multiple times w/o restarting the cluster
- cleanup();
+ if (!cleanedUp) {
+ log.debug("Non exceptional cleanup");
+ cleanup(false);
+ }
}
}
public void createContacts() throws Exception {
- SimpleJtaTransactionManagerImpl.getInstance().begin();
+ log.debug("Create 10 contacts");
+ tm.begin();
try {
for (int i = 0; i < 10; i++)
createCustomer(i);
- SimpleJtaTransactionManagerImpl.getInstance().commit();
+ tm.commit();
} catch (Exception e) {
log.error("Unable to create customer", e);
- SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ tm.rollback();
throw e;
}
}
@@ -142,16 +162,20 @@
deleteHQL += " (select customer FROM Customer as customer ";
deleteHQL += " where customer.name = :cName)";
- SimpleJtaTransactionManagerImpl.getInstance().begin();
+ tm.begin();
try {
Session session = getSessions().getCurrentSession();
int rowsAffected = session.createQuery(deleteHQL).setFlushMode(FlushMode.AUTO)
.setParameter("cName", "Red Hat").executeUpdate();
- SimpleJtaTransactionManagerImpl.getInstance().commit();
+ tm.commit();
return rowsAffected;
} catch (Exception e) {
- SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ try {
+ tm.rollback();
+ } catch (Exception ee) {
+ // ignored
+ }
throw e;
}
}
@@ -160,16 +184,17 @@
String selectHQL = "select contact.id from Contact contact";
selectHQL += " where contact.customer.name = :cName";
- SimpleJtaTransactionManagerImpl.getInstance().begin();
+ log.debug("Get contacts for customer " + customerName);
+ tm.begin();
try {
Session session = getSessions().getCurrentSession();
List results = session.createQuery(selectHQL).setFlushMode(FlushMode.AUTO).setParameter("cName", customerName)
.list();
- SimpleJtaTransactionManagerImpl.getInstance().commit();
+ tm.commit();
return results;
} catch (Exception e) {
- SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ tm.rollback();
throw e;
}
}
@@ -178,15 +203,15 @@
String selectHQL = "select contact.id from Contact contact";
selectHQL += " where contact.tlf = :cTLF";
- SimpleJtaTransactionManagerImpl.getInstance().begin();
+ tm.begin();
try {
Session session = getSessions().getCurrentSession();
List results = session.createQuery(selectHQL).setFlushMode(FlushMode.AUTO).setParameter("cTLF", tlf).list();
- SimpleJtaTransactionManagerImpl.getInstance().commit();
+ tm.commit();
return results;
} catch (Exception e) {
- SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ tm.rollback();
throw e;
}
}
@@ -194,51 +219,72 @@
public int updateContacts(String name, String newTLF) throws Exception {
String updateHQL = "update Contact set tlf = :cNewTLF where name = :cName";
- SimpleJtaTransactionManagerImpl.getInstance().begin();
+ tm.begin();
try {
Session session = getSessions().getCurrentSession();
int rowsAffected = session.createQuery(updateHQL).setFlushMode(FlushMode.AUTO).setParameter("cNewTLF", newTLF)
.setParameter("cName", name).executeUpdate();
- SimpleJtaTransactionManagerImpl.getInstance().commit();
+ tm.commit();
return rowsAffected;
} catch (Exception e) {
- SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ tm.rollback();
throw e;
}
}
public Contact getContact(Integer id) throws Exception {
-
- SimpleJtaTransactionManagerImpl.getInstance().begin();
+ tm.begin();
try {
Session session = getSessions().getCurrentSession();
Contact contact = (Contact) session.get(Contact.class, id);
- SimpleJtaTransactionManagerImpl.getInstance().commit();
+ tm.commit();
return contact;
} catch (Exception e) {
- SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ tm.rollback();
throw e;
}
}
- public void cleanup() throws Exception {
+// public void cleanup() throws Exception {
+// String deleteContactHQL = "delete from Contact";
+// String deleteCustomerHQL = "delete from Customer";
+// tm.begin();
+// try {
+// Session session = getSessions().getCurrentSession();
+// session.createQuery(deleteContactHQL).setFlushMode(FlushMode.AUTO).executeUpdate();
+// session.createQuery(deleteCustomerHQL).setFlushMode(FlushMode.AUTO).executeUpdate();
+// tm.commit();
+// } catch (Exception e) {
+// try {
+// tm.rollback();
+// } catch (Exception ee) {
+// // ignored
+// }
+// throw e;
+// }
+// }
+
+ public void cleanup(boolean ignore) throws Exception {
String deleteContactHQL = "delete from Contact";
String deleteCustomerHQL = "delete from Customer";
-
- SimpleJtaTransactionManagerImpl.getInstance().begin();
+ tm.begin();
try {
-
Session session = getSessions().getCurrentSession();
session.createQuery(deleteContactHQL).setFlushMode(FlushMode.AUTO).executeUpdate();
session.createQuery(deleteCustomerHQL).setFlushMode(FlushMode.AUTO).executeUpdate();
- SimpleJtaTransactionManagerImpl.getInstance().commit();
+ tm.commit();
} catch (Exception e) {
- SimpleJtaTransactionManagerImpl.getInstance().rollback();
- throw e;
+ if (!ignore) {
+ try {
+ tm.rollback();
+ } catch (Exception ee) {
+ // ignored
+ }
+ throw e;
+ }
}
-
}
private Customer createCustomer(int id) throws Exception {
Modified: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeJtaTransactionImpl.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeJtaTransactionImpl.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeJtaTransactionImpl.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -25,7 +25,11 @@
import java.sql.Connection;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
@@ -34,7 +38,9 @@
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
+import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,6 +57,8 @@
private LinkedList synchronizations;
private Connection connection; // the only resource we care about is jdbc connection
private final DualNodeJtaTransactionManagerImpl jtaTransactionManager;
+ private List<XAResource> enlistedResources = new ArrayList<XAResource>();
+ private Xid xid = new DualNodeJtaTransactionXid();
public DualNodeJtaTransactionImpl(DualNodeJtaTransactionManagerImpl jtaTransactionManager) {
this.jtaTransactionManager = jtaTransactionManager;
@@ -69,11 +77,17 @@
rollback();
} else {
status = Status.STATUS_PREPARING;
-
+
for (int i = 0; i < synchronizations.size(); i++) {
Synchronization s = (Synchronization) synchronizations.get(i);
s.beforeCompletion();
}
+
+ if (!runXaResourcePrepare()) {
+ status = Status.STATUS_ROLLING_BACK;
+ } else {
+ status = Status.STATUS_PREPARED;
+ }
status = Status.STATUS_COMMITTING;
@@ -86,7 +100,10 @@
throw new SystemException();
}
}
+
+ runXaResourceCommitTx();
+
status = Status.STATUS_COMMITTED;
for (int i = 0; i < synchronizations.size(); i++) {
@@ -100,6 +117,8 @@
}
public void rollback() throws IllegalStateException, SystemException {
+ status = Status.STATUS_ROLLING_BACK;
+ runXaResourceRollback();
status = Status.STATUS_ROLLEDBACK;
if (connection != null) {
@@ -149,11 +168,86 @@
public boolean enlistResource(XAResource xaResource) throws RollbackException,
IllegalStateException, SystemException {
- return false;
+ enlistedResources.add(xaResource);
+ try {
+ xaResource.start(xid, 0);
+ } catch (XAException e) {
+ log.error("Got an exception", e);
+ throw new SystemException(e.getMessage());
+ }
+ return true;
}
public boolean delistResource(XAResource xaResource, int i) throws IllegalStateException,
SystemException {
- return false;
+ throw new SystemException("not supported");
}
+
+ public Collection<XAResource> getEnlistedResources() {
+ return enlistedResources;
+ }
+
+ private boolean runXaResourcePrepare() throws SystemException {
+ Collection<XAResource> resources = getEnlistedResources();
+ for (XAResource res : resources) {
+ try {
+ res.prepare(xid);
+ } catch (XAException e) {
+ log.trace("The resource wants to rollback!", e);
+ return false;
+ } catch (Throwable th) {
+ log.error("Unexpected error from resource manager!", th);
+ throw new SystemException(th.getMessage());
+ }
+ }
+ return true;
+ }
+
+ private void runXaResourceRollback() {
+ Collection<XAResource> resources = getEnlistedResources();
+ for (XAResource res : resources) {
+ try {
+ res.rollback(xid);
+ } catch (XAException e) {
+ log.warn("Error while rolling back",e);
+ }
+ }
+ }
+
+ private boolean runXaResourceCommitTx() throws HeuristicMixedException {
+ Collection<XAResource> resources = getEnlistedResources();
+ for (XAResource res : resources) {
+ try {
+ res.commit(xid, false);//todo we only support one phase commit for now, change this!!!
+ } catch (XAException e) {
+ log.warn("exception while committing",e);
+ throw new HeuristicMixedException(e.getMessage());
+ }
+ }
+ return true;
+ }
+
+ private static class DualNodeJtaTransactionXid implements Xid {
+ private static AtomicInteger txIdCounter = new AtomicInteger(0);
+ private int id = txIdCounter.incrementAndGet();
+
+ public int getFormatId() {
+ return id;
+ }
+
+ public byte[] getGlobalTransactionId() {
+ throw new IllegalStateException("TODO - please implement me!!!"); //todo implement!!!
+ }
+
+ public byte[] getBranchQualifier() {
+ throw new IllegalStateException("TODO - please implement me!!!"); //todo implement!!!
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "{" +
+ "id=" + id +
+ '}';
+ }
+ }
}
Modified: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/EntityCollectionInvalidationTestCase.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/EntityCollectionInvalidationTestCase.java 2009-08-18 17:23:57 UTC (rev 17354)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/EntityCollectionInvalidationTestCase.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -36,7 +36,9 @@
import org.infinispan.manager.CacheManager;
import org.infinispan.marshall.MarshalledValue;
import org.infinispan.notifications.Listener;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryModified;
import org.infinispan.notifications.cachelistener.annotation.CacheEntryVisited;
+import org.infinispan.notifications.cachelistener.event.CacheEntryModifiedEvent;
import org.infinispan.notifications.cachelistener.event.CacheEntryVisitedEvent;
import org.jboss.util.collection.ConcurrentSet;
import org.slf4j.Logger;
@@ -138,12 +140,12 @@
// Modify customer in remote
remoteListener.clear();
ids = modifyCustomer(ids.customerId, remoteFactory, remoteTM);
- assertLoadedFromCache(remoteListener, ids.customerId, ids.contactIds);
+ assertLoadedFromCache(remoteListener, ids.customerId, ids.contactIds);
// After modification, local cache should have been invalidated and hence should be empty
assertTrue(localCollectionCache.isEmpty());
assertTrue(localCustomerCache.isEmpty());
- assertTrue(localContactCache.isEmpty());
+ assertTrue(localContactCache.isEmpty());
} catch (Exception e) {
log.error("Error", e);
throw e;
@@ -328,7 +330,6 @@
@CacheEntryVisited
public void nodeVisited(CacheEntryVisitedEvent event) {
log.debug(event.toString());
-
if (!event.isPre()) {
MarshalledValue mv = (MarshalledValue) event.getKey();
CacheKey cacheKey = (CacheKey) mv.get();
@@ -336,7 +337,7 @@
String key = (String) cacheKey.getEntityOrRoleName() + '#' + primKey;
log.debug("MyListener[" + name +"] - Visiting key " + key);
// String name = fqn.toString();
- String token = ".functional.cluster.";
+ String token = ".functional.";
int index = key.indexOf(token);
if (index > -1) {
index += token.length();
@@ -346,6 +347,27 @@
}
}
}
+
+// @CacheEntryModified
+// public void nodeModified(CacheEntryModifiedEvent event) {
+// log.debug(event.toString());
+// if (!event.isPre()) {
+// MarshalledValue mv = (MarshalledValue) event.getKey();
+// CacheKey cacheKey = (CacheKey) mv.get();
+// Integer primKey = (Integer) cacheKey.getKey();
+// String key = (String) cacheKey.getEntityOrRoleName() + '#' + primKey;
+// log.debug("MyListener[" + name +"] - Modified key " + key);
+// // String name = fqn.toString();
+// String token = ".functional.";
+// int index = key.indexOf(token);
+// if (index > -1) {
+// index += token.length();
+// key = key.substring(index);
+// log.debug("MyListener[" + name +"] - recording modification of " + key);
+// visited.add(key);
+// }
+// }
+// }
}
private class IdContainer {
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,299 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.infinispan.query;
+
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import junit.framework.AssertionFailedError;
+
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cache.QueryResultsRegion;
+import org.hibernate.cache.Region;
+import org.hibernate.cache.StandardQueryCache;
+import org.hibernate.cache.infinispan.InfinispanRegionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.test.cache.infinispan.AbstractGeneralDataRegionTestCase;
+import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
+import org.infinispan.Cache;
+import org.infinispan.notifications.Listener;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryVisited;
+import org.infinispan.notifications.cachelistener.event.CacheEntryVisitedEvent;
+import org.infinispan.transaction.tm.BatchModeTransactionManager;
+import org.infinispan.util.concurrent.IsolationLevel;
+
+/**
+ * Tests of QueryResultRegionImpl.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase {
+
+ // protected static final String REGION_NAME = "test/" + StandardQueryCache.class.getName();
+
+ /**
+ * Create a new EntityRegionImplTestCase.
+ *
+ * @param name
+ */
+ public QueryRegionImplTestCase(String name) {
+ super(name);
+ }
+
+ @Override
+ protected Region createRegion(InfinispanRegionFactory regionFactory, String regionName, Properties properties,
+ CacheDataDescription cdd) {
+ return regionFactory.buildQueryResultsRegion(regionName, properties);
+ }
+
+ @Override
+ protected String getStandardRegionName(String regionPrefix) {
+ return regionPrefix + "/" + StandardQueryCache.class.getName();
+ }
+
+ @Override
+ protected Cache getInfinispanCache(InfinispanRegionFactory regionFactory) {
+ return regionFactory.getCacheManager().getCache("local-query");
+ }
+
+ public void testPutDoesNotBlockGet() throws Exception {
+ putDoesNotBlockGetTest();
+ }
+
+ private void putDoesNotBlockGetTest() throws Exception {
+ Configuration cfg = createConfiguration();
+ InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
+
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
+ final QueryResultsRegion region = regionFactory.buildQueryResultsRegion(getStandardRegionName(REGION_PREFIX), cfg
+ .getProperties());
+
+ region.put(KEY, VALUE1);
+ assertEquals(VALUE1, region.get(KEY));
+
+ final CountDownLatch readerLatch = new CountDownLatch(1);
+ final CountDownLatch writerLatch = new CountDownLatch(1);
+ final CountDownLatch completionLatch = new CountDownLatch(1);
+ final ExceptionHolder holder = new ExceptionHolder();
+
+ Thread reader = new Thread() {
+ public void run() {
+ try {
+ BatchModeTransactionManager.getInstance().begin();
+ log.debug("Transaction began, get value for key");
+ assertTrue(VALUE2.equals(region.get(KEY)) == false);
+ BatchModeTransactionManager.getInstance().commit();
+ } catch (AssertionFailedError e) {
+ holder.a1 = e;
+ rollback();
+ } catch (Exception e) {
+ holder.e1 = e;
+ rollback();
+ } finally {
+ readerLatch.countDown();
+ }
+ }
+ };
+
+ Thread writer = new Thread() {
+ public void run() {
+ try {
+ BatchModeTransactionManager.getInstance().begin();
+ log.debug("Put value2");
+ region.put(KEY, VALUE2);
+ log.debug("Put finished for value2, await writer latch");
+ writerLatch.await();
+ log.debug("Writer latch finished");
+ BatchModeTransactionManager.getInstance().commit();
+ log.debug("Transaction committed");
+ } catch (Exception e) {
+ holder.e2 = e;
+ rollback();
+ } finally {
+ completionLatch.countDown();
+ }
+ }
+ };
+
+ reader.setDaemon(true);
+ writer.setDaemon(true);
+
+ writer.start();
+ assertFalse("Writer is blocking", completionLatch.await(100, TimeUnit.MILLISECONDS));
+
+ // Start the reader
+ reader.start();
+ assertTrue("Reader finished promptly", readerLatch.await(1000000000, TimeUnit.MILLISECONDS));
+
+ writerLatch.countDown();
+ assertTrue("Reader finished promptly", completionLatch.await(100, TimeUnit.MILLISECONDS));
+
+ assertEquals(VALUE2, region.get(KEY));
+
+ if (holder.a1 != null)
+ throw holder.a1;
+ else if (holder.a2 != null)
+ throw holder.a2;
+
+ assertEquals("writer saw no exceptions", null, holder.e1);
+ assertEquals("reader saw no exceptions", null, holder.e2);
+ }
+
+ public void testGetDoesNotBlockPut() throws Exception {
+ getDoesNotBlockPutTest();
+ }
+
+ // public void testGetDoesNotBlockPutPessimisticRepeatableRead() throws Exception {
+ // getDoesNotBlockPutTest();
+ // }
+
+ private void getDoesNotBlockPutTest() throws Exception {
+ Configuration cfg = createConfiguration();
+ InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
+
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
+ final QueryResultsRegion region = regionFactory.buildQueryResultsRegion(getStandardRegionName(REGION_PREFIX), cfg
+ .getProperties());
+
+ region.put(KEY, VALUE1);
+ assertEquals(VALUE1, region.get(KEY));
+
+ // final Fqn rootFqn = getRegionFqn(getStandardRegionName(REGION_PREFIX), REGION_PREFIX);
+ final Cache jbc = getInfinispanCache(regionFactory);
+
+ final CountDownLatch blockerLatch = new CountDownLatch(1);
+ final CountDownLatch writerLatch = new CountDownLatch(1);
+ final CountDownLatch completionLatch = new CountDownLatch(1);
+ final ExceptionHolder holder = new ExceptionHolder();
+
+ Thread blocker = new Thread() {
+
+ public void run() {
+ // Fqn toBlock = new Fqn(rootFqn, KEY);
+ GetBlocker blocker = new GetBlocker(blockerLatch, KEY);
+ try {
+ jbc.addListener(blocker);
+
+ BatchModeTransactionManager.getInstance().begin();
+ region.get(KEY);
+ BatchModeTransactionManager.getInstance().commit();
+ } catch (Exception e) {
+ holder.e1 = e;
+ rollback();
+ } finally {
+ jbc.removeListener(blocker);
+ }
+ }
+ };
+
+ Thread writer = new Thread() {
+
+ public void run() {
+ try {
+ writerLatch.await();
+
+ BatchModeTransactionManager.getInstance().begin();
+ region.put(KEY, VALUE2);
+ BatchModeTransactionManager.getInstance().commit();
+ } catch (Exception e) {
+ holder.e2 = e;
+ rollback();
+ } finally {
+ completionLatch.countDown();
+ }
+ }
+ };
+
+ blocker.setDaemon(true);
+ writer.setDaemon(true);
+
+ boolean unblocked = false;
+ try {
+ blocker.start();
+ writer.start();
+
+ assertFalse("Blocker is blocking", completionLatch.await(100, TimeUnit.MILLISECONDS));
+ // Start the writer
+ writerLatch.countDown();
+ assertTrue("Writer finished promptly", completionLatch.await(100, TimeUnit.MILLISECONDS));
+
+ blockerLatch.countDown();
+ unblocked = true;
+
+ if (IsolationLevel.REPEATABLE_READ.equals(jbc.getConfiguration().getIsolationLevel())) {
+ assertEquals(VALUE1, region.get(KEY));
+ } else {
+ assertEquals(VALUE2, region.get(KEY));
+ }
+
+ if (holder.a1 != null)
+ throw holder.a1;
+ else if (holder.a2 != null)
+ throw holder.a2;
+
+ assertEquals("blocker saw no exceptions", null, holder.e1);
+ assertEquals("writer saw no exceptions", null, holder.e2);
+ } finally {
+ if (!unblocked)
+ blockerLatch.countDown();
+ }
+ }
+
+ @Listener
+ public class GetBlocker {
+
+ private CountDownLatch latch;
+ // private Fqn fqn;
+ private Object key;
+
+ GetBlocker(CountDownLatch latch, Object key) {
+ this.latch = latch;
+ this.key = key;
+ }
+
+ @CacheEntryVisited
+ public void nodeVisisted(CacheEntryVisitedEvent event) {
+ if (event.isPre() && event.getKey().equals(key)) {
+ try {
+ latch.await();
+ } catch (InterruptedException e) {
+ log.error("Interrupted waiting for latch", e);
+ }
+ }
+ }
+ }
+
+ private class ExceptionHolder {
+ Exception e1;
+ Exception e2;
+ AssertionFailedError a1;
+ AssertionFailedError a2;
+ }
+}
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.hibernate.test.cache.infinispan.tm;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import org.hibernate.HibernateException;
+import org.hibernate.connection.ConnectionProvider;
+import org.hibernate.connection.ConnectionProviderFactory;
+
+/**
+ * XaConnectionProvider.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public class XaConnectionProvider implements ConnectionProvider {
+ private static ConnectionProvider actualConnectionProvider = ConnectionProviderFactory.newConnectionProvider();
+ private boolean isTransactional;
+
+ public static ConnectionProvider getActualConnectionProvider() {
+ return actualConnectionProvider;
+ }
+
+ public void configure(Properties props) throws HibernateException {
+ }
+
+ public Connection getConnection() throws SQLException {
+ XaTransactionImpl currentTransaction = XaTransactionManagerImpl.getInstance().getCurrentTransaction();
+ if (currentTransaction == null) {
+ isTransactional = false;
+ return actualConnectionProvider.getConnection();
+ } else {
+ isTransactional = true;
+ Connection connection = currentTransaction.getEnlistedConnection();
+ if (connection == null) {
+ connection = actualConnectionProvider.getConnection();
+ currentTransaction.enlistConnection(connection);
+ }
+ return connection;
+ }
+ }
+
+ public void closeConnection(Connection conn) throws SQLException {
+ if (!isTransactional) {
+ conn.close();
+ }
+ }
+
+ public void close() throws HibernateException {
+ actualConnectionProvider.close();
+ }
+
+ public boolean supportsAggressiveRelease() {
+ return true;
+ }
+}
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionImpl.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionImpl.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionImpl.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,247 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.hibernate.test.cache.infinispan.tm;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * XaResourceCapableTransactionImpl.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public class XaTransactionImpl implements Transaction {
+ private static final Logger log = LoggerFactory.getLogger(XaTransactionImpl.class);
+ private int status;
+ private LinkedList synchronizations;
+ private Connection connection; // the only resource we care about is jdbc connection
+ private final XaTransactionManagerImpl jtaTransactionManager;
+ private List<XAResource> enlistedResources = new ArrayList<XAResource>();
+ private Xid xid = new XaResourceCapableTransactionXid();
+
+ public XaTransactionImpl(XaTransactionManagerImpl jtaTransactionManager) {
+ this.jtaTransactionManager = jtaTransactionManager;
+ this.status = Status.STATUS_ACTIVE;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
+ IllegalStateException, SystemException {
+
+ if (status == Status.STATUS_MARKED_ROLLBACK) {
+ log.trace("on commit, status was marked for rollback-only");
+ rollback();
+ } else {
+ status = Status.STATUS_PREPARING;
+
+ for (int i = 0; i < synchronizations.size(); i++) {
+ Synchronization s = (Synchronization) synchronizations.get(i);
+ s.beforeCompletion();
+ }
+
+// if (!runXaResourcePrepare()) {
+// status = Status.STATUS_ROLLING_BACK;
+// } else {
+// status = Status.STATUS_PREPARED;
+// }
+
+ status = Status.STATUS_COMMITTING;
+
+ if (connection != null) {
+ try {
+ connection.commit();
+ connection.close();
+ } catch (SQLException sqle) {
+ status = Status.STATUS_UNKNOWN;
+ throw new SystemException();
+ }
+ }
+
+// runXaResourceCommitTx();
+
+ status = Status.STATUS_COMMITTED;
+
+ for (int i = 0; i < synchronizations.size(); i++) {
+ Synchronization s = (Synchronization) synchronizations.get(i);
+ s.afterCompletion(status);
+ }
+
+ // status = Status.STATUS_NO_TRANSACTION;
+ jtaTransactionManager.endCurrent(this);
+ }
+ }
+
+ public void rollback() throws IllegalStateException, SystemException {
+// status = Status.STATUS_ROLLING_BACK;
+// runXaResourceRollback();
+ status = Status.STATUS_ROLLEDBACK;
+
+ if (connection != null) {
+ try {
+ connection.rollback();
+ connection.close();
+ } catch (SQLException sqle) {
+ status = Status.STATUS_UNKNOWN;
+ throw new SystemException();
+ }
+ }
+
+ for (int i = 0; i < synchronizations.size(); i++) {
+ Synchronization s = (Synchronization) synchronizations.get(i);
+ s.afterCompletion(status);
+ }
+
+ // status = Status.STATUS_NO_TRANSACTION;
+ jtaTransactionManager.endCurrent(this);
+ }
+
+ public void setRollbackOnly() throws IllegalStateException, SystemException {
+ status = Status.STATUS_MARKED_ROLLBACK;
+ }
+
+ public void registerSynchronization(Synchronization synchronization) throws RollbackException,
+ IllegalStateException, SystemException {
+ // todo : find the spec-allowable statuses during which synch can be registered...
+ if (synchronizations == null) {
+ synchronizations = new LinkedList();
+ }
+ synchronizations.add(synchronization);
+ }
+
+ public void enlistConnection(Connection connection) {
+ if (this.connection != null) {
+ throw new IllegalStateException("Connection already registered");
+ }
+ this.connection = connection;
+ }
+
+ public Connection getEnlistedConnection() {
+ return connection;
+ }
+
+ public boolean enlistResource(XAResource xaResource) throws RollbackException, IllegalStateException,
+ SystemException {
+ enlistedResources.add(xaResource);
+ try {
+ xaResource.start(xid, 0);
+ } catch (XAException e) {
+ log.error("Got an exception", e);
+ throw new SystemException(e.getMessage());
+ }
+ return true;
+ }
+
+ public boolean delistResource(XAResource xaResource, int i) throws IllegalStateException, SystemException {
+ throw new SystemException("not supported");
+ }
+
+ public Collection<XAResource> getEnlistedResources() {
+ return enlistedResources;
+ }
+
+ private boolean runXaResourcePrepare() throws SystemException {
+ Collection<XAResource> resources = getEnlistedResources();
+ for (XAResource res : resources) {
+ try {
+ res.prepare(xid);
+ } catch (XAException e) {
+ log.trace("The resource wants to rollback!", e);
+ return false;
+ } catch (Throwable th) {
+ log.error("Unexpected error from resource manager!", th);
+ throw new SystemException(th.getMessage());
+ }
+ }
+ return true;
+ }
+
+ private void runXaResourceRollback() {
+ Collection<XAResource> resources = getEnlistedResources();
+ for (XAResource res : resources) {
+ try {
+ res.rollback(xid);
+ } catch (XAException e) {
+ log.warn("Error while rolling back",e);
+ }
+ }
+ }
+
+ private boolean runXaResourceCommitTx() throws HeuristicMixedException {
+ Collection<XAResource> resources = getEnlistedResources();
+ for (XAResource res : resources) {
+ try {
+ res.commit(xid, false);//todo we only support one phase commit for now, change this!!!
+ } catch (XAException e) {
+ log.warn("exception while committing",e);
+ throw new HeuristicMixedException(e.getMessage());
+ }
+ }
+ return true;
+ }
+
+ private static class XaResourceCapableTransactionXid implements Xid {
+ private static AtomicInteger txIdCounter = new AtomicInteger(0);
+ private int id = txIdCounter.incrementAndGet();
+
+ public int getFormatId() {
+ return id;
+ }
+
+ public byte[] getGlobalTransactionId() {
+ throw new IllegalStateException("TODO - please implement me!!!"); //todo implement!!!
+ }
+
+ public byte[] getBranchQualifier() {
+ throw new IllegalStateException("TODO - please implement me!!!"); //todo implement!!!
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "{" +
+ "id=" + id +
+ '}';
+ }
+ }
+}
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionManagerImpl.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionManagerImpl.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionManagerImpl.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.hibernate.test.cache.infinispan.tm;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.hibernate.test.tm.SimpleJtaTransactionImpl;
+import org.hibernate.test.tm.SimpleJtaTransactionManagerImpl;
+
+/**
+ * XaResourceCapableTransactionManagerImpl.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public class XaTransactionManagerImpl implements TransactionManager {
+ private static final XaTransactionManagerImpl INSTANCE = new XaTransactionManagerImpl();
+ private XaTransactionImpl currentTransaction;
+
+ public static XaTransactionManagerImpl getInstance() {
+ return INSTANCE;
+ }
+
+ public int getStatus() throws SystemException {
+ return currentTransaction == null ? Status.STATUS_NO_TRANSACTION : currentTransaction.getStatus();
+ }
+
+ public Transaction getTransaction() throws SystemException {
+ return currentTransaction;
+ }
+
+ public XaTransactionImpl getCurrentTransaction() {
+ return currentTransaction;
+ }
+
+ public void begin() throws NotSupportedException, SystemException {
+ currentTransaction = new XaTransactionImpl(this);
+ }
+
+ public Transaction suspend() throws SystemException {
+ Transaction suspended = currentTransaction;
+ currentTransaction = null;
+ return suspended;
+ }
+
+ public void resume(Transaction transaction) throws InvalidTransactionException, IllegalStateException,
+ SystemException {
+ currentTransaction = (XaTransactionImpl) transaction;
+ }
+
+ public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
+ SecurityException, IllegalStateException, SystemException {
+ if (currentTransaction == null) {
+ throw new IllegalStateException("no current transaction to commit");
+ }
+ currentTransaction.commit();
+ }
+
+ public void rollback() throws IllegalStateException, SecurityException, SystemException {
+ if (currentTransaction == null) {
+ throw new IllegalStateException("no current transaction");
+ }
+ currentTransaction.rollback();
+ }
+
+ public void setRollbackOnly() throws IllegalStateException, SystemException {
+ if (currentTransaction == null) {
+ throw new IllegalStateException("no current transaction");
+ }
+ currentTransaction.setRollbackOnly();
+ }
+
+ public void setTransactionTimeout(int i) throws SystemException {
+ }
+
+ void endCurrent(Transaction transaction) {
+ if (transaction == currentTransaction) {
+ currentTransaction = null;
+ }
+ }
+}
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionManagerLookup.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionManagerLookup.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionManagerLookup.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.hibernate.test.cache.infinispan.tm;
+
+import java.util.Properties;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.hibernate.HibernateException;
+import org.hibernate.test.tm.SimpleJtaTransactionManagerImpl;
+import org.hibernate.transaction.TransactionManagerLookup;
+
+/**
+ * XaResourceCapableTransactionManagerLookup.
+ *
+ * @author Galder Zamarreño
+ * @since 3.5
+ */
+public class XaTransactionManagerLookup implements TransactionManagerLookup {
+
+ public Object getTransactionIdentifier(Transaction transaction) {
+ return transaction;
+ }
+
+ public TransactionManager getTransactionManager(Properties props) throws HibernateException {
+ return XaTransactionManagerImpl.getInstance();
+ }
+
+ public String getUserTransactionName() {
+ throw new UnsupportedOperationException( "jndi currently not implemented for these tests" );
+ }
+
+}
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeTransactionManagerLookup.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeTransactionManagerLookup.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeTransactionManagerLookup.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,61 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.infinispan.util;
+
+import java.util.Properties;
+
+import javax.transaction.TransactionManager;
+import javax.transaction.Transaction;
+
+import org.hibernate.HibernateException;
+import org.hibernate.transaction.TransactionManagerLookup;
+import org.infinispan.transaction.tm.BatchModeTransactionManager;
+
+/**
+ * Uses the JBoss Cache BatchModeTransactionManager. Should not be used in
+ * any tests that simulate usage of database connections.
+ *
+ * @author Brian Stansberry
+ */
+public class BatchModeTransactionManagerLookup
+ implements TransactionManagerLookup {
+
+ public TransactionManager getTransactionManager(Properties props) throws HibernateException {
+ try {
+ return BatchModeTransactionManager.getInstance();
+ }
+ catch (Exception e) {
+ throw new HibernateException("Failed getting BatchModeTransactionManager", e);
+ }
+ }
+
+ public String getUserTransactionName() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getTransactionIdentifier(Transaction transaction) {
+ return transaction;
+ }
+
+}
Property changes on: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeTransactionManagerLookup.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/CacheTestSupport.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/CacheTestSupport.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/CacheTestSupport.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,152 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.infinispan.util;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.slf4j.Logger;
+
+import org.hibernate.cache.RegionFactory;
+import org.infinispan.Cache;
+
+/**
+ * Support class for tracking and cleaning up objects used in tests.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class CacheTestSupport {
+
+ private static final String PREFER_IPV4STACK = "java.net.preferIPv4Stack";
+
+ private Logger log;
+
+ private Set<Cache> caches = new HashSet();
+ private Set<RegionFactory> factories = new HashSet();
+ private Exception exception;
+ private String preferIPv4Stack;
+
+ public CacheTestSupport(Logger log) {
+ this.log = log;
+ }
+
+ public void registerCache(Cache cache) {
+ caches.add(cache);
+ }
+
+ public void registerFactory(RegionFactory factory) {
+ factories.add(factory);
+ }
+
+ public void unregisterCache(Cache cache) {
+ caches.remove(cache);
+ }
+
+ public void unregisterFactory(RegionFactory factory) {
+ factories.remove(factory);
+ }
+
+ public void setUp() throws Exception {
+
+ // Try to ensure we use IPv4; otherwise cluster formation is very slow
+ preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
+ System.setProperty(PREFER_IPV4STACK, "true");
+
+ cleanUp();
+ throwStoredException();
+ }
+
+ public void tearDown() throws Exception {
+
+ if (preferIPv4Stack == null)
+ System.clearProperty(PREFER_IPV4STACK);
+ else
+ System.setProperty(PREFER_IPV4STACK, preferIPv4Stack);
+
+ cleanUp();
+ throwStoredException();
+ }
+
+ public void avoidConcurrentFlush() {
+ // JG 2.6.1 has a problem where calling flush more than once too quickly
+ // can result in several second delays
+ sleep(100);
+ }
+
+ private void sleep(long ms) {
+ try {
+ Thread.sleep(ms);
+ }
+ catch (InterruptedException e) {
+ log.warn("Interrupted during sleep", e);
+ }
+ }
+
+ private void cleanUp() {
+ for (Iterator it = factories.iterator(); it.hasNext(); ) {
+ try {
+ ((RegionFactory) it.next()).stop();
+ }
+ catch (Exception e) {
+ storeException(e);
+ }
+ finally {
+ it.remove();
+ }
+ }
+ factories.clear();
+
+ for (Iterator it = caches.iterator(); it.hasNext(); ) {
+ try {
+ Cache cache = (Cache) it.next();
+ cache.stop();
+ }
+ catch (Exception e) {
+ storeException(e);
+ }
+ finally {
+ it.remove();
+ }
+ avoidConcurrentFlush();
+ }
+ caches.clear();
+ }
+
+ private void storeException(Exception e) {
+ if (this.exception == null) {
+ this.exception = e;
+ }
+ }
+
+ private void throwStoredException() throws Exception {
+ if (exception != null) {
+ Exception toThrow = exception;
+ exception = null;
+ throw toThrow;
+ }
+ }
+
+}
Added: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/CacheTestUtil.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/CacheTestUtil.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/CacheTestUtil.java 2009-08-18 19:48:57 UTC (rev 17355)
@@ -0,0 +1,140 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.infinispan.util;
+
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.hibernate.cache.infinispan.InfinispanRegionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.cfg.Settings;
+
+/**
+ * Utilities for cache testing.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class CacheTestUtil {
+
+ public static Configuration buildConfiguration(String regionPrefix, Class regionFactory, boolean use2ndLevel, boolean useQueries) {
+ Configuration cfg = new Configuration();
+ cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
+ cfg.setProperty(Environment.USE_STRUCTURED_CACHE, "true");
+ cfg.setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, BatchModeTransactionManagerLookup.class.getName());
+
+ cfg.setProperty(Environment.CACHE_REGION_FACTORY, regionFactory.getName());
+ cfg.setProperty(Environment.CACHE_REGION_PREFIX, regionPrefix);
+ cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, String.valueOf(use2ndLevel));
+ cfg.setProperty(Environment.USE_QUERY_CACHE, String.valueOf(useQueries));
+
+ return cfg;
+ }
+
+ public static Configuration buildLocalOnlyConfiguration(String regionPrefix, boolean use2ndLevel, boolean useQueries) {
+ Configuration cfg = buildConfiguration(regionPrefix, InfinispanRegionFactory.class, use2ndLevel, useQueries);
+ cfg.setProperty(InfinispanRegionFactory.INFINISPAN_CONFIG_RESOURCE_PROP,
+ InfinispanRegionFactory.DEF_INFINISPAN_CONFIG_RESOURCE);
+ return cfg;
+ }
+
+ public static InfinispanRegionFactory startRegionFactory(Configuration cfg) throws ClassNotFoundException,
+ InstantiationException, IllegalAccessException {
+
+ Settings settings = cfg.buildSettings();
+ Properties properties = cfg.getProperties();
+
+ String factoryType = cfg.getProperty(Environment.CACHE_REGION_FACTORY);
+ Class factoryClass = Thread.currentThread().getContextClassLoader().loadClass(factoryType);
+ InfinispanRegionFactory regionFactory = (InfinispanRegionFactory) factoryClass.newInstance();
+
+ regionFactory.start(settings, properties);
+
+ return regionFactory;
+ }
+
+ public static InfinispanRegionFactory startRegionFactory(Configuration cfg, CacheTestSupport testSupport)
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+ InfinispanRegionFactory factory = startRegionFactory(cfg);
+ testSupport.registerFactory(factory);
+ return factory;
+ }
+
+ public static void stopRegionFactory(InfinispanRegionFactory factory, CacheTestSupport testSupport) {
+ factory.stop();
+ testSupport.unregisterFactory(factory);
+ }
+
+ /**
+ * Supports easy creation of a TestSuite where a subclass' "FailureExpected" version of a base
+ * test is included in the suite, while the base test is excluded. E.g. test class FooTestCase
+ * includes method testBar(), while test class SubFooTestCase extends FooTestCase includes method
+ * testBarFailureExcluded(). Passing SubFooTestCase.class to this method will return a suite that
+ * does not include testBar().
+ *
+ * FIXME Move this to UnitTestCase
+ */
+ public static TestSuite createFailureExpectedSuite(Class testClass) {
+
+ TestSuite allTests = new TestSuite(testClass);
+ Set failureExpected = new HashSet();
+ Enumeration tests = allTests.tests();
+ while (tests.hasMoreElements()) {
+ Test t = (Test) tests.nextElement();
+ if (t instanceof TestCase) {
+ String name = ((TestCase) t).getName();
+ if (name.endsWith("FailureExpected"))
+ failureExpected.add(name);
+ }
+ }
+
+ TestSuite result = new TestSuite();
+ tests = allTests.tests();
+ while (tests.hasMoreElements()) {
+ Test t = (Test) tests.nextElement();
+ if (t instanceof TestCase) {
+ String name = ((TestCase) t).getName();
+ if (!failureExpected.contains(name + "FailureExpected")) {
+ result.addTest(t);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Prevent instantiation.
+ */
+ private CacheTestUtil() {
+ }
+
+}
15 years, 6 months
Hibernate SVN: r17354 - core/trunk.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-08-18 13:23:57 -0400 (Tue, 18 Aug 2009)
New Revision: 17354
Modified:
core/trunk/pom.xml
Log:
try using release plugin 2.0-beta-9
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2009-08-18 17:09:14 UTC (rev 17353)
+++ core/trunk/pom.xml 2009-08-18 17:23:57 UTC (rev 17354)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0.Beta-1</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>parent/pom.xml</relativePath>
</parent>
@@ -45,7 +45,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
+<!--
<version>2.0-beta-7</version>
+-->
+ <version>2.0-beta-9</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
@@ -83,4 +86,4 @@
</profile>
</profiles>
-</project>
\ No newline at end of file
+</project>
15 years, 6 months
Hibernate SVN: r17353 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-18 13:09:14 -0400 (Tue, 18 Aug 2009)
New Revision: 17353
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java
Log:
HV-203 - the parser does not explicitly close the streams anymore. Also made sure that ValidationExceptions are thrown when gield/getters are defined more than once
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java 2009-08-18 17:08:59 UTC (rev 17352)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java 2009-08-18 17:09:14 UTC (rev 17353)
@@ -17,7 +17,6 @@
*/
package org.hibernate.validation.xml;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.lang.annotation.Annotation;
@@ -26,6 +25,7 @@
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.net.URL;
+import java.security.AccessController;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -33,7 +33,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.security.AccessController;
import javax.validation.Constraint;
import javax.validation.ConstraintValidator;
import javax.validation.ValidationException;
@@ -48,33 +47,20 @@
import org.slf4j.Logger;
import org.xml.sax.SAXException;
+import org.hibernate.validation.metadata.AnnotationIgnores;
import org.hibernate.validation.metadata.ConstraintDescriptorImpl;
-import org.hibernate.validation.metadata.MetaConstraint;
import org.hibernate.validation.metadata.ConstraintHelper;
-import org.hibernate.validation.metadata.AnnotationIgnores;
-import org.hibernate.validation.util.LoggerFactory;
-import org.hibernate.validation.util.ReflectionHelper;
+import org.hibernate.validation.metadata.MetaConstraint;
import org.hibernate.validation.util.ContainsField;
-import org.hibernate.validation.util.GetMethodFromPropertyName;
import org.hibernate.validation.util.ContainsMethod;
-import org.hibernate.validation.util.GetMethod;
-import org.hibernate.validation.util.GetDeclaredField;
import org.hibernate.validation.util.GetClassLoader;
+import org.hibernate.validation.util.GetDeclaredField;
+import org.hibernate.validation.util.GetMethod;
+import org.hibernate.validation.util.GetMethodFromPropertyName;
import org.hibernate.validation.util.LoadClass;
+import org.hibernate.validation.util.LoggerFactory;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
-import org.hibernate.validation.xml.AnnotationType;
-import org.hibernate.validation.xml.BeanType;
-import org.hibernate.validation.xml.ClassType;
-import org.hibernate.validation.xml.ConstraintDefinitionType;
-import org.hibernate.validation.xml.ConstraintMappingsType;
-import org.hibernate.validation.xml.ConstraintType;
-import org.hibernate.validation.xml.ElementType;
-import org.hibernate.validation.xml.FieldType;
-import org.hibernate.validation.xml.GetterType;
-import org.hibernate.validation.xml.GroupSequenceType;
-import org.hibernate.validation.xml.GroupsType;
-import org.hibernate.validation.xml.ValidatedByType;
/**
* @author Hardy Ferentschik
@@ -104,28 +90,18 @@
public void parse(Set<InputStream> mappingStreams) {
for ( InputStream in : mappingStreams ) {
- try {
- ConstraintMappingsType mapping = getValidationConfig( in );
- parseConstraintDefinitions( mapping.getConstraintDefinition() );
- String defaultPackage = mapping.getDefaultPackage();
- for ( BeanType bean : mapping.getBean() ) {
- Class<?> beanClass = getClass( bean.getClazz(), defaultPackage );
- checkClassHasNotBeenProcessed( processedClasses, beanClass );
- annotationIgnores.setDefaultIgnoreAnnotation( beanClass, bean.isIgnoreAnnotations() );
- parseClassLevelOverrides( bean.getClassType(), beanClass, defaultPackage );
- parseFieldLevelOverrides( bean.getField(), beanClass, defaultPackage );
- parsePropertyLevelOverrides( bean.getGetter(), beanClass, defaultPackage );
- processedClasses.add( beanClass );
- }
+ ConstraintMappingsType mapping = getValidationConfig( in );
+ parseConstraintDefinitions( mapping.getConstraintDefinition() );
+ String defaultPackage = mapping.getDefaultPackage();
+ for ( BeanType bean : mapping.getBean() ) {
+ Class<?> beanClass = getClass( bean.getClazz(), defaultPackage );
+ checkClassHasNotBeenProcessed( processedClasses, beanClass );
+ annotationIgnores.setDefaultIgnoreAnnotation( beanClass, bean.isIgnoreAnnotations() );
+ parseClassLevelOverrides( bean.getClassType(), beanClass, defaultPackage );
+ parseFieldLevelOverrides( bean.getField(), beanClass, defaultPackage );
+ parsePropertyLevelOverrides( bean.getGetter(), beanClass, defaultPackage );
+ processedClasses.add( beanClass );
}
- finally {
- try {
- in.close();
- }
- catch ( IOException e ) {
- log.warn( "Error closing input stream: {}", e.getMessage() );
- }
- }
}
}
@@ -141,8 +117,8 @@
List<MetaConstraint<T, ? extends Annotation>> list = new ArrayList<MetaConstraint<T, ? extends Annotation>>();
if ( constraintMap.containsKey( beanClass ) ) {
for ( MetaConstraint<?, ? extends Annotation> metaConstraint : constraintMap.get( beanClass ) ) {
- @SuppressWarnings( "unchecked") // safe cast since the list of meta constraints is always specific to the bean type
- MetaConstraint<T, ? extends Annotation> boundMetaConstraint = ( MetaConstraint<T, ? extends Annotation> ) metaConstraint;
+ @SuppressWarnings("unchecked") // safe cast since the list of meta constraints is always specific to the bean type
+ MetaConstraint<T, ? extends Annotation> boundMetaConstraint = ( MetaConstraint<T, ? extends Annotation> ) metaConstraint;
list.add( boundMetaConstraint );
}
return list;
@@ -210,7 +186,7 @@
private Class<?> loadClass(String className, Class<?> caller) {
LoadClass action = LoadClass.action( className, caller );
- if (System.getSecurityManager() != null) {
+ if ( System.getSecurityManager() != null ) {
return AccessController.doPrivileged( action );
}
else {
@@ -245,8 +221,15 @@
}
private void parseFieldLevelOverrides(List<FieldType> fields, Class<?> beanClass, String defaultPackage) {
+ List<String> fieldNames = new ArrayList<String>();
for ( FieldType fieldType : fields ) {
String fieldName = fieldType.getName();
+ if ( fieldNames.contains( fieldName ) ) {
+ throw new ValidationException( fieldName + "is defined twice in mapping xml." );
+ }
+ else {
+ fieldNames.add( fieldName );
+ }
final boolean containsField;
ContainsField containsAction = ContainsField.action( beanClass, fieldName );
if ( System.getSecurityManager() != null ) {
@@ -289,9 +272,16 @@
}
private void parsePropertyLevelOverrides(List<GetterType> getters, Class<?> beanClass, String defaultPackage) {
+ List<String> getterNames = new ArrayList<String>();
for ( GetterType getterType : getters ) {
String getterName = getterType.getName();
- ContainsMethod cmAction = ContainsMethod.action( beanClass, getterName );
+ if ( getterNames.contains( getterName ) ) {
+ throw new ValidationException( getterName + "is defined twice in mapping xml." );
+ }
+ else {
+ getterNames.add( getterName );
+ }
+ ContainsMethod cmAction = ContainsMethod.action( beanClass, getterName );
boolean containsMethod;
if ( System.getSecurityManager() != null ) {
containsMethod = AccessController.doPrivileged( cmAction );
@@ -400,7 +390,7 @@
for ( ElementType elementType : constraint.getElement() ) {
String name = elementType.getName();
checkNameIsValid( name );
- Class<?> returnType = getAnnotationParamterType( annotationClass, name );
+ Class<?> returnType = getAnnotationParameterType( annotationClass, name );
Object elementValue = getElementValue( elementType, returnType );
annotationDescriptor.setValue( name, elementValue );
}
@@ -420,7 +410,7 @@
return metaConstraint;
}
- private <A extends Annotation> Class<?> getAnnotationParamterType(Class<A> annotationClass, String name) {
+ private <A extends Annotation> Class<?> getAnnotationParameterType(Class<A> annotationClass, String name) {
Method m;
GetMethod action = GetMethod.action( annotationClass, name );
if ( System.getSecurityManager() != null ) {
@@ -431,7 +421,7 @@
}
if ( m == null ) {
- throw new ValidationException( "Annotation of type " + annotationClass.getName() + " does not contain a paramter " + name + "." );
+ throw new ValidationException( "Annotation of type " + annotationClass.getName() + " does not contain a parameter " + name + "." );
}
return m.getReturnType();
}
@@ -488,11 +478,11 @@
returnValue = createAnnotation( annotationType, annotationClass );
}
catch ( ClassCastException e ) {
- throw new ValidationException( "Unexpected paramter value" );
+ throw new ValidationException( "Unexpected parameter value" );
}
}
else {
- throw new ValidationException( "Unexpected paramter value" );
+ throw new ValidationException( "Unexpected parameter value" );
}
return returnValue;
@@ -502,7 +492,7 @@
AnnotationDescriptor<A> annotationDescriptor = new AnnotationDescriptor<A>( returnType );
for ( ElementType elementType : annotationType.getElement() ) {
String name = elementType.getName();
- Class<?> paramterType = getAnnotationParamterType( returnType, name );
+ Class<?> paramterType = getAnnotationParameterType( returnType, name );
Object elementValue = getElementValue( elementType, paramterType );
annotationDescriptor.setValue( name, elementValue );
}
15 years, 6 months
Hibernate SVN: r17352 - in beanvalidation/trunk/validation-tck/src/main: resources and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-18 13:08:59 -0400 (Tue, 18 Aug 2009)
New Revision: 17352
Added:
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleFieldDefinitionTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleGetterDefinitionTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-EmptyXmlConfigurationTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-InvalidXmlConfigurationTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleBeanDefinitionTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleFieldDefinitionTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleGetterDefinitionTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-XmlConfigurationTest.xml
Removed:
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-multiple-field-definitions.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-multiple-getter-definitions.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-invalid-xml.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-bean-definitions.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-field-definitions.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-getter-definitions.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-no-additional-config.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation.xml
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/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/resources/tck-audit.xml
Log:
started cleaning up the xml test
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-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/EmptyXmlConfigurationTest.java 2009-08-18 17:08:59 UTC (rev 17352)
@@ -35,17 +35,17 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
-@ValidationXml(value = "validation-no-additional-config.xml")
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
+@ValidationXml(value = "validation-EmptyXmlConfigurationTest.xml")
@Resource(source = "order-constraints-no-additional-config.xml",
- destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/order-constraints-no-additional-config.xml")
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/order-constraints-no-additional-config.xml")
public class EmptyXmlConfigurationTest extends AbstractTest {
@Test
public void testNoDefinedConstraints() {
Validator validator = TestUtil.getValidatorUnderTest();
assertFalse(
- validator.getConstraintsForClass( Order.class ).isBeanConstrained(), "Bean should be unsonstrained"
+ validator.getConstraintsForClass( Order.class ).isBeanConstrained(), "Bean should be unconstrained"
);
}
}
\ No newline at end of file
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-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/InvalidXmlConfigurationTest.java 2009-08-18 17:08:59 UTC (rev 17352)
@@ -36,7 +36,7 @@
*/
@Artifact(artifactType = ArtifactType.JSR303)
@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
-@ValidationXml(value = "validation-invalid-xml.xml")
+@ValidationXml(value = "validation-InvalidXmlConfigurationTest.xml")
public class InvalidXmlConfigurationTest extends AbstractTest {
@Test
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-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleBeanDefinitionTest.java 2009-08-18 17:08:59 UTC (rev 17352)
@@ -26,8 +26,6 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.testharness.impl.packaging.Resource;
-import org.jboss.testharness.impl.packaging.Resources;
import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
import static org.testng.Assert.fail;
import org.testng.annotations.Test;
@@ -39,15 +37,7 @@
*/
@Artifact(artifactType = ArtifactType.JSR303)
@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
-@ValidationXml(value = "validation-multiple-bean-definitions.xml")
-@Resources(
- {
- @Resource(source = "user-constraints.xml",
- destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints.xml"),
- @Resource(source = "user-constraints-copy.xml",
- destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-copy.xml")
- }
-)
+@ValidationXml(value = "validation-MultipleBeanDefinitionTest.xml")
public class MultipleBeanDefinitionTest extends AbstractTest {
@Test
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-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleFieldDefinitionTest.java 2009-08-18 17:08:59 UTC (rev 17352)
@@ -26,7 +26,6 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.testharness.impl.packaging.Resource;
import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
import static org.testng.Assert.fail;
import org.testng.annotations.Test;
@@ -38,10 +37,7 @@
*/
@Artifact(artifactType = ArtifactType.JSR303)
@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
-@ValidationXml(value = "user-constraints-multiple-field-definitions.xml")
-@Resource(source = "user-constraints-multiple-field-definitions.xml",
- destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-multiple-field-definitions.xml")
-
+@ValidationXml(value = "validation-MultipleFieldDefinitionTest.xml")
public class MultipleFieldDefinitionTest extends AbstractTest {
@Test
@@ -49,10 +45,10 @@
@SpecAssertion(section = "7.1", id = "c"),
@SpecAssertion(section = "7.1", id = "e")
})
- public void testFieldMappingCanotOccurMoreThanOnce() {
+ public void testFieldMappingCannotOccurMoreThanOnce() {
try {
TestUtil.getValidatorUnderTest();
- fail();
+ fail("You should not be able to define multiple field mappings per entity");
}
catch ( ValidationException e ) {
// success
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-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleGetterDefinitionTest.java 2009-08-18 17:08:59 UTC (rev 17352)
@@ -26,7 +26,6 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.testharness.impl.packaging.Resource;
import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
import static org.testng.Assert.fail;
import org.testng.annotations.Test;
@@ -38,10 +37,7 @@
*/
@Artifact(artifactType = ArtifactType.JSR303)
@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
-@ValidationXml(value = "user-constraints-multiple-getter-definitions.xml")
-@Resource(source = "user-constraints-multiple-getter-definitions.xml",
- destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-multiple-getter-definitions.xml")
-
+@ValidationXml(value = "validation-MultipleGetterDefinitionTest.xml")
public class MultipleGetterDefinitionTest extends AbstractTest {
@Test
@@ -49,10 +45,10 @@
@SpecAssertion(section = "7.1", id = "d"),
@SpecAssertion(section = "7.1", id = "e")
})
- public void testGetterMappingCanotOccurMoreThanOnce() {
+ public void testGetterMappingCannotOccurMoreThanOnce() {
try {
TestUtil.getValidatorUnderTest();
- fail();
+ fail("You should not be able to define multiple getter mappings per entity");
}
catch ( ValidationException e ) {
// success
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-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java 2009-08-18 17:08:59 UTC (rev 17352)
@@ -39,7 +39,7 @@
*/
@Artifact(artifactType = ArtifactType.JSR303)
@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
-@ValidationXml(value = "validation.xml")
+@ValidationXml(value = "validation-XmlConfigurationTest.xml")
@Resources(
{
@Resource(source = "user-constraints.xml",
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleFieldDefinitionTest.xml (from rev 17345, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-multiple-field-definitions.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleFieldDefinitionTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleFieldDefinitionTest.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -0,0 +1,19 @@
+<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
+ xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
+ <default-package>org.hibernate.jsr303.tck.tests.xmlconfiguration</default-package>
+ <bean class="User" ignore-annotations="false">
+
+ <field name="lastname">
+ <constraint annotation="javax.validation.constraints.Pattern">
+ <message>Last name has to start with with a capital letter.</message>
+ <element name="regexp">^[A-Z][a-z]+</element>
+ </constraint>
+ </field>
+ <field name="lastname">
+ <constraint annotation="javax.validation.constraints.NotNull">
+ </constraint>
+ </field>
+
+ </bean>
+</constraint-mappings>
Property changes on: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleFieldDefinitionTest.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleGetterDefinitionTest.xml (from rev 17345, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-multiple-getter-definitions.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleGetterDefinitionTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleGetterDefinitionTest.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -0,0 +1,22 @@
+<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
+ xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
+ <default-package>org.hibernate.jsr303.tck.tests.xmlconfiguration</default-package>
+ <bean class="User" ignore-annotations="false">
+ <getter name="firstname" ignore-annotations="true">
+ <constraint annotation="javax.validation.constraints.Size">
+ <message>Size is limited!</message>
+ <groups>
+ <value>org.hibernate.jsr303.tck.tests.xmlconfiguration.TestGroup</value>
+ <value>javax.validation.groups.Default</value>
+ </groups>
+ <element name="max">10</element>
+ </constraint>
+ </getter>
+ <getter name="firstname" ignore-annotations="true">
+ <constraint annotation="javax.validation.constraints.NotNull">
+ <message>Cannot be null</message>
+ </constraint>
+ </getter>
+ </bean>
+</constraint-mappings>
Deleted: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-multiple-field-definitions.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-multiple-field-definitions.xml 2009-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-multiple-field-definitions.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -1,19 +0,0 @@
-<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
- xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
- <default-package>org.hibernate.jsr303.tck.tests.xmlconfiguration</default-package>
- <bean class="User" ignore-annotations="false">
-
- <field name="lastname">
- <constraint annotation="javax.validation.constraints.Pattern">
- <message>Last name has to start with with a capital letter.</message>
- <element name="regexp">^[A-Z][a-z]+</element>
- </constraint>
- </field>
- <field name="lastname">
- <constraint annotation="javax.validation.constraints.NotNull">
- </constraint>
- </field>
-
- </bean>
-</constraint-mappings>
Deleted: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-multiple-getter-definitions.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-multiple-getter-definitions.xml 2009-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-multiple-getter-definitions.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -1,22 +0,0 @@
-<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
- xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
- <default-package>org.hibernate.jsr303.tck.tests.xmlconfiguration</default-package>
- <bean class="User" ignore-annotations="false">
- <getter name="firstname" ignore-annotations="true">
- <constraint annotation="javax.validation.constraints.Size">
- <message>Size is limited!</message>
- <groups>
- <value>org.hibernate.jsr303.tck.tests.xmlconfiguration.TestGroup</value>
- <value>javax.validation.groups.Default</value>
- </groups>
- <element name="max">10</element>
- </constraint>
- </getter>
- <getter name="firstname" ignore-annotations="true">
- <constraint annotation="javax.validation.constraints.NotNull">
- <message>Cannot be null</message>
- </constraint>
- </getter>
- </bean>
-</constraint-mappings>
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-EmptyXmlConfigurationTest.xml (from rev 17345, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-no-additional-config.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-EmptyXmlConfigurationTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-EmptyXmlConfigurationTest.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<validation-config
+ xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd">
+
+ <constraint-mapping>org/hibernate/jsr303/tck/tests/xmlconfiguration/order-constraints-no-additional-config.xml</constraint-mapping>
+</validation-config>
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-EmptyXmlConfigurationTest.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-InvalidXmlConfigurationTest.xml (from rev 17345, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-invalid-xml.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-InvalidXmlConfigurationTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-InvalidXmlConfigurationTest.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+</validation-confi>
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-InvalidXmlConfigurationTest.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleBeanDefinitionTest.xml (from rev 17345, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-bean-definitions.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleBeanDefinitionTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleBeanDefinitionTest.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <constraint-mapping>org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints.xml</constraint-mapping>
+ <constraint-mapping>org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-copy.xml</constraint-mapping>
+</validation-config>
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleBeanDefinitionTest.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleFieldDefinitionTest.xml (from rev 17345, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-field-definitions.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleFieldDefinitionTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleFieldDefinitionTest.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <constraint-mapping>
+ org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleFieldDefinitionTest.xml
+ </constraint-mapping>
+</validation-config>
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleGetterDefinitionTest.xml (from rev 17345, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-getter-definitions.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleGetterDefinitionTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MultipleGetterDefinitionTest.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <constraint-mapping>
+ org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-MultipleGetterDefinitionTest.xml
+ </constraint-mapping>
+</validation-config>
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-XmlConfigurationTest.xml (from rev 17345, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-XmlConfigurationTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-XmlConfigurationTest.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <constraint-mapping>org/hibernate/jsr303/tck/tests/xmlconfiguration/order-constraints.xml</constraint-mapping>
+ <constraint-mapping>org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints.xml</constraint-mapping>
+ <property name="javax.validation.test">foobar</property>
+</validation-config>
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-XmlConfigurationTest.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Deleted: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-invalid-xml.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-invalid-xml.xml 2009-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-invalid-xml.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
- xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-</validation-confi>
\ No newline at end of file
Deleted: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-bean-definitions.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-bean-definitions.xml 2009-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-bean-definitions.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
- xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <constraint-mapping>org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints.xml</constraint-mapping>
- <constraint-mapping>org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-copy.xml</constraint-mapping>
-</validation-config>
\ No newline at end of file
Deleted: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-field-definitions.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-field-definitions.xml 2009-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-field-definitions.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
- xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <constraint-mapping>
- org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-multiple-field-definitions.xml
- </constraint-mapping>
-</validation-config>
\ No newline at end of file
Deleted: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-getter-definitions.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-getter-definitions.xml 2009-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-multiple-getter-definitions.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
- xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <constraint-mapping>
- org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints-multiple-getter-definitions.xml
- </constraint-mapping>
-</validation-config>
\ No newline at end of file
Deleted: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-no-additional-config.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-no-additional-config.xml 2009-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-no-additional-config.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<validation-config
- xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd">
-
- <constraint-mapping>org/hibernate/jsr303/tck/tests/xmlconfiguration/order-constraints-no-additional-config.xml</constraint-mapping>
-</validation-config>
\ No newline at end of file
Deleted: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation.xml 2009-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
- xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <constraint-mapping>org/hibernate/jsr303/tck/tests/xmlconfiguration/order-constraints.xml</constraint-mapping>
- <constraint-mapping>org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints.xml</constraint-mapping>
- <property name="javax.validation.test">foobar</property>
-</validation-config>
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-08-18 15:22:46 UTC (rev 17351)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-08-18 17:08:59 UTC (rev 17352)
@@ -831,12 +831,11 @@
META-INF/validation.xml</text>
</assertion>
<assertion id="b">
- <text>This configuration file is optional but can be used by application to refine some
- of the Bean Validation behavior</text>
+ <text>This configuration file is optional.</text>
</assertion>
<assertion id="c">
- <text>If more than one META-INF/validation.xml file is found in the classpath, a is
- raised</text>
+ <text>If more than one META-INF/validation.xml file is found in the classpath, a
+ ValidationException is raised. </text>
</assertion>
<assertion id="d">
<text>Unless stated otherwise, XML based configuration settings are overridden by values
15 years, 6 months
Hibernate SVN: r17351 - in search/trunk/src: test/java/org/hibernate/search/test/id/providedId and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-18 11:22:46 -0400 (Tue, 18 Aug 2009)
New Revision: 17351
Modified:
search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java
search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdPerson.java
Log:
HSEARCH-394
Changed the way @ProvidedId is picked up
Modified: search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java 2009-08-18 15:21:56 UTC (rev 17350)
+++ search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java 2009-08-18 15:22:46 UTC (rev 17351)
@@ -130,21 +130,21 @@
this.entityState = EntityState.INDEXED;
this.directoryProviders = directoryProviders;
this.shardingStrategy = shardingStrategy;
+ }
- if ( idKeywordName == null ) {
- // if no DocumentId then check if we have a ProvidedId instead
- ProvidedId provided = findProvidedId( clazz, reflectionManager );
- if ( provided == null ) {
- throw new SearchException( "No document id in: " + clazz.getName() );
- }
+ protected void init(XClass clazz, InitContext context) {
+ super.init( clazz, context );
+ // special case @ProvidedId
+ ProvidedId provided = findProvidedId( clazz, reflectionManager );
+ if ( provided != null ) {
idBridge = BridgeFactory.extractTwoWayType( provided.bridge() );
idKeywordName = provided.name();
}
- }
- protected void init(XClass clazz, InitContext context) {
- super.init( clazz, context );
+ if ( idKeywordName == null ) {
+ throw new SearchException( "No document id in: " + clazz.getName() );
+ }
//if composite id, use of (a, b) in ((1,2),(3,4)) fails on most database
//a TwoWayString2FieldBridgeAdaptor is never a composite id
@@ -257,7 +257,7 @@
XClass currentClass = clazz;
while ( id == null && ( !reflectionManager.equals( currentClass, Object.class ) ) ) {
id = currentClass.getAnnotation( ProvidedId.class );
- currentClass = clazz.getSuperclass();
+ currentClass = currentClass.getSuperclass();
}
return id;
}
Modified: search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdPerson.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdPerson.java 2009-08-18 15:21:56 UTC (rev 17350)
+++ search/trunk/src/test/java/org/hibernate/search/test/id/providedId/ProvidedIdPerson.java 2009-08-18 15:22:46 UTC (rev 17351)
@@ -20,8 +20,7 @@
@Id
@GeneratedValue
private long id;
-
-
+
@Field(index = Index.TOKENIZED, store = Store.YES)
private String name;
@Field(index = Index.TOKENIZED, store = Store.YES)
15 years, 6 months
Hibernate SVN: r17350 - search/trunk.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-18 11:21:56 -0400 (Tue, 18 Aug 2009)
New Revision: 17350
Modified:
search/trunk/pom.xml
Log:
Changed the jpa dependecy to the latest deployed version (instead of SNAPSHOT)
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
+++ search/trunk/pom.xml 2009-08-18 15:21:56 UTC (rev 17350)
@@ -79,7 +79,7 @@
<dependency>
<groupId>org.hibernate.java-persistence</groupId>
<artifactId>jpa-api</artifactId>
- <version>2.0.Beta-SNAPSHOT</version>
+ <version>2.0.Beta-20090815</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
15 years, 6 months
Hibernate SVN: r17349 - in core/trunk: annotations and 17 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-08-18 09:48:31 -0400 (Tue, 18 Aug 2009)
New Revision: 17349
Modified:
core/trunk/annotations/pom.xml
core/trunk/cache-ehcache/pom.xml
core/trunk/cache-jbosscache/pom.xml
core/trunk/cache-oscache/pom.xml
core/trunk/cache-swarmcache/pom.xml
core/trunk/connection-c3p0/pom.xml
core/trunk/connection-proxool/pom.xml
core/trunk/core/pom.xml
core/trunk/entitymanager/pom.xml
core/trunk/envers/pom.xml
core/trunk/hibernate-maven-plugin/pom.xml
core/trunk/jmx/pom.xml
core/trunk/parent/pom.xml
core/trunk/pom.xml
core/trunk/testing/pom.xml
core/trunk/testsuite/pom.xml
core/trunk/tutorials/eg/pom.xml
core/trunk/tutorials/pom.xml
core/trunk/tutorials/web/pom.xml
Log:
[maven-release-plugin] prepare release hibernate-3.5.0.Beta-1
Modified: core/trunk/annotations/pom.xml
===================================================================
--- core/trunk/annotations/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/annotations/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -1,37 +1,11 @@
-<?xml version="1.0"?>
-<!--
- ~ Hibernate, Relational Persistence for Idiomatic Java
- ~
- ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- ~ indicated by the @author tags or express copyright attribution
- ~ statements applied by the authors. All third-party contributions are
- ~ distributed under license by Red Hat Middleware LLC.
- ~
- ~ This copyrighted material is made available to anyone wishing to use, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
-<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/xsd/maven-4.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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -242,8 +216,8 @@
<jdbc.driver>org.hsqldb.jdbcDriver</jdbc.driver>
<jdbc.url>jdbc:hsqldb:target/test/db/hsqldb/hibernate</jdbc.url>
<jdbc.user>sa</jdbc.user>
- <jdbc.pass/>
- <jdbc.isolation/>
+ <jdbc.pass />
+ <jdbc.isolation />
</properties>
</profile>
@@ -262,8 +236,8 @@
<jdbc.driver>org.h2.Driver</jdbc.driver>
<jdbc.url>jdbc:h2:mem:target/test/db/h2/hibernate</jdbc.url>
<jdbc.user>sa</jdbc.user>
- <jdbc.pass/>
- <jdbc.isolation/>
+ <jdbc.pass />
+ <jdbc.isolation />
</properties>
</profile>
@@ -291,7 +265,7 @@
<jdbc.url>jdbc:mysql://vmg08.mw.lab.eng.bos.redhat.com/hibbrtru</jdbc.url>
<jdbc.user>hibbrtru</jdbc.user>
<jdbc.pass>hibbrtru</jdbc.pass>
- <jdbc.isolation/>
+ <jdbc.isolation />
</properties>
</profile>
@@ -311,7 +285,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>
@@ -342,7 +316,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>
@@ -367,7 +341,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>
@@ -388,7 +362,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>
@@ -409,7 +383,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>
@@ -429,7 +403,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>
@@ -455,4 +429,4 @@
</profiles>
-</project>
+</project>
\ No newline at end of file
Modified: core/trunk/cache-ehcache/pom.xml
===================================================================
--- core/trunk/cache-ehcache/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/cache-ehcache/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/cache-jbosscache/pom.xml
===================================================================
--- core/trunk/cache-jbosscache/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/cache-jbosscache/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/cache-oscache/pom.xml
===================================================================
--- core/trunk/cache-oscache/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/cache-oscache/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/cache-swarmcache/pom.xml
===================================================================
--- core/trunk/cache-swarmcache/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/cache-swarmcache/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/connection-c3p0/pom.xml
===================================================================
--- core/trunk/connection-c3p0/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/connection-c3p0/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/connection-proxool/pom.xml
===================================================================
--- core/trunk/connection-proxool/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/connection-proxool/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/core/pom.xml
===================================================================
--- core/trunk/core/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/core/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -106,7 +106,7 @@
<targetMembers>
<methodBodyReturn>
<className>org.hibernate.Version</className>
- <methodName>getVersionString</methodName>>
+ <methodName>getVersionString</methodName>>
</methodBodyReturn>
</targetMembers>
</bytecodeInjection>
@@ -171,4 +171,4 @@
<properties>
<antlrPluginVersion>2.1</antlrPluginVersion>
</properties>
-</project>
+</project>
\ No newline at end of file
Modified: core/trunk/entitymanager/pom.xml
===================================================================
--- core/trunk/entitymanager/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/entitymanager/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -1,13 +1,11 @@
-<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/xsd/maven-4.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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -94,12 +92,12 @@
<phase>process-test-classes</phase>
<configuration>
<tasks>
- <property name="package.dir" value="${basedir}/target/test-packages"/>
- <property name="package.tmp.dir" value="${basedir}/target/tmp"/>
- <property name="classes.dir" value="${project.build.directory}/test-classes"/>
- <property name="testresources.dir" value="${basedir}/src/test/resources"/>
+ <property name="package.dir" value="${basedir}/target/test-packages" />
+ <property name="package.tmp.dir" value="${basedir}/target/tmp" />
+ <property name="classes.dir" value="${project.build.directory}/test-classes" />
+ <property name="testresources.dir" value="${basedir}/src/test/resources" />
<ant antfile="${basedir}/build.xml">
- <target name="package"/>
+ <target name="package" />
</ant>
</tasks>
</configuration>
@@ -449,4 +447,4 @@
</profiles>
-</project>
+</project>
\ No newline at end of file
Modified: core/trunk/envers/pom.xml
===================================================================
--- core/trunk/envers/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/envers/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -1,13 +1,11 @@
-<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/xsd/maven-4.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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -154,4 +152,4 @@
<jbossenvers.reports.aggregate>true</jbossenvers.reports.aggregate>
</properties>
-</project>
+</project>
\ No newline at end of file
Modified: core/trunk/hibernate-maven-plugin/pom.xml
===================================================================
--- core/trunk/hibernate-maven-plugin/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/hibernate-maven-plugin/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -20,15 +20,14 @@
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
-->
-<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/xsd/maven-4.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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>hibernate-parent</artifactId>
<groupId>org.hibernate</groupId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/jmx/pom.xml
===================================================================
--- core/trunk/jmx/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/jmx/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -1,37 +1,11 @@
-<?xml version="1.0"?>
-<!--
- ~ Hibernate, Relational Persistence for Idiomatic Java
- ~
- ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- ~ indicated by the @author tags or express copyright attribution
- ~ statements applied by the authors. All third-party contributions are
- ~ distributed under license by Red Hat Middleware LLC.
- ~
- ~ This copyrighted material is made available to anyone wishing to use, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
-<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/xsd/maven-4.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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -49,4 +23,4 @@
<version>${version}</version>
</dependency>
</dependencies>
-</project>
+</project>
\ No newline at end of file
Modified: core/trunk/parent/pom.xml
===================================================================
--- core/trunk/parent/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/parent/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -1,37 +1,11 @@
-<?xml version="1.0"?>
-<!--
- ~ Hibernate, Relational Persistence for Idiomatic Java
- ~
- ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- ~ indicated by the @author tags or express copyright attribution
- ~ statements applied by the authors. All third-party contributions are
- ~ distributed under license by Red Hat Middleware LLC.
- ~
- ~ This copyrighted material is made available to anyone wishing to use, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
-<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/xsd/maven-4.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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
<packaging>pom</packaging>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<name>Hibernate Core Parent POM</name>
<description>The base POM for all Hibernate Core modules.</description>
@@ -56,9 +30,9 @@
</licenses>
<scm>
- <connection>scm:svn:https://svn.jboss.org/repos/hibernate/core/trunk</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/hibernate/core/trunk</developerConnection>
- <url>https://svn.jboss.org/repos/hibernate/core/trunk</url>
+ <connection>scm:svn:https://svn.jboss.org/repos/hibernate/core/tags/hibernate-3.5.0.B...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/hibernate/core/tags/hibernate-3.5.0.B...</developerConnection>
+ <url>https://svn.jboss.org/repos/hibernate/core/tags/hibernate-3.5.0.Beta-1</url>
</scm>
<ciManagement>
@@ -406,4 +380,4 @@
<properties>
<slf4jVersion>1.5.8</slf4jVersion>
</properties>
-</project>
+</project>
\ No newline at end of file
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -1,39 +1,11 @@
-<?xml version="1.0"?>
+<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/xsd/maven-4.0.0.xsd">
-<!--
- ~ Hibernate, Relational Persistence for Idiomatic Java
- ~
- ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- ~ indicated by the @author tags or express copyright attribution
- ~ statements applied by the authors. All third-party contributions are
- ~ distributed under license by Red Hat Middleware LLC.
- ~
- ~ This copyrighted material is made available to anyone wishing to use, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- ~
- -->
-<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/xsd/maven-4.0.0.xsd">
-
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>parent/pom.xml</relativePath>
</parent>
@@ -111,4 +83,4 @@
</profile>
</profiles>
-</project>
+</project>
\ No newline at end of file
Modified: core/trunk/testing/pom.xml
===================================================================
--- core/trunk/testing/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/testing/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/testsuite/pom.xml
===================================================================
--- core/trunk/testsuite/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/testsuite/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/tutorials/eg/pom.xml
===================================================================
--- core/trunk/tutorials/eg/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/tutorials/eg/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -32,7 +32,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tutorials</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../pom.xml</relativePath>
</parent>
Modified: core/trunk/tutorials/pom.xml
===================================================================
--- core/trunk/tutorials/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/tutorials/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/tutorials/web/pom.xml
===================================================================
--- core/trunk/tutorials/web/pom.xml 2009-08-18 12:28:19 UTC (rev 17348)
+++ core/trunk/tutorials/web/pom.xml 2009-08-18 13:48:31 UTC (rev 17349)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tutorials</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>3.5.0.Beta-1</version>
<relativePath>../pom.xml</relativePath>
</parent>
15 years, 6 months