use of org.datanucleus.NucleusContext in project tests by datanucleus.
the class DN2NamingFactoryTest method testEmbeddedPCColumnNames.
public void testEmbeddedPCColumnNames() {
JDOPersistenceManagerFactory jdoPMF = (JDOPersistenceManagerFactory) pmf;
NucleusContext nucCtx = jdoPMF.getNucleusContext();
ClassLoaderResolver clr = nucCtx.getClassLoaderResolver(null);
MetaDataManager mmgr = nucCtx.getMetaDataManager();
DN2NamingFactory factory = new DN2NamingFactory(nucCtx);
factory.setMaximumLength(SchemaComponent.COLUMN, 128);
factory.setNamingCase(NamingCase.LOWER_CASE);
AbstractClassMetaData compCmd = mmgr.getMetaDataForClass(Computer.class, clr);
AbstractMemberMetaData graphicsMmd = compCmd.getMetaDataForMember("graphicsCard");
AbstractClassMetaData cardCmd = mmgr.getMetaDataForClass(ComputerCard.class, clr);
AbstractMemberMetaData makerMmd = cardCmd.getMetaDataForMember("makerName");
List<AbstractMemberMetaData> colMmds = new ArrayList<AbstractMemberMetaData>();
colMmds.add(graphicsMmd);
colMmds.add(makerMmd);
String colName = factory.getColumnName(colMmds, 0);
// Comes from EmbeddedMetaData override
assertEquals("graphics_maker", colName);
}
use of org.datanucleus.NucleusContext in project tests by datanucleus.
the class DN2NamingFactoryTest method testTableName.
public void testTableName() {
JDOPersistenceManagerFactory jdoPMF = (JDOPersistenceManagerFactory) pmf;
NucleusContext nucCtx = jdoPMF.getNucleusContext();
ClassLoaderResolver clr = nucCtx.getClassLoaderResolver(null);
MetaDataManager mmgr = nucCtx.getMetaDataManager();
AbstractClassMetaData cmd1 = mmgr.getMetaDataForClass(BooleanArray.class, clr);
DN2NamingFactory factory = new DN2NamingFactory(nucCtx);
factory.setMaximumLength(SchemaComponent.TABLE, 128);
factory.setNamingCase(NamingCase.LOWER_CASE);
assertEquals("Table name is incorrect", "booleanarray", factory.getTableName(cmd1));
factory.setNamingCase(NamingCase.LOWER_CASE_QUOTED);
assertEquals("Table name is incorrect", "\"booleanarray\"", factory.getTableName(cmd1));
factory.setNamingCase(NamingCase.UPPER_CASE);
assertEquals("Table name is incorrect", "BOOLEANARRAY", factory.getTableName(cmd1));
factory.setNamingCase(NamingCase.UPPER_CASE_QUOTED);
assertEquals("Table name is incorrect", "\"BOOLEANARRAY\"", factory.getTableName(cmd1));
}
use of org.datanucleus.NucleusContext 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);
}
use of org.datanucleus.NucleusContext 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);
}
use of org.datanucleus.NucleusContext 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
}
}
Aggregations