Add code formatting guidelines
Add 'eclipse' folder containing Eclipse code formatter configuration and instructions how to use it. Update rule for join_wrapped_lines - Set to `false` Resolves #930 Update README Address review comments
This commit is contained in:
committed by
Marius Bogoevici
parent
9632546f03
commit
bd002e4aaf
@@ -21,13 +21,14 @@ 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.
|
||||
* 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.
|
||||
* 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
|
||||
*
|
||||
@@ -40,7 +41,7 @@ public class ParsedSchema {
|
||||
|
||||
private SchemaRegistrationResponse registration;
|
||||
|
||||
public ParsedSchema(Schema schema){
|
||||
public ParsedSchema(Schema schema) {
|
||||
this.schema = schema;
|
||||
this.representation = schema.toString();
|
||||
}
|
||||
|
||||
@@ -45,12 +45,12 @@ import org.springframework.messaging.converter.MessageConversionException;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
/**
|
||||
* Base class for Apache Avro {@link org.springframework.messaging.converter.MessageConverter} implementations.
|
||||
* Base class for Apache Avro
|
||||
* {@link org.springframework.messaging.converter.MessageConverter} implementations.
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public abstract class AbstractAvroMessageConverter extends AbstractMessageConverter {
|
||||
|
||||
|
||||
protected AbstractAvroMessageConverter(MimeType supportedMimeType) {
|
||||
super(supportedMimeType);
|
||||
}
|
||||
|
||||
@@ -38,19 +38,17 @@ import org.springframework.util.ObjectUtils;
|
||||
@ConditionalOnClass(name = "org.apache.avro.Schema")
|
||||
@ConditionalOnProperty(value = "spring.cloud.stream.schemaRegistryClient.enabled", matchIfMissing = true)
|
||||
@ConditionalOnBean(type = "org.springframework.cloud.stream.schema.client.SchemaRegistryClient")
|
||||
@EnableConfigurationProperties({AvroMessageConverterProperties.class})
|
||||
@EnableConfigurationProperties({ AvroMessageConverterProperties.class })
|
||||
public class AvroMessageConverterAutoConfiguration {
|
||||
|
||||
@Autowired
|
||||
private AvroMessageConverterProperties avroMessageConverterProperties;
|
||||
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(AvroSchemaRegistryClientMessageConverter.class)
|
||||
public AvroSchemaRegistryClientMessageConverter avroSchemaMessageConverter(
|
||||
SchemaRegistryClient schemaRegistryClient) {
|
||||
AvroSchemaRegistryClientMessageConverter
|
||||
avroSchemaRegistryClientMessageConverter = new AvroSchemaRegistryClientMessageConverter(
|
||||
AvroSchemaRegistryClientMessageConverter avroSchemaRegistryClientMessageConverter = new AvroSchemaRegistryClientMessageConverter(
|
||||
schemaRegistryClient);
|
||||
avroSchemaRegistryClientMessageConverter.setDynamicSchemaGenerationEnabled(
|
||||
this.avroMessageConverterProperties.isDynamicSchemaGenerationEnabled());
|
||||
@@ -70,7 +68,7 @@ public class AvroMessageConverterAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public CacheManager cacheManager(){
|
||||
public CacheManager cacheManager() {
|
||||
return new ConcurrentMapCacheManager();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,14 +27,11 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
/**
|
||||
* A {@link org.springframework.messaging.converter.MessageConverter}
|
||||
* using Apache Avro.
|
||||
* The schema for serializing and deserializing will be automatically inferred
|
||||
* from the class for {@link org.apache.avro.specific.SpecificRecord} and regular
|
||||
* classes, unless a specific schema is set, case in which that schema will be used
|
||||
* instead.
|
||||
* For converting to {@link org.apache.avro.generic.GenericRecord} targets,
|
||||
* a schema must be set.s
|
||||
* A {@link org.springframework.messaging.converter.MessageConverter} using Apache Avro.
|
||||
* The schema for serializing and deserializing will be automatically inferred from the
|
||||
* class for {@link org.apache.avro.specific.SpecificRecord} and regular classes, unless a
|
||||
* specific schema is set, case in which that schema will be used instead. For converting
|
||||
* to {@link org.apache.avro.generic.GenericRecord} targets, a schema must be set.s
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
|
||||
@@ -43,24 +40,24 @@ public class AvroSchemaMessageConverter extends AbstractAvroMessageConverter {
|
||||
private Schema schema;
|
||||
|
||||
/**
|
||||
* Create a {@link AvroSchemaMessageConverter}.
|
||||
* Uses the default {@link MimeType} of {@code "application/avro"}.
|
||||
* Create a {@link AvroSchemaMessageConverter}. Uses the default {@link MimeType} of
|
||||
* {@code "application/avro"}.
|
||||
*/
|
||||
public AvroSchemaMessageConverter() {
|
||||
super(new MimeType("application", "avro"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link AvroSchemaMessageConverter}.
|
||||
* The converter will be used for the provided {@link MimeType}.
|
||||
* Create a {@link AvroSchemaMessageConverter}. The converter will be used for the
|
||||
* provided {@link MimeType}.
|
||||
*/
|
||||
public AvroSchemaMessageConverter(MimeType supportedMimeType) {
|
||||
super(supportedMimeType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link AvroSchemaMessageConverter}.
|
||||
* The converter will be used for the provided {@link MimeType}s.
|
||||
* Create a {@link AvroSchemaMessageConverter}. The converter will be used for the
|
||||
* provided {@link MimeType}s.
|
||||
* @param supportedMimeTypes the mime types supported by this converter
|
||||
*/
|
||||
public AvroSchemaMessageConverter(Collection<MimeType> supportedMimeTypes) {
|
||||
|
||||
@@ -110,13 +110,15 @@ public class AvroSchemaRegistryClientMessageConverter extends AbstractAvroMessag
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance, configuring it with {@link SchemaRegistryClient} and {@link CacheManager}.
|
||||
* Creates a new instance, configuring it with {@link SchemaRegistryClient} and
|
||||
* {@link CacheManager}.
|
||||
* @param schemaRegistryClient the {@link SchemaRegistryClient} used to interact with
|
||||
* the schema registry server.
|
||||
* @param cacheManager instance of {@link CacheManager} to cache parsed schemas. If caching
|
||||
* is not required use {@link NoOpCacheManager}
|
||||
* @param cacheManager instance of {@link CacheManager} to cache parsed schemas. If
|
||||
* caching is not required use {@link NoOpCacheManager}
|
||||
*/
|
||||
public AvroSchemaRegistryClientMessageConverter(SchemaRegistryClient schemaRegistryClient, CacheManager cacheManager) {
|
||||
public AvroSchemaRegistryClientMessageConverter(SchemaRegistryClient schemaRegistryClient,
|
||||
CacheManager cacheManager) {
|
||||
super(Arrays.asList(new MimeType("application", "*+avro")));
|
||||
Assert.notNull(schemaRegistryClient, "cannot be null");
|
||||
Assert.notNull(cacheManager, "'cacheManager' cannot be null");
|
||||
@@ -194,7 +196,7 @@ public class AvroSchemaRegistryClientMessageConverter extends AbstractAvroMessag
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.cacheManager instanceof NoOpCacheManager){
|
||||
if (this.cacheManager instanceof NoOpCacheManager) {
|
||||
logger.warn("Schema caching is effectively disabled "
|
||||
+ "since configured cache manager is a NoOpCacheManager. If this was not "
|
||||
+ "the intention, please provide the appropriate instance of CacheManager "
|
||||
@@ -337,7 +339,6 @@ public class AvroSchemaRegistryClientMessageConverter extends AbstractAvroMessag
|
||||
return schema;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated as of release 1.0.4. Please use the constructor to inject CacheManager
|
||||
*/
|
||||
|
||||
@@ -46,9 +46,9 @@ public class CachingRegistryClient implements SchemaRegistryClient {
|
||||
|
||||
@Override
|
||||
public SchemaRegistrationResponse register(String subject, String format, String schema) {
|
||||
SchemaRegistrationResponse response = delegate.register(subject,format,schema);
|
||||
cacheManager.getCache(ID_CACHE).put(response.getSchemaReference(),schema);
|
||||
cacheManager.getCache(REF_CACHE).put(response.getId(),schema);
|
||||
SchemaRegistrationResponse response = delegate.register(subject, format, schema);
|
||||
cacheManager.getCache(ID_CACHE).put(response.getSchemaReference(), schema);
|
||||
cacheManager.getCache(REF_CACHE).put(response.getId(), schema);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.springframework.web.client.RestTemplate;
|
||||
*/
|
||||
public class DefaultSchemaRegistryClient implements SchemaRegistryClient {
|
||||
|
||||
|
||||
private RestTemplate template;
|
||||
|
||||
private String endpoint = "http://localhost:8990";
|
||||
@@ -69,7 +68,8 @@ public class DefaultSchemaRegistryClient implements SchemaRegistryClient {
|
||||
ResponseEntity<Map> responseEntity = this.template.getForEntity(
|
||||
this.endpoint + "/" + schemaReference.getSubject() + "/" + schemaReference
|
||||
.getFormat() + "/v" + schemaReference
|
||||
.getVersion(), Map.class);
|
||||
.getVersion(),
|
||||
Map.class);
|
||||
if (!responseEntity.getStatusCode().is2xxSuccessful()) {
|
||||
throw new RuntimeException("Failed to fetch schema: " + responseEntity.toString());
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.context.annotation.Import;
|
||||
/**
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
|
||||
@Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
|
||||
@@ -26,16 +26,19 @@ import org.springframework.cloud.stream.schema.SchemaRegistrationResponse;
|
||||
public interface SchemaRegistryClient {
|
||||
|
||||
/**
|
||||
* Registers a schema with the remote repository returning the unique identifier associated with this schema.
|
||||
* Registers a schema with the remote repository returning the unique identifier
|
||||
* associated with this schema.
|
||||
* @param subject the full name of the schema
|
||||
* @param schema
|
||||
* @return a {@link SchemaRegistrationResponse} representing the result of the operation
|
||||
* @return a {@link SchemaRegistrationResponse} representing the result of the
|
||||
* operation
|
||||
*/
|
||||
SchemaRegistrationResponse register(String subject, String format, String schema);
|
||||
|
||||
/**
|
||||
* Retrieves a schema by its reference (subject and version).
|
||||
* @param schemaReference a {@link SchemaReference} used to identify the target schema.
|
||||
* @param schemaReference a {@link SchemaReference} used to identify the target
|
||||
* schema.
|
||||
* @return
|
||||
*/
|
||||
String fetch(SchemaReference schemaReference);
|
||||
|
||||
@@ -44,7 +44,8 @@ public class SchemaRegistryClientConfiguration {
|
||||
defaultSchemaRegistryClient.setEndpoint(schemaRegistryClientProperties.getEndpoint());
|
||||
}
|
||||
|
||||
SchemaRegistryClient client = (schemaRegistryClientProperties.isCached()) ? new CachingRegistryClient(defaultSchemaRegistryClient) : defaultSchemaRegistryClient;
|
||||
SchemaRegistryClient client = (schemaRegistryClientProperties.isCached())
|
||||
? new CachingRegistryClient(defaultSchemaRegistryClient) : defaultSchemaRegistryClient;
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
@@ -53,12 +53,12 @@ public class AvroMessageConverterSerializationTests {
|
||||
Pattern versionedSchema = Pattern.compile(
|
||||
"application/" + "vnd" + "\\.([\\p{Alnum}\\$\\.]+)\\.v(\\p{Digit}+)\\+avro");
|
||||
|
||||
private ConfigurableApplicationContext schemaRegistryServerContext;
|
||||
Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private ConfigurableApplicationContext schemaRegistryServerContext;
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
public void setup() {
|
||||
schemaRegistryServerContext = SpringApplication.run(
|
||||
SchemaRegistryServerApplication.class);
|
||||
}
|
||||
@@ -72,9 +72,10 @@ public class AvroMessageConverterSerializationTests {
|
||||
public void sourceWriteSameVersion() throws Exception {
|
||||
User specificRecord = new User();
|
||||
specificRecord.setName("joe");
|
||||
Schema v1 = new Schema.Parser().parse(AvroMessageConverterSerializationTests.class.getClassLoader().getResourceAsStream("schemas/user.avsc"));
|
||||
Schema v1 = new Schema.Parser().parse(
|
||||
AvroMessageConverterSerializationTests.class.getClassLoader().getResourceAsStream("schemas/user.avsc"));
|
||||
GenericRecord genericRecord = new GenericData.Record(v1);
|
||||
genericRecord.put("name","joe");
|
||||
genericRecord.put("name", "joe");
|
||||
SchemaRegistryClient client = new DefaultSchemaRegistryClient();
|
||||
AvroSchemaRegistryClientMessageConverter converter = new AvroSchemaRegistryClientMessageConverter(client);
|
||||
converter.setDynamicSchemaGenerationEnabled(false);
|
||||
@@ -82,13 +83,19 @@ public class AvroMessageConverterSerializationTests {
|
||||
converter.setCacheManager(new ConcurrentMapCacheManager());
|
||||
converter.afterPropertiesSet();
|
||||
|
||||
Message specificMessage = converter.toMessage(specificRecord,new MutableMessageHeaders(Collections.<String,Object>emptyMap()), MimeTypeUtils.parseMimeType("application/*+avro"));
|
||||
SchemaReference specificRef = extractSchemaReference( MimeTypeUtils.parseMimeType(specificMessage.getHeaders().get("contentType").toString()));
|
||||
Message specificMessage = converter.toMessage(specificRecord,
|
||||
new MutableMessageHeaders(Collections.<String, Object>emptyMap()),
|
||||
MimeTypeUtils.parseMimeType("application/*+avro"));
|
||||
SchemaReference specificRef = extractSchemaReference(
|
||||
MimeTypeUtils.parseMimeType(specificMessage.getHeaders().get("contentType").toString()));
|
||||
|
||||
Message genericMessage = converter.toMessage(genericRecord,new MutableMessageHeaders(Collections.<String,Object>emptyMap()), MimeTypeUtils.parseMimeType("application/*+avro"));
|
||||
SchemaReference genericRef = extractSchemaReference( MimeTypeUtils.parseMimeType(genericMessage.getHeaders().get("contentType").toString()));
|
||||
Message genericMessage = converter.toMessage(genericRecord,
|
||||
new MutableMessageHeaders(Collections.<String, Object>emptyMap()),
|
||||
MimeTypeUtils.parseMimeType("application/*+avro"));
|
||||
SchemaReference genericRef = extractSchemaReference(
|
||||
MimeTypeUtils.parseMimeType(genericMessage.getHeaders().get("contentType").toString()));
|
||||
|
||||
Assert.assertEquals(genericRef,specificRef);
|
||||
Assert.assertEquals(genericRef, specificRef);
|
||||
Assert.assertEquals(1, genericRef.getVersion());
|
||||
}
|
||||
|
||||
@@ -98,7 +105,8 @@ public class AvroMessageConverterSerializationTests {
|
||||
if (schemaMatcher.find()) {
|
||||
String subject = schemaMatcher.group(1);
|
||||
Integer version = Integer.parseInt(schemaMatcher.group(2));
|
||||
schemaReference = new SchemaReference(subject, version, AvroSchemaRegistryClientMessageConverter.AVRO_FORMAT);
|
||||
schemaReference = new SchemaReference(subject, version,
|
||||
AvroSchemaRegistryClientMessageConverter.AVRO_FORMAT);
|
||||
}
|
||||
return schemaReference;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,6 @@ public class AvroSchemaMessageConverterTests {
|
||||
Message<?> outboundMessage = sourceMessageCollector.forChannel(source.output()).poll(1000,
|
||||
TimeUnit.MILLISECONDS);
|
||||
|
||||
|
||||
ConfigurableApplicationContext barSourceContext = SpringApplication.run(AvroSourceApplication.class,
|
||||
"--server.port=0",
|
||||
"--spring.jmx.enabled=false",
|
||||
@@ -87,7 +86,6 @@ public class AvroSchemaMessageConverterTests {
|
||||
|
||||
assertThat(barOutboundMessage).isNotNull();
|
||||
|
||||
|
||||
User2 secondUser2OutboundPojo = new User2();
|
||||
secondUser2OutboundPojo.setFavoriteColor("foo" + UUID.randomUUID().toString());
|
||||
secondUser2OutboundPojo.setFavoritePlace("foo" + UUID.randomUUID().toString());
|
||||
@@ -96,7 +94,6 @@ public class AvroSchemaMessageConverterTests {
|
||||
Message<?> secondBarOutboundMessage = sourceMessageCollector.forChannel(source.output()).poll(1000,
|
||||
TimeUnit.MILLISECONDS);
|
||||
|
||||
|
||||
ConfigurableApplicationContext sinkContext = SpringApplication.run(AvroSinkApplication.class,
|
||||
"--server.port=0",
|
||||
"--spring.jmx.enabled=false",
|
||||
@@ -139,7 +136,6 @@ public class AvroSchemaMessageConverterTests {
|
||||
Message<?> outboundMessage = sourceMessageCollector.forChannel(source.output()).poll(1000,
|
||||
TimeUnit.MILLISECONDS);
|
||||
|
||||
|
||||
ConfigurableApplicationContext barSourceContext = SpringApplication.run(AvroSourceApplication.class,
|
||||
"--server.port=0",
|
||||
"--spring.jmx.enabled=false",
|
||||
@@ -157,7 +153,6 @@ public class AvroSchemaMessageConverterTests {
|
||||
|
||||
assertThat(barOutboundMessage).isNotNull();
|
||||
|
||||
|
||||
User2 secondUser2OutboundPojo = new User2();
|
||||
secondUser2OutboundPojo.setFavoriteColor("foo" + UUID.randomUUID().toString());
|
||||
secondUser2OutboundPojo.setFavoritePlace("foo" + UUID.randomUUID().toString());
|
||||
@@ -166,7 +161,6 @@ public class AvroSchemaMessageConverterTests {
|
||||
Message<?> secondBarOutboundMessage = sourceMessageCollector.forChannel(source.output()).poll(1000,
|
||||
TimeUnit.MILLISECONDS);
|
||||
|
||||
|
||||
ConfigurableApplicationContext sinkContext = SpringApplication.run(AvroSinkApplication.class,
|
||||
"--server.port=0",
|
||||
"--spring.jmx.enabled=false",
|
||||
@@ -192,19 +186,18 @@ public class AvroSchemaMessageConverterTests {
|
||||
sourceContext.close();
|
||||
}
|
||||
|
||||
|
||||
@EnableBinding(Source.class)
|
||||
@EnableAutoConfiguration
|
||||
@ConfigurationProperties
|
||||
public static class AvroSourceApplication {
|
||||
|
||||
private Resource schemaLocation;
|
||||
|
||||
@Bean
|
||||
public SchemaRegistryClient schemaRegistryClient() {
|
||||
return stubSchemaRegistryClient;
|
||||
}
|
||||
|
||||
private Resource schemaLocation;
|
||||
|
||||
public void setSchemaLocation(Resource schemaLocation) {
|
||||
this.schemaLocation = schemaLocation;
|
||||
}
|
||||
@@ -227,13 +220,13 @@ public class AvroSchemaMessageConverterTests {
|
||||
|
||||
public List<User1> receivedUsers = new ArrayList<>();
|
||||
|
||||
private Resource schemaLocation;
|
||||
|
||||
@StreamListener(Sink.INPUT)
|
||||
public void listen(User1 user) {
|
||||
receivedUsers.add(user);
|
||||
}
|
||||
|
||||
private Resource schemaLocation;
|
||||
|
||||
public void setSchemaLocation(Resource schemaLocation) {
|
||||
this.schemaLocation = schemaLocation;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Marius Bogoevici
|
||||
* @author Oleg Zhurakousky
|
||||
@@ -72,7 +73,6 @@ public class AvroSchemaRegistryClientMessageConverterTests {
|
||||
Message<?> outboundMessage = sourceMessageCollector.forChannel(source.output()).poll(1000,
|
||||
TimeUnit.MILLISECONDS);
|
||||
|
||||
|
||||
ConfigurableApplicationContext barSourceContext = SpringApplication.run(AvroSourceApplication.class,
|
||||
"--server.port=0",
|
||||
"--spring.jmx.enabled=false",
|
||||
@@ -89,7 +89,6 @@ public class AvroSchemaRegistryClientMessageConverterTests {
|
||||
|
||||
assertThat(barOutboundMessage).isNotNull();
|
||||
|
||||
|
||||
User2 secondBarOutboundPojo = new User2();
|
||||
secondBarOutboundPojo.setFavoriteColor("foo" + UUID.randomUUID().toString());
|
||||
secondBarOutboundPojo.setName("foo" + UUID.randomUUID().toString());
|
||||
@@ -97,7 +96,6 @@ public class AvroSchemaRegistryClientMessageConverterTests {
|
||||
Message<?> secondBarOutboundMessage = sourceMessageCollector.forChannel(source.output()).poll(1000,
|
||||
TimeUnit.MILLISECONDS);
|
||||
|
||||
|
||||
ConfigurableApplicationContext sinkContext = SpringApplication.run(AvroSinkApplication.class,
|
||||
"--server.port=0", "--spring.jmx.enabled=false");
|
||||
Sink sink = sinkContext.getBean(Sink.class);
|
||||
@@ -116,7 +114,6 @@ public class AvroSchemaRegistryClientMessageConverterTests {
|
||||
assertThat(receivedPojos.get(1).getName()).isEqualTo(firstOutboundUser2.getName());
|
||||
assertThat(receivedPojos.get(1).getFavoritePlace()).isEqualTo("Boston");
|
||||
|
||||
|
||||
assertThat(receivedPojos.get(2)).isNotSameAs(secondBarOutboundPojo);
|
||||
assertThat(receivedPojos.get(2).getFavoriteColor()).isEqualTo(secondBarOutboundPojo.getFavoriteColor());
|
||||
assertThat(receivedPojos.get(2).getName()).isEqualTo(secondBarOutboundPojo.getName());
|
||||
@@ -128,6 +125,16 @@ public class AvroSchemaRegistryClientMessageConverterTests {
|
||||
schemaRegistryServerContext.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoCacheConfiguration() {
|
||||
ConfigurableApplicationContext sourceContext = SpringApplication.run(NoCacheConfiguration.class,
|
||||
"--spring.main.web-environment=false");
|
||||
AvroSchemaRegistryClientMessageConverter converter = sourceContext
|
||||
.getBean(AvroSchemaRegistryClientMessageConverter.class);
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(converter);
|
||||
assertThat(accessor.getPropertyValue("cacheManager")).isInstanceOf(NoOpCacheManager.class);
|
||||
}
|
||||
|
||||
@EnableBinding(Source.class)
|
||||
@EnableAutoConfiguration
|
||||
@EnableSchemaRegistryClient
|
||||
@@ -149,14 +156,6 @@ public class AvroSchemaRegistryClientMessageConverterTests {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoCacheConfiguration (){
|
||||
ConfigurableApplicationContext sourceContext = SpringApplication.run(NoCacheConfiguration.class, "--spring.main.web-environment=false");
|
||||
AvroSchemaRegistryClientMessageConverter converter = sourceContext.getBean(AvroSchemaRegistryClientMessageConverter.class);
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(converter);
|
||||
assertThat(accessor.getPropertyValue("cacheManager")).isInstanceOf(NoOpCacheManager.class);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
public static class NoCacheConfiguration {
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -62,7 +62,6 @@ public class AvroStubSchemaRegistryClientMessageConverterTests {
|
||||
Message<?> outboundMessage = sourceMessageCollector.forChannel(source.output()).poll(1000,
|
||||
TimeUnit.MILLISECONDS);
|
||||
|
||||
|
||||
ConfigurableApplicationContext barSourceContext = SpringApplication.run(AvroSourceApplication.class,
|
||||
"--server.port=0",
|
||||
"--spring.jmx.enabled=false",
|
||||
@@ -79,7 +78,6 @@ public class AvroStubSchemaRegistryClientMessageConverterTests {
|
||||
|
||||
assertThat(barOutboundMessage).isNotNull();
|
||||
|
||||
|
||||
User2 secondBarOutboundPojo = new User2();
|
||||
secondBarOutboundPojo.setFavoriteColor("foo" + UUID.randomUUID().toString());
|
||||
secondBarOutboundPojo.setName("foo" + UUID.randomUUID().toString());
|
||||
@@ -87,7 +85,6 @@ public class AvroStubSchemaRegistryClientMessageConverterTests {
|
||||
Message<?> secondBarOutboundMessage = sourceMessageCollector.forChannel(source.output()).poll(1000,
|
||||
TimeUnit.MILLISECONDS);
|
||||
|
||||
|
||||
ConfigurableApplicationContext sinkContext = SpringApplication.run(AvroSinkApplication.class,
|
||||
"--server.port=0", "--spring.jmx.enabled=false");
|
||||
Sink sink = sinkContext.getBean(Sink.class);
|
||||
@@ -106,7 +103,6 @@ public class AvroStubSchemaRegistryClientMessageConverterTests {
|
||||
assertThat(receivedPojos.get(1).getName()).isEqualTo(firstOutboundUser2.getName());
|
||||
assertThat(receivedPojos.get(1).getFavoritePlace()).isEqualTo("Boston");
|
||||
|
||||
|
||||
assertThat(receivedPojos.get(2)).isNotSameAs(secondBarOutboundPojo);
|
||||
assertThat(receivedPojos.get(2).getFavoriteColor()).isEqualTo(secondBarOutboundPojo.getFavoriteColor());
|
||||
assertThat(receivedPojos.get(2).getName()).isEqualTo(secondBarOutboundPojo.getName());
|
||||
|
||||
Reference in New Issue
Block a user