Examples of TestDriver


Examples of com.netflix.astyanax.test.TestDriver

//            })
        .build();
       
        final List<HostConnectionPool<TestClient>> hostPools = Lists.newArrayList(pool.getActivePools());
       
        final TestDriver driver = new TestDriver.Builder()
            .withIterationCount(0)
            .withThreadCount(200)
//            .withFutures(100,  TimeUnit.MILLISECONDS)
            .withCallsPerSecondSupplier(Suppliers.ofInstance(200))
//            .withFutures(100, TimeUnit.MILLISECONDS)
            .withCallback(new Function<TestDriver, Void>() {
                public Void apply(final TestDriver driver) {
                    long startTime = System.nanoTime();
                    try {
                        pool.executeWithFailover(new TestOperation() {
                            public String execute(TestClient client) throws ConnectionException, OperationException {
                                try {
                                    function.apply(driver);
                                    return null;
                                }
                                catch (RuntimeException e) {
                                    if (e.getCause() instanceof ConnectionException)
                                        throw (ConnectionException)e.getCause();
                                    throw e;
                                }
                            }
                        }, new RunOnce());
                    } catch (PoolTimeoutException e) {
                        LOG.info(e.getMessage());
                    } catch (ConnectionException e) {
                    } finally {
                        sampler.addSample((System.nanoTime() - startTime)/1000000);
                    }
                   
                    return null;
                }
            })
           
            //
            //  Event to turn timeouts on/off
            //
            .withRecurringEvent(10,  TimeUnit.SECONDS,  new Function<TestDriver, Void>() {
                @Override
                public Void apply(TestDriver driver) {
                    timeoutsEnabled.getAndSet(!timeoutsEnabled.get());
//                    LOG.info("Toggle timeouts " + timeoutsEnabled.get());
                    return null;
                }
            })
           
            //
            //  Print status information
            //
            .withRecurringEvent(1,  TimeUnit.SECONDS,  new Function<TestDriver, Void>() {
                @Override
                public Void apply(TestDriver driver) {
                    long opCount = lastOperationCount.get();
                    lastOperationCount.set(driver.getOperationCount());
                   
                    System.out.println("" + driver.getRuntime() + "," + sampler.getScore() + "," + (lastOperationCount.get() - opCount));
                    System.out.println(monitor.toString());
                    System.out.println(monitor.toString());
                    for (HostConnectionPool<TestClient> host : pool.getPools()) {
                        System.out.println("   " + host.toString());
                    }
                    return null;
                }
            })
           
            //
            //  Remove a random host
            //
            .withRecurringEvent(10,  TimeUnit.SECONDS,  new Function<TestDriver, Void>() {
                @Override
                public Void apply(TestDriver driver) {
//                    System.out.println("Latency: " + sampler.getScore());
//                   
//                    List<Host> newHosts = Lists.newArrayList(hosts);
//                    newHosts.remove(new Random().nextInt(hosts.size()));
//                    pool.setHosts(newHosts);
//                   
//                    System.out.println(monitor.toString());
//                    for (HostConnectionPool<TestClient> host : pool.getPools()) {
//                        System.out.println("   " + host.toString());
//                    }
                    return null;
                }
            })
            .build();
       
        driver.start();
        try {
            driver.await();
        } catch (InterruptedException e) {
        }
    }
View Full Code Here

Examples of com.opera.core.systems.testing.drivers.TestDriver

      currentPlatform();
    }
  }

  public void removeDriverIfNecessary() {
    TestDriver driver = getWrappedDriver();
    if (!spawnDriver && (driver != null && driver.isRunning())) {
      removeDriver();
    }
  }
View Full Code Here

Examples of com.opera.core.systems.testing.drivers.TestDriver

      removeDriver();
    }
  }

  public static void removeDriver() {
    TestDriver current = storedDriver.get();

    if (current == null) {
      return;
    }

    try {
      current.quit();
    } catch (RuntimeException ignored) {
      // fall through
    } finally {
      storedDriver.remove();
    }
View Full Code Here

Examples of com.opera.core.systems.testing.drivers.TestDriver

      testException = e;
    }

    if (test instanceof TestCase) {
      TestCase base = (TestCase) test;
      TestDriver driver = base.getWrappedDriver();

      // If any driver is present we don't need a different supplier's driver to initialize
      // TestIgnorance.  This skips the supplies(klass) check in createDriverIfNecessary().
      if (driver == null || !driver.isRunning()) {
        base.createDriverIfNecessary();
        driver = base.getWrappedDriver();
      }

      ignorance = new TestIgnorance(driver.getServices().getAvailableServices(),
                                    driver.getRunner() != null,
                                    driver.getServices().isOperaIdleAvailable(),
                                    driver.utils().getPlatform(),
                                    driver.utils().getProduct());
    } else {
      ignorance = new TestIgnorance(new LinkedHashMap<ScopeService, String>(),
                                    false,
                                    false,
                                    Platform.getCurrent(),
View Full Code Here

Examples of com.opera.core.systems.testing.drivers.TestDriver

  @Test
  public void operaExtensionIsInstalled() throws IOException {
    File oexSource = resourceCopy(resources.locate("dummy-extension.oex"));

    settings.profile().addExtension(oexSource);
    TestDriver driver = new TestDriverBuilder().using(settings).get();

    assertNotNull(driver);
    assertTrue("Expected Opera to run", driver.isRunning());
    driver.navigate().to(pages.oex);

    try {
      // The dummy extension sets a HTML attribute on the <html> element.
      By by = By.cssSelector("html[isoexinstalled759='yes']");
      (new WebDriverWait(driver, 2)).until(ExpectedConditions.presenceOfElementLocated(by));
    } catch (TimeoutException e) {
      fail("Custom opera extension not detected!");
    }

    driver.quit();
  }
View Full Code Here

Examples of com.opera.core.systems.testing.drivers.TestDriver

  @Ignore(products = CORE, value = "core does not reset port number if -debugproxy is omitted")
  public void testDefaultPort() {
    DesiredCapabilities c = new DesiredCapabilities();
    c.setCapability(OperaSettings.Capability.PORT.getCapability(), -1);

    TestDriver a = new TestDriverBuilder().using(c).get();
    assertEquals(7001, a.preferences().get("Developer Tools", "Proxy Port").getValue());
    a.quit();
  }
View Full Code Here

Examples of com.opera.core.systems.testing.drivers.TestDriver

  @Test
  public void testRandomPort() {
    DesiredCapabilities c = new DesiredCapabilities();
    c.setCapability(OperaSettings.Capability.PORT.getCapability(), 0);

    TestDriver a;
    try {
      a = new TestDriverBuilder().using(c).get();
    } catch (Exception e) {
      // If immediately exited, then it doesn't support the flags
      if (e.getMessage().contains("Opera exited immediately")) {
        return;
      } else {
        fail("Unexpected exception: " + e);
        return;
      }
    }
    Assert.assertNotSame("7001", a.preferences().get("Developer Tools", "Proxy Port").toString());
    a.quit();
  }
View Full Code Here

Examples of com.opera.core.systems.testing.drivers.TestDriver

          value = "Once this is set the autotestmode profile no longer connects on 7001, breaking future tests")
  public void testSetPort() {
    OperaSettings settings = new OperaSettings();
    settings.setPort(9876);

    TestDriver a;
    try {
      a = new TestDriverBuilder().using(settings).get();
    } catch (Exception e) {
      // If immediately exited, then it doesn't support the flags
      if (e.getMessage().contains("Opera exited immediately")) {
        return;
      } else {
        fail("Unexpected exception: " + e);
        return;
      }
    }

    assertEquals(9876, a.preferences().get("Developer Tools", "Proxy Port").getValue());
    a.quit();
  }
View Full Code Here

Examples of com.opera.core.systems.testing.drivers.TestDriver

  }

  @Test
  public void binaryIsCorrectlyLaunched() {
    settings.setBinary(OperaBinary.find());
    TestDriver driver = new TestDriverBuilder().using(settings).get();

    assertNotNull(driver);
    assertTrue("Expected Opera to run", driver.isRunning());

    driver.quit();
  }
View Full Code Here

Examples of com.opera.core.systems.testing.drivers.TestDriver

  public void binaryRegistersProduct() {
    assumeTrue(System.getenv(OperaBinary.OPERA_PATH_ENV_VAR) == null);

    settings.setBinary(OperaBinary.find(OperaProduct.MOBILE));

    TestDriver driver = new TestDriverBuilder().using(settings).get();

    assertEquals(OperaProduct.MOBILE, driver.utils().getProduct());
    assertEquals(OperaProduct.MOBILE, driver.getSettings().getProduct());

    driver.quit();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.