schema = this.repository.findById(id);
- if (!schema.isPresent()) {
- throw new SchemaNotFoundException("Could not find Schema");
- }
- return new ResponseEntity<>(schema.get(), HttpStatus.OK);
- }
-
- /**
- *
- * Find by {@link Schema#getSubject() subject} and {@link Schema#getFormat() format}.
- *
- * @param subject the {@link Schema#getSubject() subject}, must not be
- * {@literal null}.
- * @param format the {@link Schema#getFormat() format}, must not be {@literal null}.
- * @return An {@link HttpStatus#OK} response populated with the list of {@link Schema
- * Schemas}, in ascending order by {@link Schema#getVersion() version}, that matched
- * the supplied {@link Schema#getSubject() subject} and {@link Schema#getFormat()
- * format}.
- * @deprecated use {@link #findBySubjectAndFormat(String, String)}
- * @see GH-1760
- */
- @Deprecated
- public ResponseEntity> findBySubjectAndVersion(@PathVariable("subject") String subject,
- @PathVariable("format") String format) {
- return findBySubjectAndFormatOrderByVersionAsc(subject, format);
- }
-
- /**
- * Find by {@link Schema#getSubject() subject} and {@link Schema#getFormat() format}.
- *
- * @param subject the {@link Schema#getSubject() subject}, must not be
- * {@literal null}.
- * @param format the {@link Schema#getFormat() format}, must not be {@literal null}.
- * @return An {@link HttpStatus#OK} response populated with the list of {@link Schema
- * Schemas}, in ascending order by {@link Schema#getVersion() version}, that matched
- * the supplied {@link Schema#getSubject() subject} and {@link Schema#getFormat()
- * format}.
- *
- * @since 3.0.0
- */
- @GetMapping(produces = APPLICATION_JSON_VALUE, path = "/{subject}/{format}")
- @NonNull
- public ResponseEntity> findBySubjectAndFormat(@NonNull @PathVariable("subject") final String subject,
- @NonNull @PathVariable("format") final String format) {
- return findBySubjectAndFormatOrderByVersionAsc(subject, format);
- }
-
- @RequestMapping(value = "/{subject}/{format}/v{version}", method = RequestMethod.DELETE)
- public void delete(@PathVariable("subject") String subject,
- @PathVariable("format") String format,
- @PathVariable("version") Integer version) {
- if (this.schemaServerProperties.isAllowSchemaDeletion()) {
- Schema schema = this.repository.findOneBySubjectAndFormatAndVersion(subject,
- format, version);
- deleteSchema(schema);
- }
- else {
- throw new SchemaDeletionNotAllowedException();
- }
- }
-
- @RequestMapping(value = "/schemas/{id}", method = RequestMethod.DELETE)
- public void delete(@PathVariable("id") Integer id) {
- if (this.schemaServerProperties.isAllowSchemaDeletion()) {
- Optional schema = this.repository.findById(id);
- if (!schema.isPresent()) {
- throw new SchemaNotFoundException("Could not find Schema");
- }
- deleteSchema(schema.get());
- }
- else {
- throw new SchemaDeletionNotAllowedException();
- }
- }
-
- @RequestMapping(value = "/{subject}", method = RequestMethod.DELETE)
- public void delete(@PathVariable("subject") String subject) {
- if (this.schemaServerProperties.isAllowSchemaDeletion()) {
- for (Schema schema : this.repository.findAll()) {
- if (schema.getSubject().equals(subject)) {
- deleteSchema(schema);
- }
- }
- }
- else {
- throw new SchemaDeletionNotAllowedException();
- }
-
- }
-
- @NonNull
- final ResponseEntity> findBySubjectAndFormatOrderByVersionAsc(@NonNull final String subject,
- @NonNull final String format) {
- List schemas = this.repository.findBySubjectAndFormatOrderByVersion(subject, format);
- if (schemas.isEmpty()) {
- throw new SchemaNotFoundException(
- String.format("No schemas found for subject %s and format %s", subject, format));
- }
- return new ResponseEntity<>(schemas, HttpStatus.OK);
- }
-
- private void deleteSchema(Schema schema) {
- if (schema == null) {
- throw new SchemaNotFoundException("Could not find Schema");
- }
- this.repository.delete(schema);
- }
-
- @ExceptionHandler(UnsupportedFormatException.class)
- @ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "Format not supported")
- public void unsupportedFormat(UnsupportedFormatException ex) {
- }
-
- @ExceptionHandler(InvalidSchemaException.class)
- @ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "Invalid schema")
- public void invalidSchema(InvalidSchemaException ex) {
- }
-
- @ExceptionHandler(SchemaNotFoundException.class)
- @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Schema not found")
- public void schemaNotFound(SchemaNotFoundException ex) {
- }
-
- @ExceptionHandler(SchemaDeletionNotAllowedException.class)
- @ResponseStatus(value = HttpStatus.METHOD_NOT_ALLOWED, reason = "Schema deletion is not permitted")
- public void schemaDeletionNotPermitted(SchemaDeletionNotAllowedException ex) {
- }
-
-}
diff --git a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/model/Compatibility.java b/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/model/Compatibility.java
deleted file mode 100644
index 46c13a7a1..000000000
--- a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/model/Compatibility.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema.server.model;
-
-/**
- * @author Vinicius Carvalho
- */
-public enum Compatibility {
-
- /**
- * Backward compatibiltity.
- */
- BACKWARD,
-
- /**
- * Forward compatibility.
- */
- FORWARD,
-
- /**
- * Full compatibility.
- */
- FULL,
-
- /**
- * Lack of compatibility.
- */
- INCOMPATIBLE;
-
-}
diff --git a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/model/Schema.java b/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/model/Schema.java
deleted file mode 100644
index 250896c8d..000000000
--- a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/model/Schema.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema.server.model;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.Table;
-
-/**
- * @author Vinicius Carvalho
- *
- * Represents a persisted schema entity.
- */
-@Entity
-@Table(name = "SCHEMA_REPOSITORY")
-public class Schema {
-
- @Id
- @GeneratedValue
- @Column(name = "ID")
- private Integer id;
-
- @Column(name = "VERSION", nullable = false)
- private Integer version;
-
- @Column(name = "SUBJECT", nullable = false)
- private String subject;
-
- @Column(name = "FORMAT", nullable = false)
- private String format;
-
- @Lob
- @Column(name = "DEFINITION", nullable = false, length = 8192)
- private String definition;
-
- public Integer getId() {
- return this.id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public Integer getVersion() {
- return this.version;
- }
-
- public void setVersion(Integer version) {
- this.version = version;
- }
-
- public String getSubject() {
- return this.subject;
- }
-
- public void setSubject(String subject) {
- this.subject = subject;
- }
-
- public String getFormat() {
- return this.format;
- }
-
- public void setFormat(String format) {
- this.format = format;
- }
-
- public String getDefinition() {
- return this.definition;
- }
-
- public void setDefinition(String definition) {
- this.definition = definition;
- }
-
-}
diff --git a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/repository/SchemaRepository.java b/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/repository/SchemaRepository.java
deleted file mode 100644
index 9fb8ad4ae..000000000
--- a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/repository/SchemaRepository.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema.server.repository;
-
-import java.util.List;
-
-import org.springframework.cloud.stream.schema.server.model.Schema;
-import org.springframework.data.repository.PagingAndSortingRepository;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * @author Vinicius Carvalho
- */
-public interface SchemaRepository extends PagingAndSortingRepository {
-
- @Transactional
- List findBySubjectAndFormatOrderByVersion(String subject, String format);
-
- @Transactional
- Schema findOneBySubjectAndFormatAndVersion(String subject, String format,
- Integer version);
-
-}
diff --git a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/AvroSchemaValidator.java b/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/AvroSchemaValidator.java
deleted file mode 100644
index 0af3f5a64..000000000
--- a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/AvroSchemaValidator.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema.server.support;
-
-import java.util.List;
-
-import org.apache.avro.SchemaParseException;
-
-import org.springframework.cloud.stream.schema.server.model.Compatibility;
-import org.springframework.cloud.stream.schema.server.model.Schema;
-
-/**
- * @author Vinicius Carvalho
- */
-public class AvroSchemaValidator implements SchemaValidator {
-
- @Override
- public boolean isValid(String definition) {
- boolean result = true;
- try {
- new org.apache.avro.Schema.Parser().parse(definition);
- }
- catch (SchemaParseException ex) {
- result = false;
- }
- return result;
- }
-
- @Override
- public Compatibility compatibilityCheck(String source, String other) {
- return null;
- }
-
- @Override
- public Schema match(List schemas, String definition) {
- Schema result = null;
- org.apache.avro.Schema source = new org.apache.avro.Schema.Parser()
- .parse(definition);
- for (Schema s : schemas) {
- org.apache.avro.Schema target = new org.apache.avro.Schema.Parser()
- .parse(s.getDefinition());
- if (target.equals(source)) {
- result = s;
- break;
- }
- }
- return result;
- }
-
- @Override
- public String getFormat() {
- return "avro";
- }
-
-}
diff --git a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/InvalidSchemaException.java b/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/InvalidSchemaException.java
deleted file mode 100644
index c53a523db..000000000
--- a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/InvalidSchemaException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema.server.support;
-
-/**
- * @author Vinicius Carvalho
- */
-public class InvalidSchemaException extends RuntimeException {
-
- public InvalidSchemaException(String message) {
- super(message);
- }
-
-}
diff --git a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/SchemaDeletionNotAllowedException.java b/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/SchemaDeletionNotAllowedException.java
deleted file mode 100644
index 61709632d..000000000
--- a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/SchemaDeletionNotAllowedException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema.server.support;
-
-/**
- * @author Ilayaperumal Gopinathan
- */
-public class SchemaDeletionNotAllowedException extends RuntimeException {
-
- public SchemaDeletionNotAllowedException(String message) {
- super(message);
- }
-
- public SchemaDeletionNotAllowedException() {
- super("Schema Deletion Not Allowed");
- }
-
-}
diff --git a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/SchemaNotFoundException.java b/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/SchemaNotFoundException.java
deleted file mode 100644
index b8f1d4784..000000000
--- a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/SchemaNotFoundException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema.server.support;
-
-/**
- * @author Vinicius Carvalho
- */
-public class SchemaNotFoundException extends RuntimeException {
-
- public SchemaNotFoundException(String message) {
- super(message);
- }
-
-}
diff --git a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/SchemaValidator.java b/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/SchemaValidator.java
deleted file mode 100644
index 81067a82a..000000000
--- a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/SchemaValidator.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema.server.support;
-
-import java.util.List;
-
-import org.springframework.cloud.stream.schema.server.model.Compatibility;
-import org.springframework.cloud.stream.schema.server.model.Schema;
-
-/**
- * @author Vinicius Carvalho
- *
- * Provides utility methods to validate, check compatibility and match schemas of
- * different implementations
- */
-public interface SchemaValidator {
-
- /**
- * Verifies if a definition is a valid schema.
- * @param definition - The textual representation of the schema file
- * @return true if valid, false otherwise
- */
- boolean isValid(String definition);
-
- /**
- * Checks for compatibility between two schemas @see Compatibility class for types
- * This method may not be supported for certain formats.
- * @param source - The textual representation of the schema to tested
- * @param other - The textual representation of the other schema to tested
- * @return {@link Compatibility}
- */
- Compatibility compatibilityCheck(String source, String other);
-
- /**
- * Return the Schema that is represented by the definition.
- * @param schemas List of schemas to be tested
- * @param definition Textual representation of the schema
- * @return A full Schema object with identifier and subject properties
- */
- Schema match(List schemas, String definition);
-
- String getFormat();
-
-}
diff --git a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/UnsupportedFormatException.java b/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/UnsupportedFormatException.java
deleted file mode 100644
index 2c2bf85e7..000000000
--- a/spring-cloud-stream-schema-server/src/main/java/org/springframework/cloud/stream/schema/server/support/UnsupportedFormatException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema.server.support;
-
-/**
- * @author Vinicius Carvalho
- */
-public class UnsupportedFormatException extends RuntimeException {
-
- public UnsupportedFormatException(String message) {
- super(message);
- }
-
-}
diff --git a/spring-cloud-stream-schema-server/src/main/resources/META-INF/spring.factories b/spring-cloud-stream-schema-server/src/main/resources/META-INF/spring.factories
deleted file mode 100644
index 8b1378917..000000000
--- a/spring-cloud-stream-schema-server/src/main/resources/META-INF/spring.factories
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/spring-cloud-stream-schema-server/src/main/resources/application.yml b/spring-cloud-stream-schema-server/src/main/resources/application.yml
deleted file mode 100644
index a5aad28b1..000000000
--- a/spring-cloud-stream-schema-server/src/main/resources/application.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-spring:
- application:
- name: SchemaRegistryServer
-server:
- port: 8990
-
diff --git a/spring-cloud-stream-schema-server/src/test/java/org/springframework/cloud/stream/schema/server/controllers/SchemaRegistryServerAvroTests.java b/spring-cloud-stream-schema-server/src/test/java/org/springframework/cloud/stream/schema/server/controllers/SchemaRegistryServerAvroTests.java
deleted file mode 100644
index d63b5d77b..000000000
--- a/spring-cloud-stream-schema-server/src/test/java/org/springframework/cloud/stream/schema/server/controllers/SchemaRegistryServerAvroTests.java
+++ /dev/null
@@ -1,594 +0,0 @@
-/*
- * Copyright 2016-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema.server.controllers;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.stream.Stream;
-
-import org.apache.avro.Schema.Parser;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.web.ServerProperties;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.web.client.TestRestTemplate;
-import org.springframework.boot.web.server.Ssl;
-import org.springframework.cloud.stream.schema.server.config.SchemaServerProperties;
-import org.springframework.cloud.stream.schema.server.model.Schema;
-import org.springframework.cloud.stream.schema.server.support.SchemaNotFoundException;
-import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.RequestEntity;
-import org.springframework.http.ResponseEntity;
-import org.springframework.lang.NonNull;
-import org.springframework.lang.Nullable;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.web.util.UriComponentsBuilder;
-
-import static java.util.stream.Collectors.toList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD;
-
-/**
- * @author Vinicius Carvalho
- * @author Ilayaperumal Gopinathan
- */
-@RunWith(SpringRunner.class)
-// @checkstyle:off
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, properties = "spring.main.allow-bean-definition-overriding=true")
-// @checkstyle:on
-@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
-public class SchemaRegistryServerAvroTests {
-
- private static final String AVRO_FORMAT_NAME = "avro";
-
- private static final String AVRO_USER_DEFINITION_SCHEMA_V1 = "{\"namespace\": \"example.avro\",\n"
- + " \"type\": \"record\",\n" + " \"name\": \"User\",\n" + " \"fields\": [\n"
- + " {\"name\": \"name\", \"type\": \"string\"},\n"
- + " {\"name\": \"favorite_number\", \"type\": [\"int\", \"null\"]}\n"
- + " ]\n" + "}";
-
- private static final String AVRO_USER_DEFINTITION_SCHEMA_V2 = "{\"namespace\": \"example.avro\",\n"
- + " \"type\": \"record\",\n" + " \"name\": \"User\",\n" + " \"fields\": [\n"
- + " {\"name\": \"name\", \"type\": \"string\"},\n"
- + " {\"name\": \"favorite_number\", \"type\": [\"int\", \"null\"]},\n"
- + " {\"name\": \"favorite_color\", \"type\": [\"string\", \"null\"]}\n"
- + " ]\n" + "}";
-
- private static final org.apache.avro.Schema AVRO_USER_AVRO_SCHEMA_V1 = new Parser()
- .parse(AVRO_USER_DEFINITION_SCHEMA_V1);
-
- private static final org.apache.avro.Schema AVRO_USER_AVRO_SCHEMA_V2 = new Parser()
- .parse(AVRO_USER_DEFINTITION_SCHEMA_V2);
-
- private static final String AVRO_USER_SCHEMA_DEFAULT_NAME_STRATEGY_SUBJECT = AVRO_USER_AVRO_SCHEMA_V1.getName()
- .toLowerCase();
-
-
- private static final String AVRO_USER_SCHEMA_QUALIFED_NAME_STRATEGY_SUBJECT = AVRO_USER_AVRO_SCHEMA_V1
- .getFullName()
- .toLowerCase();
-
- private static final Schema AVRO_USER_REGISTRY_SCHEMA_V1 = toSchema(
- AVRO_USER_SCHEMA_DEFAULT_NAME_STRATEGY_SUBJECT,
- AVRO_FORMAT_NAME, AVRO_USER_AVRO_SCHEMA_V1.toString());
-
- private static final Schema AVRO_USER_REGISTRY_SCHEMA_V2 = toSchema(
- AVRO_USER_SCHEMA_DEFAULT_NAME_STRATEGY_SUBJECT,
- AVRO_FORMAT_NAME, AVRO_USER_AVRO_SCHEMA_V2.toString());
-
- private static final Schema AAVRO_USER_REGISTRY_SCHEMA_V1_WITH_QUAL_SUBJECT = toSchema(
- AVRO_USER_SCHEMA_QUALIFED_NAME_STRATEGY_SUBJECT,
- AVRO_FORMAT_NAME, AVRO_USER_AVRO_SCHEMA_V1.toString());
- @Autowired
- private TestRestTemplate client;
-
- @Autowired
- private SchemaServerProperties schemaServerProperties;
-
- @Autowired
- private ServerController serverController;
-
- @Autowired
- private ServerProperties serverProperties;
-
- private URI serverControllerUri;
-
- @Before
- public void setUp() {
-
- String scheme = Optional.ofNullable(this.serverProperties.getSsl())
- .filter(Ssl::isEnabled)
- .map(ssl -> "https").orElse("http");
-
- Integer port = this.serverProperties.getPort();
- String contextPath = this.serverProperties.getServlet().getContextPath();
-
- this.serverControllerUri = UriComponentsBuilder.newInstance().scheme(scheme)
- .host("localhost")
- .port(port)
- .path(contextPath).build().toUri();
-
- }
-
- @NonNull
- static Schema toSchema(String subject, String format, String definition) {
- Schema schema = new Schema();
- schema.setSubject(subject);
- schema.setFormat(format);
- schema.setDefinition(definition);
- return schema;
- }
-
- @Test
- public void testUnsupportedFormat() throws Exception {
- Schema schema = new Schema();
- schema.setFormat("spring");
- schema.setSubject("boot");
- ResponseEntity response = this.client
- .postForEntity(this.serverControllerUri, schema, Schema.class);
- assertThat(response.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
- }
-
- @Test
- public void testInvalidSchema() throws Exception {
- Schema schema = new Schema();
- schema.setFormat(AVRO_FORMAT_NAME);
- schema.setSubject("boot");
- schema.setDefinition("{}");
- ResponseEntity response = this.client
- .postForEntity(this.serverControllerUri, schema, Schema.class);
- assertThat(response.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
- }
-
- @Test
- public void testRegister1AvroSchema() {
-
- Schema schema = new Schema();
- schema.setFormat(AVRO_FORMAT_NAME);
- schema.setSubject("org.springframework.cloud.stream.schema.User");
- schema.setDefinition(SchemaRegistryServerAvroTests.AVRO_USER_DEFINITION_SCHEMA_V1);
-
- registerSchemaAndAssertSuccess(schema, 1, 1);
-
- }
-
- @Test
- public void testFindByIdFound() {
-
- ResponseEntity registerSchemaReponse = registerSchemaAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1, 1, 1);
-
- Schema registeredSchema = registerSchemaReponse.getBody();
-
- URI findByIdUriId1 = this.serverControllerUri.resolve("/schemas/" + registeredSchema.getId());
-
- ResponseEntity findByIdResponse = this.client
- .getForEntity(findByIdUriId1, Schema.class);
-
- assertThat(findByIdResponse.getStatusCode().is2xxSuccessful()).isTrue();
-
- Schema actual = findByIdResponse.getBody();
- assertSchema(registeredSchema, actual);
- }
-
- @Test
- public void testFindByIdNotFound() {
-
- registerSchemaAndAssertSuccess(AVRO_USER_REGISTRY_SCHEMA_V1, 1, 1);
-
- URI findByIdUriId1 = this.serverControllerUri.resolve("/schemas/" + 2);
-
- ResponseEntity response = this.client
- .getForEntity(findByIdUriId1, Schema.class);
-
- final HttpStatus statusCode = response.getStatusCode();
-
- assertThat(statusCode).isEqualTo(HttpStatus.NOT_FOUND);
-
- }
- @Test
- public void testUserSchemaV2() {
-
- registerSchemasAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1,
- AVRO_USER_REGISTRY_SCHEMA_V2);
- }
-
- @Test
- public void testIdempotentRegistration() {
-
- registerSchemaAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1, 1, 1);
-
-
- registerSchemaAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1, 1, 1);
-
- }
-
- @Test
- public void testSchemaNotfound() throws Exception {
- ResponseEntity response = this.client
- .getForEntity("http://localhost:8990/foo/avro/v42", Schema.class);
- assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
- }
-
- @Test
- public void testSchemaDeletionBySubjectFormatVersion() throws Exception {
-
- ResponseEntity registerSchemaAndAssertSuccess = registerSchemaAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1, 1, 1);
-
- this.schemaServerProperties.setAllowSchemaDeletion(true);
-
- URI subjectFormatVersionUri = this.serverControllerUri
- .resolve(registerSchemaAndAssertSuccess.getHeaders().getLocation());
-
-
- ResponseEntity deleteResponse = this.client.exchange(
- new RequestEntity<>(HttpMethod.DELETE, subjectFormatVersionUri),
- Void.class);
-
- assertThat(deleteResponse.getStatusCode()).isEqualTo(HttpStatus.OK);
-
- ResponseEntity findBySubjectFormatVersionUriResponse = this.client
- .getForEntity(subjectFormatVersionUri, Schema.class);
-
- assertThat(findBySubjectFormatVersionUriResponse.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
- }
-
- @Test
- public void testSchemaDeletionBySubjectFormatVersionNotFound() throws Exception {
-
- ResponseEntity registerSchemaAndAssertSuccess = registerSchemaAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1, 1, 1);
-
- this.schemaServerProperties.setAllowSchemaDeletion(true);
-
- URI subjectFormatVersionUri = this.serverControllerUri
- .resolve(registerSchemaAndAssertSuccess.getHeaders().getLocation().toString().replace("v1", "v100"));
-
- ResponseEntity deleteResponse = this.client.exchange(
- new RequestEntity<>(HttpMethod.DELETE, subjectFormatVersionUri),
- Void.class);
-
- assertThat(deleteResponse.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
-
- }
-
- @Test
- public void testSchemaDeletionBySubjectFormatVersionNotAllowed() throws Exception {
-
- ResponseEntity registerSchemaAndAssertSuccess = registerSchemaAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1, 1, 1);
-
- URI versionUri = this.serverControllerUri
- .resolve(registerSchemaAndAssertSuccess.getHeaders().getLocation());
-
- ResponseEntity deleteResponse = this.client.exchange(new RequestEntity<>(HttpMethod.DELETE, versionUri),
- Void.class);
-
- assertThat(deleteResponse.getStatusCode()).isEqualTo(HttpStatus.METHOD_NOT_ALLOWED);
-
- }
-
- @Test
- public void testSchemaDeletionById() throws Exception {
-
-
- ResponseEntity registerSchemaAndAssertSuccess = registerSchemaAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1, 1, 1);
-
- this.schemaServerProperties.setAllowSchemaDeletion(true);
- this.client.delete(this.serverControllerUri
- .resolve("/schemas/" + registerSchemaAndAssertSuccess.getBody().getVersion()));
-
- ResponseEntity response3 = this.client
- .getForEntity(registerSchemaAndAssertSuccess.getHeaders().getLocation(), Schema.class);
- assertThat(response3.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
-
- }
-
- @Test
- public void testSchemaDeletionByIdNotFound() throws Exception {
-
- registerSchemaAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1, 1, 1);
-
- this.schemaServerProperties.setAllowSchemaDeletion(true);
-
- ResponseEntity deleteByIdResponse = this.client.exchange(
- new RequestEntity<>(HttpMethod.DELETE, this.serverControllerUri
- .resolve("/schemas/" + 2)),
- Void.class);
-
- assertThat(deleteByIdResponse.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
- }
-
- @Test
- public void testSchemaDeletionByIdNotAllowed() throws Exception {
-
- ResponseEntity registerSchemaAndAssertSuccess = registerSchemaAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1, 1, 1);
-
- URI schemaIdUri = this.serverControllerUri
- .resolve(this.serverControllerUri
- .resolve("/schemas/" + registerSchemaAndAssertSuccess.getBody().getVersion()));
-
- ResponseEntity exchange = this.client.exchange(new RequestEntity<>(HttpMethod.DELETE, schemaIdUri),
- Void.class);
-
- assertThat(exchange.getStatusCode()).isEqualTo(HttpStatus.METHOD_NOT_ALLOWED);
- }
-
- @Test
- public void testSchemaDeletionBySubject() {
- Map>>> registerSchemaResponsesByFormatBySubject = registerSchemasAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1,
- AVRO_USER_REGISTRY_SCHEMA_V2, AAVRO_USER_REGISTRY_SCHEMA_V1_WITH_QUAL_SUBJECT);
-
- this.schemaServerProperties.setAllowSchemaDeletion(true);
-
- registerSchemaResponsesByFormatBySubject.forEach((subject, registerSchemaResponsesByFormat) -> {
-
- assertThat(registerSchemaResponsesByFormat).isNotEmpty();
- ResponseEntity deleteBySubject = this.client.exchange(
- new RequestEntity<>(HttpMethod.DELETE, this.serverControllerUri
- .resolve("/" + subject)),
- Void.class);
-
- assertThat(deleteBySubject.getStatusCode()).isEqualTo(HttpStatus.OK);
-
- registerSchemaResponsesByFormat.forEach((format, registerSchemaResponses) -> {
-
- assertThat(registerSchemaResponses).isNotEmpty();
-
- registerSchemaResponses.forEach(registerSchemaResponse -> {
-
- ResponseEntity shouldBe404Response = this.client.getForEntity(
- registerSchemaResponse.getHeaders().getLocation(),
- Schema.class);
-
- assertThat(shouldBe404Response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
-
- });
- });
- });
-
- }
-
- @Test
- public void testSchemaDeletionBySubjectNotFound() throws Exception {
-
- registerSchemaAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1, 1, 1);
-
- this.schemaServerProperties.setAllowSchemaDeletion(true);
-
- ResponseEntity deleteBySubject = this.client.exchange(
- new RequestEntity<>(HttpMethod.DELETE, this.serverControllerUri
- .resolve("/foo")),
- Void.class);
-
- assertThat(deleteBySubject.getStatusCode())
- .isEqualTo(HttpStatus.OK);
-
-
- }
-
- @Test
- public void testSchemaDeletionBySubjectNotAllowed() throws Exception {
-
- ResponseEntity registerSchemaAndAssertSuccess = registerSchemaAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1, 1, 1);
-
- Schema schema = registerSchemaAndAssertSuccess.getBody();
-
- ResponseEntity deleteBySubject = this.client.exchange(
- new RequestEntity<>(HttpMethod.DELETE, this.serverControllerUri
- .resolve("/" + schema.getSubject())),
- Void.class);
-
- assertThat(deleteBySubject.getStatusCode())
- .isEqualTo(HttpStatus.METHOD_NOT_ALLOWED);
-
- }
-
- @Test
- public void testFindSchemasBySubjectAndVersion() {
-
- Map>>> registerSchemaResponsesByFormatBySubject = registerSchemasAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1,
- AVRO_USER_REGISTRY_SCHEMA_V2);
-
- registerSchemaResponsesByFormatBySubject.forEach((subject, schemasByFormat) -> {
-
- assertThat(schemasByFormat).hasSize(1);
-
- schemasByFormat.forEach((format, schemas) -> {
- assertThat(schemas).hasSize(2);
-
- @SuppressWarnings("deprecation")
- final ResponseEntity> findBySubjectAndVersionResponseEntity = this.serverController
- .findBySubjectAndVersion(subject, format);
-
- assertThat(findBySubjectAndVersionResponseEntity.getStatusCode().is2xxSuccessful()).isTrue();
-
- final List schemaResponseBody = findBySubjectAndVersionResponseEntity.getBody();
-
- assertThat(schemaResponseBody)
- .zipSatisfy(schemas.stream().map(ResponseEntity::getBody)
- .collect(toList()), this::assertSchema);
-
- });
- });
-
- }
-
- @Test
- public void testFindBySubjectAndFormatOrderByVersionAscNoMatch() {
- String subject = "test";
-
- String format = AVRO_FORMAT_NAME;
-
- assertThatExceptionOfType(SchemaNotFoundException.class).isThrownBy(() -> this.serverController
- .findBySubjectAndFormatOrderByVersionAsc(subject, format))
- .withMessage("No schemas found for subject %s and format %s", subject, format)
- .withNoCause();
-
-
- }
-
- @Test
- public void testFindSchemasBySubjectAndFormat() {
-
- Map>>> registerSchemaResponsesByFormatBySubject = registerSchemasAndAssertSuccess(
- AVRO_USER_REGISTRY_SCHEMA_V1,
- AVRO_USER_REGISTRY_SCHEMA_V2);
-
- registerSchemaResponsesByFormatBySubject.forEach((subject, schemasByFormat) -> {
-
- assertThat(schemasByFormat).hasSize(1);
-
- schemasByFormat.forEach((format, schemas) -> {
- assertThat(schemas).hasSize(2);
-
- ResponseEntity> findBySubjectFormatResponse = this.client.exchange(
- this.serverControllerUri.resolve("/" + subject + "/" + format), HttpMethod.GET, null,
- new ParameterizedTypeReference>() {
- });
-
- assertThat(findBySubjectFormatResponse.getStatusCode().is2xxSuccessful()).isTrue();
-
- final List schemaResponseBody = findBySubjectFormatResponse.getBody();
-
- assertThat(schemaResponseBody)
- .zipSatisfy(schemas.stream().map(ResponseEntity::getBody)
- .collect(toList()), this::assertSchema);
-
- });
- });
-
- }
-
- private Map>>> registerSchemasAndAssertSuccess(
- @NonNull Schema... schemas) {
- Map> versionsByFormatAndSubject = new HashMap<>();
- Map>>> result = new HashMap<>();
- int numOfSchemas = schemas.length;
- int id = 0;
- for (int i = 0; i < numOfSchemas; i++) {
- Schema schema = schemas[i];
- id++;
- String format = schema.getFormat();
- String subject = schema.getSubject();
- Integer version = versionsByFormatAndSubject
- .compute(subject,
- (_subject, currentValue) -> currentValue == null ? new HashMap<>() : currentValue)
- .merge(format, 1, Integer::sum);
- ResponseEntity registerSchemaResponse = registerSchemaAndAssertSuccess(schema, version, id);
- result.compute(subject,
- (_subject, currentValue) -> currentValue == null ? new HashMap<>() : currentValue)
-
- .compute(format, (_format, currentValue) -> {
- List> value = currentValue == null ? new ArrayList<>() : currentValue;
- value.add(registerSchemaResponse);
- return value;
- });
- }
- Stream> asStream = result.entrySet().stream()
- .map(Entry::getValue)
- .map(Map::entrySet)
- .flatMap(Collection::stream)
- .map(Entry::getValue)
- .flatMap(Collection::stream);
- assertThat(asStream).hasSize(numOfSchemas);
- return result;
-
- }
-
- @NonNull
- private ResponseEntity registerSchemaAndAssertSuccess(@NonNull Schema schema,
- @Nullable Integer expectedVersion,
- @Nullable Integer expectedId) {
-
- ResponseEntity registerReponse = this.client
- .postForEntity(this.serverControllerUri, schema, Schema.class);
-
- HttpStatus statusCode = registerReponse.getStatusCode();
- assertThat(statusCode.is2xxSuccessful()).isTrue();
-
- Schema registeredSchema = registerReponse.getBody();
- assertSchema(schema, expectedVersion, expectedId, registeredSchema);
-
- HttpHeaders headers = registerReponse.getHeaders();
- assertLocation(headers, registeredSchema);
-
- return registerReponse;
- }
-
- private void assertLocation(HttpHeaders headers, Schema registeredSchema) {
- URI location = headers.getLocation();
-
- assertThat(location).isNotNull();
- assertPersisted(location, registeredSchema);
- }
-
- private void assertPersisted(URI location, Schema registeredSchema) {
-
- ResponseEntity findOneResponse = this.client.getForEntity(location,
- Schema.class);
-
- HttpStatus statusCode = findOneResponse.getStatusCode();
- assertThat(statusCode.is2xxSuccessful()).isTrue();
-
- Schema actual = findOneResponse.getBody();
- assertSchema(registeredSchema, registeredSchema.getVersion(), registeredSchema.getId(), actual);
-
- }
-
- private void assertSchema(@NonNull Schema expected, @NonNull Schema actual) {
-
- assertSchema(expected, expected.getVersion(), expected.getId(), actual);
- }
-
- private void assertSchema(@NonNull Schema expected, Integer expectedVersion, Integer expectedId,
- @NonNull Schema actual) {
-
- assertThat(actual).isEqualToIgnoringGivenFields(expected, "version", "id");
- if (expectedVersion != null) {
- assertThat(actual.getVersion()).isEqualTo(expectedVersion);
- }
- if (expectedId != null) {
- assertThat(actual.getId()).isEqualTo(expectedId);
- }
- }
-}
diff --git a/spring-cloud-stream-schema-server/src/test/java/org/springframework/cloud/stream/schema/server/entityScanning/EntityScanningTests.java b/spring-cloud-stream-schema-server/src/test/java/org/springframework/cloud/stream/schema/server/entityScanning/EntityScanningTests.java
deleted file mode 100644
index 3dad37920..000000000
--- a/spring-cloud-stream-schema-server/src/test/java/org/springframework/cloud/stream/schema/server/entityScanning/EntityScanningTests.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema.server.entityScanning;
-
-import org.junit.Test;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.cloud.stream.schema.server.EnableSchemaRegistryServer;
-import org.springframework.context.ConfigurableApplicationContext;
-
-/**
- * @author Marius Bogoevici
- */
-public class EntityScanningTests {
-
- @Test
- public void testApplicationWithEmbeddedSchemaRegistryServerOutsideOfRootPackage()
- throws Exception {
- final ConfigurableApplicationContext context = SpringApplication
- .run(CustomApplicationEmbeddingSchemaServer.class, "--server.port=0");
- context.close();
- }
-
- @EnableAutoConfiguration
- @EnableSchemaRegistryServer
- public static class CustomApplicationEmbeddingSchemaServer {
-
- }
-
-}
diff --git a/spring-cloud-stream-schema-server/src/test/java/org/springframework/cloud/stream/schema/server/entityScanning/EntityScanningTestsWithEntityScan.java b/spring-cloud-stream-schema-server/src/test/java/org/springframework/cloud/stream/schema/server/entityScanning/EntityScanningTestsWithEntityScan.java
deleted file mode 100644
index 7742f05d0..000000000
--- a/spring-cloud-stream-schema-server/src/test/java/org/springframework/cloud/stream/schema/server/entityScanning/EntityScanningTestsWithEntityScan.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema.server.entityScanning;
-
-import org.junit.Test;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.autoconfigure.domain.EntityScan;
-import org.springframework.cloud.stream.schema.server.EnableSchemaRegistryServer;
-import org.springframework.context.ConfigurableApplicationContext;
-
-/**
- * @author Marius Bogoevici
- */
-public class EntityScanningTestsWithEntityScan {
-
- @Test
- public void testApplicationWithEmbeddedSchemaRegistryServerOutsideOfRootPackage()
- throws Exception {
- final ConfigurableApplicationContext context = SpringApplication
- .run(CustomApplicationEmbeddingSchemaServer.class, "--server.port=0");
- context.close();
- }
-
- @EnableAutoConfiguration
- @EnableSchemaRegistryServer
- @EntityScan(basePackages = "org.springframework.cloud.stream.schema.server.entityScanning.domain")
- public static class CustomApplicationEmbeddingSchemaServer {
-
- }
-
-}
diff --git a/spring-cloud-stream-schema-server/src/test/java/org/springframework/cloud/stream/schema/server/entityScanning/domain/TestEntity.java b/spring-cloud-stream-schema-server/src/test/java/org/springframework/cloud/stream/schema/server/entityScanning/domain/TestEntity.java
deleted file mode 100644
index 2c65ba6af..000000000
--- a/spring-cloud-stream-schema-server/src/test/java/org/springframework/cloud/stream/schema/server/entityScanning/domain/TestEntity.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema.server.entityScanning.domain;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-
-/**
- * @author Marius Bogoevici
- */
-@Entity
-public class TestEntity {
-
- @Id
- private long id;
-
- @Column(name = "name")
- private String name;
-
- public long getId() {
- return this.id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-}
diff --git a/spring-cloud-stream-schema/.jdk8 b/spring-cloud-stream-schema/.jdk8
deleted file mode 100644
index e69de29bb..000000000
diff --git a/spring-cloud-stream-schema/pom.xml b/spring-cloud-stream-schema/pom.xml
deleted file mode 100644
index 307f2c5a0..000000000
--- a/spring-cloud-stream-schema/pom.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-
-
-
- spring-cloud-stream-parent
- org.springframework.cloud
- 3.0.0.BUILD-SNAPSHOT
-
- 4.0.0
-
- spring-cloud-stream-schema
-
- 1.8.1
-
-
-
-
- org.springframework.cloud
- spring-cloud-stream
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-configuration-processor
- true
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.apache.avro
- avro
- ${avro.version}
- true
-
-
- org.springframework.cloud
- spring-cloud-stream-test-support
- test
-
-
- org.springframework.cloud
- spring-cloud-stream-test-support-internal
- test
-
-
- org.springframework.cloud
- spring-cloud-stream-schema-server
- test
-
-
- com.fasterxml.jackson.dataformat
- jackson-dataformat-avro
- test
-
-
-
-
-
- org.apache.avro
- avro-maven-plugin
- ${avro.version}
-
-
- generate-test-sources
-
- schema
-
-
-
-
- ${project.basedir}/target/generated-test-sources
-
-
- ${project.basedir}/target/generated-test-sources
-
- ${project.basedir}/src/test/resources/schemas
-
-
- **/*.avsc
-
-
-
- ${project.basedir}/src/test/resources/schemas/imports/Email.avsc
-
-
- ${project.basedir}/src/test/resources/schemas/imports/Sms.avsc
-
-
- ${project.basedir}/src/test/resources/schemas/imports/PushNotification.avsc
-
-
-
-
-
-
-
diff --git a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/ParsedSchema.java b/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/ParsedSchema.java
deleted file mode 100644
index 1daada556..000000000
--- a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/ParsedSchema.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2017-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema;
-
-import org.apache.avro.Schema;
-
-/**
- * Stores a {@link Schema} together with its String representation.
- *
- * Helps to avoid unnecessary parsing of schema textual representation, as well as calls
- * to {@link org.apache.avro.Schema} toString method which is very expensive due the
- * utilization of {@link com.fasterxml.jackson.databind.ObjectMapper} to output a JSON
- * representation of the schema.
- *
- * Once a schema is found for any Class, be it a POJO or a
- * {@link org.apache.avro.generic.GenericContainer}, both textual representation as well
- * as the {@link org.apache.avro.Schema} will be stored within this class.
- *
- * @author Vinicius Carvalho
- *
- */
-public class ParsedSchema {
-
- private final Schema schema;
-
- private final String representation;
-
- private SchemaRegistrationResponse registration;
-
- public ParsedSchema(Schema schema) {
- this.schema = schema;
- this.representation = schema.toString();
- }
-
- public Schema getSchema() {
- return this.schema;
- }
-
- public String getRepresentation() {
- return this.representation;
- }
-
- public SchemaRegistrationResponse getRegistration() {
- return this.registration;
- }
-
- public void setRegistration(SchemaRegistrationResponse registration) {
- this.registration = registration;
- }
-
-}
diff --git a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/SchemaNotFoundException.java b/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/SchemaNotFoundException.java
deleted file mode 100644
index 4c9707e23..000000000
--- a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/SchemaNotFoundException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema;
-
-/**
- * @author Vinicius Carvalho
- */
-public class SchemaNotFoundException extends RuntimeException {
-
- public SchemaNotFoundException(String message) {
- super(message);
- }
-
-}
diff --git a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/SchemaReference.java b/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/SchemaReference.java
deleted file mode 100644
index 4a1b8c9e7..000000000
--- a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/SchemaReference.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema;
-
-import org.springframework.util.Assert;
-
-/**
- * References a schema through its subject and version.
- *
- * @author Marius Bogoevici
- */
-public class SchemaReference {
-
- private String subject;
-
- private int version;
-
- private String format;
-
- public SchemaReference(String subject, int version, String format) {
- Assert.hasText(subject, "cannot be empty");
- Assert.isTrue(version > 0, "must be a positive integer");
- Assert.hasText(format, "cannot be empty");
- this.subject = subject;
- this.version = version;
- this.format = format;
- }
-
- public String getSubject() {
- return this.subject;
- }
-
- public void setSubject(String subject) {
- Assert.hasText(subject, "cannot be empty");
- this.subject = subject;
- }
-
- public int getVersion() {
- return this.version;
- }
-
- public void setVersion(int version) {
- Assert.isTrue(version > 0, "must be a positive integer");
- this.version = version;
- }
-
- public String getFormat() {
- return this.format;
- }
-
- public void setFormat(String format) {
- Assert.hasText(format, "cannot be empty");
- this.format = format;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- SchemaReference that = (SchemaReference) o;
-
- if (this.version != that.version) {
- return false;
- }
- if (!this.subject.equals(that.subject)) {
- return false;
- }
- return this.format.equals(that.format);
-
- }
-
- @Override
- public int hashCode() {
- int result = this.subject.hashCode();
- result = 31 * result + this.version;
- result = 31 * result + this.format.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- return "SchemaReference{" + "subject='" + this.subject + '\'' + ", version="
- + this.version + ", format='" + this.format + '\'' + '}';
- }
-
-}
diff --git a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/SchemaRegistrationResponse.java b/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/SchemaRegistrationResponse.java
deleted file mode 100644
index 0a3e24efa..000000000
--- a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/SchemaRegistrationResponse.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2016-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema;
-
-/**
- * @author Marius Bogoevici
- */
-public class SchemaRegistrationResponse {
-
- private int id;
-
- private SchemaReference schemaReference;
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public SchemaReference getSchemaReference() {
- return this.schemaReference;
- }
-
- public void setSchemaReference(SchemaReference schemaReference) {
- this.schemaReference = schemaReference;
- }
-
-}
diff --git a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AbstractAvroMessageConverter.java b/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AbstractAvroMessageConverter.java
deleted file mode 100644
index 5f1daa425..000000000
--- a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AbstractAvroMessageConverter.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2016-2018 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.stream.schema.avro;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.apache.avro.Schema;
-import org.apache.avro.io.DatumWriter;
-import org.apache.avro.io.Encoder;
-import org.apache.avro.io.EncoderFactory;
-
-import org.springframework.core.io.Resource;
-import org.springframework.messaging.Message;
-import org.springframework.messaging.MessageHeaders;
-import org.springframework.messaging.converter.AbstractMessageConverter;
-import org.springframework.messaging.converter.MessageConversionException;
-import org.springframework.util.MimeType;
-
-/**
- * Base class for Apache Avro
- * {@link org.springframework.messaging.converter.MessageConverter} implementations.
- *
- * @author Marius Bogoevici
- * @author Vinicius Carvalho
- * @author Sercan Karaoglu
- * @author Ish Mahajan
- */
-public abstract class AbstractAvroMessageConverter extends AbstractMessageConverter {
-
- /**
- * common parser will let user to import external schemas.
- */
- private Schema.Parser schemaParser = new Schema.Parser();
- private AvroSchemaServiceManager avroSchemaServiceManager;
-
- @Deprecated
- protected AbstractAvroMessageConverter(MimeType supportedMimeType) {
- this(Collections.singletonList(supportedMimeType), new AvroSchemaServiceManagerImpl());
- }
-
- protected AbstractAvroMessageConverter(MimeType supportedMimeType, AvroSchemaServiceManager avroSchemaServiceManager) {
- this(Collections.singletonList(supportedMimeType), avroSchemaServiceManager);
- }
-
- @Deprecated
- protected AbstractAvroMessageConverter(Collection supportedMimeTypes) {
- this(supportedMimeTypes, new AvroSchemaServiceManagerImpl());
- setContentTypeResolver(new OriginalContentTypeResolver());
- }
-
- protected AbstractAvroMessageConverter(Collection supportedMimeTypes, AvroSchemaServiceManager manager) {
- super(supportedMimeTypes);
- setContentTypeResolver(new OriginalContentTypeResolver());
- this.avroSchemaServiceManager = manager;
- }
-
- protected AvroSchemaServiceManager avroSchemaServiceManager() {
- return this.avroSchemaServiceManager;
- }
-
- protected Schema parseSchema(Resource r) throws IOException {
- return this.schemaParser.parse(r.getInputStream());
- }
-
- @Override
- protected boolean canConvertFrom(Message> message, Class> targetClass) {
- return super.canConvertFrom(message, targetClass)
- && (message.getPayload() instanceof byte[]);
- }
-
- @Override
- protected Object convertFromInternal(Message> message, Class> targetClass,
- Object conversionHint) {
- Object result;
- try {
- byte[] payload = (byte[]) message.getPayload();
-
- MimeType mimeType = getContentTypeResolver().resolve(message.getHeaders());
- if (mimeType == null) {
- if (conversionHint instanceof MimeType) {
- mimeType = (MimeType) conversionHint;
- }
- else {
- return null;
- }
- }
-
- Schema writerSchema = resolveWriterSchemaForDeserialization(mimeType);
- Schema readerSchema = resolveReaderSchemaForDeserialization(targetClass);
-
- result = avroSchemaServiceManager().readData(targetClass, payload, readerSchema, writerSchema);
- }
- catch (IOException e) {
- throw new MessageConversionException(message, "Failed to read payload", e);
- }
- return result;
- }
-
- @Override
- protected Object convertToInternal(Object payload, MessageHeaders headers,
- Object conversionHint) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- MimeType hintedContentType = null;
- if (conversionHint instanceof MimeType) {
- hintedContentType = (MimeType) conversionHint;
- }
- Schema schema = resolveSchemaForWriting(payload, headers, hintedContentType);
- @SuppressWarnings("unchecked")
- DatumWriter