Skip to content

Commit 4a488d7

Browse files
authored
chore: Add junit timeout rule to unittests folder (GoogleCloudPlatform#5587)
May help fix GoogleCloudPlatform#5575, or at least hopefully narrow down which test is causing the issue.
1 parent f6a82ee commit 4a488d7

12 files changed

+36
-11
lines changed

unittests/src/test/java/com/google/appengine/samples/AuthenticationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.junit.Before;
2929
import org.junit.Test;
3030

31-
public class AuthenticationTest {
31+
public class AuthenticationTest extends BaseTestConfiguration {
3232

3333
private final LocalServiceTestHelper helper =
3434
new LocalServiceTestHelper(new LocalUserServiceTestConfig())
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.appengine.samples;
18+
19+
import java.util.concurrent.TimeUnit;
20+
import org.junit.Rule;
21+
import org.junit.rules.Timeout;
22+
23+
public abstract class BaseTestConfiguration {
24+
@Rule public Timeout testTimeout = new Timeout(5, TimeUnit.MINUTES);
25+
}

unittests/src/test/java/com/google/appengine/samples/DeferredTaskTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.junit.Before;
3131
import org.junit.Test;
3232

33-
public class DeferredTaskTest {
33+
public class DeferredTaskTest extends BaseTestConfiguration {
3434

3535
// Unlike CountDownLatch, TaskCountDownlatch lets us reset.
3636
private final LocalTaskQueueTestConfig.TaskCountDownLatch latch =

unittests/src/test/java/com/google/appengine/samples/LocalCustomPolicyHighRepDatastoreTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.junit.Before;
3434
import org.junit.Test;
3535

36-
public class LocalCustomPolicyHighRepDatastoreTest {
36+
public class LocalCustomPolicyHighRepDatastoreTest extends BaseTestConfiguration {
3737
private static final class CustomHighRepJobPolicy implements HighRepJobPolicy {
3838
static int newJobCounter = 0;
3939
static int existingJobCounter = 0;

unittests/src/test/java/com/google/appengine/samples/LocalDatastoreTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.junit.Before;
3232
import org.junit.Test;
3333

34-
public class LocalDatastoreTest {
34+
public class LocalDatastoreTest extends BaseTestConfiguration {
3535

3636
private final LocalServiceTestHelper helper =
3737
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());

unittests/src/test/java/com/google/appengine/samples/LocalHighRepDatastoreTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.junit.Before;
3434
import org.junit.Test;
3535

36-
public class LocalHighRepDatastoreTest {
36+
public class LocalHighRepDatastoreTest extends BaseTestConfiguration {
3737

3838
// Maximum eventual consistency.
3939
private final LocalServiceTestHelper helper =

unittests/src/test/java/com/google/appengine/samples/LocalMemcacheTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// [END imports]
3232

3333
// [START NameAndHelper]
34-
public class LocalMemcacheTest {
34+
public class LocalMemcacheTest extends BaseTestConfiguration {
3535

3636
private final LocalServiceTestHelper helper =
3737
new LocalServiceTestHelper(new LocalMemcacheServiceTestConfig());

unittests/src/test/java/com/google/appengine/samples/LocalUrlFetchTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.junit.Before;
3434
import org.junit.Test;
3535

36-
public class LocalUrlFetchTest {
36+
public class LocalUrlFetchTest extends BaseTestConfiguration {
3737
private final LocalServiceTestHelper helper =
3838
new LocalServiceTestHelper(new LocalURLFetchServiceTestConfig());
3939

unittests/src/test/java/com/google/appengine/samples/MyFirstTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import org.junit.Test;
2424

25-
public class MyFirstTest {
25+
public class MyFirstTest extends BaseTestConfiguration {
2626
@Test
2727
public void testAddition() {
2828
assertEquals(4, 2 + 2);

unittests/src/test/java/com/google/appengine/samples/ShortTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import org.junit.After;
3333
import org.junit.Test;
3434

35-
public class ShortTest {
35+
public class ShortTest extends BaseTestConfiguration {
3636
private LocalServiceTestHelper helper;
3737

3838
@After

0 commit comments

Comments
 (0)