Skip to content

Commit 274803d

Browse files
committed
Test fixes for windows path separators, line endings, more elaborate error messages
1 parent 1b3dea6 commit 274803d

File tree

9 files changed

+37
-30
lines changed

9 files changed

+37
-30
lines changed

jooby/src/main/resources/org/jooby/jooby.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ application {
1616
# class = App.class.getName()
1717

1818
# tmpdir
19-
tmpdir = ${java.io.tmpdir}/${application.name}
19+
tmpdir = ${java.io.tmpdir}${file.separator}${application.name}
2020

2121
# path (a.k.a. as contextPath)
2222
path = /

jooby/src/test/java/org/jooby/test/JoobyRunner.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ private void prepare(final Class<?> klass, final Class<?> server) throws Initial
105105
}
106106

107107
app = (Jooby) appClass.newInstance();
108+
app.throwBootstrapException();
108109
if (app instanceof ServerFeature) {
109110
int appport = ((ServerFeature) app).port;
110111
if (appport > 0) {

modules/coverage-report/src/test/java/org/jooby/jackson/JsonCustomMapperFeature.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.jooby.jackson;
22

3+
import static org.junit.Assert.assertEquals;
34
import static org.junit.Assert.assertSame;
45

56
import java.net.URISyntaxException;
@@ -31,12 +32,12 @@ public class JsonCustomMapperFeature extends ServerFeature {
3132

3233
@Test
3334
public void get() throws URISyntaxException, Exception {
34-
request()
35-
.get("/members")
36-
.expect("[ {\n" +
37-
" \"id\" : 1,\n" +
38-
" \"name\" : \"pablo\"\n" +
39-
"} ]");
35+
request().get("/members").expect(value ->
36+
assertEquals("[ {\n" +
37+
" \"id\" : 1,\n" +
38+
" \"name\" : \"pablo\"\n" +
39+
"} ]", value.replaceAll("\r\n", "\n"))
40+
);
4041
}
4142

4243
}

modules/coverage-report/src/test/java/org/jooby/jackson/JsonDoWithFeature.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import com.google.common.collect.ImmutableMap;
1111
import com.google.common.collect.Lists;
1212

13+
import static org.junit.Assert.assertEquals;
14+
1315
@SuppressWarnings("unchecked")
1416
public class JsonDoWithFeature extends ServerFeature {
1517

@@ -26,12 +28,12 @@ public class JsonDoWithFeature extends ServerFeature {
2628

2729
@Test
2830
public void get() throws URISyntaxException, Exception {
29-
request()
30-
.get("/members")
31-
.expect("[ {\n" +
32-
" \"id\" : 1,\n" +
33-
" \"name\" : \"pablo\"\n" +
34-
"} ]");
31+
request().get("/members").expect(value ->
32+
assertEquals("[ {\n" +
33+
" \"id\" : 1,\n" +
34+
" \"name\" : \"pablo\"\n" +
35+
"} ]", value.replaceAll("\r\n", "\n"))
36+
);
3537
}
3638

3739
}

modules/coverage-report/src/test/java/org/jooby/whoops/WhoopsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void shouldIgnoreMissingClass() {
4747

4848
@Test
4949
public void locationOf() {
50-
assertTrue(new File(Whoops.locationOf(Whoops.class)).exists());
50+
assertTrue(Whoops.locationOf(Whoops.class) + " file does not exist", new File(Whoops.locationOf(Whoops.class)).exists());
5151

5252
assertEquals("rt.jar", Whoops.locationOf(Object.class));
5353
}

modules/coverage-report/src/test/resources/assets.conf

Whitespace-only changes.

modules/jooby-assets-sass/src/test/java/org/jooby/assets/SassTest.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package org.jooby.assets;
22

3+
import static org.hamcrest.CoreMatchers.startsWith;
4+
import static org.hamcrest.MatcherAssert.assertThat;
35
import static org.junit.Assert.assertEquals;
46
import static org.junit.Assert.assertTrue;
57

8+
import org.hamcrest.core.StringStartsWith;
69
import org.junit.Test;
710

811
import com.typesafe.config.ConfigFactory;
@@ -204,14 +207,14 @@ public void inlineSourceMap() throws Exception {
204207
" color: $primary-color;\n" +
205208
"}\n",
206209
ConfigFactory.empty());
207-
assertTrue(output.startsWith(".foo {\n" +
208-
" color: #fff; }\n" +
209-
"\n" +
210-
"body {\n" +
211-
" font: 100% Helvetica, sans-serif;\n" +
212-
" color: #333; }\n" +
213-
"\n" +
214-
"/*# sourceMappingURL=data:application/json;base64,ewoJInZlcnNpb24iOiAzLAoJImZpbGUiOiAiLi4vLi4v"));
210+
assertThat(output, startsWith(".foo {\n" +
211+
" color: #fff; }\n" +
212+
"\n" +
213+
"body {\n" +
214+
" font: 100% Helvetica, sans-serif;\n" +
215+
" color: #333; }\n" +
216+
"\n" +
217+
"/*# sourceMappingURL=data:application/json;base64,ewoJInZlcnNpb24iOiAzLAoJImZpbGUiOiAiL")); // include up to "file": "
215218
}
216219

217220
@Test

modules/jooby-assets-svg-sprites/src/test/java/org/jooby/assets/SvgSpritesFileSetTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void requireSpriteElementPath() throws Exception {
1717

1818
@Test
1919
public void cssPath() throws Exception {
20-
assertEquals(Paths.get("target", "css", "sprite.css").toString(),
20+
assertEquals(Paths.get("target", "css").toString() + "/sprite.css",
2121
new SvgSprites()
2222
.set("spritePath", Paths.get("target", "css").toString())
2323
.cssPath());
@@ -30,7 +30,7 @@ public void cssPath() throws Exception {
3030

3131
@Test
3232
public void spritePath() throws Exception {
33-
assertEquals(Paths.get("target", "css", "sprite.svg").toString(),
33+
assertEquals(Paths.get("target", "css").toString() + "/sprite.svg",
3434
new SvgSprites()
3535
.set("spritePath", Paths.get("target", "css").toString())
3636
.spritePath());
@@ -43,7 +43,7 @@ public void spritePath() throws Exception {
4343

4444
@Test
4545
public void spritePrefix() throws Exception {
46-
assertEquals(Paths.get("target", "css", "p-sprite.svg").toString(),
46+
assertEquals(Paths.get("target", "css").toString() + "/p-sprite.svg",
4747
new SvgSprites()
4848
.set("prefix", "p")
4949
.set("spritePath", Paths.get("target", "css").toString())
@@ -58,14 +58,14 @@ public void spritePrefix() throws Exception {
5858

5959
@Test
6060
public void spriteName() throws Exception {
61-
assertEquals(Paths.get("target", "css", "p-n-sprite.svg").toString(),
61+
assertEquals(Paths.get("target", "css").toString() + "/p-n-sprite.svg",
6262
new SvgSprites()
6363
.set("prefix", "p")
6464
.set("name", "n")
6565
.set("spritePath", Paths.get("target", "css").toString())
6666
.spritePath());
6767

68-
assertEquals(Paths.get("target", "css", "n-sprite.svg").toString(),
68+
assertEquals(Paths.get("target", "css").toString() + "/n-sprite.svg",
6969
new SvgSprites()
7070
.set("name", "n")
7171
.set("spritePath", Paths.get("target", "css").toString())
@@ -74,7 +74,7 @@ public void spriteName() throws Exception {
7474

7575
@Test
7676
public void cssPrefix() throws Exception {
77-
assertEquals(Paths.get("target", "css", "p-sprite.css").toString(),
77+
assertEquals(Paths.get("target", "css").toString() + "/p-sprite.css",
7878
new SvgSprites()
7979
.set("prefix", "p")
8080
.set("spritePath", Paths.get("target", "css").toString())

modules/jooby-assets/src/test/java/org/jooby/assets/AssetCompilerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void summary() throws Exception {
8181

8282
File dir = Paths.get("target", "summary").toFile();
8383
Map<String, List<File>> files = compiler.build("dev", dir);
84-
84+
String summary = compiler.summary(files, dir.toPath(), "dev", 1000, "Foo: bar").replaceAll("\\\\","/");
8585
assertEquals("Summary:\n"
8686
+ "Pipeline: []\n"
8787
+ "Time: 1s\n"
@@ -92,7 +92,7 @@ public void summary() throws Exception {
9292
+ " assets/home.css 8b\n"
9393
+ " assets/base.js 19b\n"
9494
+ " assets/home.js 19b\n",
95-
compiler.summary(files, dir.toPath(), "dev", 1000, "Foo: bar"));
95+
summary);
9696
}
9797

9898
@Test

0 commit comments

Comments
 (0)