Skip to content

Commit

Permalink
Remove MockServletWebServer.emptyEnumeration()
Browse files Browse the repository at this point in the history
  • Loading branch information
dreis2211 authored and snicoll committed May 7, 2018
1 parent 4a1bdc2 commit 15d67d6
Showing 1 changed file with 1 addition and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@

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;
Expand Down Expand Up @@ -93,7 +91,7 @@ private void initialize() {
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) {
Expand Down Expand Up @@ -142,27 +140,6 @@ public int getPort() {
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.
*/
Expand Down

0 comments on commit 15d67d6

Please sign in to comment.