Xsd2AvroTranslator { public Map < String, String > translate(File xsdInput, String avroNamespacePrefix) throws IOException { log.info("COBOL to Avro translator started"); Map < String, String > mapSchemas = new HashMap < String, String >(); if (!xsdInput.exists()) { throw new IOException("Specified input '" + xsdInput.getName() + "' does not exist"); } log.info("Reading legstar xsd files from " + xsdInput.getName()); if (xsdInput.isDirectory()) { Collection < File > xsdFiles = FileUtils.listFiles(xsdInput, new String[] { "xsd" }, true); for (File xsdFile : xsdFiles) { translate(xsdFile, mapSchemas, avroNamespacePrefix); } } else { translate(xsdInput, mapSchemas, avroNamespacePrefix); } log.info("COBOL to Avro translator ended"); return mapSchemas; }  Map < String, String > translate(File xsdInput,
            String avroNamespacePrefix); String translate(Reader reader, String avroNamespace,
            String avroSchemaName); String translate(XmlSchema xmlSchema, String avroNamespace,
            String avroSchemaName); String getAvroFieldName(final XmlSchemaElement xsdElement); String getAvroTypeName(final XmlSchemaComplexType xsdType); static final String CHOICE_PREFIX_FORMAT; }
@Test public void testRdef01() throws Exception { Xsd2AvroTranslator cob2Avro = new Xsd2AvroTranslator(); Map<String, String> mapSchemas = cob2Avro.translate(new File( TEST_XSD_FOLDER, "rdef01.xsd"), "legstar.avro.test"); assertEquals(1, mapSchemas.size()); check(mapSchemas.get("rdef01"), "rdef01.avsc"); checkSchema(mapSchemas.get("rdef01"), 2); }
@Test public void testRdef02() throws Exception { Xsd2AvroTranslator cob2Avro = new Xsd2AvroTranslator(); Map<String, String> mapSchemas = cob2Avro.translate(new File( TEST_XSD_FOLDER, "rdef02.xsd"), "legstar.avro.test"); assertEquals(1, mapSchemas.size()); check(mapSchemas.get("rdef02"), "rdef02.avsc"); checkSchema(mapSchemas.get("rdef02"), 3); }
@Test public void testCusdat() throws Exception { Xsd2AvroTranslator cob2Avro = new Xsd2AvroTranslator(); Map<String, String> mapSchemas = cob2Avro.translate(new File( TEST_XSD_FOLDER, "cusdat.xsd"), "legstar.avro.test"); assertEquals(1, mapSchemas.size()); check(mapSchemas.get("cusdat"), "cusdat.avsc"); checkSchema(mapSchemas.get("cusdat"), 3); }
@Test public void testCflt01() throws Exception { Xsd2AvroTranslator cob2Avro = new Xsd2AvroTranslator(); Map<String, String> mapSchemas = cob2Avro.translate(new File( TEST_XSD_FOLDER, "cflt01.xsd"), "legstar.avro.test"); assertEquals(1, mapSchemas.size()); check(mapSchemas.get("cflt01"), "cflt01.avsc"); checkSchema(mapSchemas.get("cflt01"), 2); }
@Test public void testOptl01() throws Exception { Xsd2AvroTranslator cob2Avro = new Xsd2AvroTranslator(); Map<String, String> mapSchemas = cob2Avro.translate(new File( TEST_XSD_FOLDER, "optl01.xsd"), "legstar.avro.test"); assertEquals(1, mapSchemas.size()); check(mapSchemas.get("optl01"), "optl01.avsc"); checkSchema(mapSchemas.get("optl01"), 4); }
@Test public void testFlat01() throws Exception { Xsd2AvroTranslator cob2Avro = new Xsd2AvroTranslator(); Map<String, String> mapSchemas = cob2Avro.translate(new File( TEST_XSD_FOLDER, "flat01.xsd"), "legstar.avro.test"); assertEquals(1, mapSchemas.size()); check(mapSchemas.get("flat01"), "flat01.avsc"); checkSchema(mapSchemas.get("flat01"), 3); }
@Test public void testFlat02() throws Exception { Xsd2AvroTranslator cob2Avro = new Xsd2AvroTranslator(); Map<String, String> mapSchemas = cob2Avro.translate(new File( TEST_XSD_FOLDER, "flat02.xsd"), "legstar.avro.test"); assertEquals(1, mapSchemas.size()); check(mapSchemas.get("flat02"), "flat02.avsc"); checkSchema(mapSchemas.get("flat02"), 4); }
@Test public void testStru03() throws Exception { Xsd2AvroTranslator cob2Avro = new Xsd2AvroTranslator(); Map<String, String> mapSchemas = cob2Avro.translate(new File( TEST_XSD_FOLDER, "stru03.xsd"), "legstar.avro.test"); assertEquals(1, mapSchemas.size()); check(mapSchemas.get("stru03"), "stru03.avsc"); checkSchema(mapSchemas.get("stru03"), 4); }
@Test public void testStru04() throws Exception { Xsd2AvroTranslator cob2Avro = new Xsd2AvroTranslator(); Map<String, String> mapSchemas = cob2Avro.translate(new File( TEST_XSD_FOLDER, "stru04.xsd"), "legstar.avro.test"); assertEquals(1, mapSchemas.size()); check(mapSchemas.get("stru04"), "stru04.avsc"); checkSchema(mapSchemas.get("stru04"), 3); }
@Test public void testStru05() throws Exception { Xsd2AvroTranslator cob2Avro = new Xsd2AvroTranslator(); Map<String, String> mapSchemas = cob2Avro.translate(new File( TEST_XSD_FOLDER, "stru05.xsd"), "legstar.avro.test"); assertEquals(1, mapSchemas.size()); check(mapSchemas.get("stru05"), "stru05.avsc"); checkSchema(mapSchemas.get("stru05"), 3); }
@Test public void testAlltypes() throws Exception { Xsd2AvroTranslator cob2Avro = new Xsd2AvroTranslator(); Map<String, String> mapSchemas = cob2Avro.translate(new File( TEST_XSD_FOLDER, "alltypes.xsd"), "legstar.avro.test"); assertEquals(1, mapSchemas.size()); check(mapSchemas.get("alltypes"), "alltypes.avsc"); checkSchema(mapSchemas.get("alltypes"), 26); }