Removed attributes() from Request

Removes attributes() method from Request, as it exposes a mutable map.
This commit is contained in:
Arjen Poutsma
2016-09-07 10:09:27 +02:00
parent ccb3c44dbc
commit bebaee9799
7 changed files with 13 additions and 36 deletions

View File

@@ -22,7 +22,6 @@ import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -94,11 +93,10 @@ public class DefaultRequestTests {
}
@Test
public void attributes() throws Exception {
Map<String, Object> attributes = new LinkedHashMap<>();
when(mockExchange.getAttributes()).thenReturn(attributes);
public void attribute() throws Exception {
when(mockExchange.getAttribute("foo")).thenReturn(Optional.of("bar"));
assertEquals(attributes, defaultRequest.attributes());
assertEquals(Optional.of("bar"), defaultRequest.attribute("foo"));
}
@Test

View File

@@ -103,11 +103,6 @@ public class MockRequest implements Request {
return Optional.ofNullable((T) this.attributes.get(name));
}
@Override
public Map<String, Object> attributes() {
return this.attributes;
}
@Override
public List<String> queryParams(String name) {
return Collections.unmodifiableList(this.queryParams.get(name));

View File

@@ -102,14 +102,6 @@ public class RequestWrapperTests {
assertEquals(Optional.of(value), wrapper.attribute(name));
}
@Test
public void attributes() throws Exception {
Map<String, Object> attributes = Collections.singletonMap("foo", "bar");
when(mockRequest.attributes()).thenReturn(attributes);
assertSame(attributes, wrapper.attributes());
}
@Test
public void queryParam() throws Exception {
String name = "foo";