Skip to content

Commit fb1e436

Browse files
committed
Add sample with test fixtures
Resolves #4
1 parent 543a820 commit fb1e436

File tree

28 files changed

+276
-2
lines changed

28 files changed

+276
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ that shows all plugins in combination.
3434
For a quick start, you can find some samples here:
3535
* [samples/use-all-java-module-plugins](samples/use-all-java-module-plugins)
3636
* [samples/use-only-java-module-testing-plugin](samples/use-only-java-module-testing-plugin)
37+
* [samples/use-with-test-fixtures](samples/use-with-test-fixtures)
3738

3839
For general information about how to structure Gradle builds and apply community plugins like this one to all subprojects
3940
you can check out my [Understanding Gradle video series](https://www.youtube.com/playlist?list=PLWQK2ZdV4Yl2k2OmC_gsjDpdIBTN0qqkE).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
executable: gradlew
2+
args: run
23
expected-output-file: build.out
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
executable: gradlew
2+
args: run
23
expected-output-file: build.out
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
plugins {
2+
id("org.my.gradle.java-module")
3+
id("application")
4+
}
5+
6+
application {
7+
applicationDefaultJvmArgs = listOf("-ea")
8+
mainClass.set("org.my.app.App")
9+
mainModule.set("org.my.app")
10+
}
11+
12+
dependencies {
13+
implementation(project(":lib"))
14+
implementation("org.apache.xmlbeans:xmlbeans")
15+
implementation("org.slf4j:slf4j-api")
16+
17+
integtestImplementation(project(path))
18+
19+
runtimeOnly("org.slf4j:slf4j-simple")
20+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
open module org.my.app.integtest {
2+
requires org.my.app;
3+
requires org.junit.jupiter.api;
4+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.my.app.integtest;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.my.app.App;
5+
6+
import java.io.BufferedReader;
7+
import java.io.IOException;
8+
import java.io.InputStream;
9+
import java.io.InputStreamReader;
10+
11+
import static org.junit.jupiter.api.Assertions.assertTrue;
12+
13+
public class AppIntegTest {
14+
15+
@Test
16+
public void appDoesNotExplode() throws IOException {
17+
assertTrue(App.doWork());
18+
19+
try (InputStream is = AppIntegTest.class.getResourceAsStream("AppTestData.txt")) {
20+
System.out.println(new BufferedReader(new InputStreamReader(is)).readLine());
21+
}
22+
}
23+
24+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is balackbox test data
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module org.my.app {
2+
requires org.slf4j;
3+
requires org.my.lib;
4+
requires org.apache.xmlbeans;
5+
6+
exports org.my.app;
7+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.my.app;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import org.slf4j.spi.LoggerFactoryBinder;
5+
6+
import java.io.BufferedReader;
7+
import java.io.IOException;
8+
import java.io.InputStream;
9+
import java.io.InputStreamReader;
10+
11+
public class App {
12+
public static void main(String[] args) throws IOException {
13+
doWork();
14+
}
15+
16+
public static boolean doWork() throws IOException {
17+
ObjectMapper om = new ObjectMapper();
18+
if (!om.canSerialize(LoggerFactoryBinder.class)) {
19+
throw new RuntimeException("Boom!");
20+
}
21+
System.out.println(App.class.getModule().getName());
22+
printData();
23+
24+
return true;
25+
}
26+
27+
protected static void printData() throws IOException {
28+
try (InputStream is = App.class.getResourceAsStream("AppData.txt")) {
29+
System.out.println(new BufferedReader(new InputStreamReader(is)).readLine());
30+
}
31+
}
32+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is data

0 commit comments

Comments
 (0)