Posts

Showing posts with the label Spring Aop

Aspect Not Being Called In Spring Test

Answer : Not sure what you are trying to do but your @ContextConfiguration is useless as you aren't using Spring Test to run your test (that would require a @RunWith or one of the super classes from Spring Test). Next you are adding a singleton which is already fully mocked and configured (that is what the context assumes). I strongly suggest to use Spring instead of working around it. First create a configuration inside your test class for testing, this configuration should do the scanning and register the mocked bean. Second use Spring Test to run your test. @ContextConfiguration public class SoftwareServiceTests extends AbstractJUnit4SpringContextTests { private static final Logger LOGGER = LoggerFactory.getLogger(SoftwareServiceTests.class.getName()); @Autowired private SoftwareService softwareService; @Test(expected = ValidationException.class) public void testAddInvalidSoftware() throws ValidationException { LOGGER.info("Testing a...