Package org.datanucleus.metadata.xml

Examples of org.datanucleus.metadata.xml.MetaDataParser


public class MetaDataParserTest extends TestCase
{
    public void testParseMetaDataURLnullURL()
    {
        MetaDataParser parser = new MetaDataParser(
            new JDOMetaDataManager(new NucleusContext("JDO", null)),true);
        try
        {
            parser.parseMetaDataURL(null, "jdo");
            fail("expected JPOXException");
        }
        catch(NucleusException ex)
        {
            //expected
View Full Code Here


        }
    }

    public void testParseMetaDataURLnullhandler()
    {
        MetaDataParser parser = new MetaDataParser(
            new JDOMetaDataManager(new NucleusContext("JDO", null)),true);
        try
        {
            parser.parseMetaDataURL(getClass().getResource("/org/datanucleus/api/jdo/metadata/xml/package2.jdo"), null);
            fail("expected JPOXException");
        }
        catch(NucleusException ex)
        {
            //expected
View Full Code Here

public class PersistenceFileMetaDataHandlerTest extends TestCase
{
    public void testParseDefaultNamespace()
    {
        MetaDataParser parser = new MetaDataParser(
            new JDOMetaDataManager(new NucleusContext("JDO", null)),true);
        MetaData md = parser.parseMetaDataURL(getClass().getResource("/org/datanucleus/api/jdo/metadata/xml/persistence1.xml"), "persistence");
        assertNotNull(md);
    }
View Full Code Here

        assertNotNull(md);
    }

    public void testParseNamespace()
    {
        MetaDataParser parser = new MetaDataParser(
            new JDOMetaDataManager(new NucleusContext("JDO", null)),true);
        MetaData md = parser.parseMetaDataURL(getClass().getResource("/org/datanucleus/api/jdo/metadata/xml/persistence2.xml"), "persistence");
        assertNotNull(md);
    }
View Full Code Here

public class JDOMetaDataHandlerTest extends TestCase
{
    public void testParseDefaultNamespace()
    {
        MetaDataParser parser = new MetaDataParser(
            new JDOMetaDataManager(new NucleusContext("JDO", null)),true);
        MetaData md = parser.parseMetaDataURL(getClass().getResource("/org/datanucleus/api/jdo/metadata/xml/package1.jdo"), "jdo");
        assertNotNull(md);
    }
View Full Code Here

        assertNotNull(md);
    }

    public void testParseNamespace()
    {
        MetaDataParser parser = new MetaDataParser(
            new JDOMetaDataManager(new NucleusContext("JDO", null)),true);
        MetaData md = parser.parseMetaDataURL(getClass().getResource("/org/datanucleus/api/jdo/metadata/xml/package2.jdo"), "jdo");
        assertNotNull(md);
    }
View Full Code Here

     */
    protected FileMetaData parseFile(URL fileURL)
    {
        if (metaDataParser == null)
        {
            metaDataParser = new MetaDataParser(this, validateMetaData);
        }
        return (FileMetaData)metaDataParser.parseMetaDataURL(fileURL, "jpa");
    }
View Full Code Here

            try
            {
                URL fileURL = new URL(filename);
                if (metaDataParser == null)
                {
                    metaDataParser = new MetaDataParser(this, validateMetaData);
                }
                MetaData permd = metaDataParser.parseMetaDataURL(fileURL, "persistence");
                return new PersistenceFileMetaData[] {(PersistenceFileMetaData)permd};
            }
            catch (MalformedURLException mue)
            {
                // User provided file is not found
                NucleusLogger.METADATA.error("Error reading user-specified persistence.xml file " + filename, mue);
            }
        }

        HashSet metadata = new HashSet();
        ClassLoaderResolver clr = nucleusContext.getClassLoaderResolver(null);
        try
        {
            // Find all "META-INF/persistence.xml" files in the CLASSPATH of the current thread
            Enumeration files = clr.getResources("META-INF/persistence.xml",
                Thread.currentThread().getContextClassLoader());
            if (!files.hasMoreElements())
            {
                return null;
            }

            for ( ; files.hasMoreElements() ;)
            {
                // Parse the "persistence.xml"
                URL fileURL = (URL)files.nextElement();
                if (metaDataParser == null)
                {
                    metaDataParser = new MetaDataParser(this, validateMetaData);
                }
                MetaData permd = metaDataParser.parseMetaDataURL(fileURL, "persistence");
                metadata.add(permd);
            }
        }
View Full Code Here

     */
    protected FileMetaData parseFile(URL fileURL)
    {
        if (metaDataParser == null)
        {
            metaDataParser = new MetaDataParser(this, validateMetaData);
        }
        return (FileMetaData)metaDataParser.parseMetaDataURL(fileURL, "jdo");
    }
View Full Code Here

            throw new IllegalArgumentException("Contents of file is null");
        }

        NucleusContext context = new NucleusContext("JDO", NucleusContext.ContextType.ENHANCEMENT, null);
        MetaDataManager mgr = new JDOMetaDataManager(context);
        MetaDataParser parser = new MetaDataParser(mgr, true);
        JDOClassLoaderResolver clr = new JDOClassLoaderResolver();

        // Parse the MetaData
        FileMetaData filemd = (FileMetaData)parser.parseMetaDataStream(
            new ByteArrayInputStream(jdoXmlContents.getBytes()), null, "JDO");
        if (filemd == null)
        {
            return null;
        }
View Full Code Here

TOP

Related Classes of org.datanucleus.metadata.xml.MetaDataParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.