Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

HHH-5942 - Migrate to JUnit 4

  • Loading branch information...
commit df4df47b95f379286e9d0898c3efd27dde22be03 1 parent 20a120e
@sebersole sebersole authored
Showing with 4,685 additions and 2,495 deletions.
  1. +4 −2 .gitignore
  2. +74 −14 hibernate-core/src/test/java/org/hibernate/test/annotations/EntityTest.java
  3. +37 −7 hibernate-core/src/test/java/org/hibernate/test/annotations/JoinedSubclassTest.java
  4. +0 −151 hibernate-core/src/test/java/org/hibernate/test/annotations/TestCase.java
  5. +36 −4 hibernate-core/src/test/java/org/hibernate/test/annotations/access/AccessTest.java
  6. +23 −7 hibernate-core/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java
  7. +36 −2 hibernate-core/src/test/java/org/hibernate/test/annotations/any/AnyTest.java
  8. +35 −13 hibernate-core/src/test/java/org/hibernate/test/annotations/array/ArrayTest.java
  9. +13 −4 hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationAutoTest.java
  10. +15 −5 hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationDisabledTest.java
  11. +14 −5 hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java
  12. +14 −5 ...ate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationProvidedFactoryTest.java
  13. +25 −15 hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLTest.java
  14. +17 −5 hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java
  15. +18 −4 ...nate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/HibernateTraversableResolverTest.java
  16. +67 −50 hibernate-core/src/test/java/org/hibernate/test/annotations/bytecode/ProxyBreakingTest.java
  17. +16 −7 hibernate-core/src/test/java/org/hibernate/test/annotations/cascade/CascadeTest.java
  18. +45 −8 hibernate-core/src/test/java/org/hibernate/test/annotations/cid/CompositeIdTest.java
  19. +13 −4 hibernate-core/src/test/java/org/hibernate/test/annotations/cid/keymanytoone/EagerKeyManyToOneTest.java
  20. +47 −9 hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java
  21. +33 −7 hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/OrderByTest.java
  22. +39 −16 ...java/org/hibernate/test/annotations/collectionelement/deepcollectionelements/DeepCollectionElementTest.java
  23. +33 −4 ...ava/org/hibernate/test/annotations/collectionelement/indexedCollection/IndexedCollectionOfElementsTest.java
  24. +11 −22 hibernate-core/src/test/java/org/hibernate/test/annotations/dataTypes/BasicOperationsTest.java
  25. +74 −68 .../test/java/org/hibernate/test/annotations/derivedidentities/bidirectional/CompositeDerivedIdentityTest.java
  26. +12 −5 ...rnate/test/annotations/derivedidentities/bidirectional/DerivedIdentityWithBidirectionalAssociationTest.java
  27. +9 −2 ...st/java/org/hibernate/test/annotations/derivedidentities/bidirectional/OneToOneWithDerivedIdentityTest.java
  28. +38 −5 ...t/java/org/hibernate/test/annotations/derivedidentities/e1/a/DerivedIdentitySimpleParentIdClassDepTest.java
  29. +38 −8 ...ava/org/hibernate/test/annotations/derivedidentities/e1/b/DerivedIdentitySimpleParentEmbeddedIdDepTest.java
  30. +10 −4 ...src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/IdMapManyToOneSpecjTest.java
  31. +12 −42 ...rc/test/java/org/hibernate/test/annotations/derivedidentities/e1/b2/IdClassGeneratedValueManyToOneTest.java
  32. +35 −5 .../java/org/hibernate/test/annotations/derivedidentities/e1/c/DerivedIdentitySimpleParentEmbeddedDepTest.java
  33. +16 −8 .../java/org/hibernate/test/annotations/derivedidentities/e2/a/DerivedIdentityIdClassParentIdClassDepTest.java
  34. +16 −9 ...va/org/hibernate/test/annotations/derivedidentities/e2/b/DerivedIdentityIdClassParentEmbeddedIdDepTest.java
  35. +39 −7 .../java/org/hibernate/test/annotations/derivedidentities/e3/a/DerivedIdentityEmbeddedIdParentIdClassTest.java
  36. +40 −12 ...org/hibernate/test/annotations/derivedidentities/e3/b/DerivedIdentityEmbeddedIdParentEmbeddedIdDepTest.java
  37. +44 −7 ...st/java/org/hibernate/test/annotations/derivedidentities/e4/a/DerivedIdentitySimpleParentSimpleDepTest.java
  38. +42 −7 ...a/org/hibernate/test/annotations/derivedidentities/e4/b/DerivedIdentitySimpleParentSimpleDepMapsIdTest.java
  39. +40 −8 ...hibernate/test/annotations/derivedidentities/e5/a/DerivedIdentityIdClassParentSameIdTypeIdClassDepTest.java
  40. +36 −6 ...ernate/test/annotations/derivedidentities/e5/b/DerivedIdentityIdClassParentSameIdTypeEmbeddedIdDepTest.java
  41. +34 −4 ...core/src/test/java/org/hibernate/test/annotations/derivedidentities/e5/c/ForeignGeneratorViaMapsIdTest.java
  42. +36 −6 ...ernate/test/annotations/derivedidentities/e6/a/DerivedIdentityEmbeddedIdParentSameIdTypeIdClassDepTest.java
  43. +36 −6 ...ate/test/annotations/derivedidentities/e6/b/DerivedIdentityEmbeddedIdParentSameIdTypeEmbeddedIdDepTest.java
  44. +56 −18 hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java
  45. +11 −4 hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/many2one/EmbeddableWithMany2OneTest.java
  46. +11 −2 hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/one2many/EmbeddableWithOne2ManyTest.java
  47. +30 −3 ...e/src/test/java/org/hibernate/test/annotations/engine/collection/UnidirCollectionWithMultipleOwnerTest.java
  48. +53 −43 hibernate-core/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java
  49. +35 −7 hibernate-core/src/test/java/org/hibernate/test/annotations/entity/Java5FeaturesTest.java
  50. +2 −1  hibernate-core/src/test/java/org/hibernate/test/annotations/entity/PhoneNumber.java
  51. +36 −7 hibernate-core/src/test/java/org/hibernate/test/annotations/entity/PropertyDefaultMappingsTest.java
  52. +35 −3 hibernate-core/src/test/java/org/hibernate/test/annotations/entitynonentity/EntityNonEntityTest.java
  53. +39 −7 hibernate-core/src/test/java/org/hibernate/test/annotations/fetch/FetchingTest.java
  54. +10 −4 hibernate-core/src/test/java/org/hibernate/test/annotations/fetchprofile/MoreFetchProfileTest.java
  55. +81 −64 hibernate-core/src/test/java/org/hibernate/test/annotations/generics/EmbeddedGenericsTest.java
  56. +31 −3 hibernate-core/src/test/java/org/hibernate/test/annotations/generics/GenericsTest.java
  57. +69 −39 hibernate-core/src/test/java/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java
  58. +51 −22 hibernate-core/src/test/java/org/hibernate/test/annotations/genericsinheritance/GenericsInheritanceTest.java
  59. +36 −13 hibernate-core/src/test/java/org/hibernate/test/annotations/id/EnumIdTest.java
  60. +33 −4 hibernate-core/src/test/java/org/hibernate/test/annotations/id/IdClassTest.java
  61. +52 −23 hibernate-core/src/test/java/org/hibernate/test/annotations/id/IdTest.java
  62. +43 −22 hibernate-core/src/test/java/org/hibernate/test/annotations/id/JoinColumnOverrideTest.java
  63. +0 −38 hibernate-core/src/test/java/org/hibernate/test/annotations/id/NewSchemeIdTest.java
  64. +19 −17 ...rnate-core/src/test/java/org/hibernate/test/annotations/id/generationmappings/NewGeneratorMappingsTest.java
  65. +36 −13 hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/EnumIdTest.java
  66. +33 −7 hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/IdClassTest.java
  67. +23 −22 hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/IdTest.java
  68. +21 −23 hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/JoinColumnOverrideTest.java
  69. +0 −38 hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/NewSchemeIdTest.java
  70. +11 −9 hibernate-core/src/test/java/org/hibernate/test/annotations/idclass/IdClassCompositePKTest.java
  71. +8 −5 hibernate-core/src/test/java/org/hibernate/test/annotations/idclass/xml/IdClassXmlTest.java
  72. +13 −3 ...nate-core/src/test/java/org/hibernate/test/annotations/idclassgeneratedvalue/IdClassGeneratedValueTest.java
  73. +73 −43 hibernate-core/src/test/java/org/hibernate/test/annotations/identifiercollection/IdentifierCollectionTest.java
  74. +87 −80 hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/IdManyToOneTest.java
  75. +31 −11 ...core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/AlphabeticalIdManyToOneTest.java
  76. +30 −3 ...e-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/AlphabeticalManyToOneTest.java
  77. +47 −31 hibernate-core/src/test/java/org/hibernate/test/annotations/immutable/ImmutableTest.java
  78. +30 −9 hibernate-core/src/test/java/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java
  79. +67 −38 hibernate-core/src/test/java/org/hibernate/test/annotations/indexcoll/MapKeyTest.java
  80. +41 −23 hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/SubclassTest.java
  81. +18 −14 ...src/test/java/org/hibernate/test/annotations/inheritance/discriminatoroptions/DiscriminatorOptionsTest.java
  82. +52 −31 ...e-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassAndSecondaryTable.java
  83. +25 −51 hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java
  84. +38 −11 hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/mixed/SubclassTest.java
  85. +39 −11 hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/union/SubclassTest.java
  86. +42 −18 hibernate-core/src/test/java/org/hibernate/test/annotations/interfaces/InterfacesTest.java
  87. +49 −11 hibernate-core/src/test/java/org/hibernate/test/annotations/join/JoinTest.java
  88. +91 −66 hibernate-core/src/test/java/org/hibernate/test/annotations/loader/LoaderTest.java
  89. +15 −6 hibernate-core/src/test/java/org/hibernate/test/annotations/lob/AbstractLobTest.java
  90. +23 −24 hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImageTest.java
  91. +5 −5 hibernate-core/src/test/java/org/hibernate/test/annotations/lob/LobTest.java
  92. +14 −13 hibernate-core/src/test/java/org/hibernate/test/annotations/lob/MaterializedBlobTest.java
  93. +26 −19 hibernate-core/src/test/java/org/hibernate/test/annotations/lob/TextTest.java
  94. +15 −4 hibernate-core/src/test/java/org/hibernate/test/annotations/lob/VersionedLobTest.java
  95. +1 −5 hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyMaxFetchDepth0Test.java
  96. +71 −104 hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyTest.java
  97. +92 −60 hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/ManyToOneJoinTest.java
  98. +0 −50 hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/ManyToOneOnNonPkTest.java
  99. +51 −15 hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/ManyToOneTest.java
  100. +8 −2 ...t/java/org/hibernate/test/annotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java
  101. +16 −20 hibernate-core/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ManyToOneWithFormulaTest.java
  102. +10 −4 ...est/java/org/hibernate/test/annotations/mappedsuperclass/intermediate/IntermediateMappedSuperclassTest.java
  103. +40 −7 hibernate-core/src/test/java/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java
  104. +41 −8 hibernate-core/src/test/java/org/hibernate/test/annotations/naturalid/NaturalIdTest.java
  105. +34 −9 hibernate-core/src/test/java/org/hibernate/test/annotations/notfound/NotFoundTest.java
  106. +29 −14 hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/OneToManyTest.java
  107. +34 −7 hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/OrderByTest.java
  108. +53 −25 hibernate-core/src/test/java/org/hibernate/test/annotations/onetoone/OneToOneTest.java
  109. +34 −3 hibernate-core/src/test/java/org/hibernate/test/annotations/onetoone/hhh4851/HHH4851Test.java
  110. +112 −103 hibernate-core/src/test/java/org/hibernate/test/annotations/override/AssociationOverrideTest.java
  111. +34 −3 hibernate-core/src/test/java/org/hibernate/test/annotations/override/AttributeOverrideTest.java
  112. +38 −13 hibernate-core/src/test/java/org/hibernate/test/annotations/persister/PersisterTest.java
  113. +63 −34 hibernate-core/src/test/java/org/hibernate/test/annotations/polymorphism/PolymorphismTest.java
  114. +26 −32 hibernate-core/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java
  115. +34 −4 hibernate-core/src/test/java/org/hibernate/test/annotations/quote/QuoteGlobalTest.java
  116. +65 −34 hibernate-core/src/test/java/org/hibernate/test/annotations/quote/QuoteTest.java
  117. +10 −6 ...e/src/test/java/org/hibernate/test/annotations/quote/resultsetmappings/ExplicitSqlResultSetMappingTest.java
  118. +39 −7 hibernate-core/src/test/java/org/hibernate/test/annotations/referencedcolumnname/ReferencedColumnNameTest.java
  119. +33 −9 hibernate-core/src/test/java/org/hibernate/test/annotations/strategy/StrategyTest.java
  120. +89 −86 hibernate-core/src/test/java/org/hibernate/test/annotations/subselect/SubselectTest.java
  121. +37 −10 hibernate-core/src/test/java/org/hibernate/test/annotations/tableperclass/TablePerClassTest.java
  122. +14 −8 hibernate-core/src/test/java/org/hibernate/test/annotations/target/TargetTest.java
  123. +62 −32 hibernate-core/src/test/java/org/hibernate/test/annotations/tuplizer/TuplizerTest.java
  124. +33 −3 hibernate-core/src/test/java/org/hibernate/test/annotations/type/TypeTest.java
  125. +57 −28 hibernate-core/src/test/java/org/hibernate/test/annotations/various/GeneratedTest.java
  126. +33 −3 hibernate-core/src/test/java/org/hibernate/test/annotations/various/IndexTest.java
  127. +10 −5 hibernate-core/src/test/java/org/hibernate/test/annotations/various/OptimisticLockAnnotationTest.java
  128. +15 −7 hibernate-core/src/test/java/org/hibernate/test/annotations/various/TimestampTest.java
  129. +9 −3 ...te-core/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/ColumnTransformerTest.java
  130. +15 −3 hibernate-core/src/test/java/org/hibernate/test/annotations/xml/ejb3/Ejb3XmlTest.java
  131. +34 −4 hibernate-core/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmTest.java
  132. +32 −10 hibernate-core/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmWithIdentityTest.java
  133. +42 −26 hibernate-core/src/test/java/org/hibernate/test/cache/InsertedDataTest.java
  134. +51 −46 hibernate-core/src/test/java/org/hibernate/test/collection/set/PersistentSetNonLazyTest.java
  135. +5 −0 hibernate-core/src/test/java/org/hibernate/test/filter/DynamicFilterTest.java
  136. +5 −4 .../src/test/java/org/hibernate/test/instrument/runtime/AbstractTransformingClassLoaderInstrumentTestCase.java
  137. +5 −0 hibernate-core/src/test/java/org/hibernate/test/ops/SaveOrUpdateTest.java
  138. +5 −0 ...-core/src/test/java/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java
  139. +5 −0 ...te-core/src/test/java/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java
  140. +5 −0 hibernate-core/src/test/java/org/hibernate/test/querycache/QueryCacheTest.java
  141. +5 −0 hibernate-core/src/test/java/org/hibernate/test/usercollection/basic/UserCollectionTypeTest.java
  142. +1 −0  hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/BaseEntityManagerFunctionalTestCase.java
  143. +14 −4 hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/EntityManagerTest.java
  144. +22 −8 hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/packaging/JarVisitorTest.java
  145. +29 −7 hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/packaging/PackagedEntityManagerTest.java
  146. +44 −35 hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/packaging/PackagingTestCase.java
  147. +14 −6 hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/packaging/ScannerTest.java
  148. +17 −4 hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java
View
6 .gitignore
@@ -5,8 +5,10 @@
.gradle
# Build output directies
-target
-build
+/target
+*/target
+/build
+*/build
# IntelliJ specific files/directories
out
View
88 hibernate-core/src/test/java/org/hibernate/test/annotations/EntityTest.java
@@ -1,32 +1,65 @@
-//$Id$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. 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 Inc.
+ *
+ * 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.annotations;
+
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.TimeZone;
+
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.StaleStateException;
import org.hibernate.Transaction;
+import org.hibernate.engine.jdbc.spi.JdbcServices;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
-public class EntityTest extends TestCase {
- private DateFormat df;
-
- public EntityTest(String x) {
- super( x );
- df = SimpleDateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
- }
+public class EntityTest extends BaseCoreFunctionalTestCase {
+ private DateFormat df = SimpleDateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
+ @Test
public void testLoad() throws Exception {
//put an object in DB
- assertEquals( "Flight", getCfg().getClassMapping( Flight.class.getName() ).getTable().getName() );
+ assertEquals( "Flight", configuration().getClassMapping( Flight.class.getName() ).getTable().getName() );
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -53,6 +86,7 @@ public void testLoad() throws Exception {
s.close();
}
+ @Test
public void testColumn() throws Exception {
//put an object in DB
Session s = openSession();
@@ -119,6 +153,7 @@ public void testColumn() throws Exception {
s.close();
}
+ @Test
public void testColumnUnique() throws Exception {
Session s;
Transaction tx;
@@ -152,6 +187,7 @@ public void testColumnUnique() throws Exception {
}
}
+ @Test
public void testUniqueConstraint() throws Exception {
int id = 5;
Session s;
@@ -199,6 +235,7 @@ public void testUniqueConstraint() throws Exception {
}
}
+ @Test
public void testVersion() throws Exception {
// put an object in DB
Session s = openSession();
@@ -246,9 +283,9 @@ public void testVersion() throws Exception {
if ( tx != null ) tx.rollback();
s.close();
}
-
}
+ @Test
public void testFieldAccess() throws Exception {
Session s;
Transaction tx;
@@ -275,8 +312,9 @@ public void testFieldAccess() throws Exception {
s.close();
}
+ @Test
public void testEntityName() throws Exception {
- assertEquals( "Corporation", getCfg().getClassMapping( Company.class.getName() ).getTable().getName() );
+ assertEquals( "Corporation", configuration().getClassMapping( Company.class.getName() ).getTable().getName() );
Session s = openSession();
Transaction tx = s.beginTransaction();
Company comp = new Company();
@@ -295,6 +333,7 @@ public void testEntityName() throws Exception {
}
+ @Test
public void testNonGetter() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -318,6 +357,7 @@ public void testNonGetter() throws Exception {
s.close();
}
+ @Test
public void testTemporalType() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -351,6 +391,7 @@ public void testTemporalType() throws Exception {
s.close();
}
+ @Test
public void testBasic() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -372,9 +413,7 @@ public void testBasic() throws Exception {
}
}
- /**
- * @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
- */
+ @Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Flight.class,
@@ -383,5 +422,26 @@ public void testBasic() throws Exception {
};
}
+ // tests are leaving data around, so drop/recreate schema for now. this is wha the old tests did
+
+ @Override
+ protected boolean createSchema() {
+ return false;
+ }
+
+ @Before
+ public void runCreateSchema() {
+ schemaExport().create( false, true );
+ }
+
+ private SchemaExport schemaExport() {
+ return new SchemaExport( serviceRegistry().getService( JdbcServices.class ), configuration() );
+ }
+
+ @After
+ public void runDropSchema() {
+ schemaExport().drop( false, true );
+ }
+
}
View
44 hibernate-core/src/test/java/org/hibernate/test/annotations/JoinedSubclassTest.java
@@ -1,21 +1,48 @@
-//$Id$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. 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 Inc.
+ *
+ * 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.annotations;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
+
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.inheritance.Carrot;
import org.hibernate.test.annotations.inheritance.Tomato;
import org.hibernate.test.annotations.inheritance.Vegetable;
import org.hibernate.test.annotations.inheritance.VegetablePk;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/**
* @author Emmanuel Bernard
*/
-public class JoinedSubclassTest extends TestCase {
-
- public JoinedSubclassTest(String x) {
- super( x );
- }
-
+public class JoinedSubclassTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testDefaultValues() {
Session s;
Transaction tx;
@@ -39,6 +66,7 @@ public void testDefaultValues() {
s.close();
}
+ @Test
public void testDeclaredValues() {
Session s;
Transaction tx;
@@ -66,6 +94,7 @@ public void testDeclaredValues() {
s.close();
}
+ @Test
public void testCompositePk() throws Exception {
Session s;
Transaction tx;
@@ -91,6 +120,7 @@ public void testCompositePk() throws Exception {
s.close();
}
+ @Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Boat.class,
View
151 hibernate-core/src/test/java/org/hibernate/test/annotations/TestCase.java
@@ -1,151 +0,0 @@
-//$Id$
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2010, Red Hat Inc. 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 Inc.
- *
- * 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.annotations;
-
-import java.io.InputStream;
-import org.hibernate.HibernateException;
-import org.hibernate.Interceptor;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.AnnotationConfiguration;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.testing.junit.functional.annotations.HibernateTestCase;
-
-/**
- * A base class for all annotation tests.
- *
- * @author Emmnauel Bernand
- * @author Hardy Ferentschik
- */
-public abstract class TestCase extends HibernateTestCase {
-
- protected static SessionFactory sessions;
- private Session session;
-
- public TestCase() {
- super();
- }
-
- public TestCase(String name) {
- super( name );
- }
-
- public Session openSession() throws HibernateException {
- session = getSessions().openSession();
- return session;
- }
-
- public Session openSession(Interceptor interceptor) throws HibernateException {
- session = getSessions().openSession( interceptor );
- return session;
- }
-
- protected SessionFactory getSessions() {
- if ( sessions == null ) {
- try {
- buildConfiguration();
- }
- catch ( Exception e ) {
- throw new HibernateException( e );
- }
- }
- return sessions;
- }
-
- protected SessionFactoryImplementor sfi() {
- return (SessionFactoryImplementor) getSessions();
- }
-
- @Override
- protected void buildConfiguration() throws Exception {
- if ( sessions != null ) {
- sessions.close();
- }
- try {
- setCfg( new AnnotationConfiguration() );
- // by default use the new id generator scheme...
- cfg.setProperty( Configuration.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
- configure( cfg );
- if ( recreateSchema() ) {
- cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
- }
- for ( String aPackage : getAnnotatedPackages() ) {
- ( ( AnnotationConfiguration ) getCfg() ).addPackage( aPackage );
- }
- for ( Class<?> aClass : getAnnotatedClasses() ) {
- ( ( AnnotationConfiguration ) getCfg() ).addAnnotatedClass( aClass );
- }
- for ( String xmlFile : getXmlFiles() ) {
- InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile );
- getCfg().addInputStream( is );
- }
- sessions = getCfg().buildSessionFactory( getServiceRegistry() );
- }
- catch ( Exception e ) {
- e.printStackTrace();
- throw e;
- }
- }
-
- @Override
- protected void handleUnclosedResources() {
- if ( session != null && session.isOpen() ) {
- if ( session.isConnected() ) {
- session.doWork( new RollbackWork() );
- }
- session.close();
- session = null;
- fail( "unclosed session" );
- }
- else {
- session = null;
- }
- }
-
- @Override
- protected void closeResources() {
- try {
- if ( session != null && session.isOpen() ) {
- if ( session.isConnected() ) {
- session.doWork( new RollbackWork() );
- }
- session.close();
- }
- }
- catch ( Exception ignore ) {
- }
- try {
- if ( sessions != null ) {
- sessions.close();
- sessions = null;
- }
- }
- catch ( Exception ignore ) {
- }
- super.closeResources();
- }
-}
View
40 hibernate-core/src/test/java/org/hibernate/test/annotations/access/AccessTest.java
@@ -1,14 +1,45 @@
-//$Id$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. 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 Inc.
+ *
+ * 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.annotations.access;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.annotations.TestCase;
+
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
/**
* @author Emmanuel Bernard
*/
-public class AccessTest extends TestCase {
-
+public class AccessTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testSuperclassOverriding() throws Exception {
Furniture fur = new Furniture();
fur.setColor( "Black" );
@@ -28,6 +59,7 @@ public void testSuperclassOverriding() throws Exception {
s.close();
}
+ @Test
public void testSuperclassNonOverriding() throws Exception {
Furniture fur = new Furniture();
fur.setGod( "Buddha" );
View
30 hibernate-core/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java
@@ -1,4 +1,3 @@
-//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
@@ -23,19 +22,30 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.access.jpa;
+
import java.util.ArrayList;
import java.util.List;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.annotations.TestCase;
+
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.access.Closet;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
/**
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
-public class AccessTest extends TestCase {
-
+public class AccessTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testDefaultConfigurationModeIsInherited() throws Exception {
User john = new User();
john.setFirstname( "John" );
@@ -62,6 +72,7 @@ public void testDefaultConfigurationModeIsInherited() throws Exception {
s.close();
}
+ @Test
public void testSuperclassOverriding() throws Exception {
Furniture fur = new Furniture();
fur.setColor( "Black" );
@@ -81,6 +92,7 @@ public void testSuperclassOverriding() throws Exception {
s.close();
}
+ @Test
public void testSuperclassNonOverriding() throws Exception {
Furniture fur = new Furniture();
fur.setGod( "Buddha" );
@@ -97,6 +109,7 @@ public void testSuperclassNonOverriding() throws Exception {
s.close();
}
+ @Test
public void testPropertyOverriding() throws Exception {
Furniture fur = new Furniture();
fur.weight = 3;
@@ -114,6 +127,7 @@ public void testPropertyOverriding() throws Exception {
}
+ @Test
public void testNonOverridenSubclass() throws Exception {
Chair chair = new Chair();
chair.setPillow( "Blue" );
@@ -128,9 +142,9 @@ public void testNonOverridenSubclass() throws Exception {
s.delete( chair );
tx.commit();
s.close();
-
}
+ @Test
public void testOverridenSubclass() throws Exception {
BigBed bed = new BigBed();
bed.size = 5;
@@ -147,9 +161,9 @@ public void testOverridenSubclass() throws Exception {
s.delete( bed );
tx.commit();
s.close();
-
}
+ @Test
public void testFieldsOverriding() throws Exception {
Gardenshed gs = new Gardenshed();
gs.floors = 4;
@@ -165,9 +179,9 @@ public void testFieldsOverriding() throws Exception {
s.delete( gs );
tx.commit();
s.close();
-
}
+ @Test
public void testEmbeddableUsesAccessStrategyOfContainingClass() throws Exception {
Circle circle = new Circle();
Color color = new Color( 5, 10, 15 );
@@ -191,6 +205,7 @@ public void testEmbeddableUsesAccessStrategyOfContainingClass() throws Exception
s.close();
}
+ @Test
public void testEmbeddableExplicitAccessStrategy() throws Exception {
Square square = new Square();
Position pos = new Position( 10, 15 );
@@ -214,6 +229,7 @@ public void testEmbeddableExplicitAccessStrategy() throws Exception {
s.close();
}
+ @Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Bed.class,
View
38 hibernate-core/src/test/java/org/hibernate/test/annotations/any/AnyTest.java
@@ -1,11 +1,42 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. 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 Inc.
+ *
+ * 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.annotations.any;
+
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.annotations.TestCase;
-public class AnyTest extends TestCase {
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class AnyTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testDefaultAnyAssociation() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -52,6 +83,7 @@ public void testDefaultAnyAssociation() {
s.close();
}
+ @Test
public void testManyToAnyWithMap() throws Exception {
Session s = openSession();
@@ -89,6 +121,7 @@ public void testManyToAnyWithMap() throws Exception {
}
+ @Test
public void testMetaDataUseWithManyToAny() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -149,6 +182,7 @@ public void testMetaDataUseWithManyToAny() throws Exception {
};
}
+ @Override
protected String[] getAnnotatedPackages() {
return new String[] {
"org.hibernate.test.annotations.any"
View
48 hibernate-core/src/test/java/org/hibernate/test/annotations/array/ArrayTest.java
@@ -1,15 +1,44 @@
-//$Id$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. 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 Inc.
+ *
+ * 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.annotations.array;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.annotations.TestCase;
+
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.array.Contest.Month;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
/**
* @author Emmanuel Bernard
*/
-public class ArrayTest extends TestCase {
-
+public class ArrayTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testOneToMany() throws Exception {
Session s;
Transaction tx;
@@ -39,15 +68,8 @@ public void testOneToMany() throws Exception {
s.close();
}
- public ArrayTest(String x) {
- super( x );
- }
-
- @SuppressWarnings("unchecked")
+ @Override
protected Class[] getAnnotatedClasses() {
- return new Class[]{
- Competitor.class,
- Contest.class
- };
+ return new Class[] { Competitor.class, Contest.class };
}
}
View
17 hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationAutoTest.java
@@ -21,18 +21,26 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
package org.hibernate.test.annotations.beanvalidation;
-import java.math.BigDecimal;
+
import javax.validation.ConstraintViolationException;
+import java.math.BigDecimal;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.annotations.TestCase;
+
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
-public class BeanValidationAutoTest extends TestCase {
+public class BeanValidationAutoTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testListeners() {
CupHolder ch = new CupHolder();
ch.setRadius( new BigDecimal( "12" ) );
@@ -50,6 +58,7 @@ public void testListeners() {
s.close();
}
+ @Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
CupHolder.class
View
20 hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationDisabledTest.java
@@ -21,21 +21,29 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
package org.hibernate.test.annotations.beanvalidation;
-import java.math.BigDecimal;
+
import javax.validation.ConstraintViolationException;
+import java.math.BigDecimal;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
-import org.hibernate.test.annotations.TestCase;
+
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
-public class BeanValidationDisabledTest extends TestCase {
+public class BeanValidationDisabledTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testListeners() {
CupHolder ch = new CupHolder();
ch.setRadius( new BigDecimal( "12" ) );
@@ -52,8 +60,9 @@ public void testListeners() {
s.close();
}
+ @Test
public void testDDLDisabled() {
- PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() );
+ PersistentClass classMapping = configuration().getClassMapping( Address.class.getName() );
Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next();
assertTrue( "DDL constraints are applied", countryColumn.isNullable() );
}
@@ -64,6 +73,7 @@ protected void configure(Configuration cfg) {
cfg.setProperty( "javax.persistence.validation.mode", "none" );
}
+ @Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
Address.class,
View
19 hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java
@@ -21,22 +21,30 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
package org.hibernate.test.annotations.beanvalidation;
-import java.lang.annotation.Annotation;
-import java.math.BigDecimal;
+
import javax.validation.ConstraintViolationException;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
+import java.lang.annotation.Annotation;
+import java.math.BigDecimal;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
-import org.hibernate.test.annotations.TestCase;
+
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
-public class BeanValidationGroupsTest extends TestCase {
+public class BeanValidationGroupsTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testListeners() {
CupHolder ch = new CupHolder();
ch.setRadius( new BigDecimal( "12" ) );
@@ -96,6 +104,7 @@ protected void configure(Configuration cfg) {
cfg.setProperty( "hibernate.validator.apply_to_ddl", "false" );
}
+ @Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
CupHolder.class
View
19 ...-core/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationProvidedFactoryTest.java
@@ -21,23 +21,31 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
package org.hibernate.test.annotations.beanvalidation;
-import java.math.BigDecimal;
-import java.util.Locale;
+
import javax.validation.ConstraintViolationException;
import javax.validation.MessageInterpolator;
import javax.validation.Validation;
import javax.validation.ValidatorFactory;
+import java.math.BigDecimal;
+import java.util.Locale;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
-import org.hibernate.test.annotations.TestCase;
+
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
-public class BeanValidationProvidedFactoryTest extends TestCase {
+public class BeanValidationProvidedFactoryTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testListeners() {
CupHolder ch = new CupHolder();
ch.setRadius( new BigDecimal( "12" ) );
@@ -56,6 +64,7 @@ public void testListeners() {
s.close();
}
+ @Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
CupHolder.class
View
40 hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLTest.java
@@ -21,12 +21,20 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
package org.hibernate.test.annotations.beanvalidation;
+
import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
-import org.hibernate.test.annotations.TestCase;
+
+import org.junit.Test;
+
+import org.hibernate.testing.TestForIssue;
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
/**
* Test verifying that DDL constraints get applied when Bean Validation / Hibernate Validator are enabled.
@@ -34,10 +42,10 @@
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
-public class DDLTest extends TestCase {
-
+public class DDLTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testBasicDDL() {
- PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() );
+ PersistentClass classMapping = configuration().getClassMapping( Address.class.getName() );
Column stateColumn = (Column) classMapping.getProperty( "state" ).getColumnIterator().next();
assertEquals( stateColumn.getLength(), 3 );
Column zipColumn = (Column) classMapping.getProperty( "zip" ).getColumnIterator().next();
@@ -45,37 +53,38 @@ public void testBasicDDL() {
assertFalse( zipColumn.isNullable() );
}
+ @Test
public void testApplyOnIdColumn() throws Exception {
- PersistentClass classMapping = getCfg().getClassMapping( Tv.class.getName() );
+ PersistentClass classMapping = configuration().getClassMapping( Tv.class.getName() );
Column serialColumn = (Column) classMapping.getIdentifierProperty().getColumnIterator().next();
assertEquals( "Validator annotation not applied on ids", 2, serialColumn.getLength() );
}
- /**
- * HHH-5281
- *
- * @throws Exception in case the test fails
- */
+ @Test
+ @TestForIssue( jiraKey = "HHH-5281" )
public void testLengthConstraint() throws Exception {
- PersistentClass classMapping = getCfg().getClassMapping( Tv.class.getName() );
+ PersistentClass classMapping = configuration().getClassMapping( Tv.class.getName() );
Column modelColumn = (Column) classMapping.getProperty( "model" ).getColumnIterator().next();
assertEquals( modelColumn.getLength(), 5 );
}
+ @Test
public void testApplyOnManyToOne() throws Exception {
- PersistentClass classMapping = getCfg().getClassMapping( TvOwner.class.getName() );
+ PersistentClass classMapping = configuration().getClassMapping( TvOwner.class.getName() );
Column serialColumn = (Column) classMapping.getProperty( "tv" ).getColumnIterator().next();
assertEquals( "Validator annotations not applied on associations", false, serialColumn.isNullable() );
}
+ @Test
public void testSingleTableAvoidNotNull() throws Exception {
- PersistentClass classMapping = getCfg().getClassMapping( Rock.class.getName() );
+ PersistentClass classMapping = configuration().getClassMapping( Rock.class.getName() );
Column serialColumn = (Column) classMapping.getProperty( "bit" ).getColumnIterator().next();
assertTrue( "Notnull should not be applied on single tables", serialColumn.isNullable() );
}
+ @Test
public void testNotNullOnlyAppliedIfEmbeddedIsNotNullItself() throws Exception {
- PersistentClass classMapping = getCfg().getClassMapping( Tv.class.getName() );
+ PersistentClass classMapping = configuration().getClassMapping( Tv.class.getName() );
Property property = classMapping.getProperty( "tuner.frequency" );
Column serialColumn = (Column) property.getColumnIterator().next();
assertEquals(
@@ -89,6 +98,7 @@ public void testNotNullOnlyAppliedIfEmbeddedIsNotNullItself() throws Exception {
);
}
+ @Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
Address.class,
View
22 hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java
@@ -21,24 +21,32 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
package org.hibernate.test.annotations.beanvalidation;
-import java.math.BigDecimal;
+
import javax.validation.ConstraintViolationException;
+import java.math.BigDecimal;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
-import org.hibernate.test.annotations.TestCase;
+
+import org.junit.Test;
+
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
/**
* @author Vladimir Klyushnikov
* @author Hardy Ferentschik
*/
-public class DDLWithoutCallbackTest extends TestCase {
+public class DDLWithoutCallbackTest extends BaseCoreFunctionalTestCase {
+ @Test
@RequiresDialectFeature(DialectChecks.SupportsColumnCheck.class)
public void testListeners() {
CupHolder ch = new CupHolder();
@@ -46,6 +54,7 @@ public void testListeners() {
assertDatabaseConstraintViolationThrown( ch );
}
+ @Test
@RequiresDialectFeature(DialectChecks.SupportsColumnCheck.class)
public void testMinAndMaxChecksGetApplied() {
MinMax minMax = new MinMax( 1 );
@@ -63,6 +72,7 @@ public void testMinAndMaxChecksGetApplied() {
s.close();
}
+ @Test
@RequiresDialectFeature(DialectChecks.SupportsColumnCheck.class)
public void testRangeChecksGetApplied() {
Range range = new Range( 1 );
@@ -80,8 +90,9 @@ public void testRangeChecksGetApplied() {
s.close();
}
+ @Test
public void testDDLEnabled() {
- PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() );
+ PersistentClass classMapping = configuration().getClassMapping( Address.class.getName() );
Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next();
assertFalse( "DDL constraints are not applied", countryColumn.isNullable() );
}
@@ -92,6 +103,7 @@ protected void configure(Configuration cfg) {
cfg.setProperty( "javax.persistence.validation.mode", "ddl" );
}
+ @Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
Address.class,
View
22 ...e-core/src/test/java/org/hibernate/test/annotations/beanvalidation/HibernateTraversableResolverTest.java
@@ -21,20 +21,28 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-
package org.hibernate.test.annotations.beanvalidation;
-import java.math.BigDecimal;
+
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
+import java.math.BigDecimal;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
-import org.hibernate.test.annotations.TestCase;
+
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
-public class HibernateTraversableResolverTest extends TestCase {
+public class HibernateTraversableResolverTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testNonLazyAssocFieldWithConstraintsFailureExpected() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -54,6 +62,7 @@ public void testNonLazyAssocFieldWithConstraintsFailureExpected() {
s.close();
}
+ @Test
public void testEmbedded() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -82,6 +91,7 @@ public void testEmbedded() {
s.close();
}
+ @Test
public void testToOneAssocNotValidated() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -106,6 +116,7 @@ public void testToOneAssocNotValidated() {
s.close();
}
+ @Test
public void testCollectionAssocNotValidated() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -135,6 +146,7 @@ public void testCollectionAssocNotValidated() {
s.close();
}
+ @Test
public void testEmbeddedCollection() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -162,6 +174,7 @@ public void testEmbeddedCollection() {
s.close();
}
+ @Test
public void testAssocInEmbeddedNotValidated() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -201,6 +214,7 @@ protected void configure(Configuration cfg) {
cfg.setProperty( "hibernate.validator.autoregister_listeners", "false" );
}
+ @Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
Button.class,
View
117 hibernate-core/src/test/java/org/hibernate/test/annotations/bytecode/ProxyBreakingTest.java
@@ -1,51 +1,68 @@
-//$Id$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. 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 Inc.
+ *
+ * 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.annotations.bytecode;
-import org.hibernate.Hibernate;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.test.annotations.TestCase;
-
-/**
- * @author Emmanuel Bernard
- */
-public class ProxyBreakingTest extends TestCase {
-
- static {
- System.setProperty( "hibernate.bytecode.provider", "javassist" );
- }
-
- public void testProxiedBridgeMethod() throws Exception {
- //bridge methods should not be proxied
- Session s = openSession();
- Transaction tx = s.beginTransaction();
- Hammer h = new Hammer();
- s.save(h);
- s.flush();
- s.clear();
- assertNotNull( "The proxy creation failure is breaking things", h.getId() );
- h = (Hammer) s.load( Hammer.class, h.getId() );
- assertFalse( Hibernate.isInitialized( h ) );
- tx.rollback();
- s.close();
- }
-
- public ProxyBreakingTest(String name) {
- super( name );
- }
-
- protected Class[] getAnnotatedClasses() {
- return new Class[0];
- }
-
- protected String[] getXmlFiles() {
- return new String[] {
- "org/hibernate/test/annotations/bytecode/Hammer.hbm.xml"
- };
- }
-
- @Override
- protected void configure(Configuration cfg) {
- super.configure( cfg.setProperty( "hibernate.bytecode.provider", "javassist" ) );
- }
-}
+
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class ProxyBreakingTest extends BaseCoreFunctionalTestCase {
+ @Test
+ public void testProxiedBridgeMethod() throws Exception {
+ //bridge methods should not be proxied
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Hammer h = new Hammer();
+ s.save(h);
+ s.flush();
+ s.clear();
+ assertNotNull( "The proxy creation failure is breaking things", h.getId() );
+ h = (Hammer) s.load( Hammer.class, h.getId() );
+ assertFalse( Hibernate.isInitialized( h ) );
+ tx.rollback();
+ s.close();
+ }
+
+ @Override
+ protected Class[] getAnnotatedClasses() {
+ return new Class[0];
+ }
+
+ @Override
+ protected String[] getXmlFiles() {
+ return new String[] {
+ "org/hibernate/test/annotations/bytecode/Hammer.hbm.xml"
+ };
+ }
+}
View
23 hibernate-core/src/test/java/org/hibernate/test/annotations/cascade/CascadeTest.java
@@ -29,15 +29,24 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.annotations.TestCase;
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
/**
* Check some of the individual cascade styles
*
+ * @todo do something for refresh
+ *
* @author Emmanuel Bernard
*/
-//FIXME do somthing for refresh
-public class CascadeTest extends TestCase {
+public class CascadeTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testPersist() {
Session s;
Transaction tx;
@@ -58,6 +67,7 @@ public void testPersist() {
s.close();
}
+ @Test
public void testMerge() {
Session s;
Transaction tx;
@@ -95,6 +105,7 @@ public void testMerge() {
s.close();
}
+ @Test
public void testRemove() {
Session s;
Transaction tx;
@@ -126,6 +137,7 @@ public void testRemove() {
s.close();
}
+ @Test
public void testDetach() {
Session s;
Transaction tx;
@@ -160,10 +172,7 @@ public void testDetach() {
s.close();
}
- public CascadeTest(String x) {
- super( x );
- }
-
+ @Override
protected Class[] getAnnotatedClasses() {
return new Class[]{
Mouth.class,
View
53 hibernate-core/src/test/java/org/hibernate/test/annotations/cid/CompositeIdTest.java
@@ -1,26 +1,53 @@
-//$Id$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. 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 Inc.
+ *
+ * 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.annotations.cid;
+
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Disjunction;
import org.hibernate.criterion.Restrictions;
-import org.hibernate.test.annotations.TestCase;
+
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* test some composite id functionalities
*
* @author Emmanuel Bernard
*/
-public class CompositeIdTest extends TestCase {
- public CompositeIdTest(String x) {
- super( x );
- }
-
+public class CompositeIdTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testOneToOneInCompositePk() throws Exception {
Session s;
Transaction tx;
@@ -50,6 +77,7 @@ public void testOneToOneInCompositePk() throws Exception {
* This feature is not supported by the EJB3
* this is an hibernate extension
*/
+ @Test
public void testManyToOneInCompositePk() throws Exception {
Session s;
Transaction tx;
@@ -92,6 +120,7 @@ public void testManyToOneInCompositePk() throws Exception {
* This feature is not supported by the EJB3
* this is an hibernate extension
*/
+ @Test
public void testManyToOneInCompositePkAndSubclass() throws Exception {
Session s;
Transaction tx;
@@ -131,6 +160,7 @@ public void testManyToOneInCompositePkAndSubclass() throws Exception {
s.close();
}
+ @Test
public void testManyToOneInCompositeId() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -162,6 +192,7 @@ public void testManyToOneInCompositeId() throws Exception {
s.close();
}
+ @Test
public void testManyToOneInCompositeIdClass() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -187,6 +218,7 @@ public void testManyToOneInCompositeIdClass() throws Exception {
s.close();
}
+ @Test
public void testSecondaryTableWithCompositeId() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -220,6 +252,7 @@ public void testSecondaryTableWithCompositeId() throws Exception {
s.close();
}
+ @Test
public void testSecondaryTableWithIdClass() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -250,6 +283,7 @@ public void testSecondaryTableWithIdClass() throws Exception {
s.close();
}
+ @Test
public void testQueryInAndComposite() {
Session s = openSession( );
@@ -271,6 +305,8 @@ public void testQueryInAndComposite() {
transaction.rollback();
s.close();
}
+
+ @Test
public void testQueryInAndCompositeWithHQL() {
Session s = openSession( );
Transaction transaction = s.beginTransaction();
@@ -288,7 +324,6 @@ public void testQueryInAndCompositeWithHQL() {
s.close();
}
-
private void createData(Session s){
SomeEntity someEntity = new SomeEntity();
someEntity.setId( new SomeEntityId( ) );
@@ -325,6 +360,8 @@ private void createData(Session s){
someEntity.setProp( "cc3" );
s.persist( someEntity );
}
+
+ @Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Parent.class,
View
17 hibernate-core/src/test/java/org/hibernate/test/annotations/cid/keymanytoone/EagerKeyManyToOneTest.java
@@ -22,15 +22,22 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.cid.keymanytoone;
+
import org.hibernate.Session;
-import org.hibernate.test.annotations.TestCase;
+
+import org.junit.Test;
+
+import org.hibernate.testing.TestForIssue;
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
/**
- * TODO : javadoc
- *
* @author Steve Ebersole
*/
-public class EagerKeyManyToOneTest extends TestCase {
+public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase {
public static final String CARD_ID = "cardId";
public static final String KEY_ID = "keyId";
@@ -39,6 +46,8 @@
return new Class[] { Card.class, CardField.class, Key.class, PrimaryKey.class };
}
+ @Test
+ @TestForIssue( jiraKey = "HHH-4147" )
public void testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelf() {
// based on the core testsuite test of same name in org.hibernate.test.keymanytoone.bidir.component.EagerKeyManyToOneTest
// meant to test against regression relating to http://opensource.atlassian.com/projects/hibernate/browse/HHH-2277
View
56 hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java
@@ -1,29 +1,60 @@
-//$Id$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. 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 Inc.
+ *
+ * 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.annotations.collectionelement;
+
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
+
import org.hibernate.Filter;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
+
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.Country;
-import org.hibernate.test.annotations.TestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
@SuppressWarnings("unchecked")
-public class CollectionElementTest extends TestCase {
-
+public class CollectionElementTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testSimpleElement() throws Exception {
assertEquals(
"BoyFavoriteNumbers",
- getCfg().getCollectionMapping( Boy.class.getName() + '.' + "favoriteNumbers" )
+ configuration().getCollectionMapping( Boy.class.getName() + '.' + "favoriteNumbers" )
.getCollectionTable().getName()
);
Session s = openSession();
@@ -72,6 +103,7 @@ public void testSimpleElement() throws Exception {
s.close();
}
+ @Test
public void testCompositeElement() throws Exception {
Session s = openSession();
s.getTransaction().begin();
@@ -97,6 +129,7 @@ public void testCompositeElement() throws Exception {
s.close();
}
+ @Test
public void testAttributedJoin() throws Exception {
Session s = openSession();
s.getTransaction().begin();
@@ -124,13 +157,13 @@ public void testAttributedJoin() throws Exception {
s.delete( s.get( Country.class, country.getId() ) );
tx.commit();
s.close();
-
}
+ @Test
public void testLazyCollectionofElements() throws Exception {
assertEquals(
"BoyFavoriteNumbers",
- getCfg().getCollectionMapping( Boy.class.getName() + '.' + "favoriteNumbers" )
+ configuration().getCollectionMapping( Boy.class.getName() + '.' + "favoriteNumbers" )
.getCollectionTable().getName()
);
Session s = openSession();
@@ -170,6 +203,7 @@ public void testLazyCollectionofElements() throws Exception {
s.close();
}
+ @Test
public void testFetchEagerAndFilter() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -199,6 +233,7 @@ public void testFetchEagerAndFilter() throws Exception {
s.close();
}
+ @Test
public void testMapKeyType() throws Exception {
Matrix m = new Matrix();
m.getMvalues().put( 1, 1.1f );
@@ -208,11 +243,12 @@ public void testMapKeyType() throws Exception {
s.flush();
s.clear();
m = (Matrix) s.get( Matrix.class, m.getId() );
- assertEquals( 1.1f, m.getMvalues().get( 1 ) );
+ assertEquals( 1.1f, m.getMvalues().get( 1 ), 0.01f );
tx.rollback();
s.close();
}
+ @Test
public void testDefaultValueColumnForBasic() throws Exception {
isDefaultValueCollectionColumnPresent( Boy.class.getName(), "hatedNames" );
isDefaultValueCollectionColumnPresent( Boy.class.getName(), "preferredNames" );
@@ -220,6 +256,7 @@ public void testDefaultValueColumnForBasic() throws Exception {
isDefaultValueCollectionColumnPresent( Boy.class.getName(), "scorePerPreferredName");
}
+ @Test
public void testDefaultFKNameForElementCollection() throws Exception {
isCollectionColumnPresent( Boy.class.getName(), "hatedNames", "Boy_id" );
}
@@ -233,7 +270,7 @@ private void isDefaultValueCollectionColumnPresent(String collectionOwner, Strin
}
private void isCollectionColumnPresent(String collectionOwner, String propertyName, String columnName) {
- final Collection collection = getCfg().getCollectionMapping( collectionOwner + "." + propertyName );
+ final Collection collection = configuration().getCollectionMapping( collectionOwner + "." + propertyName );
final Iterator columnIterator = collection.getCollectionTable().getColumnIterator();
boolean hasDefault = false;
while ( columnIterator.hasNext() ) {
@@ -243,6 +280,7 @@ private void isCollectionColumnPresent(String collectionOwner, String propertyNa
assertTrue( "Could not find " + columnName, hasDefault );
}
+ @Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Boy.class,
View
40 hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/OrderByTest.java
@@ -1,17 +1,41 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. 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 Inc.
+ *
+ * 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.annotations.collectionelement;
+
import java.util.HashSet;
import java.util.Iterator;
-import junit.framework.Assert;
+
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.test.annotations.TestCase;
-public class OrderByTest extends TestCase {
+import org.junit.Test;
+import junit.framework.Assert;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
- /**
- * Test @OrderBy on the Widgets.name field.
- *
- */
+public class OrderByTest extends BaseCoreFunctionalTestCase {
+ @Test
public void testOrderByName() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -50,6 +74,7 @@ public void testOrderByName() throws Exception {
s.close();
}
+ @Test
public void testOrderByWithDottedNotation() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
@@ -101,6 +126,7 @@ public void testOrderByWithDottedNotation() throws Exception {
}
+ @Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Products.class,
View
55 ...a/org/hibernate/test/annotations/collectionelement/deepcollectionelements/DeepCollectionElementTest.java
@@ -1,24 +1,47 @@
-//$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. 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 Inc.
+ *
+ * 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.annotations.collectionelement.deepcollectionelements;
-import org.hibernate.test.annotations.TestCase;
+
+import org.hibernate.cfg.Configuration;
+
+import org.junit.Test;
+
+import org.hibernate.testing.FailureExpected;
+import org.hibernate.testing.ServiceRegistryBuilder;
+import org.hibernate.testing.junit4.BaseUnitTestCase;
/**
* @author Emmanuel Bernard
*/
-
-//TEST not used: wait for ANN-591 and HHH-3157
-public class DeepCollectionElementTest extends TestCase {
-
+@FailureExpected( jiraKey = "HHH-3157" )
+public class DeepCollectionElementTest extends BaseUnitTestCase {
+ @Test
public void testInitialization() throws Exception {
- //test only the SF creation
-
- }
-
- protected Class[] getAnnotatedClasses() {
- return new Class[] {
- //A.class,
- //B.class,
- //C.class
- };
+ Configuration configuration = new Configuration();
+ configuration.addAnnotatedClass( A.class );
+ configuration.addAnnotatedClass( B.class );
+ configuration.addAnnotatedClass( C.class );
+ configuration.buildSessionFactory( ServiceRegistryBuilder.buildServiceRegistry( configuration.getProperties() ) );
}
}
View
37 .../org/hibernate/test/annotations/collectionelement/indexedCollection/IndexedCollectionOfElementsTest.java
@@ -1,13 +1,41 @@
-//$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. 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 Inc.
+ *
+ * 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
+ */