public static void error(String errorMessage) { LOG.error("[Error] " + errorMessage); }
private static void error(String s) { LOGGER.error(s); }
private static void error(String s) { LOGGER.error(s); }
public static void error(String errorMessage) { LOG.error("[Error] " + errorMessage); }
/** * @deprecated Unused */ @Deprecated public static void copyFile(File from, File to) { to.getParentFile().mkdirs(); try (InputStream in = new FileInputStream(from); OutputStream out = new FileOutputStream(to)) { byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } } catch(IOException e){ LOG.error(e.getMessage(),e); } }
public static void writeResourceToFile(File file, String resourceName, Class<?> clasz) throws IOException { InputStream inputStream = clasz.getResourceAsStream("/" + resourceName); if (inputStream == null) { LOG.error("Couldn't find resource on the class path: " + resourceName); return; } try { try (FileOutputStream outputStream = new FileOutputStream(file)) { int nread; byte[] buffer = new byte[4096]; while (0 < (nread = inputStream.read(buffer))) { outputStream.write(buffer, 0, nread); } } } finally { inputStream.close(); } }
/** * Saves the content of the string buffer to the specified file. * * @param file the file to write to. * @param content the content to write to the file. */ protected void saveSuiteContent(final File file, final XMLStringBuffer content) { try (OutputStreamWriter fw = new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8"))) { fw.write(content.getStringBuffer().toString()); } catch (IOException ioe) { // TODO CQ is this normal to swallow exception here LOGGER.error("IO Exception", ioe); } } }
/** * Class.getEnclosingClass() only exists on JDK5, so reimplementing it * here. */ private static Class<?> getEnclosingClass(Class<?> declaringClass) { Class<?> result = null; String className = declaringClass.getName(); int index = className.indexOf('$'); if (index != -1) { String ecn = className.substring(0, index); try { result = Class.forName(ecn); } catch (ClassNotFoundException e) { Logger.getLogger(ClassHelper.class).error(e.getMessage(),e); } } return result; }
private void readAndPrintFile(String fileName) { try { Files.readAllLines(Paths.get(fileName)).forEach(line -> log(" " + line, Project.MSG_INFO)); } catch (IOException ex) { LOGGER.error(ex.getMessage(), ex); } }
private Object invokeMethod(Annotation test, String methodName) { Object result = null; try { // Note: we should cache methods already looked up Method m = test.getClass().getMethod(methodName); result = m.invoke(test); } catch (Exception e) { Logger.getLogger(JDK15TagFactory.class).error(e.getMessage(), e); } return result; } }
public static void writeUtf8File(@Nullable String outputDir, String fileName, XMLStringBuffer xsb, String prefix) { try { final File outDir = (outputDir != null) ? new File(outputDir) : new File("").getAbsoluteFile(); if (!outDir.exists()) { outDir.mkdirs(); } final File file = new File(outDir, fileName); if (!file.exists()) { file.createNewFile(); } try (final OutputStreamWriter w = new OutputStreamWriter(new FileOutputStream(file), "UTF-8")) { if (prefix != null) { w.append(prefix); } xsb.toWriter(w); } } catch(IOException ex) { LOG.error(ex.getMessage(), ex); } }
/** * Saves the content of the string buffer to the specified file. * * @param file the file to write to. * @param content the content to write to the file. */ protected void saveSuiteContent(final File file, final XMLStringBuffer content) { try (OutputStreamWriter fw = new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8"))) { fw.write(content.getStringBuffer().toString()); } catch (IOException ioe) { // TODO CQ is this normal to swallow exception here LOGGER.error("IO Exception", ioe); } } }
@Override public String toString() { String result = null; if (m_file != null) { flushToFile(); try { result = Files.readFile(m_file); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } } else { result = m_sb.toString(); } return result; } }
@Override public XmlSuite parse(String currentFile, InputStream inputStream, boolean loadClasses) { XmlSuite result = null; try { result = parse2(currentFile, inputStream, loadClasses); } catch (Exception e) { Logger.getLogger(DomXmlParser.class).error(e.getMessage(), e); } return result; }
private static void writeFile(File outputFile, String sb, @Nullable String encoding) { BufferedWriter fw = null; try { fw = openWriter(outputFile, encoding); fw.write(sb); Utils.log("", 3, "Creating " + outputFile.getAbsolutePath()); } catch(IOException ex) { if (TestRunner.getVerbose() > 1) { LOG.error("ERROR WHILE WRITING TO " + outputFile,ex); } else { log(FORMAT, 1, "Error while writing to " + outputFile + ": " + ex.getMessage()); } } finally { try { if (fw != null) { fw.close(); } } catch (IOException e) { // ignore } } }
private static void writeFile(File outputFile, String sb, @Nullable String encoding) { try (BufferedWriter fw = openWriter(outputFile, encoding)) { fw.write(sb); Utils.log("", 3, "Creating " + outputFile.getAbsolutePath()); } catch (IOException ex) { if (TestRunner.getVerbose() > 1) { LOG.error("ERROR WHILE WRITING TO " + outputFile, ex); } else { log(FORMAT, 1, "Error while writing to " + outputFile + ": " + ex.getMessage()); } } // ignore }
private void setText(Object bean, Text child) { List<Pair<Method, Wrapper>> pairs = Reflect.findMethodsWithAnnotation(bean.getClass(), TagContent.class, bean); for (Pair<Method, Wrapper> pair : pairs) { try { pair.first().invoke(bean, child.getTextContent()); } catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException | DOMException e) { LOGGER.error(e.getMessage(), e); } } }
@Override public int compareTo(@Nonnull Object o) { int result = 0; try { SuiteResult other = (SuiteResult) o; String n1 = getTestContext().getName(); String n2 = other.getTestContext().getName(); result = n1.compareTo(n2); } catch (Exception ex) { ex.printStackTrace(); Logger.getLogger(SuiteResult.class).error(ex.getMessage(), ex); } return result; }
@Override public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) { try { writer = createWriter(outputDirectory); } catch (IOException e) { LOG.error("Unable to create output file", e); return; } for (ISuite suite : suites) { suiteResults.add(new SuiteResult(suite)); } writeDocumentStart(); writeHead(); writeBody(); writeDocumentEnd(); writer.close(); }
/** Creates summary of the run */ @Override public void generateReport(List<XmlSuite> xml, List<ISuite> suites, String outdir) { try { m_out = createWriter(outdir); } catch (IOException e) { L.error("output file", e); return; } startHtml(m_out); generateSuiteSummaryReport(suites); generateMethodSummaryReport(suites); generateMethodDetailReport(suites); endHtml(m_out); m_out.flush(); m_out.close(); }