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();
}
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());
}
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);
}
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);
}
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);
}
Aggregations