use of org.datanucleus.ClassLoaderResolverImpl in project tests by datanucleus.
the class AnnotationTest method testIdClassAccessors.
/**
* Test of JPA @IdClass with pk using acessors.
*/
public void testIdClassAccessors() {
NucleusContext nucleusCtx = new PersistenceNucleusContextImpl("JPA", null);
MetaDataManager metaDataMgr = new JPAMetaDataManager(nucleusCtx);
ClassLoaderResolver clr = new ClassLoaderResolverImpl();
ClassMetaData cmd1 = (ClassMetaData) metaDataMgr.getMetaDataForClass(IdClassAccessors.class.getName(), clr);
assertEquals(1, cmd1.getNoOfPrimaryKeyMembers());
assertTrue(cmd1.getAbsolutePositionOfMember("free") >= 0);
assertEquals("FFFF", cmd1.getMetaDataForManagedMemberAtAbsolutePosition(cmd1.getRelativePositionOfMember("free")).getColumnMetaData()[0].getName());
}
use of org.datanucleus.ClassLoaderResolverImpl in project tests by datanucleus.
the class AnnotationTest method testOrderBy.
/**
* Test of @OrderBy.
*/
public void testOrderBy() {
NucleusContext nucleusCtx = new PersistenceNucleusContextImpl("JPA", null);
MetaDataManager metaDataMgr = new JPAMetaDataManager(nucleusCtx);
ClassLoaderResolver clr = new ClassLoaderResolverImpl();
ClassMetaData cmd1 = (ClassMetaData) metaDataMgr.getMetaDataForClass(UserGroup.class.getName(), clr);
OrderMetaData omd = cmd1.getMetaDataForMember("members").getOrderMetaData();
assertNotNull("UserGroup.members has no OrderMetaData!", omd);
FieldOrder[] orderTerms = omd.getFieldOrders();
assertFalse("UserGroup.members is not marked as using an ordered list", omd.isIndexedList());
assertNotNull("UserGroup.members has null field ordering info", orderTerms);
assertEquals("UserGroup.members has incorrect number of field ordering terms", orderTerms.length, 1);
assertEquals("UserGroup.members has incorrect field ordering field-name", orderTerms[0].getFieldName(), "name");
assertTrue("UserGroup.members has incorrect field ordering direction", orderTerms[0].isForward());
}
use of org.datanucleus.ClassLoaderResolverImpl in project tests by datanucleus.
the class AnnotationTest method testEmbeddedId.
/**
* Test of basic JPA @EmbeddedId.
*/
public void testEmbeddedId() {
NucleusContext nucleusCtx = new PersistenceNucleusContextImpl("JPA", null);
MetaDataManager metaDataMgr = new JPAMetaDataManager(nucleusCtx);
// Retrieve the metadata from the MetaDataManager (populates and initialises everything)
ClassLoaderResolver clr = new ClassLoaderResolverImpl();
ClassMetaData cmd1 = (ClassMetaData) metaDataMgr.getMetaDataForClass(Department.class.getName(), clr);
assertEquals(1, cmd1.getNoOfPrimaryKeyMembers());
}
use of org.datanucleus.ClassLoaderResolverImpl in project tests by datanucleus.
the class AnnotationTest method testColumnLength.
/**
* Test of JPA column length
*/
public void testColumnLength() {
NucleusContext nucleusCtx = new PersistenceNucleusContextImpl("JPA", null);
MetaDataManager metaDataMgr = new JPAMetaDataManager(nucleusCtx);
// Retrieve the metadata from the MetaDataManager (populates and initialises everything)
ClassLoaderResolver clr = new ClassLoaderResolverImpl();
ClassMetaData cmd1 = (ClassMetaData) metaDataMgr.getMetaDataForClass(Printer.class.getName(), clr);
AbstractMemberMetaData fmd = cmd1.getMetaDataForMember("make");
assertEquals(fmd.getColumnMetaData().length, 1);
assertEquals(fmd.getColumnMetaData()[0].getName(), "MAKE");
assertEquals(40, fmd.getColumnMetaData()[0].getLength().intValue());
}
use of org.datanucleus.ClassLoaderResolverImpl in project tests by datanucleus.
the class AnnotationTest method testEnumeratedJDBCType.
/**
* Test of JPA enumerated JDBC type.
*/
public void testEnumeratedJDBCType() {
NucleusContext nucleusCtx = new PersistenceNucleusContextImpl("JPA", null);
MetaDataManager metaDataMgr = new JPAMetaDataManager(nucleusCtx);
ClassLoaderResolver clr = new ClassLoaderResolverImpl();
ClassMetaData cmd1 = (ClassMetaData) metaDataMgr.getMetaDataForClass(EnumHolder.class.getName(), clr);
AbstractMemberMetaData mmd1 = cmd1.getMetaDataForMember("colour1");
assertEquals(JdbcType.INTEGER, mmd1.getColumnMetaData()[0].getJdbcType());
assertEquals(FieldPersistenceModifier.PERSISTENT, mmd1.getPersistenceModifier());
AbstractMemberMetaData mmd2 = cmd1.getMetaDataForMember("colour2");
assertEquals(JdbcType.VARCHAR, mmd2.getColumnMetaData()[0].getJdbcType());
assertEquals(FieldPersistenceModifier.PERSISTENT, mmd2.getPersistenceModifier());
}
Aggregations