use of org.infinispan.protostream.annotations.impl.types.ReflectionTypeFactory in project protostream by infinispan.
the class ReservedProcessorTest method testEmpty.
@Test
public void testEmpty() {
XClass classToTest = new ReflectionTypeFactory().fromClass(Integer.class);
ReservedProcessor rp = new ReservedProcessor();
rp.scan(classToTest);
IndentWriter iw = new IndentWriter();
rp.generate(iw);
assertEquals("", iw.toString());
}
use of org.infinispan.protostream.annotations.impl.types.ReflectionTypeFactory in project protostream by infinispan.
the class ReservedProcessorTest method testDuplicateReservedNumber.
@Test
public void testDuplicateReservedNumber() {
expectedException.expect(ProtoSchemaBuilderException.class);
expectedException.expectMessage("Found duplicate @ProtoReserved number 1 in org.infinispan.protostream.annotations.impl.ReservedProcessorTest.DuplicateNumber");
XClass classToTest = new ReflectionTypeFactory().fromClass(DuplicateNumber.class);
new ReservedProcessor().scan(classToTest);
}
use of org.infinispan.protostream.annotations.impl.types.ReflectionTypeFactory in project protostream by infinispan.
the class ProtoSchemaBuilder method build.
/**
* Builds the Protocol Buffers schema file defining the types and generates marshaller implementations for these
* types and registers everything with the given {@link SerializationContext}.The generated classes are defined in
* the given ClassLoader.
*
* @param serializationContext
* @param classLoader the ClassLoader in which the generated classes will be defined. If {@code null}, this
* behaves as {@link #build(SerializationContext)}
* @return the generated Protocol Buffers schema file text
* @throws ProtoSchemaBuilderException
* @throws IOException
*/
public String build(SerializationContext serializationContext, ClassLoader classLoader) throws ProtoSchemaBuilderException, IOException {
ReflectionTypeFactory typeFactory = new ReflectionTypeFactory();
Set<XClass> xclasses = classes.stream().map(typeFactory::fromClass).collect(Collectors.toCollection(LinkedHashSet::new));
BaseProtoSchemaGenerator.generateSchemaDebugComments = generateSchemaDebugComments;
return new RuntimeProtoSchemaGenerator(typeFactory, serializationContext, generator, fileName, packageName, xclasses, autoImportClasses, classLoader).generateAndRegister();
}
use of org.infinispan.protostream.annotations.impl.types.ReflectionTypeFactory in project protostream by infinispan.
the class ReservedProcessorTest method testDuplicateReservedName.
@Test
public void testDuplicateReservedName() {
expectedException.expect(ProtoSchemaBuilderException.class);
expectedException.expectMessage("Found duplicate @ProtoReserved name \"triceratops\" in org.infinispan.protostream.annotations.impl.ReservedProcessorTest.DuplicateName");
XClass classToTest = new ReflectionTypeFactory().fromClass(DuplicateName.class);
new ReservedProcessor().scan(classToTest);
}
use of org.infinispan.protostream.annotations.impl.types.ReflectionTypeFactory in project protostream by infinispan.
the class ReservedProcessorTest method testReservedNumbers.
@Test
public void testReservedNumbers() {
XClass classToTest = new ReflectionTypeFactory().fromClass(TestingReserved.class);
ReservedProcessor rp = new ReservedProcessor();
rp.scan(classToTest);
IndentWriter iw = new IndentWriter();
rp.generate(iw);
assertEquals("//reserved 1 to 7;\n//reserved \"a\", \"b\";\n", iw.toString());
}
Aggregations