@Test public void enableLTW_withAjWeavingAutodetect() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(EnableLTWConfig_withAjWeavingAutodetect.class); ctx.refresh(); LoadTimeWeaver loadTimeWeaver = ctx.getBean("loadTimeWeaver", LoadTimeWeaver.class); // no expectations -> a class file transformer should NOT be added // because no META-INF/aop.xml is present on the classpath verifyZeroInteractions(loadTimeWeaver); }
@Test public void enableLTW_withAjWeavingDisabled() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(EnableLTWConfig_withAjWeavingDisabled.class); ctx.refresh(); LoadTimeWeaver loadTimeWeaver = ctx.getBean("loadTimeWeaver", LoadTimeWeaver.class); verifyZeroInteractions(loadTimeWeaver); }
@Test public void exceptionBeforePreHandle() throws Exception { this.chain.triggerAfterCompletion(this.request, this.response, null); verifyZeroInteractions(this.interceptor1, this.interceptor2, this.interceptor3); }
@Test public void testNoInvokeWhenReturningParameterTypeDoesNotMatch() { testBeanProxy.setSpouse(this.testBeanProxy); testBeanProxy.getSpouse(); verifyZeroInteractions(mockCollaborator); }
@Test public void failurePropagates() { RuntimeException ex = new RuntimeException(); willThrow(ex).given(this.handler).handleMessage(this.message); MessageHandler secondHandler = mock(MessageHandler.class); this.channel.subscribe(this.handler); this.channel.subscribe(secondHandler); try { this.channel.send(message); } catch (MessageDeliveryException actualException) { assertThat(actualException.getCause(), equalTo(ex)); } verifyZeroInteractions(secondHandler); }
@Test public void noTransaction() throws Exception { PlatformTransactionManager ptm = mock(PlatformTransactionManager.class); TestBean tb = new TestBean(); TransactionAttributeSource tas = new MapTransactionAttributeSource(); // All the methods in this class use the advised() template method // to obtain a transaction object, configured with the given PlatformTransactionManager // and transaction attribute source ITestBean itb = (ITestBean) advised(tb, ptm, tas); checkTransactionStatus(false); itb.getName(); checkTransactionStatus(false); // expect no calls verifyZeroInteractions(ptm); }