public float getFloat() { if (min >= max) return min; return min + random().nextFloat() * (max - min); }
@Override public boolean shouldCache(Query query) throws IOException { return random().nextBoolean(); }
protected int between(int min, int max) { return min != max ? random().nextInt(max-min+1) + min : min; } }
/** * Returns a new Directory instance, with contents copied from the * provided directory. See {@link #newDirectory()} for more * information. */ public static BaseDirectoryWrapper newDirectory(Directory d) throws IOException { return newDirectory(random(), d); }
@BeforeClass public static void setupSpins() { // Randomize IOUtils.spins() count so CMS varies its dynamic defaults, and this also "fixes" core // count from the master seed so it will always be the same on reproduce: boolean spins = random().nextBoolean(); System.setProperty(ConcurrentMergeScheduler.DEFAULT_SPINS_PROPERTY, Boolean.toString(spins)); }
/** create a new index writer config with random defaults */ public static IndexWriterConfig newIndexWriterConfig(Analyzer a) { return newIndexWriterConfig(random(), a); }
public static LogMergePolicy newLogMergePolicy() { return newLogMergePolicy(random()); }
public static Field newStringField(String name, String value, Store stored) { return newField(random(), name, value, stored == Store.YES ? StringField.TYPE_STORED : StringField.TYPE_NOT_STORED); }
public static Field newStringField(String name, BytesRef value, Store stored) { return newField(random(), name, value, stored == Store.YES ? StringField.TYPE_STORED : StringField.TYPE_NOT_STORED); }
public static boolean rarely() { return rarely(random()); }
private void populateSolrUrls(MiniSolrCloudCluster cluster) { if (random().nextBoolean()) { final List<JettySolrRunner> solrNodes = cluster.getJettySolrRunners(); for (JettySolrRunner node : solrNodes) { this.solrUrls.add(node.getBaseUrl().toString()); } } else { this.solrUrls.add(cluster.getRandomJetty(random()).getBaseUrl().toString()); } }
@BeforeClass public static void setupCPUCoreCount() { // Randomize core count so CMS varies its dynamic defaults, and this also "fixes" core // count from the master seed so it will always be the same on reproduce: int numCores = TestUtil.nextInt(random(), 1, 4); System.setProperty(ConcurrentMergeScheduler.DEFAULT_CPU_CORE_COUNT_PROPERTY, Integer.toString(numCores)); }
/** Like {@link #newDirectory} except randomly the {@link VirusCheckingFS} may be installed */ public static BaseDirectoryWrapper newMaybeVirusCheckingDirectory() { if (random().nextInt(5) == 4) { Path path = addVirusChecker(createTempDir()); return newFSDirectory(path); } else { return newDirectory(random()); } }
/** create a new index writer config with random defaults */ public static IndexWriterConfig newIndexWriterConfig() { return newIndexWriterConfig(new MockAnalyzer(random())); }
public static Path addVirusChecker(Path path) { if (TestUtil.hasVirusChecker(path) == false) { VirusCheckingFS fs = new VirusCheckingFS(path.getFileSystem(), random().nextLong()); FileSystem filesystem = fs.getFileSystem(URI.create("file:///")); path = new FilterPath(path, filesystem); } return path; }
public CloudSolrClientBuilder(MiniSolrCloudCluster cluster) { if (random().nextBoolean()) { this.zkHosts.add(cluster.getZkServer().getZkAddress()); } else { populateSolrUrls(cluster); } randomizeCloudSolrClient(); }
/** Like {@link #newFSDirectory(Path)}, but randomly insert {@link VirusCheckingFS} */ public static BaseDirectoryWrapper newMaybeVirusCheckingFSDirectory(Path f) { if (random().nextInt(5) == 4) { f = addVirusChecker(f); } return newFSDirectory(f, FSLockFactory.getDefault()); }
@Test public void testBufferOverflow() throws Exception { final StringBuilder sb = new StringBuilder(); final Random r = LuceneTestCase.random(); for (int i = 0; i < 300; i++) { sb.append((char) 65 + r.nextInt(26)); } this.assertURLDecodedTo(_t, "<" + sb.toString() + ">", new String[] { sb.toString() }); }
@Test public void testBufferOverflow() throws Exception { final StringBuilder sb = new StringBuilder(); final Random r = LuceneTestCase.random(); for (int i = 0; i < 300; i++) { sb.append((char) 65 + r.nextInt(26)); } this.assertURLDecodedTo(_t, "<" + sb.toString() + ">", new String[] { sb.toString() }); }