MCPcopy Create free account
hub / github.com/PCGen/pcgen / testJar

Method testJar

code/src/itest/pcgen/io/JarTest.java:50–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48 private final File libs = new File("libs");
49
50 @Disabled
51 void testJar() throws IOException, InterruptedException, ExecutionException {
52 // Make sure the jar is in root.
53 assertThat(jar.exists(), is(true));
54
55 // Make sure libs are there
56 assertThat(libs.exists(), is(true));
57 assertThat(libs.isDirectory(), is(true));
58 assertThat(libs.listFiles().length, is(not(0)));
59
60 // Running the the command
61 ProcessBuilder pb = new ProcessBuilder("java", "-jar", pcgenJar);
62 Process process = pb.start();
63 final ExecutorService service = Executors.newSingleThreadExecutor();
64 try {
65 final Future<?> future = service.submit(() -> {
66 try {
67 BufferedReader bri
68 = new BufferedReader(new InputStreamReader(process.getInputStream()));
69 BufferedReader bre
70 = new BufferedReader(new InputStreamReader(process.getErrorStream()));
71 process.waitFor();
72
73 String line;
74 while ((line = bri.readLine()) != null) {
75 System.out.println(line);
76 }
77
78 boolean error = false;
79 while ((line = bre.readLine()) != null) {
80 System.out.println(line);
81 error = true;
82 }
83 if (error) {
84 fail();
85 }
86 } catch (InterruptedException | IOException e) {
87 fail(e.getLocalizedMessage());
88 }
89 });
90 future.get(5, TimeUnit.SECONDS);
91 } catch (final TimeoutException e) {
92 // The process may have crashed
93 process.destroy();
94 } finally {
95 service.shutdown();
96 }
97 }
98}

Callers

nothing calls this directly

Calls 5

failMethod · 0.80
startMethod · 0.65
getMethod · 0.65
existsMethod · 0.45
shutdownMethod · 0.45

Tested by

no test coverage detected