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.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.RuleChain;


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


public class ServerManagementTest public class ServerManagementTest
{ {

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

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


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


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


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


public class RecordStorageEngineTest public class RecordStorageEngineTest
{ {

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

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


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


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


public class NeoStoresTest public class NeoStoresTest
{ {
@Rule
public PageCacheRule pageCacheRule = new PageCacheRule(); private final PageCacheRule pageCacheRule = new PageCacheRule();
private final ExpectedException exception = ExpectedException.none();

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


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


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


public class AbstractKeyValueStoreTest 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 @Rule
public final ThreadingRule threading = new ThreadingRule(); public final ThreadingRule threading = new ThreadingRule();
@Rule @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>() 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; private File workingDirectory;


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


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


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


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


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


import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
Expand Down Expand Up @@ -68,12 +69,14 @@
public class IndexWorkSyncTransactionApplicationStressIT public class IndexWorkSyncTransactionApplicationStressIT
{ {
private final FileSystemAbstraction fs = new DefaultFileSystemAbstraction(); 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 @Rule
public final RecordStorageEngineRule storageEngineRule = new RecordStorageEngineRule(); public RuleChain ruleChain = RuleChain.outerRule( directory )
@Rule .around( pageCacheRule )
public final TargetDirectory.TestDirectory directory = TargetDirectory.testDirForTest( getClass() ); .around( storageEngineRule );
@Rule
public final PageCacheRule pageCacheRule = new PageCacheRule();


private final int labelId = 0; private final int labelId = 0;
private final int propertyKeyId = 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 @Parameters
public static Collection<Object[]> data() public static Collection<NumberArrayFactory> data()
{ {
return Arrays.asList( return Arrays.asList( NumberArrayFactory.HEAP, NumberArrayFactory.OFF_HEAP );
new Object[] {NumberArrayFactory.HEAP},
new Object[] {NumberArrayFactory.OFF_HEAP}
);
} }


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


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


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


import java.util.ArrayList; import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong; 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.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;

import static java.util.Arrays.asList;

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


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


@Parameter( 0 ) @Parameter
public int batchSize; public int batchSize;


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


import java.util.Map; import java.util.Map;


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


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

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


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


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


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


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

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


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

0 comments on commit 892dca3

Please sign in to comment.