Move test resource files into src/test/resources (#143)

* Move test resource files into src/test/resources

* fix a test

* Remove references to javatests/ in Java files

* fix import order

* fix semantic merge conflict
This commit is contained in:
gbrodman 2019-07-02 16:54:49 -04:00 committed by GitHub
parent 32d5940be3
commit cf507dad6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
991 changed files with 23 additions and 22 deletions

View file

@ -24,8 +24,8 @@ import google.registry.config.CredentialModule.DefaultCredential;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.BadRequestException;
import google.registry.request.Parameter; import google.registry.request.Parameter;
import google.registry.util.GoogleCredentialsBundle;
import google.registry.util.Clock; import google.registry.util.Clock;
import google.registry.util.GoogleCredentialsBundle;
import java.util.Optional; import java.util.Optional;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.joda.time.DateTimeZone; import org.joda.time.DateTimeZone;

View file

@ -96,7 +96,7 @@ public class FlowContext {
} }
/** /**
* Helper to locate test files for this flow by looking in javatests/ for all files with the * Helper to locate test files for this flow by looking in src/test/java/ for all files with the
* exact same relative filename as the flow file, but with a "*Test{,Case}.java" suffix. * exact same relative filename as the flow file, but with a "*Test{,Case}.java" suffix.
*/ */
private static Set<String> getTestFilenames(String flowName) throws IOException { private static Set<String> getTestFilenames(String flowName) throws IOException {

View file

@ -35,10 +35,10 @@ import org.junit.runners.JUnit4;
* condition. For example, there should always be a matching pair of lines such as the following: * condition. For example, there should always be a matching pair of lines such as the following:
* *
* <pre> * <pre>
* java/.../flows/session/LoginFlow.java: * src/main/java/.../flows/session/LoginFlow.java:
* @error {&#64;link AlreadyLoggedInException} * @error {&#64;link AlreadyLoggedInException}
* *
* javatests/.../flows/session/LoginFlowTest.java: * src/test/java/.../flows/session/LoginFlowTest.java:
* import .....flows.session.LoginFlow.AlreadyLoggedInException; * import .....flows.session.LoginFlow.AlreadyLoggedInException;
* </pre> * </pre>
* *

View file

@ -38,7 +38,7 @@ import org.bouncycastle.openpgp.PGPUtil;
import org.bouncycastle.openpgp.bc.BcPGPPublicKeyRingCollection; import org.bouncycastle.openpgp.bc.BcPGPPublicKeyRingCollection;
import org.bouncycastle.openpgp.bc.BcPGPSecretKeyRingCollection; import org.bouncycastle.openpgp.bc.BcPGPSecretKeyRingCollection;
/** Keyring factory that loads keys from {@code javatests/.../testing/testdata} */ /** Keyring factory that loads keys from {@code src/test/java/.../testing} */
@Module @Module
@Immutable @Immutable
public final class FakeKeyringModule { public final class FakeKeyringModule {

View file

@ -79,7 +79,7 @@ public final class TestDataHelper {
public static String loadFile(Class<?> context, String filename) { public static String loadFile(Class<?> context, String filename) {
return fileCache.computeIfAbsent( return fileCache.computeIfAbsent(
FileKey.create(context, filename), FileKey.create(context, filename),
k -> readResourceUtf8(context, "testdata/" + filename)); k -> readResourceUtf8(context, filename));
} }
/** /**
@ -102,15 +102,16 @@ public final class TestDataHelper {
public static ByteSource loadBytes(Class<?> context, String filename) { public static ByteSource loadBytes(Class<?> context, String filename) {
return byteCache.computeIfAbsent( return byteCache.computeIfAbsent(
FileKey.create(context, filename), FileKey.create(context, filename),
k -> readResourceBytes(context, "testdata/" + filename)); k -> readResourceBytes(context, filename));
} }
/** /**
* Returns the "real" location of the file loaded by the other commands, starting from javatests/. * Returns the "real" location of the file loaded by the other commands, starting from
* src/test/resources/.
*/ */
public static String filePath(Class<?> context, String filename) { public static String filePath(Class<?> context, String filename) {
String packagePath = context.getPackage().getName().replace('.', '/'); String packagePath = context.getPackage().getName().replace('.', '/');
return String.format("javatests/%s/testdata/%s", packagePath, filename); return String.format("src/test/resources/%s/%s", packagePath, filename);
} }
/** Returns a recursive iterable of all files in the given directory. */ /** Returns a recursive iterable of all files in the given directory. */

View file

@ -47,7 +47,7 @@ public class TmchTestDataExpirationTest {
new TmchXmlSignature( new TmchXmlSignature(
new TmchCertificateAuthority(TmchCaMode.PILOT, new SystemClock()))); new TmchCertificateAuthority(TmchCaMode.PILOT, new SystemClock())));
for (Path path : listFiles(TmchTestDataExpirationTest.class, "testdata/active/")) { for (Path path : listFiles(TmchTestDataExpirationTest.class, "active/")) {
if (path.toString().endsWith(".smd")) { if (path.toString().endsWith(".smd")) {
logger.atInfo().log("Verifying: %s", path); logger.atInfo().log("Verifying: %s", path);
String tmchData = ResourceUtils.readResourceUtf8(path.toUri().toURL()); String tmchData = ResourceUtils.readResourceUtf8(path.toUri().toURL());

Some files were not shown because too many files have changed in this diff Show more