mirror of
https://github.com/google/nomulus
synced 2026-09-21 07:24:26 +00:00
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:
@@ -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;
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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 {@link AlreadyLoggedInException}
|
* @error {@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>
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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. */
|
||||||
|
|||||||
@@ -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
Reference in New Issue
Block a user