Skip to content

Commit 6f0d59c

Browse files
Rename BaseEngineParTest to BaseEngineTest
1 parent d5e112a commit 6f0d59c

36 files changed

+253
-197
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v5.1.5
2+
------
3+
* Rename BaseEngineParTest to BaseEngineTest
4+
15
v5.1.4
26
------
37
* Add interop between Guava's ListenableFuture and Parseq Task

subprojects/parseq-batching/src/test/java/com/linkedin/parseq/batching/TestBatchingSupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
import org.testng.annotations.Test;
99

10-
import com.linkedin.parseq.BaseEngineTest;
10+
import com.linkedin.parseq.BaseIsolatedEngineTest;
1111
import com.linkedin.parseq.EngineBuilder;
1212
import com.linkedin.parseq.Task;
1313

14-
public class TestBatchingSupport extends BaseEngineTest {
14+
public class TestBatchingSupport extends BaseIsolatedEngineTest {
1515

1616
private final BatchingSupport _batchingSupport = new BatchingSupport();
1717

subprojects/parseq-batching/src/test/java/com/linkedin/parseq/batching/TestSimpleBatchingStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
import org.testng.annotations.Test;
66

7-
import com.linkedin.parseq.BaseEngineTest;
7+
import com.linkedin.parseq.BaseIsolatedEngineTest;
88
import com.linkedin.parseq.EngineBuilder;
99
import com.linkedin.parseq.Task;
1010

11-
public class TestSimpleBatchingStrategy extends BaseEngineTest {
11+
public class TestSimpleBatchingStrategy extends BaseIsolatedEngineTest {
1212

1313
private final BatchingSupport _batchingSupport = new BatchingSupport();
1414
private final Strategy _strategy = new Strategy();

subprojects/parseq-batching/src/test/java/com/linkedin/parseq/batching/TestTaskBatchingStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
import org.testng.annotations.Test;
1111

12-
import com.linkedin.parseq.BaseEngineTest;
12+
import com.linkedin.parseq.BaseIsolatedEngineTest;
1313
import com.linkedin.parseq.EngineBuilder;
1414
import com.linkedin.parseq.Task;
1515
import com.linkedin.parseq.function.Failure;
1616
import com.linkedin.parseq.function.Success;
1717
import com.linkedin.parseq.function.Try;
1818

19-
public class TestTaskBatchingStrategy extends BaseEngineTest {
19+
public class TestTaskBatchingStrategy extends BaseIsolatedEngineTest {
2020

2121
private final BatchingSupport _batchingSupport = new BatchingSupport();
2222

subprojects/parseq-batching/src/test/java/com/linkedin/parseq/batching/TestTaskSimpleBatchingStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
import org.testng.annotations.Test;
1111

12-
import com.linkedin.parseq.BaseEngineTest;
12+
import com.linkedin.parseq.BaseIsolatedEngineTest;
1313
import com.linkedin.parseq.EngineBuilder;
1414
import com.linkedin.parseq.Task;
1515
import com.linkedin.parseq.function.Success;
1616
import com.linkedin.parseq.function.Try;
1717

18-
public class TestTaskSimpleBatchingStrategy extends BaseEngineTest {
18+
public class TestTaskSimpleBatchingStrategy extends BaseIsolatedEngineTest {
1919

2020
private final BatchingSupport _batchingSupport = new BatchingSupport();
2121
private final Strategy _strategy = new Strategy();

subprojects/parseq-batching/src/test/java/com/linkedin/parseq/batching/TestTaskSimpleBatchingStrategyBlocking.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.linkedin.parseq.batching;
22

3-
import com.linkedin.parseq.BaseEngineTest;
3+
import com.linkedin.parseq.BaseIsolatedEngineTest;
44
import com.linkedin.parseq.EngineBuilder;
55
import com.linkedin.parseq.Task;
66
import com.linkedin.parseq.function.Success;
@@ -20,7 +20,7 @@
2020
import static org.testng.AssertJUnit.*;
2121

2222

23-
public class TestTaskSimpleBatchingStrategyBlocking extends BaseEngineTest {
23+
public class TestTaskSimpleBatchingStrategyBlocking extends BaseIsolatedEngineTest {
2424

2525
private final ScheduledExecutorService _executorService = Executors.newScheduledThreadPool(10);
2626
private final BatchingSupport _batchingSupport = new BatchingSupport();

subprojects/parseq-restli-client/src/test/java/com/linkedin/restli/client/ParSeqRestClientIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
import com.linkedin.common.callback.FutureCallback;
4040
import com.linkedin.common.util.None;
41-
import com.linkedin.parseq.BaseEngineTest;
41+
import com.linkedin.parseq.BaseIsolatedEngineTest;
4242
import com.linkedin.parseq.Engine;
4343
import com.linkedin.parseq.EngineBuilder;
4444
import com.linkedin.parseq.Task;
@@ -58,7 +58,7 @@
5858
import com.linkedin.restli.examples.greetings.client.GreetingsBuilders;
5959

6060

61-
public abstract class ParSeqRestClientIntegrationTest extends BaseEngineTest {
61+
public abstract class ParSeqRestClientIntegrationTest extends BaseIsolatedEngineTest {
6262

6363
private static final AtomicInteger PORTER = new AtomicInteger(14497);
6464
private final int _port = PORTER.getAndIncrement();
Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017 LinkedIn, Inc
2+
* Copyright 2021 LinkedIn, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
55
* use this file except in compliance with the License. You may obtain a copy of
@@ -16,39 +16,11 @@
1616

1717
package com.linkedin.parseq;
1818

19-
import org.testng.annotations.AfterClass;
20-
import org.testng.annotations.BeforeClass;
21-
22-
2319
/**
24-
* A base class that builds an Engine with default configuration.
25-
* For JUnit Jupiter (JUnit5+), see {@link com.linkedin.parseq.junitjupiter.BaseEngineParJunitJupiterTest}.
26-
*
27-
* This class creates new Engine before any test method is run and shuts it down after all tests are finished.
28-
* It can be used to run tests in parallel.
29-
*
30-
* The difference between this class and {@link BaseEngineTest} is that {@code BaseEngineTest} creates new
31-
* {@code Engine} instance for every test and thus provides higher level of isolation between the tests.
32-
*
33-
* @author Jaroslaw Odzga ([email protected])
20+
* An alias for {@link BaseEngineTest}, only kept for backwards compatibility. Please use the latter.
21+
* @author Anmol Singh Jaggi ([email protected])
3422
*/
35-
public class BaseEngineParTest extends AbstractBaseEngineTest {
36-
37-
@BeforeClass
38-
public void setUpBaseEngineParTest() throws Exception {
39-
getParSeqUnitTestHelper().setUp();
40-
}
41-
42-
@AfterClass
43-
public void tearDownBaseEngineParTest() throws Exception {
44-
if (getEngine() != null) {
45-
getParSeqUnitTestHelper().tearDown();
46-
} else {
47-
throw new RuntimeException("Tried to shut down Engine but it either has not even been created or has "
48-
+ "already been shut down, in " + this.getClass().getName());
49-
}
50-
}
51-
52-
protected void customizeEngine(EngineBuilder engineBuilder) {
53-
}
23+
@Deprecated
24+
public class BaseEngineParTest extends BaseEngineTest {
25+
// Empty
5426
}
Lines changed: 18 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012 LinkedIn, Inc
2+
* Copyright 2017 LinkedIn, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
55
* use this file except in compliance with the License. You may obtain a copy of
@@ -16,98 +16,39 @@
1616

1717
package com.linkedin.parseq;
1818

19-
import org.testng.annotations.AfterMethod;
20-
import org.testng.annotations.BeforeMethod;
19+
import org.testng.annotations.AfterClass;
20+
import org.testng.annotations.BeforeClass;
2121

2222

2323
/**
2424
* A base class that builds an Engine with default configuration.
25-
* For JUnit Jupiter (JUnit5+), see {@link com.linkedin.parseq.junitjupiter.BaseEngineJUnitJupiterTest}
25+
* For JUnit Jupiter (JUnit5+), see {@link com.linkedin.parseq.junitjupiter.BaseEngineJunitJupiterTest}.
2626
*
27-
* This class creates new Engine and shuts it down before and after every test method, so it can't be used
28-
* to run tests in parallel.
27+
* This class creates new Engine before any test method is run and shuts it down after all tests are finished.
28+
* It can be used to run tests in parallel.
2929
*
30-
* The difference between this class and {@link BaseEngineParTest} is that {@code BaseEngineParTest} creates new
31-
* {@code Engine} instance only once for all tests in the class and thus can be used to run test methods in parallel.
30+
* The difference between this class and {@link BaseIsolatedEngineTest} is that the latter creates a new
31+
* {@code Engine} instance for every test and thus provides higher level of isolation between the tests.
3232
*
33-
* @author Chris Pettitt ([email protected])
3433
* @author Jaroslaw Odzga ([email protected])
35-
*
36-
* @see ParSeqUnitTestHelper
37-
* @see BaseEngineParTest
3834
*/
3935
public class BaseEngineTest extends AbstractBaseEngineTest {
4036

41-
private volatile boolean _setUpCalled = false;
42-
private volatile boolean _tearDownCalled = false;
43-
44-
@BeforeMethod
45-
public void setUpBaseEngineTest() throws Exception {
46-
if (!_setUpCalled) {
47-
_setUpCalled = true;
48-
_tearDownCalled = false;
49-
getParSeqUnitTestHelper().setUp();
50-
}
51-
}
52-
53-
/**
54-
* This method is left for backwards compatibility purpose.
55-
* It is not a good idea to have a @BeforeMethod method named
56-
* setUp because chances are that subclass will accidentally
57-
* override this method.
58-
* TODO in next major version this method should be removed
59-
* @deprecated
60-
*/
61-
@Deprecated
62-
@BeforeMethod
63-
public void setUp() throws Exception {
64-
if (!_setUpCalled) {
65-
_setUpCalled = true;
66-
_tearDownCalled = false;
67-
getParSeqUnitTestHelper().setUp();
68-
}
37+
@BeforeClass
38+
public void setUpBaseEngineParTest() throws Exception {
39+
getParSeqUnitTestHelper().setUp();
6940
}
7041

71-
/**
72-
* This method is left for backwards compatibility purpose.
73-
* It is not a good idea to have a @AfterMethod method named
74-
* tearDown because chances are that subclass will accidentally
75-
* override this method.
76-
* TODO in next major version this method should be removed
77-
* @deprecated
78-
*/
79-
@Deprecated
80-
@AfterMethod
81-
public void tearDown() throws Exception {
82-
if (!_tearDownCalled) {
83-
_setUpCalled = false;
84-
_tearDownCalled = true;
85-
if (getEngine() != null) {
86-
getParSeqUnitTestHelper().tearDown();
87-
} else {
88-
throw new RuntimeException("Tried to shut down Engine but it either has not even been created or has "
89-
+ "already been shut down. Please make sure you are not running unit tests in parallel. If you need to "
90-
+ "run unit tests in parallel, then use BaseEngineParTest instead, in " + this.getClass().getName());
91-
}
92-
}
93-
}
94-
95-
@AfterMethod
96-
public void tearDownBaseEngineTest() throws Exception {
97-
if (!_tearDownCalled) {
98-
_setUpCalled = false;
99-
_tearDownCalled = true;
100-
if (getEngine() != null) {
101-
getParSeqUnitTestHelper().tearDown();
102-
} else {
103-
throw new RuntimeException("Tried to shut down Engine but it either has not even been created or has "
104-
+ "already been shut down. Please make sure you are not running unit tests in parallel. If you need to "
105-
+ "run unit tests in parallel, then use BaseEngineParTest instead, in " + this.getClass().getName());
106-
}
42+
@AfterClass
43+
public void tearDownBaseEngineParTest() throws Exception {
44+
if (getEngine() != null) {
45+
getParSeqUnitTestHelper().tearDown();
46+
} else {
47+
throw new RuntimeException("Tried to shut down Engine but it either has not even been created or has "
48+
+ "already been shut down, in " + this.getClass().getName());
10749
}
10850
}
10951

11052
protected void customizeEngine(EngineBuilder engineBuilder) {
11153
}
112-
11354
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
* Copyright 2012 LinkedIn, Inc
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* 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, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
17+
package com.linkedin.parseq;
18+
19+
import com.linkedin.parseq.junitjupiter.BaseIsolatedEngineJUnitJupiterTest;
20+
import org.testng.annotations.AfterMethod;
21+
import org.testng.annotations.BeforeMethod;
22+
23+
24+
/**
25+
* A base class that builds an Engine with default configuration.
26+
* For JUnit Jupiter (JUnit5+), see {@link BaseIsolatedEngineJUnitJupiterTest}
27+
*
28+
* This class creates a new Engine and shuts it down before and after every test method, so it can't be used
29+
* to run tests in parallel.
30+
*
31+
* The difference between this class and {@link BaseEngineTest} is that the latter creates a new
32+
* {@code Engine} instance only once for all tests in the class and thus can be used to run test methods in parallel.
33+
*
34+
* @author Chris Pettitt ([email protected])
35+
* @author Jaroslaw Odzga ([email protected])
36+
*
37+
* @see ParSeqUnitTestHelper
38+
* @see BaseEngineTest
39+
*/
40+
public class BaseIsolatedEngineTest extends AbstractBaseEngineTest {
41+
42+
private volatile boolean _setUpCalled = false;
43+
private volatile boolean _tearDownCalled = false;
44+
45+
@BeforeMethod
46+
public void setUpBaseEngineTest() throws Exception {
47+
if (!_setUpCalled) {
48+
_setUpCalled = true;
49+
_tearDownCalled = false;
50+
getParSeqUnitTestHelper().setUp();
51+
}
52+
}
53+
54+
/**
55+
* This method is left for backwards compatibility purpose.
56+
* It is not a good idea to have a @BeforeMethod method named
57+
* setUp because chances are that subclass will accidentally
58+
* override this method.
59+
* TODO in next major version this method should be removed
60+
* @deprecated
61+
*/
62+
@Deprecated
63+
@BeforeMethod
64+
public void setUp() throws Exception {
65+
if (!_setUpCalled) {
66+
_setUpCalled = true;
67+
_tearDownCalled = false;
68+
getParSeqUnitTestHelper().setUp();
69+
}
70+
}
71+
72+
/**
73+
* This method is left for backwards compatibility purpose.
74+
* It is not a good idea to have a @AfterMethod method named
75+
* tearDown because chances are that subclass will accidentally
76+
* override this method.
77+
* TODO in next major version this method should be removed
78+
* @deprecated
79+
*/
80+
@Deprecated
81+
@AfterMethod
82+
public void tearDown() throws Exception {
83+
if (!_tearDownCalled) {
84+
_setUpCalled = false;
85+
_tearDownCalled = true;
86+
if (getEngine() != null) {
87+
getParSeqUnitTestHelper().tearDown();
88+
} else {
89+
throw new RuntimeException("Tried to shut down Engine but it either has not even been created or has "
90+
+ "already been shut down. Please make sure you are not running unit tests in parallel. If you need to "
91+
+ "run unit tests in parallel, then use BaseEngineParTest instead, in " + this.getClass().getName());
92+
}
93+
}
94+
}
95+
96+
@AfterMethod
97+
public void tearDownBaseEngineTest() throws Exception {
98+
if (!_tearDownCalled) {
99+
_setUpCalled = false;
100+
_tearDownCalled = true;
101+
if (getEngine() != null) {
102+
getParSeqUnitTestHelper().tearDown();
103+
} else {
104+
throw new RuntimeException("Tried to shut down Engine but it either has not even been created or has "
105+
+ "already been shut down. Please make sure you are not running unit tests in parallel. If you need to "
106+
+ "run unit tests in parallel, then use BaseEngineParTest instead, in " + this.getClass().getName());
107+
}
108+
}
109+
}
110+
111+
protected void customizeEngine(EngineBuilder engineBuilder) {
112+
}
113+
114+
}

0 commit comments

Comments
 (0)