Search in sources :

Example 1 with GlueSchemaRegistryConfiguration

use of com.amazonaws.services.schemaregistry.common.configs.GlueSchemaRegistryConfiguration in project flink-mirror by flink-ci.

the class GlueSchemaRegistryAvroSerializationSchemaTest method setup.

@BeforeClass
public static void setup() throws IOException {
    metadata.put("test-key", "test-value");
    metadata.put(AWSSchemaRegistryConstants.TRANSPORT_METADATA_KEY, testTopic);
    configs.put(AWSSchemaRegistryConstants.AWS_REGION, "us-west-2");
    configs.put(AWSSchemaRegistryConstants.AWS_ENDPOINT, "https://test");
    configs.put(AWSSchemaRegistryConstants.SCHEMA_AUTO_REGISTRATION_SETTING, true);
    configs.put(AWSSchemaRegistryConstants.SCHEMA_NAME, schemaName);
    configs.put(AWSSchemaRegistryConstants.METADATA, metadata);
    Schema.Parser parser = new Schema.Parser();
    userSchema = parser.parse(new File(AVRO_USER_SCHEMA_FILE));
    userDefinedPojo = User.newBuilder().setName("test_avro_schema").setFavoriteColor("violet").setFavoriteNumber(10).build();
    glueSchemaRegistryConfiguration = new GlueSchemaRegistryConfiguration(configs);
    mockSerializationFacade = new MockGlueSchemaRegistrySerializationFacade();
}
Also used : Schema(org.apache.avro.Schema) File(java.io.File) GlueSchemaRegistryConfiguration(com.amazonaws.services.schemaregistry.common.configs.GlueSchemaRegistryConfiguration) BeforeClass(org.junit.BeforeClass)

Example 2 with GlueSchemaRegistryConfiguration

use of com.amazonaws.services.schemaregistry.common.configs.GlueSchemaRegistryConfiguration in project flink-mirror by flink-ci.

the class GlueSchemaRegistryAvroSchemaCoderTest method testWriteSchema_withoutAutoRegistration_throwsException.

/**
 * Test whether writeSchema method throws exception if auto registration un-enabled.
 */
@Test
public void testWriteSchema_withoutAutoRegistration_throwsException() throws IOException {
    configs.put(AWSSchemaRegistryConstants.SCHEMA_AUTO_REGISTRATION_SETTING, false);
    mockClient = new MockAWSSchemaRegistryClient();
    GlueSchemaRegistrySerializationFacade glueSchemaRegistrySerializationFacade = GlueSchemaRegistrySerializationFacade.builder().schemaRegistryClient(mockClient).credentialProvider(credentialsProvider).glueSchemaRegistryConfiguration(new GlueSchemaRegistryConfiguration(configs)).build();
    GlueSchemaRegistryOutputStreamSerializer glueSchemaRegistryOutputStreamSerializer = new GlueSchemaRegistryOutputStreamSerializer(testTopic, configs, glueSchemaRegistrySerializationFacade);
    GlueSchemaRegistryAvroSchemaCoder glueSchemaRegistryAvroSchemaCoder = new GlueSchemaRegistryAvroSchemaCoder(glueSchemaRegistryOutputStreamSerializer);
    thrown.expect(AWSSchemaRegistryException.class);
    thrown.expectMessage(AWSSchemaRegistryConstants.AUTO_REGISTRATION_IS_DISABLED_MSG);
    glueSchemaRegistryAvroSchemaCoder.writeSchema(userSchema, new ByteArrayOutputStream());
}
Also used : GlueSchemaRegistrySerializationFacade(com.amazonaws.services.schemaregistry.serializers.GlueSchemaRegistrySerializationFacade) ByteArrayOutputStream(java.io.ByteArrayOutputStream) GlueSchemaRegistryConfiguration(com.amazonaws.services.schemaregistry.common.configs.GlueSchemaRegistryConfiguration) Test(org.junit.Test)

Example 3 with GlueSchemaRegistryConfiguration

use of com.amazonaws.services.schemaregistry.common.configs.GlueSchemaRegistryConfiguration in project flink-mirror by flink-ci.

the class GlueSchemaRegistryJsonSerializationSchemaTest method setup.

@BeforeClass
public static void setup() {
    metadata.put("test-key", "test-value");
    metadata.put(AWSSchemaRegistryConstants.TRANSPORT_METADATA_KEY, testTopic);
    configs.put(AWSSchemaRegistryConstants.AWS_REGION, "us-west-2");
    configs.put(AWSSchemaRegistryConstants.AWS_ENDPOINT, "https://test");
    configs.put(AWSSchemaRegistryConstants.SCHEMA_AUTO_REGISTRATION_SETTING, true);
    configs.put(AWSSchemaRegistryConstants.SCHEMA_NAME, schemaName);
    configs.put(AWSSchemaRegistryConstants.METADATA, metadata);
    userSchema = JsonDataWithSchema.builder(JSON_SCHEMA, "{\"f1\":\"iphone\",\"f2\":12}").build();
    userDefinedPojo = Car.builder().make("Tesla").model("3").used(false).miles(6000).year(2021).listedDate(new GregorianCalendar(2020, Calendar.FEBRUARY, 20).getTime()).purchaseDate(Date.from(Instant.parse("2020-01-01T00:00:00.000Z"))).owners(new String[] { "Harry", "Megan" }).serviceChecks(Arrays.asList(5000.0f, 10780.30f)).build();
    glueSchemaRegistryConfiguration = new GlueSchemaRegistryConfiguration(configs);
    mockSerializationFacade = new MockGlueSchemaRegistrySerializationFacade();
}
Also used : GregorianCalendar(java.util.GregorianCalendar) GlueSchemaRegistryConfiguration(com.amazonaws.services.schemaregistry.common.configs.GlueSchemaRegistryConfiguration) BeforeClass(org.junit.BeforeClass)

Example 4 with GlueSchemaRegistryConfiguration

use of com.amazonaws.services.schemaregistry.common.configs.GlueSchemaRegistryConfiguration in project flink by apache.

the class GlueSchemaRegistryAvroSerializationSchemaTest method setup.

@BeforeClass
public static void setup() throws IOException {
    metadata.put("test-key", "test-value");
    metadata.put(AWSSchemaRegistryConstants.TRANSPORT_METADATA_KEY, testTopic);
    configs.put(AWSSchemaRegistryConstants.AWS_REGION, "us-west-2");
    configs.put(AWSSchemaRegistryConstants.AWS_ENDPOINT, "https://test");
    configs.put(AWSSchemaRegistryConstants.SCHEMA_AUTO_REGISTRATION_SETTING, true);
    configs.put(AWSSchemaRegistryConstants.SCHEMA_NAME, schemaName);
    configs.put(AWSSchemaRegistryConstants.METADATA, metadata);
    Schema.Parser parser = new Schema.Parser();
    userSchema = parser.parse(new File(AVRO_USER_SCHEMA_FILE));
    userDefinedPojo = User.newBuilder().setName("test_avro_schema").setFavoriteColor("violet").setFavoriteNumber(10).build();
    glueSchemaRegistryConfiguration = new GlueSchemaRegistryConfiguration(configs);
    mockSerializationFacade = new MockGlueSchemaRegistrySerializationFacade();
}
Also used : Schema(org.apache.avro.Schema) File(java.io.File) GlueSchemaRegistryConfiguration(com.amazonaws.services.schemaregistry.common.configs.GlueSchemaRegistryConfiguration) BeforeClass(org.junit.BeforeClass)

Example 5 with GlueSchemaRegistryConfiguration

use of com.amazonaws.services.schemaregistry.common.configs.GlueSchemaRegistryConfiguration in project flink by apache.

the class GlueSchemaRegistryJsonSerializationSchemaTest method setup.

@BeforeClass
public static void setup() {
    metadata.put("test-key", "test-value");
    metadata.put(AWSSchemaRegistryConstants.TRANSPORT_METADATA_KEY, testTopic);
    configs.put(AWSSchemaRegistryConstants.AWS_REGION, "us-west-2");
    configs.put(AWSSchemaRegistryConstants.AWS_ENDPOINT, "https://test");
    configs.put(AWSSchemaRegistryConstants.SCHEMA_AUTO_REGISTRATION_SETTING, true);
    configs.put(AWSSchemaRegistryConstants.SCHEMA_NAME, schemaName);
    configs.put(AWSSchemaRegistryConstants.METADATA, metadata);
    userSchema = JsonDataWithSchema.builder(JSON_SCHEMA, "{\"f1\":\"iphone\",\"f2\":12}").build();
    userDefinedPojo = Car.builder().make("Tesla").model("3").used(false).miles(6000).year(2021).listedDate(new GregorianCalendar(2020, Calendar.FEBRUARY, 20).getTime()).purchaseDate(Date.from(Instant.parse("2020-01-01T00:00:00.000Z"))).owners(new String[] { "Harry", "Megan" }).serviceChecks(Arrays.asList(5000.0f, 10780.30f)).build();
    glueSchemaRegistryConfiguration = new GlueSchemaRegistryConfiguration(configs);
    mockSerializationFacade = new MockGlueSchemaRegistrySerializationFacade();
}
Also used : GregorianCalendar(java.util.GregorianCalendar) GlueSchemaRegistryConfiguration(com.amazonaws.services.schemaregistry.common.configs.GlueSchemaRegistryConfiguration) BeforeClass(org.junit.BeforeClass)

Aggregations

GlueSchemaRegistryConfiguration (com.amazonaws.services.schemaregistry.common.configs.GlueSchemaRegistryConfiguration)54 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)22 Test (org.junit.jupiter.api.Test)20 MethodSource (org.junit.jupiter.params.provider.MethodSource)9 AWSSchemaRegistryException (com.amazonaws.services.schemaregistry.exception.AWSSchemaRegistryException)8 GetSchemaByDefinitionRequest (software.amazon.awssdk.services.glue.model.GetSchemaByDefinitionRequest)8 GlueSchemaRegistrySerializationFacade (com.amazonaws.services.schemaregistry.serializers.GlueSchemaRegistrySerializationFacade)7 Schema (org.apache.avro.Schema)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 EntityNotFoundException (software.amazon.awssdk.services.glue.model.EntityNotFoundException)7 GlueSchemaRegistryKafkaSerializer (com.amazonaws.services.schemaregistry.serializers.GlueSchemaRegistryKafkaSerializer)6 UUID (java.util.UUID)6 BeforeClass (org.junit.BeforeClass)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 File (java.io.File)5 GetSchemaVersionResponse (software.amazon.awssdk.services.glue.model.GetSchemaVersionResponse)4 SchemaByDefinitionFetcher (com.amazonaws.services.schemaregistry.common.SchemaByDefinitionFetcher)3 TestDataGenerator (com.amazonaws.services.schemaregistry.integrationtests.generators.TestDataGenerator)3 IOException (java.io.IOException)3 GregorianCalendar (java.util.GregorianCalendar)3