Search in sources :

Example 36 with SDOXMLHelper

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

the class SDOTestCase method setUp.

@Override
public void setUp() {
    xmlComparer = new SDOXMLComparer();
    if (customContext) {
        // default to instance of a HelperContext
        aHelperContext = new SDOHelperContext();
    } else {
        // default to static context (Global)
        aHelperContext = HelperProvider.getDefaultContext();
    }
    typeHelper = aHelperContext.getTypeHelper();
    xmlHelper = aHelperContext.getXMLHelper();
    xsdHelper = aHelperContext.getXSDHelper();
    equalityHelper = aHelperContext.getEqualityHelper();
    copyHelper = aHelperContext.getCopyHelper();
    dataFactory = aHelperContext.getDataFactory();
    // TODO: we should be using the DataHelper interface
    dataHelper = (SDODataHelper) aHelperContext.getDataHelper();
    DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
    builderFactory.setNamespaceAware(true);
    builderFactory.setIgnoringElementContentWhitespace(true);
    try {
        parser = builderFactory.newDocumentBuilder();
    } catch (Exception e) {
        fail("Could not create parser.");
        e.printStackTrace();
    }
    ((SDOTypeHelper) typeHelper).reset();
    ((SDOXMLHelper) xmlHelper).reset();
    ((SDOXSDHelper) xsdHelper).reset();
}
Also used : SDOTypeHelper(org.eclipse.persistence.sdo.helper.SDOTypeHelper) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) SDOHelperContext(org.eclipse.persistence.sdo.helper.SDOHelperContext) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper) SDOXMLHelper(org.eclipse.persistence.sdo.helper.SDOXMLHelper)

Example 37 with SDOXMLHelper

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

the class LoadAndSaveTestCases method testClassGenerationLoadAndSave.

public void testClassGenerationLoadAndSave() throws Exception {
    // TODO: hard coded path should be parameterized as an option to the test suite
    String tmpDirName = tempFileDir + "/tmp/";
    File f = new File(tmpDirName);
    f.mkdir();
    f.deleteOnExit();
    generateClasses(tmpDirName);
    setUp();
    compileFiles(tmpDirName, getPackages());
    URL[] urls = new URL[1];
    urls[0] = f.toURI().toURL();
    URLClassLoader myURLLoader = new URLClassLoader(urls);
    String package1 = getPackages().get(0);
    String className = package1 + "/" + getRootInterfaceName();
    className = className.replaceAll("/", ".");
    Class<?> urlLoadedClass = myURLLoader.loadClass(className);
    ((SDOXMLHelper) xmlHelper).setLoader(new SDOClassLoader(myURLLoader, aHelperContext));
    Class<?> loadedClass2 = ((SDOXMLHelper) xmlHelper).getLoader().loadClass(className);
    defineTypes();
    assertEquals(urlLoadedClass, loadedClass2);
    FileInputStream inputStream = new FileInputStream(getControlFileName());
    XMLDocument document = xmlHelper.load(inputStream);
    Class<?> loadedClass = document.getRootObject().getType().getInstanceClass();
    assertEquals(urlLoadedClass, loadedClass);
    verifyAfterLoad(document);
    StringWriter writer = new StringWriter();
    xmlHelper.save(document, writer, null);
    compareXML(getControlWriteFileName(), writer.toString());
}
Also used : StringWriter(java.io.StringWriter) URLClassLoader(java.net.URLClassLoader) SDOClassLoader(org.eclipse.persistence.sdo.helper.SDOClassLoader) SDOXMLHelper(org.eclipse.persistence.sdo.helper.SDOXMLHelper) File(java.io.File) URL(java.net.URL) FileInputStream(java.io.FileInputStream) XMLDocument(commonj.sdo.helper.XMLDocument)

Example 38 with SDOXMLHelper

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

the class LoadAndSaveMimeTypeOnPropertyManyTestCases method setUp.

@Override
public void setUp() {
    super.setUp();
    XMLMarshaller aMarshaller = ((SDOXMLHelper) xmlHelper).getXmlMarshaller();
    XMLUnmarshaller anUnmarshaller = ((SDOXMLHelper) xmlHelper).getXmlUnmarshaller();
    XMLAttachmentMarshaller anAttachmentMarshaller = new AttachmentMarshallerImpl("c_id0");
    XMLAttachmentUnmarshaller anAttachmentUnmarshaller = new AttachmentUnmarshallerImpl("Testing".getBytes());
    aMarshaller.setAttachmentMarshaller(anAttachmentMarshaller);
    anUnmarshaller.setAttachmentUnmarshaller(anAttachmentUnmarshaller);
}
Also used : XMLMarshaller(org.eclipse.persistence.oxm.XMLMarshaller) XMLAttachmentMarshaller(org.eclipse.persistence.oxm.attachment.XMLAttachmentMarshaller) XMLUnmarshaller(org.eclipse.persistence.oxm.XMLUnmarshaller) SDOXMLHelper(org.eclipse.persistence.sdo.helper.SDOXMLHelper) XMLAttachmentUnmarshaller(org.eclipse.persistence.oxm.attachment.XMLAttachmentUnmarshaller)

Example 39 with SDOXMLHelper

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

the class LoadAndSaveMimeTypeOnXSDManyTestCases method setUp.

@Override
public void setUp() {
    super.setUp();
    XMLMarshaller aMarshaller = ((SDOXMLHelper) xmlHelper).getXmlMarshaller();
    XMLUnmarshaller anUnmarshaller = ((SDOXMLHelper) xmlHelper).getXmlUnmarshaller();
    XMLAttachmentMarshaller anAttachmentMarshaller = new AttachmentMarshallerImpl("c_id0");
    XMLAttachmentUnmarshaller anAttachmentUnmarshaller = new AttachmentUnmarshallerImpl("Testing".getBytes());
    aMarshaller.setAttachmentMarshaller(anAttachmentMarshaller);
    anUnmarshaller.setAttachmentUnmarshaller(anAttachmentUnmarshaller);
}
Also used : XMLMarshaller(org.eclipse.persistence.oxm.XMLMarshaller) XMLAttachmentMarshaller(org.eclipse.persistence.oxm.attachment.XMLAttachmentMarshaller) XMLUnmarshaller(org.eclipse.persistence.oxm.XMLUnmarshaller) SDOXMLHelper(org.eclipse.persistence.sdo.helper.SDOXMLHelper) XMLAttachmentUnmarshaller(org.eclipse.persistence.oxm.attachment.XMLAttachmentUnmarshaller)

Example 40 with SDOXMLHelper

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

the class LoadAndSaveMimeTypeOnXSDTestCases method setUp.

@Override
public void setUp() {
    super.setUp();
    XMLMarshaller aMarshaller = ((SDOXMLHelper) xmlHelper).getXmlMarshaller();
    XMLUnmarshaller anUnmarshaller = ((SDOXMLHelper) xmlHelper).getXmlUnmarshaller();
    XMLAttachmentMarshaller anAttachmentMarshaller = new AttachmentMarshallerImpl("c_id0");
    XMLAttachmentUnmarshaller anAttachmentUnmarshaller = new AttachmentUnmarshallerImpl("Testing".getBytes());
    aMarshaller.setAttachmentMarshaller(anAttachmentMarshaller);
    anUnmarshaller.setAttachmentUnmarshaller(anAttachmentUnmarshaller);
}
Also used : XMLMarshaller(org.eclipse.persistence.oxm.XMLMarshaller) XMLAttachmentMarshaller(org.eclipse.persistence.oxm.attachment.XMLAttachmentMarshaller) XMLUnmarshaller(org.eclipse.persistence.oxm.XMLUnmarshaller) SDOXMLHelper(org.eclipse.persistence.sdo.helper.SDOXMLHelper) XMLAttachmentUnmarshaller(org.eclipse.persistence.oxm.attachment.XMLAttachmentUnmarshaller)

Aggregations

SDOXMLHelper (org.eclipse.persistence.sdo.helper.SDOXMLHelper)40 SDOMarshalListener (org.eclipse.persistence.sdo.helper.SDOMarshalListener)22 SDODataObject (org.eclipse.persistence.sdo.SDODataObject)21 SDOChangeSummary (org.eclipse.persistence.sdo.SDOChangeSummary)16 XMLDocument (commonj.sdo.helper.XMLDocument)6 XMLMarshaller (org.eclipse.persistence.oxm.XMLMarshaller)6 XMLUnmarshaller (org.eclipse.persistence.oxm.XMLUnmarshaller)5 XMLAttachmentMarshaller (org.eclipse.persistence.oxm.attachment.XMLAttachmentMarshaller)5 XMLAttachmentUnmarshaller (org.eclipse.persistence.oxm.attachment.XMLAttachmentUnmarshaller)5 ArrayList (java.util.ArrayList)4 List (java.util.List)3 SDOType (org.eclipse.persistence.sdo.SDOType)3 SDOClassLoader (org.eclipse.persistence.sdo.helper.SDOClassLoader)3 SDOTypeHelper (org.eclipse.persistence.sdo.helper.SDOTypeHelper)3 DataObject (commonj.sdo.DataObject)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FileInputStream (java.io.FileInputStream)2 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)2 SDOXSDHelper (org.eclipse.persistence.sdo.helper.SDOXSDHelper)2 Type (commonj.sdo.Type)1