Issue Fix flaky test PrimitiveSchemaTest
@@ -20,6 +20,7 @@ package org.apache.pulsar.client.impl.schema;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import io.netty.buffer.ByteBuf;
@@ -48,7 +49,14 @@ import org.testng.annotations.Test;
@Slf4j
public class PrimitiveSchemaTest {
- private static final Map<Schema, List<Object>> testData = new HashMap() {
+
+ @DataProvider(name = "schemas")
+ public Object[][] schemas() {
+
+ // we are not using a static initialization block, see here:
+ // https://github.com/apache/pulsar/issues/11037
+
+ final Map<Schema, List<Object>> testData = new HashMap() {
{
put(BooleanSchema.of(), Arrays.asList(false, true));
put(StringSchema.utf8(), Arrays.asList("my string"));
@@ -71,7 +79,7 @@ public class PrimitiveSchemaTest {
}
};
- private static final Map<Schema, List<Object>> testData2 = new HashMap() {
+ final Map<Schema, List<Object>> testData2 = new HashMap() {
{
put(Schema.BOOL, Arrays.asList(false, true));
put(Schema.STRING, Arrays.asList("my string"));
@@ -93,8 +101,13 @@ public class PrimitiveSchemaTest {
}
};
- @DataProvider(name = "schemas")
- public Object[][] schemas() {
+ for (Schema schema : testData.keySet()) {
+ assertNotNull(schema);
+ }
+ for (Schema schema : testData2.keySet()) {
+ assertNotNull(schema);
+ }
+
return new Object[][] { { testData }, { testData2 } };
}
