@Test public void testXsdGen() throws IOException { final File outFile = new File("test_sli.xsd"); if (!outFile.exists()) { if (!outFile.createNewFile()) { Assert.fail("failed to create temp file " + outFile.getName()); } } final String folder = getFolder(outFile); final String file = outFile.getName(); final String[] strArr = new String[] { "--documentFile", getAbsPath("test_doc.xml"), "--xmiFile", getAbsPath("test_sli.xmi"), "--plugInName", "org.slc.sli.modeling.tools.xsdgen.PluginForREST", "--outFolder", folder, "--outFile", file }; XsdGen.main(strArr); final URIResolver mockResolver = Mockito.mock(URIResolver.class); final XmlSchema schema = XsdReader.readSchema(outFile.getAbsoluteFile(), mockResolver); Assert.assertNotNull(schema); Assert.assertEquals(2, schema.getElements().getCount()); Assert.assertNotNull(schema.getElementByName("assessmentList")); Assert.assertNotNull(schema.getElementByName("assessment")); outFile.deleteOnExit(); }
public static void main(final String[] args) { final OptionParser parser = new OptionParser(); final OptionSpec<?> helpSpec = parser.acceptsAll(ARGUMENT_HELP, "Show help"); final OptionSpec<File> documentFileSpec = optionSpec(parser, ARGUMENT_DOCUMENT_FILE, "Domain file", File.class); final OptionSpec<File> xmiFileSpec = optionSpec(parser, ARGUMENT_XMI, "XMI file", File.class); final OptionSpec<String> outFileSpec = optionSpec(parser, ARGUMENT_OUT_FILE, "Output file", String.class); final OptionSpec<File> outFolderSpec = optionSpec(parser, ARGUMENT_OUT_FOLDER, "Output folder", File.class); final OptionSpec<String> plugInNameSpec = optionSpec(parser, ARGUMENT_PLUGIN_NAME, "PlugIn name", String.class); try { final OptionSet options = parser.parse(args); if (options.hasArgument(helpSpec)) { try { parser.printHelpOn(System.out); } catch (final IOException e) { throw new XsdGenRuntimeException(e); } } else { try { final File xmiFile = options.valueOf(xmiFileSpec); final ModelIndex model = new DefaultModelIndex(XmiReader.readModel(xmiFile)); final File documentFile = options.valueOf(documentFileSpec); final PsmConfig<Type> psmConfig = PsmConfigReader.readConfig(documentFile, model); final String plugInName = options.valueOf(plugInNameSpec); final Uml2XsdPlugin plugIn = loadPlugIn(plugInName); final File outFolder = options.valueOf(outFolderSpec); final String outFile = options.valueOf(outFileSpec); final File outLocation = new File(outFolder, outFile); Uml2XsdWriter.writeSchema(psmConfig.getDocuments(), model, plugIn, outLocation); } catch (final FileNotFoundException e) { throw new XsdGenRuntimeException(e); } } } catch (final OptionException e) { LOG.error(e.getMessage()); } catch (final ClassNotFoundException e) { LOG.warn("Unable to load plugin specified in " + ARGUMENT_PLUGIN_NAME + " argument: " + e.getMessage()); } }
XsdGen { public static void main(final String[] args) { final OptionParser parser = new OptionParser(); final OptionSpec<?> helpSpec = parser.acceptsAll(ARGUMENT_HELP, "Show help"); final OptionSpec<File> documentFileSpec = optionSpec(parser, ARGUMENT_DOCUMENT_FILE, "Domain file", File.class); final OptionSpec<File> xmiFileSpec = optionSpec(parser, ARGUMENT_XMI, "XMI file", File.class); final OptionSpec<String> outFileSpec = optionSpec(parser, ARGUMENT_OUT_FILE, "Output file", String.class); final OptionSpec<File> outFolderSpec = optionSpec(parser, ARGUMENT_OUT_FOLDER, "Output folder", File.class); final OptionSpec<String> plugInNameSpec = optionSpec(parser, ARGUMENT_PLUGIN_NAME, "PlugIn name", String.class); try { final OptionSet options = parser.parse(args); if (options.hasArgument(helpSpec)) { try { parser.printHelpOn(System.out); } catch (final IOException e) { throw new XsdGenRuntimeException(e); } } else { try { final File xmiFile = options.valueOf(xmiFileSpec); final ModelIndex model = new DefaultModelIndex(XmiReader.readModel(xmiFile)); final File documentFile = options.valueOf(documentFileSpec); final PsmConfig<Type> psmConfig = PsmConfigReader.readConfig(documentFile, model); final String plugInName = options.valueOf(plugInNameSpec); final Uml2XsdPlugin plugIn = loadPlugIn(plugInName); final File outFolder = options.valueOf(outFolderSpec); final String outFile = options.valueOf(outFileSpec); final File outLocation = new File(outFolder, outFile); Uml2XsdWriter.writeSchema(psmConfig.getDocuments(), model, plugIn, outLocation); } catch (final FileNotFoundException e) { throw new XsdGenRuntimeException(e); } } } catch (final OptionException e) { LOG.error(e.getMessage()); } catch (final ClassNotFoundException e) { LOG.warn("Unable to load plugin specified in " + ARGUMENT_PLUGIN_NAME + " argument: " + e.getMessage()); } } }
XsdGen { public static void main(final String[] args) { final OptionParser parser = new OptionParser(); final OptionSpec<?> helpSpec = parser.acceptsAll(ARGUMENT_HELP, "Show help"); final OptionSpec<File> documentFileSpec = optionSpec(parser, ARGUMENT_DOCUMENT_FILE, "Domain file", File.class); final OptionSpec<File> xmiFileSpec = optionSpec(parser, ARGUMENT_XMI, "XMI file", File.class); final OptionSpec<String> outFileSpec = optionSpec(parser, ARGUMENT_OUT_FILE, "Output file", String.class); final OptionSpec<File> outFolderSpec = optionSpec(parser, ARGUMENT_OUT_FOLDER, "Output folder", File.class); final OptionSpec<String> plugInNameSpec = optionSpec(parser, ARGUMENT_PLUGIN_NAME, "PlugIn name", String.class); try { final OptionSet options = parser.parse(args); if (options.hasArgument(helpSpec)) { try { parser.printHelpOn(System.out); } catch (final IOException e) { throw new XsdGenRuntimeException(e); } } else { try { final File xmiFile = options.valueOf(xmiFileSpec); final ModelIndex model = new DefaultModelIndex(XmiReader.readModel(xmiFile)); final File documentFile = options.valueOf(documentFileSpec); final PsmConfig<Type> psmConfig = PsmConfigReader.readConfig(documentFile, model); final String plugInName = options.valueOf(plugInNameSpec); final Uml2XsdPlugin plugIn = loadPlugIn(plugInName); final File outFolder = options.valueOf(outFolderSpec); final String outFile = options.valueOf(outFileSpec); final File outLocation = new File(outFolder, outFile); Uml2XsdWriter.writeSchema(psmConfig.getDocuments(), model, plugIn, outLocation); } catch (final FileNotFoundException e) { throw new XsdGenRuntimeException(e); } } } catch (final OptionException e) { LOG.error(e.getMessage()); } catch (final ClassNotFoundException e) { LOG.warn("Unable to load plugin specified in " + ARGUMENT_PLUGIN_NAME + " argument: " + e.getMessage()); } }  }
XsdGen { public static void main(final String[] args) { final OptionParser parser = new OptionParser(); final OptionSpec<?> helpSpec = parser.acceptsAll(ARGUMENT_HELP, "Show help"); final OptionSpec<File> documentFileSpec = optionSpec(parser, ARGUMENT_DOCUMENT_FILE, "Domain file", File.class); final OptionSpec<File> xmiFileSpec = optionSpec(parser, ARGUMENT_XMI, "XMI file", File.class); final OptionSpec<String> outFileSpec = optionSpec(parser, ARGUMENT_OUT_FILE, "Output file", String.class); final OptionSpec<File> outFolderSpec = optionSpec(parser, ARGUMENT_OUT_FOLDER, "Output folder", File.class); final OptionSpec<String> plugInNameSpec = optionSpec(parser, ARGUMENT_PLUGIN_NAME, "PlugIn name", String.class); try { final OptionSet options = parser.parse(args); if (options.hasArgument(helpSpec)) { try { parser.printHelpOn(System.out); } catch (final IOException e) { throw new XsdGenRuntimeException(e); } } else { try { final File xmiFile = options.valueOf(xmiFileSpec); final ModelIndex model = new DefaultModelIndex(XmiReader.readModel(xmiFile)); final File documentFile = options.valueOf(documentFileSpec); final PsmConfig<Type> psmConfig = PsmConfigReader.readConfig(documentFile, model); final String plugInName = options.valueOf(plugInNameSpec); final Uml2XsdPlugin plugIn = loadPlugIn(plugInName); final File outFolder = options.valueOf(outFolderSpec); final String outFile = options.valueOf(outFileSpec); final File outLocation = new File(outFolder, outFile); Uml2XsdWriter.writeSchema(psmConfig.getDocuments(), model, plugIn, outLocation); } catch (final FileNotFoundException e) { throw new XsdGenRuntimeException(e); } } } catch (final OptionException e) { LOG.error(e.getMessage()); } catch (final ClassNotFoundException e) { LOG.warn("Unable to load plugin specified in " + ARGUMENT_PLUGIN_NAME + " argument: " + e.getMessage()); } }  static void main(final String[] args); }
XsdGen { public static void main(final String[] args) { final OptionParser parser = new OptionParser(); final OptionSpec<?> helpSpec = parser.acceptsAll(ARGUMENT_HELP, "Show help"); final OptionSpec<File> documentFileSpec = optionSpec(parser, ARGUMENT_DOCUMENT_FILE, "Domain file", File.class); final OptionSpec<File> xmiFileSpec = optionSpec(parser, ARGUMENT_XMI, "XMI file", File.class); final OptionSpec<String> outFileSpec = optionSpec(parser, ARGUMENT_OUT_FILE, "Output file", String.class); final OptionSpec<File> outFolderSpec = optionSpec(parser, ARGUMENT_OUT_FOLDER, "Output folder", File.class); final OptionSpec<String> plugInNameSpec = optionSpec(parser, ARGUMENT_PLUGIN_NAME, "PlugIn name", String.class); try { final OptionSet options = parser.parse(args); if (options.hasArgument(helpSpec)) { try { parser.printHelpOn(System.out); } catch (final IOException e) { throw new XsdGenRuntimeException(e); } } else { try { final File xmiFile = options.valueOf(xmiFileSpec); final ModelIndex model = new DefaultModelIndex(XmiReader.readModel(xmiFile)); final File documentFile = options.valueOf(documentFileSpec); final PsmConfig<Type> psmConfig = PsmConfigReader.readConfig(documentFile, model); final String plugInName = options.valueOf(plugInNameSpec); final Uml2XsdPlugin plugIn = loadPlugIn(plugInName); final File outFolder = options.valueOf(outFolderSpec); final String outFile = options.valueOf(outFileSpec); final File outLocation = new File(outFolder, outFile); Uml2XsdWriter.writeSchema(psmConfig.getDocuments(), model, plugIn, outLocation); } catch (final FileNotFoundException e) { throw new XsdGenRuntimeException(e); } } } catch (final OptionException e) { LOG.error(e.getMessage()); } catch (final ClassNotFoundException e) { LOG.warn("Unable to load plugin specified in " + ARGUMENT_PLUGIN_NAME + " argument: " + e.getMessage()); } }  static void main(final String[] args);  }