use of org.datanucleus.metadata.MetaDataManager in project tests by datanucleus.
the class JPANamingFactoryTest method testTableName.
public void testTableName() {
JPAEntityManagerFactory jpaEMF = (JPAEntityManagerFactory) emf;
NucleusContext nucCtx = jpaEMF.getNucleusContext();
ClassLoaderResolver clr = nucCtx.getClassLoaderResolver(null);
MetaDataManager mmgr = nucCtx.getMetaDataManager();
AbstractClassMetaData cmd1 = mmgr.getMetaDataForClass(ByteArray.class, clr);
NamingFactory factory = new JPANamingFactory(nucCtx);
factory.setMaximumLength(SchemaComponent.TABLE, 128);
factory.setNamingCase(NamingCase.LOWER_CASE);
assertEquals("Table name is incorrect", "bytearray", factory.getTableName(cmd1));
factory.setNamingCase(NamingCase.LOWER_CASE_QUOTED);
assertEquals("Table name is incorrect", "\"bytearray\"", factory.getTableName(cmd1));
factory.setNamingCase(NamingCase.UPPER_CASE);
assertEquals("Table name is incorrect", "BYTEARRAY", factory.getTableName(cmd1));
factory.setNamingCase(NamingCase.UPPER_CASE_QUOTED);
assertEquals("Table name is incorrect", "\"BYTEARRAY\"", factory.getTableName(cmd1));
AbstractClassMetaData cmd2 = mmgr.getMetaDataForClass(SimpleClass.class, clr);
factory.setNamingCase(NamingCase.LOWER_CASE);
assertEquals("Table name is incorrect", "mysimpleclass", factory.getTableName(cmd2));
}
use of org.datanucleus.metadata.MetaDataManager in project tests by datanucleus.
the class DN2NamingFactoryTest method testVersionColumnName.
public void testVersionColumnName() {
JDOPersistenceManagerFactory jdoPMF = (JDOPersistenceManagerFactory) pmf;
NucleusContext nucCtx = jdoPMF.getNucleusContext();
ClassLoaderResolver clr = nucCtx.getClassLoaderResolver(null);
MetaDataManager mmgr = nucCtx.getMetaDataManager();
AbstractClassMetaData cmd1 = mmgr.getMetaDataForClass(Trade1.class, clr);
DN2NamingFactory factory = new DN2NamingFactory(nucCtx);
factory.setMaximumLength(SchemaComponent.COLUMN, 128);
factory.setNamingCase(NamingCase.LOWER_CASE);
assertEquals("Column name for version is incorrect", "version", factory.getColumnName(cmd1, ColumnType.VERSION_COLUMN));
}
use of org.datanucleus.metadata.MetaDataManager 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.metadata.MetaDataManager 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.metadata.MetaDataManager in project tests by datanucleus.
the class BasicTest method testDependent.
/**
* Test for defaulting of "dependent" attribute on a field and on a collection.
*/
public void testDependent() {
MetaDataManager mgr = new JDOMetaDataManager(new PersistenceNucleusContextImpl("JDO", null));
mgr.setValidate(false);
AbstractClassMetaData cmdInh2 = mgr.getMetaDataForClass(Container.class, new ClassLoaderResolverImpl());
AbstractMemberMetaData fmd = cmdInh2.getMetaDataForMember("members");
// mmd doesn't have dependent attribute, so should default to false
assertFalse(fmd.isDependent());
assertFalse(fmd.getCollection().isDependentElement());
}
Aggregations