LUCENE-9871: cleaning up the build system. Upgrade palantir. Remove all ant-related hacks.

This commit is contained in:
Dawid Weiss 2021-03-30 12:41:06 +02:00
commit c7455ff561
42 changed files with 268 additions and 427 deletions

View File

@ -20,7 +20,7 @@ import java.time.format.DateTimeFormatter
plugins { plugins {
id "base" id "base"
id "com.palantir.consistent-versions" version "1.14.0" id "com.palantir.consistent-versions" version "1.28.0"
id "org.owasp.dependencycheck" version "5.3.0" id "org.owasp.dependencycheck" version "5.3.0"
id 'de.thetaphi.forbiddenapis' version '3.1' apply false id 'de.thetaphi.forbiddenapis' version '3.1' apply false
id "de.undercouch.download" version "4.1.1" apply false id "de.undercouch.download" version "4.1.1" apply false
@ -28,7 +28,7 @@ plugins {
id 'com.diffplug.spotless' version "5.8.2" apply false id 'com.diffplug.spotless' version "5.8.2" apply false
} }
apply from: file('gradle/defaults.gradle') apply from: file('gradle/globals.gradle')
// General metadata. // General metadata.
@ -107,24 +107,21 @@ ext {
// if the build file is incorrectly written and evaluates something // if the build file is incorrectly written and evaluates something
// eagerly). // eagerly).
apply from: file('gradle/generate-defaults.gradle') apply from: file('gradle/generation/local-settings.gradle')
// Ant-compatibility layer: apply folder layout early so that
// evaluation of other scripts doesn't need to be deferred.
apply from: file('gradle/ant-compat/folder-layout.gradle')
// Set up defaults and configure aspects for certain modules or functionality // Set up defaults and configure aspects for certain modules or functionality
// (java, tests) // (java, tests)
apply from: file('gradle/defaults-java.gradle') apply from: file('gradle/java/folder-layout.gradle')
apply from: file('gradle/java/javac.gradle')
apply from: file('gradle/testing/defaults-tests.gradle') apply from: file('gradle/testing/defaults-tests.gradle')
apply from: file('gradle/testing/randomization.gradle') apply from: file('gradle/testing/randomization.gradle')
apply from: file('gradle/testing/fail-on-no-tests.gradle') apply from: file('gradle/testing/fail-on-no-tests.gradle')
apply from: file('gradle/testing/alternative-jdk-support.gradle') apply from: file('gradle/testing/alternative-jdk-support.gradle')
apply from: file('gradle/jar-manifest.gradle') apply from: file('gradle/java/jar-manifest.gradle')
// Publishing and releasing // Publishing and releasing
apply from: file('gradle/maven/defaults-maven.gradle') apply from: file('gradle/publishing/defaults-maven.gradle')
apply from: file('gradle/releasing.gradle') apply from: file('gradle/publishing/distribution.gradle')
// IDE support, settings and specials. // IDE support, settings and specials.
apply from: file('gradle/ide/intellij-idea.gradle') apply from: file('gradle/ide/intellij-idea.gradle')
@ -143,7 +140,6 @@ apply from: file('gradle/validation/rat-sources.gradle')
apply from: file('gradle/validation/owasp-dependency-check.gradle') apply from: file('gradle/validation/owasp-dependency-check.gradle')
apply from: file('gradle/validation/ecj-lint.gradle') apply from: file('gradle/validation/ecj-lint.gradle')
apply from: file('gradle/validation/gradlew-scripts-tweaked.gradle') apply from: file('gradle/validation/gradlew-scripts-tweaked.gradle')
apply from: file('gradle/validation/check-broken-links.gradle')
apply from: file('gradle/validation/spotless.gradle') apply from: file('gradle/validation/spotless.gradle')
@ -163,7 +159,7 @@ apply from: file('gradle/datasets/external-datasets.gradle')
apply from: file('gradle/native/disable-native.gradle') apply from: file('gradle/native/disable-native.gradle')
// Additional development aids. // Additional development aids.
apply from: file('gradle/maven/maven-local.gradle') apply from: file('gradle/publishing/maven-local.gradle')
apply from: file('gradle/testing/per-project-summary.gradle') apply from: file('gradle/testing/per-project-summary.gradle')
apply from: file('gradle/testing/slowest-tests-at-end.gradle') apply from: file('gradle/testing/slowest-tests-at-end.gradle')
apply from: file('gradle/testing/failed-tests-at-end.gradle') apply from: file('gradle/testing/failed-tests-at-end.gradle')
@ -171,16 +167,11 @@ apply from: file('gradle/testing/profiling.gradle')
apply from: file('gradle/testing/beasting.gradle') apply from: file('gradle/testing/beasting.gradle')
apply from: file('gradle/help.gradle') apply from: file('gradle/help.gradle')
// Ant-compatibility layer. ALL OF THESE SHOULD BE GONE at some point. They are
// here so that we can coexist with current ant build but they are indicative
// of potential problems with the build conventions, dependencies, etc.
apply from: file('gradle/ant-compat/misc.gradle')
apply from: file('gradle/ant-compat/test-classes-cross-deps.gradle')
apply from: file('gradle/documentation/documentation.gradle') apply from: file('gradle/documentation/documentation.gradle')
apply from: file('gradle/documentation/changes-to-html.gradle') apply from: file('gradle/documentation/changes-to-html.gradle')
apply from: file('gradle/documentation/markdown.gradle') apply from: file('gradle/documentation/markdown.gradle')
apply from: file('gradle/documentation/render-javadoc.gradle') apply from: file('gradle/documentation/render-javadoc.gradle')
apply from: file('gradle/documentation/check-broken-links.gradle')
apply from: file('gradle/hacks/gradle-archives.gradle') apply from: file('gradle/hacks/gradle-archives.gradle')
apply from: file('gradle/hacks/wipe-temp.gradle') apply from: file('gradle/hacks/wipe-temp.gradle')

View File

@ -1,45 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Exclude inner classes from testing.
allprojects {
tasks.withType(Test) { task ->
exclude '**/*$*'
}
}
// Exclude test classes that are not actually stand-alone tests (they're executed from other stuff).
configure(project(":lucene:replicator")) {
plugins.withType(JavaPlugin) {
test {
exclude "**/SimpleServer*"
}
}
}
// Resources from top-level project folder are looked up via getClass(). Strange.
configure(project(":lucene:benchmark")) {
plugins.withType(JavaPlugin) {
task syncConf(type: Sync) {
from('conf')
into file("${sourceSets.test.java.outputDir}/conf")
}
processTestResources.dependsOn syncConf
}
}

View File

@ -1,43 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Set up cross-project dependency on test classes. This should be resolved by pulling reused classes into
// a separate regular module. Exporting test classes is sort of weird.
configure([project(":lucene:spatial3d"),
project(":lucene:analysis:common"),
project(":lucene:backward-codecs"),
project(":lucene:queryparser")]) {
plugins.withType(JavaPlugin) {
configurations {
testClassesExported
}
artifacts {
testClassesExported sourceSets.test.java.outputDir, {
builtBy testClasses
}
}
}
}
configure(project(":lucene:spatial-extras")) {
plugins.withType(JavaPlugin) {
dependencies {
testImplementation project(path: ':lucene:spatial3d', configuration: 'testClassesExported')
}
}
}

View File

@ -15,36 +15,38 @@
* limitations under the License. * limitations under the License.
*/ */
configure(rootProject) { def resources = scriptResources(buildscript)
task checkBrokenLinks {
group 'Verification'
description 'Check broken links in the entire documentation'
dependsOn ':lucene:documentation:checkBrokenLinks'
}
}
configure(project(':lucene:documentation')) { configure(project(':lucene:documentation')) {
task checkBrokenLinks(type: CheckBrokenLinksTask, 'dependsOn': 'documentation') task checkBrokenLinks(type: CheckBrokenLinksTask) {
group 'Verification'
description 'Check broken links in the entire documentation'
dependsOn 'documentation'
validationScript = file("${resources}/checkJavadocLinks.py")
docsDir.fileProvider(provider { -> file(project.docroot) })
output = project.file("${buildDir}/check-broken-links-output.txt")
}
check.dependsOn checkBrokenLinks check.dependsOn checkBrokenLinks
} }
class CheckBrokenLinksTask extends DefaultTask { class CheckBrokenLinksTask extends DefaultTask {
// wraps input directory location in DirectoryProperty so as to lazily evaluate 'docroot' property // wraps input directory location in DirectoryProperty so as to lazily evaluate 'docroot' property
// (see gradle/documentation/documentation.gradle) // (see gradle/documentation/documentation.gradle)
@InputDirectory @InputDirectory
final DirectoryProperty docsDir = project.objects.directoryProperty() final DirectoryProperty docsDir = project.objects.directoryProperty()
.fileProvider(project.providers.provider { project.docroot })
@InputFile @InputFile
File script = project.rootProject.file("dev-tools/scripts/checkJavadocLinks.py") File validationScript
@OutputFile
File output
@TaskAction @TaskAction
def check() { def check() {
def outputFile = project.file("${getTemporaryDir()}/check-broken-links-output.txt")
def result def result
outputFile.withOutputStream { output -> output.withOutputStream { output ->
result = project.exec { result = project.exec {
executable project.externalTool("python3") executable project.externalTool("python3")
ignoreExitValue = true ignoreExitValue = true
@ -52,14 +54,14 @@ class CheckBrokenLinksTask extends DefaultTask {
errorOutput = output errorOutput = output
args = [ args = [
"-B", "-B",
script.absolutePath, validationScript.absolutePath,
docsDir.get().getAsFile() docsDir.get().getAsFile()
] ]
} }
} }
if (result.getExitValue() != 0) { if (result.getExitValue() != 0) {
throw new GradleException("Broken links check failed. Command output at: ${outputFile}") throw new GradleException("Broken links check failed. Command output at: ${output}")
} }
} }
} }

View File

@ -23,13 +23,6 @@ allprojects {
// Repositories to fetch dependencies from. // Repositories to fetch dependencies from.
repositories { repositories {
mavenCentral() mavenCentral()
if (System.getProperty("skip.lucene") as Boolean) {
maven {
name "ApacheSnapshots"
url 'https://repository.apache.org/content/repositories/snapshots/'
}
}
} }
// Artifacts will have names after full gradle project path // Artifacts will have names after full gradle project path

View File

@ -30,7 +30,12 @@ allprojects {
// Inject vm options into any JavaExec task... We could narrow it // Inject vm options into any JavaExec task... We could narrow it
// down but I don't think there is any harm in keeping it broad. // down but I don't think there is any harm in keeping it broad.
tasks.withType(JavaExec) { tasks.withType(JavaExec) { task ->
// Skip tuning java exec for benchmarks.
if (task.path == ":lucene:benchmark:run") {
return
}
jvmArgs += vmOpts jvmArgs += vmOpts
} }
} }

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
// Adapt to custom folder convention. // Adapt to custom, legacy folder convention.
allprojects { allprojects {
plugins.withType(JavaPlugin) { plugins.withType(JavaPlugin) {
sourceSets { sourceSets {
@ -32,11 +32,7 @@ allprojects {
into sourceSets.test.java.outputDir into sourceSets.test.java.outputDir
} }
processTestResources.dependsOn copyTestResources processTestResources.dependsOn copyTestResources
}
}
allprojects {
plugins.withType(JavaPlugin) {
// if 'src/tools' exists, add it as a separate sourceSet. // if 'src/tools' exists, add it as a separate sourceSet.
if (file('src/tools/java').exists()) { if (file('src/tools/java').exists()) {
sourceSets { sourceSets {

View File

@ -84,6 +84,20 @@ configure(subprojects.findAll { it.path in rootProject.published }) { prj ->
} }
} }
// Skip any test fixtures in publishing.
afterEvaluate {
configurations.matching {
return it.name in [
"testFixturesApiElements",
"testFixturesRuntimeElements"
]
}.all {
project.components.java.withVariantsFromConfiguration(it) {
skip()
}
}
}
// Do not generate gradle metadata files. // Do not generate gradle metadata files.
tasks.withType(GenerateModuleMetadata) { tasks.withType(GenerateModuleMetadata) {
enabled = false enabled = false

View File

@ -69,10 +69,12 @@ allprojects { prj ->
suppressAnnotations += [ suppressAnnotations += [
"**.SuppressForbidden" "**.SuppressForbidden"
] ]
doFirst dynamicSignatures.curry(configurations.compileClasspath, "lucene")
} }
// Configure defaults for sourceSets.test // Configure defaults for sourceSets.test
forbiddenApisTest { tasks.matching { it.name in ["forbiddenApisTest", "forbiddenApisTestFixtures"] }.all {
bundledSignatures += [ bundledSignatures += [
'jdk-unsafe', 'jdk-unsafe',
'jdk-deprecated', 'jdk-deprecated',
@ -87,6 +89,12 @@ allprojects { prj ->
suppressAnnotations += [ suppressAnnotations += [
"**.SuppressForbidden" "**.SuppressForbidden"
] ]
if (it.name == "forbiddenApisTestFixtures") {
doFirst dynamicSignatures.curry(configurations.testFixturesCompileClasspath, "lucene")
} else {
doFirst dynamicSignatures.curry(configurations.testCompileClasspath, "lucene")
}
} }
// Configure defaults for sourceSets.tools (if present). // Configure defaults for sourceSets.tools (if present).
@ -103,9 +111,21 @@ allprojects { prj ->
] ]
doFirst dynamicSignatures.curry(configurations.toolsCompileClasspath, "lucene") doFirst dynamicSignatures.curry(configurations.toolsCompileClasspath, "lucene")
inputs.dir(file(resources)) inputs.dir(file(resources))
} }
// We rely on resolved configurations to compute the relevant set of rule
// files for forbiddenApis. Since we don't want to resolve these configurations until
// the task is executed, we can't really use them as task inputs properly. This is a
// chicken-and-egg problem.
//
// This is the simplest workaround possible: just point at all the rule files and indicate
// them as inputs. This way if a rule is modified, checks will be reapplied.
configure(tasks.matching { it.name.startsWith("forbiddenApis") }) { task ->
task.inputs.dir(file(resources))
}
// Disable sysout signatures for these projects. // Disable sysout signatures for these projects.
if (prj.path in [ if (prj.path in [
":lucene:demo", ":lucene:demo",
@ -116,24 +136,5 @@ allprojects { prj ->
'jdk-system-out' 'jdk-system-out'
] ]
} }
forbiddenApisMain {
doFirst dynamicSignatures.curry(configurations.compileClasspath, "lucene")
}
forbiddenApisTest {
doFirst dynamicSignatures.curry(configurations.testCompileClasspath, "lucene")
}
// We rely on resolved configurations to compute the relevant set of rule
// files for forbiddenApis. Since we don't want to resolve these configurations until
// the task is executed, we can't really use them as task inputs properly. This is a
// chicken-and-egg problem.
//
// This is the simplest workaround possible: just point at all the rule files and indicate
// them as inputs. This way if a rule is modified, checks will be reapplied.
configure([forbiddenApisMain, forbiddenApisTest]) { task ->
task.inputs.dir(file(resources))
}
}) })
} }

View File

@ -1,2 +0,0 @@
@defaultMessage Use org.apache.solr.common.annotation.JsonProperty instead
com.fasterxml.jackson.annotation.JsonProperty

View File

@ -1,35 +0,0 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
@defaultMessage Spawns threads without MDC logging context; use ExecutorUtil.newMDCAwareFixedThreadPool instead
java.util.concurrent.Executors#newFixedThreadPool(int,java.util.concurrent.ThreadFactory)
@defaultMessage Spawns threads without MDC logging context; use ExecutorUtil.newMDCAwareSingleThreadExecutor instead
java.util.concurrent.Executors#newSingleThreadExecutor(java.util.concurrent.ThreadFactory)
@defaultMessage Spawns threads without MDC logging context; use ExecutorUtil.newMDCAwareCachedThreadPool instead
java.util.concurrent.Executors#newCachedThreadPool(java.util.concurrent.ThreadFactory)
@defaultMessage Use ExecutorUtil.MDCAwareThreadPoolExecutor instead of ThreadPoolExecutor
java.util.concurrent.ThreadPoolExecutor#<init>(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.BlockingQueue,java.util.concurrent.ThreadFactory,java.util.concurrent.RejectedExecutionHandler)
java.util.concurrent.ThreadPoolExecutor#<init>(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.BlockingQueue)
java.util.concurrent.ThreadPoolExecutor#<init>(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.BlockingQueue,java.util.concurrent.ThreadFactory)
java.util.concurrent.ThreadPoolExecutor#<init>(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.BlockingQueue,java.util.concurrent.RejectedExecutionHandler)
@defaultMessage Use RTimer/TimeOut/System.nanoTime for time comparisons, and `new Date()` output/debugging/stats of timestamps. If for some miscellaneous reason, you absolutely need to use this, use a SuppressForbidden.
java.lang.System#currentTimeMillis()
@defaultMessage Use slf4j classes instead
java.util.logging.**

View File

@ -1,20 +0,0 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
@defaultMessage Creates threads without a thread name
java.lang.Thread#<init>()
java.lang.Thread#<init>(java.lang.Runnable)
java.lang.Thread#<init>(java.lang.ThreadGroup,java.lang.Runnable)

View File

@ -1,43 +0,0 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
@defaultMessage Servlet API method is parsing request parameters without using the correct encoding if no extra configuration is given in the servlet container
javax.servlet.ServletRequest#getParameter(java.lang.String)
javax.servlet.ServletRequest#getParameterMap()
javax.servlet.ServletRequest#getParameterNames()
javax.servlet.ServletRequest#getParameterValues(java.lang.String)
javax.servlet.http.HttpServletRequest#getSession() @ Servlet API getter has side effect of creating sessions
@defaultMessage Servlet API method is broken and slow in some environments (e.g., Jetty's UTF-8 readers)
javax.servlet.ServletRequest#getReader()
javax.servlet.ServletResponse#getWriter()
javax.servlet.ServletInputStream#readLine(byte[],int,int)
javax.servlet.ServletOutputStream#print(boolean)
javax.servlet.ServletOutputStream#print(char)
javax.servlet.ServletOutputStream#print(double)
javax.servlet.ServletOutputStream#print(float)
javax.servlet.ServletOutputStream#print(int)
javax.servlet.ServletOutputStream#print(long)
javax.servlet.ServletOutputStream#print(java.lang.String)
javax.servlet.ServletOutputStream#println(boolean)
javax.servlet.ServletOutputStream#println(char)
javax.servlet.ServletOutputStream#println(double)
javax.servlet.ServletOutputStream#println(float)
javax.servlet.ServletOutputStream#println(int)
javax.servlet.ServletOutputStream#println(long)
javax.servlet.ServletOutputStream#println(java.lang.String)

View File

@ -1,3 +0,0 @@
@defaultMessage Use slf4j classes instead
org.apache.log4j.**
org.apache.logging.log4j.**

View File

@ -190,8 +190,8 @@ class ValidateSourcePatternsTask extends DefaultTask {
def validSPINameJavadocTag = ~$/(?s)\s*\*\s*@lucene\.spi\s+\{@value #NAME\}/$; def validSPINameJavadocTag = ~$/(?s)\s*\*\s*@lucene\.spi\s+\{@value #NAME\}/$;
def isLicense = { matcher, ratDocument -> def isLicense = { matcher, ratDocument ->
licenseMatcher.reset(); licenseMatcher.reset()
return lineSplitter.split(matcher.group(1)).any{ licenseMatcher.match(ratDocument, it) }; return lineSplitter.split(matcher.group(1)).any { licenseMatcher.match(ratDocument, it) }
} }
def checkLicenseHeaderPrecedes = { f, description, contentPattern, commentPattern, text, ratDocument -> def checkLicenseHeaderPrecedes = { f, description, contentPattern, commentPattern, text, ratDocument ->
@ -213,7 +213,7 @@ class ValidateSourcePatternsTask extends DefaultTask {
def checkMockitoAssume = { f, text -> def checkMockitoAssume = { f, text ->
if (text.contains("mockito") && !text.contains("assumeWorkingMockito()")) { if (text.contains("mockito") && !text.contains("assumeWorkingMockito()")) {
reportViolation(f, 'File uses Mockito but has no assumeWorkingMockito() call'); reportViolation(f, 'File uses Mockito but has no assumeWorkingMockito() call')
} }
} }

View File

@ -19,7 +19,7 @@ plugins {
id "java" id "java"
} }
description = 'System for benchmarking Lucene' description = 'Lucene benchmarking module'
dependencies { dependencies {
implementation project(':lucene:core') implementation project(':lucene:core')
@ -43,9 +43,15 @@ dependencies {
testImplementation project(':lucene:test-framework') testImplementation project(':lucene:test-framework')
} }
// We add 'conf' to resources because we validate *.alg script correctness in one of the tests.
sourceSets {
test.resources.srcDirs += ['conf']
}
task run(type: JavaExec) { task run(type: JavaExec) {
description "Run a perf test (optional: -PtaskAlg=conf/your-algorithm-file -PmaxHeapSize=1G)" description "Run a perf test (optional: -PtaskAlg=conf/your-algorithm-file -PmaxHeapSize=1G)"
main 'org.apache.lucene.benchmark.byTask.Benchmark' main 'org.apache.lucene.benchmark.byTask.Benchmark'
classpath sourceSets.main.runtimeClasspath classpath sourceSets.main.runtimeClasspath
// allow these to be specified on the CLI via -PtaskAlg= for example // allow these to be specified on the CLI via -PtaskAlg= for example
args = [propertyOrDefault('taskAlg', 'conf/micro-standard.alg')] args = [propertyOrDefault('taskAlg', 'conf/micro-standard.alg')]

View File

@ -18,6 +18,7 @@ package org.apache.lucene.benchmark.byTask;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import java.net.URL;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream; import java.nio.file.DirectoryStream;
import java.nio.file.Files; import java.nio.file.Files;
@ -35,6 +36,7 @@ import org.apache.lucene.benchmark.byTask.utils.Config;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks; import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
import org.junit.Assert;
/** Test very simply that perf tasks are parsed as expected. */ /** Test very simply that perf tasks are parsed as expected. */
@SuppressSysoutChecks(bugUrl = "very noisy") @SuppressSysoutChecks(bugUrl = "very noisy")
@ -122,9 +124,14 @@ public class TestPerfTasksParse extends LuceneTestCase {
/** Test the parsing of example scripts * */ /** Test the parsing of example scripts * */
@SuppressWarnings("try") @SuppressWarnings("try")
public void testParseExamples() throws Exception { public void testParseExamples() throws Exception {
// hackedy-hack-hack
// Locate the folder with *.alg resources. This is hacky - we look up
// one of the resources and then assume it's an accessible path.
URL resource = getClass().getClassLoader().getResource("addIndexes.alg");
Assert.assertNotNull("Couldn't locate *.alg resources?", resource);
boolean foundFiles = false; boolean foundFiles = false;
final Path examplesDir = Paths.get(getClass().getResource("/conf").toURI()); final Path examplesDir = Paths.get(resource.toURI()).getParent();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(examplesDir, "*.alg")) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(examplesDir, "*.alg")) {
for (Path path : stream) { for (Path path : stream) {
Config config = new Config(Files.newBufferedReader(path, StandardCharsets.UTF_8)); Config config = new Config(Files.newBufferedReader(path, StandardCharsets.UTF_8));
@ -152,10 +159,12 @@ public class TestPerfTasksParse extends LuceneTestCase {
config.set("query.maker", MockQueryMaker.class.getName()); config.set("query.maker", MockQueryMaker.class.getName());
} }
PerfRunData data = new PerfRunData(config); PerfRunData data = new PerfRunData(config);
try (Algorithm algo = new Algorithm(data)) {} new Algorithm(data).close();
foundFiles = true; foundFiles = true;
} }
} }
if (!foundFiles) { if (!foundFiles) {
fail("could not find any .alg files!"); fail("could not find any .alg files!");
} }

View File

@ -17,17 +17,18 @@
package org.apache.lucene.util; package org.apache.lucene.util;
public class TestVirtualMethod extends LuceneTestCase { public class TestVirtualMethod extends LuceneTestCase {
private static final VirtualMethod<Base> publicTestMethod =
new VirtualMethod<>(Base.class, "publicTest", String.class);
private static final VirtualMethod<Base> protectedTestMethod =
new VirtualMethod<>(Base.class, "protectedTest", int.class);
private static final VirtualMethod<TestVirtualMethod> publicTestMethod = static class Base {
new VirtualMethod<>(TestVirtualMethod.class, "publicTest", String.class); public void publicTest(String test) {}
private static final VirtualMethod<TestVirtualMethod> protectedTestMethod =
new VirtualMethod<>(TestVirtualMethod.class, "protectedTest", int.class);
public void publicTest(String test) {} protected void protectedTest(int test) {}
}
protected void protectedTest(int test) {} static class Nested1 extends Base {
static class TestClass1 extends TestVirtualMethod {
@Override @Override
public void publicTest(String test) {} public void publicTest(String test) {}
@ -35,74 +36,73 @@ public class TestVirtualMethod extends LuceneTestCase {
protected void protectedTest(int test) {} protected void protectedTest(int test) {}
} }
static class TestClass2 extends TestClass1 { static class Nested2 extends Nested1 {
@Override // make it public here @Override // make it public here
public void protectedTest(int test) {} public void protectedTest(int test) {}
} }
static class TestClass3 extends TestClass2 { static class Nested3 extends Nested2 {
@Override @Override
public void publicTest(String test) {} public void publicTest(String test) {}
} }
static class TestClass4 extends TestVirtualMethod {} static class Nested4 extends Base {}
static class TestClass5 extends TestClass4 {} static class Nested5 extends Nested4 {}
public void testGeneral() { public void testGeneral() {
assertEquals(0, publicTestMethod.getImplementationDistance(this.getClass())); assertEquals(0, publicTestMethod.getImplementationDistance(Base.class));
assertEquals(1, publicTestMethod.getImplementationDistance(TestClass1.class)); assertEquals(1, publicTestMethod.getImplementationDistance(Nested1.class));
assertEquals(1, publicTestMethod.getImplementationDistance(TestClass2.class)); assertEquals(1, publicTestMethod.getImplementationDistance(Nested2.class));
assertEquals(3, publicTestMethod.getImplementationDistance(TestClass3.class)); assertEquals(3, publicTestMethod.getImplementationDistance(Nested3.class));
assertFalse(publicTestMethod.isOverriddenAsOf(TestClass4.class)); assertFalse(publicTestMethod.isOverriddenAsOf(Nested4.class));
assertFalse(publicTestMethod.isOverriddenAsOf(TestClass5.class)); assertFalse(publicTestMethod.isOverriddenAsOf(Nested5.class));
assertEquals(0, protectedTestMethod.getImplementationDistance(this.getClass())); assertEquals(0, protectedTestMethod.getImplementationDistance(Base.class));
assertEquals(1, protectedTestMethod.getImplementationDistance(TestClass1.class)); assertEquals(1, protectedTestMethod.getImplementationDistance(Nested1.class));
assertEquals(2, protectedTestMethod.getImplementationDistance(TestClass2.class)); assertEquals(2, protectedTestMethod.getImplementationDistance(Nested2.class));
assertEquals(2, protectedTestMethod.getImplementationDistance(TestClass3.class)); assertEquals(2, protectedTestMethod.getImplementationDistance(Nested3.class));
assertFalse(protectedTestMethod.isOverriddenAsOf(TestClass4.class)); assertFalse(protectedTestMethod.isOverriddenAsOf(Nested4.class));
assertFalse(protectedTestMethod.isOverriddenAsOf(TestClass5.class)); assertFalse(protectedTestMethod.isOverriddenAsOf(Nested5.class));
assertTrue( assertTrue(
VirtualMethod.compareImplementationDistance( VirtualMethod.compareImplementationDistance(
TestClass3.class, publicTestMethod, protectedTestMethod) Nested3.class, publicTestMethod, protectedTestMethod)
> 0); > 0);
assertEquals( assertEquals(
0, 0,
VirtualMethod.compareImplementationDistance( VirtualMethod.compareImplementationDistance(
TestClass5.class, publicTestMethod, protectedTestMethod)); Nested5.class, publicTestMethod, protectedTestMethod));
} }
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
public void testExceptions() { public void testExceptions() {
// LuceneTestCase is not a subclass and can never override publicTest(String) // Object is not a subclass and can never override publicTest(String)
expectThrows( expectThrows(
IllegalArgumentException.class, IllegalArgumentException.class,
() -> { () -> {
// cast to Class to remove generics: publicTestMethod.getImplementationDistance((Class) Object.class);
publicTestMethod.getImplementationDistance((Class) LuceneTestCase.class);
}); });
// Method bogus() does not exist, so IAE should be thrown // Method bogus() does not exist, so IAE should be thrown
expectThrows( expectThrows(
IllegalArgumentException.class, IllegalArgumentException.class,
() -> { () -> {
new VirtualMethod<>(TestVirtualMethod.class, "bogus"); new VirtualMethod<>(Base.class, "bogus");
}); });
// Method publicTest(String) is not declared in TestClass2, so IAE should be thrown // Method publicTest(String) is not declared in TestClass2, so IAE should be thrown
expectThrows( expectThrows(
IllegalArgumentException.class, IllegalArgumentException.class,
() -> { () -> {
new VirtualMethod<>(TestClass2.class, "publicTest", String.class); new VirtualMethod<>(Nested2.class, "publicTest", String.class);
}); });
// try to create a second instance of the same baseClass / method combination // try to create a second instance of the same baseClass / method combination
expectThrows( expectThrows(
UnsupportedOperationException.class, UnsupportedOperationException.class,
() -> { () -> {
new VirtualMethod<>(TestVirtualMethod.class, "publicTest", String.class); new VirtualMethod<>(Base.class, "publicTest", String.class);
}); });
} }
} }

View File

@ -47,10 +47,11 @@ import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks; import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
import org.apache.lucene.util.SuppressForbidden; import org.apache.lucene.util.SuppressForbidden;
import org.apache.lucene.util.TestUtil; import org.apache.lucene.util.TestUtil;
import org.junit.AssumptionViolatedException;
/** /**
* Child process with silly naive TCP socket server to handle between-node commands, launched for * Child process with silly naive TCP socket server to handle between-node commands, launched for
* each node by TestNRTReplication. * each node by {@link TestNRTReplication}.
*/ */
@SuppressCodecs({"MockRandom", "Direct", "SimpleText"}) @SuppressCodecs({"MockRandom", "Direct", "SimpleText"})
@SuppressSysoutChecks(bugUrl = "Stuff gets printed, important stuff for debugging a failure") @SuppressSysoutChecks(bugUrl = "Stuff gets printed, important stuff for debugging a failure")
@ -223,8 +224,12 @@ public class SimpleServer extends LuceneTestCase {
@SuppressWarnings("try") @SuppressWarnings("try")
public void test() throws Exception { public void test() throws Exception {
String nodeId = System.getProperty("tests.nrtreplication.nodeid");
if (nodeId == null) {
throw new AssumptionViolatedException("Not a stand-alone test.");
}
int id = Integer.parseInt(System.getProperty("tests.nrtreplication.nodeid")); int id = Integer.parseInt(nodeId);
Thread.currentThread().setName("main child " + id); Thread.currentThread().setName("main child " + id);
Path indexPath = Paths.get(System.getProperty("tests.nrtreplication.indexpath")); Path indexPath = Paths.get(System.getProperty("tests.nrtreplication.indexpath"));
boolean isPrimary = System.getProperty("tests.nrtreplication.isPrimary") != null; boolean isPrimary = System.getProperty("tests.nrtreplication.isPrimary") != null;

View File

@ -27,6 +27,7 @@ dependencies {
api 'io.sgr:s2-geometry-library-java' api 'io.sgr:s2-geometry-library-java'
testImplementation project(':lucene:test-framework') testImplementation project(':lucene:test-framework')
testImplementation testFixtures(project(':lucene:spatial3d'))
testImplementation 'org.locationtech.jts:jts-core' testImplementation 'org.locationtech.jts:jts-core'
testImplementation 'org.locationtech.spatial4j:spatial4j::tests' testImplementation 'org.locationtech.spatial4j:spatial4j::tests'

View File

@ -16,6 +16,7 @@
*/ */
package org.apache.lucene.spatial.spatial4j; package org.apache.lucene.spatial.spatial4j;
import static org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator.*;
import static org.locationtech.spatial4j.distance.DistanceUtils.DEGREES_TO_RADIANS; import static org.locationtech.spatial4j.distance.DistanceUtils.DEGREES_TO_RADIANS;
import java.io.IOException; import java.io.IOException;
@ -39,7 +40,6 @@ import org.apache.lucene.spatial3d.geom.GeoPoint;
import org.apache.lucene.spatial3d.geom.GeoPointShape; import org.apache.lucene.spatial3d.geom.GeoPointShape;
import org.apache.lucene.spatial3d.geom.GeoPolygonFactory; import org.apache.lucene.spatial3d.geom.GeoPolygonFactory;
import org.apache.lucene.spatial3d.geom.PlanetModel; import org.apache.lucene.spatial3d.geom.PlanetModel;
import org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator;
import org.junit.Test; import org.junit.Test;
import org.locationtech.spatial4j.shape.Rectangle; import org.locationtech.spatial4j.shape.Rectangle;
import org.locationtech.spatial4j.shape.Shape; import org.locationtech.spatial4j.shape.Shape;
@ -47,7 +47,6 @@ import org.locationtech.spatial4j.shape.Shape;
public class TestGeo3dRpt extends RandomSpatialOpStrategyTestCase { public class TestGeo3dRpt extends RandomSpatialOpStrategyTestCase {
private PlanetModel planetModel; private PlanetModel planetModel;
private RandomGeo3dShapeGenerator shapeGenerator;
private SpatialPrefixTree grid; private SpatialPrefixTree grid;
private RecursivePrefixTreeStrategy rptStrategy; private RecursivePrefixTreeStrategy rptStrategy;
@ -73,8 +72,7 @@ public class TestGeo3dRpt extends RandomSpatialOpStrategyTestCase {
} }
private void setupStrategy() { private void setupStrategy() {
shapeGenerator = new RandomGeo3dShapeGenerator(); planetModel = randomPlanetModel();
planetModel = shapeGenerator.randomPlanetModel();
Geo3dSpatialContextFactory factory = new Geo3dSpatialContextFactory(); Geo3dSpatialContextFactory factory = new Geo3dSpatialContextFactory();
factory.planetModel = planetModel; factory.planetModel = planetModel;
ctx = factory.newSpatialContext(); ctx = factory.newSpatialContext();
@ -135,8 +133,8 @@ public class TestGeo3dRpt extends RandomSpatialOpStrategyTestCase {
@Override @Override
protected Shape randomIndexedShape() { protected Shape randomIndexedShape() {
int type = shapeGenerator.randomShapeType(); int type = randomShapeType();
GeoAreaShape areaShape = shapeGenerator.randomGeoAreaShape(type, planetModel); GeoAreaShape areaShape = randomGeoAreaShape(type, planetModel);
if (areaShape instanceof GeoPointShape) { if (areaShape instanceof GeoPointShape) {
return new Geo3dPointShape((GeoPointShape) areaShape, ctx); return new Geo3dPointShape((GeoPointShape) areaShape, ctx);
} }
@ -145,8 +143,8 @@ public class TestGeo3dRpt extends RandomSpatialOpStrategyTestCase {
@Override @Override
protected Shape randomQueryShape() { protected Shape randomQueryShape() {
int type = shapeGenerator.randomShapeType(); int type = randomShapeType();
GeoAreaShape areaShape = shapeGenerator.randomGeoAreaShape(type, planetModel); GeoAreaShape areaShape = randomGeoAreaShape(type, planetModel);
return new Geo3dShape<>(areaShape, ctx); return new Geo3dShape<>(areaShape, ctx);
} }

View File

@ -16,10 +16,13 @@
*/ */
apply plugin: 'java-library' apply plugin: 'java-library'
apply plugin: 'java-test-fixtures'
description = '3D spatial planar geometry APIs' description = '3D spatial planar geometry APIs'
dependencies { dependencies {
api project(':lucene:core') api project(':lucene:core')
testFixturesApi project(':lucene:test-framework')
testImplementation project(':lucene:test-framework') testImplementation project(':lucene:test-framework')
} }

View File

@ -24,7 +24,7 @@ import org.apache.lucene.util.TestUtil;
public class TestGeo3DDocValues extends LuceneTestCase { public class TestGeo3DDocValues extends LuceneTestCase {
public void testBasic() throws Exception { public void testBasic() {
checkPointEncoding(0.0, 0.0); checkPointEncoding(0.0, 0.0);
checkPointEncoding(45.0, 72.0); checkPointEncoding(45.0, 72.0);
checkPointEncoding(-45.0, -100.0); checkPointEncoding(-45.0, -100.0);

View File

@ -17,18 +17,17 @@
package org.apache.lucene.spatial3d.geom; package org.apache.lucene.spatial3d.geom;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test; import org.junit.Test;
/** /**
* Check relationship between polygon and GeoShapes of composite polygons. Normally we construct the * Check relationship between polygon and GeoShapes of composite polygons. Normally we construct the
* composite polygon (when possible) and the complex one. * composite polygon (when possible) and the complex one.
*/ */
public class TestCompositeGeoPolygonRelationships { public class TestCompositeGeoPolygonRelationships extends LuceneTestCase {
@Test @Test
public void testGeoCompositePolygon1() { public void testGeoCompositePolygon1() {

View File

@ -16,15 +16,12 @@
*/ */
package org.apache.lucene.spatial3d.geom; package org.apache.lucene.spatial3d.geom;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test; import org.junit.Test;
public class TestGeoBBox { public class TestGeoBBox extends LuceneTestCase {
protected static final double DEGREES_TO_RADIANS = Math.PI / 180.0; protected static final double DEGREES_TO_RADIANS = Math.PI / 180.0;
@ -32,7 +29,7 @@ public class TestGeoBBox {
public void testBBoxDegenerate() { public void testBBoxDegenerate() {
GeoBBox box; GeoBBox box;
int relationship; int relationship;
List<GeoPoint> points = new ArrayList<GeoPoint>(); List<GeoPoint> points = new ArrayList<>();
points.add( points.add(
new GeoPoint(PlanetModel.SPHERE, -49 * DEGREES_TO_RADIANS, -176 * DEGREES_TO_RADIANS)); new GeoPoint(PlanetModel.SPHERE, -49 * DEGREES_TO_RADIANS, -176 * DEGREES_TO_RADIANS));
points.add( points.add(

View File

@ -16,13 +16,10 @@
*/ */
package org.apache.lucene.spatial3d.geom; package org.apache.lucene.spatial3d.geom;
import static org.junit.Assert.assertEquals; import org.apache.lucene.util.LuceneTestCase;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test; import org.junit.Test;
public class TestGeoConvexPolygon { public class TestGeoConvexPolygon extends LuceneTestCase {
@Test @Test
public void testPolygonPointWithin() { public void testPolygonPointWithin() {

View File

@ -17,11 +17,14 @@
package org.apache.lucene.spatial3d.geom; package org.apache.lucene.spatial3d.geom;
import static org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator.*;
import com.carrotsearch.randomizedtesting.annotations.Repeat; import com.carrotsearch.randomizedtesting.annotations.Repeat;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test; import org.junit.Test;
/** Tests for GeoExactCircle. */ /** Tests for GeoExactCircle. */
public class TestGeoExactCircle extends RandomGeo3dShapeGenerator { public class TestGeoExactCircle extends LuceneTestCase {
@Test @Test
public void testExactCircle() { public void testExactCircle() {
@ -78,8 +81,7 @@ public class TestGeoExactCircle extends RandomGeo3dShapeGenerator {
@Repeat(iterations = 100) @Repeat(iterations = 100)
public void RandomPointBearingWGS84Test() { public void RandomPointBearingWGS84Test() {
PlanetModel planetModel = PlanetModel.WGS84; PlanetModel planetModel = PlanetModel.WGS84;
RandomGeo3dShapeGenerator generator = new RandomGeo3dShapeGenerator(); GeoPoint center = randomGeoPoint(planetModel);
GeoPoint center = generator.randomGeoPoint(planetModel);
double radius = random().nextDouble() * Math.PI; double radius = random().nextDouble() * Math.PI;
checkBearingPoint(planetModel, center, radius, 0); checkBearingPoint(planetModel, center, radius, 0);
checkBearingPoint(planetModel, center, radius, 0.5 * Math.PI); checkBearingPoint(planetModel, center, radius, 0.5 * Math.PI);
@ -197,7 +199,8 @@ public class TestGeoExactCircle extends RandomGeo3dShapeGenerator {
@Repeat(iterations = 100) @Repeat(iterations = 100)
public void testRandomLUCENE8054() { public void testRandomLUCENE8054() {
PlanetModel planetModel = randomPlanetModel(); PlanetModel planetModel = randomPlanetModel();
GeoCircle circle1 = (GeoCircle) randomGeoAreaShape(EXACT_CIRCLE, planetModel); GeoCircle circle1 =
(GeoCircle) randomGeoAreaShape(RandomGeo3dShapeGenerator.EXACT_CIRCLE, planetModel);
// new radius, a bit smaller than the generated one! // new radius, a bit smaller than the generated one!
double radius = circle1.getRadius() * (1 - 0.01 * random().nextDouble()); double radius = circle1.getRadius() * (1 - 0.01 * random().nextDouble());
// circle with same center and new radius // circle with same center and new radius

View File

@ -16,14 +16,11 @@
*/ */
package org.apache.lucene.spatial3d.geom; package org.apache.lucene.spatial3d.geom;
import static org.junit.Assert.assertEquals; import org.apache.lucene.util.LuceneTestCase;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test; import org.junit.Test;
/** Test basic plane functionality. */ /** Test basic plane functionality. */
public class TestGeoModel { public class TestGeoModel extends LuceneTestCase {
protected static final PlanetModel scaledModel = new PlanetModel(1.2, 1.5); protected static final PlanetModel scaledModel = new PlanetModel(1.2, 1.5);

View File

@ -16,14 +16,11 @@
*/ */
package org.apache.lucene.spatial3d.geom; package org.apache.lucene.spatial3d.geom;
import static org.junit.Assert.assertEquals; import org.apache.lucene.util.LuceneTestCase;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test; import org.junit.Test;
/** Test basic plane functionality. */ /** Test basic plane functionality. */
public class TestPlane { public class TestPlane extends LuceneTestCase {
@Test @Test
public void testIdenticalPlanes() { public void testIdenticalPlanes() {

View File

@ -17,15 +17,17 @@
package org.apache.lucene.spatial3d.geom; package org.apache.lucene.spatial3d.geom;
import static org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator.*;
import com.carrotsearch.randomizedtesting.annotations.Repeat; import com.carrotsearch.randomizedtesting.annotations.Repeat;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test; import org.junit.Test;
/** Test to check Serialization */ /** Test to check Serialization */
public class TestRandomBinaryCodec extends RandomGeo3dShapeGenerator { public class TestRandomBinaryCodec extends LuceneTestCase {
@Test @Test
@Repeat(iterations = 10) @Repeat(iterations = 10)
public void testRandomPointCodec() throws IOException { public void testRandomPointCodec() throws IOException {

View File

@ -16,15 +16,17 @@
*/ */
package org.apache.lucene.spatial3d.geom; package org.apache.lucene.spatial3d.geom;
import static org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator.*;
import com.carrotsearch.randomizedtesting.generators.BiasedNumbers; import com.carrotsearch.randomizedtesting.generators.BiasedNumbers;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test; import org.junit.Test;
/** Random test for polygons. */ /** Random test for polygons. */
public class TestRandomGeoPolygon extends RandomGeo3dShapeGenerator { public class TestRandomGeoPolygon extends LuceneTestCase {
@Test @Test
public void testRandomLUCENE8157() { public void testRandomLUCENE8157() {
final PlanetModel planetModel = randomPlanetModel(); final PlanetModel planetModel = randomPlanetModel();

View File

@ -17,11 +17,13 @@
package org.apache.lucene.spatial3d.geom; package org.apache.lucene.spatial3d.geom;
import static org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator.*;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test; import org.junit.Test;
/** Random test to check relationship between GeoAreaShapes and GeoShapes. */ /** Random test to check relationship between GeoAreaShapes and GeoShapes. */
public class TestRandomGeoShapeRelationship extends RandomGeo3dShapeGenerator { public class TestRandomGeoShapeRelationship extends LuceneTestCase {
/** /**
* Test for WITHIN points. We build a WITHIN shape with respect the geoAreaShape and create a * Test for WITHIN points. We build a WITHIN shape with respect the geoAreaShape and create a
* point WITHIN the shape. The resulting shape should be WITHIN the original shape. * point WITHIN the shape. The resulting shape should be WITHIN the original shape.

View File

@ -17,13 +17,16 @@
package org.apache.lucene.spatial3d.geom; package org.apache.lucene.spatial3d.geom;
import static org.apache.lucene.spatial3d.geom.RandomGeo3dShapeGenerator.*;
import com.carrotsearch.randomizedtesting.annotations.Repeat; import com.carrotsearch.randomizedtesting.annotations.Repeat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test; import org.junit.Test;
/** Random test for planes. */ /** Random test for planes. */
public class TestRandomPlane extends RandomGeo3dShapeGenerator { public class TestRandomPlane extends LuceneTestCase {
@Test @Test
@Repeat(iterations = 10) @Repeat(iterations = 10)

View File

@ -17,19 +17,17 @@
package org.apache.lucene.spatial3d.geom; package org.apache.lucene.spatial3d.geom;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test; import org.junit.Test;
/** /**
* Check relationship between polygon and GeoShapes of basic polygons. Normally we construct the * Check relationship between polygon and GeoShapes of basic polygons. Normally we construct the
* convex, concave counterpart and the convex polygon as a complex polygon. * convex, concave counterpart and the convex polygon as a complex polygon.
*/ */
public class TestSimpleGeoPolygonRelationships { public class TestSimpleGeoPolygonRelationships extends LuceneTestCase {
/** Test with two shapes with no crossing edges and no points in common in convex case. */ /** Test with two shapes with no crossing edges and no points in common in convex case. */
@Test @Test

View File

@ -17,14 +17,14 @@
package org.apache.lucene.spatial3d.geom; package org.apache.lucene.spatial3d.geom;
import static com.carrotsearch.randomizedtesting.RandomizedTest.randomDouble; import com.carrotsearch.randomizedtesting.RandomizedContext;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.lucene.util.LuceneTestCase; import java.util.Random;
/** /**
* Class for generating random Geo3dShapes. They can be generated under given constraints which are * Class for generating random Geo3dShapes. They can be generated under given constraints which are
@ -34,7 +34,7 @@ import org.apache.lucene.util.LuceneTestCase;
* otherwise they are convex. Internally they can be created using GeoConvexPolygons and * otherwise they are convex. Internally they can be created using GeoConvexPolygons and
* GeoConcavePolygons. * GeoConcavePolygons.
*/ */
public class RandomGeo3dShapeGenerator extends LuceneTestCase { public final class RandomGeo3dShapeGenerator {
/* Max num of iterations to find right shape under given constrains */ /* Max num of iterations to find right shape under given constrains */
private static final int MAX_SHAPE_ITERATIONS = 20; private static final int MAX_SHAPE_ITERATIONS = 20;
@ -59,13 +59,21 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
protected static final int CONVEX_SIMPLE_POLYGON = 500; protected static final int CONVEX_SIMPLE_POLYGON = 500;
protected static final int CONCAVE_SIMPLE_POLYGON = 501; protected static final int CONCAVE_SIMPLE_POLYGON = 501;
/** Static methods only. */
private RandomGeo3dShapeGenerator() {}
/** @return Returns a private-use random forked from the current {@link RandomizedContext}. */
private static Random random() {
return new Random(RandomizedContext.current().getRandom().nextLong());
}
/** /**
* Method that returns a random generated Planet model from the supported Planet models. currently * Method that returns a random generated Planet model from the supported Planet models. currently
* SPHERE and WGS84 * SPHERE and WGS84
* *
* @return a random generated Planet model * @return a random generated Planet model
*/ */
public PlanetModel randomPlanetModel() { public static PlanetModel randomPlanetModel() {
final int shapeType = random().nextInt(2); final int shapeType = random().nextInt(2);
switch (shapeType) { switch (shapeType) {
case 0: case 0:
@ -86,7 +94,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* *
* @return a random generated shape code * @return a random generated shape code
*/ */
public int randomShapeType() { public static int randomShapeType() {
return random().nextInt(12); return random().nextInt(12);
} }
@ -98,7 +106,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* *
* @return a random generated polygon code * @return a random generated polygon code
*/ */
public int randomGeoAreaShapeType() { public static int randomGeoAreaShapeType() {
return random().nextInt(12); return random().nextInt(12);
} }
@ -107,7 +115,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* *
* @return a random generated convex shape code * @return a random generated convex shape code
*/ */
public int randomConvexShapeType() { public static int randomConvexShapeType() {
int shapeType = randomShapeType(); int shapeType = randomShapeType();
while (isConcave(shapeType)) { while (isConcave(shapeType)) {
shapeType = randomShapeType(); shapeType = randomShapeType();
@ -120,7 +128,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* *
* @return a random generated concave shape code * @return a random generated concave shape code
*/ */
public int randomConcaveShapeType() { public static int randomConcaveShapeType() {
int shapeType = randomShapeType(); int shapeType = randomShapeType();
while (!isConcave(shapeType)) { while (!isConcave(shapeType)) {
shapeType = randomShapeType(); shapeType = randomShapeType();
@ -133,7 +141,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* *
* @return true if the shape represented by the code is concave * @return true if the shape represented by the code is concave
*/ */
public boolean isConcave(int shapeType) { public static boolean isConcave(int shapeType) {
return (shapeType == CONCAVE_POLYGON); return (shapeType == CONCAVE_POLYGON);
} }
@ -142,7 +150,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* *
* @return an empty Constraints object * @return an empty Constraints object
*/ */
public Constraints getEmptyConstraint() { public static Constraints getEmptyConstraint() {
return new Constraints(); return new Constraints();
} }
@ -152,7 +160,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param planetModel The planet model. * @param planetModel The planet model.
* @return The random generated GeoPoint. * @return The random generated GeoPoint.
*/ */
public GeoPoint randomGeoPoint(PlanetModel planetModel) { public static GeoPoint randomGeoPoint(PlanetModel planetModel) {
GeoPoint point = null; GeoPoint point = null;
while (point == null) { while (point == null) {
point = randomGeoPoint(planetModel, getEmptyConstraint()); point = randomGeoPoint(planetModel, getEmptyConstraint());
@ -168,14 +176,14 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoPoint. * @return The random generated GeoPoint.
*/ */
public GeoPoint randomGeoPoint(PlanetModel planetModel, Constraints constraints) { public static GeoPoint randomGeoPoint(PlanetModel planetModel, Constraints constraints) {
int iterations = 0; int iterations = 0;
while (iterations < MAX_POINT_ITERATIONS) { while (iterations < MAX_POINT_ITERATIONS) {
double lat = randomDouble() * Math.PI / 2; double lat = RandomizedTest.randomDouble() * Math.PI / 2;
if (random().nextBoolean()) { if (random().nextBoolean()) {
lat = (-1) * lat; lat = (-1) * lat;
} }
double lon = randomDouble() * Math.PI; double lon = RandomizedTest.randomDouble() * Math.PI;
if (random().nextBoolean()) { if (random().nextBoolean()) {
lon = (-1) * lon; lon = (-1) * lon;
} }
@ -195,7 +203,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param planetModel The planet model. * @param planetModel The planet model.
* @return The random generated GeoAreaShape. * @return The random generated GeoAreaShape.
*/ */
public GeoAreaShape randomGeoAreaShape(int shapeType, PlanetModel planetModel) { public static GeoAreaShape randomGeoAreaShape(int shapeType, PlanetModel planetModel) {
GeoAreaShape geoAreaShape = null; GeoAreaShape geoAreaShape = null;
while (geoAreaShape == null) { while (geoAreaShape == null) {
geoAreaShape = randomGeoAreaShape(shapeType, planetModel, new Constraints()); geoAreaShape = randomGeoAreaShape(shapeType, planetModel, new Constraints());
@ -212,7 +220,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoAreaShape. * @return The random generated GeoAreaShape.
*/ */
public GeoAreaShape randomGeoAreaShape( public static GeoAreaShape randomGeoAreaShape(
int shapeType, PlanetModel planetModel, Constraints constraints) { int shapeType, PlanetModel planetModel, Constraints constraints) {
return (GeoAreaShape) randomGeoShape(shapeType, planetModel, constraints); return (GeoAreaShape) randomGeoShape(shapeType, planetModel, constraints);
} }
@ -224,7 +232,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param planetModel The planet model. * @param planetModel The planet model.
* @return The random generated GeoShape. * @return The random generated GeoShape.
*/ */
public GeoShape randomGeoShape(int shapeType, PlanetModel planetModel) { public static GeoShape randomGeoShape(int shapeType, PlanetModel planetModel) {
GeoShape geoShape = null; GeoShape geoShape = null;
while (geoShape == null) { while (geoShape == null) {
geoShape = randomGeoShape(shapeType, planetModel, new Constraints()); geoShape = randomGeoShape(shapeType, planetModel, new Constraints());
@ -241,7 +249,8 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoShape. * @return The random generated GeoShape.
*/ */
public GeoShape randomGeoShape(int shapeType, PlanetModel planetModel, Constraints constraints) { public static GeoShape randomGeoShape(
int shapeType, PlanetModel planetModel, Constraints constraints) {
switch (shapeType) { switch (shapeType) {
case CONVEX_POLYGON: case CONVEX_POLYGON:
{ {
@ -312,7 +321,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoPointShape. * @return The random generated GeoPointShape.
*/ */
private GeoPointShape point(PlanetModel planetModel, Constraints constraints) { private static GeoPointShape point(PlanetModel planetModel, Constraints constraints) {
int iterations = 0; int iterations = 0;
while (iterations < MAX_SHAPE_ITERATIONS) { while (iterations < MAX_SHAPE_ITERATIONS) {
iterations++; iterations++;
@ -344,7 +353,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoCircle. * @return The random generated GeoCircle.
*/ */
private GeoCircle circle(PlanetModel planetModel, Constraints constraints) { private static GeoCircle circle(PlanetModel planetModel, Constraints constraints) {
int iterations = 0; int iterations = 0;
while (iterations < MAX_SHAPE_ITERATIONS) { while (iterations < MAX_SHAPE_ITERATIONS) {
iterations++; iterations++;
@ -377,7 +386,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoCircle. * @return The random generated GeoCircle.
*/ */
private GeoCircle exactCircle(PlanetModel planetModel, Constraints constraints) { private static GeoCircle exactCircle(PlanetModel planetModel, Constraints constraints) {
int iterations = 0; int iterations = 0;
while (iterations < MAX_SHAPE_ITERATIONS) { while (iterations < MAX_SHAPE_ITERATIONS) {
iterations++; iterations++;
@ -411,7 +420,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoBBox. * @return The random generated GeoBBox.
*/ */
private GeoBBox rectangle(PlanetModel planetModel, Constraints constraints) { private static GeoBBox rectangle(PlanetModel planetModel, Constraints constraints) {
int iterations = 0; int iterations = 0;
while (iterations < MAX_SHAPE_ITERATIONS) { while (iterations < MAX_SHAPE_ITERATIONS) {
@ -451,7 +460,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated degenerated GeoPath. * @return The random generated degenerated GeoPath.
*/ */
private GeoPath line(PlanetModel planetModel, Constraints constraints) { private static GeoPath line(PlanetModel planetModel, Constraints constraints) {
int iterations = 0; int iterations = 0;
while (iterations < MAX_SHAPE_ITERATIONS) { while (iterations < MAX_SHAPE_ITERATIONS) {
iterations++; iterations++;
@ -483,7 +492,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoPath. * @return The random generated GeoPath.
*/ */
private GeoPath path(PlanetModel planetModel, Constraints constraints) { private static GeoPath path(PlanetModel planetModel, Constraints constraints) {
int iterations = 0; int iterations = 0;
while (iterations < MAX_SHAPE_ITERATIONS) { while (iterations < MAX_SHAPE_ITERATIONS) {
iterations++; iterations++;
@ -516,7 +525,8 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoCompositeMembershipShape. * @return The random generated GeoCompositeMembershipShape.
*/ */
private GeoCompositeAreaShape collection(PlanetModel planetModel, Constraints constraints) { private static GeoCompositeAreaShape collection(
PlanetModel planetModel, Constraints constraints) {
int iterations = 0; int iterations = 0;
while (iterations < MAX_SHAPE_ITERATIONS) { while (iterations < MAX_SHAPE_ITERATIONS) {
iterations++; iterations++;
@ -544,7 +554,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoPolygon. * @return The random generated GeoPolygon.
*/ */
private GeoPolygon convexPolygon(PlanetModel planetModel, Constraints constraints) { private static GeoPolygon convexPolygon(PlanetModel planetModel, Constraints constraints) {
int vertexCount = random().nextInt(4) + 3; int vertexCount = random().nextInt(4) + 3;
int iterations = 0; int iterations = 0;
while (iterations < MAX_SHAPE_ITERATIONS) { while (iterations < MAX_SHAPE_ITERATIONS) {
@ -575,7 +585,8 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoPolygon. * @return The random generated GeoPolygon.
*/ */
private GeoPolygon convexPolygonWithHoles(PlanetModel planetModel, Constraints constraints) { private static GeoPolygon convexPolygonWithHoles(
PlanetModel planetModel, Constraints constraints) {
int vertexCount = random().nextInt(4) + 3; int vertexCount = random().nextInt(4) + 3;
int iterations = 0; int iterations = 0;
while (iterations < MAX_SHAPE_ITERATIONS) { while (iterations < MAX_SHAPE_ITERATIONS) {
@ -633,7 +644,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param pointConstraints The given constraints that a point must comply. * @param pointConstraints The given constraints that a point must comply.
* @return The random generated GeoPolygon. * @return The random generated GeoPolygon.
*/ */
private List<GeoPolygon> concavePolygonHoles( private static List<GeoPolygon> concavePolygonHoles(
PlanetModel planetModel, PlanetModel planetModel,
GeoPolygon polygon, GeoPolygon polygon,
Constraints holeConstraints, Constraints holeConstraints,
@ -681,7 +692,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoPolygon. * @return The random generated GeoPolygon.
*/ */
private GeoPolygon concavePolygon(PlanetModel planetModel, Constraints constraints) { private static GeoPolygon concavePolygon(PlanetModel planetModel, Constraints constraints) {
int vertexCount = random().nextInt(4) + 3; int vertexCount = random().nextInt(4) + 3;
int iterations = 0; int iterations = 0;
@ -715,7 +726,8 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoPolygon. * @return The random generated GeoPolygon.
*/ */
private GeoPolygon concavePolygonWithHoles(PlanetModel planetModel, Constraints constraints) { private static GeoPolygon concavePolygonWithHoles(
PlanetModel planetModel, Constraints constraints) {
int vertexCount = random().nextInt(4) + 3; int vertexCount = random().nextInt(4) + 3;
int iterations = 0; int iterations = 0;
while (iterations < MAX_SHAPE_ITERATIONS) { while (iterations < MAX_SHAPE_ITERATIONS) {
@ -770,7 +782,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoPolygon. * @return The random generated GeoPolygon.
*/ */
private GeoPolygon complexPolygon(PlanetModel planetModel, Constraints constraints) { private static GeoPolygon complexPolygon(PlanetModel planetModel, Constraints constraints) {
int polygonsCount = random().nextInt(2) + 1; int polygonsCount = random().nextInt(2) + 1;
int iterations = 0; int iterations = 0;
while (iterations < MAX_SHAPE_ITERATIONS) { while (iterations < MAX_SHAPE_ITERATIONS) {
@ -807,7 +819,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoPolygon. * @return The random generated GeoPolygon.
*/ */
private GeoPolygon simpleConvexPolygon(PlanetModel planetModel, Constraints constraints) { private static GeoPolygon simpleConvexPolygon(PlanetModel planetModel, Constraints constraints) {
int iterations = 0; int iterations = 0;
while (iterations < MAX_SHAPE_ITERATIONS) { while (iterations < MAX_SHAPE_ITERATIONS) {
iterations++; iterations++;
@ -838,7 +850,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated GeoPolygon. * @return The random generated GeoPolygon.
*/ */
private GeoPolygon concaveSimplePolygon(PlanetModel planetModel, Constraints constraints) { private static GeoPolygon concaveSimplePolygon(PlanetModel planetModel, Constraints constraints) {
int iterations = 0; int iterations = 0;
while (iterations < MAX_SHAPE_ITERATIONS) { while (iterations < MAX_SHAPE_ITERATIONS) {
iterations++; iterations++;
@ -870,7 +882,8 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param constraints The given constraints. * @param constraints The given constraints.
* @return The random generated List of GeoPoints. * @return The random generated List of GeoPoints.
*/ */
private List<GeoPoint> points(int count, PlanetModel planetModel, Constraints constraints) { private static List<GeoPoint> points(
int count, PlanetModel planetModel, Constraints constraints) {
List<GeoPoint> geoPoints = new ArrayList<>(count); List<GeoPoint> geoPoints = new ArrayList<>(count);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
GeoPoint point = randomGeoPoint(planetModel, constraints); GeoPoint point = randomGeoPoint(planetModel, constraints);
@ -889,7 +902,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param shape The polygon to check. * @param shape The polygon to check.
* @return True if the polygon contains antipodal points. * @return True if the polygon contains antipodal points.
*/ */
private boolean isConcave(PlanetModel planetModel, GeoPolygon shape) { private static boolean isConcave(PlanetModel planetModel, GeoPolygon shape) {
return (shape.isWithin(planetModel.NORTH_POLE) && shape.isWithin(planetModel.SOUTH_POLE)) return (shape.isWithin(planetModel.NORTH_POLE) && shape.isWithin(planetModel.SOUTH_POLE))
|| (shape.isWithin(planetModel.MAX_X_POLE) && shape.isWithin(planetModel.MIN_X_POLE)) || (shape.isWithin(planetModel.MAX_X_POLE) && shape.isWithin(planetModel.MIN_X_POLE))
|| (shape.isWithin(planetModel.MAX_Y_POLE) && shape.isWithin(planetModel.MIN_Y_POLE)); || (shape.isWithin(planetModel.MAX_Y_POLE) && shape.isWithin(planetModel.MIN_Y_POLE));
@ -903,7 +916,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param shape The polygon to check. * @param shape The polygon to check.
* @return True if the polygon dies not contains antipodal points. * @return True if the polygon dies not contains antipodal points.
*/ */
private boolean isConvex(PlanetModel planetModel, GeoPolygon shape) { private static boolean isConvex(PlanetModel planetModel, GeoPolygon shape) {
return !isConcave(planetModel, shape); return !isConcave(planetModel, shape);
} }
@ -912,8 +925,8 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* *
* @return the cutoff angle. * @return the cutoff angle.
*/ */
private double randomCutoffAngle() { private static double randomCutoffAngle() {
return randomDouble() * Math.PI; return RandomizedTest.randomDouble() * Math.PI;
} }
/** /**
@ -922,7 +935,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* @param points The points to order. * @param points The points to order.
* @return The list of ordered points anti-clockwise. * @return The list of ordered points anti-clockwise.
*/ */
protected List<GeoPoint> orderPoints(List<GeoPoint> points) { protected static List<GeoPoint> orderPoints(List<GeoPoint> points) {
double x = 0; double x = 0;
double y = 0; double y = 0;
double z = 0; double z = 0;
@ -964,7 +977,7 @@ public class RandomGeo3dShapeGenerator extends LuceneTestCase {
* Class that holds the constraints that are given to build shapes. It consists in a list of * Class that holds the constraints that are given to build shapes. It consists in a list of
* GeoAreaShapes and relationships the new shape needs to satisfy. * GeoAreaShapes and relationships the new shape needs to satisfy.
*/ */
class Constraints extends HashMap<GeoAreaShape, Integer> { static class Constraints extends HashMap<GeoAreaShape, Integer> {
/** /**
* Check if the shape is valid under the constraints. * Check if the shape is valid under the constraints.

View File

@ -19,40 +19,38 @@ rootProject.name = "lucene-root"
includeBuild("dev-tools/missing-doclet") includeBuild("dev-tools/missing-doclet")
if (!(System.getProperty("skip.lucene") as Boolean)) { include "lucene:analysis:common"
include "lucene:analysis:common" include "lucene:analysis:icu"
include "lucene:analysis:icu" include "lucene:analysis:kuromoji"
include "lucene:analysis:kuromoji" include "lucene:analysis:morfologik"
include "lucene:analysis:morfologik" include "lucene:analysis:nori"
include "lucene:analysis:nori" include "lucene:analysis:opennlp"
include "lucene:analysis:opennlp" include "lucene:analysis:phonetic"
include "lucene:analysis:phonetic" include "lucene:analysis:smartcn"
include "lucene:analysis:smartcn" include "lucene:analysis:stempel"
include "lucene:analysis:stempel" include "lucene:backward-codecs"
include "lucene:backward-codecs" include "lucene:benchmark"
include "lucene:benchmark" include "lucene:classification"
include "lucene:classification" include "lucene:codecs"
include "lucene:codecs" include "lucene:core"
include "lucene:core" include "lucene:demo"
include "lucene:demo" include "lucene:expressions"
include "lucene:expressions" include "lucene:facet"
include "lucene:facet" include "lucene:grouping"
include "lucene:grouping" include "lucene:highlighter"
include "lucene:highlighter" include "lucene:join"
include "lucene:join" include "lucene:luke"
include "lucene:luke" include "lucene:memory"
include "lucene:memory" include "lucene:misc"
include "lucene:misc" include "lucene:misc:native"
include "lucene:misc:native" include "lucene:monitor"
include "lucene:monitor" include "lucene:queries"
include "lucene:queries" include "lucene:queryparser"
include "lucene:queryparser" include "lucene:replicator"
include "lucene:replicator" include "lucene:sandbox"
include "lucene:sandbox" include "lucene:spatial-extras"
include "lucene:spatial-extras" include "lucene:spatial3d"
include "lucene:spatial3d" include "lucene:suggest"
include "lucene:suggest" include "lucene:test-framework"
include "lucene:test-framework" include "lucene:documentation"
include "lucene:documentation" include "lucene:packaging"
include "lucene:packaging"
}