Skip to content

Commit 9ce2299

Browse files
committed
fix build+code coverage
1 parent 3b224c8 commit 9ce2299

4 files changed

Lines changed: 17 additions & 5 deletions

File tree

jooby-rocker/src/main/java/org/jooby/rocker/RockerRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void render(final Object value, final Context ctx) throws Exception {
6969
}
7070
}
7171

72-
private String path(final String path) {
72+
static String path(final String path) {
7373
if (path.startsWith("/")) {
7474
return path.substring(1);
7575
}

jooby-rocker/src/test/java/org/jooby/rocker/RockerRenderTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ public void renderViewWithPrefix() throws Exception {
133133
});
134134
}
135135

136+
@Test
137+
public void rockerPrefixPath() throws Exception {
138+
assertEquals("foo", RockerRenderer.path("/foo"));
139+
assertEquals("foo", RockerRenderer.path("foo"));
140+
}
141+
136142
@Test
137143
public void renderViewWithPrefix2() throws Exception {
138144
new MockUnit(BindableRockerModel.class, Renderer.Context.class, View.class)

jooby-servlet/src/main/java/org/jooby/servlet/ServletServletRequest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323
import java.io.IOException;
2424
import java.io.InputStream;
2525
import java.net.URLDecoder;
26-
import java.util.*;
26+
import java.util.Arrays;
27+
import java.util.Collections;
28+
import java.util.Enumeration;
29+
import java.util.List;
30+
import java.util.Map;
31+
import java.util.Optional;
2732
import java.util.concurrent.Executor;
2833
import java.util.function.Function;
2934
import java.util.stream.Collectors;
@@ -127,7 +132,7 @@ public Map<String, Object> attributes() {
127132
return Collections.emptyMap();
128133
}
129134
return Collections.list(attributeNames).stream()
130-
.collect(Collectors.toMap(Function.identity(), name -> req.getAttribute(name)));
135+
.collect(Collectors.toMap(Function.identity(), req::getAttribute));
131136
}
132137

133138
@Override

jooby-servlet/src/test/java/org/jooby/servlet/ServletServletRequestTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44
import static org.junit.Assert.assertEquals;
55

66
import java.io.IOException;
7-
import java.util.Arrays;
87
import java.util.Collections;
98
import java.util.UUID;
109

1110
import javax.servlet.ServletException;
1211
import javax.servlet.http.HttpServletRequest;
1312

14-
import com.google.common.collect.ImmutableMap;
1513
import org.jooby.MediaType;
1614
import org.jooby.test.MockUnit;
1715
import org.junit.Test;
1816

17+
import com.google.common.collect.ImmutableMap;
1918
import com.google.common.collect.Iterators;
2019
import com.google.common.collect.Lists;
2120

@@ -203,6 +202,7 @@ public void attributes() throws Exception {
203202
HttpServletRequest req = unit.get(HttpServletRequest.class);
204203
expect(req.getContentType()).andReturn("text/html");
205204
expect(req.getPathInfo()).andReturn("/");
205+
expect(req.getContextPath()).andReturn("");
206206
expect(req.getAttributeNames()).andReturn(
207207
Collections.enumeration(Collections.singletonList("server.attribute")));
208208
expect(req.getAttribute("server.attribute")).andReturn(serverAttribute);
@@ -223,6 +223,7 @@ public void emptyAttributes() throws Exception {
223223
HttpServletRequest req = unit.get(HttpServletRequest.class);
224224
expect(req.getContentType()).andReturn("text/html");
225225
expect(req.getPathInfo()).andReturn("/");
226+
expect(req.getContextPath()).andReturn("");
226227
expect(req.getAttributeNames()).andReturn(Collections.emptyEnumeration());
227228
})
228229
.run(unit -> {

0 commit comments

Comments
 (0)