Search in sources :

Example 41 with PersistenceNucleusContextImpl

use of org.datanucleus.PersistenceNucleusContextImpl 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 42 with PersistenceNucleusContextImpl

use of org.datanucleus.PersistenceNucleusContextImpl 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)

Example 43 with PersistenceNucleusContextImpl

use of org.datanucleus.PersistenceNucleusContextImpl in project datanucleus-api-jdo by datanucleus.

the class JDOMetaDataHandlerTest 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/package2.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 44 with PersistenceNucleusContextImpl

use of org.datanucleus.PersistenceNucleusContextImpl in project datanucleus-api-jdo by datanucleus.

the class PersistenceFileMetaDataHandlerTest 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/persistence1.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 45 with PersistenceNucleusContextImpl

use of org.datanucleus.PersistenceNucleusContextImpl in project datanucleus-api-jdo by datanucleus.

the class MetaDataManagerTest method testLocationsForPackage.

/**
 * Test of the valid locations for a specified package.
 */
public void testLocationsForPackage() {
    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 package name
    String packageName = "org.jpox.samples";
    List locations = mgr.getValidMetaDataLocationsForPackage("jdo", null, packageName);
    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");
    checkLocations(packageName, locations, validLocations);
    // Try 1 level package name
    packageName = "org";
    locations = mgr.getValidMetaDataLocationsForPackage("jdo", null, packageName);
    assertTrue("Locations returned from MetaData Manager was null!", locations != null);
    validLocations.clear();
    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");
    checkLocations(packageName, locations, validLocations);
    // Try 0 level package name
    packageName = "";
    locations = mgr.getValidMetaDataLocationsForPackage("jdo", null, packageName);
    assertTrue("Locations returned from MetaData Manager was null!", locations != null);
    validLocations.clear();
    validLocations.add("/META-INF/package.jdo");
    validLocations.add("/WEB-INF/package.jdo");
    validLocations.add("/package.jdo");
    checkLocations(packageName, locations, validLocations);
    // Try typical ORM package name
    packageName = "org.jpox.samples";
    locations = mgr.getValidMetaDataLocationsForPackage("orm", "jpox", packageName);
    assertTrue("Locations returned from MetaData Manager was null!", locations != null);
    validLocations.clear();
    validLocations.add("/META-INF/package-jpox.orm");
    validLocations.add("/WEB-INF/package-jpox.orm");
    validLocations.add("/package-jpox.orm");
    validLocations.add("/org-jpox.orm");
    validLocations.add("/org/package-jpox.orm");
    validLocations.add("/org/jpox-jpox.orm");
    validLocations.add("/org/jpox/package-jpox.orm");
    validLocations.add("/org/jpox/samples-jpox.orm");
    validLocations.add("/org/jpox/samples/package-jpox.orm");
    checkLocations(packageName, 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)

Aggregations

PersistenceNucleusContextImpl (org.datanucleus.PersistenceNucleusContextImpl)86 MetaDataManager (org.datanucleus.metadata.MetaDataManager)69 NucleusContext (org.datanucleus.NucleusContext)59 ClassLoaderResolver (org.datanucleus.ClassLoaderResolver)56 JPAMetaDataManager (org.datanucleus.api.jpa.metadata.JPAMetaDataManager)51 ClassMetaData (org.datanucleus.metadata.ClassMetaData)51 PersistenceUnitMetaData (org.datanucleus.metadata.PersistenceUnitMetaData)40 ClassLoaderResolverImpl (org.datanucleus.ClassLoaderResolverImpl)35 AbstractMemberMetaData (org.datanucleus.metadata.AbstractMemberMetaData)32 JDOMetaDataManager (org.datanucleus.api.jdo.metadata.JDOMetaDataManager)29 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)18 ElementMetaData (org.datanucleus.metadata.ElementMetaData)12 JoinMetaData (org.datanucleus.metadata.JoinMetaData)10 ColumnMetaData (org.datanucleus.metadata.ColumnMetaData)7 MetaDataParser (org.datanucleus.metadata.xml.MetaDataParser)7 PackageMetaData (org.datanucleus.metadata.PackageMetaData)6 FetchPlan (org.datanucleus.FetchPlan)5 FetchPlanForClass (org.datanucleus.FetchPlanForClass)5 JDOFetchPlan (org.datanucleus.api.jdo.JDOFetchPlan)5 ArrayList (java.util.ArrayList)4