@Test @Repeat(iterations = 20) public void testSequentialAccessSparseVectorWritable() throws Exception { Vector v = new SequentialAccessSparseVector(MAX_VECTOR_SIZE); createRandom(v); doTestVectorWritableEquals(v); }
/** * Determine if a given method's iterations should run with a fixed seed or not. */ private boolean isConstantSeedForAllIterations(Method method) { if (testCaseRandomnessOverride != null) return true; Repeat repeat; if ((repeat = method.getAnnotation(Repeat.class)) != null) { return repeat.useConstantSeed(); } if ((repeat = suiteClass.getAnnotation(Repeat.class)) != null) { return repeat.useConstantSeed(); } return false; }
/** * Determine method iteration count based on (first declaration order wins): * <ul> * <li>global property {@link SysGlobals#SYSPROP_ITERATIONS}.</li> * <li>method annotation {@link Repeat}.</li> * <li>class annotation {@link Repeat}.</li> * <li>The default (1).</li> * <ul> */ private int determineMethodIterationCount(Method method) { // Global override. if (iterationsOverride != null) return iterationsOverride; Repeat repeat; if ((repeat = method.getAnnotation(Repeat.class)) != null) { return repeat.iterations(); } if ((repeat = suiteClass.getAnnotation(Repeat.class)) != null) { return repeat.iterations(); } return DEFAULT_ITERATIONS; }
/** * Determine if a given method's iterations should run with a fixed seed or not. */ private boolean isConstantSeedForAllIterations(Method method) { if (testCaseRandomnessOverride != null) return true; Repeat repeat; if ((repeat = method.getAnnotation(Repeat.class)) != null) { return repeat.useConstantSeed(); } if ((repeat = suiteClass.getAnnotation(Repeat.class)) != null) { return repeat.useConstantSeed(); } return false; }
/** * Determine method iteration count based on (first declaration order wins): * <ul> * <li>global property {@link SysGlobals#SYSPROP_ITERATIONS}.</li> * <li>method annotation {@link Repeat}.</li> * <li>class annotation {@link Repeat}.</li> * <li>The default (1).</li> * <ul> */ private int determineMethodIterationCount(Method method) { // Global override. if (iterationsOverride != null) return iterationsOverride; Repeat repeat; if ((repeat = method.getAnnotation(Repeat.class)) != null) { return repeat.iterations(); } if ((repeat = suiteClass.getAnnotation(Repeat.class)) != null) { return repeat.iterations(); } return DEFAULT_ITERATIONS; }
@Test @Repeat(iterations = 20) public void testDenseVectorWritable() throws Exception { Vector v = new DenseVector(MAX_VECTOR_SIZE); createRandom(v); doTestVectorWritableEquals(v); }
@Test @Repeat(iterations = 20) public void testRandomAccessSparseVectorWritable() throws Exception { Vector v = new RandomAccessSparseVector(MAX_VECTOR_SIZE); createRandom(v); doTestVectorWritableEquals(v); }
@Test @Repeat(iterations = 20) public void testNamedVectorWritable() throws Exception { Vector v = new DenseVector(MAX_VECTOR_SIZE); v = new NamedVector(v, "Victor"); createRandom(v); doTestVectorWritableEquals(v); }
@Seed("deadbeef") @Test @Repeat(iterations = 20) public void testAgainstReferenceOpenHashSet() { Set<Integer> base = new OpenHashSet<>();
@Test @Repeat(iterations = 20) public void testViewSequentialAccessSparseVectorWritable() throws Exception { Vector v = new SequentialAccessSparseVector(MAX_VECTOR_SIZE); createRandom(v); Vector view = new VectorView(v, 0, v.size()); doTestVectorWritableEquals(view); }
@Test @Repeat(iterations = 20) public void testAgainstReferenceOpenIntHashSet() { AbstractIntSet base = new OpenIntHashSet();
@Test @Repeat(iterations = 20) public void testAgainstReferenceOpenObjectIntHashMap() { OpenObjectIntHashMap<Integer> base = new OpenObjectIntHashMap<>();
@Test @Repeat(iterations = 20) public void testAgainstReferenceOpenIntObjectHashMap() { OpenIntObjectHashMap<Integer> base = new OpenIntObjectHashMap<>();
@Test @Repeat(iterations = 20) public void testAgainstReferenceOpenIntIntHashMap() { OpenIntIntHashMap base = new OpenIntIntHashMap();
@Repeat(iterations = 5) public void mySecondTest() { System.out.println("Second test."); } }
@Test @Repeat(iterations = 3) public void addOne() { System.out.println("counter=" + (++counter) + ", costly=" + costly); } }
@Test @Repeat(iterations = 10) public void executorLeak() throws Exception { int numThreads = 50; final ExecutorService executor = Executors.newFixedThreadPool(numThreads); for (int i = 0; i < 2 * numThreads; i++) { executor.submit(new Runnable() { public void run() { sleep(10); } }); } executor.shutdown(); executor.awaitTermination(1, TimeUnit.SECONDS); Assert.assertTrue(executor.isShutdown()); Assert.assertTrue(executor.isTerminated()); } }
@Repeat(iterations = 10, useConstantSeed = false) @Test public void halfAndHalf() { assertTrue(randomBoolean()); } }
@Repeat(iterations = 5, useConstantSeed = true) @Seed("f00ddead") @Test public void repeatFailure() { assertTrue(randomBoolean()); }
@Seeds({@Seed("deadbeef"), @Seed("cafebabe")}) @Test @Repeat(iterations = 2, useConstantSeed = true) public void paramsWithRepeatAndSeeds() { System.out.println(value + " " + string + " " + getContext().getRandomness()); }