Hibernate SVN: r16824 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/validation and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-17 16:57:08 -0400 (Wed, 17 Jun 2009)
New Revision: 16824
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Man.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Account.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatorImplTest.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
Added @SpecAssertions
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Account.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Account.java 2009-06-17 20:28:59 UTC (rev 16823)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Account.java 2009-06-17 20:57:08 UTC (rev 16824)
@@ -17,8 +17,6 @@
*/
package org.hibernate.jsr303.tck.tests.metadata;
-import javax.validation.Valid;
-
/**
* Class with no constraints but with a cascade @Valid annotation
*/
@@ -35,7 +33,6 @@
this.accountLogin = accountLogin;
}
- @Valid
public Customer getCustomer() {
return customer;
}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java 2009-06-17 20:28:59 UTC (rev 16823)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java 2009-06-17 20:57:08 UTC (rev 16824)
@@ -18,10 +18,12 @@
package org.hibernate.jsr303.tck.tests.metadata;
import java.util.Set;
+import javax.validation.Validator;
import javax.validation.metadata.BeanDescriptor;
import javax.validation.metadata.PropertyDescriptor;
-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;
@@ -44,26 +46,51 @@
public class BeanDescriptorTest extends AbstractTest {
@Test
- public void testIsBeanConstrained() {
+ @SpecAssertion(section = "5.3", id = "a")
+ public void testIsBeanConstrainedDueToValidAnnotation() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
// constraint via @Valid
assertFalse( beanDescriptor.hasConstraints(), "There should be no direct constraints on the specified bean." );
assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted due to @valid " );
+ }
+ @Test
+ @SpecAssertion(section = "5.3", id = "a")
+ public void testIsBeanConstrainedDueToConstraintOnEntity() {
+ Validator validator = TestUtil.getDefaultValidator();
+
// constraint hosted on bean itself
- beanDescriptor = validator.getConstraintsForClass( Account.class );
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Account.class );
assertTrue( beanDescriptor.hasConstraints(), "There should be direct constraints on the specified bean." );
assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted due to @valid" );
+ }
+ @Test
+ @SpecAssertion(section = "5.3", id = "a")
+ public void testIsBeanConstrainedDueToConstraintProperty() {
+ Validator validator = TestUtil.getDefaultValidator();
+
// constraint on bean property
- beanDescriptor = validator.getConstraintsForClass( Order.class );
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
assertFalse( beanDescriptor.hasConstraints(), "There should be no direct constraints on the specified bean." );
assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted due to @NotNull" );
}
@Test
+ @SpecAssertion(section = "5.3", id = "a")
+ public void testIsBeanConstrainedDueToConstraintOnInterface() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ // constraint on implemented interface
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Man.class );
+ assertFalse( beanDescriptor.hasConstraints(), "There should be no direct constraints on the specified bean." );
+ assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted due to constraints on Person." );
+ }
+
+ @Test
+ @SpecAssertion(section = "5.3", id = "a")
public void testUnconstraintClass() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( UnconstraintEntity.class );
@@ -72,23 +99,21 @@
}
@Test
- public void testGetConstraintForExistingConstrainedProperty() {
+ @SpecAssertion(section = "5.3", id = "b")
+ public void testGetConstraintForConstrainedProperty() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderNumber" );
assertEquals(
propertyDescriptor.getConstraintDescriptors().size(), 1, "There should be one constraint descriptor"
);
-
- beanDescriptor = validator.getConstraintsForClass( Customer.class );
- propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList" );
- assertEquals(
- propertyDescriptor.getConstraintDescriptors().size(), 0, "There should be no constraint descriptors"
- );
- assertTrue( propertyDescriptor.isCascaded(), "The property should be cascaded" );
}
@Test
+ @SpecAssertions({
+ @SpecAssertion(section = "5.3", id = "b"),
+ @SpecAssertion(section = "5.4", id = "a")
+ })
public void testGetConstraintForUnConstrainedProperty() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
@@ -100,6 +125,7 @@
}
@Test
+ @SpecAssertion(section = "5.3", id = "b")
public void testGetConstraintsForNonExistingProperty() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java 2009-06-17 20:28:59 UTC (rev 16823)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java 2009-06-17 20:57:08 UTC (rev 16824)
@@ -20,10 +20,11 @@
import java.lang.annotation.Annotation;
import java.util.Map;
import java.util.Set;
-import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
+import javax.validation.metadata.ConstraintDescriptor;
+import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
@@ -116,7 +117,8 @@
}
@Test
- public void testDefaultGroupIsReturned() {
+ @SpecAssertion(section = "5.5", id = "e")
+ public void testDefaultGroupIsReturnedIfNoGroupSpecifiedInDeclaration() {
ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Order.class, "orderNumber" );
Set<Class<?>> groups = descriptor.getGroups();
assertTrue( groups.size() == 1 );
@@ -132,7 +134,8 @@
// }
@Test
- public void testGetAttributes() {
+ @SpecAssertion(section = "5.5", id = "b")
+ public void testGetAttributesFromConstraintDescriptor() {
ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Order.class, "orderNumber" );
Map<String, Object> attributes = descriptor.getAttributes();
assertTrue( attributes.containsKey( "message" ) );
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Man.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Man.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Man.java 2009-06-17 20:57:08 UTC (rev 16824)
@@ -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.metadata;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Man implements Person {
+
+ private String firstName;
+ private String middleName;
+ private String lastName;
+
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getMiddleName() {
+ return middleName;
+ }
+
+ public void setMiddleName(String middleName) {
+ this.middleName = middleName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Man.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatorImplTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatorImplTest.java 2009-06-17 20:28:59 UTC (rev 16823)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatorImplTest.java 2009-06-17 20:57:08 UTC (rev 16824)
@@ -30,6 +30,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.test.audit.annotations.SpecAssertion;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@@ -132,6 +133,7 @@
}
@Test
+ @SpecAssertion(section = "5.1", id="a")
public void testBasicValidation() {
Validator validator = TestUtil.getDefaultValidator();
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-17 20:28:59 UTC (rev 16823)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-17 20:57:08 UTC (rev 16824)
@@ -871,20 +871,20 @@
<section id="5.1" title="Validator">
<assertion id="a">
<text>If a constraint definition or declaration hosted by the requested class (or any of
- it's superclasses and interfaces ac- cording to the constraint propagation rules) is
+ it's superclasses and interfaces according to the constraint propagation rules) is
invalid, a ValidationException is raised</text>
</assertion>
</section>
<section id="5.3" title="BeanDescriptor">
<assertion id="a">
<text>isBeanConstrained returns true if the given class (and superclasses and
- interfaces) host at least one validation de- claration (either constraint or @Valid
+ interfaces) host at least one validation declaration (either constraint or @Valid
annotation)</text>
</assertion>
<assertion id="b">
<text>getConstraintsForProperty returns a PropertyDescriptor object describing the
property level constraints (See Section 3.1.2). The property is uniquely identified
- by its name as per the JavaBeans convention: field level and get- ter level
+ by its name as per the JavaBeans convention: field level and getter level
constraints of the given name are all returned</text>
</assertion>
</section>
@@ -900,7 +900,7 @@
</assertion>
<assertion id="b">
<text>getAttributes returns a map containing the annotation attribute names as a key,
- and the annotation attribute val- ues as a value</text>
+ and the annotation attribute values as a value</text>
</assertion>
<assertion id="c">
<text>If ConstraintDescriptor represents a composing annotation (see Section 2.3), the
@@ -910,7 +910,7 @@
<text>getGroups returns the groups the constraint is supposed to be applied upon</text>
</assertion>
<assertion id="e">
- <text>If no group is set on the constraint de- claration, the Default group is
+ <text>If no group is set on the constraint declaration, the Default group is
returned</text>
</assertion>
<assertion id="f">
15 years, 6 months
Hibernate SVN: r16823 - in core/trunk: testsuite/src/test/java/org/hibernate/test/sql/hand and 7 other directories.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2009-06-17 16:28:59 -0400 (Wed, 17 Jun 2009)
New Revision: 16823
Added:
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/ImageHolder.java
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/TextHolder.java
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sqlserver/
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sqlserver/Mappings.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sqlserver/SQLServerCustomSQLTest.java
Modified:
core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/CustomSQLTestSupport.java
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/db2/Mappings.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/mysql/Mappings.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/oracle/Mappings.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sybase/Mappings.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sybase/SybaseCustomSQLTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/query/NativeSQLQueries.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/query/NativeSQLQueriesTest.java
Log:
HHH-3892 : Add support for "text" and "image" Hibernate types for native SQL queries
Modified: core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java 2009-06-17 15:17:31 UTC (rev 16822)
+++ core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java 2009-06-17 20:28:59 UTC (rev 16823)
@@ -216,6 +216,8 @@
registerHibernateType( Types.TIMESTAMP, Hibernate.TIMESTAMP.getName() );
registerHibernateType( Types.VARCHAR, Hibernate.STRING.getName() );
registerHibernateType( Types.VARBINARY, Hibernate.BINARY.getName() );
+ registerHibernateType( Types.LONGVARCHAR, Hibernate.TEXT.getName() );
+ registerHibernateType( Types.LONGVARBINARY, Hibernate.IMAGE.getName() );
registerHibernateType( Types.NUMERIC, Hibernate.BIG_DECIMAL.getName() );
registerHibernateType( Types.DECIMAL, Hibernate.BIG_DECIMAL.getName() );
registerHibernateType( Types.BLOB, Hibernate.BLOB.getName() );
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/ImageHolder.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/ImageHolder.java (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/ImageHolder.java 2009-06-17 20:28:59 UTC (rev 16823)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2009, 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.sql.hand;
+
+/**
+ * @author Gail Badner
+ */
+public class ImageHolder {
+ private Long id;
+ private byte[] photo;
+
+ public ImageHolder(byte[] photo) {
+ this.photo = photo;
+ }
+
+ public ImageHolder() {
+ }
+
+ /**
+ * @return Returns the id.
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * @param id The id to set.
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Returns the photo.
+ */
+ public byte[] getPhoto() {
+ return photo;
+ }
+
+ /**
+ * @param photo The photo to set.
+ */
+ public void setPhoto(byte[] photo) {
+ this.photo = photo;
+ }
+}
\ No newline at end of file
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/TextHolder.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/TextHolder.java (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/TextHolder.java 2009-06-17 20:28:59 UTC (rev 16823)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2009, 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.sql.hand;
+
+/**
+ * @author Gail Badner
+ */
+public class TextHolder {
+ private Long id;
+ private String description;
+
+ public TextHolder(String description) {
+ this.description = description;
+ }
+
+ public TextHolder() {
+ }
+
+ /**
+ * @return Returns the id.
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * @param id The id to set.
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Returns the description.
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description The description to set.
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
\ No newline at end of file
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/CustomSQLTestSupport.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/CustomSQLTestSupport.java 2009-06-17 15:17:31 UTC (rev 16822)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/CustomSQLTestSupport.java 2009-06-17 20:28:59 UTC (rev 16823)
@@ -7,9 +7,12 @@
import org.hibernate.LockMode;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.util.ArrayHelper;
import org.hibernate.test.sql.hand.Employment;
import org.hibernate.test.sql.hand.Organization;
import org.hibernate.test.sql.hand.Person;
+import org.hibernate.test.sql.hand.TextHolder;
+import org.hibernate.test.sql.hand.ImageHolder;
import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
/**
@@ -91,4 +94,81 @@
s.close();
}
+ public void testTextProperty() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ String description = buildLongString( 15000, 'a' );
+ TextHolder holder = new TextHolder( description );
+ s.save( holder );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ holder = ( TextHolder ) s.get( TextHolder.class, holder.getId() );
+ assertEquals( description, holder.getDescription() );
+ description = buildLongString( 15000, 'b' );
+ holder.setDescription( description );
+ s.save( holder );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ holder = ( TextHolder ) s.get( TextHolder.class, holder.getId() );
+ assertEquals( description, holder.getDescription() );
+ s.delete( holder );
+ t.commit();
+ s.close();
+ }
+
+ public void testImageProperty() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ byte[] photo = buildLongByteArray( 15000, true );
+ ImageHolder holder = new ImageHolder( photo );
+ s.save( holder );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ holder = ( ImageHolder ) s.get( ImageHolder.class, holder.getId() );
+ assertTrue( ArrayHelper.isEquals( photo, holder.getPhoto() ) );
+ photo = buildLongByteArray( 15000, false );
+ holder.setPhoto( photo );
+ s.save( holder );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ holder = ( ImageHolder ) s.get( ImageHolder.class, holder.getId() );
+ assertTrue( ArrayHelper.isEquals( photo, holder.getPhoto() ) );
+ s.delete( holder );
+ t.commit();
+ s.close();
+ }
+
+ private String buildLongString(int size, char baseChar) {
+ StringBuffer buff = new StringBuffer();
+ for( int i = 0; i < size; i++ ) {
+ buff.append( baseChar );
+ }
+ return buff.toString();
+ }
+
+ private byte[] buildLongByteArray(int size, boolean on) {
+ byte[] data = new byte[size];
+ data[0] = mask( on );
+ for ( int i = 0; i < size; i++ ) {
+ data[i] = mask( on );
+ on = !on;
+ }
+ return data;
+ }
+
+ private byte mask(boolean on) {
+ return on ? ( byte ) 1 : ( byte ) 0;
+ }
}
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/db2/Mappings.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/db2/Mappings.hbm.xml 2009-06-17 15:17:31 UTC (rev 16822)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/db2/Mappings.hbm.xml 2009-06-17 20:28:59 UTC (rev 16823)
@@ -65,6 +65,36 @@
<sql-delete>DELETE FROM EMPLOYMENT WHERE EMPID=?</sql-delete>
</class>
+ <class name="TextHolder">
+ <id name="id" column="id">
+ <generator class="increment"/>
+ </id>
+ <property name="description" type="text" length="15000"/>
+ <loader query-ref="textholder"/>
+ <sql-insert>
+ INSERT INTO TEXTHOLDER
+ (DESCRIPTION, ID)
+ VALUES (?, ?)
+ </sql-insert>
+ <sql-update>UPDATE TEXTHOLDER SET DESCRIPTION=? WHERE ID=?</sql-update>
+ <sql-delete>DELETE FROM TEXTHOLDER WHERE ID=?</sql-delete>
+ </class>
+
+ <class name="ImageHolder">
+ <id name="id" column="id">
+ <generator class="increment"/>
+ </id>
+ <property name="photo" type="image" length="15000"/>
+ <loader query-ref="imageholder"/>
+ <sql-insert>
+ INSERT INTO IMAGEHOLDER
+ (PHOTO, ID)
+ VALUES (?, ?)
+ </sql-insert>
+ <sql-update>UPDATE IMAGEHOLDER SET PHOTO=? WHERE ID=?</sql-update>
+ <sql-delete>DELETE FROM IMAGEHOLDER WHERE ID=?</sql-delete>
+ </class>
+
<resultset name="org-emp-regionCode">
<return-scalar column="regionCode" type="string"/>
<return alias="org" class="Organization"/>
@@ -183,6 +213,16 @@
{ call HIBDB2TST.selectAllEmployments() }
</sql-query>
+ <sql-query name="textholder">
+ <return alias="h" class="TextHolder" lock-mode="upgrade"/>
+ SELECT ID AS {h.id}, DESCRIPTION AS {h.description} FROM TEXTHOLDER WHERE ID=? /*FOR UPDATE*/
+ </sql-query>
+
+ <sql-query name="imageholder">
+ <return alias="h" class="ImageHolder" lock-mode="upgrade"/>
+ SELECT ID AS {h.id}, PHOTO AS {h.photo} FROM IMAGEHOLDER WHERE ID=? /*FOR UPDATE*/
+ </sql-query>
+
<!-- DB2 seem to *require* users to specify explicit schema/location when executing a stored procedure *stupid* -->
<database-object>
<create>CREATE SCHEMA HIBDB2TST</create>
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/mysql/Mappings.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/mysql/Mappings.hbm.xml 2009-06-17 15:17:31 UTC (rev 16822)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/mysql/Mappings.hbm.xml 2009-06-17 20:28:59 UTC (rev 16823)
@@ -65,6 +65,36 @@
<sql-delete>DELETE FROM EMPLOYMENT WHERE EMPID=?</sql-delete>
</class>
+ <class name="TextHolder">
+ <id name="id" column="id">
+ <generator class="increment"/>
+ </id>
+ <property name="description" type="text" length="15000"/>
+ <loader query-ref="textholder"/>
+ <sql-insert>
+ INSERT INTO TEXTHOLDER
+ (DESCRIPTION, ID)
+ VALUES (?, ?)
+ </sql-insert>
+ <sql-update>UPDATE TEXTHOLDER SET DESCRIPTION=? WHERE ID=?</sql-update>
+ <sql-delete>DELETE FROM TEXTHOLDER WHERE ID=?</sql-delete>
+ </class>
+
+ <class name="ImageHolder">
+ <id name="id" column="id">
+ <generator class="increment"/>
+ </id>
+ <property name="photo" type="image" length="15000"/>
+ <loader query-ref="imageholder"/>
+ <sql-insert>
+ INSERT INTO IMAGEHOLDER
+ (PHOTO, ID)
+ VALUES (?, ?)
+ </sql-insert>
+ <sql-update>UPDATE IMAGEHOLDER SET PHOTO=? WHERE ID=?</sql-update>
+ <sql-delete>DELETE FROM IMAGEHOLDER WHERE ID=?</sql-delete>
+ </class>
+
<resultset name="org-emp-regionCode">
<return-scalar column="regionCode" type="string"/>
<return alias="org" class="Organization"/>
@@ -180,7 +210,17 @@
</return>
{ call selectAllEmployments() }
</sql-query>
-
+
+ <sql-query name="textholder">
+ <return alias="h" class="TextHolder" lock-mode="upgrade"/>
+ SELECT ID AS {h.id}, DESCRIPTION AS {h.description} FROM TEXTHOLDER WHERE ID=? /*FOR UPDATE*/
+ </sql-query>
+
+ <sql-query name="imageholder">
+ <return alias="h" class="ImageHolder" lock-mode="upgrade"/>
+ SELECT ID AS {h.id}, PHOTO AS {h.photo} FROM IMAGEHOLDER WHERE ID=? /*FOR UPDATE*/
+ </sql-query>
+
<database-object>
<create>
CREATE PROCEDURE selectAllEmployments ()
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/oracle/Mappings.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/oracle/Mappings.hbm.xml 2009-06-17 15:17:31 UTC (rev 16822)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/oracle/Mappings.hbm.xml 2009-06-17 20:28:59 UTC (rev 16823)
@@ -65,6 +65,36 @@
<sql-delete>DELETE FROM EMPLOYMENT WHERE EMPID=?</sql-delete>
</class>
+ <class name="TextHolder">
+ <id name="id" column="id">
+ <generator class="increment"/>
+ </id>
+ <property name="description" type="text" length="15000"/>
+ <loader query-ref="textholder"/>
+ <sql-insert>
+ INSERT INTO TEXTHOLDER
+ (DESCRIPTION, ID)
+ VALUES (?, ?)
+ </sql-insert>
+ <sql-update>UPDATE TEXTHOLDER SET DESCRIPTION=? WHERE ID=?</sql-update>
+ <sql-delete>DELETE FROM TEXTHOLDER WHERE ID=?</sql-delete>
+ </class>
+
+ <class name="ImageHolder">
+ <id name="id" column="id">
+ <generator class="increment"/>
+ </id>
+ <property name="photo" type="image" length="15000"/>
+ <loader query-ref="imageholder"/>
+ <sql-insert>
+ INSERT INTO IMAGEHOLDER
+ (PHOTO, ID)
+ VALUES (?, ?)
+ </sql-insert>
+ <sql-update>UPDATE IMAGEHOLDER SET PHOTO=? WHERE ID=?</sql-update>
+ <sql-delete>DELETE FROM IMAGEHOLDER WHERE ID=?</sql-delete>
+ </class>
+
<resultset name="org-emp-regionCode">
<return-scalar column="regionCode" type="string"/>
<return alias="org" class="Organization"/>
@@ -139,6 +169,16 @@
ORDER BY STARTDATE ASC
</sql-query>
+ <sql-query name="textholder">
+ <return alias="h" class="TextHolder" lock-mode="upgrade"/>
+ SELECT ID AS {h.id}, DESCRIPTION AS {h.description} FROM TEXTHOLDER WHERE ID=? /*FOR UPDATE*/
+ </sql-query>
+
+ <sql-query name="imageholder">
+ <return alias="h" class="ImageHolder" lock-mode="upgrade"/>
+ SELECT ID AS {h.id}, PHOTO AS {h.photo} FROM IMAGEHOLDER WHERE ID=? /*FOR UPDATE*/
+ </sql-query>
+
<database-object>
<create>
CREATE OR REPLACE FUNCTION testParamHandling (j number, i number)
@@ -202,7 +242,7 @@
END;
</create>
<drop>
- DROP PROCEDURE createPerson;
+ DROP PROCEDURE createPerson
</drop>
</database-object>
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sqlserver/Mappings.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sqlserver/Mappings.hbm.xml (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sqlserver/Mappings.hbm.xml 2009-06-17 20:28:59 UTC (rev 16823)
@@ -0,0 +1,287 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+ This mapping demonstrates the use of Hibernate with all-handwritten SQL!
+
+ NOTE: this version is for SQLServer
+-->
+<hibernate-mapping package="org.hibernate.test.sql.hand" default-access="field">
+
+ <class name="Organization" table="ORGANIZATION">
+ <id name="id" unsaved-value="0" column="ORGID">
+ <generator class="increment"/>
+ </id>
+ <property name="name" not-null="true" column="NAME"/>
+ <set name="employments"
+ inverse="true"
+ order-by="DUMMY">
+ <key column="EMPLOYER"/> <!-- only needed for DDL generation -->
+ <one-to-many class="Employment"/>
+ <loader query-ref="organizationEmployments"/>
+ </set>
+ <!-- query-list name="currentEmployments"
+ query-ref="organizationCurrentEmployments"-->
+ <loader query-ref="organization"/>
+ <sql-insert>INSERT INTO ORGANIZATION (NAME, ORGID) VALUES ( UPPER(?), ? )</sql-insert>
+ <sql-update>UPDATE ORGANIZATION SET NAME=UPPER(?) WHERE ORGID=?</sql-update>
+ <sql-delete>DELETE FROM ORGANIZATION WHERE ORGID=?</sql-delete>
+ </class>
+
+ <class name="Person" table="PERSON">
+ <id name="id" unsaved-value="0" column="PERID">
+ <generator class="increment"/>
+ </id>
+ <property name="name" not-null="true" column="NAME"/>
+ <loader query-ref="person"/>
+ <sql-insert>INSERT INTO PERSON (NAME, PERID) VALUES ( UPPER(?), ? )</sql-insert>
+ <sql-update>UPDATE PERSON SET NAME=UPPER(?) WHERE PERID=?</sql-update>
+ <sql-delete>DELETE FROM PERSON WHERE PERID=?</sql-delete>
+ </class>
+
+ <class name="Employment" table="EMPLOYMENT">
+ <id name="employmentId" unsaved-value="0" column="EMPID">
+ <generator class="increment"/>
+ </id>
+ <many-to-one name="employee" column="EMPLOYEE" not-null="true" update="false"/>
+ <many-to-one name="employer" column="EMPLOYER" not-null="true" update="false"/>
+ <property name="startDate" column="STARTDATE" not-null="true" update="false" insert="false"/>
+ <property name="endDate" column="ENDDATE" insert="false"/>
+ <property name="regionCode" column="REGIONCODE" update="false"/>
+ <property name="salary" type="org.hibernate.test.sql.hand.MonetaryAmountUserType">
+ <column name="VALUE" sql-type="float"/>
+ <column name="CURRENCY"/>
+ </property>
+ <loader query-ref="employment"/>
+ <sql-insert>
+ INSERT INTO EMPLOYMENT
+ (EMPLOYEE, EMPLOYER, STARTDATE, REGIONCODE, VALUE, CURRENCY, EMPID)
+ VALUES (?, ?, getdate(), UPPER(?), ?, ?, ?)
+ </sql-insert>
+ <sql-update>UPDATE EMPLOYMENT SET ENDDATE=?, VALUE=?, CURRENCY=? WHERE EMPID=?</sql-update>
+ <sql-delete>DELETE FROM EMPLOYMENT WHERE EMPID=?</sql-delete>
+ </class>
+
+ <class name="TextHolder">
+ <id name="id" column="id">
+ <generator class="increment"/>
+ </id>
+ <property name="description" type="text" length="15000"/>
+ <loader query-ref="textholder"/>
+ <sql-insert>
+ INSERT INTO TEXTHOLDER
+ (DESCRIPTION, ID)
+ VALUES (?, ?)
+ </sql-insert>
+ <sql-update>UPDATE TEXTHOLDER SET DESCRIPTION=? WHERE ID=?</sql-update>
+ <sql-delete>DELETE FROM TEXTHOLDER WHERE ID=?</sql-delete>
+ </class>
+
+ <class name="ImageHolder">
+ <id name="id" column="id">
+ <generator class="increment"/>
+ </id>
+ <property name="photo" type="image" length="15000"/>
+ <loader query-ref="imageholder"/>
+ <sql-insert>
+ INSERT INTO IMAGEHOLDER
+ (PHOTO, ID)
+ VALUES (?, ?)
+ </sql-insert>
+ <sql-update>UPDATE IMAGEHOLDER SET PHOTO=? WHERE ID=?</sql-update>
+ <sql-delete>DELETE FROM IMAGEHOLDER WHERE ID=?</sql-delete>
+ </class>
+
+ <resultset name="org-emp-regionCode">
+ <return-scalar column="regionCode" type="string"/>
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.employments"/>
+ </resultset>
+
+ <resultset name="org-emp-person">
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.employments"/>
+ <return-join alias="pers" property="emp.employee"/>
+ </resultset>
+
+ <sql-query name="person">
+ <return alias="p" class="Person" lock-mode="upgrade"/>
+ SELECT NAME AS {p.name}, PERID AS {p.id} FROM PERSON WHERE PERID=? /*FOR UPDATE*/
+ </sql-query>
+
+ <sql-query name="organization">
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.employments"/>
+ SELECT {org.*}, {emp.*}
+ FROM ORGANIZATION org
+ LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID = emp.EMPLOYER
+ WHERE org.ORGID=?
+ </sql-query>
+
+
+ <!--sql-query name="organization">
+ <return alias="org" class="Organization"/>
+ SELECT NAME AS {org.name}, ORGID AS {org.id} FROM ORGANIZATION
+ WHERE ORGID=?
+ </sql-query-->
+
+ <sql-query name="allOrganizationsWithEmployees" flush-mode="never">
+ <return alias="org" class="Organization"/>
+ SELECT DISTINCT org.NAME AS {org.name}, org.ORGID AS {org.id}
+ FROM ORGANIZATION org
+ INNER JOIN EMPLOYMENT e ON e.EMPLOYER = org.ORGID
+ </sql-query>
+
+
+
+
+
+ <sql-query name="employment">
+ <return alias="emp" class="Employment"/>
+ SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer},
+ STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate},
+ REGIONCODE as {emp.regionCode}, EMPID AS {emp.id}
+ FROM EMPLOYMENT
+ WHERE EMPID = ?
+ </sql-query>
+
+ <sql-query name="organizationEmployments">
+ <load-collection alias="empcol" role="Organization.employments"/>
+ SELECT {empcol.*}
+ FROM EMPLOYMENT empcol
+ WHERE EMPLOYER = :id
+ ORDER BY STARTDATE ASC, EMPLOYEE ASC
+ </sql-query>
+
+
+ <sql-query name="organizationCurrentEmployments">
+ <return alias="emp" class="Employment">
+ <return-property name="salary">
+ <!-- as multi column properties are not supported via the
+ {}-syntax, we need to provide an explicit column list for salary via <return-property> -->
+ <return-column name="VALUE"/>
+ <return-column name="CURRENCY"/>
+ </return-property>
+ <!-- Here we are remapping endDate. Notice that we can still use {emp.endDate} in the SQL. -->
+ <return-property name="endDate" column="myEndDate"/>
+ </return>
+ <synchronize table="EMPLOYMENT"/>
+ SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer},
+ STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate},
+ REGIONCODE as {emp.regionCode}, EMPID AS {emp.id}, VALUE, CURRENCY
+ FROM EMPLOYMENT
+ WHERE EMPLOYER = :id AND ENDDATE IS NULL
+ ORDER BY STARTDATE ASC
+ </sql-query>
+
+ <sql-query name="simpleScalar" callable="true">
+ <return-scalar column="name" type="string"/>
+ <return-scalar column="value" type="long"/>
+ { call simpleScalar(:number) }
+ </sql-query>
+
+ <sql-query name="paramhandling" callable="true">
+ <return-scalar column="value" type="long"/>
+ <return-scalar column="value2" type="long"/>
+ { call paramHandling(?,?) }
+ </sql-query>
+
+ <sql-query name="paramhandling_mixed" callable="true">
+ <return-scalar column="value" type="long" />
+ <return-scalar column="value2" type="long" />
+ { call paramHandling(?,:second) }
+ </sql-query>
+
+ <sql-query name="selectAllEmployments" callable="true">
+ <return alias="" class="Employment">
+ <return-property name="employee" column="EMPLOYEE"/>
+ <return-property name="employer" column="EMPLOYER"/>
+ <return-property name="startDate" column="STARTDATE"/>
+ <return-property name="endDate" column="ENDDATE"/>
+ <return-property name="regionCode" column="REGIONCODE"/>
+ <return-property name="id" column="EMPID"/>
+ <return-property name="salary">
+ <!-- as multi column properties are not supported via the
+ {}-syntax, we need to provide an explicit column list for salary via <return-property> -->
+ <return-column name="VALUE"/>
+ <return-column name="CURRENCY"/>
+ </return-property>
+ </return>
+ { call selectAllEmployments() }
+ </sql-query>
+
+ <sql-query name="textholder">
+ <return alias="h" class="TextHolder" lock-mode="upgrade"/>
+ SELECT ID AS {h.id}, DESCRIPTION AS {h.description} FROM TEXTHOLDER WHERE ID=? /*FOR UPDATE*/
+ </sql-query>
+
+ <sql-query name="imageholder">
+ <return alias="h" class="ImageHolder" lock-mode="upgrade"/>
+ SELECT ID AS {h.id}, PHOTO AS {h.photo} FROM IMAGEHOLDER WHERE ID=? /*FOR UPDATE*/
+ </sql-query>
+
+ <database-object>
+ <create>
+ CREATE PROCEDURE selectAllEmployments AS
+ SELECT EMPLOYEE, EMPLOYER, STARTDATE, ENDDATE,
+ REGIONCODE, EMPID, VALUE, CURRENCY
+ FROM EMPLOYMENT
+ </create>
+ <drop>
+ DROP PROCEDURE selectAllEmployments
+ </drop>
+ </database-object>
+
+ <!-- The following is a workaround for HHH-3685 so that SchemaExport -->
+ <!-- changes the transaction mode of selectAllEmployments to "chained" -->
+ <database-object>
+ <create>
+ sp_procxmode selectAllEmployments, 'chained'
+ </create>
+ <!-- no drop command corresponding to "sp_procxmode ..." -->
+ <drop/>
+ </database-object>
+
+ <database-object>
+ <create>
+ CREATE PROCEDURE paramHandling @j int, @i int AS
+ SELECT @j as value, @i as value2
+ </create>
+ <drop>
+ DROP PROCEDURE paramHandling
+ </drop>
+ </database-object>
+
+ <!-- The following is a workaround for HHH-3685 so that SchemaExport -->
+ <!-- changes the transaction mode of paramHandling to "chained" -->
+ <database-object>
+ <create>
+ sp_procxmode paramHandling, 'chained'
+ </create>
+ <!-- no drop command corresponding to "sp_procxmode ..." -->
+ <drop/>
+ </database-object>
+
+ <database-object>
+ <create>
+ CREATE PROCEDURE simpleScalar @number int AS
+ SELECT @number as value, 'getAll' as name
+ </create>
+ <drop>
+ DROP PROCEDURE simpleScalar
+ </drop>
+ </database-object>
+
+ <!-- The following is a workaround for HHH-3685 so that SchemaExport -->
+ <!-- changes the transaction mode of simpleScalar to "chained" -->
+ <database-object>
+ <create>
+ sp_procxmode simpleScalar, 'chained'
+ </create>
+ <!-- no drop command corresponding to "sp_procxmode ..." -->
+ <drop/>
+ </database-object>
+
+</hibernate-mapping>
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sqlserver/SQLServerCustomSQLTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sqlserver/SQLServerCustomSQLTest.java (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sqlserver/SQLServerCustomSQLTest.java 2009-06-17 20:28:59 UTC (rev 16823)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2009, 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.sql.hand.custom.sqlserver;
+
+import junit.framework.Test;
+
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.SQLServerDialect;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.test.sql.hand.custom.CustomStoredProcTestSupport;
+
+/**
+ * Custom SQL tests for SQLServer
+ *
+ * @author Gail Badner
+ */
+public class SQLServerCustomSQLTest extends CustomStoredProcTestSupport {
+
+ public SQLServerCustomSQLTest(String str) {
+ super( str );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "sql/hand/custom/sqlserver/Mappings.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SQLServerCustomSQLTest.class );
+ }
+
+ public boolean appliesTo(Dialect dialect) {
+ return ( dialect instanceof SQLServerDialect );
+ }
+}
\ No newline at end of file
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sybase/Mappings.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sybase/Mappings.hbm.xml 2009-06-17 15:17:31 UTC (rev 16822)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sybase/Mappings.hbm.xml 2009-06-17 20:28:59 UTC (rev 16823)
@@ -6,7 +6,7 @@
<!--
This mapping demonstrates the use of Hibernate with all-handwritten SQL!
- NOTE: this version is for Sybase/SQLServer
+ NOTE: this version is for Sybase
-->
<hibernate-mapping package="org.hibernate.test.sql.hand" default-access="field">
@@ -64,6 +64,36 @@
<sql-delete>DELETE FROM EMPLOYMENT WHERE EMPID=?</sql-delete>
</class>
+ <class name="TextHolder">
+ <id name="id" column="id">
+ <generator class="increment"/>
+ </id>
+ <property name="description" type="text" length="15000"/>
+ <loader query-ref="textholder"/>
+ <sql-insert>
+ INSERT INTO TEXTHOLDER
+ (DESCRIPTION, ID)
+ VALUES (?, ?)
+ </sql-insert>
+ <sql-update>UPDATE TEXTHOLDER SET DESCRIPTION=? WHERE ID=?</sql-update>
+ <sql-delete>DELETE FROM TEXTHOLDER WHERE ID=?</sql-delete>
+ </class>
+
+ <class name="ImageHolder">
+ <id name="id" column="id">
+ <generator class="increment"/>
+ </id>
+ <property name="photo" type="image" length="15000"/>
+ <loader query-ref="imageholder"/>
+ <sql-insert>
+ INSERT INTO IMAGEHOLDER
+ (PHOTO, ID)
+ VALUES (?, ?)
+ </sql-insert>
+ <sql-update>UPDATE IMAGEHOLDER SET PHOTO=? WHERE ID=?</sql-update>
+ <sql-delete>DELETE FROM IMAGEHOLDER WHERE ID=?</sql-delete>
+ </class>
+
<resultset name="org-emp-regionCode">
<return-scalar column="regionCode" type="string"/>
<return alias="org" class="Organization"/>
@@ -181,7 +211,17 @@
</return>
{ call selectAllEmployments() }
</sql-query>
-
+
+ <sql-query name="textholder">
+ <return alias="h" class="TextHolder" lock-mode="upgrade"/>
+ SELECT ID AS {h.id}, DESCRIPTION AS {h.description} FROM TEXTHOLDER WHERE ID=? /*FOR UPDATE*/
+ </sql-query>
+
+ <sql-query name="imageholder">
+ <return alias="h" class="ImageHolder" lock-mode="upgrade"/>
+ SELECT ID AS {h.id}, PHOTO AS {h.photo} FROM IMAGEHOLDER WHERE ID=? /*FOR UPDATE*/
+ </sql-query>
+
<database-object>
<create>
CREATE PROCEDURE selectAllEmployments AS
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sybase/SybaseCustomSQLTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sybase/SybaseCustomSQLTest.java 2009-06-17 15:17:31 UTC (rev 16822)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/custom/sybase/SybaseCustomSQLTest.java 2009-06-17 20:28:59 UTC (rev 16823)
@@ -5,11 +5,14 @@
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.SybaseDialect;
+import org.hibernate.dialect.SybaseASE15Dialect;
+import org.hibernate.dialect.Sybase11Dialect;
+import org.hibernate.dialect.SybaseAnywhereDialect;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.test.sql.hand.custom.CustomStoredProcTestSupport;
/**
- * Custom SQL tests for Sybase/SQLServer (Transact-SQL)
+ * Custom SQL tests for Sybase dialects
*
* @author Gavin King
*/
@@ -28,7 +31,10 @@
}
public boolean appliesTo(Dialect dialect) {
- return ( dialect instanceof SybaseDialect );
+ return ( dialect instanceof SybaseDialect ||
+ dialect instanceof SybaseASE15Dialect ||
+ dialect instanceof Sybase11Dialect ||
+ dialect instanceof SybaseAnywhereDialect );
}
}
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/query/NativeSQLQueries.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/query/NativeSQLQueries.hbm.xml 2009-06-17 15:17:31 UTC (rev 16822)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/query/NativeSQLQueries.hbm.xml 2009-06-17 20:28:59 UTC (rev 16823)
@@ -117,6 +117,20 @@
<property name="length" column="flength"/>
</class>
+ <class name="TextHolder">
+ <id name="id" column="id">
+ <generator class="increment"/>
+ </id>
+ <property name="description" type="text" length="15000"/>
+ </class>
+
+ <class name="ImageHolder">
+ <id name="id" column="id">
+ <generator class="increment"/>
+ </id>
+ <property name="photo" type="image" length="15000"/>
+ </class>
+
<resultset name="org-emp-regionCode">
<return-scalar column="regionCode" type="string"/>
<return alias="org" class="Organization"/>
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/query/NativeSQLQueriesTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/query/NativeSQLQueriesTest.java 2009-06-17 15:17:31 UTC (rev 16822)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/sql/hand/query/NativeSQLQueriesTest.java 2009-06-17 20:28:59 UTC (rev 16823)
@@ -15,6 +15,7 @@
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.util.ArrayHelper;
import org.hibernate.test.sql.hand.Organization;
import org.hibernate.test.sql.hand.Person;
import org.hibernate.test.sql.hand.Employment;
@@ -24,6 +25,8 @@
import org.hibernate.test.sql.hand.SpaceShip;
import org.hibernate.test.sql.hand.Speech;
import org.hibernate.test.sql.hand.Group;
+import org.hibernate.test.sql.hand.TextHolder;
+import org.hibernate.test.sql.hand.ImageHolder;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.junit.functional.FunctionalTestCase;
@@ -96,6 +99,14 @@
" join PERSON pers on pers.PERID = emp.EMPLOYEE ";
}
+ protected String getDescriptionsSQL() {
+ return "select DESCRIPTION from TEXTHOLDER";
+ }
+
+ protected String getPhotosSQL() {
+ return "select PHOTO from IMAGEHOLDER";
+ }
+
public void testFailOnNoAddEntityOrScalar() {
// Note: this passes, but for the wrong reason.
// there is actually an exception thrown, but it is the database
@@ -668,6 +679,66 @@
s.close();
}
+ public void testTextTypeInSQLQuery() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ String description = buildLongString( 15000, 'a' );
+ TextHolder holder = new TextHolder( description );
+ s.persist( holder );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ String descriptionRead = ( String ) s.createSQLQuery( getDescriptionsSQL() )
+ .uniqueResult();
+ assertEquals( description, descriptionRead );
+ s.delete( holder );
+ t.commit();
+ s.close();
+ }
+
+ public void testImageTypeInSQLQuery() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ byte[] photo = buildLongByteArray( 15000, true );
+ ImageHolder holder = new ImageHolder( photo );
+ s.persist( holder );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ byte[] photoRead = ( byte[] ) s.createSQLQuery( getPhotosSQL() )
+ .uniqueResult();
+ assertTrue( ArrayHelper.isEquals( photo, photoRead ) );
+ s.delete( holder );
+ t.commit();
+ s.close();
+ }
+
+ private String buildLongString(int size, char baseChar) {
+ StringBuffer buff = new StringBuffer();
+ for( int i = 0; i < size; i++ ) {
+ buff.append( baseChar );
+ }
+ return buff.toString();
+ }
+
+ private byte[] buildLongByteArray(int size, boolean on) {
+ byte[] data = new byte[size];
+ data[0] = mask( on );
+ for ( int i = 0; i < size; i++ ) {
+ data[i] = mask( on );
+ on = !on;
+ }
+ return data;
+ }
+
+ private byte mask(boolean on) {
+ return on ? ( byte ) 1 : ( byte ) 0;
+ }
+
private static class UpperCasedAliasToEntityMapResultTransformer extends BasicTransformerAdapter implements Serializable {
public Object transformTuple(Object[] tuple, String[] aliases) {
Map result = new HashMap( tuple.length );
15 years, 6 months
Hibernate SVN: r16822 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-17 11:17:31 -0400 (Wed, 17 Jun 2009)
New Revision: 16822
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ConstraintDescriptorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ConstraintHelper.java
Log:
HV-169 HV-140
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ConstraintDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ConstraintDescriptorImpl.java 2009-06-17 15:12:54 UTC (rev 16821)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ConstraintDescriptorImpl.java 2009-06-17 15:17:31 UTC (rev 16822)
@@ -122,20 +122,20 @@
}
private void findConstraintValidatorClasses() {
- if ( constraintHelper.containsConstraintValidatorDefinition( annotation.annotationType() ) ) {
- for ( Class<? extends ConstraintValidator<? extends Annotation, ?>> validator : constraintHelper
- .getConstraintValidatorDefinition( annotation.annotationType() ) ) {
- constraintValidatorDefinitonClasses.add( ( Class<? extends ConstraintValidator<T, ?>> ) validator );
+ final Class<T> annotationType = getAnnotationType();
+ if ( constraintHelper.containsConstraintValidatorDefinition( annotationType ) ) {
+ for ( Class<? extends ConstraintValidator<T, ?>> validator : constraintHelper
+ .getConstraintValidatorDefinition( annotationType ) ) {
+ constraintValidatorDefinitonClasses.add( validator );
}
return;
}
List<Class<? extends ConstraintValidator<? extends Annotation, ?>>> constraintDefinitonClasses = new ArrayList<Class<? extends ConstraintValidator<? extends Annotation, ?>>>();
if ( constraintHelper.isBuiltinConstraint( annotation.annotationType() ) ) {
- constraintDefinitonClasses.addAll( constraintHelper.getBuiltInConstraints( annotation.annotationType() ) );
+ constraintDefinitonClasses.addAll( constraintHelper.getBuiltInConstraints( annotationType ) );
}
else {
- final Class<? extends Annotation> annotationType = annotation.annotationType();
Class<? extends ConstraintValidator<?, ?>>[] validatedBy = annotationType
.getAnnotation( Constraint.class )
.validatedBy();
@@ -153,6 +153,11 @@
}
}
+ @SuppressWarnings("unchecked")
+ private Class<T> getAnnotationType() {
+ return ( Class<T> ) annotation.annotationType();
+ }
+
public T getAnnotation() {
return annotation;
}
@@ -354,6 +359,7 @@
}
@Override
+ @SuppressWarnings("SimplifiableIfStatement")
public boolean equals(Object o) {
if ( this == o ) {
return true;
@@ -362,7 +368,8 @@
return false;
}
- ClassIndexWrapper that = ( ClassIndexWrapper ) o;
+ @SuppressWarnings("unchecked") // safe due to the check above
+ ClassIndexWrapper that = ( ClassIndexWrapper ) o;
if ( index != that.index ) {
return false;
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ConstraintHelper.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ConstraintHelper.java 2009-06-17 15:12:54 UTC (rev 16821)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ConstraintHelper.java 2009-06-17 15:17:31 UTC (rev 16822)
@@ -22,7 +22,6 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.validation.Constraint;
import javax.validation.ConstraintDefinitionException;
@@ -82,10 +81,10 @@
*/
public class ConstraintHelper {
- private final Map<Class<? extends Annotation>, List<Class<? extends ConstraintValidator<?, ?>>>> builtinConstraints =
+ private final ConcurrentHashMap<Class<? extends Annotation>, List<Class<? extends ConstraintValidator<?, ?>>>> builtinConstraints =
new ConcurrentHashMap<Class<? extends Annotation>, List<Class<? extends ConstraintValidator<?, ?>>>>();
- private final Map<Class<? extends Annotation>, List<Class<? extends ConstraintValidator<? extends Annotation, ?>>>> constraintValidatorDefinitons =
+ private final ConcurrentHashMap<Class<? extends Annotation>, List<Class<? extends ConstraintValidator<? extends Annotation, ?>>>> constraintValidatorDefinitons =
new ConcurrentHashMap<Class<? extends Annotation>, List<Class<? extends ConstraintValidator<? extends Annotation, ?>>>>();
public ConstraintHelper() {
@@ -160,14 +159,13 @@
builtinConstraints.put( Size.class, constraintList );
}
- public List<Class<? extends ConstraintValidator<? extends Annotation, ?>>> getBuiltInConstraints(Class<? extends Annotation> annotationType) {
- final List<Class<? extends ConstraintValidator<?, ?>>> builtInList = getBuiltInFromAnnotationType(
- annotationType
- );
+ public List<Class<? extends ConstraintValidator<? extends Annotation, ?>>> getBuiltInConstraints(Class<? extends Annotation> annotationClass) {
+ final List<Class<? extends ConstraintValidator<?, ?>>> builtInList = builtinConstraints.get( annotationClass );
if ( builtInList == null || builtInList.size() == 0 ) {
- throw new ValidationException( "Unable to find constraints for " + annotationType );
+ throw new ValidationException( "Unable to find constraints for " + annotationClass );
}
+
List<Class<? extends ConstraintValidator<? extends Annotation, ?>>> constraints =
new ArrayList<Class<? extends ConstraintValidator<? extends Annotation, ?>>>( builtInList.size() );
for ( Class<? extends ConstraintValidator<?, ?>> validatorClass : builtInList ) {
@@ -180,10 +178,6 @@
return constraints;
}
- private List<Class<? extends ConstraintValidator<?, ?>>> getBuiltInFromAnnotationType(Class<? extends Annotation> annotationType) {
- return builtinConstraints.get( annotationType );
- }
-
public boolean isBuiltinConstraint(Class<? extends Annotation> annotationType) {
return builtinConstraints.containsKey( annotationType );
}
@@ -318,15 +312,27 @@
return true;
}
- public List<Class<? extends ConstraintValidator<? extends Annotation, ?>>> getConstraintValidatorDefinition(Class<? extends Annotation> annotationClass) {
+ public <T extends Annotation> List<Class<? extends ConstraintValidator<T, ?>>> getConstraintValidatorDefinition(Class<T> annotationClass) {
if ( annotationClass == null ) {
throw new IllegalArgumentException( "Class cannot be null" );
}
- return constraintValidatorDefinitons.get( annotationClass );
+
+ final List<Class<? extends ConstraintValidator<? extends Annotation, ?>>> list = constraintValidatorDefinitons.get( annotationClass );
+
+ List<Class<? extends ConstraintValidator<T, ?>>> constraintsValidators =
+ new ArrayList<Class<? extends ConstraintValidator<T, ?>>>( list.size() );
+ for ( Class<? extends ConstraintValidator<?, ?>> validatorClass : list ) {
+ //safe cause all CV for a given annotation A are CV<A, ?>
+ @SuppressWarnings("unchecked")
+ Class<ConstraintValidator<T, ?>> safeValdiatorClass = ( Class<ConstraintValidator<T, ?>> ) validatorClass;
+ constraintsValidators.add( safeValdiatorClass );
+ }
+
+ return constraintsValidators;
}
public <A extends Annotation> void addConstraintValidatorDefinition(Class<A> annotationClass, List<Class<? extends ConstraintValidator<? extends Annotation, ?>>> definitionClasses) {
- constraintValidatorDefinitons.put( annotationClass, definitionClasses );
+ constraintValidatorDefinitons.putIfAbsent( annotationClass, definitionClasses );
}
public boolean containsConstraintValidatorDefinition(Class<? extends Annotation> annotationClass) {
15 years, 6 months
Hibernate SVN: r16821 - core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional.
by hibernate-commits@lists.jboss.org
Author: cbredesen
Date: 2009-06-17 11:12:54 -0400 (Wed, 17 Jun 2009)
New Revision: 16821
Added:
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/BasicReadOnlyTestCase.java
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java
Removed:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicCacheTest.java
Log:
Split tests into read-only and transactional
Copied: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractInfinispanTestCase.java (from rev 16796, core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicCacheTest.java)
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractInfinispanTestCase.java (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/AbstractInfinispanTestCase.java 2009-06-17 15:12:54 UTC (rev 16821)
@@ -0,0 +1,94 @@
+package org.hibernate.test.cache.infinispan.functional;
+
+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();
+ }
+
+}
\ No newline at end of file
Deleted: core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicCacheTest.java
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicCacheTest.java 2009-06-17 13:31:32 UTC (rev 16820)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicCacheTest.java 2009-06-17 15:12:54 UTC (rev 16821)
@@ -1,93 +0,0 @@
-package org.hibernate.test.cache.infinispan.functional;
-
-import org.hibernate.Session;
-import org.hibernate.junit.functional.FunctionalTestCase;
-import org.hibernate.stat.SecondLevelCacheStatistics;
-import org.hibernate.stat.Statistics;
-
-public class BasicCacheTest extends FunctionalTestCase {
-
- public BasicCacheTest( String string ) {
- super( string );
- }
-
- public String[] getMappings() {
- return new String[] { "cache/infinispan/functional/Item.hbm.xml" };
- }
-
- @Override
- public String getCacheConcurrencyStrategy() {
- return "transactional";
- }
-
- public void testEntityCache() {
- Item item = new Item("chris", "Chris's Item");
-
- Session s = openSession();
- Statistics stats = s.getSessionFactory().getStatistics();
- s.getTransaction().begin();
- s.persist( item );
- s.getTransaction().commit();
- s.close();
-
- stats.clear();
- s = openSession();
- Item found = (Item) s.load( Item.class, item.getId() );
- System.out.println( stats );
- assertEquals( item.getDescription(), found.getDescription() );
- assertEquals( 0, stats.getSecondLevelCacheMissCount() );
- assertEquals( 1, stats.getSecondLevelCacheHitCount() );
- s.delete( found );
- s.close();
- }
-
- 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();
- stats.clear();
- 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( another );
- s.persist( item );
- s.getTransaction().commit();
- s.close();
-
- s = openSession();
- Item loaded = (Item) s.load( Item.class, item.getId() );
- assertEquals( 1, loaded.getItems().size() );
- s.close();
-
- s = openSession();
- Statistics stats = s.getSessionFactory().getStatistics();
- stats.clear();
- SecondLevelCacheStatistics cStats = stats.getSecondLevelCacheStatistics( Item.class.getName() + ".items" );
- Item loadedWithCachedCollection = (Item) s.load( Item.class, item.getId() );
- assertEquals( 1, loadedWithCachedCollection.getItems().size() );
- assertEquals( 1, cStats.getHitCount() );
- s.close();
- }
-
-}
\ No newline at end of file
Added: 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 (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicReadOnlyTestCase.java 2009-06-17 15:12:54 UTC (rev 16821)
@@ -0,0 +1,9 @@
+package org.hibernate.test.cache.infinispan.functional;
+
+public class BasicReadOnlyTestCase extends AbstractInfinispanTestCase {
+
+ public BasicReadOnlyTestCase( String string ) {
+ super( string, "read-only" );
+ }
+
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/BasicTransactionalTestCase.java 2009-06-17 15:12:54 UTC (rev 16821)
@@ -0,0 +1,9 @@
+package org.hibernate.test.cache.infinispan.functional;
+
+public class BasicTransactionalTestCase extends AbstractInfinispanTestCase {
+
+ public BasicTransactionalTestCase( String string ) {
+ super( string, "transactional" );
+ }
+
+}
15 years, 6 months
Hibernate SVN: r16820 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-17 09:31:32 -0400 (Wed, 17 Jun 2009)
New Revision: 16820
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinValidatorOverrideTest.java
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/validation.xml
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
Fixed tests to run incontainer
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java 2009-06-17 12:29:46 UTC (rev 16819)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java 2009-06-17 13:31:32 UTC (rev 16820)
@@ -27,11 +27,13 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Classes;
import static org.testng.Assert.assertTrue;
import static org.testng.FileAssert.fail;
import org.testng.annotations.Test;
import static org.hibernate.jsr303.tck.util.TestUtil.getInputStreamForPath;
+import org.hibernate.jsr303.tck.util.TestUtil;
/**
* @author Hardy Ferentschik
@@ -39,6 +41,7 @@
@Artifact(artifactType = ArtifactType.JSR303)
@Resource(source = "empty-constraints.xml",
destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/configuration/empty-constraints.xml")
+(a)Classes(TestUtil.class)
public class MappingStreamHandlingTest extends AbstractTest {
@Test
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinValidatorOverrideTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinValidatorOverrideTest.java 2009-06-17 12:29:46 UTC (rev 16819)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinValidatorOverrideTest.java 2009-06-17 13:31:32 UTC (rev 16820)
@@ -30,10 +30,12 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Classes;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
import static org.hibernate.jsr303.tck.util.TestUtil.getInputStreamForPath;
+import org.hibernate.jsr303.tck.util.TestUtil;
/**
* @author Hardy Ferentschik
@@ -41,6 +43,7 @@
@Artifact(artifactType = ArtifactType.JSR303)
@Resource(source = "builtin-constraints-override.xml",
destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/builtin-constraints-override.xml")
+(a)Classes(TestUtil.class)
public class BuiltinValidatorOverrideTest extends AbstractTest {
@Test
Modified: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/validation.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/validation.xml 2009-06-17 12:29:46 UTC (rev 16819)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/validation.xml 2009-06-17 13:31:32 UTC (rev 16820)
@@ -2,5 +2,5 @@
<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">
- <default-provider>org.hibernate.jsr303.tck.tests.bootstrap.customprovider.TCKValidatorConfiguration</default-provider>
+ <default-provider>org.hibernate.jsr303.tck.tests.bootstrap.customprovider.TCKValidationProvider</default-provider>
</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-06-17 12:29:46 UTC (rev 16819)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-17 13:31:32 UTC (rev 16820)
@@ -856,7 +856,7 @@
</assertion>
<assertion id="o">
<text>If a public no-arg constructor is missing, a ValidationException is raised during
- the Configura- tion.buildValidatorFactory() call</text>
+ the Configuration.buildValidatorFactory() call</text>
</assertion>
</section>
<section id="4.4.7" title="Usage">
@@ -971,7 +971,7 @@
<section id="7.1" title="Constraint definition and declaration">
<assertion id="a">
<text>Specifically when exploring metadata, the Bean Validation provider must ensure
- that an annotation instance corres- ponding to the XML declaration is provided via
+ that an annotation instance corresponding to the XML declaration is provided via
ConstraintDescriptor.getAnnnotation()</text>
</assertion>
<assertion id="b">
15 years, 6 months
Hibernate SVN: r16819 - in beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck: tests/metadata and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-17 08:29:46 -0400 (Wed, 17 Jun 2009)
New Revision: 16819
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
Log:
Added missing builtin constraint tests.
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java 2009-06-17 12:29:31 UTC (rev 16818)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java 2009-06-17 12:29:46 UTC (rev 16819)
@@ -31,6 +31,8 @@
import static org.testng.FileAssert.fail;
import org.testng.annotations.Test;
+import static org.hibernate.jsr303.tck.util.TestUtil.getInputStreamForPath;
+
/**
* @author Hardy Ferentschik
*/
@@ -39,7 +41,6 @@
destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/configuration/empty-constraints.xml")
public class MappingStreamHandlingTest extends AbstractTest {
-
@Test
@SpecAssertion(section = "4.4.3", id = "b")
public void testMappingStreamGetsClosed() {
@@ -82,17 +83,6 @@
}
}
- private InputStream getInputStreamForPath(String path) {
- // try the context class loader first
- InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream( path );
-
- // try the current class loader
- if ( inputStream == null ) {
- inputStream = this.getClass().getResourceAsStream( path );
- }
- return inputStream;
- }
-
public class DelegatingInputStream extends InputStream {
boolean closeHasBeenCalled = false;
final InputStream delegate;
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java 2009-06-17 12:29:31 UTC (rev 16818)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java 2009-06-17 12:29:46 UTC (rev 16819)
@@ -128,7 +128,7 @@
// Set<ConstraintDescriptor<?>> descriptors = getConstraintDescriptorsFor( Order.class, "orderNumber" );
// assertTrue( descriptors.size() == 1, "There should only by one descriptor." );
// ConstraintDescriptor<?> descriptor = descriptors.iterator().next();
-// assertEquals( descriptor.getConstraintValidatorClasses().get( 0 ), NotNullValidator.class, "Wrong classes" );
+// assertEquals( descriptor.getConstraintValidatorClasses().get( 0 ), InvertedNotNullValidator.class, "Wrong classes" );
// }
@Test
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-06-17 12:29:31 UTC (rev 16818)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-06-17 12:29:46 UTC (rev 16819)
@@ -17,16 +17,17 @@
*/
package org.hibernate.jsr303.tck.util;
+import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
import javax.validation.metadata.ConstraintDescriptor;
-import javax.validation.ConstraintViolation;
import javax.validation.metadata.ElementDescriptor;
import javax.validation.metadata.PropertyDescriptor;
-import javax.validation.Validation;
-import javax.validation.Validator;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@@ -121,4 +122,15 @@
ElementDescriptor elementDescriptor = getPropertyDescriptor( clazz, property );
return elementDescriptor.getConstraintDescriptors();
}
+
+ public static InputStream getInputStreamForPath(String path) {
+ // try the context class loader first
+ InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream( path );
+
+ // try the current class loader
+ if ( inputStream == null ) {
+ inputStream = TestUtil.class.getResourceAsStream( path );
+ }
+ return inputStream;
+ }
}
15 years, 6 months
Hibernate SVN: r16818 - in beanvalidation/trunk/validation-tck/src/main: resources/org/hibernate/jsr303/tck/tests and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-17 08:29:31 -0400 (Wed, 17 Jun 2009)
New Revision: 16818
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinValidatorOverrideTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/InvertedNotNullValidator.java
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/constraints/
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/builtin-constraints-override.xml
Log:
Added missing builtin constraint tests.
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinValidatorOverrideTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinValidatorOverrideTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinValidatorOverrideTest.java 2009-06-17 12:29:31 UTC (rev 16818)
@@ -0,0 +1,74 @@
+// $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.constraints.builtinconstraints;
+
+import java.io.InputStream;
+import java.util.Set;
+import javax.validation.Configuration;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.constraints.NotNull;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Resource;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+import static org.hibernate.jsr303.tck.util.TestUtil.getInputStreamForPath;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Resource(source = "builtin-constraints-override.xml",
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/builtin-constraints-override.xml")
+public class BuiltinValidatorOverrideTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "6", id = "b")
+ public void testXmlConfiguredValidatorConfigurationHasPrecedence() {
+ Configuration<?> config = Validation.byDefaultProvider().configure();
+ InputStream in = getInputStreamForPath(
+ "org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/builtin-constraints-override.xml"
+ );
+ config.addMapping( in );
+ Validator validator = config.buildValidatorFactory().getValidator();
+ DummyEntity dummy = new DummyEntity();
+ Set<ConstraintViolation<DummyEntity>> violation = validator.validate( dummy );
+ assertTrue(
+ violation.isEmpty(),
+ "There should be no violation even though dummyProperty is null, because the default validator got overriden in xml."
+ );
+
+ dummy.dummyProperty = "foobar";
+ violation = validator.validate( dummy );
+ assertTrue(
+ violation.size() == 1,
+ "There should be one violation due to the InvertedNotNullValidator."
+ );
+ }
+
+ class DummyEntity {
+ @NotNull
+ String dummyProperty;
+ }
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinValidatorOverrideTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/InvertedNotNullValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/InvertedNotNullValidator.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/InvertedNotNullValidator.java 2009-06-17 12:29:31 UTC (rev 16818)
@@ -0,0 +1,34 @@
+// $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.constraints.builtinconstraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class InvertedNotNullValidator implements ConstraintValidator<NotNull, Object> {
+ public void initialize(NotNull constraintAnnotation) {
+ }
+
+ public boolean isValid(Object value, ConstraintValidatorContext constraintValidatorContext) {
+ return value == null;
+ }
+}
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/InvertedNotNullValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/builtin-constraints-override.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/builtin-constraints-override.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/builtin-constraints-override.xml 2009-06-17 12:29:31 UTC (rev 16818)
@@ -0,0 +1,9 @@
+<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">
+ <constraint-definition annotation="javax.validation.constraints.NotNull">
+ <validated-by include-existing-validators="false">
+ <value>org.hibernate.jsr303.tck.tests.constraints.builtinconstraints.InvertedNotNullValidator</value>
+ </validated-by>
+ </constraint-definition>
+</constraint-mappings>
Property changes on: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/builtin-constraints-override.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
15 years, 6 months
Hibernate SVN: r16817 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider and 5 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-17 07:21:33 -0400 (Wed, 17 Jun 2009)
New Revision: 16817
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/configuration/
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/configuration/empty-constraints.xml
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/CustomProviderResolverTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/validationxml/ValidationXmlBootstrapTest.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
added some tests for mapping stream handling
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/CustomProviderResolverTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/CustomProviderResolverTest.java 2009-06-17 10:42:27 UTC (rev 16816)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/CustomProviderResolverTest.java 2009-06-17 11:21:33 UTC (rev 16817)
@@ -57,7 +57,6 @@
}
};
-
TCKValidatorConfiguration configuration = Validation
.byProvider( TCKValidationProvider.class )
.providerResolver( resolver )
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/validationxml/ValidationXmlBootstrapTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/validationxml/ValidationXmlBootstrapTest.java 2009-06-17 10:42:27 UTC (rev 16816)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/validationxml/ValidationXmlBootstrapTest.java 2009-06-17 11:21:33 UTC (rev 16817)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java 2009-06-17 11:21:33 UTC (rev 16817)
@@ -0,0 +1,113 @@
+// $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.configuration;
+
+import java.io.IOException;
+import java.io.InputStream;
+import javax.validation.Configuration;
+import javax.validation.Validation;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Resource;
+import static org.testng.Assert.assertTrue;
+import static org.testng.FileAssert.fail;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Resource(source = "empty-constraints.xml",
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/configuration/empty-constraints.xml")
+public class MappingStreamHandlingTest extends AbstractTest {
+
+
+ @Test
+ @SpecAssertion(section = "4.4.3", id = "b")
+ public void testMappingStreamGetsClosed() {
+ Configuration<?> config = Validation.byDefaultProvider().configure();
+ InputStream in = getInputStreamForPath( "org/hibernate/jsr303/tck/tests/configuration/empty-constraints.xml" );
+ DelegatingInputStream delegatingInputStream = new DelegatingInputStream( in );
+ config.addMapping( delegatingInputStream );
+ config.buildValidatorFactory();
+
+ assertTrue( delegatingInputStream.closeHasBeenCalled, "The input stream must be closed." );
+ }
+
+ @Test
+ @SpecAssertion(section = "4.4.3", id = "b")
+ public void testMappingStreamGetsClosedInExceptionalCondition() {
+ Configuration<?> config = Validation.byDefaultProvider().configure();
+ DummyInputStream dummyIn = new DummyInputStream();
+ config.addMapping( dummyIn );
+ try {
+ config.buildValidatorFactory();
+ fail();
+ }
+ catch ( Exception e ) {
+ // success
+ }
+
+ assertTrue( dummyIn.closeHasBeenCalled, "The input stream must be closed." );
+ }
+
+ public class DummyInputStream extends InputStream {
+ boolean closeHasBeenCalled = false;
+
+ public int read() throws IOException {
+ throw new IOException();
+ }
+
+ public void close() throws IOException {
+ closeHasBeenCalled = true;
+ super.close();
+ }
+ }
+
+ private InputStream getInputStreamForPath(String path) {
+ // try the context class loader first
+ InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream( path );
+
+ // try the current class loader
+ if ( inputStream == null ) {
+ inputStream = this.getClass().getResourceAsStream( path );
+ }
+ return inputStream;
+ }
+
+ public class DelegatingInputStream extends InputStream {
+ boolean closeHasBeenCalled = false;
+ final InputStream delegate;
+
+ public DelegatingInputStream(InputStream in) {
+ delegate = in;
+ }
+
+ public int read() throws IOException {
+ return delegate.read();
+ }
+
+ public void close() throws IOException {
+ closeHasBeenCalled = true;
+ delegate.close();
+ }
+ }
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/configuration/MappingStreamHandlingTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/configuration/empty-constraints.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/configuration/empty-constraints.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/configuration/empty-constraints.xml 2009-06-17 11:21:33 UTC (rev 16817)
@@ -0,0 +1,4 @@
+<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">
+</constraint-mappings>
Property changes on: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/configuration/empty-constraints.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-17 10:42:27 UTC (rev 16816)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-17 11:21:33 UTC (rev 16817)
@@ -703,33 +703,29 @@
identifying the provider.</text>
</assertion>
<assertion id="b">
- <text>The isSuitable() method of its ValidationProvider implementation must return true
- when this sub interface type is passed as a parameter, false otherwise</text>
- </assertion>
- <assertion id="c">
<text>Streams represented in the XML configuration and opened by the Configuration
implementation must be closed by the Configuration implementation after the
ValidatorFactory creation (or if an exception occurs)</text>
</assertion>
- <assertion id="d">
+ <assertion id="c">
<text>Use the provider implementation requested if Configuration has been created from
Validation.byProvider(Class)</text>
</assertion>
- <assertion id="e">
+ <assertion id="d">
<text>Use the provider implementation associated with the Configuration implementation
described in the XML configuration (under validation-config.default-provider see
Section 4.4.6) if defined: the value of this element is the fully qualified class
name of the Configuration sub interface uniquely identifying the provider.</text>
</assertion>
- <assertion id="f">
+ <assertion id="e">
<text>Use the first provider implementation returned by
validationProviderResolver.getValidationProviders()</text>
</assertion>
- <assertion id="g">
+ <assertion id="f">
<text>If no ValidationProviderResolver instance has been specified, the default
- ValidationProviderResolv- er is used</text>
+ ValidationProviderResolver is used</text>
</assertion>
- <assertion id="h">
+ <assertion id="g">
<text>If a problem occurs while building the ValidationFactory, a ValidationException is
raised</text>
</assertion>
15 years, 6 months
Hibernate SVN: r16816 - in beanvalidation/trunk/validation-api/src/main/java/javax/validation: constraints and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-17 06:42:27 -0400 (Wed, 17 Jun 2009)
New Revision: 16816
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validation.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMax.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMin.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Digits.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Future.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Past.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Pattern.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ConfigurationState.java
Log:
Fixed javadoc warnings on @see tag and updates some of the text
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java 2009-06-17 09:13:53 UTC (rev 16815)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/OverridesAttribute.java 2009-06-17 10:42:27 UTC (rev 16816)
@@ -60,7 +60,7 @@
/**
* Defines several @OverridesAttribute annotations on the same element
- * @see {@link OverridesAttribute}
+ * @see OverridesAttribute
*/
@Documented
@Target({ METHOD })
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validation.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validation.java 2009-06-17 09:13:53 UTC (rev 16815)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validation.java 2009-06-17 10:42:27 UTC (rev 16816)
@@ -38,12 +38,9 @@
* <ul>
* <li>
* The easiest approach is to build the default ValidatorFactory.
- * <pre>
- * ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
- * </pre>
+ * <pre>{@code ValidatorFactory factory = Validation.buildDefaultValidatorFactory();}</pre>
* In this case, the default validation provider resolver
* will be used to locate available providers.
- *
* The chosen provider is defined as followed:
* <ul>
* <li>if the XML configuration defines a provider, this provider is used</li>
@@ -57,27 +54,25 @@
* <code>ValidationProviderResolver</code>. The chosen
* <code>ValidationProvider</code> is then determined in the same way
* as in the default bootstrapping case (see above).
- * <pre>
- * Configuration<?> configuration = Validation
+ * <pre>{@code
+ * Configuration<?> configuration = Validation
* .byDefaultProvider()
* .providerResolver( new MyResolverStrategy() )
* .configure();
- * ValidatorFactory factory = configuration.buildValidatorFactory();
+ * ValidatorFactory factory = configuration.buildValidatorFactory();}
* </pre>
* </li>
- *
- * <p/>
* <li>
* The third approach allows you to specify explicitly and in
* a type safe fashion the expected provider.
*
* Optionally you can choose a custom <code>ValidationProviderResolver</code>.
- * <pre>
+ * <pre>{@code
* ACMEConfiguration configuration = Validation
* .byProvider(ACMEProvider.class)
* .providerResolver( new MyResolverStrategy() ) // optionally set the provider resolver
* .configure();
- * ValidatorFactory factory = configuration.buildValidatorFactory();
+ * ValidatorFactory factory = configuration.buildValidatorFactory();}
* </pre>
* </li>
* </ul>
@@ -93,7 +88,7 @@
* </ul>
*
* @author Emmanuel Bernard
- * @author Hardy Feretnschik
+ * @author Hardy Ferentschik
*/
public class Validation {
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMax.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMax.java 2009-06-17 09:13:53 UTC (rev 16815)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMax.java 2009-06-17 10:42:27 UTC (rev 16816)
@@ -69,7 +69,7 @@
* Defines several @DecimalMax annotations on the same element
*
* @author Emmanuel Bernard
- * @see {@link DecimalMax}
+ * @see DecimalMax
*/
@Target({ METHOD, FIELD, ANNOTATION_TYPE })
@Retention(RUNTIME)
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMin.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMin.java 2009-06-17 09:13:53 UTC (rev 16815)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/DecimalMin.java 2009-06-17 10:42:27 UTC (rev 16816)
@@ -66,7 +66,7 @@
/**
* Defines several @DecimalMin annotations on the same element
- * @see {@link DecimalMin}
+ * @see DecimalMin
*
* @author Emmanuel Bernard
*/
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Digits.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Digits.java 2009-06-17 09:13:53 UTC (rev 16815)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Digits.java 2009-06-17 10:42:27 UTC (rev 16816)
@@ -41,7 +41,6 @@
* <code>null</code> elements are considered valid
*
* @author Emmanuel Bernard
- * @todo Is string supported or not?
*/
@Target({ METHOD, FIELD, ANNOTATION_TYPE })
@Retention(RUNTIME)
@@ -66,7 +65,7 @@
/**
* Defines several @Digits annotations on the same element
- * @see {@link Digits}
+ * @see Digits
*
* @author Emmanuel Bernard
*/
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Future.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Future.java 2009-06-17 09:13:53 UTC (rev 16815)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Future.java 2009-06-17 10:42:27 UTC (rev 16816)
@@ -56,7 +56,7 @@
/**
* Defines several @Future annotations on the same element
- * @see {@link Future}
+ * @see Future
*
* @author Emmanuel Bernard
*/
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java 2009-06-17 09:13:53 UTC (rev 16815)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Max.java 2009-06-17 10:42:27 UTC (rev 16816)
@@ -63,7 +63,7 @@
/**
* Defines several @Max annotations on the same element
- * @see {@link Max}
+ * @see Max
*
* @author Emmanuel Bernard
*/
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java 2009-06-17 09:13:53 UTC (rev 16815)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Min.java 2009-06-17 10:42:27 UTC (rev 16816)
@@ -63,7 +63,7 @@
/**
* Defines several @Min annotations on the same element
- * @see {@link Min}
+ * @see Min
*
* @author Emmanuel Bernard
*/
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Past.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Past.java 2009-06-17 09:13:53 UTC (rev 16815)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Past.java 2009-06-17 10:42:27 UTC (rev 16816)
@@ -56,7 +56,7 @@
/**
* Defines several @Past annotations on the same element
- * @see {@link Past}
+ * @see Past
*
* @author Emmanuel Bernard
*/
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Pattern.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Pattern.java 2009-06-17 09:13:53 UTC (rev 16815)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Pattern.java 2009-06-17 10:42:27 UTC (rev 16816)
@@ -130,7 +130,7 @@
/**
* Defines several @Pattern annotations on the same element
- * @see @link Pattern}
+ * @see Pattern
*
* @author Emmanuel Bernard
*/
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java 2009-06-17 09:13:53 UTC (rev 16815)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/constraints/Size.java 2009-06-17 10:42:27 UTC (rev 16816)
@@ -64,7 +64,7 @@
/**
* Defines several @Size annotations on the same element
- * @see {@link Size}
+ * @see Size
*
* @author Emmanuel Bernard
*/
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ConfigurationState.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ConfigurationState.java 2009-06-17 09:13:53 UTC (rev 16815)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ConfigurationState.java 2009-06-17 10:42:27 UTC (rev 16816)
@@ -18,8 +18,8 @@
package javax.validation.spi;
import java.io.InputStream;
+import java.util.Map;
import java.util.Set;
-import java.util.Map;
import javax.validation.ConstraintValidatorFactory;
import javax.validation.MessageInterpolator;
import javax.validation.TraversableResolver;
@@ -36,30 +36,36 @@
public interface ConfigurationState {
/**
- * returns true if Configuration.ignoreXMLConfiguration() has been called
+ * Returns true if Configuration.ignoreXMLConfiguration() has been called
* In this case, the ValidatorFactory must ignore META-INF/validation.xml
- * @return true if META-INF/validation.xml should be ignored
+ *
+ * @return {@code true} if META-INF/validation.xml should be ignored
*/
boolean isIgnoreXmlConfiguration();
/**
- * Message interpolator as defined in the following decreasing priority:
- * - set via the Configuration programmatic API
- * - defined in META-INF/validation.xml provided that ignoredXmlConfiguration
- * is false. In this case the instance is created via its no-arg constructor.
- * - null if undefined.
+ * Returns the message interpolator of this configuration..
+ * Message interpolator is defined in the following decreasing priority:
+ * <ul>
+ * <li>set via the Configuration programmatic API</li>
+ * <li>defined in META-INF/validation.xml provided that ignoredXmlConfiguration
+ * is false. In this case the instance is created via its no-arg constructor.</li>
+ * <li>{@code null} if undefined.</li>
+ * </ul>
*
* @return message provider instance or null if not defined
*/
MessageInterpolator getMessageInterpolator();
/**
- * Returns a set of stream corresponding to:
- * - mapping XML streams passed programmatically in Configuration
- * - mapping XML stream located in the resources defined in
+ * Returns a set of configuration streams.
+ * The streams are defined by:
+ * <ul>
+ * <li>mapping XML streams passed programmatically in Configuration</li>
+ * <li>mapping XML stream located in the resources defined in</li>
* META-INF/validation.xml (constraint-mapping element)
- *
- * Streams represented in the XML configuration and opened by the
+ * </ul>
+ * Streams represented in the XML configuration and opened by the
* configuration implementation must be closed by the configuration
* implementation after the ValidatorFactory creation (or if an exception
* occurs).
@@ -69,36 +75,44 @@
Set<InputStream> getMappingStreams();
/**
- * ConstraintValidatorFactory implementation as defined in the following
+ * Returns the constraint validator factory of this configuration.
+ * The {@code ConstraintValidatorFactory} implementation is defined in the following
* decreasing priority:
- * - set via the Configuration programmatic API
- * - defined in META-INF/validation.xml provided that ignoredXmlConfiguration
- * is false. In this case the instance is created via its no-arg constructor.
- * - null if undefined.
+ * <ul>
+ * <li>set via the Configuration programmatic API</li>
+ * <li>defined in META-INF/validation.xml provided that ignoredXmlConfiguration
+ * is false. In this case the instance is created via its no-arg constructor.</li>
+ * <li>{@code null} if undefined.</li>
+ * </ul>
*
- * @return factory instance or null if not defined
+ * @return factory instance or {@code null} if not defined
*/
ConstraintValidatorFactory getConstraintValidatorFactory();
/**
- * TraversableResolver as defined in the following decreasing priority:
- * - set via the Configuration programmatic API
- * - defined in META-INF/validation.xml provided that ignoredXmlConfiguration
- * is false. In this case the instance is created via its no-arg constructor.
- * - null if undefined.
+ * Returns the traversable resolver for this configuration.
+ * TraversableResolver is defined in the following decreasing priority:
+ * <ul>
+ * <li>set via the Configuration programmatic API</li>
+ * <li>defined in META-INF/validation.xml provided that ignoredXmlConfiguration
+ * is false. In this case the instance is created via its no-arg constructor.</li>
+ * <li>{@code null} if undefined.</li>
+ * </ul>
*
- * @return traversable provider instance or null if not defined
+ * @return traversable provider instance or {@code null} if not defined
*/
TraversableResolver getTraversableResolver();
/**
- * return non type-safe properties defined via:
- * - Configuration.addProperty(String, String)
- * - META-INF/validation.xml provided that ignoredXmlConfiguration
+ * Returns a map of non type-safe custom properties.
+ * Properties defined via:
+ * <ul>
+ * <li>Configuration.addProperty(String, String)</li>
+ * <li>META-INF/validation.xml provided that ignoredXmlConfiguration</li>
* is false.
- *
+ * </ul>
* If a property is defined both programmatically and in XML,
- * the value defined programmatically has priority
+ * the value defined programmatically has priority
*
* @return Map whose key is the property key and the value the property value
*/
15 years, 6 months
Hibernate SVN: r16815 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-17 05:13:53 -0400 (Wed, 17 Jun 2009)
New Revision: 16815
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/HibernateTraversableResolverTest.java
Log:
Updated the test due to HV-163 fix in Validator
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/HibernateTraversableResolverTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/HibernateTraversableResolverTest.java 2009-06-17 09:09:25 UTC (rev 16814)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/HibernateTraversableResolverTest.java 2009-06-17 09:13:53 UTC (rev 16815)
@@ -1,20 +1,20 @@
package org.hibernate.test.annotations.beanvalidation;
import java.math.BigDecimal;
-import javax.validation.ConstraintViolationException;
import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
-import org.hibernate.test.annotations.TestCase;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
+import org.hibernate.test.annotations.TestCase;
/**
* @author Emmanuel Bernard
*/
public class HibernateTraversableResolverTest extends TestCase {
public void testNonLazyAssocFieldWithConstraintsFailureExpected() {
- Session s = openSession( );
+ Session s = openSession();
Transaction tx = s.beginTransaction();
Screen screen = new Screen();
@@ -22,7 +22,7 @@
try {
s.persist( screen );
s.flush();
- fail("@NotNull on a non lazy association is not evaluated");
+ fail( "@NotNull on a non lazy association is not evaluated" );
}
catch ( ConstraintViolationException e ) {
assertEquals( 1, e.getConstraintViolations().size() );
@@ -33,7 +33,7 @@
}
public void testEmbedded() {
- Session s = openSession( );
+ Session s = openSession();
Transaction tx = s.beginTransaction();
Screen screen = new Screen();
@@ -46,7 +46,7 @@
try {
s.persist( screen );
s.flush();
- fail("@NotNull on empedded property is not evaluated");
+ fail( "@NotNull on empedded property is not evaluated" );
}
catch ( ConstraintViolationException e ) {
assertEquals( 1, e.getConstraintViolations().size() );
@@ -60,7 +60,7 @@
}
public void testToOneAssocNotValidated() {
- Session s = openSession( );
+ Session s = openSession();
Transaction tx = s.beginTransaction();
Screen screen = new Screen();
@@ -71,7 +71,7 @@
try {
s.persist( screen );
s.flush();
- fail("Associated objects should not be validated");
+ fail( "Associated objects should not be validated" );
}
catch ( ConstraintViolationException e ) {
assertEquals( 1, e.getConstraintViolations().size() );
@@ -84,7 +84,7 @@
}
public void testCollectionAssocNotValidated() {
- Session s = openSession( );
+ Session s = openSession();
Transaction tx = s.beginTransaction();
Screen screen = new Screen();
@@ -100,7 +100,7 @@
try {
s.persist( screen );
s.flush();
- fail("Associated objects should not be validated");
+ fail( "Associated objects should not be validated" );
}
catch ( ConstraintViolationException e ) {
assertEquals( 1, e.getConstraintViolations().size() );
@@ -113,7 +113,7 @@
}
public void testEmbeddedCollection() {
- Session s = openSession( );
+ Session s = openSession();
Transaction tx = s.beginTransaction();
Screen screen = new Screen();
@@ -125,14 +125,13 @@
try {
s.persist( screen );
s.flush();
- fail("Collection of embedded objects should be validated");
+ fail( "Collection of embedded objects should be validated" );
}
catch ( ConstraintViolationException e ) {
assertEquals( 1, e.getConstraintViolations().size() );
final ConstraintViolation constraintViolation = e.getConstraintViolations().iterator().next();
assertEquals( Screen.class, constraintViolation.getRootBeanClass() );
- // connectors[0] should be connectors expect failure when bug is fixed in HV
- assertEquals( "connectors[0].number", constraintViolation.getPropertyPath() );
+ assertEquals( "connectors[].number", constraintViolation.getPropertyPath() );
}
tx.rollback();
@@ -140,7 +139,7 @@
}
public void testAssocInEmbeddedNotValidated() {
- Session s = openSession( );
+ Session s = openSession();
Transaction tx = s.beginTransaction();
Screen screen = new Screen();
@@ -160,7 +159,7 @@
display.setBrand( null );
s.persist( screen );
s.flush();
- fail("Collection of embedded objects should be validated");
+ fail( "Collection of embedded objects should be validated" );
}
catch ( ConstraintViolationException e ) {
assertEquals( 1, e.getConstraintViolations().size() );
15 years, 6 months