### Question:
Report { public static void main(String[] args) { System.out.println("Starting UFAL report generation..."); CommandLineParser parser = new PosixParser(); CommandLine cmdline = null; Options options = new Options(); options.addOption("e", "email", true, "Send report to this email address."); options.addOption("s", "specific", true, "Perform only specific reports (use index starting from 0)."); try { cmdline = parser.parse(options, args); } catch (ParseException e) { System.err.println("Invalid cmd line " + e.toString() ); log.fatal(e); System.exit(1); } DSpaceApi.load_dspace(); String dspace_dir = ConfigurationManager.getProperty("dspace.dir"); try { List<Integer> to_perform = null; if ( cmdline.getOptionValues('s') != null ) { to_perform = new ArrayList<Integer>(); for (String s : cmdline.getOptionValues('s')) { to_perform.add( Integer.valueOf(s)); } } Report r = new Report(); r.generate(to_perform); System.out.println("Reports generated..."); if ( cmdline.hasOption('e') ) { String to = cmdline.getOptionValue('e'); if ( !to.contains("@") ) { to = ConfigurationManager.getProperty("info.recipient"); } try { String email_path = dspace_dir.endsWith("/") ? dspace_dir : dspace_dir + "/"; email_path += Report.EMAIL_PATH; System.out.println(String.format("Looking for email template at [%s]", email_path)); Email email = ConfigurationManager.getEmail(email_path); email.addRecipient(to); email.addArgument( r.toString() ); email.send(); }catch (Exception me) { System.err.println("\nError sending email:"); System.err.println(" - Error: " + me); System.exit(1); } } System.out.print( r.toString() ); }catch (Exception e) { log.fatal(e); e.printStackTrace(); }finally { } } Report(); void generate(); void generate(List<Integer> to_perform); String toString(); static void main(String[] args); static final String EMAIL_PATH; }### Answer:
@Test public void testReportHandleResolutionStatistics() throws IllegalAccessException { String args[] = {"-s", "1"}; try { DSpaceApi.load_dspace("../dspace/"); }catch(Exception e) { } for (Field f : ConfigurationManager.class.getDeclaredFields()) { f.setAccessible(true); if ( f.getName().equals("properties") ) { ((Properties)f.get(null)).setProperty("dspace.url", "XXX"); } } Report.main(args); }