Search in sources :

Example 1 with JDOMetaDataHelper

use of org.datanucleus.api.jdo.metadata.JDOMetaDataHelper in project tests by datanucleus.

the class BasicTest method testMetaDataManagerI18N.

/**
 * Test for the MetaDataManager.
 */
public void testMetaDataManagerI18N() {
    JDOMetaDataHelper mdProc = new JDOMetaDataHelper();
    String filename = "/org/jpox/samples/i18n/UTF8.jdo";
    MetaDataManager mmgr1 = new JDOMetaDataManager(new PersistenceNucleusContextImpl("JDO", null));
    MetaDataParser parser1 = new MetaDataParser(mmgr1, mmgr1.getNucleusContext().getPluginManager(), true, true);
    mmgr1.setValidate(false);
    FileMetaData fmd = (FileMetaData) parser1.parseMetaDataStream(MetaDataParser.class.getResourceAsStream(filename), filename, "jdo");
    fmd.getPackage("org.jpox.samples.i18n").getClass("UTF8");
    org.datanucleus.metadata.AbstractClassMetaData cmd1 = fmd.getPackage("org.jpox.samples.i18n").getClass("UTF8");
    cmd1.populate(new ClassLoaderResolverImpl(), null, mmgr1);
    cmd1.initialise(new ClassLoaderResolverImpl());
    MetaDataManager mmgr2 = new JDOMetaDataManager(new PersistenceNucleusContextImpl("JDO", null));
    mmgr2.setValidate(false);
    org.datanucleus.metadata.AbstractClassMetaData cmd = mmgr2.getMetaDataForClass(UTF8.class, new ClassLoaderResolverImpl());
    if (!mdProc.getXMLForMetaData(cmd, "", "").equals(mdProc.getXMLForMetaData(cmd1, "", ""))) {
        fail("i18n UTF-8 issues in parser");
    }
    filename = "/org/jpox/samples/i18n/ISO8859_2.jdo";
    MetaDataManager mmgr3 = new JDOMetaDataManager(new PersistenceNucleusContextImpl("JDO", null));
    MetaDataParser parser3 = new MetaDataParser(mmgr3, mmgr3.getNucleusContext().getPluginManager(), true, true);
    mmgr3.setValidate(false);
    fmd = (FileMetaData) parser3.parseMetaDataStream(MetaDataParser.class.getResourceAsStream(filename), filename, "jdo");
    fmd.getPackage("org.jpox.samples.i18n").getClass("ISO8859_2");
    MetaDataManager mmgr4 = new JDOMetaDataManager(new PersistenceNucleusContextImpl("JDO", null));
    mmgr4.setValidate(false);
    cmd1 = fmd.getPackage("org.jpox.samples.i18n").getClass("ISO8859_2");
    cmd1.populate(new ClassLoaderResolverImpl(), null, mmgr4);
    cmd1.initialise(null);
    cmd = mmgr4.getMetaDataForClass(ISO8859_2.class, new ClassLoaderResolverImpl());
    if (!mdProc.getXMLForMetaData(cmd, "", "").equals(mdProc.getXMLForMetaData(cmd1, "", ""))) {
        fail("i18n ISO8859_2 issues in parser");
    }
}
Also used : JDOMetaDataHelper(org.datanucleus.api.jdo.metadata.JDOMetaDataHelper) ISO8859_2(org.jpox.samples.i18n.ISO8859_2) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) MetaDataManager(org.datanucleus.metadata.MetaDataManager) PersistenceNucleusContextImpl(org.datanucleus.PersistenceNucleusContextImpl) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) MetaDataParser(org.datanucleus.metadata.xml.MetaDataParser) FileMetaData(org.datanucleus.metadata.FileMetaData) AbstractClassMetaData(org.datanucleus.metadata.AbstractClassMetaData) ClassLoaderResolverImpl(org.datanucleus.ClassLoaderResolverImpl)

Aggregations

ClassLoaderResolverImpl (org.datanucleus.ClassLoaderResolverImpl)1 PersistenceNucleusContextImpl (org.datanucleus.PersistenceNucleusContextImpl)1 JDOMetaDataHelper (org.datanucleus.api.jdo.metadata.JDOMetaDataHelper)1 JDOMetaDataManager (org.datanucleus.api.jdo.metadata.JDOMetaDataManager)1 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)1 FileMetaData (org.datanucleus.metadata.FileMetaData)1 MetaDataManager (org.datanucleus.metadata.MetaDataManager)1 MetaDataParser (org.datanucleus.metadata.xml.MetaDataParser)1 ISO8859_2 (org.jpox.samples.i18n.ISO8859_2)1