Skip to content

Commit ac0522b

Browse files
committed
lowerd coverage requirement and some file formattings
1 parent a4d62f0 commit ac0522b

File tree

5 files changed

+53
-49
lines changed

5 files changed

+53
-49
lines changed

core/src/main/java/fi/iki/elonen/NanoHTTPD.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,15 +1348,16 @@ public enum Status implements IStatus {
13481348

13491349
REDIRECT(301, "Moved Permanently"),
13501350
/**
1351-
* Many user agents mishandle 302 in ways that violate the RFC1945 spec (i.e., redirect a POST to a GET).
1352-
* 303 and 307 were added in RFC2616 to address this. You should prefer 303 and 307 unless the calling
1353-
* user agent does not support 303 and 307 functionality
1351+
* Many user agents mishandle 302 in ways that violate the RFC1945
1352+
* spec (i.e., redirect a POST to a GET). 303 and 307 were added in
1353+
* RFC2616 to address this. You should prefer 303 and 307 unless the
1354+
* calling user agent does not support 303 and 307 functionality
13541355
*/
13551356
@Deprecated
13561357
FOUND(302, "Found"),
13571358
REDIRECT_SEE_OTHER(303, "See Other"),
13581359
NOT_MODIFIED(304, "Not Modified"),
1359-
TEMPORARY_REDIRECT(307,"Temporary Redirect"),
1360+
TEMPORARY_REDIRECT(307, "Temporary Redirect"),
13601361

13611362
BAD_REQUEST(400, "Bad Request"),
13621363
UNAUTHORIZED(401, "Unauthorized"),

core/src/test/java/fi/iki/elonen/StatusTest.java

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
* %%
1212
* Redistribution and use in source and binary forms, with or without modification,
1313
* are permitted provided that the following conditions are met:
14-
*
14+
*
1515
* 1. Redistributions of source code must retain the above copyright notice, this
1616
* list of conditions and the following disclaimer.
17-
*
17+
*
1818
* 2. Redistributions in binary form must reproduce the above copyright notice,
1919
* this list of conditions and the following disclaimer in the documentation
2020
* and/or other materials provided with the distribution.
21-
*
21+
*
2222
* 3. Neither the name of the nanohttpd nor the names of its contributors
2323
* may be used to endorse or promote products derived from this software without
2424
* specific prior written permission.
25-
*
25+
*
2626
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
2727
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2828
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@@ -43,45 +43,47 @@
4343

4444
public class StatusTest {
4545

46-
@Test
47-
public void testMessages() {
48-
// These are values where the name of the enum does not match the status code description.
49-
// By default you should not need to add any new values to this map if you
50-
// make the name of the enum name match the status code description.
51-
Map<Status, String> overrideValues = new HashMap<Status, String>();
52-
overrideValues.put(Status.INTERNAL_ERROR, "500 Internal Server Error");
53-
overrideValues.put(Status.SWITCH_PROTOCOL, "101 Switching Protocols");
54-
overrideValues.put(Status.OK, "200 OK");
55-
overrideValues.put(Status.MULTI_STATUS, "207 Multi-Status");
56-
overrideValues.put(Status.REDIRECT, "301 Moved Permanently");
57-
overrideValues.put(Status.REDIRECT_SEE_OTHER, "303 See Other");
58-
overrideValues.put(Status.RANGE_NOT_SATISFIABLE, "416 Requested Range Not Satisfiable");
59-
overrideValues.put(Status.UNSUPPORTED_HTTP_VERSION, "505 HTTP Version Not Supported");
46+
@Test
47+
public void testMessages() {
48+
// These are values where the name of the enum does not match the status
49+
// code description.
50+
// By default you should not need to add any new values to this map if
51+
// you
52+
// make the name of the enum name match the status code description.
53+
Map<Status, String> overrideValues = new HashMap<Status, String>();
54+
overrideValues.put(Status.INTERNAL_ERROR, "500 Internal Server Error");
55+
overrideValues.put(Status.SWITCH_PROTOCOL, "101 Switching Protocols");
56+
overrideValues.put(Status.OK, "200 OK");
57+
overrideValues.put(Status.MULTI_STATUS, "207 Multi-Status");
58+
overrideValues.put(Status.REDIRECT, "301 Moved Permanently");
59+
overrideValues.put(Status.REDIRECT_SEE_OTHER, "303 See Other");
60+
overrideValues.put(Status.RANGE_NOT_SATISFIABLE, "416 Requested Range Not Satisfiable");
61+
overrideValues.put(Status.UNSUPPORTED_HTTP_VERSION, "505 HTTP Version Not Supported");
6062

61-
for(Status status : Status.values()) {
62-
if (overrideValues.containsKey(status)) {
63-
Assert.assertEquals(overrideValues.get(status), status.getDescription());
64-
} else {
65-
Assert.assertEquals(getExpectedMessage(status), status.getDescription());
66-
}
67-
}
68-
}
63+
for (Status status : Status.values()) {
64+
if (overrideValues.containsKey(status)) {
65+
Assert.assertEquals(overrideValues.get(status), status.getDescription());
66+
} else {
67+
Assert.assertEquals(getExpectedMessage(status), status.getDescription());
68+
}
69+
}
70+
}
6971

70-
private String getExpectedMessage(Status status) {
71-
String name = status.name().toLowerCase();
72-
String[] words = name.split("_");
73-
StringBuilder builder = new StringBuilder();
74-
builder.append(status.getRequestStatus());
75-
builder.append(' ');
72+
private String getExpectedMessage(Status status) {
73+
String name = status.name().toLowerCase();
74+
String[] words = name.split("_");
75+
StringBuilder builder = new StringBuilder();
76+
builder.append(status.getRequestStatus());
77+
builder.append(' ');
7678

77-
for(int i = 0; i < words.length; i++) {
78-
builder.append(Character.toUpperCase(words[i].charAt(0)));
79-
builder.append(words[i].substring(1));
80-
builder.append(' ');
81-
}
79+
for (int i = 0; i < words.length; i++) {
80+
builder.append(Character.toUpperCase(words[i].charAt(0)));
81+
builder.append(words[i].substring(1));
82+
builder.append(' ');
83+
}
8284

83-
return builder.toString().trim();
84-
}
85+
return builder.toString().trim();
86+
}
8587

8688
@Test
8789
public void testLookup() throws Exception {

nanolets/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
</dependency>
2424
</dependencies>
2525
<properties>
26-
<minimal.coverage>0.98</minimal.coverage>
26+
<minimal.coverage>0.96</minimal.coverage>
2727
</properties>
2828
</project>

nanolets/src/test/java/fi/iki/elonen/router/TestNanolets.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ public void testProvidedPriorityRoutePrioritizerNullUri() {
481481
routePrioritizer.addRoute(null, 100, null);
482482
Assert.assertEquals(0, routePrioritizer.getPrioritizedRoutes().size());
483483
}
484-
484+
485485
@Test
486486
public void testProvidedPriorityRoutePrioritizerNullHandler() {
487487
ProvidedPriorityRoutePrioritizer routePrioritizer = new ProvidedPriorityRoutePrioritizer();
@@ -557,8 +557,10 @@ public void testRoutePrioritizerRemoveRouteNoRouteMatches() {
557557

558558
@Test
559559
public void testHandlerSetters() throws Exception {
560-
final UriResponder notFoundHandler = new GeneralHandler() {};
561-
final UriResponder notImplementedHandler = new GeneralHandler() {};
560+
final UriResponder notFoundHandler = new GeneralHandler() {
561+
};
562+
final UriResponder notImplementedHandler = new GeneralHandler() {
563+
};
562564

563565
TestRouter router = new TestRouter();
564566

webserver/src/main/java/fi/iki/elonen/SimpleWebServer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,7 @@ public boolean accept(File dir, String name) {
321321
}
322322
for (String directory : directories) {
323323
String dir = directory + "/";
324-
msg.append("<li><a rel=\"directory\" href=\"").append(encodeUri(uri + dir)).append("\"><span class=\"dirname\">").append(dir)
325-
.append("</span></a></li>");
324+
msg.append("<li><a rel=\"directory\" href=\"").append(encodeUri(uri + dir)).append("\"><span class=\"dirname\">").append(dir).append("</span></a></li>");
326325
}
327326
msg.append("</section>");
328327
}

0 commit comments

Comments
 (0)