summaryrefslogtreecommitdiffstats
path: root/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/TestData/StandardXSDFactory.java
blob: 828b0117e63629ccc8cb78d2407f4e01259e58f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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();
    
  }
  

}