org.hibernate.Interceptor.toString()

Here are the examples of the java api org.hibernate.Interceptor.toString() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

16 Source : LocalSessionFactoryBeanTests.java
with Apache License 2.0
from langtianya

@Test
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithEnreplacedyInterceptor() throws Exception {
    LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {

        @Override
        protected Configuration newConfiguration() {
            return new Configuration() {

                @Override
                public Configuration setInterceptor(Interceptor interceptor) {
                    throw new IllegalArgumentException(interceptor.toString());
                }
            };
        }
    };
    sfb.setMappingResources(new String[0]);
    sfb.setDataSource(new DriverManagerDataSource());
    Interceptor enreplacedyInterceptor = mock(Interceptor.clreplaced);
    sfb.setEnreplacedyInterceptor(enreplacedyInterceptor);
    try {
        sfb.afterPropertiesSet();
        fail("Should have thrown IllegalArgumentException");
    } catch (IllegalArgumentException ex) {
        // expected
        replacedertTrue("Correct exception", ex.getMessage().equals(enreplacedyInterceptor.toString()));
    }
}