Skip to content

Commit 2cbafed

Browse files
Rename BaseEngineParTest to BaseEngineTest
1 parent d5e112a commit 2cbafed

File tree

9 files changed

+313
-152
lines changed

9 files changed

+313
-152
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
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 (jodzga@linkedin.com)
20+
* An alias for {@link BaseEngineTest}, only kept for backwards compatibility. Please use the latter.
21+
* @author Anmol Singh Jaggi (ajaggi@linkedin.com)
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: 22 additions & 79 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,41 @@
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 (cpettitt@linkedin.com)
3433
* @author Jaroslaw Odzga (jodzga@linkedin.com)
35-
*
36-
* @see ParSeqUnitTestHelper
37-
* @see BaseEngineParTest
3834
*/
39-
public class BaseEngineTest extends AbstractBaseEngineTest {
40-
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-
}
35+
public class BaseEngineTest extends OldBaseEngineTest {
36+
37+
@BeforeClass
38+
public void setUpBaseEngineParTest() throws Exception {
39+
getParSeqUnitTestHelper().setUp();
5140
}
5241

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-
}
69-
}
70-
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

52+
@Override
11053
protected void customizeEngine(EngineBuilder engineBuilder) {
54+
11155
}
112-
11356
}
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 (cpettitt@linkedin.com)
35+
* @author Jaroslaw Odzga (jodzga@linkedin.com)
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 BaseEngineTest 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 BaseEngineTest instead, in " + this.getClass().getName());
107+
}
108+
}
109+
}
110+
111+
protected void customizeEngine(EngineBuilder engineBuilder) {
112+
}
113+
114+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright 2021 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 org.testng.annotations.AfterMethod;
20+
import org.testng.annotations.BeforeMethod;
21+
22+
23+
abstract class OldBaseEngineTest extends AbstractBaseEngineTest {
24+
25+
/**
26+
* This method is left for backwards compatibility purpose.
27+
* TODO in next major version this method should be removed
28+
* @deprecated
29+
*/
30+
@Deprecated
31+
@BeforeMethod
32+
public void setUpBaseEngineTest() throws Exception {
33+
}
34+
35+
/**
36+
* This method is left for backwards compatibility purpose.
37+
* TODO in next major version this method should be removed
38+
* @deprecated
39+
*/
40+
@Deprecated
41+
@BeforeMethod
42+
public void setUp() throws Exception {
43+
}
44+
45+
/**
46+
* This method is left for backwards compatibility purpose.
47+
* TODO in next major version this method should be removed
48+
* @deprecated
49+
*/
50+
@Deprecated
51+
@AfterMethod
52+
public void tearDown() throws Exception {
53+
}
54+
55+
/**
56+
* This method is left for backwards compatibility purpose.
57+
* TODO in next major version this method should be removed
58+
* @deprecated
59+
*/
60+
@Deprecated
61+
@AfterMethod
62+
public void tearDownBaseEngineTest() throws Exception {
63+
}
64+
}

0 commit comments

Comments
 (0)