From 10554a85c9960190099bea349d10cb8a01bf48ce Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 12 Apr 2016 08:34:38 +0200 Subject: [PATCH] Polish --- ...AbstractApplicationEventListenerTests.java | 4 +- .../AnnotationDrivenEventListenerTests.java | 40 +++++++++---------- .../event/ApplicationContextEventTests.java | 6 +-- ...ApplicationListenerMethodAdapterTests.java | 24 +++++------ .../EventPublicationInterceptorTests.java | 12 +++--- .../event/test/AbstractIdentifiable.java | 8 ++-- .../context/event/test/EventCollector.java | 6 +-- .../test/IdentifiableApplicationEvent.java | 8 ++-- 8 files changed, 54 insertions(+), 54 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/context/event/AbstractApplicationEventListenerTests.java b/spring-context/src/test/java/org/springframework/context/event/AbstractApplicationEventListenerTests.java index a0784d03e8..f7aedb13ab 100644 --- a/spring-context/src/test/java/org/springframework/context/event/AbstractApplicationEventListenerTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/AbstractApplicationEventListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public abstract class AbstractApplicationEventListenerTests { } public T getPayload() { - return payload; + return this.payload; } } diff --git a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java index ac04539725..89738660ad 100644 --- a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java @@ -117,7 +117,7 @@ public class AnnotationDrivenEventListenerTests { public void metaAnnotationIsDiscovered() { load(MetaAnnotationListenerTestBean.class); - MetaAnnotationListenerTestBean bean = context.getBean(MetaAnnotationListenerTestBean.class); + MetaAnnotationListenerTestBean bean = this.context.getBean(MetaAnnotationListenerTestBean.class); this.eventCollector.assertNoEventReceived(bean); TestEvent event = new TestEvent(); @@ -149,9 +149,9 @@ public class AnnotationDrivenEventListenerTests { failingContext.register(BasicConfiguration.class, InvalidMethodSignatureEventListener.class); - thrown.expect(BeanInitializationException.class); - thrown.expectMessage(InvalidMethodSignatureEventListener.class.getName()); - thrown.expectMessage("cannotBeCalled"); + this.thrown.expect(BeanInitializationException.class); + this.thrown.expectMessage(InvalidMethodSignatureEventListener.class.getName()); + this.thrown.expectMessage("cannotBeCalled"); failingContext.refresh(); } @@ -341,7 +341,7 @@ public class AnnotationDrivenEventListenerTests { this.eventCollector.assertNoEventReceived(listener); this.context.publishEvent(event); - countDownLatch.await(2, TimeUnit.SECONDS); + this.countDownLatch.await(2, TimeUnit.SECONDS); this.eventCollector.assertEvent(listener, event); this.eventCollector.assertTotalEventsCount(1); } @@ -356,7 +356,7 @@ public class AnnotationDrivenEventListenerTests { this.eventCollector.assertNoEventReceived(listener); this.context.publishEvent(event); - countDownLatch.await(2, TimeUnit.SECONDS); + this.countDownLatch.await(2, TimeUnit.SECONDS); this.eventCollector.assertEvent(listener, event); this.eventCollector.assertTotalEventsCount(1); } @@ -371,7 +371,7 @@ public class AnnotationDrivenEventListenerTests { this.eventCollector.assertNoEventReceived(listener); this.context.publishEvent(event); - countDownLatch.await(2, TimeUnit.SECONDS); + this.countDownLatch.await(2, TimeUnit.SECONDS); this.eventCollector.assertEvent(listener, event); this.eventCollector.assertTotalEventsCount(1); } @@ -401,7 +401,7 @@ public class AnnotationDrivenEventListenerTests { this.eventCollector.assertNoEventReceived(listener); this.context.publishEvent(event); - countDownLatch.await(2, TimeUnit.SECONDS); + this.countDownLatch.await(2, TimeUnit.SECONDS); this.eventCollector.assertEvent(listener, event); this.eventCollector.assertTotalEventsCount(1); @@ -699,7 +699,7 @@ public class AnnotationDrivenEventListenerTests { public void handleAsync(AnotherTestEvent event) { collectEvent(event); if ("fail".equals(event.content)) { - countDownLatch.countDown(); + this.countDownLatch.countDown(); throw new IllegalStateException("Test exception"); } } @@ -717,7 +717,7 @@ public class AnnotationDrivenEventListenerTests { public void handleAsync(AnotherTestEvent event) { assertTrue(!Thread.currentThread().getName().equals(event.content)); collectEvent(event); - countDownLatch.countDown(); + this.countDownLatch.countDown(); } } @@ -756,15 +756,15 @@ public class AnnotationDrivenEventListenerTests { @EventListener @Override public void handleIt(TestEvent event) { - eventCollector.addEvent(this, event); + this.eventCollector.addEvent(this, event); } @EventListener @Async public void handleAsync(AnotherTestEvent event) { assertTrue(!Thread.currentThread().getName().equals(event.content)); - eventCollector.addEvent(this, event); - countDownLatch.countDown(); + this.eventCollector.addEvent(this, event); + this.countDownLatch.countDown(); } } @@ -782,15 +782,15 @@ public class AnnotationDrivenEventListenerTests { @EventListener @Override public void handleIt(TestEvent event) { - eventCollector.addEvent(this, event); + this.eventCollector.addEvent(this, event); } @EventListener @Async public void handleAsync(AnotherTestEvent event) { assertTrue(!Thread.currentThread().getName().equals(event.content)); - eventCollector.addEvent(this, event); - countDownLatch.countDown(); + this.eventCollector.addEvent(this, event); + this.countDownLatch.countDown(); } } @@ -811,7 +811,7 @@ public class AnnotationDrivenEventListenerTests { @Override public void handleIt(TestEvent event) { - eventCollector.addEvent(this, event); + this.eventCollector.addEvent(this, event); } } @@ -914,18 +914,18 @@ public class AnnotationDrivenEventListenerTests { @EventListener @Order(50) public void handleThird(String payload) { - order.add("third"); + this.order.add("third"); } @EventListener @Order(-50) public void handleFirst(String payload) { - order.add("first"); + this.order.add("first"); } @EventListener public void handleSecond(String payload) { - order.add("second"); + this.order.add("second"); } } diff --git a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java index a56c77be07..c65d60b89c 100644 --- a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -452,7 +452,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen @Override public void onApplicationEvent(MyEvent event) { - assertTrue(otherListener.seenEvents.contains(event)); + assertTrue(this.otherListener.seenEvents.contains(event)); } } @@ -503,7 +503,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen @Override public void onApplicationEvent(MyEvent event) { - assertTrue(otherListener.seenEvents.contains(event)); + assertTrue(this.otherListener.seenEvents.contains(event)); } } diff --git a/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java b/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java index b9cc4dd0d8..7737318013 100644 --- a/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -148,7 +148,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv Method method = ReflectionUtils.findMethod(SampleEvents.class, "tooManyParameters", String.class, String.class); - thrown.expect(IllegalStateException.class); + this.thrown.expect(IllegalStateException.class); createTestInstance(method); } @@ -157,7 +157,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv Method method = ReflectionUtils.findMethod(SampleEvents.class, "noParameter"); - thrown.expect(IllegalStateException.class); + this.thrown.expect(IllegalStateException.class); createTestInstance(method); } @@ -166,7 +166,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv Method method = ReflectionUtils.findMethod(SampleEvents.class, "moreThanOneParameter", String.class, Integer.class); - thrown.expect(IllegalStateException.class); + this.thrown.expect(IllegalStateException.class); createTestInstance(method); } @@ -237,9 +237,9 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv "generateRuntimeException", GenericTestEvent.class); GenericTestEvent event = createGenericTestEvent("fail"); - thrown.expect(IllegalStateException.class); - thrown.expectMessage("Test exception"); - thrown.expectCause(is(isNull(Throwable.class))); + this.thrown.expect(IllegalStateException.class); + this.thrown.expectMessage("Test exception"); + this.thrown.expectCause(is(isNull(Throwable.class))); invokeListener(method, event); } @@ -249,8 +249,8 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv "generateCheckedException", GenericTestEvent.class); GenericTestEvent event = createGenericTestEvent("fail"); - thrown.expect(UndeclaredThrowableException.class); - thrown.expectCause(is(instanceOf(IOException.class))); + this.thrown.expect(UndeclaredThrowableException.class); + this.thrown.expectCause(is(instanceOf(IOException.class))); invokeListener(method, event); } @@ -265,8 +265,8 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv Method method = ReflectionUtils.findMethod(InvalidProxyTestBean.class, "handleIt2", ApplicationEvent.class); StaticApplicationListenerMethodAdapter listener = new StaticApplicationListenerMethodAdapter(method, bean); - thrown.expect(IllegalStateException.class); - thrown.expectMessage("handleIt2"); + this.thrown.expect(IllegalStateException.class); + this.thrown.expectMessage("handleIt2"); listener.onApplicationEvent(createGenericTestEvent("test")); } @@ -373,7 +373,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @Override public Object getTargetBean() { - return targetBean; + return this.targetBean; } } diff --git a/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java b/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java index 0cb677c3fc..6437ac5773 100644 --- a/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,20 +46,20 @@ public class EventPublicationInterceptorTests { @Before public void setUp() { - publisher = mock(ApplicationEventPublisher.class); + this.publisher = mock(ApplicationEventPublisher.class); } @Test(expected=IllegalArgumentException.class) public void testWithNoApplicationEventClassSupplied() throws Exception { EventPublicationInterceptor interceptor = new EventPublicationInterceptor(); - interceptor.setApplicationEventPublisher(publisher); + interceptor.setApplicationEventPublisher(this.publisher); interceptor.afterPropertiesSet(); } @Test(expected=IllegalArgumentException.class) public void testWithNonApplicationEventClassSupplied() throws Exception { EventPublicationInterceptor interceptor = new EventPublicationInterceptor(); - interceptor.setApplicationEventPublisher(publisher); + interceptor.setApplicationEventPublisher(this.publisher); interceptor.setApplicationEventClass(getClass()); interceptor.afterPropertiesSet(); } @@ -67,7 +67,7 @@ public class EventPublicationInterceptorTests { @Test(expected=IllegalArgumentException.class) public void testWithAbstractStraightApplicationEventClassSupplied() throws Exception { EventPublicationInterceptor interceptor = new EventPublicationInterceptor(); - interceptor.setApplicationEventPublisher(publisher); + interceptor.setApplicationEventPublisher(this.publisher); interceptor.setApplicationEventClass(ApplicationEvent.class); interceptor.afterPropertiesSet(); } @@ -75,7 +75,7 @@ public class EventPublicationInterceptorTests { @Test(expected=IllegalArgumentException.class) public void testWithApplicationEventClassThatDoesntExposeAValidCtor() throws Exception { EventPublicationInterceptor interceptor = new EventPublicationInterceptor(); - interceptor.setApplicationEventPublisher(publisher); + interceptor.setApplicationEventPublisher(this.publisher); interceptor.setApplicationEventClass(TestEventWithNoValidOneArgObjectCtor.class); interceptor.afterPropertiesSet(); } diff --git a/spring-context/src/test/java/org/springframework/context/event/test/AbstractIdentifiable.java b/spring-context/src/test/java/org/springframework/context/event/test/AbstractIdentifiable.java index b960d8aa9b..3a61bc0199 100644 --- a/spring-context/src/test/java/org/springframework/context/event/test/AbstractIdentifiable.java +++ b/spring-context/src/test/java/org/springframework/context/event/test/AbstractIdentifiable.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ public abstract class AbstractIdentifiable implements Identifiable { @Override public String getId() { - return id; + return this.id; } @Override @@ -41,12 +41,12 @@ public abstract class AbstractIdentifiable implements Identifiable { AbstractIdentifiable that = (AbstractIdentifiable) o; - return id.equals(that.id); + return this.id.equals(that.id); } @Override public int hashCode() { - return id.hashCode(); + return this.id.hashCode(); } } diff --git a/spring-context/src/test/java/org/springframework/context/event/test/EventCollector.java b/spring-context/src/test/java/org/springframework/context/event/test/EventCollector.java index 78dddb96b0..9df254c247 100644 --- a/spring-context/src/test/java/org/springframework/context/event/test/EventCollector.java +++ b/spring-context/src/test/java/org/springframework/context/event/test/EventCollector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ public class EventCollector { * Assert that the listener identified by the specified id has not received any event. */ public void assertNoEventReceived(String listenerId) { - List events = content.getOrDefault(listenerId, Collections.emptyList()); + List events = this.content.getOrDefault(listenerId, Collections.emptyList()); assertEquals("Expected no events but got " + events, 0, events.size()); } @@ -72,7 +72,7 @@ public class EventCollector { * specified events, in that specific order. */ public void assertEvent(String listenerId, Object... events) { - List actual = content.getOrDefault(listenerId, Collections.emptyList()); + List actual = this.content.getOrDefault(listenerId, Collections.emptyList()); assertEquals("wrong number of events", events.length, actual.size()); for (int i = 0; i < events.length; i++) { assertEquals("Wrong event at index " + i, events[i], actual.get(i)); diff --git a/spring-context/src/test/java/org/springframework/context/event/test/IdentifiableApplicationEvent.java b/spring-context/src/test/java/org/springframework/context/event/test/IdentifiableApplicationEvent.java index 8694c97774..6e2df2dcb7 100644 --- a/spring-context/src/test/java/org/springframework/context/event/test/IdentifiableApplicationEvent.java +++ b/spring-context/src/test/java/org/springframework/context/event/test/IdentifiableApplicationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ public abstract class IdentifiableApplicationEvent extends ApplicationEvent impl @Override public String getId() { - return id; + return this.id; } @Override @@ -55,13 +55,13 @@ public abstract class IdentifiableApplicationEvent extends ApplicationEvent impl IdentifiableApplicationEvent that = (IdentifiableApplicationEvent) o; - return id.equals(that.id); + return this.id.equals(that.id); } @Override public int hashCode() { - return id.hashCode(); + return this.id.hashCode(); } }