-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename BaseEngineParTest to BaseEngineTest
- Loading branch information
1 parent
d5e112a
commit 6f0d59c
Showing
36 changed files
with
253 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2017 LinkedIn, Inc | ||
* Copyright 2021 LinkedIn, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
|
@@ -16,39 +16,11 @@ | |
|
||
package com.linkedin.parseq; | ||
|
||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
|
||
|
||
/** | ||
* A base class that builds an Engine with default configuration. | ||
* For JUnit Jupiter (JUnit5+), see {@link com.linkedin.parseq.junitjupiter.BaseEngineParJunitJupiterTest}. | ||
* | ||
* This class creates new Engine before any test method is run and shuts it down after all tests are finished. | ||
* It can be used to run tests in parallel. | ||
* | ||
* The difference between this class and {@link BaseEngineTest} is that {@code BaseEngineTest} creates new | ||
* {@code Engine} instance for every test and thus provides higher level of isolation between the tests. | ||
* | ||
* @author Jaroslaw Odzga ([email protected]) | ||
* An alias for {@link BaseEngineTest}, only kept for backwards compatibility. Please use the latter. | ||
* @author Anmol Singh Jaggi ([email protected]) | ||
*/ | ||
public class BaseEngineParTest extends AbstractBaseEngineTest { | ||
|
||
@BeforeClass | ||
public void setUpBaseEngineParTest() throws Exception { | ||
getParSeqUnitTestHelper().setUp(); | ||
} | ||
|
||
@AfterClass | ||
public void tearDownBaseEngineParTest() throws Exception { | ||
if (getEngine() != null) { | ||
getParSeqUnitTestHelper().tearDown(); | ||
} else { | ||
throw new RuntimeException("Tried to shut down Engine but it either has not even been created or has " | ||
+ "already been shut down, in " + this.getClass().getName()); | ||
} | ||
} | ||
|
||
protected void customizeEngine(EngineBuilder engineBuilder) { | ||
} | ||
@Deprecated | ||
public class BaseEngineParTest extends BaseEngineTest { | ||
// Empty | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2012 LinkedIn, Inc | ||
* Copyright 2017 LinkedIn, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
|
@@ -16,98 +16,39 @@ | |
|
||
package com.linkedin.parseq; | ||
|
||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
|
||
|
||
/** | ||
* A base class that builds an Engine with default configuration. | ||
* For JUnit Jupiter (JUnit5+), see {@link com.linkedin.parseq.junitjupiter.BaseEngineJUnitJupiterTest} | ||
* For JUnit Jupiter (JUnit5+), see {@link com.linkedin.parseq.junitjupiter.BaseEngineJunitJupiterTest}. | ||
* | ||
* This class creates new Engine and shuts it down before and after every test method, so it can't be used | ||
* to run tests in parallel. | ||
* This class creates new Engine before any test method is run and shuts it down after all tests are finished. | ||
* It can be used to run tests in parallel. | ||
* | ||
* The difference between this class and {@link BaseEngineParTest} is that {@code BaseEngineParTest} creates new | ||
* {@code Engine} instance only once for all tests in the class and thus can be used to run test methods in parallel. | ||
* The difference between this class and {@link BaseIsolatedEngineTest} is that the latter creates a new | ||
* {@code Engine} instance for every test and thus provides higher level of isolation between the tests. | ||
* | ||
* @author Chris Pettitt ([email protected]) | ||
* @author Jaroslaw Odzga ([email protected]) | ||
* | ||
* @see ParSeqUnitTestHelper | ||
* @see BaseEngineParTest | ||
*/ | ||
public class BaseEngineTest extends AbstractBaseEngineTest { | ||
|
||
private volatile boolean _setUpCalled = false; | ||
private volatile boolean _tearDownCalled = false; | ||
|
||
@BeforeMethod | ||
public void setUpBaseEngineTest() throws Exception { | ||
if (!_setUpCalled) { | ||
_setUpCalled = true; | ||
_tearDownCalled = false; | ||
getParSeqUnitTestHelper().setUp(); | ||
} | ||
} | ||
|
||
/** | ||
* This method is left for backwards compatibility purpose. | ||
* It is not a good idea to have a @BeforeMethod method named | ||
* setUp because chances are that subclass will accidentally | ||
* override this method. | ||
* TODO in next major version this method should be removed | ||
* @deprecated | ||
*/ | ||
@Deprecated | ||
@BeforeMethod | ||
public void setUp() throws Exception { | ||
if (!_setUpCalled) { | ||
_setUpCalled = true; | ||
_tearDownCalled = false; | ||
getParSeqUnitTestHelper().setUp(); | ||
} | ||
@BeforeClass | ||
public void setUpBaseEngineParTest() throws Exception { | ||
getParSeqUnitTestHelper().setUp(); | ||
} | ||
|
||
/** | ||
* This method is left for backwards compatibility purpose. | ||
* It is not a good idea to have a @AfterMethod method named | ||
* tearDown because chances are that subclass will accidentally | ||
* override this method. | ||
* TODO in next major version this method should be removed | ||
* @deprecated | ||
*/ | ||
@Deprecated | ||
@AfterMethod | ||
public void tearDown() throws Exception { | ||
if (!_tearDownCalled) { | ||
_setUpCalled = false; | ||
_tearDownCalled = true; | ||
if (getEngine() != null) { | ||
getParSeqUnitTestHelper().tearDown(); | ||
} else { | ||
throw new RuntimeException("Tried to shut down Engine but it either has not even been created or has " | ||
+ "already been shut down. Please make sure you are not running unit tests in parallel. If you need to " | ||
+ "run unit tests in parallel, then use BaseEngineParTest instead, in " + this.getClass().getName()); | ||
} | ||
} | ||
} | ||
|
||
@AfterMethod | ||
public void tearDownBaseEngineTest() throws Exception { | ||
if (!_tearDownCalled) { | ||
_setUpCalled = false; | ||
_tearDownCalled = true; | ||
if (getEngine() != null) { | ||
getParSeqUnitTestHelper().tearDown(); | ||
} else { | ||
throw new RuntimeException("Tried to shut down Engine but it either has not even been created or has " | ||
+ "already been shut down. Please make sure you are not running unit tests in parallel. If you need to " | ||
+ "run unit tests in parallel, then use BaseEngineParTest instead, in " + this.getClass().getName()); | ||
} | ||
@AfterClass | ||
public void tearDownBaseEngineParTest() throws Exception { | ||
if (getEngine() != null) { | ||
getParSeqUnitTestHelper().tearDown(); | ||
} else { | ||
throw new RuntimeException("Tried to shut down Engine but it either has not even been created or has " | ||
+ "already been shut down, in " + this.getClass().getName()); | ||
} | ||
} | ||
|
||
protected void customizeEngine(EngineBuilder engineBuilder) { | ||
} | ||
|
||
} |
114 changes: 114 additions & 0 deletions
114
subprojects/parseq-test-api/src/main/java/com/linkedin/parseq/BaseIsolatedEngineTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Copyright 2012 LinkedIn, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package com.linkedin.parseq; | ||
|
||
import com.linkedin.parseq.junitjupiter.BaseIsolatedEngineJUnitJupiterTest; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeMethod; | ||
|
||
|
||
/** | ||
* A base class that builds an Engine with default configuration. | ||
* For JUnit Jupiter (JUnit5+), see {@link BaseIsolatedEngineJUnitJupiterTest} | ||
* | ||
* This class creates a new Engine and shuts it down before and after every test method, so it can't be used | ||
* to run tests in parallel. | ||
* | ||
* The difference between this class and {@link BaseEngineTest} is that the latter creates a new | ||
* {@code Engine} instance only once for all tests in the class and thus can be used to run test methods in parallel. | ||
* | ||
* @author Chris Pettitt ([email protected]) | ||
* @author Jaroslaw Odzga ([email protected]) | ||
* | ||
* @see ParSeqUnitTestHelper | ||
* @see BaseEngineTest | ||
*/ | ||
public class BaseIsolatedEngineTest extends AbstractBaseEngineTest { | ||
|
||
private volatile boolean _setUpCalled = false; | ||
private volatile boolean _tearDownCalled = false; | ||
|
||
@BeforeMethod | ||
public void setUpBaseEngineTest() throws Exception { | ||
if (!_setUpCalled) { | ||
_setUpCalled = true; | ||
_tearDownCalled = false; | ||
getParSeqUnitTestHelper().setUp(); | ||
} | ||
} | ||
|
||
/** | ||
* This method is left for backwards compatibility purpose. | ||
* It is not a good idea to have a @BeforeMethod method named | ||
* setUp because chances are that subclass will accidentally | ||
* override this method. | ||
* TODO in next major version this method should be removed | ||
* @deprecated | ||
*/ | ||
@Deprecated | ||
@BeforeMethod | ||
public void setUp() throws Exception { | ||
if (!_setUpCalled) { | ||
_setUpCalled = true; | ||
_tearDownCalled = false; | ||
getParSeqUnitTestHelper().setUp(); | ||
} | ||
} | ||
|
||
/** | ||
* This method is left for backwards compatibility purpose. | ||
* It is not a good idea to have a @AfterMethod method named | ||
* tearDown because chances are that subclass will accidentally | ||
* override this method. | ||
* TODO in next major version this method should be removed | ||
* @deprecated | ||
*/ | ||
@Deprecated | ||
@AfterMethod | ||
public void tearDown() throws Exception { | ||
if (!_tearDownCalled) { | ||
_setUpCalled = false; | ||
_tearDownCalled = true; | ||
if (getEngine() != null) { | ||
getParSeqUnitTestHelper().tearDown(); | ||
} else { | ||
throw new RuntimeException("Tried to shut down Engine but it either has not even been created or has " | ||
+ "already been shut down. Please make sure you are not running unit tests in parallel. If you need to " | ||
+ "run unit tests in parallel, then use BaseEngineParTest instead, in " + this.getClass().getName()); | ||
} | ||
} | ||
} | ||
|
||
@AfterMethod | ||
public void tearDownBaseEngineTest() throws Exception { | ||
if (!_tearDownCalled) { | ||
_setUpCalled = false; | ||
_tearDownCalled = true; | ||
if (getEngine() != null) { | ||
getParSeqUnitTestHelper().tearDown(); | ||
} else { | ||
throw new RuntimeException("Tried to shut down Engine but it either has not even been created or has " | ||
+ "already been shut down. Please make sure you are not running unit tests in parallel. If you need to " | ||
+ "run unit tests in parallel, then use BaseEngineParTest instead, in " + this.getClass().getName()); | ||
} | ||
} | ||
} | ||
|
||
protected void customizeEngine(EngineBuilder engineBuilder) { | ||
} | ||
|
||
} |
Oops, something went wrong.