Remove MockServletWebServer.emptyEnumeration()

Closes gh-13084
pull/12890/merge
dreis2211 7 years ago committed by Stephane Nicoll
parent 4a1bdc2c05
commit 15d67d6b12

@ -18,11 +18,9 @@ package org.springframework.boot.testsupport.web.servlet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import javax.servlet.Filter;
import javax.servlet.FilterRegistration;
@ -93,7 +91,7 @@ public abstract class MockServletWebServer {
given(this.servletContext.getInitParameter(anyString())).willAnswer(
(invocation) -> initParameters.get(invocation.getArgument(0)));
given(this.servletContext.getAttributeNames())
.willReturn(MockServletWebServer.emptyEnumeration());
.willReturn(Collections.emptyEnumeration());
given(this.servletContext.getNamedDispatcher("default"))
.willReturn(mock(RequestDispatcher.class));
for (Initializer initializer : this.initializers) {
@ -142,27 +140,6 @@ public abstract class MockServletWebServer {
return this.port;
}
@SuppressWarnings("unchecked")
public static <T> Enumeration<T> emptyEnumeration() {
return (Enumeration<T>) EmptyEnumeration.EMPTY_ENUMERATION;
}
private static class EmptyEnumeration<E> implements Enumeration<E> {
static final MockServletWebServer.EmptyEnumeration<Object> EMPTY_ENUMERATION = new MockServletWebServer.EmptyEnumeration<>();
@Override
public boolean hasMoreElements() {
return false;
}
@Override
public E nextElement() {
throw new NoSuchElementException();
}
}
/**
* A registered servlet.
*/

Loading…
Cancel
Save