Package com.crawljax.core.configuration

Examples of com.crawljax.core.configuration.CrawljaxConfiguration


    RunWithWebServer server = new RunWithWebServer("/site");
    server.before();
    CrawljaxConfigurationBuilder builder = CrawljaxConfiguration
            .builderFor(server.getSiteUrl().resolve("iframe/"));
    builder.crawlRules().click("a");
    CrawljaxConfiguration config = builder.build();

    CandidateElementExtractor extractor = newElementExtractor(config);
    browser.goToUrl(server.getSiteUrl().resolve("iframe/"));
    List<CandidateElement> candidates = extractor.extract(DUMMY_STATE);
View Full Code Here


  @Test
  public void whenNoFollowExternalUrlDoNotFollow() throws IOException, URISyntaxException {
    CrawljaxConfigurationBuilder builder =
            CrawljaxConfiguration.builderFor("http://example.com");
    builder.crawlRules().click("a");
    CrawljaxConfiguration config = builder.build();
    CandidateElementExtractor extractor = newElementExtractor(config);

    List<CandidateElement> extract = extractFromTestFile(extractor);

    assertThat(config.getCrawlRules().followExternalLinks(), is(false));
    assertThat(extract, hasSize(2));
  }
View Full Code Here

  public void whenFollowExternalUrlDoFollow() throws IOException, URISyntaxException {
    CrawljaxConfigurationBuilder builder =
            CrawljaxConfiguration.builderFor("http://example.com");
    builder.crawlRules().click("a");
    builder.crawlRules().followExternalLinks(true);
    CrawljaxConfiguration config = builder.build();
    CandidateElementExtractor extractor = newElementExtractor(config);

    List<CandidateElement> extract = extractFromTestFile(extractor);

    assertThat(config.getCrawlRules().followExternalLinks(), is(true));
    assertThat(extract, hasSize(3));
  }
View Full Code Here

   * Make sure On new State Plugin executed.
   */
  @Test
  public void testOnNewStatePlugin() {
    hit = false;
    CrawljaxConfiguration config = CrawljaxConfiguration.builderFor(
            "http://localhost").addPlugin(new OnNewStatePlugin() {

      @Override
      public void onNewState(CrawlerContext context, StateVertex state) {
        hit = true;
View Full Code Here

  }

  private void setupForConsumers(int consumers) {
    executor = Executors.newFixedThreadPool(consumers + 2);
    CrawljaxConfiguration config =
            CrawljaxConfiguration
                    .builderFor("http://example.com")
                    .addPlugin(postCrawlPlugin)
                    .setBrowserConfig(
                            new BrowserConfiguration(BrowserType.FIREFOX, consumers))
                    .build();

    candidateActions =
            new UnfiredCandidateActions(config.getBrowserConfig(), graphProvider,
                    new MetricRegistry());

    consumersDoneLatch = new ExitNotifier(config.getMaximumStates());

    when(consumerFactory.get()).thenReturn(new CrawlTaskConsumer(candidateActions,
            consumersDoneLatch, crawler));

    crawlSessionProvider = new CrawlSessionProvider(graph, config, new MetricRegistry());
View Full Code Here

  private MetricRegistry registry;

  @Before
  public void setup() {
    registry = new MetricRegistry();
    CrawljaxConfiguration config = CrawljaxConfiguration.builderFor("http://localhost")
            .addPlugin(domChange, browserCreatedPlugin,
                    fireEventFailedPlugin, invariantViolationPlugin, newStatePlugin,
                    onRevisitStatePlugin,
                    urlLoadPlugin, postCrawlingPlugin, prestatePlugin).build();
    plugins = new Plugins(config, registry);
View Full Code Here

* @see <a href="http://metrics.codahale.com/">http://metrics.codahale.com/</a>
*/
public class MetricPluginExample {

  public static void main(String[] args) {
    CrawljaxConfiguration config =
            CrawljaxConfiguration.builderFor("http://demo.crawljax.com")
                    .addPlugin(new MetricPlugin())
                    .build();

    new CrawljaxRunner(config).call();
View Full Code Here

    when(formHandlerFactory.newFormHandler(browser)).thenReturn(formHandler);
    url = URI.create("http://example.com");
    when(browser.getCurrentUrl()).thenReturn(url.toString());
    when(sessionProvider.get()).thenReturn(session);

    CrawljaxConfiguration config = Mockito.spy(CrawljaxConfiguration.builderFor(url).build());
    stateComparator = new StateComparator(config.getCrawlRules());

    when(extractor.extract(target)).thenReturn(ImmutableList.of(action));
    when(graphProvider.get()).thenReturn(graph);

    context =
View Full Code Here

  public void testIframeExclusions() throws CrawljaxException {
    CrawljaxConfigurationBuilder builder = setupConfig();
    builder.crawlRules().dontCrawlFrame("frame1");
    builder.crawlRules().dontCrawlFrame("sub");
    builder.crawlRules().dontCrawlFrame("frame0");
    CrawljaxConfiguration config = builder.build();
    crawljax = new CrawljaxRunner(config);
    CrawlSession session = crawljax.call();
    assertThat(session.getStateFlowGraph(), hasEdges(3));
    assertThat(session.getStateFlowGraph(), hasStates(4));
  }
View Full Code Here

      System.exit(1);
    }
    CrawlSpecification crawler = new CrawlSpecification(args[0]);
    crawler.clickDefaultElements();

    CrawljaxConfiguration config = new CrawljaxConfiguration();

    config.setCrawlSpecification(crawler);

    try {
      CrawljaxController crawljax = new CrawljaxController(config);
      crawljax.run();
    } catch (ConfigurationException e) {
View Full Code Here

TOP

Related Classes of com.crawljax.core.configuration.CrawljaxConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.