Search in sources :

Example 1 with ProgramConverter

use of net.morimekta.providence.reflect.util.ProgramConverter in project providence by morimekta.

the class CMessageBuilderTest method setUp.

@Before
public void setUp() throws IOException {
    File file = tmp.newFile("test.thrift").getCanonicalFile().getAbsoluteFile();
    ProgramRegistry tmp = new ProgramRegistry();
    ThriftProgramParser parser = new ThriftProgramParser();
    ProgramConverter converter = new ProgramConverter(tmp);
    ProgramType program = parser.parse(getClass().getResourceAsStream("/parser/tests/test.thrift"), file, ImmutableList.of());
    tmp.putProgram(file.getPath(), converter.convert(file.getPath(), program));
    registry = tmp.registryForPath(file.getCanonicalFile().getAbsolutePath());
}
Also used : ProgramRegistry(net.morimekta.providence.reflect.util.ProgramRegistry) ProgramConverter(net.morimekta.providence.reflect.util.ProgramConverter) ProgramType(net.morimekta.providence.model.ProgramType) File(java.io.File) ThriftProgramParser(net.morimekta.providence.reflect.parser.ThriftProgramParser) Before(org.junit.Before)

Example 2 with ProgramConverter

use of net.morimekta.providence.reflect.util.ProgramConverter in project providence by morimekta.

the class CServiceMethodTest method setUp.

@Before
public void setUp() throws IOException {
    File numeric = ResourceUtils.copyResourceTo("/parser/calculator/number.thrift", tmp.getRoot());
    File calculator = ResourceUtils.copyResourceTo("/parser/calculator/calculator.thrift", tmp.getRoot());
    ProgramRegistry registry = new ProgramRegistry();
    ThriftProgramParser parser = new ThriftProgramParser();
    ProgramConverter converter = new ProgramConverter(registry);
    ProgramType program = parser.parse(new FileInputStream(numeric), numeric, ImmutableList.of(tmp.getRoot()));
    registry.putProgram(numeric.getCanonicalPath(), converter.convert(numeric.getCanonicalPath(), program));
    program = parser.parse(new FileInputStream(calculator), calculator, ImmutableList.of(tmp.getRoot()));
    registry.putProgram(calculator.getCanonicalPath(), converter.convert(calculator.getCanonicalPath(), program));
    this.registry = registry.registryForPath(calculator.getCanonicalPath());
}
Also used : ProgramRegistry(net.morimekta.providence.reflect.util.ProgramRegistry) ProgramConverter(net.morimekta.providence.reflect.util.ProgramConverter) ProgramType(net.morimekta.providence.model.ProgramType) File(java.io.File) ThriftProgramParser(net.morimekta.providence.reflect.parser.ThriftProgramParser) FileInputStream(java.io.FileInputStream) Before(org.junit.Before)

Example 3 with ProgramConverter

use of net.morimekta.providence.reflect.util.ProgramConverter in project providence by morimekta.

the class CServiceTest method setUp.

@Before
public void setUp() throws IOException {
    File numeric = ResourceUtils.copyResourceTo("/parser/calculator/number.thrift", tmp.getRoot());
    File calculator = ResourceUtils.copyResourceTo("/parser/calculator/calculator.thrift", tmp.getRoot());
    ProgramRegistry registry = new ProgramRegistry();
    ThriftProgramParser parser = new ThriftProgramParser();
    ProgramConverter converter = new ProgramConverter(registry);
    ProgramType program = parser.parse(new FileInputStream(numeric), numeric, ImmutableList.of(tmp.getRoot()));
    registry.putProgram(numeric.getCanonicalPath(), converter.convert(numeric.getCanonicalPath(), program));
    program = parser.parse(new FileInputStream(calculator), calculator, ImmutableList.of(tmp.getRoot()));
    registry.putProgram(calculator.getCanonicalPath(), converter.convert(calculator.getCanonicalPath(), program));
    this.registry = registry.registryForPath(calculator.getCanonicalPath());
}
Also used : ProgramRegistry(net.morimekta.providence.reflect.util.ProgramRegistry) ProgramConverter(net.morimekta.providence.reflect.util.ProgramConverter) ProgramType(net.morimekta.providence.model.ProgramType) File(java.io.File) ThriftProgramParser(net.morimekta.providence.reflect.parser.ThriftProgramParser) FileInputStream(java.io.FileInputStream) Before(org.junit.Before)

Aggregations

File (java.io.File)3 ProgramType (net.morimekta.providence.model.ProgramType)3 ThriftProgramParser (net.morimekta.providence.reflect.parser.ThriftProgramParser)3 ProgramConverter (net.morimekta.providence.reflect.util.ProgramConverter)3 ProgramRegistry (net.morimekta.providence.reflect.util.ProgramRegistry)3 Before (org.junit.Before)3 FileInputStream (java.io.FileInputStream)2