Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename BaseEngineParTest to BaseEngineTest #307

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v5.1.5
------
* Rename BaseEngineParTest to BaseEngineTest

v5.1.4
------
* Add interop between Guava's ListenableFuture and Parseq Task
Expand Down
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
Expand All @@ -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 (jodzga@linkedin.com)
* An alias for {@link BaseEngineTest}, only kept for backwards compatibility. Please use the latter.
* @author Anmol Singh Jaggi (ajaggi@linkedin.com)
*/
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
}
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
Expand All @@ -16,98 +16,41 @@

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 (cpettitt@linkedin.com)
* @author Jaroslaw Odzga (jodzga@linkedin.com)
*
* @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();
}
public class BaseEngineTest extends OldBaseEngineTest {

@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 @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());
}
@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());
}
}

@Override
protected void customizeEngine(EngineBuilder engineBuilder) {

}

}
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 (cpettitt@linkedin.com)
* @author Jaroslaw Odzga (jodzga@linkedin.com)
*
* @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 BaseEngineTest 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 BaseEngineTest instead, in " + this.getClass().getName());
}
}
}

protected void customizeEngine(EngineBuilder engineBuilder) {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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
* 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 org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;


abstract class OldBaseEngineTest extends AbstractBaseEngineTest {

/**
* This method is left for backwards compatibility purpose.
* TODO in next major version this method should be removed
* @deprecated
*/
@Deprecated
@BeforeMethod
public void setUpBaseEngineTest() throws Exception {
}

/**
* This method is left for backwards compatibility purpose.
* TODO in next major version this method should be removed
* @deprecated
*/
@Deprecated
@BeforeMethod
public void setUp() throws Exception {
}

/**
* This method is left for backwards compatibility purpose.
* TODO in next major version this method should be removed
* @deprecated
*/
@Deprecated
@AfterMethod
public void tearDown() throws Exception {
}

/**
* This method is left for backwards compatibility purpose.
* TODO in next major version this method should be removed
* @deprecated
*/
@Deprecated
@AfterMethod
public void tearDownBaseEngineTest() throws Exception {
}
}
Loading