HHH-15670 Implement RequiresDialectFeature.reverse()

- implement RequiresDialectFeature.reverse()
- remove not-feature checks to reverse = true
This commit is contained in:
Philippe Marschall 2022-11-04 17:38:56 +01:00 committed by Christian Beikov
parent 0b733d4ba2
commit 4aede4ca88
7 changed files with 16 additions and 31 deletions

View File

@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.fail;
*
* @author Steve Ebersole
*/
@RequiresDialectFeature(feature = DialectFeatureChecks.DoesReadCommittedNotCauseWritersToBlockReadersCheck.class)
@RequiresDialectFeature(feature = DialectFeatureChecks.DoesReadCommittedCauseWritersToBlockReadersCheck.class, reverse = true)
public class JPALockTest extends AbstractJPATest {
private SQLServerSnapshotIsolationConnectionProvider connectionProvider = new SQLServerSnapshotIsolationConnectionProvider();

View File

@ -38,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.fail;
*
* @author Steve Ebersole
*/
@RequiresDialectFeature(feature = DialectFeatureChecks.DoesReadCommittedNotCauseWritersToBlockReadersCheck.class)
@RequiresDialectFeature(feature = DialectFeatureChecks.DoesReadCommittedCauseWritersToBlockReadersCheck.class, reverse = true)
public class RepeatableReadTest extends AbstractJPATest {
private SQLServerSnapshotIsolationConnectionProvider connectionProvider = new SQLServerSnapshotIsolationConnectionProvider();

View File

@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.fail;
* @author Steve Ebersole
*/
@RequiresDialectFeature(
feature = DialectFeatureChecks.DoesRepeatableReadNotCauseReadersToBlockWritersCheck.class,
feature = DialectFeatureChecks.DoesRepeatableReadCauseReadersToBlockWritersCheck.class, reverse = true,
comment = "potential deadlock"
)
@DomainModel(

View File

@ -16,6 +16,6 @@ import org.hibernate.testing.orm.junit.SessionFactory;
*/
@DomainModel( annotatedClasses = ExampleEntity.class )
@SessionFactory
@RequiresDialectFeature( feature = DialectFeatureChecks.DoesNotSupportNullPrecedence.class )
@RequiresDialectFeature( feature = DialectFeatureChecks.SupportNullPrecedence.class, reverse = true )
public class SupportingNotNativelyDialectTest extends AbstractNullPrecedenceTest {
}

View File

@ -279,7 +279,7 @@ public class CMTTest {
@Test
@RequiresDialectFeature(
feature = DialectFeatureChecks.DoesReadCommittedNotCauseWritersToBlockReadersCheck.class,
feature = DialectFeatureChecks.DoesReadCommittedCauseWritersToBlockReadersCheck.class, reverse = true,
comment = "write locks block readers"
)
@SkipForDialect(dialectClass = CockroachDialect.class, reason = "Cockroach uses SERIALIZABLE by default and seems to fail reading a row that is exclusively locked by a different TX")

View File

@ -162,12 +162,6 @@ abstract public class DialectFeatureChecks {
}
}
public static class DoesReadCommittedNotCauseWritersToBlockReadersCheck implements DialectFeatureCheck {
public boolean apply(Dialect dialect) {
return ! dialect.doesReadCommittedCauseWritersToBlockReaders();
}
}
public static class DoesRepeatableReadCauseReadersToBlockWritersCheck implements DialectFeatureCheck {
public boolean apply(Dialect dialect) {
return dialect.doesRepeatableReadCauseReadersToBlockWriters();
@ -217,9 +211,9 @@ abstract public class DialectFeatureChecks {
}
}
public static class DoesNotSupportFollowOnLocking implements DialectFeatureCheck {
public static class SupportFollowOnLocking implements DialectFeatureCheck {
public boolean apply(Dialect dialect) {
return !dialect.useFollowOnLocking( null, null );
return dialect.useFollowOnLocking( null, null );
}
}
@ -241,12 +235,6 @@ abstract public class DialectFeatureChecks {
}
}
public static class DoesNotSupportNullPrecedence implements DialectFeatureCheck {
public boolean apply(Dialect dialect) {
return !dialect.supportsNullPrecedence();
}
}
public static class SupportsPadWithChar implements DialectFeatureCheck {
public boolean apply(Dialect dialect) {
return !( dialect instanceof DerbyDialect );
@ -370,12 +358,6 @@ abstract public class DialectFeatureChecks {
}
}
public static class DoesRepeatableReadNotCauseReadersToBlockWritersCheck implements DialectFeatureCheck {
public boolean apply(Dialect dialect) {
return ! dialect.doesRepeatableReadCauseReadersToBlockWriters();
}
}
public static class CurrentTimestampHasMicrosecondPrecision implements DialectFeatureCheck {
public boolean apply(Dialect dialect) {
return !dialect.currentTimestamp().contains( "6" );

View File

@ -192,18 +192,21 @@ public class DialectFilterExtension implements ExecutionCondition {
for ( RequiresDialectFeature effectiveRequiresDialectFeature : effectiveRequiresDialectFeatures ) {
try {
final DialectFeatureCheck dialectFeatureCheck = effectiveRequiresDialectFeature.feature()
.newInstance();
if ( !dialectFeatureCheck.apply( dialect ) ) {
final Class<? extends DialectFeatureCheck> featureClass = effectiveRequiresDialectFeature.feature();
final DialectFeatureCheck featureCheck = featureClass.getConstructor().newInstance();
boolean testResult = featureCheck.apply( dialect );
if ( effectiveRequiresDialectFeature.reverse() ) {
testResult = !testResult;
}
if ( !testResult ) {
return ConditionEvaluationResult.disabled(
String.format(
Locale.ROOT,
"Failed @RequiresDialectFeature [%s]",
effectiveRequiresDialectFeature.feature()
) );
featureClass ) );
}
}
catch (InstantiationException | IllegalAccessException e) {
catch (ReflectiveOperationException e) {
throw new RuntimeException( "Unable to instantiate DialectFeatureCheck class", e );
}
}