Package com.crawljax.core.configuration.CrawljaxConfiguration

Examples of com.crawljax.core.configuration.CrawljaxConfiguration.CrawljaxConfigurationBuilder


  @ClassRule
  public static final RunWithWebServer SERVER = new RunWithWebServer("/site");

  @Test
  public void maximumDepthIsOblidged() throws Exception {
    CrawljaxConfigurationBuilder builder = SERVER.newConfigBuilder("infinite.html");
    int depth = 3;

    CrawljaxRunner runner = new CrawljaxRunner(builder.setMaximumDepth(depth).build());
    CrawlSession session = runner.call();

    assertThat(session.getStateFlowGraph(), hasStates(depth + 1));
    assertThat(runner.getReason(), is(ExitStatus.EXHAUSTED));
  }
View Full Code Here


    assertThat(runner.getReason(), is(ExitStatus.EXHAUSTED));
  }

  @Test(timeout = 60_000)
  public void maximumTimeIsOblidged() throws Exception {
    CrawljaxConfigurationBuilder builder = SERVER.newConfigBuilder("infinite.html");

    CrawljaxRunner runner = new CrawljaxRunner(builder.setUnlimitedCrawlDepth()
            .setMaximumRunTime(25, TimeUnit.SECONDS)
            .build());
    runner.call();
    assertThat(runner.getReason(), is(ExitStatus.MAX_TIME));
View Full Code Here

  }

  @Test(timeout = 60_000)
  public void maximumStatesIsOblidged() throws Exception {
    CrawljaxConfigurationBuilder builder = SERVER.newConfigBuilder("infinite.html");

    CrawljaxRunner runner = new CrawljaxRunner(builder.setUnlimitedCrawlDepth()
            .setMaximumStates(3)
            .build());
    CrawlSession session = runner.call();
    assertThat(session.getStateFlowGraph(), hasStates(3));
    assertThat(runner.getReason(), is(ExitStatus.MAX_STATES));
View Full Code Here

  }

  @Test(timeout = 60_000)
  public void whenStopIsCalledTheCrawlerStopsGracefully() throws Exception {
    CrawljaxConfigurationBuilder builder = SERVER.newConfigBuilder("infinite.html");

    CrawljaxRunner runner = new CrawljaxRunner(builder.setUnlimitedCrawlDepth()
            .setUnlimitedCrawlDepth()
            .setUnlimitedStates()
            .build());

    ExecutorService executor = Executors.newSingleThreadExecutor();
View Full Code Here

  @Test
  public void testHiddenElementsSiteCrawl() throws Exception {
    CrawlSession crawl = new BaseCrawler("hidden-elements-site") {
      @Override
      public CrawljaxConfigurationBuilder newCrawlConfigurationBuilder() {
        CrawljaxConfigurationBuilder builder =
                super.newCrawlConfigurationBuilder();
        builder.crawlRules().crawlHiddenAnchors(true);
        return builder;
      }
    }.crawl();

    StateFlowGraph stateFlowGraph = crawl.getStateFlowGraph();
View Full Code Here

  }

  @Test(timeout = 60_000)
  public void whenCrawljaxIsShutDownByAPluginItShutsDown() throws Exception {
    CrawljaxConfigurationBuilder builder = SERVER.newConfigBuilder("infinite.html");

    CrawljaxRunner runner = new CrawljaxRunner(builder.setUnlimitedCrawlDepth()
            .addPlugin(new OnNewStatePlugin() {

              private int count = 0;

              @Override
View Full Code Here

   * Make sure InvariantViolationPlugin executed.
   */
  @Test
  public void testInvariantFailurePlugin() {
    hit = false;
    CrawljaxConfigurationBuilder builder = CrawljaxConfiguration.builderFor(
            "http://localhost").addPlugin(new OnInvariantViolationPlugin() {
      @Override
      public void onInvariantViolation(Invariant invariant, CrawlerContext context) {
        hit = true;
      }
    });
    builder.crawlRules().addInvariant(new Invariant("Test123", new Condition() {

      @Override
      public boolean check(EmbeddedBrowser browser) {
        return false;
      }
    }));
    setStateMachineForConfig(builder.build());

    // state2.equals(state3)
    StateVertex state2 = new StateVertexImpl(2, "state2", "<table><div>state2</div></table>");
    StateVertex state3 = new StateVertexImpl(3, "state3", "<table><div>state2</div></table>");

View Full Code Here

  @ClassRule
  public static final RunWithWebServer WEB_SERVER = new RunWithWebServer("site");

  @Test
  public void testPopups() throws CrawljaxException {
    CrawljaxConfigurationBuilder builder =
            CrawljaxConfiguration.builderFor(WEB_SERVER.getSiteUrl().toExternalForm()
                    + "popup");
    builder.setMaximumDepth(3);
    builder.crawlRules().click("a");
    builder.crawlRules().waitAfterEvent(100, TimeUnit.MILLISECONDS);
    builder.crawlRules().waitAfterReloadUrl(100, TimeUnit.MILLISECONDS);
    CrawljaxRunner runner = new CrawljaxRunner(builder.build());
    CrawlSession session = runner.call();
    assertThat(session.getStateFlowGraph(), hasEdges(2));
    assertThat(session.getStateFlowGraph(), hasStates(3));
  }
View Full Code Here

  /**
   * retrieve / build the CrawljaxConfiguration for the given arguments.
   */
  protected CrawljaxConfiguration getCrawljaxConfiguration() {

    CrawljaxConfigurationBuilder builder =
            CrawljaxConfiguration.builderFor(WEB_SERVER.getSiteUrl());
    builder.crawlRules().waitAfterEvent(getTimeOutAfterEvent(), TimeUnit.MILLISECONDS);
    builder.crawlRules()
            .waitAfterReloadUrl(getTimeOutAfterReloadUrl(), TimeUnit.MILLISECONDS);
    builder.setMaximumDepth(3);
    builder.crawlRules().clickOnce(true);

    builder.setBrowserConfig(getBrowserConfiguration());

    addCrawlElements(builder);

    builder.crawlRules().setInputSpec(getInputSpecification());

    addCrawlConditions(builder);
    addOracleComparators(builder);
    addInvariants(builder);
    addWaitConditions(builder);
    addPlugins(builder);

    return builder.build();
  }
View Full Code Here

   * Override this method to specify a different configuration.
   *
   * @return a new {@link CrawljaxConfiguration} to crawl with.
   */
  protected CrawljaxConfigurationBuilder newCrawlConfigurationBuilder() {
    CrawljaxConfigurationBuilder builder = CrawljaxConfiguration.builderFor(getUrl());
    builder.crawlRules().clickDefaultElements();
    builder.setUnlimitedRuntime();
    builder.setUnlimitedCrawlDepth();
    builder.addPlugin(new PostCrawlStateGraphChecker());
    return builder;
  }
View Full Code Here

TOP

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

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.