NamingConventionTests should test subclasses of ESIntegTestCase end with IT

These are integration tests.
This commit is contained in:
Robert Muir 2015-08-03 21:34:53 -04:00
parent 9091f46602
commit d7cf5cd6af
4 changed files with 14 additions and 4 deletions

View File

@ -26,6 +26,7 @@ import junit.framework.TestCase;
import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.io.PathUtils; import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.ESTokenStreamTestCase; import org.elasticsearch.test.ESTokenStreamTestCase;
import org.junit.Ignore; import org.junit.Ignore;
@ -51,6 +52,7 @@ public class NamingConventionTests extends ESTestCase {
final Set<Class> notImplementing = new HashSet<>(); final Set<Class> notImplementing = new HashSet<>();
final Set<Class> pureUnitTest = new HashSet<>(); final Set<Class> pureUnitTest = new HashSet<>();
final Set<Class> missingSuffix = new HashSet<>(); final Set<Class> missingSuffix = new HashSet<>();
final Set<Class> integTestsInDisguise = new HashSet<>();
String[] packages = {"org.elasticsearch", "org.apache.lucene"}; String[] packages = {"org.elasticsearch", "org.apache.lucene"};
for (final String packageName : packages) { for (final String packageName : packages) {
final String path = "/" + packageName.replace('.', '/'); final String path = "/" + packageName.replace('.', '/');
@ -76,12 +78,19 @@ public class NamingConventionTests extends ESTestCase {
Class<?> clazz = loadClass(filename); Class<?> clazz = loadClass(filename);
if (Modifier.isAbstract(clazz.getModifiers()) == false && Modifier.isInterface(clazz.getModifiers()) == false) { if (Modifier.isAbstract(clazz.getModifiers()) == false && Modifier.isInterface(clazz.getModifiers()) == false) {
if (clazz.getName().endsWith("Tests") || if (clazz.getName().endsWith("Tests") ||
clazz.getName().endsWith("IT") ||
clazz.getName().endsWith("Test")) { // don't worry about the ones that match the pattern clazz.getName().endsWith("Test")) { // don't worry about the ones that match the pattern
if (ESIntegTestCase.class.isAssignableFrom(clazz)) {
integTestsInDisguise.add(clazz);
}
if (isTestCase(clazz) == false) { if (isTestCase(clazz) == false) {
notImplementing.add(clazz); notImplementing.add(clazz);
} }
} else if (clazz.getName().endsWith("IT")) {
if (isTestCase(clazz) == false) {
notImplementing.add(clazz);
}
// otherwise fine
} else if (isTestCase(clazz)) { } else if (isTestCase(clazz)) {
missingSuffix.add(clazz); missingSuffix.add(clazz);
} else if (junit.framework.Test.class.isAssignableFrom(clazz) || hasTestAnnotation(clazz)) { } else if (junit.framework.Test.class.isAssignableFrom(clazz) || hasTestAnnotation(clazz)) {
@ -151,6 +160,7 @@ public class NamingConventionTests extends ESTestCase {
pureUnitTest.isEmpty()); pureUnitTest.isEmpty());
assertTrue("Classes ending with Test|Tests] must subclass [" + classesToSubclass +"] " + notImplementing.toString(), assertTrue("Classes ending with Test|Tests] must subclass [" + classesToSubclass +"] " + notImplementing.toString(),
notImplementing.isEmpty()); notImplementing.isEmpty());
assertTrue("Subclasses of ESIntegTestCase should end with IT as they are integration tests: " + integTestsInDisguise, integTestsInDisguise.isEmpty());
} }
/* /*

View File

@ -36,7 +36,7 @@ import static org.hamcrest.Matchers.*;
* *
*/ */
@ClusterScope(scope= Scope.TEST, numDataNodes =0) @ClusterScope(scope= Scope.TEST, numDataNodes =0)
public class SimpleNodesInfoTests extends PluginTestCase { public class SimpleNodesInfoIT extends PluginTestCase {
static final class Fields { static final class Fields {
static final String SITE_PLUGIN = "dummy"; static final String SITE_PLUGIN = "dummy";

View File

@ -49,7 +49,7 @@ import java.util.concurrent.*;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.greaterThan;
public class BlobStoreFormatTests extends AbstractSnapshotIntegTestCase { public class BlobStoreFormatIT extends AbstractSnapshotIntegTestCase {
private static final ParseFieldMatcher parseFieldMatcher = new ParseFieldMatcher(Settings.EMPTY); private static final ParseFieldMatcher parseFieldMatcher = new ParseFieldMatcher(Settings.EMPTY);

View File

@ -48,7 +48,7 @@ import static org.hamcrest.Matchers.notNullValue;
/** /**
*/ */
@ESIntegTestCase.ClusterScope(minNumDataNodes = 2) @ESIntegTestCase.ClusterScope(minNumDataNodes = 2)
public class RepositoriesTests extends AbstractSnapshotIntegTestCase { public class RepositoriesIT extends AbstractSnapshotIntegTestCase {
@Test @Test
public void testRepositoryCreation() throws Exception { public void testRepositoryCreation() throws Exception {