@Test
public void testCaseInsensitiveMatching() throws Exception
{

    configurationService.setProperty("usage-statistics.bots.case-insensitive", true);
    spiderDetectorService = new SpiderDetectorServiceImpl(configurationService);
    DummyHttpServletRequest req = new DummyHttpServletRequest();
    req.setAddress(NOT_A_BOT_ADDRESS); // avoid surprises
    req.setRemoteHost("notabot.example.com"); // avoid surprises
    req.setAgent("Firefox"); // avoid surprises
    String candidate;
    // Test agent patterns
    req.setAgent("msnboT Is WaTching you");
    assertTrue("'msnbot' didn't match pattern", spiderDetectorService.isSpider(req));
    req.setAgent("FirefOx");
    assertFalse("'Firefox' matched a pattern", spiderDetectorService.isSpider(req));
    // Test IP patterns
    candidate = "192.168.2.1";
    req.setAddress(candidate);
    assertTrue(candidate + " did not match IP patterns", spiderDetectorService.isSpider(req));
    req.setAddress(NOT_A_BOT_ADDRESS);
    assertFalse(NOT_A_BOT_ADDRESS + " matched IP patterns", spiderDetectorService.isSpider(req));
    // Test DNS patterns
    candidate = "baiduspiDer-dSPace-test.crawl.baIDu.com";
    req.setRemoteHost(candidate);
    assertTrue(candidate + " did match DNS patterns", spiderDetectorService.isSpider(req));
    candidate = "wIki.dsPace.oRg";
    req.setRemoteHost(candidate);
    assertFalse(candidate + " matched DNS patterns", spiderDetectorService.isSpider(req));
}