- Version of JMockit that was used: 1.24
- Description of the problem or enhancement request:
Support constructor injection when using Spring with @qualifier. Real (unmocked) instance of the type which corresponds to the chosen qualifier, should satisfy the constructor of the tested class.
Currently this test fails:
public class ClassWithQualifiedSpringDependencyTest {
@Tested(fullyInitialized = true)
ClassWithQualifiedDependency tested;
@BeforeClass
public static void prepare() {
Dependency.class.getName();
}
@Test
public void testInjection() {
assertNotNull(tested);
assertNotNull(tested.getDependency());
assertSame(tested.getDependency().getClass(), Dependency.class);
}
@Service
public class ClassWithQualifiedDependency {
private IDependency dependency;
@Autowired
public ClassWithQualifiedDependency(@Qualifier("commonDependency") IDependency d) {
this.dependency = d;
}
public IDependency getDependency() {
return dependency;
}
}
public interface IDependency {
}
@Service("commonDependency")
public class Dependency implements IDependency {
}
@Service("lessCommonDependency")
public class Dependency2 implements IDependency {
}
}
The following exception is thrown:
java.lang.IllegalArgumentException: No constructor in tested class that can be satisfied by available injectables
public ClassWithQualifiedSpringDependencyTest$ClassWithQualitfiedDependency(ClassWithQualifiedSpringDependencyTest,ClassWithQualifiedSpringDependencyTest$IDependency)
disregarded because parameter names are not available
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Support constructor injection when using Spring with @qualifier. Real (unmocked) instance of the type which corresponds to the chosen qualifier, should satisfy the constructor of the tested class.
Currently this test fails:
The following exception is thrown: