use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class TransactionJoiningTest method testIsJoinedAfterMarkedForRollbackImplict.
@Test
@TestForIssue(jiraKey = "HHH-10807")
public void testIsJoinedAfterMarkedForRollbackImplict() throws Exception {
assertFalse(JtaStatusHelper.isActive(TestingJtaPlatformImpl.INSTANCE.getTransactionManager()));
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().begin();
EntityManager entityManager = entityManagerFactory().createEntityManager();
SharedSessionContractImplementor session = entityManager.unwrap(SharedSessionContractImplementor.class);
ExtraAssertions.assertTyping(JtaTransactionCoordinatorImpl.class, session.getTransactionCoordinator());
JtaTransactionCoordinatorImpl transactionCoordinator = (JtaTransactionCoordinatorImpl) session.getTransactionCoordinator();
assertTrue(transactionCoordinator.isSynchronizationRegistered());
assertTrue(transactionCoordinator.isActive());
assertTrue(transactionCoordinator.isJoined());
assertTrue(entityManager.isOpen());
assertTrue(session.isOpen());
transactionCoordinator.getTransactionDriverControl().markRollbackOnly();
assertTrue(transactionCoordinator.isActive());
assertTrue(transactionCoordinator.isJoined());
assertTrue(entityManager.isJoinedToTransaction());
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().rollback();
entityManager.close();
assertFalse(entityManager.isOpen());
assertFalse(session.isOpen());
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class GetAndIsVariantGetterTest method testAnnotationsFieldAccess.
@Test
@TestForIssue(jiraKey = "HHH-10309")
public void testAnnotationsFieldAccess() {
// this one should be ok because the AccessType is FIELD
Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(AnotherEntity.class).buildMetadata();
assertNotNull(metadata.getEntityBinding(AnotherEntity.class.getName()).getIdentifier());
assertNotNull(metadata.getEntityBinding(AnotherEntity.class.getName()).getIdentifierProperty());
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class GetterSetterSerializationTest method testProtectedMethodSetter.
@Test
@TestForIssue(jiraKey = "HHH-11202")
public void testProtectedMethodSetter() throws Exception {
final AnEntity entity = new AnEntity(new PK(1L));
final Getter getter = new GetterMethodImpl(AnEntity.class, "pk", ReflectHelper.findGetterMethod(AnEntity.class, "pk"));
final Setter setter = new SetterMethodImpl(AnEntity.class, "pk", ReflectHelper.findSetterMethod(AnEntity.class, "pk", PK.class));
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(setter);
final ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
final Setter setterClone = (Setter) ois.readObject();
final PK pkNew = new PK(2L);
setterClone.set(entity, pkNew, null);
assertSame(pkNew, getter.get(entity));
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class GetterSetterSerializationTest method testProtectedMethodGetter.
@Test
@TestForIssue(jiraKey = "HHH-11202")
public void testProtectedMethodGetter() throws Exception {
final AnEntity entity = new AnEntity(new PK(1L));
final Getter getter = new GetterMethodImpl(AnEntity.class, "pk", ReflectHelper.findGetterMethod(AnEntity.class, "pk"));
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(getter);
final ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
final Getter getterClone = (Getter) ois.readObject();
assertSame(getter.get(entity), getterClone.get(entity));
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class GetterSetterSerializationTest method testPrivateFieldSetter.
@Test
@TestForIssue(jiraKey = "HHH-11202")
public void testPrivateFieldSetter() throws Exception {
AnEntity entity = new AnEntity(new PK(1L));
final Getter getter = new GetterFieldImpl(AnEntity.class, "pk", ReflectHelper.findField(AnEntity.class, "pk"));
final Setter setter = new SetterFieldImpl(AnEntity.class, "pk", ReflectHelper.findField(AnEntity.class, "pk"));
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(setter);
final ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
final Setter setterClone = (Setter) ois.readObject();
final PK pkNew = new PK(2L);
setterClone.set(entity, pkNew, null);
assertSame(pkNew, getter.get(entity));
}
Aggregations