Package org.baeldung.ex.mappingexception

Source Code of org.baeldung.ex.mappingexception.Cause3MappingExceptionIntegrationTest

package org.baeldung.ex.mappingexception;

import org.baeldung.ex.mappingexception.cause3.persistence.model.Foo;
import org.baeldung.ex.mappingexception.spring.Cause3PersistenceConfig;
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 = { Cause3PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
public class Cause3MappingExceptionIntegrationTest {

    @Autowired
    private SessionFactory sessionFactory;

    // tests

    @Test(expected = MappingException.class)
    @Transactional
    public final void givenEntityIsPersisted_thenException() {
        sessionFactory.getCurrentSession().saveOrUpdate(new Foo());
    }

}
TOP

Related Classes of org.baeldung.ex.mappingexception.Cause3MappingExceptionIntegrationTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.