/
NikolayIvkin
/
tutorials1
Обзор
Документация
Войти
/
NikolayIvkin
/
tutorials1
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
spring-exceptions/src/test/java/com/baeldung/ex/mappingexception/Cause1MappingExceptionManualTest.java
30 строк
1 KB
Krzysztof Woyke
BAEL-20262: Migrate spring-exceptions module to the com.baeldung package
20 дек 2019, 14:32
20 дек 2019, 14:32
98bdc46
Код
Авторство
О чём код?
package com.baeldung.ex.mappingexception; import com.baeldung.ex.mappingexception.cause1.persistence.model.Foo; import com.baeldung.ex.mappingexception.spring.Cause1PersistenceConfig; import org.hibernate.MappingException; import org.hibernate.SessionFactory; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { Cause1PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) public class Cause1MappingExceptionManualTest { @Autowired private SessionFactory sessionFactory; // tests @Test(expected = MappingException.class) @Transactional public final void givenEntityIsPersisted_thenException() { sessionFactory.getCurrentSession().saveOrUpdate(new Foo()); } }