mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 08:27:14 +02:00
Restore global config after tests
Fix a couple more cases when caching related configs are changed. This does not fix all our problems with Gradle builds. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=228735790
This commit is contained in:
parent
4866955c76
commit
f94090c415
4 changed files with 50 additions and 24 deletions
|
@ -391,9 +391,14 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
|
||||
@Test
|
||||
public void testSuccess_cachingDisabled() throws Exception {
|
||||
boolean origIsCachingEnabled = RegistryConfig.isEppResourceCachingEnabled();
|
||||
try {
|
||||
RegistryConfig.overrideIsEppResourceCachingEnabledForTesting(false);
|
||||
persistContactsAndHosts();
|
||||
doSuccessfulTest();
|
||||
} finally {
|
||||
RegistryConfig.overrideIsEppResourceCachingEnabledForTesting(origIsCachingEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -194,10 +194,15 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
|
||||
@Test
|
||||
public void testSuccess_cachingDisabled() throws Exception {
|
||||
boolean origIsCachingEnabled = RegistryConfig.isEppResourceCachingEnabled();
|
||||
try {
|
||||
RegistryConfig.overrideIsEppResourceCachingEnabledForTesting(false);
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
doSuccessfulTest();
|
||||
} finally {
|
||||
RegistryConfig.overrideIsEppResourceCachingEnabledForTesting(origIsCachingEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package google.registry.model.registrar;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
@ -454,6 +455,11 @@ public class RegistrarTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testSuccess_setAllowedTldsUncached_newTldNotInCache() {
|
||||
int origSingletonCacheRefreshSeconds =
|
||||
RegistryConfig.CONFIG_SETTINGS.get().caching.singletonCacheRefreshSeconds;
|
||||
// Sanity check for Gradle-based open-source build.
|
||||
checkState(
|
||||
origSingletonCacheRefreshSeconds == 0, "singletonCacheRefreshSeconds expected to be 0.");
|
||||
try {
|
||||
// Cache duration in tests is 0. To make sure the data isn't in the cache we have to set it
|
||||
// to a higher value and reset the cache.
|
||||
|
@ -490,8 +496,8 @@ public class RegistrarTest extends EntityTestCase {
|
|||
// TLDs
|
||||
assertThat(Registries.getTlds()).doesNotContain("newtld");
|
||||
} finally {
|
||||
// Set the cache duration back to 0 to satisfy other tests.
|
||||
RegistryConfig.CONFIG_SETTINGS.get().caching.singletonCacheRefreshSeconds = 0;
|
||||
RegistryConfig.CONFIG_SETTINGS.get().caching.singletonCacheRefreshSeconds =
|
||||
origSingletonCacheRefreshSeconds;
|
||||
Registries.resetCache();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,19 +49,26 @@ public class RequestFactoryModuleTest {
|
|||
@Test
|
||||
public void test_provideHttpRequestFactory_localhost() throws Exception {
|
||||
// Make sure that localhost creates a request factory with an initializer.
|
||||
boolean origIsLocal = RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal;
|
||||
RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal = true;
|
||||
try {
|
||||
HttpRequestFactory factory = RequestFactoryModule.provideHttpRequestFactory(googleCredential);
|
||||
HttpRequestInitializer initializer = factory.getInitializer();
|
||||
assertThat(initializer).isNotNull();
|
||||
HttpRequest request = factory.buildGetRequest(new GenericUrl("http://localhost"));
|
||||
initializer.initialize(request);
|
||||
verifyZeroInteractions(googleCredential);
|
||||
} finally {
|
||||
RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal = origIsLocal;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_provideHttpRequestFactory_remote() throws Exception {
|
||||
// Make sure that example.com creates a request factory with the UNITTEST client id but no
|
||||
boolean origIsLocal = RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal;
|
||||
RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal = false;
|
||||
try {
|
||||
HttpRequestFactory factory = RequestFactoryModule.provideHttpRequestFactory(googleCredential);
|
||||
HttpRequestInitializer initializer = factory.getInitializer();
|
||||
assertThat(initializer).isNotNull();
|
||||
|
@ -71,5 +78,8 @@ public class RequestFactoryModuleTest {
|
|||
assertThat(request.getConnectTimeout()).isEqualTo(REQUEST_TIMEOUT_MS);
|
||||
assertThat(request.getReadTimeout()).isEqualTo(REQUEST_TIMEOUT_MS);
|
||||
verifyNoMoreInteractions(googleCredential);
|
||||
} finally {
|
||||
RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal = origIsLocal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue