Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

@Test(groups = "broker-admin")
@Slf4j
public class AdminApiDelayedDelivery extends MockedPulsarServiceBaseTest {
public class AdminApiDelayedDeliveryTest extends MockedPulsarServiceBaseTest {

@BeforeMethod
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

@Slf4j
@Test(groups = "broker-admin")
public class AdminApiMaxUnackedMessages extends MockedPulsarServiceBaseTest {
public class AdminApiMaxUnackedMessagesTest extends MockedPulsarServiceBaseTest {

@BeforeMethod
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,13 @@
import org.apache.pulsar.common.protocol.schema.PostSchemaPayload;
import org.apache.pulsar.common.schema.SchemaInfo;
import org.apache.pulsar.common.schema.SchemaType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

@Slf4j
@Test(groups = "broker-admin")
public class AdminApiSchemaValidationEnforced extends MockedPulsarServiceBaseTest {

private static final Logger LOG = LoggerFactory.getLogger(AdminApiSchemaValidationEnforced.class);
public class AdminApiSchemaValidationEnforcedTest extends MockedPulsarServiceBaseTest {

@BeforeMethod
@Override
Expand Down Expand Up @@ -82,8 +78,9 @@ public void testDisableSchemaValidationEnforcedNoSchema() throws Exception {
admin.namespaces().setSchemaValidationEnforced(namespace, false);
try {
admin.schemas().getSchemaInfo(topicName);
fail();
} catch (PulsarAdminException.NotFoundException e) {
assertTrue(e.getMessage().contains("HTTP 404 Not Found"));
assertEquals(e.getMessage(), "Schema not found");
}
try (Producer p = pulsarClient.newProducer().topic(topicName).create()) {
p.send("test schemaValidationEnforced".getBytes());
Expand All @@ -99,22 +96,32 @@ public void testDisableSchemaValidationEnforcedHasSchema() throws Exception {
admin.namespaces().setSchemaValidationEnforced(namespace, false);
try {
admin.schemas().getSchemaInfo(topicName);
fail();
} catch (PulsarAdminException.NotFoundException e) {
assertTrue(e.getMessage().contains("HTTP 404 Not Found"));
assertEquals(e.getMessage(), "Schema not found");
}
Map<String, String> properties = new HashMap<>();
SchemaInfo schemaInfo = SchemaInfo.builder()
.type(SchemaType.STRING)
.properties(properties)
.name("test")
.timestamp(1L)
.schema("".getBytes())
.build();
PostSchemaPayload postSchemaPayload = new PostSchemaPayload("STRING", "", properties);
admin.schemas().createSchema(topicName, postSchemaPayload);
try (Producer p = pulsarClient.newProducer().topic(topicName).create()) {
p.send("test schemaValidationEnforced".getBytes());
}
assertEquals(admin.schemas().getSchemaInfo(topicName), schemaInfo);
assertSchemaInfoEquals(admin.schemas().getSchemaInfo(topicName), schemaInfo);
}

private static void assertSchemaInfoEquals(SchemaInfo actual, SchemaInfo expected) {
assertEquals(actual.getName(), expected.getName());
assertEquals(actual.getSchema(), expected.getSchema());
assertEquals(actual.getType(), expected.getType());
assertEquals(actual.getProperties(), expected.getProperties());
assertEquals(actual.getSchemaDefinition(), expected.getSchemaDefinition());
}


Expand All @@ -127,8 +134,9 @@ public void testEnableSchemaValidationEnforcedNoSchema() throws Exception {
admin.namespaces().setSchemaValidationEnforced(namespace,true);
try {
admin.schemas().getSchemaInfo(topicName);
fail();
} catch (PulsarAdminException.NotFoundException e) {
assertTrue(e.getMessage().contains("HTTP 404 Not Found"));
assertEquals(e.getMessage(), "Schema not found");
}
try (Producer p = pulsarClient.newProducer().topic(topicName).create()) {
p.send("test schemaValidationEnforced".getBytes());
Expand All @@ -147,8 +155,9 @@ public void testEnableSchemaValidationEnforcedHasSchemaMismatch() throws Excepti
admin.topics().getStats(topicName);
try {
admin.schemas().getSchemaInfo(topicName);
fail();
} catch (PulsarAdminException.NotFoundException e) {
assertTrue(e.getMessage().contains("HTTP 404 Not Found"));
assertEquals(e.getMessage(), "Schema not found");
}
Map<String, String> properties = new HashMap<>();
properties.put("key1", "value1");
Expand Down Expand Up @@ -177,8 +186,9 @@ public void testEnableSchemaValidationEnforcedHasSchemaMatch() throws Exception
assertFalse(admin.namespaces().getSchemaValidationEnforced(namespace));
try {
admin.schemas().getSchemaInfo(topicName);
fail();
} catch (PulsarAdminException.NotFoundException e) {
assertTrue(e.getMessage().contains("HTTP 404 Not Found"));
assertEquals(e.getMessage(), "Schema not found");
}
admin.namespaces().setSchemaValidationEnforced(namespace,true);
Map<String, String> properties = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.testng.annotations.Test;

@Test(groups = "broker-api")
public class TlsHostVerification extends TlsProducerConsumerBase {
public class TlsHostVerificationTest extends TlsProducerConsumerBase {

@Test
public void testTlsHostVerificationAdminClient() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.testng.annotations.Test;

@Test(groups = "broker-api")
public class TlsProducerConsumerBase extends ProducerConsumerBase {
public abstract class TlsProducerConsumerBase extends ProducerConsumerBase {
protected final String TLS_TRUST_CERT_FILE_PATH = "./src/test/resources/authentication/tls/cacert.pem";
protected final String TLS_CLIENT_CERT_FILE_PATH = "./src/test/resources/authentication/tls/client-cert.pem";
protected final String TLS_CLIENT_KEY_FILE_PATH = "./src/test/resources/authentication/tls/client-key.pem";
Expand Down