Skip to content
Open
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap;
import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaRegistryServerVersion;
import io.confluent.kafka.schemaregistry.client.rest.entities.requests.RegisterSchemaRequest;
import io.confluent.kafka.schemaregistry.client.rest.entities.requests.RegisterSchemaResponse;
import io.confluent.kafka.schemaregistry.utils.QualifiedSubject;
Expand Down Expand Up @@ -990,6 +991,12 @@ public SchemaRegistryDeployment getSchemaRegistryDeployment()
return restService.getSchemaRegistryDeployment();
}

@Override
public SchemaRegistryServerVersion getSchemaRegistryServerVersion()
throws IOException, RestClientException {
return restService.getSchemaRegistryServerVersion();
}

@Override
public Collection<String> getAllSubjects() throws IOException, RestClientException {
return restService.getAllSubjects();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.confluent.kafka.schemaregistry.client.rest.entities.Metadata;
import io.confluent.kafka.schemaregistry.client.rest.entities.RuleSet;
import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaRegistryDeployment;
import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaRegistryServerVersion;
import io.confluent.kafka.schemaregistry.client.rest.entities.requests.RegisterSchemaResponse;
import java.io.Closeable;
import java.io.IOException;
Expand Down Expand Up @@ -295,6 +296,11 @@ default SchemaRegistryDeployment getSchemaRegistryDeployment()
throw new UnsupportedOperationException();
}

default SchemaRegistryServerVersion getSchemaRegistryServerVersion()
throws IOException, RestClientException {
throw new UnsupportedOperationException();
}

public Collection<String> getAllSubjects() throws IOException, RestClientException;

default Collection<String> getAllSubjects(boolean lookupDeletedSubject) throws IOException,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import io.confluent.kafka.schemaregistry.client.rest.entities.RuleSet;
import io.confluent.kafka.schemaregistry.client.rest.entities.requests.RegisterSchemaRequest;
import io.confluent.kafka.schemaregistry.client.rest.entities.requests.RegisterSchemaResponse;
import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaRegistryDeployment;
import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaRegistryServerVersion;
import java.util.ArrayList;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -888,6 +891,44 @@ public void testMissingSchemaCache() throws Exception {
client.getId(SUBJECT_0, AVRO_SCHEMA_0);
}

@Test
public void testGetSchemaRegistryDeployment() throws Exception {
List<String> deploymentAttributes = new ArrayList<>(Collections.singleton("deploymentScope:opensource"));
SchemaRegistryDeployment expectedDeployment = new SchemaRegistryDeployment(deploymentAttributes);

expect(restService.getSchemaRegistryDeployment())
.andReturn(expectedDeployment);

replay(restService);

SchemaRegistryDeployment deployment = client.getSchemaRegistryDeployment();

assertNotNull(deployment);
assertEquals(expectedDeployment.getAttributes(), deployment.getAttributes());

verify(restService);
}

@Test
public void testGetSchemaRegistryServerVersion() throws Exception {
String version = "7.5.0";
String commitId = "abc123def456";
SchemaRegistryServerVersion expectedVersion = new SchemaRegistryServerVersion(version, commitId);

expect(restService.getSchemaRegistryServerVersion())
.andReturn(expectedVersion);

replay(restService);

SchemaRegistryServerVersion serverVersion = client.getSchemaRegistryServerVersion();

assertNotNull(serverVersion);
assertEquals(version, serverVersion.getVersion());
assertEquals(commitId, serverVersion.getCommitId());

verify(restService);
}


private static AvroSchema avroSchema(final int i) {
return new AvroSchema(avroSchemaString(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.confluent.kafka.schemaregistry.client.rest.entities.Schema;
import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaReference;
import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaRegistryDeployment;
import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaRegistryServerVersion;
import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaString;
import io.confluent.kafka.schemaregistry.client.rest.entities.ExtendedSchema;
import io.confluent.kafka.schemaregistry.client.rest.entities.SubjectVersion;
Expand All @@ -52,6 +53,7 @@
import io.confluent.kafka.schemaregistry.rest.VersionId;
import io.confluent.kafka.schemaregistry.rest.exceptions.Errors;
import io.confluent.kafka.schemaregistry.rest.exceptions.RestInvalidCompatibilityException;
import io.confluent.kafka.schemaregistry.utils.AppInfoParser;
import io.confluent.kafka.schemaregistry.utils.Props;
import io.confluent.kafka.schemaregistry.rest.exceptions.RestInvalidModeException;
import io.confluent.kafka.schemaregistry.storage.KafkaSchemaRegistry;
Expand Down Expand Up @@ -692,6 +694,12 @@ public SchemaRegistryDeployment getSchemaRegistryDeployment()
return Props.getSchemaRegistryDeployment(schemaRegistry.properties());
}

@Override
public SchemaRegistryServerVersion getSchemaRegistryServerVersion()
throws IOException, RestClientException {
return new SchemaRegistryServerVersion(AppInfoParser.getVersion(), AppInfoParser.getCommitId());
}

@Override
public void reset() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Props {

Check warning on line 25 in core/src/main/java/io/confluent/kafka/schemaregistry/utils/Props.java

View check run for this annotation

SonarQube-Confluent / schema-registry Sonarqube Results

core/src/main/java/io/confluent/kafka/schemaregistry/utils/Props.java#L25

Add a private constructor to hide the implicit public one.
public static final String PROPERTY_SCHEMA_REGISTRY_DEPLOYMENT_ATTRIBUTES
= "schema.registry.metadata.deployment.attributes";
private static final Logger log = LoggerFactory.getLogger(Props.class);
Expand All @@ -36,7 +36,7 @@
List<?> srDeploymentList = (List<?>) srDeployment;
// Validate and process each element
List<String> processedList = srDeploymentList.stream().map(
item -> item.toString().trim().toLowerCase()
item -> item.toString().trim()
).collect(Collectors.toList());
return new SchemaRegistryDeployment(processedList);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
import io.confluent.kafka.schemaregistry.client.rest.entities.Config;
import io.confluent.kafka.schemaregistry.client.rest.entities.Metadata;
import io.confluent.kafka.schemaregistry.client.rest.entities.Schema;
import io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException;
import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaRegistryDeployment;
import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaRegistryServerVersion;
import io.confluent.kafka.schemaregistry.rest.SchemaRegistryConfig;
import io.confluent.kafka.schemaregistry.rest.exceptions.RestInvalidSchemaException;
import io.confluent.kafka.schemaregistry.rest.exceptions.RestOperationNotPermittedException;
import io.confluent.kafka.schemaregistry.storage.KafkaSchemaRegistry;
import io.confluent.kafka.schemaregistry.storage.StoreUtils;
import io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer;
import io.confluent.kafka.schemaregistry.utils.Props;

import java.io.IOException;
import java.util.*;
Expand Down Expand Up @@ -214,4 +216,27 @@
Schema s2 = client.getByVersion(SUBJECT2, 1, false);
assertEquals(id2, s2.getId().intValue());
}

@Test
public void testGetSchemaRegistryDeployment() throws Exception {
Map<String, Object> props = new HashMap<>();
List<String> deploymentAttributes = new ArrayList<String>(Collections.singleton("deploymentScope:opensource"));

Check warning on line 223 in core/src/test/java/io/confluent/kafka/schemaregistry/rest/client/LocalSchemaRegistryClientTest.java

View check run for this annotation

SonarQube-Confluent / schema-registry Sonarqube Results

core/src/test/java/io/confluent/kafka/schemaregistry/rest/client/LocalSchemaRegistryClientTest.java#L223

Replace the type specification in this constructor call with the diamond operator ("<>"). (sonar.java.source not set. Assuming 7 or greater.)
props.put(Props.PROPERTY_SCHEMA_REGISTRY_DEPLOYMENT_ATTRIBUTES, deploymentAttributes);

SchemaRegistryDeployment deployment = client.getSchemaRegistryDeployment();

assertNotNull(deployment);
assertEquals(deployment.getAttributes(),
new ArrayList<String>(Collections.singleton("deploymentScope:opensource"))
);
}

@Test
public void testGetSchemaRegistryServerVersion() throws Exception {
SchemaRegistryServerVersion version = client.getSchemaRegistryServerVersion();

assertNotNull(version);
assertNotNull(version.getVersion());
assertNotNull(version.getCommitId());
}
}
Loading
Loading