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;
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.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.hibernate.Hibernate;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
@ -17,18 +21,11 @@ import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.transform.DistinctRootEntityResultTransformer;
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 org.junit.Test;
public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
@ -36,24 +33,15 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
@Test
public void testNoScroll() {
try {
insertTestData();
Session s = openSession();
List list = s.createQuery( QUERY ).setResultTransformer( DistinctRootEntityResultTransformer.INSTANCE ).list();
assertResultFromAllUsers( list );
s.close();
}
finally {
deleteAll();
}
}
@Test
@SkipForDialect( { SQLServerDialect.class, Oracle8iDialect.class, H2Dialect.class } )
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();
ScrollableResults results = s.createQuery( QUERY ).scroll();
List list = new ArrayList();
@ -63,15 +51,9 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
assertResultFromAllUsers( list );
s.close();
}
finally {
deleteAll();
}
}
@Test
public void testIncompleteScrollFirstResult() {
try {
insertTestData();
Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll();
results.next();
@ -79,16 +61,10 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
assertResultFromOneUser( p );
s.close();
}
finally {
deleteAll();
}
}
@Test
@TestForIssue( jiraKey = "HHH-1283" )
public void testIncompleteScrollSecondResult() {
try {
insertTestData();
Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll();
results.next();
@ -99,15 +75,9 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
assertResultFromOneUser( p );
s.close();
}
finally {
deleteAll();
}
}
@Test
public void testIncompleteScrollFirstResultInTransaction() {
try {
insertTestData();
Session s = openSession();
Transaction tx = s.beginTransaction();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll();
@ -117,16 +87,10 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
tx.commit();
s.close();
}
finally {
deleteAll();
}
}
@Test
@TestForIssue( jiraKey = "HHH-1283" )
public void testIncompleteScrollSecondResultInTransaction() {
try {
insertTestData();
Session s = openSession();
Transaction tx = s.beginTransaction();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll();
@ -139,16 +103,10 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
tx.commit();
s.close();
}
finally {
deleteAll();
}
}
@Test
@TestForIssue( jiraKey = "HHH-1283")
public void testIncompleteScroll() {
try {
insertTestData();
Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll();
results.next();
@ -184,16 +142,10 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
assertNull( cOther );
s.close();
}
finally {
deleteAll();
}
}
@Test
@TestForIssue( jiraKey = "HHH-1283" )
public void testIncompleteScrollLast() {
try {
insertTestData();
Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll();
results.next();
@ -232,16 +184,10 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
assertResultFromOneUser( pOther );
s.close();
}
finally {
deleteAll();
}
}
@Test
@TestForIssue( jiraKey = "HHH-1283" )
public void testScrollOrderParentAsc() {
try {
insertTestData();
Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc" ).scroll();
List list = new ArrayList();
@ -251,16 +197,10 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
assertResultFromAllUsers( list );
s.close();
}
finally {
deleteAll();
}
}
@Test
@TestForIssue( jiraKey = "HHH-1283" )
public void testScrollOrderParentDesc() {
try {
insertTestData();
Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name desc" ).scroll();
List list = new ArrayList();
@ -270,16 +210,10 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
assertResultFromAllUsers( list );
s.close();
}
finally {
deleteAll();
}
}
@Test
@TestForIssue( jiraKey = "HHH-1283" )
public void testScrollOrderParentAscChildrenAsc() {
try {
insertTestData();
Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc, c.name asc" ).scroll();
List list = new ArrayList();
@ -289,16 +223,10 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
assertResultFromAllUsers( list );
s.close();
}
finally {
deleteAll();
}
}
@Test
@TestForIssue( jiraKey = "HHH-1283" )
public void testScrollOrderParentAscChildrenDesc() {
try {
insertTestData();
Session s = openSession();
ScrollableResults results = s.createQuery( QUERY + " order by p.name asc, c.name desc" ).scroll();
List list = new ArrayList();
@ -308,15 +236,9 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
assertResultFromAllUsers( list );
s.close();
}
finally {
deleteAll();
}
}
@Test
public void testScrollOrderChildrenDesc() {
try {
insertTestData();
Session s = openSession();
Transaction t = s.beginTransaction();
Parent p0 = new Parent( "parent0" );
@ -340,15 +262,9 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
s.close();
}
}
finally {
deleteAll();
}
}
@Test
public void testListOrderChildrenDesc() {
try {
insertTestData();
Session s = openSession();
Transaction t = s.beginTransaction();
Parent p0 = new Parent( "parent0" );
@ -368,10 +284,6 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
s.close();
}
}
finally {
deleteAll();
}
}
private void assertResultFromOneUser(Parent parent) {
assertEquals(
@ -388,17 +300,8 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
}
}
private void deleteAll() {
Session s = openSession();
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() {
@Override
protected void prepareTest() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
Child child_1_1 = new Child( "achild1-1");
@ -431,26 +334,21 @@ public class HQLScrollFetchTest extends BaseCoreFunctionalTestCase {
t.commit();
s.close();
}
}
// private void insertTestData() {
// Session s = openSession();
// Transaction t = s.beginTransaction();
// s.save( makeParent( "parent1", "child1-1", "child1-2", "child1-3" ) );
// s.save( makeParent( "parent2", "child2-1", "child2-2", "child2-3" ) );
// t.commit();
// s.close();
// }
@Override
protected void cleanupTest() throws Exception {
Session s = openSession();
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();
}
public String[] getMappings() {
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;
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.IOException;
import java.net.URL;
@ -30,12 +35,12 @@ import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;
import java.util.Set;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
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.Entry;
import org.hibernate.jpa.packaging.internal.ExplodedJarVisitor;
@ -47,20 +52,17 @@ import org.hibernate.jpa.packaging.internal.JarProtocolVisitor;
import org.hibernate.jpa.packaging.internal.JarVisitor;
import org.hibernate.jpa.packaging.internal.JarVisitorFactory;
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.explodedpar.Carpet;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue;
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 org.junit.Test;
/**
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
@RequiresDialect( H2Dialect.class ) // Nothing dialect-specific -- no need to run in matrix.
@SuppressWarnings("unchecked")
public class JarVisitorTest extends PackagingTestCase {
@Test

View File

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