intellij spring integration test class does not autowire if extend class with ContextConfiguration

Using the IntelliJ 11.3

For Spring Integration Tests, I have a base class that defines the spring configurations files and some other stuff related to all Spring Tests. When I subclass this for an intergration test I see the warning in the IDE that IntelliJ can not autowire the Spring Bean. However it runs the unit test OK so it is just an IntelliJ issue. Also the complete project builds via maven OK

If I move the Spring Configuration to the test class Intellij does not have the autowire warning.

Warning Configuration

@ContextConfiguration(locations = {"/META-INF/spring/applicationContext.xml",
                                   "/META-INF/spring/test-datasource.xml"})
public abstract class AbstractEmployeeDataServicesIntegrationTest extends JUnit4DbunitSpringContextTests{


// no ContextConfiguration defined here since it is inherited
public class EmployeeIntegrationTest extends AbstractEmployeeDataServicesIntegrationTest {

 @Autowired
 private EmployeeService employeeService; // warning here that it could not autowire since it could not find any beans of type EmployeeService



OK Configuration (for test class)

ContextConfiguration(locations = {"/META-INF/spring/applicationContext.xml",
        "/META-INF/spring/test-datasource.xml"})
public class EmployeeIntegrationTest extends AbstractEmployeeDataServicesIntegrationTest {

 @Autowired
 private EmployeeService employeeService;

 @Test
 public void createEmployee() {

1 comment
Comment actions Permalink

It sounds like IDEA-84470 which is a regression of IDEA-79243, IDEA-73018, and IDEA-56648. This bug has been a tricky one. The use case that exposes the bug keeps getting a bit more refined. So once it appears fixed, a more specific use case surfaces that causes the bug to appear. I suggest you vote for and provide your use case in the bug report IDEA-84470.

0

Please sign in to leave a comment.