Skip to content

Commit b6103da

Browse files
committed
Add samples and test runner for samples
1 parent 93e9fd2 commit b6103da

File tree

45 files changed

+506
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+506
-0
lines changed

.github/workflows/build.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Build Plugin
2+
on: [ push, pull_request ]
3+
jobs:
4+
gradle-build:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: git clone
8+
uses: actions/checkout@v2
9+
- name: Set up JDK 11
10+
uses: actions/[email protected]
11+
with:
12+
distribution: 'zulu'
13+
java-version: 11
14+
- name: gradle build
15+
id: gradle
16+
uses: gradle/[email protected]
17+
with:
18+
arguments: :build
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
javaModuleDependencies {
14+
runtimeOnly(gav("org.slf4j.simple"))
15+
}
16+
}
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: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
23+
printData();
24+
25+
return true;
26+
}
27+
28+
protected static void printData() throws IOException {
29+
try (InputStream is = App.class.getResourceAsStream("AppData.txt")) {
30+
System.out.println(new BufferedReader(new InputStreamReader(is)).readLine());
31+
}
32+
}
33+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is data
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.my.app;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import java.io.BufferedReader;
6+
import java.io.IOException;
7+
import java.io.InputStream;
8+
import java.io.InputStreamReader;
9+
10+
import static org.junit.jupiter.api.Assertions.assertEquals;
11+
12+
public class AppWhiteboxTest {
13+
14+
@Test
15+
public void printDataTest() throws IOException {
16+
App.printData();
17+
assertEquals("org.my.app", AppWhiteboxTest.class.getModule().getName());
18+
19+
try (InputStream is = AppWhiteboxTest.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 whitebox test data

0 commit comments

Comments
 (0)