public void sendReportMail(Collector collector, boolean collectorServer,
			List<JavaInformations> javaInformationsList, Period period) throws Exception { // NOPMD
		final File tmpFile = new File(Parameters.TEMPORARY_DIRECTORY,
				PdfReport.getFileName(collector.getApplication()));
		try {
			try (OutputStream output = new BufferedOutputStream(new FileOutputStream(tmpFile))) {
				final PdfReport pdfReport = new PdfReport(collector, collectorServer,
						javaInformationsList, period, output);
				pdfReport.toPdf();
			}

			final String subject;
			final String subjectPrefix = Parameter.MAIL_SUBJECT_PREFIX.getValue();
			if (subjectPrefix != null) {
				// échappement des quotes qui sont des caractères spéciaux pour MessageFormat
				subject = MessageFormat.format(subjectPrefix.replace("'", "''"),
						collector.getApplication()) + " - " + period.getLabel();
			} else {
				subject = I18N.getFormattedString("Monitoring_sur", collector.getApplication())
						+ " - " + period.getLabel();
			}

			final Mailer mailer = new Mailer(Parameter.MAIL_SESSION.getValue());
			final String adminEmails = Parameter.ADMIN_EMAILS.getValue();
			mailer.send(adminEmails, subject, "", Collections.singletonList(tmpFile), false);
		} finally {
			if (!tmpFile.delete()) {
				tmpFile.deleteOnExit();
			}
		}
	}
@Test
	public void testSendReportMail() throws Exception {
		final Counter counter = new Counter("http", null);
		final Collector collector = new Collector("test", Collections.singletonList(counter));
		final List<JavaInformations> javaInformationslist = Collections
				.singletonList(new JavaInformations(null, true));
		setProperty(Parameter.ADMIN_EMAILS, "evernat@free.fr");
		setProperty(Parameter.MAIL_SESSION, "mail/Session");
		try {
			new MailReport().sendReportMail(collector, false, javaInformationslist, Period.SEMAINE);
		} catch (final NoInitialContextException e) {
			assertNotNull("ok", e);
		}
		setProperty(Parameter.MAIL_SUBJECT_PREFIX, "[javamelody] ");
		try {
			new MailReport().sendReportMail(collector, false, javaInformationslist, Period.SEMAINE);
		} catch (final NoInitialContextException e) {
			assertNotNull("ok", e);
		}

		// sendReportMailForLocalServer
		final String path = "path";
		final ServletContext context = createNiceMock(ServletContext.class);
		expect(context.getMajorVersion()).andReturn(5).anyTimes();
		expect(context.getMinorVersion()).andReturn(0).anyTimes();
		expect(context.getContextPath()).andReturn(path).anyTimes();
		replay(context);
		Parameters.initialize(context);
		try {
			new MailReport().sendReportMailForLocalServer(collector, Period.SEMAINE);
		} catch (final NoInitialContextException e) {
			assertNotNull("ok", e);
		}
		verify(context);
	}