use of org.hibernate.testing.FailureExpected in project hibernate-orm by hibernate.
the class CustomRunner method doComputation.
protected List<FrameworkMethod> doComputation() {
// Next, get all the test methods as understood by JUnit
final List<FrameworkMethod> methods = super.computeTestMethods();
// Now process that full list of test methods and build our custom result
final List<FrameworkMethod> result = new ArrayList<FrameworkMethod>();
final boolean doValidation = Boolean.getBoolean(Helper.VALIDATE_FAILURE_EXPECTED);
int testCount = 0;
Ignore virtualIgnore;
for (FrameworkMethod frameworkMethod : methods) {
// potentially ignore based on expected failure
final FailureExpected failureExpected = Helper.locateAnnotation(FailureExpected.class, frameworkMethod, getTestClass());
if (failureExpected != null && !doValidation) {
virtualIgnore = new IgnoreImpl(Helper.extractIgnoreMessage(failureExpected, frameworkMethod));
} else {
virtualIgnore = convertSkipToIgnore(frameworkMethod);
}
testCount++;
log.trace("adding test " + Helper.extractTestName(frameworkMethod) + " [#" + testCount + "]");
result.add(new ExtendedFrameworkMethod(frameworkMethod, virtualIgnore, failureExpected));
}
return result;
}
use of org.hibernate.testing.FailureExpected in project hibernate-orm by hibernate.
the class CompositeCustomType method testRemoval.
@Test
@TestForIssue(jiraKey = "HHH-9207")
@FailureExpected(jiraKey = "HHH-9207")
public void testRemoval() {
EntityManager em = getEntityManager();
final Component comp1 = new Component(null, 11);
final Component comp2 = new Component(null, 22);
final CompositeCustomTypeSetEntity entity = new CompositeCustomTypeSetEntity();
entity.setComponents(new HashSet<Component>());
entity.getComponents().add(comp1);
entity.getComponents().add(comp2);
em.getTransaction().begin();
em.persist(entity);
em.getTransaction().commit();
em.getTransaction().begin();
entity.getComponents().remove(comp1);
em.getTransaction().commit();
CompositeCustomTypeSetEntity rev1 = getAuditReader().find(CompositeCustomTypeSetEntity.class, entity.getId(), 1);
CompositeCustomTypeSetEntity rev2 = getAuditReader().find(CompositeCustomTypeSetEntity.class, entity.getId(), 2);
assertEquals("Unexpected components", TestTools.makeSet(comp1, comp2), rev1.getComponents());
assertEquals("Unexpected components", TestTools.makeSet(comp2), rev2.getComponents());
}
use of org.hibernate.testing.FailureExpected in project hibernate-orm by hibernate.
the class EmbeddableWithDeclaredDataTest method testEmbeddableThatExtendsMappedSuperclass.
@Test
@FailureExpected(jiraKey = "HHH-9193")
public void testEmbeddableThatExtendsMappedSuperclass() {
// Reload and Compare Revision
EntityManager em = getEntityManager();
em.getTransaction().begin();
EntityWithEmbeddableWithDeclaredData entityLoaded = em.find(EntityWithEmbeddableWithDeclaredData.class, id);
AuditReader reader = AuditReaderFactory.get(em);
List<Number> revs = reader.getRevisions(EntityWithEmbeddableWithDeclaredData.class, id);
Assert.assertEquals(1, revs.size());
EntityWithEmbeddableWithDeclaredData entityRev1 = reader.find(EntityWithEmbeddableWithDeclaredData.class, id, revs.get(0));
em.getTransaction().commit();
Assert.assertEquals(entityLoaded.getName(), entityRev1.getName());
// only value.codeArt should be audited because it is the only audited field in EmbeddableWithDeclaredData;
// fields in AbstractEmbeddable should not be audited.
Assert.assertEquals(entityLoaded.getValue().getCodeart(), entityRev1.getValue().getCodeart());
Assert.assertNull(entityRev1.getValue().getCode());
}
use of org.hibernate.testing.FailureExpected in project hibernate-orm by hibernate.
the class CallbacksTest method testPostUpdateCollection.
@Test
@FailureExpected(message = "collection change does not trigger an event", jiraKey = "EJB-288")
public void testPostUpdateCollection() throws Exception {
// create a cat
EntityManager em = getOrCreateEntityManager();
Cat cat = new Cat();
em.getTransaction().begin();
cat.setLength(23);
cat.setAge(2);
cat.setName("Beetle");
cat.setDateOfBirth(new Date());
em.persist(cat);
em.getTransaction().commit();
// assert it is persisted
List ids = Cat.getIdList();
Object id = Cat.getIdList().get(ids.size() - 1);
assertNotNull(id);
// add a kitten to the cat - triggers PostCollectionRecreateEvent
int postVersion = Cat.postVersion;
em.getTransaction().begin();
Kitten kitty = new Kitten();
kitty.setName("kitty");
List kittens = new ArrayList<Kitten>();
kittens.add(kitty);
cat.setKittens(kittens);
em.getTransaction().commit();
assertEquals("Post version should have been incremented.", postVersion + 1, Cat.postVersion);
// add another kitten - triggers PostCollectionUpdateEvent.
postVersion = Cat.postVersion;
em.getTransaction().begin();
Kitten tom = new Kitten();
tom.setName("Tom");
cat.getKittens().add(tom);
em.getTransaction().commit();
assertEquals("Post version should have been incremented.", postVersion + 1, Cat.postVersion);
// delete a kitty - triggers PostCollectionUpdateEvent
postVersion = Cat.postVersion;
em.getTransaction().begin();
cat.getKittens().remove(tom);
em.getTransaction().commit();
assertEquals("Post version should have been incremented.", postVersion + 1, Cat.postVersion);
// delete and recreate kittens - triggers PostCollectionRemoveEvent and PostCollectionRecreateEvent)
postVersion = Cat.postVersion;
em.getTransaction().begin();
cat.setKittens(new ArrayList<Kitten>());
em.getTransaction().commit();
assertEquals("Post version should have been incremented.", postVersion + 2, Cat.postVersion);
em.close();
}
use of org.hibernate.testing.FailureExpected in project hibernate-orm by hibernate.
the class QueryBuilderTest method testMissingDialectFunction.
@Test
@TestForIssue(jiraKey = "HHH-10737")
@FailureExpected(jiraKey = "HHH-10737")
public void testMissingDialectFunction() {
doInJPA(this::entityManagerFactory, em -> {
Human human = new Human();
human.setId(200L);
human.setName("2");
human.setBorn(new Date());
em.persist(human);
em.getTransaction().commit();
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<HumanDTO> criteria = cb.createQuery(HumanDTO.class);
Root<Human> root = criteria.from(Human.class);
criteria.select(cb.construct(HumanDTO.class, root.get(Human_.id), root.get(Human_.name), cb.function("convert", String.class, root.get(Human_.born), cb.literal(110))));
em.createQuery(criteria).getResultList();
});
}
Aggregations