private static String[] convertMessage(final CompilerMessage message) { String text = message.getMessage(); if (!text.contains("\n")) { return new String[] {text}; } ArrayList<String> lines = new ArrayList<String>(); StringTokenizer tokenizer = new StringTokenizer(text, "\n", false); while (tokenizer.hasMoreTokens()) { lines.add(tokenizer.nextToken()); } return ArrayUtil.toStringArray(lines); }
@Override public void finished( boolean aborted, int errors, int warnings, final CompileContext compileContext) { try { for (CompilerMessageCategory category : CompilerMessageCategory.values()) { for (CompilerMessage message : compileContext.getMessages(category)) { final String msg = message.getMessage(); if (category != CompilerMessageCategory.INFORMATION || !msg.startsWith("Compilation completed successfully")) { myMessages.add(category + ": " + msg); } } } if (errors > 0) { fail("Compiler errors occurred! " + StringUtil.join(myMessages, "\n")); } assertFalse("Code did not compile!", aborted); } catch (Throwable t) { myError = t; } finally { mySemaphore.up(); } }