Package com.carrotsearch.randomizedtesting

Examples of com.carrotsearch.randomizedtesting.RandomizedContext


        File directory = new File(System.getProperty("tempDir", System.getProperty("java.io.tmpdir")));
        assert directory.exists() &&
               directory.isDirectory() &&
               directory.canWrite();

        RandomizedContext ctx = RandomizedContext.current();
        Class<?> clazz = ctx.getTargetClass();
        String prefix = clazz.getName();
        prefix = prefix.replaceFirst("^org.apache.lucene.", "lucene.");
        prefix = prefix.replaceFirst("^org.apache.solr.", "solr.");

        int attempt = 0;
        File f;
        do {
          if (attempt++ >= TEMP_NAME_RETRY_THRESHOLD) {
            throw new RuntimeException(
                "Failed to get a temporary name too many times, check your temp directory and consider manually cleaning it: "
                  + directory.getAbsolutePath());           
          }
          f = new File(directory, prefix + "-" + ctx.getRunnerSeedAsString()
                + "-" + String.format(Locale.ENGLISH, "%03d", attempt));
        } while (!f.mkdirs());

        tempDirBase = f;
        registerToRemoveAfterSuite(tempDirBase);
View Full Code Here


* can be re-run with the same random sequence if something fails.
*/
public class Test002ExtendingRandomizedTest extends RandomizedTest {
  @Test
  public void getContextByHand() {
    RandomizedContext context = RandomizedContext.current();
    Random rnd = context.getRandom();
    System.out.println("Random, next int: " + rnd.nextInt());
  }
View Full Code Here

  @Test
  public void subThreadContextPropagation() throws Throwable {
    final long seed = Utils.getRunnerSeed();
    new ThreadWithException() {
      protected void runWrapped() {
        RandomizedContext ctx = RandomizedContext.current();
        Assert.assertEquals(seed, Utils.getSeed(ctx.getRandomness()));
      }
    }.startAndJoin();
  }
View Full Code Here

    final long seed = Utils.getRunnerSeed();
    final ExecutorService executor = Executors.newCachedThreadPool();
    try {
      executor.submit(new Runnable() {
        public void run() {
          RandomizedContext ctx = RandomizedContext.current();
          Assert.assertEquals(seed, Utils.getSeed(ctx.getRandomness()));
        }
      }).get();
    } catch (ExecutionException e) {
      throw e.getCause();
    } finally {
View Full Code Here

        File directory = new File(System.getProperty("tempDir", System.getProperty("java.io.tmpdir")));
        assert directory.exists() &&
               directory.isDirectory() &&
               directory.canWrite();

        RandomizedContext ctx = RandomizedContext.current();
        Class<?> clazz = ctx.getTargetClass();
        String prefix = clazz.getName();
        prefix = prefix.replaceFirst("^org.apache.lucene.", "lucene.");
        prefix = prefix.replaceFirst("^org.apache.solr.", "solr.");

        int attempt = 0;
        File f;
        do {
          if (attempt++ >= TEMP_NAME_RETRY_THRESHOLD) {
            throw new RuntimeException(
                "Failed to get a temporary name too many times, check your temp directory and consider manually cleaning it: "
                  + directory.getAbsolutePath());           
          }
          f = new File(directory, prefix + "-" + ctx.getRunnerSeedAsString()
                + "-" + String.format(Locale.ENGLISH, "%03d", attempt));
        } while (!f.mkdirs());

        tempDirBase = f;
        registerToRemoveAfterSuite(tempDirBase);
View Full Code Here

TOP

Related Classes of com.carrotsearch.randomizedtesting.RandomizedContext

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.