private void doMonitoring(HttpServletRequest httpRequest, HttpServletResponse httpResponse)
			throws IOException, ServletException {
		if (isRumMonitoring(httpRequest, httpResponse)) {
			return;
		}

		if (!isAllowed(httpRequest, httpResponse)) {
			return;
		}

		final Collector collector = filterContext.getCollector();
		final MonitoringController monitoringController = new MonitoringController(collector, null);
		monitoringController.doActionIfNeededAndReport(httpRequest, httpResponse,
				filterConfig.getServletContext());

		if ("stop".equalsIgnoreCase(HttpParameter.COLLECTOR.getParameterFrom(httpRequest))) {
			// on a été appelé par un serveur de collecte qui fera l'aggrégation dans le temps,
			// le stockage et les courbes, donc on arrête le timer s'il est démarré
			// et on vide les stats pour que le serveur de collecte ne récupère que les deltas
			for (final Counter counter : collector.getCounters()) {
				counter.clear();
			}

			if (!collector.isStopped()) {
				LOG.debug(
						"Stopping the javamelody collector in this webapp, because a collector server from "
								+ httpRequest.getRemoteAddr()
								+ " wants to collect the data itself");
				filterContext.stopCollector();
			}
		}
	}
@Test
	public void testDoMonitoring() throws ServletException, IOException {
		monitoring(Collections.emptyMap());
		monitoring(Collections.singletonMap(HttpParameter.FORMAT, "html"));
		monitoring(Collections.singletonMap(HttpParameter.FORMAT, "htmlbody"));
		setProperty(Parameter.DISABLED, Boolean.TRUE.toString());
		try {
			setUp();
			monitoring(Collections.emptyMap(), false);
		} finally {
			setProperty(Parameter.DISABLED, Boolean.FALSE.toString());
		}
		setProperty(Parameter.NO_DATABASE, Boolean.TRUE.toString());
		try {
			setUp();
			monitoring(Collections.emptyMap());
		} finally {
			setProperty(Parameter.NO_DATABASE, Boolean.FALSE.toString());
		}
		setProperty(Parameter.ALLOWED_ADDR_PATTERN, "256.*");
		try {
			setUp();
			monitoring(Collections.emptyMap(), false);
			setProperty(Parameter.ALLOWED_ADDR_PATTERN, ".*");
			setUp();
			monitoring(Collections.emptyMap(), false);
		} finally {
			setProperty(Parameter.ALLOWED_ADDR_PATTERN, null);
		}
		setProperty(Parameter.AUTHORIZED_USERS, "admin:password, ");
		try {
			setUp();
			monitoring(Collections.emptyMap(), false);
			setProperty(Parameter.AUTHORIZED_USERS, "");
			setUp();
			monitoring(Collections.emptyMap(), false);
		} finally {
			setProperty(Parameter.AUTHORIZED_USERS, null);
		}
		setProperty(Parameter.MONITORING_PATH, "/admin/monitoring");
		try {
			setUp();
			monitoring(Collections.emptyMap(), false);
		} finally {
			setProperty(Parameter.MONITORING_PATH, "/monitoring");
		}
		try {
			setProperty(Parameter.JMX_EXPOSE_ENABLED, Boolean.TRUE.toString());
			setUp();
			monitoring(Collections.emptyMap());
		} finally {
			setProperty(Parameter.JMX_EXPOSE_ENABLED, null);
		}
	}