Skip to content

Commit

Permalink
Added unit test to demonstrate bug when crawler user agent is non-low…
Browse files Browse the repository at this point in the history
…ercase
  • Loading branch information
rvenutolo committed Apr 2, 2016
1 parent 996f6d0 commit bb6bb78
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package edu.uci.ics.crawler4j.tests;

import edu.uci.ics.crawler4j.robotstxt.HostDirectives;
import edu.uci.ics.crawler4j.robotstxt.RobotstxtParser;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;

public class RobotstxtParserNonLowercaseUserAgentTest {

@Test
public void testParseWithNonLowercaseUserAgent() {
String userAgent = "testAgent";
String content = "User-agent: " + userAgent + "\n"
+ "Disallow: /test/path/\n";
HostDirectives hostDirectives = RobotstxtParser.parse(content, userAgent);
assertNotNull("parsed HostDirectives is null", hostDirectives);
assertFalse("HostDirectives should not allow path: '/test/path/'", hostDirectives.allows("/test/path/"));
}

}

0 comments on commit bb6bb78

Please sign in to comment.