HHH-8814 simplified the test a bit

This commit is contained in:
Brett Meyer 2014-02-12 13:00:42 -05:00
parent 949df8bd00
commit 7d828b1d25
2 changed files with 17 additions and 20 deletions

View File

@ -3,16 +3,16 @@ package org.hibernate.test.id;
public class Person {
private Long id;
private long id;
public Person() {
}
public Long getId() {
public long getId() {
return id;
}
public void setId(final Long id) {
public void setId(final long id) {
this.id = id;
}

View File

@ -1,9 +1,12 @@
package org.hibernate.test.id;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
@ -14,27 +17,21 @@ public class SequenceGeneratorTest extends BaseCoreFunctionalTestCase {
return new String[] { "id/Person.hbm.xml" };
}
/**
* This seems a little trivial, but we need to guarantee that all Dialects start their sequences on a non-0 value.
*/
@Test
public void testDistinctId() throws Exception {
@TestForIssue(jiraKey = "HHH-8814")
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
public void testStartOfSequence() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
final int testLength = 8;
final Person[] persons = new Person[testLength];
for (int i = 0; i < testLength; i++) {
persons[i] = new Person();
s.persist(persons[i]);
}
tx.commit();
s.close();
for (int i = 0; i < testLength; i++) {
assertEquals(i + 1, persons[i].getId().intValue());
}
s = openSession();
tx = s.beginTransaction();
s.createQuery("delete from Person").executeUpdate();
final Person person = new Person();
s.persist(person);
tx.commit();
s.close();
assertTrue(person.getId() > 0);
}
}