Skip to content

Commit

Permalink
don't merge, bumped junit to 5
Browse files Browse the repository at this point in the history
  • Loading branch information
datomo committed Dec 15, 2023
1 parent ea8413e commit b2af204
Show file tree
Hide file tree
Showing 79 changed files with 704 additions and 842 deletions.
9 changes: 8 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ plugins {
}


test {
useJUnitPlatform()
}


allprojects {

version = versionMajor + "." + versionMinor + "." + versionMicro
Expand All @@ -40,6 +45,7 @@ allprojects {
}
}


apply plugin: "java-library"
apply plugin: "io.freefair.lombok"
apply plugin: "com.adarshr.test-logger"
Expand Down Expand Up @@ -133,6 +139,8 @@ allprojects {
testCompileOnly(group: 'org.pf4j', name: 'pf4j', version: pf4j_version) {
exclude group: "org.slf4j"
}
testImplementation(group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junit_jupiter_version)
testRuntimeOnly(group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junit_jupiter_version)
}

idea {
Expand Down Expand Up @@ -164,7 +172,6 @@ allprojects {
}



idea {
project {
settings {
Expand Down
2 changes: 1 addition & 1 deletion config/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {

// --- Test Compile ---
testImplementation project(path: ":core", configuration: "tests")
testImplementation group: "junit", name: "junit", version: junit_version
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: junit_jupiter_version
}


Expand Down
4 changes: 3 additions & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ configurations {
}



buildscript {
dependencies {
// JavaCC (https://github.com/johnmartel/javaccPlugin)
Expand Down Expand Up @@ -82,7 +83,8 @@ dependencies {
api group: "io.activej", name: "activej-serializer", version: activej_serializer_version

// --- Test Compile ---
testImplementation group: "junit", name: "junit", version: junit_version
testImplementation group: 'org.junit.platform', name: 'junit-platform-suite-engine', version: junit_suite_version
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: junit_jupiter_version
testImplementation group: "org.hamcrest", name: "hamcrest-core", version: hamcrest_core_version // BSD 3-clause
}

Expand Down
137 changes: 0 additions & 137 deletions core/src/main/java/org/polypheny/db/type/entity/PolyTimeStamp.java

This file was deleted.

5 changes: 5 additions & 0 deletions core/src/test/java/org/polypheny/db/AdapterTestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

package org.polypheny.db;

import org.junit.jupiter.api.Tag;
import org.junit.platform.suite.api.Suite;

@Suite
@Tag("adapter")
public class AdapterTestSuite {

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.polypheny.db.algebra.exceptions.ConstraintViolationException;
import org.polypheny.db.transaction.PUID;
import org.polypheny.db.transaction.PUID.Type;
Expand All @@ -37,7 +37,7 @@

public class CowHashIndexTest {

@BeforeClass
@BeforeAll
public static void init() {
PolyphenyHomeDirManager.setModeAndGetInstance( PolyMode.TEST );
}
Expand All @@ -48,7 +48,7 @@ public void testCopyOnWriteIsolation() {
CoWHashIndex idx = new CoWHashIndex( 42L, "idx_test", null, null, Collections.emptyList(), Collections.emptyList() );
PolyXid xid1 = PolyXid.generateLocalTransactionIdentifier( PUID.randomPUID( Type.NODE ), PUID.randomPUID( Type.TRANSACTION ) );
PolyXid xid2 = PolyXid.generateLocalTransactionIdentifier( PUID.randomPUID( Type.NODE ), PUID.randomPUID( Type.TRANSACTION ) );
Assert.assertEquals( 0, idx.getRaw().size() );
Assertions.assertEquals( 0, idx.getRaw().size() );
// Insert and delete some values as xid1
idx.insert( xid1, asPolyValues( 1, 2, 3 ), asPolyValues( 1 ) );
idx.insertAll( xid1, Arrays.asList(
Expand All @@ -58,40 +58,40 @@ public void testCopyOnWriteIsolation() {
) );
idx.delete( xid1, asPolyValues( 2, 3, 4 ) );
// Make sure the values are not yet visible by either transaction
Assert.assertFalse( idx.contains( xid1, asPolyValues( 1, 2, 3 ) ) );
Assert.assertFalse( idx.contains( xid1, asPolyValues( 2, 3, 4 ) ) );
Assert.assertFalse( idx.contains( xid1, asPolyValues( 3, 4, 5 ) ) );
Assert.assertFalse( idx.contains( xid2, asPolyValues( 1, 2, 3 ) ) );
Assert.assertFalse( idx.contains( xid2, asPolyValues( 2, 3, 4 ) ) );
Assert.assertFalse( idx.contains( xid2, asPolyValues( 3, 4, 5 ) ) );
Assertions.assertFalse( idx.contains( xid1, asPolyValues( 1, 2, 3 ) ) );
Assertions.assertFalse( idx.contains( xid1, asPolyValues( 2, 3, 4 ) ) );
Assertions.assertFalse( idx.contains( xid1, asPolyValues( 3, 4, 5 ) ) );
Assertions.assertFalse( idx.contains( xid2, asPolyValues( 1, 2, 3 ) ) );
Assertions.assertFalse( idx.contains( xid2, asPolyValues( 2, 3, 4 ) ) );
Assertions.assertFalse( idx.contains( xid2, asPolyValues( 3, 4, 5 ) ) );
// Invoke atom isolation barrier
idx.barrier( xid1 );
// Make sure the values are only visible by transaction 1
Assert.assertTrue( idx.contains( xid1, asPolyValues( 1, 2, 3 ) ) );
Assert.assertFalse( idx.contains( xid1, asPolyValues( 2, 3, 4 ) ) );
Assert.assertTrue( idx.contains( xid1, asPolyValues( 3, 4, 5 ) ) );
Assert.assertFalse( idx.contains( xid2, asPolyValues( 1, 2, 3 ) ) );
Assert.assertFalse( idx.contains( xid2, asPolyValues( 2, 3, 4 ) ) );
Assert.assertFalse( idx.contains( xid2, asPolyValues( 3, 4, 5 ) ) );
Assertions.assertTrue( idx.contains( xid1, asPolyValues( 1, 2, 3 ) ) );
Assertions.assertFalse( idx.contains( xid1, asPolyValues( 2, 3, 4 ) ) );
Assertions.assertTrue( idx.contains( xid1, asPolyValues( 3, 4, 5 ) ) );
Assertions.assertFalse( idx.contains( xid2, asPolyValues( 1, 2, 3 ) ) );
Assertions.assertFalse( idx.contains( xid2, asPolyValues( 2, 3, 4 ) ) );
Assertions.assertFalse( idx.contains( xid2, asPolyValues( 3, 4, 5 ) ) );
// Commit
idx.commit( xid1 );
// Make sure the values are visible by both transactions
Assert.assertTrue( idx.contains( xid1, asPolyValues( 1, 2, 3 ) ) );
Assert.assertFalse( idx.contains( xid1, asPolyValues( 2, 3, 4 ) ) );
Assert.assertTrue( idx.contains( xid1, asPolyValues( 3, 4, 5 ) ) );
Assert.assertTrue( idx.contains( xid2, asPolyValues( 1, 2, 3 ) ) );
Assert.assertFalse( idx.contains( xid1, asPolyValues( 2, 3, 4 ) ) );
Assert.assertTrue( idx.contains( xid2, asPolyValues( 3, 4, 5 ) ) );
Assertions.assertTrue( idx.contains( xid1, asPolyValues( 1, 2, 3 ) ) );
Assertions.assertFalse( idx.contains( xid1, asPolyValues( 2, 3, 4 ) ) );
Assertions.assertTrue( idx.contains( xid1, asPolyValues( 3, 4, 5 ) ) );
Assertions.assertTrue( idx.contains( xid2, asPolyValues( 1, 2, 3 ) ) );
Assertions.assertFalse( idx.contains( xid1, asPolyValues( 2, 3, 4 ) ) );
Assertions.assertTrue( idx.contains( xid2, asPolyValues( 3, 4, 5 ) ) );
// Insert, then rollback
idx.insert( xid1, asPolyValues( 2, 3, 4 ), asPolyValues( 1 ) );
Assert.assertFalse( idx.contains( xid1, asPolyValues( 2, 3, 4 ) ) );
Assert.assertFalse( idx.contains( xid2, asPolyValues( 2, 3, 4 ) ) );
Assertions.assertFalse( idx.contains( xid1, asPolyValues( 2, 3, 4 ) ) );
Assertions.assertFalse( idx.contains( xid2, asPolyValues( 2, 3, 4 ) ) );
idx.barrier( xid1 );
Assert.assertTrue( idx.contains( xid1, asPolyValues( 2, 3, 4 ) ) );
Assert.assertFalse( idx.contains( xid2, asPolyValues( 2, 3, 4 ) ) );
Assertions.assertTrue( idx.contains( xid1, asPolyValues( 2, 3, 4 ) ) );
Assertions.assertFalse( idx.contains( xid2, asPolyValues( 2, 3, 4 ) ) );
idx.rollback( xid1 );
Assert.assertFalse( idx.contains( xid1, asPolyValues( 2, 3, 4 ) ) );
Assert.assertFalse( idx.contains( xid2, asPolyValues( 2, 3, 4 ) ) );
Assertions.assertFalse( idx.contains( xid1, asPolyValues( 2, 3, 4 ) ) );
Assertions.assertFalse( idx.contains( xid2, asPolyValues( 2, 3, 4 ) ) );
}


Expand All @@ -103,11 +103,11 @@ public void testDuplicateDetection() {
idx.insert( xid1, asPolyValues( 1, 2, 3 ), asPolyValues( 1 ) );
try {
idx.barrier( xid1 );
Assert.fail( "Expected ConstraintViolationException not thrown!" );
Assertions.fail( "Expected ConstraintViolationException not thrown!" );
} catch ( ConstraintViolationException ignored ) {
// pass
} catch ( Throwable t ) {
Assert.fail( "Expected ConstraintViolationException, got this instead: " + t );
Assertions.fail( "Expected ConstraintViolationException, got this instead: " + t );
}
idx.rollback( xid1 );
idx.insertAll( xid1, Arrays.asList(
Expand All @@ -119,20 +119,20 @@ public void testDuplicateDetection() {
) );
try {
idx.barrier( xid1 );
Assert.fail( "Expected ConstraintViolationException not thrown!" );
Assertions.fail( "Expected ConstraintViolationException not thrown!" );
} catch ( ConstraintViolationException ignored ) {
// pass
} catch ( Throwable t ) {
Assert.fail( "Expected ConstraintViolationException, got this instead: " + t );
Assertions.fail( "Expected ConstraintViolationException, got this instead: " + t );
}
// Attempt to commit, should fail, as barrier could not complete
try {
idx.commit( xid1 );
Assert.fail( "Expected IllegalStateException not thrown!" );
Assertions.fail( "Expected IllegalStateException not thrown!" );
} catch ( IllegalStateException ignored ) {
// pass
} catch ( Throwable t ) {
Assert.fail( "Expected IllegalStateException, got this instead: " + t );
Assertions.fail( "Expected IllegalStateException, got this instead: " + t );
}
// No choice but to roll back
idx.rollback( xid1 );
Expand All @@ -150,12 +150,12 @@ public void testContains() {
Pair.of( asPolyValues( 5, 6, 7 ), asPolyValues( 5 ) )
) );
idx.barrier( xid1 );
Assert.assertTrue( idx.contains( xid1, asPolyValues( 3, 4, 5 ) ) );
Assert.assertFalse( idx.contains( xid1, asPolyValues( 1, 2, 3 ) ) );
Assert.assertTrue( idx.containsAny( xid1, Arrays.asList( asPolyValues( 1, 2, 3 ), asPolyValues( 3, 4, 5 ) ) ) );
Assert.assertFalse( idx.containsAny( xid1, Arrays.asList( asPolyValues( 1, 2, 3 ), asPolyValues( 0, 1, 2 ) ) ) );
Assert.assertTrue( idx.containsAll( xid1, Arrays.asList( asPolyValues( 3, 4, 5 ), asPolyValues( 5, 6, 7 ) ) ) );
Assert.assertFalse( idx.containsAll( xid1, Arrays.asList( asPolyValues( 1, 2, 3 ), asPolyValues( 3, 4, 5 ) ) ) );
Assertions.assertTrue( idx.contains( xid1, asPolyValues( 3, 4, 5 ) ) );
Assertions.assertFalse( idx.contains( xid1, asPolyValues( 1, 2, 3 ) ) );
Assertions.assertTrue( idx.containsAny( xid1, Arrays.asList( asPolyValues( 1, 2, 3 ), asPolyValues( 3, 4, 5 ) ) ) );
Assertions.assertFalse( idx.containsAny( xid1, Arrays.asList( asPolyValues( 1, 2, 3 ), asPolyValues( 0, 1, 2 ) ) ) );
Assertions.assertTrue( idx.containsAll( xid1, Arrays.asList( asPolyValues( 3, 4, 5 ), asPolyValues( 5, 6, 7 ) ) ) );
Assertions.assertFalse( idx.containsAll( xid1, Arrays.asList( asPolyValues( 1, 2, 3 ), asPolyValues( 3, 4, 5 ) ) ) );
}


Expand Down
Loading

0 comments on commit b2af204

Please sign in to comment.