Search in sources :

Example 1 with DefaultSchemaLocationResolver

use of org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver in project eclipselink by eclipse-ee4j.

the class DefineAndGenerateAppInfoTestCases method testNullSource.

public void testNullSource() {
    InputStream is = getSchemaInputStream(getSchemaToDefine());
    List types = xsdHelper.define(is, getSchemaLocation());
    compareGeneratedTypes(getControlTypes(), types);
    DefaultSchemaLocationResolver resolver = new DefaultSchemaLocationResolver(getMap());
    String generatedSchema = ((SDOXSDHelper) xsdHelper).generate(types, resolver);
    Type itemsType = typeHelper.getType(getUri(), "Items");
    Property itemProp = itemsType.getProperty("item");
    String appInfoItemTest = xsdHelper.getAppinfo(itemProp, null);
}
Also used : Type(commonj.sdo.Type) SDOType(org.eclipse.persistence.sdo.SDOType) DefaultSchemaLocationResolver(org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver) InputStream(java.io.InputStream) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper) ArrayList(java.util.ArrayList) List(java.util.List) SDOProperty(org.eclipse.persistence.sdo.SDOProperty) Property(commonj.sdo.Property)

Example 2 with DefaultSchemaLocationResolver

use of org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver in project eclipselink by eclipse-ee4j.

the class DefineAndGenerateAppInfoTestCases method testDefineAndGenerate.

@Override
public void testDefineAndGenerate() throws Exception {
    InputStream is = getSchemaInputStream(getSchemaToDefine());
    List types = xsdHelper.define(is, getSchemaLocation());
    compareGeneratedTypes(getControlTypes(), types);
    DefaultSchemaLocationResolver resolver = new DefaultSchemaLocationResolver(getMap());
    String generatedSchema = ((SDOXSDHelper) xsdHelper).generate(types, resolver);
    String controlSchema = getSchema(getControlGeneratedFileName());
    log("EXPECTED: \n" + controlSchema);
    log("ACTUAL: \n" + generatedSchema);
    StringReader reader = new StringReader(generatedSchema);
    InputSource inputSource = new InputSource(reader);
    Document generatedSchemaDoc = parser.parse(inputSource);
    reader.close();
    assertSchemaIdentical(getDocument(getControlGeneratedFileName()), generatedSchemaDoc);
}
Also used : InputSource(org.xml.sax.InputSource) DefaultSchemaLocationResolver(org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver) InputStream(java.io.InputStream) StringReader(java.io.StringReader) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper) ArrayList(java.util.ArrayList) List(java.util.List) Document(org.w3c.dom.Document)

Example 3 with DefaultSchemaLocationResolver

use of org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver in project eclipselink by eclipse-ee4j.

the class DefineAndGenerateWrapperTypeTestCases method testSchemaTypeAsDataObject.

public void testSchemaTypeAsDataObject() throws Exception {
    DefaultSchemaLocationResolver resolver = new DefaultSchemaLocationResolver(getMap());
    String generatedSchema = ((SDOXSDHelper) xsdHelper).generate(getTypesToGenerateFromForSchemaTypeTest(), resolver);
    String controlSchema = getSchema(getControlGeneratedFileName());
    log("EXPECTED: \n" + controlSchema);
    log("ACTUAL: \n" + generatedSchema);
    StringReader reader = new StringReader(generatedSchema);
    InputSource inputSource = new InputSource(reader);
    Document generatedSchemaDoc = parser.parse(inputSource);
    reader.close();
    assertSchemaIdentical(getDocument(getControlGeneratedFileName()), generatedSchemaDoc);
}
Also used : InputSource(org.xml.sax.InputSource) DefaultSchemaLocationResolver(org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver) StringReader(java.io.StringReader) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper) Document(org.w3c.dom.Document)

Example 4 with DefaultSchemaLocationResolver

use of org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver in project eclipselink by eclipse-ee4j.

the class DefineAndGenerateWrapperTypeTestCases method testGenerateSchemaRoundTrip.

public void testGenerateSchemaRoundTrip() throws Exception {
    DefaultSchemaLocationResolver resolver = new DefaultSchemaLocationResolver(getMap());
    FileInputStream is = new FileInputStream(getSchemaToDefine());
    List types = xsdHelper.define(is, null);
    String generatedSchema = ((SDOXSDHelper) xsdHelper).generate(types, resolver);
    String controlSchema = getSchema(getSchemaToDefine());
    log("EXPECTED: \n" + controlSchema);
    log("ACTUAL: \n" + generatedSchema);
    StringReader reader = new StringReader(generatedSchema);
    InputSource inputSource = new InputSource(reader);
    Document generatedSchemaDoc = parser.parse(inputSource);
    reader.close();
    assertSchemaIdentical(getDocument(getSchemaToDefine()), generatedSchemaDoc);
}
Also used : InputSource(org.xml.sax.InputSource) DefaultSchemaLocationResolver(org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver) StringReader(java.io.StringReader) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper) ArrayList(java.util.ArrayList) List(java.util.List) Document(org.w3c.dom.Document) FileInputStream(java.io.FileInputStream)

Example 5 with DefaultSchemaLocationResolver

use of org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver in project eclipselink by eclipse-ee4j.

the class DefineAndGenerateBidirectionalTestCases method testDefineAndGenerateUsingSpecMethod.

/**
 * This function will define control types programmatically to compare to XSD definition
 * by using the standard spec SDODataObject generation method on page
 *
 * The existing getControlTypes() uses non-public Property constructors
 */
public void testDefineAndGenerateUsingSpecMethod() throws Exception {
    boolean useXSD = false;
    List types;
    DefaultSchemaLocationResolver resolver = new DefaultSchemaLocationResolver(getMap());
    if (useXSD) {
        // InputStream is = getSchemaInputStream(getSchemaToDefine());
        // List types = xsdHelper.define(is, getSchemaLocation());
        types = xsdHelper.define(getXSDString(XSD_PATH));
    // compareGeneratedTypes(getControlTypesViaSpecMethod(), types);
    } else {
        registerTypes();
        types = getTypesToGenerateFrom();
    }
    String generatedSchema = ((SDOXSDHelper) xsdHelper).generate(types, resolver);
    log(generatedSchema);
    try {
        // false, types);
        root = createRootObject(true, types);
    } catch (Exception e) {
        // SDOTestCase will currently throw a fail()
        fail(e.getMessage());
    }
    int aRootsize = preOrderTraversalDataObjectList((SDODataObject) root).size();
    // assertEquals(4, aRootsize);
    // get opposite properties
    // check that opposite bidirectional links resolve
    // DataObject porderDO = (DataObject)root.get("porder[1]");
    assertTrue(writeXML(root, URINAME, COMPANY_TYPENAME, System.out));
// assertXMLIdentical(getDocument(getControlGeneratedFileName()), generatedSchemaDoc);
}
Also used : DefaultSchemaLocationResolver(org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper) ArrayList(java.util.ArrayList) List(java.util.List) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Aggregations

DefaultSchemaLocationResolver (org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver)19 SDOXSDHelper (org.eclipse.persistence.sdo.helper.SDOXSDHelper)19 Type (commonj.sdo.Type)11 SDODataObject (org.eclipse.persistence.sdo.SDODataObject)11 DataObject (commonj.sdo.DataObject)7 StringReader (java.io.StringReader)7 ArrayList (java.util.ArrayList)7 List (java.util.List)7 QName (javax.xml.namespace.QName)7 ListWrapper (org.eclipse.persistence.sdo.helper.ListWrapper)7 Document (org.w3c.dom.Document)7 InputSource (org.xml.sax.InputSource)7 SDOType (org.eclipse.persistence.sdo.SDOType)4 InputStream (java.io.InputStream)3 DataGraph (commonj.sdo.DataGraph)2 FileInputStream (java.io.FileInputStream)2 SDODataGraph (org.eclipse.persistence.sdo.SDODataGraph)2 Property (commonj.sdo.Property)1 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)1