![JAR search and dependency download from the Maven repository](/logo.png)
org.nerd4j.test.SpringAwareBaseTest Maven / Gradle / Ivy
Show all versions of nerd4j-test Show documentation
/*
* #%L
* Nerd4j Test
* %%
* Copyright (C) 2011 - 2013 Nerd4j
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
package org.nerd4j.test;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.junit.rules.ExpectedException;
import org.springframework.test.annotation.Timed;
import org.springframework.test.annotation.Repeat;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.IfProfileValue;
import org.springframework.test.annotation.NotTransactional;
import org.springframework.test.annotation.ProfileValueSourceConfiguration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.transaction.AfterTransaction;
import org.springframework.test.context.transaction.BeforeTransaction;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.transaction.annotation.Transactional;
/**
* Abstract class useful for the support of JUnit test with transactional
* behavior and dependency injection provided by the Spring framework.
*
*
* Test runner: {@link SpringJUnit4ClassRunner}
provides the environment
* that allows the execution of the test into the Spring
* context. It also provides support for the following annotations:
*
* - {@link Test @Test}
* - {@link ExpectedException @ExpectedException}
* - {@link Timed @Timed}
* - {@link Repeat @Repeat}
* - {@link Ignore @Ignore}
* - {@link ProfileValueSourceConfiguration @ProfileValueSourceConfiguration}
* - {@link IfProfileValue @IfProfileValue}
*
*
*
*
* Execution listener: {@link DependencyInjectionTestExecutionListener}
* provides base support for the dependency injection
* when other listeners are involved.
* If there are no other listeners involved this can be removed.
*
*
*
* Execution listener: {@link DirtiesContextTestExecutionListener}
* allows the management of a dirty context.
* A dirty context is closed and removed
* after the test execution.
* It also provides support for the following annotation:
*
* - {@link DirtiesContext @DirtiesContext}
*
*
*
*
* Execution listener: {@link TransactionalTestExecutionListener}
* provides support for transactions and allows test
* to be executed in a transactional environment.
* It also provides support for the following annotations:
*
* - {@link Transactional @Transactional}
* - {@link NotTransactional @NotTransactional} (deprecated)
* - {@link Rollback @Rollback}
* - {@link BeforeTransaction @BeforeTransaction}
* - {@link AfterTransaction @AfterTransaction}
*
*
* The behavior of the transactions can be handled at a class levelusing
* {@link TransactionConfiguration @TransactionConfiguration} or at
* a method level using {@link Rollback @Rollback}.
*
*
* @author Nerd4j Team
*/
/* Spring context aware test runner. */
@RunWith( SpringJUnit4ClassRunner.class )
/* Default Spring context test configuration file. */
@ContextConfiguration( locations = {"classpath:/spring-test.xml"} )
/* Execution listener to be used. */
@TestExecutionListeners( {
DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class,
TransactionalTestExecutionListener.class } )
public abstract class SpringAwareBaseTest extends BaseTest
{}