0 Replies Latest reply on Sep 18, 2015 4:13 PM by claudinei

    Get test resource path as string

    claudinei Newbie

      I´m using arquillian with TestNg to test my reports generator class, i created a report file to test the method and put it in /test/resources/ directory but i don't know how to pass the path to my method.

      The method is like this:

      public void generateReport(final String reportName, final ReportType reportType, final List<Object> data, final Map<String, Object> parameters) {
           JasperPrint jasperPrint = JasperFillManager.fillReport(report.getPath() + "/" + report.getName() + ".jasper", report.getParameters(),  collectionDataSource);

      The path is a String in web I use getExternalContext().getRealPath, but I need the resources path for test.

      I tried to add the report file as a resource in arquillian and give "" for path, but it's not works.


      Test method:


      public void shouldGenerateReport() throws ReportException, AccessDeniedException {
           report = new Report("testReport", ReportType.PDF, "", new ArrayList<>(), null);
           ByteArrayOutputStream stream = reportService.generateReport(report);