Skip to content

Commit

Permalink
Switch to latest junit 4.12 and fixing all affected tests
Browse files Browse the repository at this point in the history
Cleanup parametrized Object[] in a couple of kernel tests.
Full release notes for junit 4.12 can be found at
https://github.com/junit-team/junit/blob/master/doc/ReleaseNotes4.12.md
  • Loading branch information
MishaDemianenko committed Jan 20, 2016
1 parent 66947f6 commit 892dca3
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 60 deletions.
Expand Up @@ -21,6 +21,7 @@

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;

import org.neo4j.kernel.GraphDatabaseDependencies;
import org.neo4j.kernel.configuration.Config;
Expand All @@ -40,10 +41,13 @@

public class ServerManagementTest
{

private final CleanupRule cleanup = new CleanupRule();
private final TargetDirectory.TestDirectory baseDir = TargetDirectory.testDirForTest( getClass() );

@Rule
public final CleanupRule cleanup = new CleanupRule();
@Rule
public final TargetDirectory.TestDirectory baseDir = TargetDirectory.testDirForTest( getClass() );
public RuleChain ruleChain = RuleChain.outerRule( baseDir )
.around( cleanup );

@Test
public void shouldBeAbleToRestartServer() throws Exception
Expand Down
Expand Up @@ -21,6 +21,7 @@

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;

import java.io.IOException;
import java.util.concurrent.ThreadLocalRandom;
Expand Down Expand Up @@ -49,12 +50,15 @@

public class RecordStorageEngineTest
{

private final RecordStorageEngineRule storageEngineRule = new RecordStorageEngineRule();
private final EphemeralFileSystemRule fsRule = new EphemeralFileSystemRule();
private final PageCacheRule pageCacheRule = new PageCacheRule();

@Rule
public final RecordStorageEngineRule storageEngineRule = new RecordStorageEngineRule();
@Rule
public final EphemeralFileSystemRule fsRule = new EphemeralFileSystemRule();
@Rule
public final PageCacheRule pageCacheRule = new PageCacheRule();
public RuleChain ruleChain = RuleChain.outerRule( fsRule )
.around( pageCacheRule )
.around( storageEngineRule );

@Test( timeout = 30_000 )
public void shutdownRecordStorageEngineAfterFailedTransaction() throws Throwable
Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.RuleChain;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -90,16 +91,18 @@

public class NeoStoresTest
{
@Rule
public PageCacheRule pageCacheRule = new PageCacheRule();

private final PageCacheRule pageCacheRule = new PageCacheRule();
private final ExpectedException exception = ExpectedException.none();

@Rule
public EphemeralFileSystemRule fs = new EphemeralFileSystemRule();
@Rule
public TargetDirectory.TestDirectory dir = TargetDirectory.testDirForTestWithEphemeralFS( fs.get(), getClass() );
@Rule
public NeoStoreDataSourceRule dsRule = new NeoStoreDataSourceRule();
@Rule
public final ExpectedException exception = ExpectedException.none();
public RuleChain ruleChain = RuleChain.outerRule( exception ).around( pageCacheRule );

private PageCache pageCache;
private File storeDir;
Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.RuleChain;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -49,12 +50,15 @@

public class AbstractKeyValueStoreTest
{
@Rule
public final Resources resourceManager = new Resources( FILE_IN_EXISTING_DIRECTORY );

private final ExpectedException expectedException = ExpectedException.none();
private final Resources resourceManager = new Resources( FILE_IN_EXISTING_DIRECTORY );

@Rule
public final ThreadingRule threading = new ThreadingRule();
@Rule
public final ExpectedException expectedException = ExpectedException.none();
public final RuleChain ruleChain = RuleChain.outerRule( expectedException )
.around( resourceManager );

private static final HeaderField<Long> TX_ID = new HeaderField<Long>()
{
Expand Down
Expand Up @@ -71,14 +71,14 @@ public static class SupportedVersions
private File workingDirectory;

@Parameterized.Parameters( name = "{0}" )
public static Collection<Object[]> versions()
public static Collection<String> versions()
{
return Arrays.asList(
new Object[]{Legacy19Store.LEGACY_VERSION},
new Object[]{Legacy20Store.LEGACY_VERSION},
new Object[]{Legacy21Store.LEGACY_VERSION},
new Object[]{Legacy22Store.LEGACY_VERSION},
new Object[]{Legacy23Store.LEGACY_VERSION}
Legacy19Store.LEGACY_VERSION,
Legacy20Store.LEGACY_VERSION,
Legacy21Store.LEGACY_VERSION,
Legacy22Store.LEGACY_VERSION,
Legacy23Store.LEGACY_VERSION
);
}

Expand Down Expand Up @@ -195,12 +195,9 @@ public static class UnsupportedVersions
private static final String neostoreFilename = "neostore";

@Parameterized.Parameters( name = "{0}" )
public static Collection<Object[]> versions()
public static Collection<String> versions()
{
return Arrays.asList(
new Object[]{"v0.9.5"},
new Object[]{"v0.A.4"}
);
return Arrays.asList( "v0.9.5", "v0.A.4" );
}

@Rule
Expand Down
Expand Up @@ -21,6 +21,7 @@

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -68,12 +69,14 @@
public class IndexWorkSyncTransactionApplicationStressIT
{
private final FileSystemAbstraction fs = new DefaultFileSystemAbstraction();
private final RecordStorageEngineRule storageEngineRule = new RecordStorageEngineRule();
private final TargetDirectory.TestDirectory directory = TargetDirectory.testDirForTest( getClass() );
private final PageCacheRule pageCacheRule = new PageCacheRule();

@Rule
public final RecordStorageEngineRule storageEngineRule = new RecordStorageEngineRule();
@Rule
public final TargetDirectory.TestDirectory directory = TargetDirectory.testDirForTest( getClass() );
@Rule
public final PageCacheRule pageCacheRule = new PageCacheRule();
public RuleChain ruleChain = RuleChain.outerRule( directory )
.around( pageCacheRule )
.around( storageEngineRule );

private final int labelId = 0;
private final int propertyKeyId = 0;
Expand Down
Expand Up @@ -83,12 +83,9 @@ private void swap( long[] expected, int fromIndex, int toIndex, int items )
}

@Parameters
public static Collection<Object[]> data()
public static Collection<NumberArrayFactory> data()
{
return Arrays.asList(
new Object[] {NumberArrayFactory.HEAP},
new Object[] {NumberArrayFactory.OFF_HEAP}
);
return Arrays.asList( NumberArrayFactory.HEAP, NumberArrayFactory.OFF_HEAP );
}

public IntArrayTest( NumberArrayFactory factory )
Expand Down
Expand Up @@ -96,12 +96,9 @@ private void swap( long[] expected, int fromIndex, int toIndex, int items )
}

@Parameters
public static Collection<Object[]> data()
public static Collection<NumberArrayFactory> data()
{
return Arrays.asList(
new Object[] {NumberArrayFactory.HEAP},
new Object[] {NumberArrayFactory.OFF_HEAP}
);
return Arrays.asList( NumberArrayFactory.HEAP, NumberArrayFactory.OFF_HEAP );
}

public LongArrayTest( NumberArrayFactory factory )
Expand Down
Expand Up @@ -24,33 +24,24 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;

import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicLong;

import org.neo4j.helpers.ArrayUtil;

import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import static java.util.Arrays.asList;

import static org.neo4j.unsafe.impl.batchimport.stats.Keys.done_batches;

@RunWith( Parameterized.class )
public class CoarseBoundedProgressExecutionMonitorTest
{
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> parameters()
public static Iterable<Integer> parameters()
{
List<Object[]> result = new ArrayList<>();
result.add( ArrayUtil.<Object>array( 1 ) );
result.add( ArrayUtil.<Object>array( 10 ) );
result.add( ArrayUtil.<Object>array( 123 ) );
return result;
return Arrays.asList(1, 10, 123);
}

@Parameter( 0 )
@Parameter
public int batchSize;

@Test
Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;

import java.util.Map;

Expand All @@ -46,10 +47,13 @@

public class LuceneDataSourceTest
{
private final LifeRule life = new LifeRule( true );
private final TestDirectory directory = TargetDirectory.testDirForTest( getClass() );

@Rule
public final LifeRule life = new LifeRule( true );
@Rule
public final TestDirectory directory = TargetDirectory.testDirForTest( getClass() );
public final RuleChain ruleChain = RuleChain.outerRule( directory )
.around( life );

private IndexConfigStore indexStore;
private LuceneDataSource dataSource;

Expand Down
Expand Up @@ -21,6 +21,7 @@

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -61,8 +62,12 @@

public class TestBranchedData
{
public final @Rule LifeRule life = new LifeRule( true );
public final @Rule TestDirectory directory = TargetDirectory.testDirForTest( getClass() );
private final LifeRule life = new LifeRule( true );
private final TestDirectory directory = TargetDirectory.testDirForTest( getClass() );

@Rule
public final RuleChain ruleChain = RuleChain.outerRule( directory )
.around( life );

@Test
public void migrationOfBranchedDataDirectories() throws Exception
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -493,7 +493,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down

0 comments on commit 892dca3

Please sign in to comment.