HHH-7569 Correct test-only failures in hibernate-core-master-matrix CI

job
This commit is contained in:
brmeyer 2012-09-19 05:24:51 -04:00
parent 8c58af3b19
commit 6660d2412a
3 changed files with 228 additions and 326 deletions

View File

@ -1,14 +1,18 @@
package org.hibernate.test.hqlfetchscroll; package org.hibernate.test.hqlfetchscroll;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import org.junit.Test;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.ScrollableResults; import org.hibernate.ScrollableResults;
import org.hibernate.Session; import org.hibernate.Session;
@ -17,18 +21,11 @@
import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.SQLServerDialect; import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.transform.DistinctRootEntityResultTransformer; import org.hibernate.transform.DistinctRootEntityResultTransformer;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase { public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
@ -36,24 +33,15 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
@Test @Test
public void testNoScroll() { public void testNoScroll() {
try {
insertTestData();
Session s = openSession(); Session s = openSession();
List list = s.createQuery( QUERY ).setResultTransformer( DistinctRootEntityResultTransformer.INSTANCE ).list(); List list = s.createQuery( QUERY ).setResultTransformer( DistinctRootEntityResultTransformer.INSTANCE ).list();
assertResultFromAllUsers( list ); assertResultFromAllUsers( list );
s.close(); s.close();
} }
finally {
deleteAll();
}
}
@Test @Test
@SkipForDialect( { SQLServerDialect.class, Oracle8iDialect.class, H2Dialect.class } ) @SkipForDialect( { SQLServerDialect.class, Oracle8iDialect.class, H2Dialect.class } )
public void testScroll() { public void testScroll() {
//"SQL Server, Oracle, and H2 do not sort the result set automatically, so failure as expected","HQLScrollFetchTest" );
try {
insertTestData();
Session s = openSession(); Session s = openSession();
ScrollableResults results = s.createQuery( QUERY ).scroll(); ScrollableResults results = s.createQuery( QUERY ).scroll();
List list = new ArrayList(); List list = new ArrayList();
@ -63,15 +51,9 @@ public void testScroll() {
assertResultFromAllUsers( list ); assertResultFromAllUsers( list );
s.close(); s.close();
} }
finally {
deleteAll();
}
}
@Test @Test
public void testIncompleteScrollFirstResult() { public void testIncompleteScrollFirstResult() {
try {
insertTestData();
Session s = openSession(); Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll(); ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll();
results.next(); results.next();
@ -79,16 +61,10 @@ public void testIncompleteScrollFirstResult() {
assertResultFromOneUser( p ); assertResultFromOneUser( p );
s.close(); s.close();
} }
finally {
deleteAll();
}
}
@Test @Test
@TestForIssue( jiraKey = "HHH-1283" ) @TestForIssue( jiraKey = "HHH-1283" )
public void testIncompleteScrollSecondResult() { public void testIncompleteScrollSecondResult() {
try {
insertTestData();
Session s = openSession(); Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll(); ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll();
results.next(); results.next();
@ -99,15 +75,9 @@ public void testIncompleteScrollSecondResult() {
assertResultFromOneUser( p ); assertResultFromOneUser( p );
s.close(); s.close();
} }
finally {
deleteAll();
}
}
@Test @Test
public void testIncompleteScrollFirstResultInTransaction() { public void testIncompleteScrollFirstResultInTransaction() {
try {
insertTestData();
Session s = openSession(); Session s = openSession();
Transaction tx = s.beginTransaction(); Transaction tx = s.beginTransaction();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll(); ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll();
@ -117,16 +87,10 @@ public void testIncompleteScrollFirstResultInTransaction() {
tx.commit(); tx.commit();
s.close(); s.close();
} }
finally {
deleteAll();
}
}
@Test @Test
@TestForIssue( jiraKey = "HHH-1283" ) @TestForIssue( jiraKey = "HHH-1283" )
public void testIncompleteScrollSecondResultInTransaction() { public void testIncompleteScrollSecondResultInTransaction() {
try {
insertTestData();
Session s = openSession(); Session s = openSession();
Transaction tx = s.beginTransaction(); Transaction tx = s.beginTransaction();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll(); ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll();
@ -139,16 +103,10 @@ public void testIncompleteScrollSecondResultInTransaction() {
tx.commit(); tx.commit();
s.close(); s.close();
} }
finally {
deleteAll();
}
}
@Test @Test
@TestForIssue( jiraKey = "HHH-1283") @TestForIssue( jiraKey = "HHH-1283")
public void testIncompleteScroll() { public void testIncompleteScroll() {
try {
insertTestData();
Session s = openSession(); Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll(); ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll();
results.next(); results.next();
@ -184,16 +142,10 @@ else if ( Child.class.isInstance( entity ) ) {
assertNull( cOther ); assertNull( cOther );
s.close(); s.close();
} }
finally {
deleteAll();
}
}
@Test @Test
@TestForIssue( jiraKey = "HHH-1283" ) @TestForIssue( jiraKey = "HHH-1283" )
public void testIncompleteScrollLast() { public void testIncompleteScrollLast() {
try {
insertTestData();
Session s = openSession(); Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll(); ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll();
results.next(); results.next();
@ -232,16 +184,10 @@ else if ( Child.class.isInstance( entity ) ) {
assertResultFromOneUser( pOther ); assertResultFromOneUser( pOther );
s.close(); s.close();
} }
finally {
deleteAll();
}
}
@Test @Test
@TestForIssue( jiraKey = "HHH-1283" ) @TestForIssue( jiraKey = "HHH-1283" )
public void testScrollOrderParentAsc() { public void testScrollOrderParentAsc() {
try {
insertTestData();
Session s = openSession(); Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll(); ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll();
List list = new ArrayList(); List list = new ArrayList();
@ -251,16 +197,10 @@ public void testScrollOrderParentAsc() {
assertResultFromAllUsers( list ); assertResultFromAllUsers( list );
s.close(); s.close();
} }
finally {
deleteAll();
}
}
@Test @Test
@TestForIssue( jiraKey = "HHH-1283" ) @TestForIssue( jiraKey = "HHH-1283" )
public void testScrollOrderParentDesc() { public void testScrollOrderParentDesc() {
try {
insertTestData();
Session s = openSession(); Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name desc" ).scroll(); ScrollableResults results = s.createQuery( QUERY + " order by p.name desc" ).scroll();
List list = new ArrayList(); List list = new ArrayList();
@ -270,16 +210,10 @@ public void testScrollOrderParentDesc() {
assertResultFromAllUsers( list ); assertResultFromAllUsers( list );
s.close(); s.close();
} }
finally {
deleteAll();
}
}
@Test @Test
@TestForIssue( jiraKey = "HHH-1283" ) @TestForIssue( jiraKey = "HHH-1283" )
public void testScrollOrderParentAscChildrenAsc() { public void testScrollOrderParentAscChildrenAsc() {
try {
insertTestData();
Session s = openSession(); Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc, c.name asc" ).scroll(); ScrollableResults results = s.createQuery( QUERY + " order by p.name asc, c.name asc" ).scroll();
List list = new ArrayList(); List list = new ArrayList();
@ -289,16 +223,10 @@ public void testScrollOrderParentAscChildrenAsc() {
assertResultFromAllUsers( list ); assertResultFromAllUsers( list );
s.close(); s.close();
} }
finally {
deleteAll();
}
}
@Test @Test
@TestForIssue( jiraKey = "HHH-1283" ) @TestForIssue( jiraKey = "HHH-1283" )
public void testScrollOrderParentAscChildrenDesc() { public void testScrollOrderParentAscChildrenDesc() {
try {
insertTestData();
Session s = openSession(); Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc, c.name desc" ).scroll(); ScrollableResults results = s.createQuery( QUERY + " order by p.name asc, c.name desc" ).scroll();
List list = new ArrayList(); List list = new ArrayList();
@ -308,15 +236,9 @@ public void testScrollOrderParentAscChildrenDesc() {
assertResultFromAllUsers( list ); assertResultFromAllUsers( list );
s.close(); s.close();
} }
finally {
deleteAll();
}
}
@Test @Test
public void testScrollOrderChildrenDesc() { public void testScrollOrderChildrenDesc() {
try {
insertTestData();
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
Parent p0 = new Parent( "parent0" ); Parent p0 = new Parent( "parent0" );
@ -340,15 +262,9 @@ public void testScrollOrderChildrenDesc() {
s.close(); s.close();
} }
} }
finally {
deleteAll();
}
}
@Test @Test
public void testListOrderChildrenDesc() { public void testListOrderChildrenDesc() {
try {
insertTestData();
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
Parent p0 = new Parent( "parent0" ); Parent p0 = new Parent( "parent0" );
@ -368,10 +284,6 @@ public void testListOrderChildrenDesc() {
s.close(); s.close();
} }
} }
finally {
deleteAll();
}
}
private void assertResultFromOneUser(Parent parent) { private void assertResultFromOneUser(Parent parent) {
assertEquals( assertEquals(
@ -388,17 +300,8 @@ private void assertResultFromAllUsers(List list) {
} }
} }
private void deleteAll() { @Override
Session s = openSession(); protected void prepareTest() throws Exception {
Transaction t = s.beginTransaction();
List list = s.createQuery( "from Parent" ).list();
for ( Iterator i = list.iterator(); i.hasNext(); ) {
s.delete( (Parent) i.next() );
}
t.commit();
s.close();
}
private void insertTestData() {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
Child child_1_1 = new Child( "achild1-1"); Child child_1_1 = new Child( "achild1-1");
@ -433,24 +336,19 @@ private void insertTestData() {
s.close(); s.close();
} }
// private void insertTestData() { @Override
// Session s = openSession(); protected void cleanupTest() throws Exception {
// Transaction t = s.beginTransaction(); Session s = openSession();
// s.save( makeParent( "parent1", "child1-1", "child1-2", "child1-3" ) ); Transaction t = s.beginTransaction();
// s.save( makeParent( "parent2", "child2-1", "child2-2", "child2-3" ) ); List list = s.createQuery( "from Parent" ).list();
// t.commit(); for ( Iterator i = list.iterator(); i.hasNext(); ) {
// s.close(); s.delete( (Parent) i.next() );
// } }
t.commit();
s.close();
}
public String[] getMappings() { public String[] getMappings() {
return new String[] { "hqlfetchscroll/ParentChild.hbm.xml" }; return new String[] { "hqlfetchscroll/ParentChild.hbm.xml" };
} }
// protected Object makeParent(String name, String child1, String child2, String child3) {
// Parent parent = new Parent( name );
// parent.addChild( new Child( child1 ) );
// parent.addChild( new Child( child2 ) );
// parent.addChild( new Child( child3 ) );
// return parent;
// }
} }

View File

@ -23,6 +23,11 @@
*/ */
package org.hibernate.jpa.test.packaging; package org.hibernate.jpa.test.packaging;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
@ -30,12 +35,12 @@
import java.net.URLStreamHandler; import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory; import java.net.URLStreamHandlerFactory;
import java.util.Set; import java.util.Set;
import javax.persistence.Embeddable; import javax.persistence.Embeddable;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import org.junit.Test; import org.hibernate.dialect.H2Dialect;
import org.hibernate.jpa.packaging.internal.ClassFilter; import org.hibernate.jpa.packaging.internal.ClassFilter;
import org.hibernate.jpa.packaging.internal.Entry; import org.hibernate.jpa.packaging.internal.Entry;
import org.hibernate.jpa.packaging.internal.ExplodedJarVisitor; import org.hibernate.jpa.packaging.internal.ExplodedJarVisitor;
@ -47,20 +52,17 @@
import org.hibernate.jpa.packaging.internal.JarVisitor; import org.hibernate.jpa.packaging.internal.JarVisitor;
import org.hibernate.jpa.packaging.internal.JarVisitorFactory; import org.hibernate.jpa.packaging.internal.JarVisitorFactory;
import org.hibernate.jpa.packaging.internal.PackageFilter; import org.hibernate.jpa.packaging.internal.PackageFilter;
import org.hibernate.jpa.test.pack.explodedpar.Carpet;
import org.hibernate.jpa.test.pack.defaultpar.Version; import org.hibernate.jpa.test.pack.defaultpar.Version;
import org.hibernate.jpa.test.pack.explodedpar.Carpet;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
* @author Hardy Ferentschik * @author Hardy Ferentschik
*/ */
@RequiresDialect( H2Dialect.class ) // Nothing dialect-specific -- no need to run in matrix.
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class JarVisitorTest extends PackagingTestCase { public class JarVisitorTest extends PackagingTestCase {
@Test @Test

View File

@ -447,7 +447,9 @@ protected void cleanupCache() {
sessionFactory.getCache().evictNaturalIdRegions(); sessionFactory.getCache().evictNaturalIdRegions();
} }
} }
protected boolean isCleanupTestDataRequired() { return false; } protected boolean isCleanupTestDataRequired() { return false; }
protected void cleanupTestData() throws Exception { protected void cleanupTestData() throws Exception {
Session s = openSession(); Session s = openSession();
s.beginTransaction(); s.beginTransaction();