Skip to content

Commit

Permalink
HSEARCH-3153 Fix JUnit related violations found by ForbiddenAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanne committed May 2, 2018
1 parent 1c289d0 commit 85f5d43
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
Expand Up @@ -24,7 +24,7 @@
import org.junit.Before;
import org.junit.Test;

import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertFalse;

public class LoggerInfoStreamTest {

Expand Down
Expand Up @@ -8,8 +8,6 @@

import java.util.concurrent.TimeUnit;

import junit.framework.AssertionFailedError;

/**
* A utility allowing to re-execute a piece of code in the current thread until it "works".
* <p>
Expand Down Expand Up @@ -90,7 +88,7 @@ public interface ThrowingRunnable<E extends Exception> {
}

private AssertionError newAssertionPollingError(AssertionError lastAssertionError, int nbOfFailedAttempts, long timeSpentNanos) {
AssertionError error = new AssertionFailedError(
AssertionError error = new AssertionError(
"Assertion failed even after " + nbOfFailedAttempts + " attempts in " + timeSpentNanos + "ns : "
+ lastAssertionError.getMessage()
);
Expand Down
Expand Up @@ -26,8 +26,15 @@
import org.hibernate.search.util.logging.impl.Log;
import org.hibernate.search.util.logging.impl.LoggerFactory;
import java.lang.invoke.MethodHandles;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
* Test case for master/slave directories.
*
Expand Down Expand Up @@ -66,6 +73,7 @@ public class FSSlaveAndMasterDPTest extends MultipleSFTestCase {
*
* @throws Exception in case the test fails.
*/
@Test
public void testProperCopy() throws Exception {

// assert that the slave index is empty
Expand Down Expand Up @@ -176,13 +184,15 @@ static Path prepareDirectories(String testId) throws IOException {
}

@Override
protected void setUp() throws Exception {
this.root = prepareDirectories( getClass().getSimpleName() + "." + this.getName() );
@Before
public void setUp() throws Exception {
this.root = prepareDirectories( getClass().getSimpleName() );
super.setUp();
}

@Override
protected void tearDown() throws Exception {
@After
public void tearDown() throws Exception {
super.tearDown();
cleanupDirectories( root );
}
Expand All @@ -204,6 +214,7 @@ public Class<?>[] getAnnotatedClasses() {
};
}

@Test
public void testSourceNotReady() throws Exception {
int retries = 1;
Configuration cfg = new Configuration();
Expand Down
Expand Up @@ -8,22 +8,23 @@

import java.io.InputStream;

import junit.framework.TestCase;

import org.apache.lucene.util.Version;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.search.testsupport.TestConstants;

import org.junit.After;
import org.junit.Before;

/**
* Build multiple session factories from the same set of classes
* The configuration can be altered overriding {@link #configure}.
*
* @author Emmanuel Bernard
*/
public abstract class MultipleSFTestCase extends TestCase {
public abstract class MultipleSFTestCase {

private static SessionFactory[] sessionFactories;
private static Configuration[] cfgs;
Expand Down Expand Up @@ -74,14 +75,14 @@ protected void buildSessionFactories(Class[] classes, String[] packages, String[
}
}

@Override
protected void setUp() throws Exception {
@Before
public void setUp() throws Exception {
buildSessionFactories( getAnnotatedClasses(), getAnnotatedPackages(), getXmlFiles() );
lastTestClass = getClass();
}

@Override
protected void tearDown() throws Exception {
@After
public void tearDown() throws Exception {
for ( SessionFactory sf : getSessionFactories() ) {
sf.close();
}
Expand Down

0 comments on commit 85f5d43

Please sign in to comment.