I have found the solution and would like to post it for anyone else that encounters this. The trick is using factory-method="aspectOf"
in your spring bean definition. So using the example above, I would add this line to my applicationContext.xml
<bean class="com.my.package.MyAdviceClass" factory-method="aspectOf"/>
Any my unit test would look something like this:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:/META-INF/spring/applicationContext.xml")
public class MyAdviceClassTest {
@Autowired private MyAdviceClass advice;
@Mock private MyExternalResource resource;
@Before
public void setUp() throws Exception {
initMocks(this);
advice.setResource(resource);
}
@Test
public void featureTest() {
// Perform testing
}
}
More details are available here.