use of org.apache.beam.sdk.coders.DefaultCoder.DefaultCoderProviderRegistrar.DefaultCoderProvider in project beam by apache.
the class DefaultCoderTest method testUnknown.
@Test
public void testUnknown() throws Exception {
thrown.expect(CannotProvideCoderException.class);
new DefaultCoderProvider().coderFor(TypeDescriptor.of(Unknown.class), Collections.<Coder<?>>emptyList());
}
use of org.apache.beam.sdk.coders.DefaultCoder.DefaultCoderProviderRegistrar.DefaultCoderProvider in project beam by apache.
the class DefaultCoderTest method testDefaultCoderInCollection.
@Test
public void testDefaultCoderInCollection() throws Exception {
CoderRegistry registry = CoderRegistry.createDefault();
registry.registerCoderProvider(new DefaultCoderProvider());
Coder<List<AvroRecord>> avroRecordCoder = registry.getCoder(new TypeDescriptor<List<AvroRecord>>() {
});
assertThat(avroRecordCoder, instanceOf(ListCoder.class));
assertThat(((ListCoder) avroRecordCoder).getElemCoder(), instanceOf(AvroCoder.class));
assertThat(registry.getCoder(new TypeDescriptor<List<SerializableRecord>>() {
}), Matchers.<Coder<List<SerializableRecord>>>equalTo(ListCoder.of(SerializableCoder.of(SerializableRecord.class))));
}
use of org.apache.beam.sdk.coders.DefaultCoder.DefaultCoderProviderRegistrar.DefaultCoderProvider in project beam by apache.
the class DefaultCoderTest method testCodersWithoutComponents.
@Test
public void testCodersWithoutComponents() throws Exception {
CoderRegistry registry = CoderRegistry.createDefault();
registry.registerCoderProvider(new DefaultCoderProvider());
assertThat(registry.getCoder(AvroRecord.class), instanceOf(AvroCoder.class));
assertThat(registry.getCoder(SerializableRecord.class), instanceOf(SerializableCoder.class));
assertThat(registry.getCoder(CustomRecord.class), instanceOf(CustomSerializableCoder.class));
assertThat(registry.getCoder(OldCustomRecord.class), instanceOf(OldCustomSerializableCoder.class));
}
Aggregations