package test.sdo21.tests.TestData; import java.io.IOException; import java.io.InputStream; import java.net.URL; import commonj.sdo.helper.HelperContext; import commonj.sdo.Type; /** * * Concrete specialization of the StandardFactory test data creation factory * which uses an XSD to create the required metadata. * */ public class StandardXSDFactory extends StandardFactory { public final static String TEST_MODEL = "/api_test.xsd"; public void defineMetaData(HelperContext hc) throws IOException { Type t = hc.getTypeHelper().getType(TEST_NAMESPACE, "Abstract"); if (t != null) { // the test types have already been defined in this HelperContext (this will happen when the // implementation being tested does not support multiple contexts, which is not a 2.1 requirement). return; } // Populate the meta data for the test model (APITest) URL url = this.getClass().getResource(TEST_MODEL); InputStream inputStream = url.openStream(); hc.getXSDHelper().define(inputStream, url.toString()); inputStream.close(); } }