Search in sources :

Example 11 with JDOMetaDataManager

use of org.datanucleus.api.jdo.metadata.JDOMetaDataManager in project datanucleus-api-jdo by datanucleus.

the class JDOMetaDataHandlerTest method testParseDefaultNamespace.

public void testParseDefaultNamespace() {
    NucleusContext nucCtx = new PersistenceNucleusContextImpl("JDO", null);
    MetaDataParser parser = new MetaDataParser(new JDOMetaDataManager(nucCtx), nucCtx.getPluginManager(), true, true);
    MetaData md = parser.parseMetaDataURL(getClass().getResource("/org/datanucleus/api/jdo/metadata/xml/package1.jdo"), "jdo");
    assertNotNull(md);
}
Also used : MetaData(org.datanucleus.metadata.MetaData) NucleusContext(org.datanucleus.NucleusContext) PersistenceNucleusContextImpl(org.datanucleus.PersistenceNucleusContextImpl) MetaDataParser(org.datanucleus.metadata.xml.MetaDataParser) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager)

Example 12 with JDOMetaDataManager

use of org.datanucleus.api.jdo.metadata.JDOMetaDataManager in project datanucleus-api-jdo by datanucleus.

the class PersistenceFileMetaDataHandlerTest method testParseNamespace.

public void testParseNamespace() {
    NucleusContext nucCtx = new PersistenceNucleusContextImpl("JDO", null);
    MetaDataParser parser = new MetaDataParser(new JDOMetaDataManager(nucCtx), nucCtx.getPluginManager(), true, true);
    MetaData md = parser.parseMetaDataURL(getClass().getResource("/org/datanucleus/api/jdo/metadata/xml/persistence2.xml"), "persistence");
    assertNotNull(md);
}
Also used : MetaData(org.datanucleus.metadata.MetaData) NucleusContext(org.datanucleus.NucleusContext) PersistenceNucleusContextImpl(org.datanucleus.PersistenceNucleusContextImpl) MetaDataParser(org.datanucleus.metadata.xml.MetaDataParser) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager)

Example 13 with JDOMetaDataManager

use of org.datanucleus.api.jdo.metadata.JDOMetaDataManager in project datanucleus-api-jdo by datanucleus.

the class MetaDataManagerTest method testLocationsForClass.

/**
 * Test of the valid locations for a specified class.
 */
public void testLocationsForClass() {
    Map startupProps = new HashMap<>();
    startupProps.put(JDOPropertyNames.PROPERTY_METADATA_XML_JDO_1_0, "true");
    JDOMetaDataManager mgr = new JDOMetaDataManager(new PersistenceNucleusContextImpl("JDO", startupProps));
    // Try typical JDO class name
    String className = "org.jpox.samples.store.Product";
    List locations = mgr.getValidMetaDataLocationsForClass("jdo", null, className);
    assertTrue("Locations returned from MetaData Manager was null!", locations != null);
    List validLocations = new ArrayList();
    validLocations.add("/META-INF/package.jdo");
    validLocations.add("/WEB-INF/package.jdo");
    validLocations.add("/package.jdo");
    validLocations.add("/org.jdo");
    validLocations.add("/org/package.jdo");
    validLocations.add("/org/jpox.jdo");
    validLocations.add("/org/jpox/package.jdo");
    validLocations.add("/org/jpox/samples.jdo");
    validLocations.add("/org/jpox/samples/package.jdo");
    validLocations.add("/org/jpox/samples/store.jdo");
    validLocations.add("/org/jpox/samples/store/package.jdo");
    validLocations.add("/org/jpox/samples/store/Product.jdo");
    checkLocations(className, locations, validLocations);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PersistenceNucleusContextImpl(org.datanucleus.PersistenceNucleusContextImpl) List(java.util.List) ArrayList(java.util.ArrayList) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) Map(java.util.Map) HashMap(java.util.HashMap)

Example 14 with JDOMetaDataManager

use of org.datanucleus.api.jdo.metadata.JDOMetaDataManager in project datanucleus-api-jdo by datanucleus.

the class MetaDataParserTest method testParseMetaDataURLnullURL.

public void testParseMetaDataURLnullURL() {
    NucleusContext nucCtx = new PersistenceNucleusContextImpl("JDO", null);
    MetaDataParser parser = new MetaDataParser(new JDOMetaDataManager(nucCtx), nucCtx.getPluginManager(), true, true);
    try {
        parser.parseMetaDataURL(null, "jdo");
        fail("expected JPOXException");
    } catch (NucleusException ex) {
    // expected
    }
}
Also used : NucleusContext(org.datanucleus.NucleusContext) PersistenceNucleusContextImpl(org.datanucleus.PersistenceNucleusContextImpl) MetaDataParser(org.datanucleus.metadata.xml.MetaDataParser) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) NucleusException(org.datanucleus.exceptions.NucleusException)

Example 15 with JDOMetaDataManager

use of org.datanucleus.api.jdo.metadata.JDOMetaDataManager in project datanucleus-api-jdo by datanucleus.

the class MetaDataParserTest method testParseMetaDataURLnullhandler.

public void testParseMetaDataURLnullhandler() {
    NucleusContext nucCtx = new PersistenceNucleusContextImpl("JDO", null);
    MetaDataParser parser = new MetaDataParser(new JDOMetaDataManager(nucCtx), nucCtx.getPluginManager(), true, true);
    try {
        parser.parseMetaDataURL(getClass().getResource("/org/datanucleus/api/jdo/metadata/xml/package2.jdo"), null);
        fail("expected JPOXException");
    } catch (NucleusException ex) {
    // expected
    }
}
Also used : NucleusContext(org.datanucleus.NucleusContext) PersistenceNucleusContextImpl(org.datanucleus.PersistenceNucleusContextImpl) MetaDataParser(org.datanucleus.metadata.xml.MetaDataParser) JDOMetaDataManager(org.datanucleus.api.jdo.metadata.JDOMetaDataManager) NucleusException(org.datanucleus.exceptions.NucleusException)

Aggregations

JDOMetaDataManager (org.datanucleus.api.jdo.metadata.JDOMetaDataManager)28 PersistenceNucleusContextImpl (org.datanucleus.PersistenceNucleusContextImpl)27 ClassLoaderResolverImpl (org.datanucleus.ClassLoaderResolverImpl)20 MetaDataManager (org.datanucleus.metadata.MetaDataManager)17 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)16 MetaDataParser (org.datanucleus.metadata.xml.MetaDataParser)8 NucleusContext (org.datanucleus.NucleusContext)7 FetchPlan (org.datanucleus.FetchPlan)5 FetchPlanForClass (org.datanucleus.FetchPlanForClass)5 JDOFetchPlan (org.datanucleus.api.jdo.JDOFetchPlan)5 ArrayList (java.util.ArrayList)4 BitSet (java.util.BitSet)4 MetaData (org.datanucleus.metadata.MetaData)4 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 NucleusException (org.datanucleus.exceptions.NucleusException)2 FileMetaData (org.datanucleus.metadata.FileMetaData)2 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1