Polish
This commit is contained in:
parent
80194bd0e3
commit
10da3d390e
|
|
@ -17,6 +17,7 @@
|
||||||
package org.springframework.boot.actuate.health;
|
package org.springframework.boot.actuate.health;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.mail.Address;
|
import javax.mail.Address;
|
||||||
import javax.mail.Message;
|
import javax.mail.Message;
|
||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
|
|
@ -28,7 +29,6 @@ import javax.mail.URLName;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
@ -72,7 +72,8 @@ public class MailHealthIndicatorTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void smtpIsDown() throws MessagingException {
|
public void smtpIsDown() throws MessagingException {
|
||||||
doThrow(new MessagingException("A test exception")).when(this.mailSender).testConnection();
|
doThrow(new MessagingException("A test exception")).when(this.mailSender)
|
||||||
|
.testConnection();
|
||||||
Health health = this.indicator.health();
|
Health health = this.indicator.health();
|
||||||
assertEquals(Status.DOWN, health.getStatus());
|
assertEquals(Status.DOWN, health.getStatus());
|
||||||
assertEquals("smtp.acme.org:25", health.getDetails().get("location"));
|
assertEquals("smtp.acme.org:25", health.getDetails().get("location"));
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,9 @@ public class AutoConfigurationReportLoggingInitializer implements
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsEventType(ResolvableType resolvableType) {
|
public boolean supportsEventType(ResolvableType resolvableType) {
|
||||||
Class<?> type = resolvableType.getRawClass();
|
Class<?> type = resolvableType.getRawClass();
|
||||||
|
if (type == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return ContextRefreshedEvent.class.isAssignableFrom(type)
|
return ContextRefreshedEvent.class.isAssignableFrom(type)
|
||||||
|| ApplicationFailedEvent.class.isAssignableFrom(type);
|
|| ApplicationFailedEvent.class.isAssignableFrom(type);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,9 @@ public final class ClasspathLoggingApplicationListener implements
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsEventType(ResolvableType resolvableType) {
|
public boolean supportsEventType(ResolvableType resolvableType) {
|
||||||
Class<?> type = resolvableType.getRawClass();
|
Class<?> type = resolvableType.getRawClass();
|
||||||
|
if (type == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return ApplicationStartedEvent.class.isAssignableFrom(type)
|
return ApplicationStartedEvent.class.isAssignableFrom(type)
|
||||||
|| ApplicationFailedEvent.class.isAssignableFrom(type);
|
|| ApplicationFailedEvent.class.isAssignableFrom(type);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,8 +117,7 @@ public class LoggingApplicationListener implements GenericApplicationListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsEventType(ResolvableType resolvableType) {
|
public boolean supportsEventType(ResolvableType resolvableType) {
|
||||||
Class<?> eventType = resolvableType.getRawClass();
|
return isAssignableFrom(resolvableType.getRawClass(), EVENT_TYPES);
|
||||||
return isAssignableFrom(eventType, EVENT_TYPES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -127,11 +126,13 @@ public class LoggingApplicationListener implements GenericApplicationListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAssignableFrom(Class<?> type, Class<?>... supportedTypes) {
|
private boolean isAssignableFrom(Class<?> type, Class<?>... supportedTypes) {
|
||||||
|
if (type != null) {
|
||||||
for (Class<?> supportedType : supportedTypes) {
|
for (Class<?> supportedType : supportedTypes) {
|
||||||
if (supportedType.isAssignableFrom(type)) {
|
if (supportedType.isAssignableFrom(type)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue