diff --git a/build.gradle b/build.gradle
index cfd865324c2..a288e0d6c6b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -109,12 +109,9 @@ ext {
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
// (java, tests)
+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/randomization.gradle')
diff --git a/gradle/ant-compat/misc.gradle b/gradle/ant-compat/misc.gradle
index d50a80baa0e..baefa2b16b4 100644
--- a/gradle/ant-compat/misc.gradle
+++ b/gradle/ant-compat/misc.gradle
@@ -15,16 +15,6 @@
* limitations under the License.
*/
-// 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) {
diff --git a/gradle/ant-compat/folder-layout.gradle b/gradle/java/folder-layout.gradle
similarity index 94%
rename from gradle/ant-compat/folder-layout.gradle
rename to gradle/java/folder-layout.gradle
index c86f68b7eee..11133aa9cee 100644
--- a/gradle/ant-compat/folder-layout.gradle
+++ b/gradle/java/folder-layout.gradle
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-// Adapt to custom folder convention.
+// Adapt to custom, legacy folder convention.
allprojects {
plugins.withType(JavaPlugin) {
sourceSets {
@@ -32,11 +32,7 @@ allprojects {
into sourceSets.test.java.outputDir
}
processTestResources.dependsOn copyTestResources
- }
-}
-allprojects {
- plugins.withType(JavaPlugin) {
// if 'src/tools' exists, add it as a separate sourceSet.
if (file('src/tools/java').exists()) {
sourceSets {
diff --git a/lucene/core/src/test/org/apache/lucene/util/TestVirtualMethod.java b/lucene/core/src/test/org/apache/lucene/util/TestVirtualMethod.java
index 3d3c270d736..45e706efcdd 100644
--- a/lucene/core/src/test/org/apache/lucene/util/TestVirtualMethod.java
+++ b/lucene/core/src/test/org/apache/lucene/util/TestVirtualMethod.java
@@ -17,17 +17,18 @@
package org.apache.lucene.util;
public class TestVirtualMethod extends LuceneTestCase {
+ private static final VirtualMethod publicTestMethod =
+ new VirtualMethod<>(Base.class, "publicTest", String.class);
+ private static final VirtualMethod protectedTestMethod =
+ new VirtualMethod<>(Base.class, "protectedTest", int.class);
- private static final VirtualMethod publicTestMethod =
- new VirtualMethod<>(TestVirtualMethod.class, "publicTest", String.class);
- private static final VirtualMethod protectedTestMethod =
- new VirtualMethod<>(TestVirtualMethod.class, "protectedTest", int.class);
+ static class Base {
+ public void publicTest(String test) {}
- public void publicTest(String test) {}
+ protected void protectedTest(int test) {}
+ }
- protected void protectedTest(int test) {}
-
- static class TestClass1 extends TestVirtualMethod {
+ static class Nested1 extends Base {
@Override
public void publicTest(String test) {}
@@ -35,74 +36,73 @@ public class TestVirtualMethod extends LuceneTestCase {
protected void protectedTest(int test) {}
}
- static class TestClass2 extends TestClass1 {
+ static class Nested2 extends Nested1 {
@Override // make it public here
public void protectedTest(int test) {}
}
- static class TestClass3 extends TestClass2 {
+ static class Nested3 extends Nested2 {
@Override
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() {
- assertEquals(0, publicTestMethod.getImplementationDistance(this.getClass()));
- assertEquals(1, publicTestMethod.getImplementationDistance(TestClass1.class));
- assertEquals(1, publicTestMethod.getImplementationDistance(TestClass2.class));
- assertEquals(3, publicTestMethod.getImplementationDistance(TestClass3.class));
- assertFalse(publicTestMethod.isOverriddenAsOf(TestClass4.class));
- assertFalse(publicTestMethod.isOverriddenAsOf(TestClass5.class));
+ assertEquals(0, publicTestMethod.getImplementationDistance(Base.class));
+ assertEquals(1, publicTestMethod.getImplementationDistance(Nested1.class));
+ assertEquals(1, publicTestMethod.getImplementationDistance(Nested2.class));
+ assertEquals(3, publicTestMethod.getImplementationDistance(Nested3.class));
+ assertFalse(publicTestMethod.isOverriddenAsOf(Nested4.class));
+ assertFalse(publicTestMethod.isOverriddenAsOf(Nested5.class));
- assertEquals(0, protectedTestMethod.getImplementationDistance(this.getClass()));
- assertEquals(1, protectedTestMethod.getImplementationDistance(TestClass1.class));
- assertEquals(2, protectedTestMethod.getImplementationDistance(TestClass2.class));
- assertEquals(2, protectedTestMethod.getImplementationDistance(TestClass3.class));
- assertFalse(protectedTestMethod.isOverriddenAsOf(TestClass4.class));
- assertFalse(protectedTestMethod.isOverriddenAsOf(TestClass5.class));
+ assertEquals(0, protectedTestMethod.getImplementationDistance(Base.class));
+ assertEquals(1, protectedTestMethod.getImplementationDistance(Nested1.class));
+ assertEquals(2, protectedTestMethod.getImplementationDistance(Nested2.class));
+ assertEquals(2, protectedTestMethod.getImplementationDistance(Nested3.class));
+ assertFalse(protectedTestMethod.isOverriddenAsOf(Nested4.class));
+ assertFalse(protectedTestMethod.isOverriddenAsOf(Nested5.class));
assertTrue(
VirtualMethod.compareImplementationDistance(
- TestClass3.class, publicTestMethod, protectedTestMethod)
+ Nested3.class, publicTestMethod, protectedTestMethod)
> 0);
assertEquals(
0,
VirtualMethod.compareImplementationDistance(
- TestClass5.class, publicTestMethod, protectedTestMethod));
+ Nested5.class, publicTestMethod, protectedTestMethod));
}
@SuppressWarnings({"rawtypes", "unchecked"})
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(
IllegalArgumentException.class,
() -> {
- // cast to Class to remove generics:
- publicTestMethod.getImplementationDistance((Class) LuceneTestCase.class);
+ publicTestMethod.getImplementationDistance((Class) Object.class);
});
// Method bogus() does not exist, so IAE should be thrown
expectThrows(
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
expectThrows(
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
expectThrows(
UnsupportedOperationException.class,
() -> {
- new VirtualMethod<>(TestVirtualMethod.class, "publicTest", String.class);
+ new VirtualMethod<>(Base.class, "publicTest", String.class);
});
}
}
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimpleServer.java b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimpleServer.java
index 4d91dfc8957..d5f51d78f24 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimpleServer.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimpleServer.java
@@ -47,10 +47,11 @@ import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
import org.apache.lucene.util.SuppressForbidden;
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
- * each node by TestNRTReplication.
+ * each node by {@link TestNRTReplication}.
*/
@SuppressCodecs({"MockRandom", "Direct", "SimpleText"})
@SuppressSysoutChecks(bugUrl = "Stuff gets printed, important stuff for debugging a failure")
@@ -223,8 +224,12 @@ public class SimpleServer extends LuceneTestCase {
@SuppressWarnings("try")
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);
Path indexPath = Paths.get(System.getProperty("tests.nrtreplication.indexpath"));
boolean isPrimary = System.getProperty("tests.nrtreplication.isPrimary") != null;