From f31f65408ce9f3eb02447e3f916664e51e2efa0e Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 28 Feb 2019 14:54:23 +0100 Subject: [PATCH] Polishing --- .../event/EventPublicationInterceptorTests.java | 12 ++++++------ .../event/PayloadApplicationEventTests.java | 17 +++++++---------- 2 files changed, 13 insertions(+), 16 deletions(-) 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 6437ac57731..dc298c2264c 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-2016 the original author or authors. + * Copyright 2002-2019 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,14 +49,14 @@ public class EventPublicationInterceptorTests { this.publisher = mock(ApplicationEventPublisher.class); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void testWithNoApplicationEventClassSupplied() throws Exception { EventPublicationInterceptor interceptor = new EventPublicationInterceptor(); interceptor.setApplicationEventPublisher(this.publisher); interceptor.afterPropertiesSet(); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void testWithNonApplicationEventClassSupplied() throws Exception { EventPublicationInterceptor interceptor = new EventPublicationInterceptor(); interceptor.setApplicationEventPublisher(this.publisher); @@ -64,7 +64,7 @@ public class EventPublicationInterceptorTests { interceptor.afterPropertiesSet(); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void testWithAbstractStraightApplicationEventClassSupplied() throws Exception { EventPublicationInterceptor interceptor = new EventPublicationInterceptor(); interceptor.setApplicationEventPublisher(this.publisher); @@ -72,7 +72,7 @@ public class EventPublicationInterceptorTests { interceptor.afterPropertiesSet(); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void testWithApplicationEventClassThatDoesntExposeAValidCtor() throws Exception { EventPublicationInterceptor interceptor = new EventPublicationInterceptor(); interceptor.setApplicationEventPublisher(this.publisher); @@ -129,7 +129,7 @@ public class EventPublicationInterceptorTests { public static class FactoryBeanTestListener extends TestListener implements FactoryBean { @Override - public Object getObject() throws Exception { + public Object getObject() { return "test"; } diff --git a/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java b/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java index c9f9c17996c..1b1100bafea 100644 --- a/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java @@ -35,10 +35,10 @@ public class PayloadApplicationEventTests { @Test public void testEventClassWithInterface() { - ApplicationContext ac = new AnnotationConfigApplicationContext(Listener.class); - MyEventClass event = new MyEventClass<>(this, "xyz"); + ApplicationContext ac = new AnnotationConfigApplicationContext(AuditableListener.class); + AuditablePayloadEvent event = new AuditablePayloadEvent<>(this, "xyz"); ac.publishEvent(event); - assertTrue(ac.getBean(Listener.class).events.contains(event)); + assertTrue(ac.getBean(AuditableListener.class).events.contains(event)); } @@ -46,20 +46,17 @@ public class PayloadApplicationEventTests { } - public static class MyEventClass extends PayloadApplicationEvent implements Auditable { + @SuppressWarnings("serial") + public static class AuditablePayloadEvent extends PayloadApplicationEvent implements Auditable { - public MyEventClass(Object source, GT payload) { + public AuditablePayloadEvent(Object source, T payload) { super(source, payload); } - - public String toString() { - return "Payload: " + getPayload(); - } } @Component - public static class Listener { + public static class AuditableListener { public final List events = new ArrayList<>();