Skip to content

Commit b6de18d

Browse files
committed
Feature: unit testing and integration testing fix #579
1 parent 13c9810 commit b6de18d

File tree

17 files changed

+1403
-57
lines changed

17 files changed

+1403
-57
lines changed

coverage-report/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@
667667
<dependency>
668668
<groupId>junit</groupId>
669669
<artifactId>junit</artifactId>
670-
<scope>test</scope>
670+
<optional>true</optional>
671671
</dependency>
672672

673673
<dependency>

gource.mp4

Whitespace-only changes.

jooby-archetype/src/main/resources/archetype-resources/pom.xml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,10 @@
4545
</dependency>
4646

4747
<dependency>
48-
<groupId>org.jooby</groupId>
49-
<artifactId>jooby</artifactId>
50-
<scope>test</scope>
51-
<classifier>tests</classifier>
52-
</dependency>
53-
54-
<!-- Fluent HC -->
55-
<dependency>
56-
<groupId>org.apache.httpcomponents</groupId>
57-
<artifactId>fluent-hc</artifactId>
48+
<groupId>io.rest-assured</groupId>
49+
<artifactId>rest-assured</artifactId>
5850
<scope>test</scope>
5951
</dependency>
60-
61-
<dependency>
62-
<groupId>org.apache.httpcomponents</groupId>
63-
<artifactId>httpmime</artifactId>
64-
<scope>test</scope>
65-
</dependency>
66-
6752
</dependencies>
6853

6954
<build>
Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,42 @@
11
package ${package};
22

3+
import static io.restassured.RestAssured.get;
4+
import static org.hamcrest.Matchers.equalTo;
5+
import static org.junit.Assert.assertEquals;
6+
7+
import org.jooby.test.JoobyRule;
8+
import org.jooby.test.MockRouter;
9+
import org.junit.ClassRule;
310
import org.junit.Test;
411

512
/**
613
* @author jooby generator
714
*/
8-
public class AppTest extends BaseTest {
15+
public class AppTest {
16+
17+
/**
18+
* One app/server for all the test of this class. If you want to start/stop a new server per test,
19+
* remove the static modifier and replace the {@link ClassRule} annotation with {@link Rule}.
20+
*/
21+
@ClassRule
22+
public static JoobyRule app = new JoobyRule(new App());
23+
24+
@Test
25+
public void integrationTest() {
26+
get("/")
27+
.then()
28+
.assertThat()
29+
.body(equalTo("Hello World!"))
30+
.statusCode(200)
31+
.contentType("text/html;charset=UTF-8");
32+
}
933

1034
@Test
11-
public void index() throws Exception {
12-
server.get("/")
13-
.expect(200)
14-
.header("Content-Type", "text/html;charset=UTF-8");
35+
public void unitTest() throws Throwable {
36+
String result = new MockRouter(new App())
37+
.get("/");
38+
39+
assertEquals("Hello World!", result);
1540
}
1641

1742
}

jooby-archetype/src/main/resources/archetype-resources/src/test/java/BaseTest.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

jooby-thymeleaf/src/main/java/org/jooby/thymeleaf/Thl.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
119
package org.jooby.thymeleaf;
220

321
import static java.util.Objects.requireNonNull;

jooby-thymeleaf/src/main/java/org/jooby/thymeleaf/ThlEngine.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
119
package org.jooby.thymeleaf;
220

321
import java.io.FileNotFoundException;

jooby-thymeleaf/src/main/java/org/jooby/thymeleaf/Thlxss.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
119
package org.jooby.thymeleaf;
220

321
import org.jooby.Env;

jooby/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
<dependency>
136136
<groupId>junit</groupId>
137137
<artifactId>junit</artifactId>
138-
<scope>test</scope>
138+
<optional>true</optional>
139139
</dependency>
140140

141141
<dependency>

jooby/src/main/java/org/jooby/Deferred.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ public void resolve(final Object value) {
287287
} else {
288288
Result result;
289289
if (value instanceof Result) {
290+
super.set(value);
290291
result = (Result) value;
291292
} else {
292293
super.set(value);
@@ -303,6 +304,7 @@ public void resolve(final Object value) {
303304
* @param cause A value for this deferred.
304305
*/
305306
public void reject(final Throwable cause) {
307+
super.set(cause);
306308
handler.handle(null, cause);
307309
}
308310

0 commit comments

Comments
 (0)