Пример #1
0
  /**
   * TestCase for getReportDocument method
   *
   * <p>Returns the report document file path
   *
   * <ol>
   *   <li>If document file is absolute path, returns it directly.
   *   <li>If it is relative path, returns the absolute path that is relative to the working folder.
   *   <li>If null, generate the document file that follows the current session id in the document
   *       folder.
   *       <ol>
   */
  public void testGetReportDocument() {
    // Absolute path
    String documentFile =
        System.getProperty("java.io.tmpdir") + "/report1.rptdocument"; // $NON-NLS-1$ //$NON-NLS-2$
    request.addParameter(ParameterAccessor.PARAM_REPORT_DOCUMENT, documentFile);
    try {
      assertEquals(documentFile, ParameterAccessor.getReportDocument(request, null, false));
    } catch (ViewerException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // Relative path
    request.addParameter(
        ParameterAccessor.PARAM_REPORT_DOCUMENT, "report1.rptdocument"); // $NON-NLS-1$
    documentFile =
        new File(root, "report1.rptdocument").getAbsolutePath().replace('\\', '/'); // $NON-NLS-1$
    try {
      String docName = ParameterAccessor.getReportDocument(request, null, false).replace('\\', '/');
      assertEquals(documentFile, docName);
    } catch (ViewerException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    /*
    		// Don't exist document file in request
    		request.removeParameter( ParameterAccessor.PARAM_REPORT_DOCUMENT );
    		String reportFile = "myproject\\report1.rptdesign"; //$NON-NLS-1$
    		request.addParameter( ParameterAccessor.PARAM_REPORT, reportFile );
    		try {
    			documentFile = ParameterAccessor
    					.getReportDocument( request, null, true );
    		} catch (ViewerException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		assertNotNull( documentFile );
    		assertTrue( documentFile.indexOf( session.getId( ) ) > 0 );
    		assertTrue( documentFile.indexOf( "report1.rptdocument" ) > 0 ); //$NON-NLS-1$
    */
    request.removeParameter(ParameterAccessor.PARAM_REPORT);
    request.removeParameter(ParameterAccessor.PARAM_REPORT_DOCUMENT);
  }