|
16 | 16 | import java.util.concurrent.atomic.AtomicInteger; |
17 | 17 | import org.junit.jupiter.api.Test; |
18 | 18 | import org.junit.jupiter.api.io.TempDir; |
| 19 | +import org.junit.platform.engine.TestDescriptor; |
| 20 | +import org.junit.platform.engine.support.descriptor.MethodSource; |
19 | 21 |
|
20 | 22 | /** |
21 | 23 | * Exercises the conformance harness itself, without a running sqld container where possible. |
@@ -63,6 +65,54 @@ void fileMemoryUriIsNotRetained() { |
63 | 65 | assertThat(memoryMode.retained()).isFalse(); |
64 | 66 | } |
65 | 67 |
|
| 68 | + @Test |
| 69 | + void quarantineExcludesOnlyTheAppendixBConflicts() { |
| 70 | + XerialQuarantine quarantine = new XerialQuarantine(); |
| 71 | + |
| 72 | + for (XerialQuarantine.Quarantined quarantined : XerialQuarantine.QUARANTINED) { |
| 73 | + assertThat( |
| 74 | + quarantine |
| 75 | + .apply( |
| 76 | + descriptor( |
| 77 | + quarantined.className(), |
| 78 | + quarantined.methodName())) |
| 79 | + .excluded()) |
| 80 | + .as("%s#%s", quarantined.className(), quarantined.methodName()) |
| 81 | + .isTrue(); |
| 82 | + } |
| 83 | + |
| 84 | + assertThat(quarantine.apply(descriptor("org.sqlite.ResultSetTest", "next")).included()) |
| 85 | + .as("an unconflicted xerial test") |
| 86 | + .isTrue(); |
| 87 | + } |
| 88 | + |
| 89 | + @Test |
| 90 | + void quarantineIsInactiveDuringTheXerialControlRun() { |
| 91 | + String previous = System.getProperty(XerialControl.ENABLED_PROPERTY); |
| 92 | + System.setProperty(XerialControl.ENABLED_PROPERTY, "xerial"); |
| 93 | + try { |
| 94 | + XerialQuarantine quarantine = new XerialQuarantine(); |
| 95 | + for (XerialQuarantine.Quarantined quarantined : XerialQuarantine.QUARANTINED) { |
| 96 | + assertThat( |
| 97 | + quarantine |
| 98 | + .apply( |
| 99 | + descriptor( |
| 100 | + quarantined.className(), |
| 101 | + quarantined.methodName())) |
| 102 | + .included()) |
| 103 | + .as("control run keeps %s#%s", quarantined.className(), |
| 104 | + quarantined.methodName()) |
| 105 | + .isTrue(); |
| 106 | + } |
| 107 | + } finally { |
| 108 | + if (previous == null) { |
| 109 | + System.clearProperty(XerialControl.ENABLED_PROPERTY); |
| 110 | + } else { |
| 111 | + System.setProperty(XerialControl.ENABLED_PROPERTY, previous); |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | + |
66 | 116 | @Test |
67 | 117 | void queryStringIsPartOfTheFileNamespace() { |
68 | 118 | XerialConformanceDriver.Target readOnly = |
@@ -163,6 +213,19 @@ void stopReportsASwallowedCleanupFailure() { |
163 | 213 | } |
164 | 214 | } |
165 | 215 |
|
| 216 | + private static TestDescriptor descriptor(String className, String methodName) { |
| 217 | + MethodSource source = MethodSource.from(className, methodName); |
| 218 | + return (TestDescriptor) |
| 219 | + Proxy.newProxyInstance( |
| 220 | + TestDescriptor.class.getClassLoader(), |
| 221 | + new Class<?>[] {TestDescriptor.class}, |
| 222 | + (proxy, method, args) -> |
| 223 | + switch (method.getName()) { |
| 224 | + case "getSource" -> java.util.Optional.of(source); |
| 225 | + default -> null; |
| 226 | + }); |
| 227 | + } |
| 228 | + |
166 | 229 | private static Connection wrap(Connection connection, String namespace) { |
167 | 230 | return wrap(connection, namespace, ignored -> {}); |
168 | 231 | } |
|
0 commit comments