Java Code Examples for com.sun.tools.xjc.Options#parseArguments()

The following examples show how to use com.sun.tools.xjc.Options#parseArguments() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonixPluginTest.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void compilesWFS_V_2_0() throws Exception {

	new File("target/generated-sources/wfs-v_2_0").mkdirs();

	URL schema = getClass().getResource("/ogc/wfs/2.0/wfs.xsd");
	URL binding = getClass().getResource("/ogc/wfs-v_2_0.xjb");
	final String[] arguments = new String[] { "-xmlschema",
			schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
			"target/generated-sources/wfs-v_2_0", "-extension", "-Xjsonix"

	};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
Example 2
Source File: RunPluginsForCustomer.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
	public void compilesCustomer() throws Exception {

		new File("target/generated-sources/xjc").mkdirs();

		URL schema = getClass().getResource("/customer.xsd");
		URL binding = getClass().getResource("/customer.xjb");
		final String[] arguments = new String[] { "-xmlschema",
				schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
				"target/generated-sources/xjc", "-extension",
				"-XsimpleHashCode",
//				"-XsimpleEquals", "-XsimpleToString" 
				};

		Options options = new Options();
		options.parseArguments(arguments);
		ConsoleErrorReporter receiver = new ConsoleErrorReporter();
		Model model = ModelLoader.load(options, new JCodeModel(), receiver);
		model.generateCode(options, receiver);
		com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
		model.codeModel.build(cw);
	}
 
Example 3
Source File: RunPluginsForMain.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
	public void compilesSchema() throws Exception {

		new File("target/generated-sources/xjc").mkdirs();

		URL schema = getClass().getResource("/main.xsd");
		URL binding = getClass().getResource("/main.xjb");
		final String[] arguments = new String[] { "-xmlschema",
				schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
				"target/generated-sources/xjc", "-extension",
				"-XsimpleHashCode",
//				"-XsimpleEquals", "-XsimpleToString"
				};

		Options options = new Options();
		options.parseArguments(arguments);
		ConsoleErrorReporter receiver = new ConsoleErrorReporter();
		Model model = ModelLoader.load(options, new JCodeModel(), receiver);
		model.generateCode(options, receiver);
		com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
		model.codeModel.build(cw);
	}
 
Example 4
Source File: RunPluginsForCases.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void compilesSchema() throws Exception {

	new File("target/generated-sources/xjc").mkdirs();

	URL schema = getClass().getResource("/cases.xsd");
	// URL binding = getClass().getResource("/cases.xjb");
	final String[] arguments = new String[] { "-xmlschema",
			schema.toExternalForm(),
			// "-b", binding.toExternalForm(),
			"-d", "target/generated-sources/xjc", "-extension",
			"-XsimpleHashCode", "-XsimpleEquals",
	// "-XsimpleToString"

	};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
Example 5
Source File: RunSimplifyPlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void compilesSchema() throws Exception {

	new File("target/generated-sources/xjc").mkdirs();

	URL schema = getClass().getResource("/schema.xsd");
	URL binding = getClass().getResource("/binding.xjb");
	final String[] arguments = new String[] { "-xmlschema",
			schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
			"target/generated-sources/xjc", "-extension", "-Xsimplify", "-Xsimplify-usePluralForm=true"};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
Example 6
Source File: ExecuteJAXB1058.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void compilesContext_V_1_1_0() throws Exception {

	new File("target/generated-sources/xjc").mkdirs();

	final String[] arguments = new String[] { "-xmlschema",
			new File("src/main/resources/schema.xsd").toURI().toString(),
			"-d",
			"target/generated-sources/xjc", 
			"-XfixJAXB1058",
			"-extension", "-XtoString",
			"-Xequals", "-XhashCode", "-Xcopyable", "-Xmergeable"};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
Example 7
Source File: RunSimplifyPlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void compilesSchema() throws Exception {

	new File("target/generated-sources/xjc").mkdirs();

	URL schema = getClass().getResource("/schema.xsd");
	URL binding = getClass().getResource("/bindings.xjb");
	final String[] arguments = new String[] { "-xmlschema",
			schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
			"target/generated-sources/xjc", "-extension", "-Xsimplify", "-Xsimplify-usePluralForm=true"};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
Example 8
Source File: RunPlugins.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void compilesSchema() throws Exception {

	new File("target/generated-sources/xjc").mkdirs();

	URL schema = getClass().getResource("/schema.xsd");
	URL binding = getClass().getResource("/binding.xjb");
	final String[] arguments = new String[] { "-xmlschema",
			schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
			"target/generated-sources/xjc", "-extension", "-XtoString",
			"-Xequals", "-XhashCode", "-Xcopyable", "-Xmergeable" };

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
Example 9
Source File: JsonixPluginTest.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void compilesOWS_V_1_1_0() throws Exception {

	new File("target/generated-sources/ows-v_1_1_0").mkdirs();

	URL schema = getClass().getResource("/ogc/ows/1.1.0/owsAll.xsd");
	URL binding = getClass().getResource("/ogc/ows-v_1_1_0.xjb");
	final String[] arguments = new String[] { "-xmlschema",
			schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
			"target/generated-sources/ows-v_1_1_0", "-extension",
			"-Xjsonix"

	};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
Example 10
Source File: JsonixPluginZeroTest.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void compilesBasicZero() throws Exception {

	new File("target/generated-sources/basic/zero").mkdirs();

	final String[] arguments = new String[] {
			"-xmlschema",
			getClass().getResource("/basic/zero/schema.xsd")
					.toExternalForm(), "-d",
			"target/generated-sources/basic/zero", "-extension", "-Xjsonix", "-Xjsonix-generateJsonSchema"

	};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
Example 11
Source File: CompileIssues.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void compilesIssues() throws Exception {

	new File("target/generated-sources/xjc").mkdirs();

	URL schema = getClass().getResource("/schema.xsd");
	URL binding = getClass().getResource("/binding.xjb");

	final String[] arguments = new String[] {
			"-xmlschema", schema.toExternalForm(),
			"-b", binding.toExternalForm(),
			"-d", "target/generated-sources/xjc",
			"-extension",
			"-Xjsonix",
			"-Xjsonix-generateJsonSchema"

	};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
Example 12
Source File: JsonixPluginTest.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void compilesContext_V_1_1_0() throws Exception {

	new File("target/generated-sources/context-v_1_1_0").mkdirs();

	final String[] arguments = new String[] {
			"-xmlschema",
			getClass().getResource("/ogc/context/1.1.0/wmcAll.xsd")
					.toExternalForm(),
			"-b",
			getClass().getResource("/ogc/context-v_1_1_0.xjb")
					.toExternalForm(), "-d",
			"target/generated-sources/context-v_1_1_0", "-extension",
			"-Xjsonix"

	};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}
 
Example 13
Source File: MModelInfoLoader.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public MModelInfo<NType, NClass> loadModel(String resource)
		throws Exception {
	System.setProperty("javax.xml.accessExternalSchema", "all");

	new File("target/generated-sources/" + resource).mkdirs();
	final String[] arguments = new String[] { "-xmlschema",
			getClass().getResource("/" + resource).toExternalForm(), "-d",
			"target/generated-sources/" + resource, "-extension",
			"-Xjsonix", "-Xjsonix-generateJsonSchema" };

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);

	final MModelInfo<NType, NClass> modelInfo = new XJCCMInfoFactory(model)
			.createModel();

	return modelInfo;
}
 
Example 14
Source File: DynamicCompiler.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Options createOptions() throws IOException, BadCommandLineException {
	final Options options = new Options();
	options.targetDir = targetDirectory;
	options.verbose = true;
	options.debugMode = false;
	options.setSchemaLanguage(Language.XMLSCHEMA);
	options.strictCheck = false;
	options.readOnly = false;
	options.compatibilityMode = Options.EXTENSION;
	// options.set

	if (schemas != null) {
		for (final File schema : schemas) {
			options.addGrammar(schema);
		}
	}

	if (bindings != null) {
		for (File binding : bindings) {
			options.addBindFile(binding);
		}
	}

	if (catalog != null) {
		options.addCatalog(catalog);
	}
	options.parseArguments(getArguments());
	return options;
}
 
Example 15
Source File: AlphaMInfoFactoryTest.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@BeforeClass
public static void createModel() throws BadCommandLineException,
		IOException {
	final String generateDirectory = "target/generated-sources/"
			+ AlphaMInfoFactoryTest.class.getPackage().getName();
	new File(generateDirectory).mkdirs();
	final URL schema = AlphaMInfoFactoryTest.class
			.getResource("schema.xsd");
	final URL binding = AlphaMInfoFactoryTest.class
			.getResource("binding.xjb");
	final String[] arguments = new String[] { "-xmlschema",
			schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
			generateDirectory, "-extension" };

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	Assert.assertNotNull(model);

	final XJCCMInfoFactory factory = new XJCCMInfoFactory(model);

	AlphaMInfoFactoryTest.MODEL_INFO = factory.createModel();

	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);

}
 
Example 16
Source File: OptionsFactory.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Creates and initializes an instance of XJC options.
 *
 */
public Options createOptions(OptionsConfiguration optionsConfiguration)
		throws MojoExecutionException {
	final Options options = new Options();

	options.verbose = optionsConfiguration.isVerbose();
	options.debugMode = optionsConfiguration.isDebugMode();

	options.classpaths.addAll(optionsConfiguration.getPlugins());

	options.target = SpecVersion.V2_2;

	final String encoding = optionsConfiguration.getEncoding();

	if (encoding != null) {
		options.encoding = createEncoding(encoding);
	}

	options.setSchemaLanguage(createLanguage(optionsConfiguration
			.getSchemaLanguage()));

	options.entityResolver = optionsConfiguration.getEntityResolver();

	for (InputSource grammar : optionsConfiguration.getGrammars()) {
		options.addGrammar(grammar);
	}

	for (InputSource bindFile : optionsConfiguration.getBindFiles()) {
		options.addBindFile(bindFile);
	}

	// Setup Other Options

	options.defaultPackage = optionsConfiguration.getGeneratePackage();
	options.targetDir = optionsConfiguration.getGenerateDirectory();

	options.strictCheck = optionsConfiguration.isStrict();
	options.readOnly = optionsConfiguration.isReadOnly();
	options.packageLevelAnnotations = optionsConfiguration
			.isPackageLevelAnnotations();
	options.noFileHeader = optionsConfiguration.isNoFileHeader();
	options.enableIntrospection = optionsConfiguration
			.isEnableIntrospection();
	options.disableXmlSecurity = optionsConfiguration
			.isDisableXmlSecurity();
	if (optionsConfiguration.getAccessExternalSchema() != null) {
		System.setProperty("javax.xml.accessExternalSchema",
				optionsConfiguration.getAccessExternalSchema());
	}
	if (optionsConfiguration.getAccessExternalDTD() != null) {
		System.setProperty("javax.xml.accessExternalDTD",
				optionsConfiguration.getAccessExternalDTD());
	}
	if (optionsConfiguration.isEnableExternalEntityProcessing()) {
		System.setProperty("enableExternalEntityProcessing", Boolean.TRUE.toString());
	}
	options.contentForWildcard = optionsConfiguration
			.isContentForWildcard();

	if (optionsConfiguration.isExtension()) {
		options.compatibilityMode = Options.EXTENSION;
	}

	final List<String> arguments = optionsConfiguration.getArguments();
	try {
		options.parseArguments(arguments.toArray(new String[arguments
				.size()]));
	}

	catch (BadCommandLineException bclex) {
		throw new MojoExecutionException("Error parsing the command line ["
				+ arguments + "]", bclex);
	}

	return options;
}
 
Example 17
Source File: OptionsFactory.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Creates and initializes an instance of XJC options.
 * 
 */
public Options createOptions(OptionsConfiguration optionsConfiguration)
		throws MojoExecutionException {
	final Options options = new Options();

	options.verbose = optionsConfiguration.isVerbose();
	options.debugMode = optionsConfiguration.isDebugMode();

	options.classpaths.addAll(optionsConfiguration.getPlugins());

	options.target = createSpecVersion(optionsConfiguration
			.getSpecVersion());

	final String encoding = optionsConfiguration.getEncoding();

	if (encoding != null) {
		options.encoding = createEncoding(encoding);
	}

	options.setSchemaLanguage(createLanguage(optionsConfiguration
			.getSchemaLanguage()));

	options.entityResolver = optionsConfiguration.getEntityResolver();

	for (InputSource grammar : optionsConfiguration.getGrammars()) {
		options.addGrammar(grammar);
	}

	for (InputSource bindFile : optionsConfiguration.getBindFiles()) {
		options.addBindFile(bindFile);
	}

	// Setup Other Options

	options.defaultPackage = optionsConfiguration.getGeneratePackage();
	options.targetDir = optionsConfiguration.getGenerateDirectory();

	options.strictCheck = optionsConfiguration.isStrict();
	options.readOnly = optionsConfiguration.isReadOnly();
	options.packageLevelAnnotations = optionsConfiguration
			.isPackageLevelAnnotations();
	options.noFileHeader = optionsConfiguration.isNoFileHeader();
	options.enableIntrospection = optionsConfiguration
			.isEnableIntrospection();
	options.disableXmlSecurity = optionsConfiguration
			.isDisableXmlSecurity();

	if (optionsConfiguration.getAccessExternalSchema() != null) {
		System.setProperty("javax.xml.accessExternalSchema",
				optionsConfiguration.getAccessExternalSchema());
	}
	if (optionsConfiguration.getAccessExternalDTD() != null) {
		System.setProperty("javax.xml.accessExternalDTD",
				optionsConfiguration.getAccessExternalDTD());
	}
	if (optionsConfiguration.isEnableExternalEntityProcessing()) {
		System.setProperty("enableExternalEntityProcessing", Boolean.TRUE.toString());
	}
	options.contentForWildcard = optionsConfiguration
			.isContentForWildcard();

	if (optionsConfiguration.isExtension()) {
		options.compatibilityMode = Options.EXTENSION;
	}

	final List<String> arguments = optionsConfiguration.getArguments();
	try {
		options.parseArguments(arguments.toArray(new String[arguments
				.size()]));
	}

	catch (BadCommandLineException bclex) {
		throw new MojoExecutionException("Error parsing the command line ["
				+ arguments + "]", bclex);
	}

	return options;
}
 
Example 18
Source File: OptionsFactory.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Creates and initializes an instance of XJC options.
 *
 */
public Options createOptions(OptionsConfiguration optionsConfiguration)
		throws MojoExecutionException {
	final Options options = new Options();

	options.verbose = optionsConfiguration.isVerbose();
	options.debugMode = optionsConfiguration.isDebugMode();

	options.classpaths.addAll(optionsConfiguration.getPlugins());

	options.target = SpecVersion.V2_1;

	options.setSchemaLanguage(createLanguage(optionsConfiguration
			.getSchemaLanguage()));

	options.entityResolver = optionsConfiguration.getEntityResolver();

	for (InputSource grammar : optionsConfiguration.getGrammars()) {
		options.addGrammar(grammar);
	}

	for (InputSource bindFile : optionsConfiguration.getBindFiles()) {
		options.addBindFile(bindFile);
	}

	// Setup Other Options

	options.defaultPackage = optionsConfiguration.getGeneratePackage();
	options.targetDir = optionsConfiguration.getGenerateDirectory();

	options.strictCheck = optionsConfiguration.isStrict();
	options.readOnly = optionsConfiguration.isReadOnly();
	options.packageLevelAnnotations = optionsConfiguration
			.isPackageLevelAnnotations();
	options.noFileHeader = optionsConfiguration.isNoFileHeader();
	options.enableIntrospection = optionsConfiguration
			.isEnableIntrospection();
	// options.disableXmlSecurity =
	// optionsConfiguration.isDisableXmlSecurity();
	if (optionsConfiguration.getAccessExternalSchema() != null) {
		System.setProperty("javax.xml.accessExternalSchema",
				optionsConfiguration.getAccessExternalSchema());
	}
	if (optionsConfiguration.getAccessExternalDTD() != null) {
		System.setProperty("javax.xml.accessExternalDTD",
				optionsConfiguration.getAccessExternalDTD());
	}
	if (optionsConfiguration.isEnableExternalEntityProcessing()) {
		System.setProperty("enableExternalEntityProcessing", Boolean.TRUE.toString());
	}
	options.contentForWildcard = optionsConfiguration
			.isContentForWildcard();

	if (optionsConfiguration.isExtension()) {
		options.compatibilityMode = Options.EXTENSION;
	}

	final List<String> arguments = optionsConfiguration.getArguments();
	try {
		options.parseArguments(arguments.toArray(new String[arguments
				.size()]));
	}

	catch (BadCommandLineException bclex) {
		throw new MojoExecutionException("Error parsing the command line ["
				+ arguments + "]", bclex);
	}

	return options;
}
 
Example 19
Source File: GH26Test.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Test
	public void compilesSchema() throws Exception {

		new File("target/generated-sources/xjc").mkdirs();

		URL schema = getClass().getResource("/schema.xsd");
		URL binding = getClass().getResource("/binding.xjb");
		final String[] arguments = new String[] { "-xmlschema",
				schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
				"target/generated-sources/xjc", "-extension", "-XhashCode",
				"-Xequals", "-XtoString", "-Xcopyable", "-Xmergeable",
				"-Xinheritance", "-Xsetters", "-Xsetters-mode=direct",
				"-Xwildcard", "-XenumValue"
		// "-XsimpleToString"

		};

		Options options = new Options();
		options.parseArguments(arguments);
		ConsoleErrorReporter receiver = new ConsoleErrorReporter();
		Model model = ModelLoader.load(options, new JCodeModel(), receiver);
		final XJCCMInfoFactory factory = new XJCCMInfoFactory(model);
		final MModelInfo<NType, NClass> mmodel = factory.createModel();

		final MClassInfo<NType, NClass> classInfo = mmodel
				.getClassInfo("org.jvnet.jaxb2_commons.tests.issues.IssueGH26Type");
		Assert.assertNotNull(classInfo);

		final MElementPropertyInfo<NType, NClass> a = (MElementPropertyInfo<NType, NClass>) classInfo
				.getProperty("a");
		Assert.assertEquals("a", a.getDefaultValue());
		Assert.assertNotNull(a.getDefaultValueNamespaceContext());
		final MElementsPropertyInfo<NType, NClass> bOrC = (MElementsPropertyInfo<NType, NClass>) classInfo
				.getProperty("bOrC");
		
//		Assert.assertEquals("b", bOrC.getElementTypeInfos().get(0).getDefaultValue());
		Assert.assertNotNull(bOrC.getElementTypeInfos().get(0).getDefaultValueNamespaceContext());
		
//		Assert.assertEquals("3", bOrC.getElementTypeInfos().get(1).getDefaultValue());
		Assert.assertNotNull(bOrC.getElementTypeInfos().get(1).getDefaultValueNamespaceContext());

		final MElementRefsPropertyInfo<NType, NClass> dOrE = (MElementRefsPropertyInfo<NType, NClass>) classInfo
				.getProperty("dOrE");
//		Assert.assertEquals("e", dOrE.getElementTypeInfos().get(0).getDefaultValue());
		Assert.assertNotNull(dOrE.getElementTypeInfos().get(0).getDefaultValueNamespaceContext());
		
//		Assert.assertEquals("d", dOrE.getElementTypeInfos().get(1).getDefaultValue());
		Assert.assertNotNull(dOrE.getElementTypeInfos().get(1).getDefaultValueNamespaceContext());

		final MAttributePropertyInfo<NType, NClass> z = (MAttributePropertyInfo<NType, NClass>) classInfo
				.getProperty("z");
		Assert.assertEquals("z", z.getDefaultValue());
		Assert.assertNotNull(z.getDefaultValueNamespaceContext());
		// model.generateCode(options, receiver);
		// com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
		// model.codeModel.build(cw);
	}
 
Example 20
Source File: RunPlugins.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Test
public void compilesSchema() throws Exception {

	new File("target/generated-sources/xjc").mkdirs();

	URL schema = getClass().getResource("/schema.xsd");
	URL binding = getClass().getResource("/binding.xjb");
	final String[] arguments = new String[] {
			//
			"-xmlschema", schema.toExternalForm(),
			//
			"-b", binding.toExternalForm(),
			//
			"-d", "target/generated-sources/xjc",
			//
			"-extension",
			//
			"-XhashCode",
			//
			"-Xequals",
			//
			"-XtoString",
			//
			"-Xcopyable",
			//
			"-Xmergeable",
			//
			"-Xinheritance",
			//
			"-Xsetters",
			//
			"-Xsetters-mode=direct",
			//
			"-Xwildcard",
			//
			"-XenumValue"
			// "-XsimpleToString"
	};

	Options options = new Options();
	options.parseArguments(arguments);
	ConsoleErrorReporter receiver = new ConsoleErrorReporter();
	Model model = ModelLoader.load(options, new JCodeModel(), receiver);
	model.generateCode(options, receiver);
	com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
	model.codeModel.build(cw);
}