@Test
public void testToDouble() throws Exception {

    assertEquals(Double.valueOf(0.1), new RequestParameter(null, "0.1").toDouble());
    assertEquals(Double.valueOf(-0.1), new RequestParameter(null, "-0.1").toDouble());
    assertEquals(Double.valueOf(0.1), new RequestParameter(null, "foo").toDouble(0.1));
    assertEquals(Double.valueOf(0.1), new RequestParameter(null, "").toDouble(0.1));
    assertEquals(Double.valueOf(0.1), new RequestParameter(null, null).toDouble(0.1));
    try {
        new RequestParameter("foo", "").toDouble();
    } catch (MissingRequestParameterException e) {
        assertEquals("foo", e.getParameterName());
    }
    try {
        new RequestParameter("foo", null).toDouble();
    } catch (MissingRequestParameterException e) {
        assertEquals("foo", e.getParameterName());
    }
    try {
        new RequestParameter("foo", "0.1").validateWith(ALWAYS_INVALID_VALIDATION).toDouble();
    } catch (InvalidRequestParameterException e) {
        assertEquals("foo", e.getParameterName());
        assertEquals("0.1", e.getParameterValue());
    }
}