@Test public void testAdvisorAdapterRegistrationManagerPresentInContext() { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-with-bpp.xml", getClass()); ITestBean tb = (ITestBean) ctx.getBean("testBean"); // just invoke any method to see if advice fired try { tb.getName(); assertEquals(1, getAdviceImpl(tb).getInvocationCounter()); } catch (UnknownAdviceTypeException ex) { fail("Should not throw UnknownAdviceTypeException"); } }
@Test public void testAdvisorAdapterRegistrationManagerNotPresentInContext() { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-without-bpp.xml", getClass()); ITestBean tb = (ITestBean) ctx.getBean("testBean"); // just invoke any method to see if advice fired try { tb.getName(); fail("Should throw UnknownAdviceTypeException"); } catch (UnknownAdviceTypeException ex) { // expected assertEquals(0, getAdviceImpl(tb).getInvocationCounter()); } }